diff --git a/.changeset/export-manager-class-types.md b/.changeset/export-manager-class-types.md new file mode 100644 index 00000000000..42f84f3b9d1 --- /dev/null +++ b/.changeset/export-manager-class-types.md @@ -0,0 +1,5 @@ +--- +'@tanstack/query-core': minor +--- + +Export the `FocusManager`, `OnlineManager`, and `TimeoutManager` types so their methods appear in the generated reference docs. diff --git a/docs/config.json b/docs/config.json index ff82b31c171..9bbeb14325c 100644 --- a/docs/config.json +++ b/docs/config.json @@ -970,56 +970,7 @@ }, { "label": "API Reference", - "children": [ - { - "label": "QueryClient", - "to": "reference/QueryClient" - }, - { - "label": "QueryCache", - "to": "reference/QueryCache" - }, - { - "label": "MutationCache", - "to": "reference/MutationCache" - }, - { - "label": "QueryObserver", - "to": "reference/QueryObserver" - }, - { - "label": "InfiniteQueryObserver", - "to": "reference/InfiniteQueryObserver" - }, - { - "label": "QueriesObserver", - "to": "reference/QueriesObserver" - }, - { - "label": "streamedQuery", - "to": "reference/streamedQuery" - }, - { - "label": "focusManager", - "to": "reference/focusManager" - }, - { - "label": "onlineManager", - "to": "reference/onlineManager" - }, - { - "label": "environmentManager", - "to": "reference/environmentManager" - }, - { - "label": "notifyManager", - "to": "reference/notifyManager" - }, - { - "label": "timeoutManager", - "to": "reference/timeoutManager" - } - ], + "children": [], "frameworks": [ { "label": "react", @@ -1029,1274 +980,5222 @@ "to": "framework/react/reference/index" }, { - "label": "Functions / useQuery", - "to": "framework/react/reference/functions/useQuery" + "label": "Functions / HydrationBoundary", + "to": "framework/react/reference/functions/HydrationBoundary" }, { - "label": "Functions / useQueries", - "to": "framework/react/reference/functions/useQueries" + "label": "Functions / QueryClientProvider", + "to": "framework/react/reference/functions/QueryClientProvider" }, { - "label": "Functions / useInfiniteQuery", - "to": "framework/react/reference/functions/useInfiniteQuery" + "label": "Functions / QueryErrorResetBoundary", + "to": "framework/react/reference/functions/QueryErrorResetBoundary" }, { - "label": "Functions / useMutation", - "to": "framework/react/reference/functions/useMutation" + "label": "Functions / defaultShouldDehydrateMutation", + "to": "framework/react/reference/functions/defaultShouldDehydrateMutation" }, { - "label": "Functions / useIsFetching", - "to": "framework/react/reference/functions/useIsFetching" + "label": "Functions / defaultShouldDehydrateQuery", + "to": "framework/react/reference/functions/defaultShouldDehydrateQuery" }, { - "label": "Functions / useIsMutating", - "to": "framework/react/reference/functions/useIsMutating" + "label": "Functions / dehydrate", + "to": "framework/react/reference/functions/dehydrate" }, { - "label": "Functions / useMutationState", - "to": "framework/react/reference/functions/useMutationState" + "label": "Functions / dehydrateQuery", + "to": "framework/react/reference/functions/dehydrateQuery" }, { - "label": "Functions / useSuspenseQuery", - "to": "framework/react/reference/functions/useSuspenseQuery" + "label": "Functions / experimental_streamedQuery", + "to": "framework/react/reference/functions/experimental_streamedQuery" }, { - "label": "Functions / useSuspenseInfiniteQuery", - "to": "framework/react/reference/functions/useSuspenseInfiniteQuery" + "label": "Functions / hashKey", + "to": "framework/react/reference/functions/hashKey" }, { - "label": "Functions / useSuspenseQueries", - "to": "framework/react/reference/functions/useSuspenseQueries" + "label": "Functions / hydrate", + "to": "framework/react/reference/functions/hydrate" }, { - "label": "Functions / QueryClientProvider", - "to": "framework/react/reference/functions/QueryClientProvider" + "label": "Functions / infiniteQueryOptions", + "to": "framework/react/reference/functions/infiniteQueryOptions" }, { - "label": "Functions / useQueryClient", - "to": "framework/react/reference/functions/useQueryClient" + "label": "Functions / isCancelledError", + "to": "framework/react/reference/functions/isCancelledError" }, { - "label": "Functions / queryOptions", - "to": "framework/react/reference/functions/queryOptions" + "label": "Functions / keepPreviousData", + "to": "framework/react/reference/functions/keepPreviousData" }, { - "label": "Functions / infiniteQueryOptions", - "to": "framework/react/reference/functions/infiniteQueryOptions" + "label": "Functions / matchMutation", + "to": "framework/react/reference/functions/matchMutation" + }, + { + "label": "Functions / matchQuery", + "to": "framework/react/reference/functions/matchQuery" }, { "label": "Functions / mutationOptions", "to": "framework/react/reference/functions/mutationOptions" }, { - "label": "Functions / usePrefetchQuery", - "to": "framework/react/reference/functions/usePrefetchQuery" + "label": "Functions / noop", + "to": "framework/react/reference/functions/noop" }, { - "label": "Functions / usePrefetchInfiniteQuery", - "to": "framework/react/reference/functions/usePrefetchInfiniteQuery" + "label": "Functions / partialMatchKey", + "to": "framework/react/reference/functions/partialMatchKey" }, { - "label": "Functions / QueryErrorResetBoundary", - "to": "framework/react/reference/functions/QueryErrorResetBoundary" + "label": "Functions / queryOptions", + "to": "framework/react/reference/functions/queryOptions" }, { - "label": "Functions / useQueryErrorResetBoundary", - "to": "framework/react/reference/functions/useQueryErrorResetBoundary" + "label": "Functions / replaceEqualDeep", + "to": "framework/react/reference/functions/replaceEqualDeep" }, { - "label": "Functions / HydrationBoundary", - "to": "framework/react/reference/functions/HydrationBoundary" + "label": "Functions / shouldThrowError", + "to": "framework/react/reference/functions/shouldThrowError" }, { - "label": "Functions / useIsRestoring", - "to": "framework/react/reference/functions/useIsRestoring" + "label": "Functions / useInfiniteQuery", + "to": "framework/react/reference/functions/useInfiniteQuery" }, { - "label": "Interfaces / HydrationBoundaryProps", - "to": "framework/react/reference/interfaces/HydrationBoundaryProps" + "label": "Functions / useIsFetching", + "to": "framework/react/reference/functions/useIsFetching" }, { - "label": "Interfaces / QueryErrorResetBoundaryProps", - "to": "framework/react/reference/interfaces/QueryErrorResetBoundaryProps" + "label": "Functions / useIsMutating", + "to": "framework/react/reference/functions/useIsMutating" }, { - "label": "Interfaces / UseBaseQueryOptions", - "to": "framework/react/reference/interfaces/UseBaseQueryOptions" + "label": "Functions / useIsRestoring", + "to": "framework/react/reference/functions/useIsRestoring" }, { - "label": "Interfaces / UseInfiniteQueryOptions", - "to": "framework/react/reference/interfaces/UseInfiniteQueryOptions" + "label": "Functions / useMutation", + "to": "framework/react/reference/functions/useMutation" }, { - "label": "Interfaces / UseMutationOptions", - "to": "framework/react/reference/interfaces/UseMutationOptions" + "label": "Functions / useMutationState", + "to": "framework/react/reference/functions/useMutationState" }, { - "label": "Interfaces / UseQueryOptions", - "to": "framework/react/reference/interfaces/UseQueryOptions" + "label": "Functions / usePrefetchInfiniteQuery", + "to": "framework/react/reference/functions/usePrefetchInfiniteQuery" }, { - "label": "Interfaces / UseSuspenseInfiniteQueryOptions", - "to": "framework/react/reference/interfaces/UseSuspenseInfiniteQueryOptions" + "label": "Functions / usePrefetchQuery", + "to": "framework/react/reference/functions/usePrefetchQuery" }, { - "label": "Interfaces / UseSuspenseQueryOptions", - "to": "framework/react/reference/interfaces/UseSuspenseQueryOptions" + "label": "Functions / useQueries", + "to": "framework/react/reference/functions/useQueries" }, { - "label": "Types / AnyUseBaseQueryOptions", - "to": "framework/react/reference/type-aliases/AnyUseBaseQueryOptions" + "label": "Functions / useQuery", + "to": "framework/react/reference/functions/useQuery" }, { - "label": "Types / AnyUseInfiniteQueryOptions", - "to": "framework/react/reference/type-aliases/AnyUseInfiniteQueryOptions" + "label": "Functions / useQueryClient", + "to": "framework/react/reference/functions/useQueryClient" }, { - "label": "Types / AnyUseMutationOptions", - "to": "framework/react/reference/type-aliases/AnyUseMutationOptions" + "label": "Functions / useQueryErrorResetBoundary", + "to": "framework/react/reference/functions/useQueryErrorResetBoundary" }, { - "label": "Types / AnyUseQueryOptions", - "to": "framework/react/reference/type-aliases/AnyUseQueryOptions" + "label": "Functions / useSuspenseInfiniteQuery", + "to": "framework/react/reference/functions/useSuspenseInfiniteQuery" }, { - "label": "Types / AnyUseSuspenseInfiniteQueryOptions", - "to": "framework/react/reference/type-aliases/AnyUseSuspenseInfiniteQueryOptions" + "label": "Functions / useSuspenseQueries", + "to": "framework/react/reference/functions/useSuspenseQueries" }, { - "label": "Types / AnyUseSuspenseQueryOptions", - "to": "framework/react/reference/type-aliases/AnyUseSuspenseQueryOptions" + "label": "Functions / useSuspenseQuery", + "to": "framework/react/reference/functions/useSuspenseQuery" }, { - "label": "Types / DefinedInitialDataInfiniteOptions", - "to": "framework/react/reference/type-aliases/DefinedInitialDataInfiniteOptions" + "label": "Classes / CancelledError", + "to": "framework/react/reference/classes/CancelledError" }, { - "label": "Types / DefinedInitialDataOptions", - "to": "framework/react/reference/type-aliases/DefinedInitialDataOptions" + "label": "Classes / InfiniteQueryObserver", + "to": "framework/react/reference/classes/InfiniteQueryObserver" }, { - "label": "Types / DefinedUseInfiniteQueryResult", - "to": "framework/react/reference/type-aliases/DefinedUseInfiniteQueryResult" + "label": "Classes / Mutation", + "to": "framework/react/reference/classes/Mutation" }, { - "label": "Types / DefinedUseQueryResult", - "to": "framework/react/reference/type-aliases/DefinedUseQueryResult" + "label": "Classes / MutationCache", + "to": "framework/react/reference/classes/MutationCache" }, { - "label": "Types / QueriesOptions", - "to": "framework/react/reference/type-aliases/QueriesOptions" + "label": "Classes / MutationObserver", + "to": "framework/react/reference/classes/MutationObserver" }, { - "label": "Types / QueriesResults", - "to": "framework/react/reference/type-aliases/QueriesResults" + "label": "Classes / QueriesObserver", + "to": "framework/react/reference/classes/QueriesObserver" }, { - "label": "Types / QueryClientProviderProps", - "to": "framework/react/reference/type-aliases/QueryClientProviderProps" + "label": "Classes / Query", + "to": "framework/react/reference/classes/Query" }, { - "label": "Types / QueryErrorClearResetFunction", - "to": "framework/react/reference/type-aliases/QueryErrorClearResetFunction" + "label": "Classes / QueryCache", + "to": "framework/react/reference/classes/QueryCache" }, { - "label": "Types / QueryErrorIsResetFunction", - "to": "framework/react/reference/type-aliases/QueryErrorIsResetFunction" + "label": "Classes / QueryClient", + "to": "framework/react/reference/classes/QueryClient" }, { - "label": "Types / QueryErrorResetBoundaryFunction", - "to": "framework/react/reference/type-aliases/QueryErrorResetBoundaryFunction" + "label": "Classes / QueryObserver", + "to": "framework/react/reference/classes/QueryObserver" }, { - "label": "Types / QueryErrorResetFunction", - "to": "framework/react/reference/type-aliases/QueryErrorResetFunction" + "label": "Interfaces / CancelOptions", + "to": "framework/react/reference/interfaces/CancelOptions" }, { - "label": "Types / SuspenseQueriesOptions", - "to": "framework/react/reference/type-aliases/SuspenseQueriesOptions" + "label": "Interfaces / DefaultOptions", + "to": "framework/react/reference/interfaces/DefaultOptions" }, { - "label": "Types / SuspenseQueriesResults", - "to": "framework/react/reference/type-aliases/SuspenseQueriesResults" + "label": "Interfaces / DehydrateOptions", + "to": "framework/react/reference/interfaces/DehydrateOptions" }, { - "label": "Types / UndefinedInitialDataInfiniteOptions", - "to": "framework/react/reference/type-aliases/UndefinedInitialDataInfiniteOptions" + "label": "Interfaces / DehydratedState", + "to": "framework/react/reference/interfaces/DehydratedState" }, { - "label": "Types / UndefinedInitialDataOptions", - "to": "framework/react/reference/type-aliases/UndefinedInitialDataOptions" + "label": "Interfaces / EnsureQueryDataOptions", + "to": "framework/react/reference/interfaces/EnsureQueryDataOptions" }, { - "label": "Types / UnusedSkipTokenInfiniteOptions", - "to": "framework/react/reference/type-aliases/UnusedSkipTokenInfiniteOptions" + "label": "Interfaces / FetchNextPageOptions", + "to": "framework/react/reference/interfaces/FetchNextPageOptions" }, { - "label": "Types / UnusedSkipTokenOptions", - "to": "framework/react/reference/type-aliases/UnusedSkipTokenOptions" + "label": "Interfaces / FetchPreviousPageOptions", + "to": "framework/react/reference/interfaces/FetchPreviousPageOptions" }, { - "label": "Types / UseBaseMutationResult", - "to": "framework/react/reference/type-aliases/UseBaseMutationResult" + "label": "Interfaces / FetchQueryOptions", + "to": "framework/react/reference/interfaces/FetchQueryOptions" }, { - "label": "Types / UseBaseQueryResult", - "to": "framework/react/reference/type-aliases/UseBaseQueryResult" + "label": "Interfaces / FocusManager", + "to": "framework/react/reference/interfaces/FocusManager" }, { - "label": "Types / UseInfiniteQueryResult", - "to": "framework/react/reference/type-aliases/UseInfiniteQueryResult" + "label": "Interfaces / HydrateOptions", + "to": "framework/react/reference/interfaces/HydrateOptions" }, { - "label": "Types / UseMutateAsyncFunction", - "to": "framework/react/reference/type-aliases/UseMutateAsyncFunction" + "label": "Interfaces / HydrationBoundaryProps", + "to": "framework/react/reference/interfaces/HydrationBoundaryProps" }, { - "label": "Types / UseMutateFunction", - "to": "framework/react/reference/type-aliases/UseMutateFunction" + "label": "Interfaces / InfiniteData", + "to": "framework/react/reference/interfaces/InfiniteData" }, { - "label": "Types / UseMutationResult", - "to": "framework/react/reference/type-aliases/UseMutationResult" + "label": "Interfaces / InfiniteQueryObserverBaseResult", + "to": "framework/react/reference/interfaces/InfiniteQueryObserverBaseResult" }, { - "label": "Types / UsePrefetchInfiniteQueryOptions", - "to": "framework/react/reference/type-aliases/UsePrefetchInfiniteQueryOptions" + "label": "Interfaces / InfiniteQueryObserverLoadingErrorResult", + "to": "framework/react/reference/interfaces/InfiniteQueryObserverLoadingErrorResult" }, { - "label": "Types / UsePrefetchQueryOptions", - "to": "framework/react/reference/type-aliases/UsePrefetchQueryOptions" + "label": "Interfaces / InfiniteQueryObserverLoadingResult", + "to": "framework/react/reference/interfaces/InfiniteQueryObserverLoadingResult" }, { - "label": "Types / UseQueryResult", - "to": "framework/react/reference/type-aliases/UseQueryResult" + "label": "Interfaces / InfiniteQueryObserverOptions", + "to": "framework/react/reference/interfaces/InfiniteQueryObserverOptions" }, { - "label": "Types / UseSuspenseInfiniteQueryResult", - "to": "framework/react/reference/type-aliases/UseSuspenseInfiniteQueryResult" + "label": "Interfaces / InfiniteQueryObserverPendingResult", + "to": "framework/react/reference/interfaces/InfiniteQueryObserverPendingResult" }, { - "label": "Types / UseSuspenseQueryResult", - "to": "framework/react/reference/type-aliases/UseSuspenseQueryResult" + "label": "Interfaces / InfiniteQueryObserverPlaceholderResult", + "to": "framework/react/reference/interfaces/InfiniteQueryObserverPlaceholderResult" }, { - "label": "Variables / IsRestoringProvider", - "to": "framework/react/reference/variables/IsRestoringProvider" + "label": "Interfaces / InfiniteQueryObserverRefetchErrorResult", + "to": "framework/react/reference/interfaces/InfiniteQueryObserverRefetchErrorResult" }, { - "label": "Variables / QueryClientContext", - "to": "framework/react/reference/variables/QueryClientContext" - } - ] - }, - { - "label": "vue", - "children": [ + "label": "Interfaces / InfiniteQueryObserverSuccessResult", + "to": "framework/react/reference/interfaces/InfiniteQueryObserverSuccessResult" + }, { - "label": "Vue Reference", - "to": "framework/vue/reference/index" + "label": "Interfaces / InfiniteQueryPageParamsOptions", + "to": "framework/react/reference/interfaces/InfiniteQueryPageParamsOptions" }, { - "label": "Functions / useQuery", - "to": "framework/vue/reference/functions/useQuery" + "label": "Interfaces / InitialPageParam", + "to": "framework/react/reference/interfaces/InitialPageParam" }, { - "label": "Functions / useQueries", - "to": "framework/vue/reference/functions/useQueries" + "label": "Interfaces / InvalidateOptions", + "to": "framework/react/reference/interfaces/InvalidateOptions" }, { - "label": "Functions / useInfiniteQuery", - "to": "framework/vue/reference/functions/useInfiniteQuery" + "label": "Interfaces / InvalidateQueryFilters", + "to": "framework/react/reference/interfaces/InvalidateQueryFilters" }, { - "label": "Functions / useMutation", - "to": "framework/vue/reference/functions/useMutation" + "label": "Interfaces / MutateOptions", + "to": "framework/react/reference/interfaces/MutateOptions" }, { - "label": "Functions / useIsFetching", - "to": "framework/vue/reference/functions/useIsFetching" + "label": "Interfaces / MutationCacheConfig", + "to": "framework/react/reference/interfaces/MutationCacheConfig" }, { - "label": "Functions / useIsMutating", - "to": "framework/vue/reference/functions/useIsMutating" + "label": "Interfaces / MutationFilters", + "to": "framework/react/reference/interfaces/MutationFilters" }, { - "label": "Functions / useMutationState", - "to": "framework/vue/reference/functions/useMutationState" + "label": "Interfaces / MutationObserverBaseResult", + "to": "framework/react/reference/interfaces/MutationObserverBaseResult" }, { - "label": "Functions / useQueryClient", - "to": "framework/vue/reference/functions/useQueryClient" + "label": "Interfaces / MutationObserverErrorResult", + "to": "framework/react/reference/interfaces/MutationObserverErrorResult" }, { - "label": "Functions / queryOptions", - "to": "framework/vue/reference/functions/queryOptions" + "label": "Interfaces / MutationObserverIdleResult", + "to": "framework/react/reference/interfaces/MutationObserverIdleResult" }, { - "label": "Functions / infiniteQueryOptions", - "to": "framework/vue/reference/functions/infiniteQueryOptions" + "label": "Interfaces / MutationObserverLoadingResult", + "to": "framework/react/reference/interfaces/MutationObserverLoadingResult" }, { - "label": "Functions / mutationOptions", - "to": "framework/vue/reference/functions/mutationOptions" + "label": "Interfaces / MutationObserverOptions", + "to": "framework/react/reference/interfaces/MutationObserverOptions" }, { - "label": "Functions / usePrefetchQuery", - "to": "framework/vue/reference/functions/usePrefetchQuery" + "label": "Interfaces / MutationObserverSuccessResult", + "to": "framework/react/reference/interfaces/MutationObserverSuccessResult" }, { - "label": "Functions / usePrefetchInfiniteQuery", - "to": "framework/vue/reference/functions/usePrefetchInfiniteQuery" + "label": "Interfaces / MutationOptions", + "to": "framework/react/reference/interfaces/MutationOptions" }, { - "label": "Classes / MutationCache", - "to": "framework/vue/reference/classes/MutationCache" + "label": "Interfaces / MutationState", + "to": "framework/react/reference/interfaces/MutationState" }, { - "label": "Classes / QueryCache", - "to": "framework/vue/reference/classes/QueryCache" + "label": "Interfaces / NotifyEvent", + "to": "framework/react/reference/interfaces/NotifyEvent" }, { - "label": "Classes / QueryClient", - "to": "framework/vue/reference/classes/QueryClient" + "label": "Interfaces / OnlineManager", + "to": "framework/react/reference/interfaces/OnlineManager" }, { - "label": "Types / DefinedInitialDataInfiniteOptions", - "to": "framework/vue/reference/type-aliases/DefinedInitialDataInfiniteOptions" + "label": "Interfaces / QueriesObserverOptions", + "to": "framework/react/reference/interfaces/QueriesObserverOptions" }, { - "label": "Types / DefinedInitialQueryOptions", - "to": "framework/vue/reference/type-aliases/DefinedInitialQueryOptions" + "label": "Interfaces / QueryCacheConfig", + "to": "framework/react/reference/interfaces/QueryCacheConfig" }, { - "label": "Types / DefinedInitialQueryOptionsWithDataTag", - "to": "framework/vue/reference/type-aliases/DefinedInitialQueryOptionsWithDataTag" + "label": "Interfaces / QueryClientConfig", + "to": "framework/react/reference/interfaces/QueryClientConfig" }, { - "label": "Types / MutationFilters", - "to": "framework/vue/reference/type-aliases/MutationFilters" + "label": "Interfaces / QueryErrorResetBoundaryProps", + "to": "framework/react/reference/interfaces/QueryErrorResetBoundaryProps" }, { - "label": "Types / MutationOptions", - "to": "framework/vue/reference/type-aliases/MutationOptions" + "label": "Interfaces / QueryExecuteOptions", + "to": "framework/react/reference/interfaces/QueryExecuteOptions" }, { - "label": "Types / MutationStateOptions", - "to": "framework/vue/reference/type-aliases/MutationStateOptions" + "label": "Interfaces / QueryFilters", + "to": "framework/react/reference/interfaces/QueryFilters" }, { - "label": "Types / QueryFilters", - "to": "framework/vue/reference/type-aliases/QueryFilters" + "label": "Interfaces / QueryObserverBaseResult", + "to": "framework/react/reference/interfaces/QueryObserverBaseResult" }, { - "label": "Types / QueryOptions", - "to": "framework/vue/reference/type-aliases/QueryOptions" + "label": "Interfaces / QueryObserverLoadingErrorResult", + "to": "framework/react/reference/interfaces/QueryObserverLoadingErrorResult" }, { - "label": "Types / UndefinedInitialDataInfiniteOptions", - "to": "framework/vue/reference/type-aliases/UndefinedInitialDataInfiniteOptions" + "label": "Interfaces / QueryObserverLoadingResult", + "to": "framework/react/reference/interfaces/QueryObserverLoadingResult" }, { - "label": "Types / UndefinedInitialQueryOptions", - "to": "framework/vue/reference/type-aliases/UndefinedInitialQueryOptions" + "label": "Interfaces / QueryObserverOptions", + "to": "framework/react/reference/interfaces/QueryObserverOptions" }, { - "label": "Types / UndefinedInitialQueryOptionsWithDataTag", - "to": "framework/vue/reference/type-aliases/UndefinedInitialQueryOptionsWithDataTag" + "label": "Interfaces / QueryObserverPendingResult", + "to": "framework/react/reference/interfaces/QueryObserverPendingResult" }, { - "label": "Types / UseInfiniteQueryOptions", - "to": "framework/vue/reference/type-aliases/UseInfiniteQueryOptions" + "label": "Interfaces / QueryObserverPlaceholderResult", + "to": "framework/react/reference/interfaces/QueryObserverPlaceholderResult" }, { - "label": "Types / UseInfiniteQueryReturnType", - "to": "framework/vue/reference/type-aliases/UseInfiniteQueryReturnType" + "label": "Interfaces / QueryObserverRefetchErrorResult", + "to": "framework/react/reference/interfaces/QueryObserverRefetchErrorResult" }, { - "label": "Types / UseMutationOptions", - "to": "framework/vue/reference/type-aliases/UseMutationOptions" + "label": "Interfaces / QueryObserverSuccessResult", + "to": "framework/react/reference/interfaces/QueryObserverSuccessResult" }, { - "label": "Types / UseMutationReturnType", - "to": "framework/vue/reference/type-aliases/UseMutationReturnType" + "label": "Interfaces / QueryOptions", + "to": "framework/react/reference/interfaces/QueryOptions" }, { - "label": "Types / UsePrefetchInfiniteQueryOptions", - "to": "framework/vue/reference/type-aliases/UsePrefetchInfiniteQueryOptions" + "label": "Interfaces / QueryState", + "to": "framework/react/reference/interfaces/QueryState" }, { - "label": "Types / UsePrefetchQueryOptions", - "to": "framework/vue/reference/type-aliases/UsePrefetchQueryOptions" + "label": "Interfaces / RefetchOptions", + "to": "framework/react/reference/interfaces/RefetchOptions" }, { - "label": "Types / UseQueriesOptions", - "to": "framework/vue/reference/type-aliases/UseQueriesOptions" + "label": "Interfaces / RefetchQueryFilters", + "to": "framework/react/reference/interfaces/RefetchQueryFilters" }, { - "label": "Types / UseQueriesResults", - "to": "framework/vue/reference/type-aliases/UseQueriesResults" + "label": "Interfaces / Register", + "to": "framework/react/reference/interfaces/Register" }, { - "label": "Types / UseQueryDefinedReturnType", - "to": "framework/vue/reference/type-aliases/UseQueryDefinedReturnType" + "label": "Interfaces / ResetOptions", + "to": "framework/react/reference/interfaces/ResetOptions" }, { - "label": "Types / UseQueryOptions", - "to": "framework/vue/reference/type-aliases/UseQueryOptions" + "label": "Interfaces / ResultOptions", + "to": "framework/react/reference/interfaces/ResultOptions" }, { - "label": "Types / UseQueryReturnType", - "to": "framework/vue/reference/type-aliases/UseQueryReturnType" + "label": "Interfaces / SetDataOptions", + "to": "framework/react/reference/interfaces/SetDataOptions" }, { - "label": "Types / VueQueryPluginOptions", - "to": "framework/vue/reference/type-aliases/VueQueryPluginOptions" + "label": "Interfaces / TimeoutManager", + "to": "framework/react/reference/interfaces/TimeoutManager" }, { - "label": "Variables / VueQueryPlugin", - "to": "framework/vue/reference/variables/VueQueryPlugin" - } - ] - }, - { - "label": "solid", - "children": [ - { - "label": "Solid Reference", - "to": "framework/solid/reference/index" + "label": "Interfaces / UseBaseQueryOptions", + "to": "framework/react/reference/interfaces/UseBaseQueryOptions" }, { - "label": "Functions / useQuery", - "to": "framework/solid/reference/functions/useQuery" + "label": "Interfaces / UseInfiniteQueryOptions", + "to": "framework/react/reference/interfaces/UseInfiniteQueryOptions" }, { - "label": "Functions / useQueries", - "to": "framework/solid/reference/functions/useQueries" + "label": "Interfaces / UseMutationOptions", + "to": "framework/react/reference/interfaces/UseMutationOptions" }, { - "label": "Functions / useInfiniteQuery", - "to": "framework/solid/reference/functions/useInfiniteQuery" + "label": "Interfaces / UseQueryOptions", + "to": "framework/react/reference/interfaces/UseQueryOptions" }, { - "label": "Functions / useMutation", - "to": "framework/solid/reference/functions/useMutation" + "label": "Interfaces / UseSuspenseInfiniteQueryOptions", + "to": "framework/react/reference/interfaces/UseSuspenseInfiniteQueryOptions" }, { - "label": "Functions / useIsFetching", - "to": "framework/solid/reference/functions/useIsFetching" + "label": "Interfaces / UseSuspenseQueryOptions", + "to": "framework/react/reference/interfaces/UseSuspenseQueryOptions" }, { - "label": "Functions / useIsMutating", - "to": "framework/solid/reference/functions/useIsMutating" + "label": "Types / AnyDataTag", + "to": "framework/react/reference/type-aliases/AnyDataTag" }, { - "label": "Functions / useMutationState", - "to": "framework/solid/reference/functions/useMutationState" + "label": "Types / AnyUseBaseQueryOptions", + "to": "framework/react/reference/type-aliases/AnyUseBaseQueryOptions" }, { - "label": "Functions / QueryClientProvider", - "to": "framework/solid/reference/functions/QueryClientProvider" + "label": "Types / AnyUseInfiniteQueryOptions", + "to": "framework/react/reference/type-aliases/AnyUseInfiniteQueryOptions" }, { - "label": "Functions / useQueryClient", - "to": "framework/solid/reference/functions/useQueryClient" + "label": "Types / AnyUseMutationOptions", + "to": "framework/react/reference/type-aliases/AnyUseMutationOptions" }, { - "label": "Functions / queryOptions", - "to": "framework/solid/reference/functions/queryOptions" + "label": "Types / AnyUseQueryOptions", + "to": "framework/react/reference/type-aliases/AnyUseQueryOptions" }, { - "label": "Functions / infiniteQueryOptions", - "to": "framework/solid/reference/functions/infiniteQueryOptions" + "label": "Types / AnyUseSuspenseInfiniteQueryOptions", + "to": "framework/react/reference/type-aliases/AnyUseSuspenseInfiniteQueryOptions" }, { - "label": "Functions / mutationOptions", - "to": "framework/solid/reference/functions/mutationOptions" + "label": "Types / AnyUseSuspenseQueryOptions", + "to": "framework/react/reference/type-aliases/AnyUseSuspenseQueryOptions" }, { - "label": "Functions / useIsRestoring", - "to": "framework/solid/reference/functions/useIsRestoring" + "label": "Types / DataTag", + "to": "framework/react/reference/type-aliases/DataTag" }, { - "label": "Classes / QueryClient", - "to": "framework/solid/reference/classes/QueryClient" + "label": "Types / DefaultError", + "to": "framework/react/reference/type-aliases/DefaultError" }, { - "label": "Interfaces / DefaultOptions", - "to": "framework/solid/reference/interfaces/DefaultOptions" + "label": "Types / DefaultedInfiniteQueryObserverOptions", + "to": "framework/react/reference/type-aliases/DefaultedInfiniteQueryObserverOptions" }, { - "label": "Interfaces / InfiniteQueryObserverOptions", - "to": "framework/solid/reference/interfaces/InfiniteQueryObserverOptions" + "label": "Types / DefaultedQueryObserverOptions", + "to": "framework/react/reference/type-aliases/DefaultedQueryObserverOptions" }, { - "label": "Interfaces / InfiniteQueryOptions", - "to": "framework/solid/reference/interfaces/InfiniteQueryOptions" + "label": "Types / DefinedInfiniteQueryObserverResult", + "to": "framework/react/reference/type-aliases/DefinedInfiniteQueryObserverResult" }, { - "label": "Interfaces / MutationOptions", - "to": "framework/solid/reference/interfaces/MutationOptions" + "label": "Types / DefinedInitialDataInfiniteOptions", + "to": "framework/react/reference/type-aliases/DefinedInitialDataInfiniteOptions" }, { - "label": "Interfaces / QueryClientConfig", - "to": "framework/solid/reference/interfaces/QueryClientConfig" + "label": "Types / DefinedInitialDataOptions", + "to": "framework/react/reference/type-aliases/DefinedInitialDataOptions" }, { - "label": "Interfaces / QueryObserverOptions", - "to": "framework/solid/reference/interfaces/QueryObserverOptions" + "label": "Types / DefinedQueryObserverResult", + "to": "framework/react/reference/type-aliases/DefinedQueryObserverResult" }, { - "label": "Interfaces / QueryOptions", - "to": "framework/solid/reference/interfaces/QueryOptions" + "label": "Types / DefinedUseInfiniteQueryResult", + "to": "framework/react/reference/type-aliases/DefinedUseInfiniteQueryResult" }, { - "label": "Interfaces / UseBaseQueryOptions", - "to": "framework/solid/reference/interfaces/UseBaseQueryOptions" + "label": "Types / DefinedUseQueryResult", + "to": "framework/react/reference/type-aliases/DefinedUseQueryResult" }, { - "label": "Types / DefinedInitialDataInfiniteOptions", - "to": "framework/solid/reference/type-aliases/DefinedInitialDataInfiniteOptions" + "label": "Types / DistributiveOmit", + "to": "framework/react/reference/type-aliases/DistributiveOmit" }, { - "label": "Types / DefinedInitialDataOptions", - "to": "framework/solid/reference/type-aliases/DefinedInitialDataOptions" + "label": "Types / EnsureInfiniteQueryDataOptions", + "to": "framework/react/reference/type-aliases/EnsureInfiniteQueryDataOptions" }, { - "label": "Types / DefinedUseBaseQueryResult", - "to": "framework/solid/reference/type-aliases/DefinedUseBaseQueryResult" + "label": "Types / FetchInfiniteQueryOptions", + "to": "framework/react/reference/type-aliases/FetchInfiniteQueryOptions" }, { - "label": "Types / DefinedUseInfiniteQueryResult", - "to": "framework/solid/reference/type-aliases/DefinedUseInfiniteQueryResult" + "label": "Types / FetchStatus", + "to": "framework/react/reference/type-aliases/FetchStatus" }, { - "label": "Types / DefinedUseQueryResult", - "to": "framework/solid/reference/type-aliases/DefinedUseQueryResult" + "label": "Types / GetNextPageParamFunction", + "to": "framework/react/reference/type-aliases/GetNextPageParamFunction" }, { - "label": "Types / QueryClientProviderProps", - "to": "framework/solid/reference/type-aliases/QueryClientProviderProps" + "label": "Types / GetPreviousPageParamFunction", + "to": "framework/react/reference/type-aliases/GetPreviousPageParamFunction" }, { - "label": "Types / UndefinedInitialDataInfiniteOptions", - "to": "framework/solid/reference/type-aliases/UndefinedInitialDataInfiniteOptions" + "label": "Types / InferDataFromTag", + "to": "framework/react/reference/type-aliases/InferDataFromTag" }, { - "label": "Types / UndefinedInitialDataOptions", - "to": "framework/solid/reference/type-aliases/UndefinedInitialDataOptions" + "label": "Types / InferErrorFromTag", + "to": "framework/react/reference/type-aliases/InferErrorFromTag" }, { - "label": "Types / UseBaseMutationResult", - "to": "framework/solid/reference/type-aliases/UseBaseMutationResult" + "label": "Types / InfiniteQueryExecuteOptions", + "to": "framework/react/reference/type-aliases/InfiniteQueryExecuteOptions" }, { - "label": "Types / UseBaseQueryResult", - "to": "framework/solid/reference/type-aliases/UseBaseQueryResult" + "label": "Types / InfiniteQueryObserverResult", + "to": "framework/react/reference/type-aliases/InfiniteQueryObserverResult" }, { - "label": "Types / UseInfiniteQueryOptions", - "to": "framework/solid/reference/type-aliases/UseInfiniteQueryOptions" + "label": "Types / InitialDataFunction", + "to": "framework/react/reference/type-aliases/InitialDataFunction" }, { - "label": "Types / UseInfiniteQueryResult", - "to": "framework/solid/reference/type-aliases/UseInfiniteQueryResult" + "label": "Types / ManagedTimerId", + "to": "framework/react/reference/type-aliases/ManagedTimerId" }, { - "label": "Types / UseMutateAsyncFunction", - "to": "framework/solid/reference/type-aliases/UseMutateAsyncFunction" + "label": "Types / MutateFunction", + "to": "framework/react/reference/type-aliases/MutateFunction" }, { - "label": "Types / UseMutateFunction", - "to": "framework/solid/reference/type-aliases/UseMutateFunction" + "label": "Types / MutateFunctionRest", + "to": "framework/react/reference/type-aliases/MutateFunctionRest" }, { - "label": "Types / UseMutationOptions", - "to": "framework/solid/reference/type-aliases/UseMutationOptions" + "label": "Types / MutationCacheNotifyEvent", + "to": "framework/react/reference/type-aliases/MutationCacheNotifyEvent" }, { - "label": "Types / UseMutationResult", - "to": "framework/solid/reference/type-aliases/UseMutationResult" + "label": "Types / MutationFunction", + "to": "framework/react/reference/type-aliases/MutationFunction" }, { - "label": "Types / UseQueryOptions", - "to": "framework/solid/reference/type-aliases/UseQueryOptions" + "label": "Types / MutationFunctionContext", + "to": "framework/react/reference/type-aliases/MutationFunctionContext" }, { - "label": "Types / UseQueryResult", - "to": "framework/solid/reference/type-aliases/UseQueryResult" + "label": "Types / MutationKey", + "to": "framework/react/reference/type-aliases/MutationKey" }, { - "label": "Variables / IsRestoringProvider", - "to": "framework/solid/reference/variables/IsRestoringProvider" + "label": "Types / MutationMeta", + "to": "framework/react/reference/type-aliases/MutationMeta" }, { - "label": "Variables / QueryClientContext", - "to": "framework/solid/reference/variables/QueryClientContext" + "label": "Types / MutationObserverResult", + "to": "framework/react/reference/type-aliases/MutationObserverResult" }, { - "label": "Variables / createInfiniteQuery", - "to": "framework/solid/reference/variables/createInfiniteQuery" + "label": "Types / MutationScope", + "to": "framework/react/reference/type-aliases/MutationScope" }, { - "label": "Variables / createMutation", - "to": "framework/solid/reference/variables/createMutation" + "label": "Types / MutationStatus", + "to": "framework/react/reference/type-aliases/MutationStatus" }, { - "label": "Variables / createQueries", - "to": "framework/solid/reference/variables/createQueries" + "label": "Types / NetworkMode", + "to": "framework/react/reference/type-aliases/NetworkMode" }, { - "label": "Variables / createQuery", - "to": "framework/solid/reference/variables/createQuery" - } - ] - }, - { - "label": "svelte", - "children": [ - { - "label": "Svelte Reference", - "to": "framework/svelte/reference/index" + "label": "Types / NonUndefinedGuard", + "to": "framework/react/reference/type-aliases/NonUndefinedGuard" }, { - "label": "Functions / createQuery", - "to": "framework/svelte/reference/functions/createQuery" + "label": "Types / NotifyEventType", + "to": "framework/react/reference/type-aliases/NotifyEventType" }, { - "label": "Functions / createQueries", - "to": "framework/svelte/reference/functions/createQueries" + "label": "Types / NotifyOnChangeProps", + "to": "framework/react/reference/type-aliases/NotifyOnChangeProps" }, { - "label": "Functions / createInfiniteQuery", - "to": "framework/svelte/reference/functions/createInfiniteQuery" + "label": "Types / OmitKeyof", + "to": "framework/react/reference/type-aliases/OmitKeyof" }, { - "label": "Functions / createMutation", - "to": "framework/svelte/reference/functions/createMutation" + "label": "Types / Override", + "to": "framework/react/reference/type-aliases/Override" }, { - "label": "Functions / useIsFetching", - "to": "framework/svelte/reference/functions/useIsFetching" + "label": "Types / PlaceholderDataFunction", + "to": "framework/react/reference/type-aliases/PlaceholderDataFunction" }, { - "label": "Functions / useIsMutating", - "to": "framework/svelte/reference/functions/useIsMutating" + "label": "Types / QueriesOptions", + "to": "framework/react/reference/type-aliases/QueriesOptions" }, { - "label": "Functions / useMutationState", - "to": "framework/svelte/reference/functions/useMutationState" + "label": "Types / QueriesPlaceholderDataFunction", + "to": "framework/react/reference/type-aliases/QueriesPlaceholderDataFunction" }, { - "label": "Functions / useQueryClient", - "to": "framework/svelte/reference/functions/useQueryClient" + "label": "Types / QueriesResults", + "to": "framework/react/reference/type-aliases/QueriesResults" }, { - "label": "Functions / queryOptions", - "to": "framework/svelte/reference/functions/queryOptions" + "label": "Types / QueryBooleanOption", + "to": "framework/react/reference/type-aliases/QueryBooleanOption" }, { - "label": "Functions / infiniteQueryOptions", - "to": "framework/svelte/reference/functions/infiniteQueryOptions" + "label": "Types / QueryCacheNotifyEvent", + "to": "framework/react/reference/type-aliases/QueryCacheNotifyEvent" }, { - "label": "Functions / mutationOptions", - "to": "framework/svelte/reference/functions/mutationOptions" + "label": "Types / QueryClientProviderProps", + "to": "framework/react/reference/type-aliases/QueryClientProviderProps" }, { - "label": "Functions / useHydrate", - "to": "framework/svelte/reference/functions/useHydrate" + "label": "Types / QueryErrorClearResetFunction", + "to": "framework/react/reference/type-aliases/QueryErrorClearResetFunction" }, { - "label": "Functions / getIsRestoringContext", - "to": "framework/svelte/reference/functions/getIsRestoringContext" + "label": "Types / QueryErrorIsResetFunction", + "to": "framework/react/reference/type-aliases/QueryErrorIsResetFunction" }, { - "label": "Functions / getQueryClientContext", - "to": "framework/svelte/reference/functions/getQueryClientContext" + "label": "Types / QueryErrorResetBoundaryFunction", + "to": "framework/react/reference/type-aliases/QueryErrorResetBoundaryFunction" }, { - "label": "Functions / setIsRestoringContext", - "to": "framework/svelte/reference/functions/setIsRestoringContext" + "label": "Types / QueryErrorResetFunction", + "to": "framework/react/reference/type-aliases/QueryErrorResetFunction" }, { - "label": "Functions / setQueryClientContext", - "to": "framework/svelte/reference/functions/setQueryClientContext" + "label": "Types / QueryFunction", + "to": "framework/react/reference/type-aliases/QueryFunction" }, { - "label": "Functions / useIsRestoring", - "to": "framework/svelte/reference/functions/useIsRestoring" + "label": "Types / QueryFunctionContext", + "to": "framework/react/reference/type-aliases/QueryFunctionContext" }, { - "label": "Types / Accessor", - "to": "framework/svelte/reference/type-aliases/Accessor" + "label": "Types / QueryKey", + "to": "framework/react/reference/type-aliases/QueryKey" }, { - "label": "Types / CreateBaseMutationResult", - "to": "framework/svelte/reference/type-aliases/CreateBaseMutationResult" + "label": "Types / QueryKeyHashFunction", + "to": "framework/react/reference/type-aliases/QueryKeyHashFunction" }, { - "label": "Types / CreateBaseQueryOptions", - "to": "framework/svelte/reference/type-aliases/CreateBaseQueryOptions" + "label": "Types / QueryKeyWithDataTag", + "to": "framework/react/reference/type-aliases/QueryKeyWithDataTag" }, { - "label": "Types / CreateBaseQueryResult", - "to": "framework/svelte/reference/type-aliases/CreateBaseQueryResult" + "label": "Types / QueryMeta", + "to": "framework/react/reference/type-aliases/QueryMeta" }, { - "label": "Types / CreateInfiniteQueryOptions", - "to": "framework/svelte/reference/type-aliases/CreateInfiniteQueryOptions" + "label": "Types / QueryObserverResult", + "to": "framework/react/reference/type-aliases/QueryObserverResult" }, { - "label": "Types / CreateInfiniteQueryResult", - "to": "framework/svelte/reference/type-aliases/CreateInfiniteQueryResult" + "label": "Types / QueryPersister", + "to": "framework/react/reference/type-aliases/QueryPersister" }, { - "label": "Types / CreateMutateAsyncFunction", - "to": "framework/svelte/reference/type-aliases/CreateMutateAsyncFunction" + "label": "Types / QueryStatus", + "to": "framework/react/reference/type-aliases/QueryStatus" }, { - "label": "Types / CreateMutateFunction", - "to": "framework/svelte/reference/type-aliases/CreateMutateFunction" + "label": "Types / SkipToken", + "to": "framework/react/reference/type-aliases/SkipToken" }, { - "label": "Types / CreateMutationOptions", - "to": "framework/svelte/reference/type-aliases/CreateMutationOptions" + "label": "Types / StaleTime", + "to": "framework/react/reference/type-aliases/StaleTime" }, { - "label": "Types / CreateMutationResult", - "to": "framework/svelte/reference/type-aliases/CreateMutationResult" + "label": "Types / StaleTimeFunction", + "to": "framework/react/reference/type-aliases/StaleTimeFunction" }, { - "label": "Types / CreateQueryOptions", - "to": "framework/svelte/reference/type-aliases/CreateQueryOptions" + "label": "Types / SuspenseQueriesOptions", + "to": "framework/react/reference/type-aliases/SuspenseQueriesOptions" + }, + { + "label": "Types / SuspenseQueriesResults", + "to": "framework/react/reference/type-aliases/SuspenseQueriesResults" + }, + { + "label": "Types / ThrowOnError", + "to": "framework/react/reference/type-aliases/ThrowOnError" + }, + { + "label": "Types / TimeoutCallback", + "to": "framework/react/reference/type-aliases/TimeoutCallback" + }, + { + "label": "Types / TimeoutProvider", + "to": "framework/react/reference/type-aliases/TimeoutProvider" + }, + { + "label": "Types / UndefinedInitialDataInfiniteOptions", + "to": "framework/react/reference/type-aliases/UndefinedInitialDataInfiniteOptions" + }, + { + "label": "Types / UndefinedInitialDataOptions", + "to": "framework/react/reference/type-aliases/UndefinedInitialDataOptions" + }, + { + "label": "Types / UnsetMarker", + "to": "framework/react/reference/type-aliases/UnsetMarker" + }, + { + "label": "Types / UnusedSkipTokenInfiniteOptions", + "to": "framework/react/reference/type-aliases/UnusedSkipTokenInfiniteOptions" + }, + { + "label": "Types / UnusedSkipTokenOptions", + "to": "framework/react/reference/type-aliases/UnusedSkipTokenOptions" + }, + { + "label": "Types / Updater", + "to": "framework/react/reference/type-aliases/Updater" + }, + { + "label": "Types / UseBaseMutationResult", + "to": "framework/react/reference/type-aliases/UseBaseMutationResult" + }, + { + "label": "Types / UseBaseQueryResult", + "to": "framework/react/reference/type-aliases/UseBaseQueryResult" + }, + { + "label": "Types / UseInfiniteQueryResult", + "to": "framework/react/reference/type-aliases/UseInfiniteQueryResult" + }, + { + "label": "Types / UseMutateAsyncFunction", + "to": "framework/react/reference/type-aliases/UseMutateAsyncFunction" + }, + { + "label": "Types / UseMutateFunction", + "to": "framework/react/reference/type-aliases/UseMutateFunction" + }, + { + "label": "Types / UseMutationResult", + "to": "framework/react/reference/type-aliases/UseMutationResult" + }, + { + "label": "Types / UsePrefetchInfiniteQueryOptions", + "to": "framework/react/reference/type-aliases/UsePrefetchInfiniteQueryOptions" + }, + { + "label": "Types / UsePrefetchQueryOptions", + "to": "framework/react/reference/type-aliases/UsePrefetchQueryOptions" + }, + { + "label": "Types / UseQueryResult", + "to": "framework/react/reference/type-aliases/UseQueryResult" + }, + { + "label": "Types / UseSuspenseInfiniteQueryResult", + "to": "framework/react/reference/type-aliases/UseSuspenseInfiniteQueryResult" + }, + { + "label": "Types / UseSuspenseQueryResult", + "to": "framework/react/reference/type-aliases/UseSuspenseQueryResult" + }, + { + "label": "Types / WithRequired", + "to": "framework/react/reference/type-aliases/WithRequired" + }, + { + "label": "Types / dataTagErrorSymbol", + "to": "framework/react/reference/type-aliases/dataTagErrorSymbol" + }, + { + "label": "Types / dataTagSymbol", + "to": "framework/react/reference/type-aliases/dataTagSymbol" + }, + { + "label": "Variables / IsRestoringProvider", + "to": "framework/react/reference/variables/IsRestoringProvider" + }, + { + "label": "Variables / QueryClientContext", + "to": "framework/react/reference/variables/QueryClientContext" + }, + { + "label": "Variables / dataTagErrorSymbol", + "to": "framework/react/reference/variables/dataTagErrorSymbol" + }, + { + "label": "Variables / dataTagSymbol", + "to": "framework/react/reference/variables/dataTagSymbol" + }, + { + "label": "Variables / defaultScheduler", + "to": "framework/react/reference/variables/defaultScheduler" + }, + { + "label": "Variables / environmentManager", + "to": "framework/react/reference/variables/environmentManager" + }, + { + "label": "Variables / focusManager", + "to": "framework/react/reference/variables/focusManager" + }, + { + "label": "Variables / isServer", + "to": "framework/react/reference/variables/isServer" + }, + { + "label": "Variables / notifyManager", + "to": "framework/react/reference/variables/notifyManager" + }, + { + "label": "Variables / onlineManager", + "to": "framework/react/reference/variables/onlineManager" + }, + { + "label": "Variables / skipToken", + "to": "framework/react/reference/variables/skipToken" + }, + { + "label": "Variables / timeoutManager", + "to": "framework/react/reference/variables/timeoutManager" + }, + { + "label": "Variables / unsetMarker", + "to": "framework/react/reference/variables/unsetMarker" + } + ] + }, + { + "label": "vue", + "children": [ + { + "label": "Vue Reference", + "to": "framework/vue/reference/index" + }, + { + "label": "Functions / defaultShouldDehydrateMutation", + "to": "framework/vue/reference/functions/defaultShouldDehydrateMutation" + }, + { + "label": "Functions / defaultShouldDehydrateQuery", + "to": "framework/vue/reference/functions/defaultShouldDehydrateQuery" + }, + { + "label": "Functions / dehydrate", + "to": "framework/vue/reference/functions/dehydrate" + }, + { + "label": "Functions / dehydrateQuery", + "to": "framework/vue/reference/functions/dehydrateQuery" + }, + { + "label": "Functions / experimental_streamedQuery", + "to": "framework/vue/reference/functions/experimental_streamedQuery" + }, + { + "label": "Functions / hashKey", + "to": "framework/vue/reference/functions/hashKey" + }, + { + "label": "Functions / hydrate", + "to": "framework/vue/reference/functions/hydrate" + }, + { + "label": "Functions / infiniteQueryOptions", + "to": "framework/vue/reference/functions/infiniteQueryOptions" + }, + { + "label": "Functions / isCancelledError", + "to": "framework/vue/reference/functions/isCancelledError" + }, + { + "label": "Functions / keepPreviousData", + "to": "framework/vue/reference/functions/keepPreviousData" + }, + { + "label": "Functions / matchMutation", + "to": "framework/vue/reference/functions/matchMutation" + }, + { + "label": "Functions / matchQuery", + "to": "framework/vue/reference/functions/matchQuery" + }, + { + "label": "Functions / mutationOptions", + "to": "framework/vue/reference/functions/mutationOptions" + }, + { + "label": "Functions / noop", + "to": "framework/vue/reference/functions/noop" + }, + { + "label": "Functions / partialMatchKey", + "to": "framework/vue/reference/functions/partialMatchKey" + }, + { + "label": "Functions / queryOptions", + "to": "framework/vue/reference/functions/queryOptions" + }, + { + "label": "Functions / replaceEqualDeep", + "to": "framework/vue/reference/functions/replaceEqualDeep" + }, + { + "label": "Functions / shouldThrowError", + "to": "framework/vue/reference/functions/shouldThrowError" + }, + { + "label": "Functions / useInfiniteQuery", + "to": "framework/vue/reference/functions/useInfiniteQuery" + }, + { + "label": "Functions / useIsFetching", + "to": "framework/vue/reference/functions/useIsFetching" + }, + { + "label": "Functions / useIsMutating", + "to": "framework/vue/reference/functions/useIsMutating" + }, + { + "label": "Functions / useMutation", + "to": "framework/vue/reference/functions/useMutation" + }, + { + "label": "Functions / useMutationState", + "to": "framework/vue/reference/functions/useMutationState" + }, + { + "label": "Functions / usePrefetchInfiniteQuery", + "to": "framework/vue/reference/functions/usePrefetchInfiniteQuery" + }, + { + "label": "Functions / usePrefetchQuery", + "to": "framework/vue/reference/functions/usePrefetchQuery" + }, + { + "label": "Functions / useQueries", + "to": "framework/vue/reference/functions/useQueries" + }, + { + "label": "Functions / useQuery", + "to": "framework/vue/reference/functions/useQuery" + }, + { + "label": "Functions / useQueryClient", + "to": "framework/vue/reference/functions/useQueryClient" + }, + { + "label": "Classes / CancelledError", + "to": "framework/vue/reference/classes/CancelledError" + }, + { + "label": "Classes / InfiniteQueryObserver", + "to": "framework/vue/reference/classes/InfiniteQueryObserver" + }, + { + "label": "Classes / Mutation", + "to": "framework/vue/reference/classes/Mutation" + }, + { + "label": "Classes / MutationCache", + "to": "framework/vue/reference/classes/MutationCache" + }, + { + "label": "Classes / MutationObserver", + "to": "framework/vue/reference/classes/MutationObserver" + }, + { + "label": "Classes / QueriesObserver", + "to": "framework/vue/reference/classes/QueriesObserver" + }, + { + "label": "Classes / Query", + "to": "framework/vue/reference/classes/Query" + }, + { + "label": "Classes / QueryCache", + "to": "framework/vue/reference/classes/QueryCache" + }, + { + "label": "Classes / QueryClient", + "to": "framework/vue/reference/classes/QueryClient" + }, + { + "label": "Classes / QueryObserver", + "to": "framework/vue/reference/classes/QueryObserver" + }, + { + "label": "Interfaces / CancelOptions", + "to": "framework/vue/reference/interfaces/CancelOptions" + }, + { + "label": "Interfaces / DefaultOptions", + "to": "framework/vue/reference/interfaces/DefaultOptions" + }, + { + "label": "Interfaces / DehydrateOptions", + "to": "framework/vue/reference/interfaces/DehydrateOptions" + }, + { + "label": "Interfaces / DehydratedState", + "to": "framework/vue/reference/interfaces/DehydratedState" + }, + { + "label": "Interfaces / EnsureQueryDataOptions", + "to": "framework/vue/reference/interfaces/EnsureQueryDataOptions" + }, + { + "label": "Interfaces / FetchNextPageOptions", + "to": "framework/vue/reference/interfaces/FetchNextPageOptions" + }, + { + "label": "Interfaces / FetchPreviousPageOptions", + "to": "framework/vue/reference/interfaces/FetchPreviousPageOptions" + }, + { + "label": "Interfaces / FetchQueryOptions", + "to": "framework/vue/reference/interfaces/FetchQueryOptions" + }, + { + "label": "Interfaces / FocusManager", + "to": "framework/vue/reference/interfaces/FocusManager" + }, + { + "label": "Interfaces / HydrateOptions", + "to": "framework/vue/reference/interfaces/HydrateOptions" + }, + { + "label": "Interfaces / InfiniteData", + "to": "framework/vue/reference/interfaces/InfiniteData" + }, + { + "label": "Interfaces / InfiniteQueryObserverBaseResult", + "to": "framework/vue/reference/interfaces/InfiniteQueryObserverBaseResult" + }, + { + "label": "Interfaces / InfiniteQueryObserverLoadingErrorResult", + "to": "framework/vue/reference/interfaces/InfiniteQueryObserverLoadingErrorResult" + }, + { + "label": "Interfaces / InfiniteQueryObserverLoadingResult", + "to": "framework/vue/reference/interfaces/InfiniteQueryObserverLoadingResult" + }, + { + "label": "Interfaces / InfiniteQueryObserverOptions", + "to": "framework/vue/reference/interfaces/InfiniteQueryObserverOptions" + }, + { + "label": "Interfaces / InfiniteQueryObserverPendingResult", + "to": "framework/vue/reference/interfaces/InfiniteQueryObserverPendingResult" + }, + { + "label": "Interfaces / InfiniteQueryObserverPlaceholderResult", + "to": "framework/vue/reference/interfaces/InfiniteQueryObserverPlaceholderResult" + }, + { + "label": "Interfaces / InfiniteQueryObserverRefetchErrorResult", + "to": "framework/vue/reference/interfaces/InfiniteQueryObserverRefetchErrorResult" + }, + { + "label": "Interfaces / InfiniteQueryObserverSuccessResult", + "to": "framework/vue/reference/interfaces/InfiniteQueryObserverSuccessResult" + }, + { + "label": "Interfaces / InfiniteQueryPageParamsOptions", + "to": "framework/vue/reference/interfaces/InfiniteQueryPageParamsOptions" + }, + { + "label": "Interfaces / InitialPageParam", + "to": "framework/vue/reference/interfaces/InitialPageParam" + }, + { + "label": "Interfaces / InvalidateOptions", + "to": "framework/vue/reference/interfaces/InvalidateOptions" + }, + { + "label": "Interfaces / InvalidateQueryFilters", + "to": "framework/vue/reference/interfaces/InvalidateQueryFilters" + }, + { + "label": "Interfaces / MutateOptions", + "to": "framework/vue/reference/interfaces/MutateOptions" + }, + { + "label": "Interfaces / MutationCacheConfig", + "to": "framework/vue/reference/interfaces/MutationCacheConfig" + }, + { + "label": "Interfaces / MutationObserverBaseResult", + "to": "framework/vue/reference/interfaces/MutationObserverBaseResult" + }, + { + "label": "Interfaces / MutationObserverErrorResult", + "to": "framework/vue/reference/interfaces/MutationObserverErrorResult" + }, + { + "label": "Interfaces / MutationObserverIdleResult", + "to": "framework/vue/reference/interfaces/MutationObserverIdleResult" + }, + { + "label": "Interfaces / MutationObserverLoadingResult", + "to": "framework/vue/reference/interfaces/MutationObserverLoadingResult" + }, + { + "label": "Interfaces / MutationObserverOptions", + "to": "framework/vue/reference/interfaces/MutationObserverOptions" + }, + { + "label": "Interfaces / MutationObserverSuccessResult", + "to": "framework/vue/reference/interfaces/MutationObserverSuccessResult" + }, + { + "label": "Interfaces / MutationState", + "to": "framework/vue/reference/interfaces/MutationState" + }, + { + "label": "Interfaces / NotifyEvent", + "to": "framework/vue/reference/interfaces/NotifyEvent" + }, + { + "label": "Interfaces / OnlineManager", + "to": "framework/vue/reference/interfaces/OnlineManager" + }, + { + "label": "Interfaces / QueriesObserverOptions", + "to": "framework/vue/reference/interfaces/QueriesObserverOptions" + }, + { + "label": "Interfaces / QueryCacheConfig", + "to": "framework/vue/reference/interfaces/QueryCacheConfig" + }, + { + "label": "Interfaces / QueryClientConfig", + "to": "framework/vue/reference/interfaces/QueryClientConfig" + }, + { + "label": "Interfaces / QueryExecuteOptions", + "to": "framework/vue/reference/interfaces/QueryExecuteOptions" + }, + { + "label": "Interfaces / QueryObserverBaseResult", + "to": "framework/vue/reference/interfaces/QueryObserverBaseResult" + }, + { + "label": "Interfaces / QueryObserverLoadingErrorResult", + "to": "framework/vue/reference/interfaces/QueryObserverLoadingErrorResult" + }, + { + "label": "Interfaces / QueryObserverLoadingResult", + "to": "framework/vue/reference/interfaces/QueryObserverLoadingResult" + }, + { + "label": "Interfaces / QueryObserverOptions", + "to": "framework/vue/reference/interfaces/QueryObserverOptions" + }, + { + "label": "Interfaces / QueryObserverPendingResult", + "to": "framework/vue/reference/interfaces/QueryObserverPendingResult" + }, + { + "label": "Interfaces / QueryObserverPlaceholderResult", + "to": "framework/vue/reference/interfaces/QueryObserverPlaceholderResult" + }, + { + "label": "Interfaces / QueryObserverRefetchErrorResult", + "to": "framework/vue/reference/interfaces/QueryObserverRefetchErrorResult" + }, + { + "label": "Interfaces / QueryObserverSuccessResult", + "to": "framework/vue/reference/interfaces/QueryObserverSuccessResult" + }, + { + "label": "Interfaces / QueryState", + "to": "framework/vue/reference/interfaces/QueryState" + }, + { + "label": "Interfaces / RefetchOptions", + "to": "framework/vue/reference/interfaces/RefetchOptions" + }, + { + "label": "Interfaces / RefetchQueryFilters", + "to": "framework/vue/reference/interfaces/RefetchQueryFilters" + }, + { + "label": "Interfaces / Register", + "to": "framework/vue/reference/interfaces/Register" + }, + { + "label": "Interfaces / ResetOptions", + "to": "framework/vue/reference/interfaces/ResetOptions" + }, + { + "label": "Interfaces / ResultOptions", + "to": "framework/vue/reference/interfaces/ResultOptions" + }, + { + "label": "Interfaces / SetDataOptions", + "to": "framework/vue/reference/interfaces/SetDataOptions" + }, + { + "label": "Interfaces / TimeoutManager", + "to": "framework/vue/reference/interfaces/TimeoutManager" + }, + { + "label": "Types / AnyDataTag", + "to": "framework/vue/reference/type-aliases/AnyDataTag" + }, + { + "label": "Types / DataTag", + "to": "framework/vue/reference/type-aliases/DataTag" + }, + { + "label": "Types / DefaultError", + "to": "framework/vue/reference/type-aliases/DefaultError" + }, + { + "label": "Types / DefaultedInfiniteQueryObserverOptions", + "to": "framework/vue/reference/type-aliases/DefaultedInfiniteQueryObserverOptions" + }, + { + "label": "Types / DefaultedQueryObserverOptions", + "to": "framework/vue/reference/type-aliases/DefaultedQueryObserverOptions" + }, + { + "label": "Types / DefinedInfiniteQueryObserverResult", + "to": "framework/vue/reference/type-aliases/DefinedInfiniteQueryObserverResult" + }, + { + "label": "Types / DefinedInitialDataInfiniteOptions", + "to": "framework/vue/reference/type-aliases/DefinedInitialDataInfiniteOptions" + }, + { + "label": "Types / DefinedInitialQueryOptions", + "to": "framework/vue/reference/type-aliases/DefinedInitialQueryOptions" + }, + { + "label": "Types / DefinedInitialQueryOptionsWithDataTag", + "to": "framework/vue/reference/type-aliases/DefinedInitialQueryOptionsWithDataTag" + }, + { + "label": "Types / DefinedQueryObserverResult", + "to": "framework/vue/reference/type-aliases/DefinedQueryObserverResult" + }, + { + "label": "Types / DistributiveOmit", + "to": "framework/vue/reference/type-aliases/DistributiveOmit" + }, + { + "label": "Types / EnsureInfiniteQueryDataOptions", + "to": "framework/vue/reference/type-aliases/EnsureInfiniteQueryDataOptions" + }, + { + "label": "Types / FetchInfiniteQueryOptions", + "to": "framework/vue/reference/type-aliases/FetchInfiniteQueryOptions" + }, + { + "label": "Types / FetchStatus", + "to": "framework/vue/reference/type-aliases/FetchStatus" + }, + { + "label": "Types / GetNextPageParamFunction", + "to": "framework/vue/reference/type-aliases/GetNextPageParamFunction" + }, + { + "label": "Types / GetPreviousPageParamFunction", + "to": "framework/vue/reference/type-aliases/GetPreviousPageParamFunction" + }, + { + "label": "Types / InferDataFromTag", + "to": "framework/vue/reference/type-aliases/InferDataFromTag" + }, + { + "label": "Types / InferErrorFromTag", + "to": "framework/vue/reference/type-aliases/InferErrorFromTag" + }, + { + "label": "Types / InfiniteQueryExecuteOptions", + "to": "framework/vue/reference/type-aliases/InfiniteQueryExecuteOptions" + }, + { + "label": "Types / InfiniteQueryObserverResult", + "to": "framework/vue/reference/type-aliases/InfiniteQueryObserverResult" + }, + { + "label": "Types / InitialDataFunction", + "to": "framework/vue/reference/type-aliases/InitialDataFunction" + }, + { + "label": "Types / ManagedTimerId", + "to": "framework/vue/reference/type-aliases/ManagedTimerId" + }, + { + "label": "Types / MutateFunction", + "to": "framework/vue/reference/type-aliases/MutateFunction" + }, + { + "label": "Types / MutateFunctionRest", + "to": "framework/vue/reference/type-aliases/MutateFunctionRest" + }, + { + "label": "Types / MutationCacheNotifyEvent", + "to": "framework/vue/reference/type-aliases/MutationCacheNotifyEvent" + }, + { + "label": "Types / MutationFilters", + "to": "framework/vue/reference/type-aliases/MutationFilters" + }, + { + "label": "Types / MutationFunction", + "to": "framework/vue/reference/type-aliases/MutationFunction" + }, + { + "label": "Types / MutationFunctionContext", + "to": "framework/vue/reference/type-aliases/MutationFunctionContext" + }, + { + "label": "Types / MutationKey", + "to": "framework/vue/reference/type-aliases/MutationKey" + }, + { + "label": "Types / MutationMeta", + "to": "framework/vue/reference/type-aliases/MutationMeta" + }, + { + "label": "Types / MutationObserverResult", + "to": "framework/vue/reference/type-aliases/MutationObserverResult" + }, + { + "label": "Types / MutationOptions", + "to": "framework/vue/reference/type-aliases/MutationOptions" + }, + { + "label": "Types / MutationScope", + "to": "framework/vue/reference/type-aliases/MutationScope" + }, + { + "label": "Types / MutationStateOptions", + "to": "framework/vue/reference/type-aliases/MutationStateOptions" + }, + { + "label": "Types / MutationStatus", + "to": "framework/vue/reference/type-aliases/MutationStatus" + }, + { + "label": "Types / NetworkMode", + "to": "framework/vue/reference/type-aliases/NetworkMode" + }, + { + "label": "Types / NonUndefinedGuard", + "to": "framework/vue/reference/type-aliases/NonUndefinedGuard" + }, + { + "label": "Types / NotifyEventType", + "to": "framework/vue/reference/type-aliases/NotifyEventType" + }, + { + "label": "Types / NotifyOnChangeProps", + "to": "framework/vue/reference/type-aliases/NotifyOnChangeProps" + }, + { + "label": "Types / OmitKeyof", + "to": "framework/vue/reference/type-aliases/OmitKeyof" + }, + { + "label": "Types / Override", + "to": "framework/vue/reference/type-aliases/Override" + }, + { + "label": "Types / PlaceholderDataFunction", + "to": "framework/vue/reference/type-aliases/PlaceholderDataFunction" + }, + { + "label": "Types / QueriesPlaceholderDataFunction", + "to": "framework/vue/reference/type-aliases/QueriesPlaceholderDataFunction" + }, + { + "label": "Types / QueryBooleanOption", + "to": "framework/vue/reference/type-aliases/QueryBooleanOption" + }, + { + "label": "Types / QueryCacheNotifyEvent", + "to": "framework/vue/reference/type-aliases/QueryCacheNotifyEvent" + }, + { + "label": "Types / QueryFilters", + "to": "framework/vue/reference/type-aliases/QueryFilters" + }, + { + "label": "Types / QueryFunction", + "to": "framework/vue/reference/type-aliases/QueryFunction" + }, + { + "label": "Types / QueryFunctionContext", + "to": "framework/vue/reference/type-aliases/QueryFunctionContext" + }, + { + "label": "Types / QueryKey", + "to": "framework/vue/reference/type-aliases/QueryKey" + }, + { + "label": "Types / QueryKeyHashFunction", + "to": "framework/vue/reference/type-aliases/QueryKeyHashFunction" + }, + { + "label": "Types / QueryKeyWithDataTag", + "to": "framework/vue/reference/type-aliases/QueryKeyWithDataTag" + }, + { + "label": "Types / QueryMeta", + "to": "framework/vue/reference/type-aliases/QueryMeta" + }, + { + "label": "Types / QueryObserverResult", + "to": "framework/vue/reference/type-aliases/QueryObserverResult" + }, + { + "label": "Types / QueryOptions", + "to": "framework/vue/reference/type-aliases/QueryOptions" + }, + { + "label": "Types / QueryPersister", + "to": "framework/vue/reference/type-aliases/QueryPersister" + }, + { + "label": "Types / QueryStatus", + "to": "framework/vue/reference/type-aliases/QueryStatus" + }, + { + "label": "Types / SkipToken", + "to": "framework/vue/reference/type-aliases/SkipToken" + }, + { + "label": "Types / StaleTime", + "to": "framework/vue/reference/type-aliases/StaleTime" + }, + { + "label": "Types / StaleTimeFunction", + "to": "framework/vue/reference/type-aliases/StaleTimeFunction" + }, + { + "label": "Types / ThrowOnError", + "to": "framework/vue/reference/type-aliases/ThrowOnError" + }, + { + "label": "Types / TimeoutCallback", + "to": "framework/vue/reference/type-aliases/TimeoutCallback" + }, + { + "label": "Types / TimeoutProvider", + "to": "framework/vue/reference/type-aliases/TimeoutProvider" + }, + { + "label": "Types / UndefinedInitialDataInfiniteOptions", + "to": "framework/vue/reference/type-aliases/UndefinedInitialDataInfiniteOptions" + }, + { + "label": "Types / UndefinedInitialQueryOptions", + "to": "framework/vue/reference/type-aliases/UndefinedInitialQueryOptions" + }, + { + "label": "Types / UndefinedInitialQueryOptionsWithDataTag", + "to": "framework/vue/reference/type-aliases/UndefinedInitialQueryOptionsWithDataTag" + }, + { + "label": "Types / UnsetMarker", + "to": "framework/vue/reference/type-aliases/UnsetMarker" + }, + { + "label": "Types / Updater", + "to": "framework/vue/reference/type-aliases/Updater" + }, + { + "label": "Types / UseInfiniteQueryOptions", + "to": "framework/vue/reference/type-aliases/UseInfiniteQueryOptions" + }, + { + "label": "Types / UseInfiniteQueryReturnType", + "to": "framework/vue/reference/type-aliases/UseInfiniteQueryReturnType" + }, + { + "label": "Types / UseMutationOptions", + "to": "framework/vue/reference/type-aliases/UseMutationOptions" + }, + { + "label": "Types / UseMutationReturnType", + "to": "framework/vue/reference/type-aliases/UseMutationReturnType" + }, + { + "label": "Types / UsePrefetchInfiniteQueryOptions", + "to": "framework/vue/reference/type-aliases/UsePrefetchInfiniteQueryOptions" + }, + { + "label": "Types / UsePrefetchQueryOptions", + "to": "framework/vue/reference/type-aliases/UsePrefetchQueryOptions" + }, + { + "label": "Types / UseQueriesOptions", + "to": "framework/vue/reference/type-aliases/UseQueriesOptions" + }, + { + "label": "Types / UseQueriesResults", + "to": "framework/vue/reference/type-aliases/UseQueriesResults" + }, + { + "label": "Types / UseQueryDefinedReturnType", + "to": "framework/vue/reference/type-aliases/UseQueryDefinedReturnType" + }, + { + "label": "Types / UseQueryOptions", + "to": "framework/vue/reference/type-aliases/UseQueryOptions" + }, + { + "label": "Types / UseQueryReturnType", + "to": "framework/vue/reference/type-aliases/UseQueryReturnType" + }, + { + "label": "Types / VueQueryPluginOptions", + "to": "framework/vue/reference/type-aliases/VueQueryPluginOptions" + }, + { + "label": "Types / WithRequired", + "to": "framework/vue/reference/type-aliases/WithRequired" + }, + { + "label": "Types / dataTagErrorSymbol", + "to": "framework/vue/reference/type-aliases/dataTagErrorSymbol" + }, + { + "label": "Types / dataTagSymbol", + "to": "framework/vue/reference/type-aliases/dataTagSymbol" + }, + { + "label": "Variables / VueQueryPlugin", + "to": "framework/vue/reference/variables/VueQueryPlugin" + }, + { + "label": "Variables / dataTagErrorSymbol", + "to": "framework/vue/reference/variables/dataTagErrorSymbol" + }, + { + "label": "Variables / dataTagSymbol", + "to": "framework/vue/reference/variables/dataTagSymbol" + }, + { + "label": "Variables / defaultScheduler", + "to": "framework/vue/reference/variables/defaultScheduler" + }, + { + "label": "Variables / environmentManager", + "to": "framework/vue/reference/variables/environmentManager" + }, + { + "label": "Variables / focusManager", + "to": "framework/vue/reference/variables/focusManager" + }, + { + "label": "Variables / isServer", + "to": "framework/vue/reference/variables/isServer" + }, + { + "label": "Variables / notifyManager", + "to": "framework/vue/reference/variables/notifyManager" + }, + { + "label": "Variables / onlineManager", + "to": "framework/vue/reference/variables/onlineManager" + }, + { + "label": "Variables / skipToken", + "to": "framework/vue/reference/variables/skipToken" + }, + { + "label": "Variables / timeoutManager", + "to": "framework/vue/reference/variables/timeoutManager" + }, + { + "label": "Variables / unsetMarker", + "to": "framework/vue/reference/variables/unsetMarker" + } + ] + }, + { + "label": "solid", + "children": [ + { + "label": "Solid Reference", + "to": "framework/solid/reference/index" + }, + { + "label": "Functions / QueryClientProvider", + "to": "framework/solid/reference/functions/QueryClientProvider" + }, + { + "label": "Functions / defaultShouldDehydrateMutation", + "to": "framework/solid/reference/functions/defaultShouldDehydrateMutation" + }, + { + "label": "Functions / defaultShouldDehydrateQuery", + "to": "framework/solid/reference/functions/defaultShouldDehydrateQuery" + }, + { + "label": "Functions / dehydrate", + "to": "framework/solid/reference/functions/dehydrate" + }, + { + "label": "Functions / dehydrateQuery", + "to": "framework/solid/reference/functions/dehydrateQuery" + }, + { + "label": "Functions / experimental_streamedQuery", + "to": "framework/solid/reference/functions/experimental_streamedQuery" + }, + { + "label": "Functions / hashKey", + "to": "framework/solid/reference/functions/hashKey" + }, + { + "label": "Functions / hydrate", + "to": "framework/solid/reference/functions/hydrate" + }, + { + "label": "Functions / infiniteQueryOptions", + "to": "framework/solid/reference/functions/infiniteQueryOptions" + }, + { + "label": "Functions / isCancelledError", + "to": "framework/solid/reference/functions/isCancelledError" + }, + { + "label": "Functions / keepPreviousData", + "to": "framework/solid/reference/functions/keepPreviousData" + }, + { + "label": "Functions / matchMutation", + "to": "framework/solid/reference/functions/matchMutation" + }, + { + "label": "Functions / matchQuery", + "to": "framework/solid/reference/functions/matchQuery" + }, + { + "label": "Functions / mutationOptions", + "to": "framework/solid/reference/functions/mutationOptions" + }, + { + "label": "Functions / noop", + "to": "framework/solid/reference/functions/noop" + }, + { + "label": "Functions / partialMatchKey", + "to": "framework/solid/reference/functions/partialMatchKey" + }, + { + "label": "Functions / queryOptions", + "to": "framework/solid/reference/functions/queryOptions" + }, + { + "label": "Functions / replaceEqualDeep", + "to": "framework/solid/reference/functions/replaceEqualDeep" + }, + { + "label": "Functions / shouldThrowError", + "to": "framework/solid/reference/functions/shouldThrowError" + }, + { + "label": "Functions / useInfiniteQuery", + "to": "framework/solid/reference/functions/useInfiniteQuery" + }, + { + "label": "Functions / useIsFetching", + "to": "framework/solid/reference/functions/useIsFetching" + }, + { + "label": "Functions / useIsMutating", + "to": "framework/solid/reference/functions/useIsMutating" + }, + { + "label": "Functions / useIsRestoring", + "to": "framework/solid/reference/functions/useIsRestoring" + }, + { + "label": "Functions / useMutation", + "to": "framework/solid/reference/functions/useMutation" + }, + { + "label": "Functions / useMutationState", + "to": "framework/solid/reference/functions/useMutationState" + }, + { + "label": "Functions / useQueries", + "to": "framework/solid/reference/functions/useQueries" + }, + { + "label": "Functions / useQuery", + "to": "framework/solid/reference/functions/useQuery" + }, + { + "label": "Functions / useQueryClient", + "to": "framework/solid/reference/functions/useQueryClient" + }, + { + "label": "Classes / CancelledError", + "to": "framework/solid/reference/classes/CancelledError" + }, + { + "label": "Classes / InfiniteQueryObserver", + "to": "framework/solid/reference/classes/InfiniteQueryObserver" + }, + { + "label": "Classes / Mutation", + "to": "framework/solid/reference/classes/Mutation" + }, + { + "label": "Classes / MutationCache", + "to": "framework/solid/reference/classes/MutationCache" + }, + { + "label": "Classes / MutationObserver", + "to": "framework/solid/reference/classes/MutationObserver" + }, + { + "label": "Classes / QueriesObserver", + "to": "framework/solid/reference/classes/QueriesObserver" + }, + { + "label": "Classes / Query", + "to": "framework/solid/reference/classes/Query" + }, + { + "label": "Classes / QueryCache", + "to": "framework/solid/reference/classes/QueryCache" + }, + { + "label": "Classes / QueryClient", + "to": "framework/solid/reference/classes/QueryClient" + }, + { + "label": "Classes / QueryObserver", + "to": "framework/solid/reference/classes/QueryObserver" + }, + { + "label": "Interfaces / CancelOptions", + "to": "framework/solid/reference/interfaces/CancelOptions" + }, + { + "label": "Interfaces / DefaultOptions", + "to": "framework/solid/reference/interfaces/DefaultOptions" + }, + { + "label": "Interfaces / DehydrateOptions", + "to": "framework/solid/reference/interfaces/DehydrateOptions" + }, + { + "label": "Interfaces / DehydratedState", + "to": "framework/solid/reference/interfaces/DehydratedState" + }, + { + "label": "Interfaces / EnsureQueryDataOptions", + "to": "framework/solid/reference/interfaces/EnsureQueryDataOptions" + }, + { + "label": "Interfaces / FetchNextPageOptions", + "to": "framework/solid/reference/interfaces/FetchNextPageOptions" + }, + { + "label": "Interfaces / FetchPreviousPageOptions", + "to": "framework/solid/reference/interfaces/FetchPreviousPageOptions" + }, + { + "label": "Interfaces / FetchQueryOptions", + "to": "framework/solid/reference/interfaces/FetchQueryOptions" + }, + { + "label": "Interfaces / FocusManager", + "to": "framework/solid/reference/interfaces/FocusManager" + }, + { + "label": "Interfaces / HydrateOptions", + "to": "framework/solid/reference/interfaces/HydrateOptions" + }, + { + "label": "Interfaces / InfiniteData", + "to": "framework/solid/reference/interfaces/InfiniteData" + }, + { + "label": "Interfaces / InfiniteQueryObserverBaseResult", + "to": "framework/solid/reference/interfaces/InfiniteQueryObserverBaseResult" + }, + { + "label": "Interfaces / InfiniteQueryObserverLoadingErrorResult", + "to": "framework/solid/reference/interfaces/InfiniteQueryObserverLoadingErrorResult" + }, + { + "label": "Interfaces / InfiniteQueryObserverLoadingResult", + "to": "framework/solid/reference/interfaces/InfiniteQueryObserverLoadingResult" + }, + { + "label": "Interfaces / InfiniteQueryObserverOptions", + "to": "framework/solid/reference/interfaces/InfiniteQueryObserverOptions" + }, + { + "label": "Interfaces / InfiniteQueryObserverPendingResult", + "to": "framework/solid/reference/interfaces/InfiniteQueryObserverPendingResult" + }, + { + "label": "Interfaces / InfiniteQueryObserverPlaceholderResult", + "to": "framework/solid/reference/interfaces/InfiniteQueryObserverPlaceholderResult" + }, + { + "label": "Interfaces / InfiniteQueryObserverRefetchErrorResult", + "to": "framework/solid/reference/interfaces/InfiniteQueryObserverRefetchErrorResult" + }, + { + "label": "Interfaces / InfiniteQueryObserverSuccessResult", + "to": "framework/solid/reference/interfaces/InfiniteQueryObserverSuccessResult" + }, + { + "label": "Interfaces / InfiniteQueryOptions", + "to": "framework/solid/reference/interfaces/InfiniteQueryOptions" + }, + { + "label": "Interfaces / InfiniteQueryPageParamsOptions", + "to": "framework/solid/reference/interfaces/InfiniteQueryPageParamsOptions" + }, + { + "label": "Interfaces / InitialPageParam", + "to": "framework/solid/reference/interfaces/InitialPageParam" + }, + { + "label": "Interfaces / InvalidateOptions", + "to": "framework/solid/reference/interfaces/InvalidateOptions" + }, + { + "label": "Interfaces / InvalidateQueryFilters", + "to": "framework/solid/reference/interfaces/InvalidateQueryFilters" + }, + { + "label": "Interfaces / MutateOptions", + "to": "framework/solid/reference/interfaces/MutateOptions" + }, + { + "label": "Interfaces / MutationCacheConfig", + "to": "framework/solid/reference/interfaces/MutationCacheConfig" + }, + { + "label": "Interfaces / MutationFilters", + "to": "framework/solid/reference/interfaces/MutationFilters" + }, + { + "label": "Interfaces / MutationObserverBaseResult", + "to": "framework/solid/reference/interfaces/MutationObserverBaseResult" + }, + { + "label": "Interfaces / MutationObserverErrorResult", + "to": "framework/solid/reference/interfaces/MutationObserverErrorResult" + }, + { + "label": "Interfaces / MutationObserverIdleResult", + "to": "framework/solid/reference/interfaces/MutationObserverIdleResult" + }, + { + "label": "Interfaces / MutationObserverLoadingResult", + "to": "framework/solid/reference/interfaces/MutationObserverLoadingResult" + }, + { + "label": "Interfaces / MutationObserverOptions", + "to": "framework/solid/reference/interfaces/MutationObserverOptions" + }, + { + "label": "Interfaces / MutationObserverSuccessResult", + "to": "framework/solid/reference/interfaces/MutationObserverSuccessResult" + }, + { + "label": "Interfaces / MutationOptions", + "to": "framework/solid/reference/interfaces/MutationOptions" + }, + { + "label": "Interfaces / MutationState", + "to": "framework/solid/reference/interfaces/MutationState" + }, + { + "label": "Interfaces / NotifyEvent", + "to": "framework/solid/reference/interfaces/NotifyEvent" + }, + { + "label": "Interfaces / OnlineManager", + "to": "framework/solid/reference/interfaces/OnlineManager" + }, + { + "label": "Interfaces / QueriesObserverOptions", + "to": "framework/solid/reference/interfaces/QueriesObserverOptions" + }, + { + "label": "Interfaces / QueryCacheConfig", + "to": "framework/solid/reference/interfaces/QueryCacheConfig" + }, + { + "label": "Interfaces / QueryClientConfig", + "to": "framework/solid/reference/interfaces/QueryClientConfig" + }, + { + "label": "Interfaces / QueryExecuteOptions", + "to": "framework/solid/reference/interfaces/QueryExecuteOptions" + }, + { + "label": "Interfaces / QueryFilters", + "to": "framework/solid/reference/interfaces/QueryFilters" + }, + { + "label": "Interfaces / QueryObserverBaseResult", + "to": "framework/solid/reference/interfaces/QueryObserverBaseResult" + }, + { + "label": "Interfaces / QueryObserverLoadingErrorResult", + "to": "framework/solid/reference/interfaces/QueryObserverLoadingErrorResult" + }, + { + "label": "Interfaces / QueryObserverLoadingResult", + "to": "framework/solid/reference/interfaces/QueryObserverLoadingResult" + }, + { + "label": "Interfaces / QueryObserverOptions", + "to": "framework/solid/reference/interfaces/QueryObserverOptions" + }, + { + "label": "Interfaces / QueryObserverPendingResult", + "to": "framework/solid/reference/interfaces/QueryObserverPendingResult" + }, + { + "label": "Interfaces / QueryObserverPlaceholderResult", + "to": "framework/solid/reference/interfaces/QueryObserverPlaceholderResult" + }, + { + "label": "Interfaces / QueryObserverRefetchErrorResult", + "to": "framework/solid/reference/interfaces/QueryObserverRefetchErrorResult" + }, + { + "label": "Interfaces / QueryObserverSuccessResult", + "to": "framework/solid/reference/interfaces/QueryObserverSuccessResult" + }, + { + "label": "Interfaces / QueryOptions", + "to": "framework/solid/reference/interfaces/QueryOptions" + }, + { + "label": "Interfaces / QueryState", + "to": "framework/solid/reference/interfaces/QueryState" + }, + { + "label": "Interfaces / RefetchOptions", + "to": "framework/solid/reference/interfaces/RefetchOptions" + }, + { + "label": "Interfaces / RefetchQueryFilters", + "to": "framework/solid/reference/interfaces/RefetchQueryFilters" + }, + { + "label": "Interfaces / Register", + "to": "framework/solid/reference/interfaces/Register" + }, + { + "label": "Interfaces / ResetOptions", + "to": "framework/solid/reference/interfaces/ResetOptions" + }, + { + "label": "Interfaces / ResultOptions", + "to": "framework/solid/reference/interfaces/ResultOptions" + }, + { + "label": "Interfaces / SetDataOptions", + "to": "framework/solid/reference/interfaces/SetDataOptions" + }, + { + "label": "Interfaces / TimeoutManager", + "to": "framework/solid/reference/interfaces/TimeoutManager" + }, + { + "label": "Interfaces / UseBaseQueryOptions", + "to": "framework/solid/reference/interfaces/UseBaseQueryOptions" + }, + { + "label": "Types / AnyDataTag", + "to": "framework/solid/reference/type-aliases/AnyDataTag" + }, + { + "label": "Types / DataTag", + "to": "framework/solid/reference/type-aliases/DataTag" + }, + { + "label": "Types / DefaultError", + "to": "framework/solid/reference/type-aliases/DefaultError" + }, + { + "label": "Types / DefaultedInfiniteQueryObserverOptions", + "to": "framework/solid/reference/type-aliases/DefaultedInfiniteQueryObserverOptions" + }, + { + "label": "Types / DefaultedQueryObserverOptions", + "to": "framework/solid/reference/type-aliases/DefaultedQueryObserverOptions" + }, + { + "label": "Types / DefinedInfiniteQueryObserverResult", + "to": "framework/solid/reference/type-aliases/DefinedInfiniteQueryObserverResult" + }, + { + "label": "Types / DefinedInitialDataInfiniteOptions", + "to": "framework/solid/reference/type-aliases/DefinedInitialDataInfiniteOptions" + }, + { + "label": "Types / DefinedInitialDataOptions", + "to": "framework/solid/reference/type-aliases/DefinedInitialDataOptions" + }, + { + "label": "Types / DefinedQueryObserverResult", + "to": "framework/solid/reference/type-aliases/DefinedQueryObserverResult" + }, + { + "label": "Types / DefinedUseBaseQueryResult", + "to": "framework/solid/reference/type-aliases/DefinedUseBaseQueryResult" + }, + { + "label": "Types / DefinedUseInfiniteQueryResult", + "to": "framework/solid/reference/type-aliases/DefinedUseInfiniteQueryResult" + }, + { + "label": "Types / DefinedUseQueryResult", + "to": "framework/solid/reference/type-aliases/DefinedUseQueryResult" + }, + { + "label": "Types / DistributiveOmit", + "to": "framework/solid/reference/type-aliases/DistributiveOmit" + }, + { + "label": "Types / EnsureInfiniteQueryDataOptions", + "to": "framework/solid/reference/type-aliases/EnsureInfiniteQueryDataOptions" + }, + { + "label": "Types / FetchInfiniteQueryOptions", + "to": "framework/solid/reference/type-aliases/FetchInfiniteQueryOptions" + }, + { + "label": "Types / FetchStatus", + "to": "framework/solid/reference/type-aliases/FetchStatus" + }, + { + "label": "Types / GetNextPageParamFunction", + "to": "framework/solid/reference/type-aliases/GetNextPageParamFunction" + }, + { + "label": "Types / GetPreviousPageParamFunction", + "to": "framework/solid/reference/type-aliases/GetPreviousPageParamFunction" + }, + { + "label": "Types / InferDataFromTag", + "to": "framework/solid/reference/type-aliases/InferDataFromTag" + }, + { + "label": "Types / InferErrorFromTag", + "to": "framework/solid/reference/type-aliases/InferErrorFromTag" + }, + { + "label": "Types / InfiniteQueryExecuteOptions", + "to": "framework/solid/reference/type-aliases/InfiniteQueryExecuteOptions" + }, + { + "label": "Types / InfiniteQueryObserverResult", + "to": "framework/solid/reference/type-aliases/InfiniteQueryObserverResult" + }, + { + "label": "Types / InitialDataFunction", + "to": "framework/solid/reference/type-aliases/InitialDataFunction" + }, + { + "label": "Types / ManagedTimerId", + "to": "framework/solid/reference/type-aliases/ManagedTimerId" + }, + { + "label": "Types / MutateFunction", + "to": "framework/solid/reference/type-aliases/MutateFunction" + }, + { + "label": "Types / MutateFunctionRest", + "to": "framework/solid/reference/type-aliases/MutateFunctionRest" + }, + { + "label": "Types / MutationCacheNotifyEvent", + "to": "framework/solid/reference/type-aliases/MutationCacheNotifyEvent" + }, + { + "label": "Types / MutationFunction", + "to": "framework/solid/reference/type-aliases/MutationFunction" + }, + { + "label": "Types / MutationFunctionContext", + "to": "framework/solid/reference/type-aliases/MutationFunctionContext" + }, + { + "label": "Types / MutationKey", + "to": "framework/solid/reference/type-aliases/MutationKey" + }, + { + "label": "Types / MutationMeta", + "to": "framework/solid/reference/type-aliases/MutationMeta" + }, + { + "label": "Types / MutationObserverResult", + "to": "framework/solid/reference/type-aliases/MutationObserverResult" + }, + { + "label": "Types / MutationScope", + "to": "framework/solid/reference/type-aliases/MutationScope" + }, + { + "label": "Types / MutationStatus", + "to": "framework/solid/reference/type-aliases/MutationStatus" + }, + { + "label": "Types / NetworkMode", + "to": "framework/solid/reference/type-aliases/NetworkMode" + }, + { + "label": "Types / NonUndefinedGuard", + "to": "framework/solid/reference/type-aliases/NonUndefinedGuard" + }, + { + "label": "Types / NotifyEventType", + "to": "framework/solid/reference/type-aliases/NotifyEventType" + }, + { + "label": "Types / NotifyOnChangeProps", + "to": "framework/solid/reference/type-aliases/NotifyOnChangeProps" + }, + { + "label": "Types / OmitKeyof", + "to": "framework/solid/reference/type-aliases/OmitKeyof" + }, + { + "label": "Types / Override", + "to": "framework/solid/reference/type-aliases/Override" + }, + { + "label": "Types / PlaceholderDataFunction", + "to": "framework/solid/reference/type-aliases/PlaceholderDataFunction" + }, + { + "label": "Types / QueriesPlaceholderDataFunction", + "to": "framework/solid/reference/type-aliases/QueriesPlaceholderDataFunction" + }, + { + "label": "Types / QueryBooleanOption", + "to": "framework/solid/reference/type-aliases/QueryBooleanOption" + }, + { + "label": "Types / QueryCacheNotifyEvent", + "to": "framework/solid/reference/type-aliases/QueryCacheNotifyEvent" + }, + { + "label": "Types / QueryClientProviderProps", + "to": "framework/solid/reference/type-aliases/QueryClientProviderProps" + }, + { + "label": "Types / QueryFunction", + "to": "framework/solid/reference/type-aliases/QueryFunction" + }, + { + "label": "Types / QueryFunctionContext", + "to": "framework/solid/reference/type-aliases/QueryFunctionContext" + }, + { + "label": "Types / QueryKey", + "to": "framework/solid/reference/type-aliases/QueryKey" + }, + { + "label": "Types / QueryKeyHashFunction", + "to": "framework/solid/reference/type-aliases/QueryKeyHashFunction" + }, + { + "label": "Types / QueryKeyWithDataTag", + "to": "framework/solid/reference/type-aliases/QueryKeyWithDataTag" + }, + { + "label": "Types / QueryMeta", + "to": "framework/solid/reference/type-aliases/QueryMeta" + }, + { + "label": "Types / QueryObserverResult", + "to": "framework/solid/reference/type-aliases/QueryObserverResult" + }, + { + "label": "Types / QueryPersister", + "to": "framework/solid/reference/type-aliases/QueryPersister" + }, + { + "label": "Types / QueryStatus", + "to": "framework/solid/reference/type-aliases/QueryStatus" + }, + { + "label": "Types / SkipToken", + "to": "framework/solid/reference/type-aliases/SkipToken" + }, + { + "label": "Types / StaleTime", + "to": "framework/solid/reference/type-aliases/StaleTime" + }, + { + "label": "Types / StaleTimeFunction", + "to": "framework/solid/reference/type-aliases/StaleTimeFunction" + }, + { + "label": "Types / ThrowOnError", + "to": "framework/solid/reference/type-aliases/ThrowOnError" + }, + { + "label": "Types / TimeoutCallback", + "to": "framework/solid/reference/type-aliases/TimeoutCallback" + }, + { + "label": "Types / TimeoutProvider", + "to": "framework/solid/reference/type-aliases/TimeoutProvider" + }, + { + "label": "Types / UndefinedInitialDataInfiniteOptions", + "to": "framework/solid/reference/type-aliases/UndefinedInitialDataInfiniteOptions" + }, + { + "label": "Types / UndefinedInitialDataOptions", + "to": "framework/solid/reference/type-aliases/UndefinedInitialDataOptions" + }, + { + "label": "Types / UnsetMarker", + "to": "framework/solid/reference/type-aliases/UnsetMarker" + }, + { + "label": "Types / Updater", + "to": "framework/solid/reference/type-aliases/Updater" + }, + { + "label": "Types / UseBaseMutationResult", + "to": "framework/solid/reference/type-aliases/UseBaseMutationResult" + }, + { + "label": "Types / UseBaseQueryResult", + "to": "framework/solid/reference/type-aliases/UseBaseQueryResult" + }, + { + "label": "Types / UseInfiniteQueryOptions", + "to": "framework/solid/reference/type-aliases/UseInfiniteQueryOptions" + }, + { + "label": "Types / UseInfiniteQueryResult", + "to": "framework/solid/reference/type-aliases/UseInfiniteQueryResult" + }, + { + "label": "Types / UseMutateAsyncFunction", + "to": "framework/solid/reference/type-aliases/UseMutateAsyncFunction" + }, + { + "label": "Types / UseMutateFunction", + "to": "framework/solid/reference/type-aliases/UseMutateFunction" + }, + { + "label": "Types / UseMutationOptions", + "to": "framework/solid/reference/type-aliases/UseMutationOptions" + }, + { + "label": "Types / UseMutationResult", + "to": "framework/solid/reference/type-aliases/UseMutationResult" + }, + { + "label": "Types / UseQueryOptions", + "to": "framework/solid/reference/type-aliases/UseQueryOptions" + }, + { + "label": "Types / UseQueryResult", + "to": "framework/solid/reference/type-aliases/UseQueryResult" + }, + { + "label": "Types / WithRequired", + "to": "framework/solid/reference/type-aliases/WithRequired" + }, + { + "label": "Types / dataTagErrorSymbol", + "to": "framework/solid/reference/type-aliases/dataTagErrorSymbol" + }, + { + "label": "Types / dataTagSymbol", + "to": "framework/solid/reference/type-aliases/dataTagSymbol" + }, + { + "label": "Variables / IsRestoringProvider", + "to": "framework/solid/reference/variables/IsRestoringProvider" + }, + { + "label": "Variables / QueryClientContext", + "to": "framework/solid/reference/variables/QueryClientContext" + }, + { + "label": "Variables / createInfiniteQuery", + "to": "framework/solid/reference/variables/createInfiniteQuery" + }, + { + "label": "Variables / createMutation", + "to": "framework/solid/reference/variables/createMutation" + }, + { + "label": "Variables / createQueries", + "to": "framework/solid/reference/variables/createQueries" + }, + { + "label": "Variables / createQuery", + "to": "framework/solid/reference/variables/createQuery" + }, + { + "label": "Variables / dataTagErrorSymbol", + "to": "framework/solid/reference/variables/dataTagErrorSymbol" + }, + { + "label": "Variables / dataTagSymbol", + "to": "framework/solid/reference/variables/dataTagSymbol" + }, + { + "label": "Variables / defaultScheduler", + "to": "framework/solid/reference/variables/defaultScheduler" + }, + { + "label": "Variables / environmentManager", + "to": "framework/solid/reference/variables/environmentManager" + }, + { + "label": "Variables / focusManager", + "to": "framework/solid/reference/variables/focusManager" + }, + { + "label": "Variables / isServer", + "to": "framework/solid/reference/variables/isServer" + }, + { + "label": "Variables / notifyManager", + "to": "framework/solid/reference/variables/notifyManager" + }, + { + "label": "Variables / onlineManager", + "to": "framework/solid/reference/variables/onlineManager" + }, + { + "label": "Variables / skipToken", + "to": "framework/solid/reference/variables/skipToken" + }, + { + "label": "Variables / timeoutManager", + "to": "framework/solid/reference/variables/timeoutManager" + }, + { + "label": "Variables / unsetMarker", + "to": "framework/solid/reference/variables/unsetMarker" + } + ] + }, + { + "label": "svelte", + "children": [ + { + "label": "Svelte Reference", + "to": "framework/svelte/reference/index" + }, + { + "label": "Functions / createInfiniteQuery", + "to": "framework/svelte/reference/functions/createInfiniteQuery" + }, + { + "label": "Functions / createMutation", + "to": "framework/svelte/reference/functions/createMutation" + }, + { + "label": "Functions / createQueries", + "to": "framework/svelte/reference/functions/createQueries" + }, + { + "label": "Functions / createQuery", + "to": "framework/svelte/reference/functions/createQuery" + }, + { + "label": "Functions / defaultShouldDehydrateMutation", + "to": "framework/svelte/reference/functions/defaultShouldDehydrateMutation" + }, + { + "label": "Functions / defaultShouldDehydrateQuery", + "to": "framework/svelte/reference/functions/defaultShouldDehydrateQuery" + }, + { + "label": "Functions / dehydrate", + "to": "framework/svelte/reference/functions/dehydrate" + }, + { + "label": "Functions / dehydrateQuery", + "to": "framework/svelte/reference/functions/dehydrateQuery" + }, + { + "label": "Functions / experimental_streamedQuery", + "to": "framework/svelte/reference/functions/experimental_streamedQuery" + }, + { + "label": "Functions / getIsRestoringContext", + "to": "framework/svelte/reference/functions/getIsRestoringContext" + }, + { + "label": "Functions / getQueryClientContext", + "to": "framework/svelte/reference/functions/getQueryClientContext" + }, + { + "label": "Functions / hashKey", + "to": "framework/svelte/reference/functions/hashKey" + }, + { + "label": "Functions / hydrate", + "to": "framework/svelte/reference/functions/hydrate" + }, + { + "label": "Functions / infiniteQueryOptions", + "to": "framework/svelte/reference/functions/infiniteQueryOptions" + }, + { + "label": "Functions / isCancelledError", + "to": "framework/svelte/reference/functions/isCancelledError" + }, + { + "label": "Functions / keepPreviousData", + "to": "framework/svelte/reference/functions/keepPreviousData" + }, + { + "label": "Functions / matchMutation", + "to": "framework/svelte/reference/functions/matchMutation" + }, + { + "label": "Functions / matchQuery", + "to": "framework/svelte/reference/functions/matchQuery" + }, + { + "label": "Functions / mutationOptions", + "to": "framework/svelte/reference/functions/mutationOptions" + }, + { + "label": "Functions / noop", + "to": "framework/svelte/reference/functions/noop" + }, + { + "label": "Functions / partialMatchKey", + "to": "framework/svelte/reference/functions/partialMatchKey" + }, + { + "label": "Functions / queryOptions", + "to": "framework/svelte/reference/functions/queryOptions" + }, + { + "label": "Functions / replaceEqualDeep", + "to": "framework/svelte/reference/functions/replaceEqualDeep" + }, + { + "label": "Functions / setIsRestoringContext", + "to": "framework/svelte/reference/functions/setIsRestoringContext" + }, + { + "label": "Functions / setQueryClientContext", + "to": "framework/svelte/reference/functions/setQueryClientContext" + }, + { + "label": "Functions / shouldThrowError", + "to": "framework/svelte/reference/functions/shouldThrowError" + }, + { + "label": "Functions / useHydrate", + "to": "framework/svelte/reference/functions/useHydrate" + }, + { + "label": "Functions / useIsFetching", + "to": "framework/svelte/reference/functions/useIsFetching" + }, + { + "label": "Functions / useIsMutating", + "to": "framework/svelte/reference/functions/useIsMutating" + }, + { + "label": "Functions / useIsRestoring", + "to": "framework/svelte/reference/functions/useIsRestoring" + }, + { + "label": "Functions / useMutationState", + "to": "framework/svelte/reference/functions/useMutationState" + }, + { + "label": "Functions / useQueryClient", + "to": "framework/svelte/reference/functions/useQueryClient" + }, + { + "label": "Classes / CancelledError", + "to": "framework/svelte/reference/classes/CancelledError" + }, + { + "label": "Classes / InfiniteQueryObserver", + "to": "framework/svelte/reference/classes/InfiniteQueryObserver" + }, + { + "label": "Classes / Mutation", + "to": "framework/svelte/reference/classes/Mutation" + }, + { + "label": "Classes / MutationCache", + "to": "framework/svelte/reference/classes/MutationCache" + }, + { + "label": "Classes / MutationObserver", + "to": "framework/svelte/reference/classes/MutationObserver" + }, + { + "label": "Classes / QueriesObserver", + "to": "framework/svelte/reference/classes/QueriesObserver" + }, + { + "label": "Classes / Query", + "to": "framework/svelte/reference/classes/Query" + }, + { + "label": "Classes / QueryCache", + "to": "framework/svelte/reference/classes/QueryCache" + }, + { + "label": "Classes / QueryClient", + "to": "framework/svelte/reference/classes/QueryClient" + }, + { + "label": "Classes / QueryObserver", + "to": "framework/svelte/reference/classes/QueryObserver" + }, + { + "label": "Interfaces / CancelOptions", + "to": "framework/svelte/reference/interfaces/CancelOptions" + }, + { + "label": "Interfaces / DefaultOptions", + "to": "framework/svelte/reference/interfaces/DefaultOptions" + }, + { + "label": "Interfaces / DehydrateOptions", + "to": "framework/svelte/reference/interfaces/DehydrateOptions" + }, + { + "label": "Interfaces / DehydratedState", + "to": "framework/svelte/reference/interfaces/DehydratedState" + }, + { + "label": "Interfaces / EnsureQueryDataOptions", + "to": "framework/svelte/reference/interfaces/EnsureQueryDataOptions" + }, + { + "label": "Interfaces / FetchNextPageOptions", + "to": "framework/svelte/reference/interfaces/FetchNextPageOptions" + }, + { + "label": "Interfaces / FetchPreviousPageOptions", + "to": "framework/svelte/reference/interfaces/FetchPreviousPageOptions" + }, + { + "label": "Interfaces / FetchQueryOptions", + "to": "framework/svelte/reference/interfaces/FetchQueryOptions" + }, + { + "label": "Interfaces / FocusManager", + "to": "framework/svelte/reference/interfaces/FocusManager" + }, + { + "label": "Interfaces / HydrateOptions", + "to": "framework/svelte/reference/interfaces/HydrateOptions" + }, + { + "label": "Interfaces / InfiniteData", + "to": "framework/svelte/reference/interfaces/InfiniteData" + }, + { + "label": "Interfaces / InfiniteQueryObserverBaseResult", + "to": "framework/svelte/reference/interfaces/InfiniteQueryObserverBaseResult" + }, + { + "label": "Interfaces / InfiniteQueryObserverLoadingErrorResult", + "to": "framework/svelte/reference/interfaces/InfiniteQueryObserverLoadingErrorResult" + }, + { + "label": "Interfaces / InfiniteQueryObserverLoadingResult", + "to": "framework/svelte/reference/interfaces/InfiniteQueryObserverLoadingResult" + }, + { + "label": "Interfaces / InfiniteQueryObserverOptions", + "to": "framework/svelte/reference/interfaces/InfiniteQueryObserverOptions" + }, + { + "label": "Interfaces / InfiniteQueryObserverPendingResult", + "to": "framework/svelte/reference/interfaces/InfiniteQueryObserverPendingResult" + }, + { + "label": "Interfaces / InfiniteQueryObserverPlaceholderResult", + "to": "framework/svelte/reference/interfaces/InfiniteQueryObserverPlaceholderResult" + }, + { + "label": "Interfaces / InfiniteQueryObserverRefetchErrorResult", + "to": "framework/svelte/reference/interfaces/InfiniteQueryObserverRefetchErrorResult" + }, + { + "label": "Interfaces / InfiniteQueryObserverSuccessResult", + "to": "framework/svelte/reference/interfaces/InfiniteQueryObserverSuccessResult" + }, + { + "label": "Interfaces / InfiniteQueryPageParamsOptions", + "to": "framework/svelte/reference/interfaces/InfiniteQueryPageParamsOptions" + }, + { + "label": "Interfaces / InitialPageParam", + "to": "framework/svelte/reference/interfaces/InitialPageParam" + }, + { + "label": "Interfaces / InvalidateOptions", + "to": "framework/svelte/reference/interfaces/InvalidateOptions" + }, + { + "label": "Interfaces / InvalidateQueryFilters", + "to": "framework/svelte/reference/interfaces/InvalidateQueryFilters" + }, + { + "label": "Interfaces / MutateOptions", + "to": "framework/svelte/reference/interfaces/MutateOptions" + }, + { + "label": "Interfaces / MutationCacheConfig", + "to": "framework/svelte/reference/interfaces/MutationCacheConfig" + }, + { + "label": "Interfaces / MutationFilters", + "to": "framework/svelte/reference/interfaces/MutationFilters" + }, + { + "label": "Interfaces / MutationObserverBaseResult", + "to": "framework/svelte/reference/interfaces/MutationObserverBaseResult" + }, + { + "label": "Interfaces / MutationObserverErrorResult", + "to": "framework/svelte/reference/interfaces/MutationObserverErrorResult" + }, + { + "label": "Interfaces / MutationObserverIdleResult", + "to": "framework/svelte/reference/interfaces/MutationObserverIdleResult" + }, + { + "label": "Interfaces / MutationObserverLoadingResult", + "to": "framework/svelte/reference/interfaces/MutationObserverLoadingResult" + }, + { + "label": "Interfaces / MutationObserverOptions", + "to": "framework/svelte/reference/interfaces/MutationObserverOptions" + }, + { + "label": "Interfaces / MutationObserverSuccessResult", + "to": "framework/svelte/reference/interfaces/MutationObserverSuccessResult" + }, + { + "label": "Interfaces / MutationOptions", + "to": "framework/svelte/reference/interfaces/MutationOptions" + }, + { + "label": "Interfaces / MutationState", + "to": "framework/svelte/reference/interfaces/MutationState" + }, + { + "label": "Interfaces / NotifyEvent", + "to": "framework/svelte/reference/interfaces/NotifyEvent" + }, + { + "label": "Interfaces / OnlineManager", + "to": "framework/svelte/reference/interfaces/OnlineManager" + }, + { + "label": "Interfaces / QueriesObserverOptions", + "to": "framework/svelte/reference/interfaces/QueriesObserverOptions" + }, + { + "label": "Interfaces / QueryCacheConfig", + "to": "framework/svelte/reference/interfaces/QueryCacheConfig" + }, + { + "label": "Interfaces / QueryClientConfig", + "to": "framework/svelte/reference/interfaces/QueryClientConfig" + }, + { + "label": "Interfaces / QueryExecuteOptions", + "to": "framework/svelte/reference/interfaces/QueryExecuteOptions" + }, + { + "label": "Interfaces / QueryFilters", + "to": "framework/svelte/reference/interfaces/QueryFilters" + }, + { + "label": "Interfaces / QueryObserverBaseResult", + "to": "framework/svelte/reference/interfaces/QueryObserverBaseResult" + }, + { + "label": "Interfaces / QueryObserverLoadingErrorResult", + "to": "framework/svelte/reference/interfaces/QueryObserverLoadingErrorResult" + }, + { + "label": "Interfaces / QueryObserverLoadingResult", + "to": "framework/svelte/reference/interfaces/QueryObserverLoadingResult" + }, + { + "label": "Interfaces / QueryObserverOptions", + "to": "framework/svelte/reference/interfaces/QueryObserverOptions" + }, + { + "label": "Interfaces / QueryObserverPendingResult", + "to": "framework/svelte/reference/interfaces/QueryObserverPendingResult" + }, + { + "label": "Interfaces / QueryObserverPlaceholderResult", + "to": "framework/svelte/reference/interfaces/QueryObserverPlaceholderResult" + }, + { + "label": "Interfaces / QueryObserverRefetchErrorResult", + "to": "framework/svelte/reference/interfaces/QueryObserverRefetchErrorResult" + }, + { + "label": "Interfaces / QueryObserverSuccessResult", + "to": "framework/svelte/reference/interfaces/QueryObserverSuccessResult" + }, + { + "label": "Interfaces / QueryOptions", + "to": "framework/svelte/reference/interfaces/QueryOptions" + }, + { + "label": "Interfaces / QueryState", + "to": "framework/svelte/reference/interfaces/QueryState" + }, + { + "label": "Interfaces / RefetchOptions", + "to": "framework/svelte/reference/interfaces/RefetchOptions" + }, + { + "label": "Interfaces / RefetchQueryFilters", + "to": "framework/svelte/reference/interfaces/RefetchQueryFilters" + }, + { + "label": "Interfaces / Register", + "to": "framework/svelte/reference/interfaces/Register" + }, + { + "label": "Interfaces / ResetOptions", + "to": "framework/svelte/reference/interfaces/ResetOptions" + }, + { + "label": "Interfaces / ResultOptions", + "to": "framework/svelte/reference/interfaces/ResultOptions" + }, + { + "label": "Interfaces / SetDataOptions", + "to": "framework/svelte/reference/interfaces/SetDataOptions" + }, + { + "label": "Interfaces / TimeoutManager", + "to": "framework/svelte/reference/interfaces/TimeoutManager" + }, + { + "label": "Types / Accessor", + "to": "framework/svelte/reference/type-aliases/Accessor" + }, + { + "label": "Types / AnyDataTag", + "to": "framework/svelte/reference/type-aliases/AnyDataTag" + }, + { + "label": "Types / CreateBaseMutationResult", + "to": "framework/svelte/reference/type-aliases/CreateBaseMutationResult" + }, + { + "label": "Types / CreateBaseQueryOptions", + "to": "framework/svelte/reference/type-aliases/CreateBaseQueryOptions" + }, + { + "label": "Types / CreateBaseQueryResult", + "to": "framework/svelte/reference/type-aliases/CreateBaseQueryResult" + }, + { + "label": "Types / CreateInfiniteQueryOptions", + "to": "framework/svelte/reference/type-aliases/CreateInfiniteQueryOptions" + }, + { + "label": "Types / CreateInfiniteQueryResult", + "to": "framework/svelte/reference/type-aliases/CreateInfiniteQueryResult" + }, + { + "label": "Types / CreateMutateAsyncFunction", + "to": "framework/svelte/reference/type-aliases/CreateMutateAsyncFunction" + }, + { + "label": "Types / CreateMutateFunction", + "to": "framework/svelte/reference/type-aliases/CreateMutateFunction" + }, + { + "label": "Types / CreateMutationOptions", + "to": "framework/svelte/reference/type-aliases/CreateMutationOptions" + }, + { + "label": "Types / CreateMutationResult", + "to": "framework/svelte/reference/type-aliases/CreateMutationResult" + }, + { + "label": "Types / CreateQueryOptions", + "to": "framework/svelte/reference/type-aliases/CreateQueryOptions" + }, + { + "label": "Types / CreateQueryResult", + "to": "framework/svelte/reference/type-aliases/CreateQueryResult" + }, + { + "label": "Types / DataTag", + "to": "framework/svelte/reference/type-aliases/DataTag" + }, + { + "label": "Types / DefaultError", + "to": "framework/svelte/reference/type-aliases/DefaultError" + }, + { + "label": "Types / DefaultedInfiniteQueryObserverOptions", + "to": "framework/svelte/reference/type-aliases/DefaultedInfiniteQueryObserverOptions" + }, + { + "label": "Types / DefaultedQueryObserverOptions", + "to": "framework/svelte/reference/type-aliases/DefaultedQueryObserverOptions" + }, + { + "label": "Types / DefinedCreateBaseQueryResult", + "to": "framework/svelte/reference/type-aliases/DefinedCreateBaseQueryResult" + }, + { + "label": "Types / DefinedCreateQueryResult", + "to": "framework/svelte/reference/type-aliases/DefinedCreateQueryResult" + }, + { + "label": "Types / DefinedInfiniteQueryObserverResult", + "to": "framework/svelte/reference/type-aliases/DefinedInfiniteQueryObserverResult" + }, + { + "label": "Types / DefinedInitialDataOptions", + "to": "framework/svelte/reference/type-aliases/DefinedInitialDataOptions" + }, + { + "label": "Types / DefinedQueryObserverResult", + "to": "framework/svelte/reference/type-aliases/DefinedQueryObserverResult" + }, + { + "label": "Types / DistributiveOmit", + "to": "framework/svelte/reference/type-aliases/DistributiveOmit" + }, + { + "label": "Types / EnsureInfiniteQueryDataOptions", + "to": "framework/svelte/reference/type-aliases/EnsureInfiniteQueryDataOptions" + }, + { + "label": "Types / FetchInfiniteQueryOptions", + "to": "framework/svelte/reference/type-aliases/FetchInfiniteQueryOptions" + }, + { + "label": "Types / FetchStatus", + "to": "framework/svelte/reference/type-aliases/FetchStatus" + }, + { + "label": "Types / GetNextPageParamFunction", + "to": "framework/svelte/reference/type-aliases/GetNextPageParamFunction" + }, + { + "label": "Types / GetPreviousPageParamFunction", + "to": "framework/svelte/reference/type-aliases/GetPreviousPageParamFunction" + }, + { + "label": "Types / HydrationBoundary", + "to": "framework/svelte/reference/type-aliases/HydrationBoundary" + }, + { + "label": "Types / InferDataFromTag", + "to": "framework/svelte/reference/type-aliases/InferDataFromTag" + }, + { + "label": "Types / InferErrorFromTag", + "to": "framework/svelte/reference/type-aliases/InferErrorFromTag" + }, + { + "label": "Types / InfiniteQueryExecuteOptions", + "to": "framework/svelte/reference/type-aliases/InfiniteQueryExecuteOptions" + }, + { + "label": "Types / InfiniteQueryObserverResult", + "to": "framework/svelte/reference/type-aliases/InfiniteQueryObserverResult" + }, + { + "label": "Types / InitialDataFunction", + "to": "framework/svelte/reference/type-aliases/InitialDataFunction" + }, + { + "label": "Types / ManagedTimerId", + "to": "framework/svelte/reference/type-aliases/ManagedTimerId" + }, + { + "label": "Types / MutateFunction", + "to": "framework/svelte/reference/type-aliases/MutateFunction" + }, + { + "label": "Types / MutateFunctionRest", + "to": "framework/svelte/reference/type-aliases/MutateFunctionRest" + }, + { + "label": "Types / MutationCacheNotifyEvent", + "to": "framework/svelte/reference/type-aliases/MutationCacheNotifyEvent" + }, + { + "label": "Types / MutationFunction", + "to": "framework/svelte/reference/type-aliases/MutationFunction" + }, + { + "label": "Types / MutationFunctionContext", + "to": "framework/svelte/reference/type-aliases/MutationFunctionContext" + }, + { + "label": "Types / MutationKey", + "to": "framework/svelte/reference/type-aliases/MutationKey" + }, + { + "label": "Types / MutationMeta", + "to": "framework/svelte/reference/type-aliases/MutationMeta" + }, + { + "label": "Types / MutationObserverResult", + "to": "framework/svelte/reference/type-aliases/MutationObserverResult" + }, + { + "label": "Types / MutationScope", + "to": "framework/svelte/reference/type-aliases/MutationScope" + }, + { + "label": "Types / MutationStateOptions", + "to": "framework/svelte/reference/type-aliases/MutationStateOptions" + }, + { + "label": "Types / MutationStatus", + "to": "framework/svelte/reference/type-aliases/MutationStatus" + }, + { + "label": "Types / MutationTypeFromResult", + "to": "framework/svelte/reference/type-aliases/MutationTypeFromResult" + }, + { + "label": "Types / NetworkMode", + "to": "framework/svelte/reference/type-aliases/NetworkMode" + }, + { + "label": "Types / NonUndefinedGuard", + "to": "framework/svelte/reference/type-aliases/NonUndefinedGuard" + }, + { + "label": "Types / NotifyEventType", + "to": "framework/svelte/reference/type-aliases/NotifyEventType" + }, + { + "label": "Types / NotifyOnChangeProps", + "to": "framework/svelte/reference/type-aliases/NotifyOnChangeProps" + }, + { + "label": "Types / OmitKeyof", + "to": "framework/svelte/reference/type-aliases/OmitKeyof" + }, + { + "label": "Types / Override", + "to": "framework/svelte/reference/type-aliases/Override" + }, + { + "label": "Types / PlaceholderDataFunction", + "to": "framework/svelte/reference/type-aliases/PlaceholderDataFunction" + }, + { + "label": "Types / QueriesOptions", + "to": "framework/svelte/reference/type-aliases/QueriesOptions" + }, + { + "label": "Types / QueriesPlaceholderDataFunction", + "to": "framework/svelte/reference/type-aliases/QueriesPlaceholderDataFunction" + }, + { + "label": "Types / QueriesResults", + "to": "framework/svelte/reference/type-aliases/QueriesResults" + }, + { + "label": "Types / QueryBooleanOption", + "to": "framework/svelte/reference/type-aliases/QueryBooleanOption" + }, + { + "label": "Types / QueryCacheNotifyEvent", + "to": "framework/svelte/reference/type-aliases/QueryCacheNotifyEvent" + }, + { + "label": "Types / QueryClientProviderProps", + "to": "framework/svelte/reference/type-aliases/QueryClientProviderProps" + }, + { + "label": "Types / QueryFunction", + "to": "framework/svelte/reference/type-aliases/QueryFunction" + }, + { + "label": "Types / QueryFunctionContext", + "to": "framework/svelte/reference/type-aliases/QueryFunctionContext" + }, + { + "label": "Types / QueryKey", + "to": "framework/svelte/reference/type-aliases/QueryKey" + }, + { + "label": "Types / QueryKeyHashFunction", + "to": "framework/svelte/reference/type-aliases/QueryKeyHashFunction" + }, + { + "label": "Types / QueryKeyWithDataTag", + "to": "framework/svelte/reference/type-aliases/QueryKeyWithDataTag" + }, + { + "label": "Types / QueryMeta", + "to": "framework/svelte/reference/type-aliases/QueryMeta" + }, + { + "label": "Types / QueryObserverResult", + "to": "framework/svelte/reference/type-aliases/QueryObserverResult" + }, + { + "label": "Types / QueryPersister", + "to": "framework/svelte/reference/type-aliases/QueryPersister" + }, + { + "label": "Types / QueryStatus", + "to": "framework/svelte/reference/type-aliases/QueryStatus" + }, + { + "label": "Types / SkipToken", + "to": "framework/svelte/reference/type-aliases/SkipToken" + }, + { + "label": "Types / StaleTime", + "to": "framework/svelte/reference/type-aliases/StaleTime" + }, + { + "label": "Types / StaleTimeFunction", + "to": "framework/svelte/reference/type-aliases/StaleTimeFunction" + }, + { + "label": "Types / ThrowOnError", + "to": "framework/svelte/reference/type-aliases/ThrowOnError" + }, + { + "label": "Types / TimeoutCallback", + "to": "framework/svelte/reference/type-aliases/TimeoutCallback" + }, + { + "label": "Types / TimeoutProvider", + "to": "framework/svelte/reference/type-aliases/TimeoutProvider" + }, + { + "label": "Types / UndefinedInitialDataOptions", + "to": "framework/svelte/reference/type-aliases/UndefinedInitialDataOptions" + }, + { + "label": "Types / UnsetMarker", + "to": "framework/svelte/reference/type-aliases/UnsetMarker" + }, + { + "label": "Types / Updater", + "to": "framework/svelte/reference/type-aliases/Updater" + }, + { + "label": "Types / WithRequired", + "to": "framework/svelte/reference/type-aliases/WithRequired" + }, + { + "label": "Types / dataTagErrorSymbol", + "to": "framework/svelte/reference/type-aliases/dataTagErrorSymbol" + }, + { + "label": "Types / dataTagSymbol", + "to": "framework/svelte/reference/type-aliases/dataTagSymbol" + }, + { + "label": "Variables / HydrationBoundary", + "to": "framework/svelte/reference/variables/HydrationBoundary" + }, + { + "label": "Variables / dataTagErrorSymbol", + "to": "framework/svelte/reference/variables/dataTagErrorSymbol" + }, + { + "label": "Variables / dataTagSymbol", + "to": "framework/svelte/reference/variables/dataTagSymbol" + }, + { + "label": "Variables / defaultScheduler", + "to": "framework/svelte/reference/variables/defaultScheduler" + }, + { + "label": "Variables / environmentManager", + "to": "framework/svelte/reference/variables/environmentManager" + }, + { + "label": "Variables / focusManager", + "to": "framework/svelte/reference/variables/focusManager" + }, + { + "label": "Variables / isServer", + "to": "framework/svelte/reference/variables/isServer" + }, + { + "label": "Variables / notifyManager", + "to": "framework/svelte/reference/variables/notifyManager" + }, + { + "label": "Variables / onlineManager", + "to": "framework/svelte/reference/variables/onlineManager" + }, + { + "label": "Variables / skipToken", + "to": "framework/svelte/reference/variables/skipToken" + }, + { + "label": "Variables / timeoutManager", + "to": "framework/svelte/reference/variables/timeoutManager" + }, + { + "label": "Variables / unsetMarker", + "to": "framework/svelte/reference/variables/unsetMarker" + } + ] + }, + { + "label": "lit", + "children": [ + { + "label": "Lit Reference", + "to": "framework/lit/reference/index" + }, + { + "label": "Classes / CancelledError", + "to": "framework/lit/reference/classes/CancelledError" + }, + { + "label": "Classes / InfiniteQueryObserver", + "to": "framework/lit/reference/classes/InfiniteQueryObserver" + }, + { + "label": "Classes / Mutation", + "to": "framework/lit/reference/classes/Mutation" + }, + { + "label": "Classes / MutationCache", + "to": "framework/lit/reference/classes/MutationCache" + }, + { + "label": "Classes / MutationObserver", + "to": "framework/lit/reference/classes/MutationObserver" + }, + { + "label": "Classes / QueriesObserver", + "to": "framework/lit/reference/classes/QueriesObserver" + }, + { + "label": "Classes / Query", + "to": "framework/lit/reference/classes/Query" + }, + { + "label": "Classes / QueryCache", + "to": "framework/lit/reference/classes/QueryCache" + }, + { + "label": "Classes / QueryClient", + "to": "framework/lit/reference/classes/QueryClient" + }, + { + "label": "Classes / QueryClientProvider", + "to": "framework/lit/reference/classes/QueryClientProvider" + }, + { + "label": "Classes / QueryObserver", + "to": "framework/lit/reference/classes/QueryObserver" + }, + { + "label": "Functions / createInfiniteQueryController", + "to": "framework/lit/reference/functions/createInfiniteQueryController" + }, + { + "label": "Functions / createMutationController", + "to": "framework/lit/reference/functions/createMutationController" + }, + { + "label": "Functions / createQueriesController", + "to": "framework/lit/reference/functions/createQueriesController" + }, + { + "label": "Functions / createQueryController", + "to": "framework/lit/reference/functions/createQueryController" + }, + { + "label": "Functions / defaultShouldDehydrateMutation", + "to": "framework/lit/reference/functions/defaultShouldDehydrateMutation" + }, + { + "label": "Functions / defaultShouldDehydrateQuery", + "to": "framework/lit/reference/functions/defaultShouldDehydrateQuery" + }, + { + "label": "Functions / dehydrate", + "to": "framework/lit/reference/functions/dehydrate" + }, + { + "label": "Functions / dehydrateQuery", + "to": "framework/lit/reference/functions/dehydrateQuery" + }, + { + "label": "Functions / experimental_streamedQuery", + "to": "framework/lit/reference/functions/experimental_streamedQuery" + }, + { + "label": "Functions / hashKey", + "to": "framework/lit/reference/functions/hashKey" + }, + { + "label": "Functions / hydrate", + "to": "framework/lit/reference/functions/hydrate" + }, + { + "label": "Functions / infiniteQueryOptions", + "to": "framework/lit/reference/functions/infiniteQueryOptions" + }, + { + "label": "Functions / isCancelledError", + "to": "framework/lit/reference/functions/isCancelledError" + }, + { + "label": "Functions / keepPreviousData", + "to": "framework/lit/reference/functions/keepPreviousData" + }, + { + "label": "Functions / matchMutation", + "to": "framework/lit/reference/functions/matchMutation" + }, + { + "label": "Functions / matchQuery", + "to": "framework/lit/reference/functions/matchQuery" + }, + { + "label": "Functions / mutationOptions", + "to": "framework/lit/reference/functions/mutationOptions" + }, + { + "label": "Functions / noop", + "to": "framework/lit/reference/functions/noop" + }, + { + "label": "Functions / partialMatchKey", + "to": "framework/lit/reference/functions/partialMatchKey" + }, + { + "label": "Functions / queryOptions", + "to": "framework/lit/reference/functions/queryOptions" + }, + { + "label": "Functions / replaceEqualDeep", + "to": "framework/lit/reference/functions/replaceEqualDeep" + }, + { + "label": "Functions / shouldThrowError", + "to": "framework/lit/reference/functions/shouldThrowError" + }, + { + "label": "Functions / useIsFetching", + "to": "framework/lit/reference/functions/useIsFetching" + }, + { + "label": "Functions / useIsMutating", + "to": "framework/lit/reference/functions/useIsMutating" + }, + { + "label": "Functions / useMutationState", + "to": "framework/lit/reference/functions/useMutationState" + }, + { + "label": "Functions / useQueryClient", + "to": "framework/lit/reference/functions/useQueryClient" + }, + { + "label": "Context / queryClientContext", + "to": "framework/lit/reference/variables/queryClientContext" + }, + { + "label": "Context / getDefaultQueryClient", + "to": "framework/lit/reference/functions/getDefaultQueryClient" + }, + { + "label": "Context / registerDefaultQueryClient", + "to": "framework/lit/reference/functions/registerDefaultQueryClient" + }, + { + "label": "Context / unregisterDefaultQueryClient", + "to": "framework/lit/reference/functions/unregisterDefaultQueryClient" + }, + { + "label": "Context / resolveQueryClient", + "to": "framework/lit/reference/functions/resolveQueryClient" + }, + { + "label": "Interfaces / CancelOptions", + "to": "framework/lit/reference/interfaces/CancelOptions" + }, + { + "label": "Interfaces / DefaultOptions", + "to": "framework/lit/reference/interfaces/DefaultOptions" + }, + { + "label": "Interfaces / DehydrateOptions", + "to": "framework/lit/reference/interfaces/DehydrateOptions" + }, + { + "label": "Interfaces / DehydratedState", + "to": "framework/lit/reference/interfaces/DehydratedState" + }, + { + "label": "Interfaces / EnsureQueryDataOptions", + "to": "framework/lit/reference/interfaces/EnsureQueryDataOptions" + }, + { + "label": "Interfaces / FetchNextPageOptions", + "to": "framework/lit/reference/interfaces/FetchNextPageOptions" + }, + { + "label": "Interfaces / FetchPreviousPageOptions", + "to": "framework/lit/reference/interfaces/FetchPreviousPageOptions" + }, + { + "label": "Interfaces / FetchQueryOptions", + "to": "framework/lit/reference/interfaces/FetchQueryOptions" + }, + { + "label": "Interfaces / FocusManager", + "to": "framework/lit/reference/interfaces/FocusManager" + }, + { + "label": "Interfaces / HydrateOptions", + "to": "framework/lit/reference/interfaces/HydrateOptions" + }, + { + "label": "Interfaces / InfiniteData", + "to": "framework/lit/reference/interfaces/InfiniteData" + }, + { + "label": "Interfaces / InfiniteQueryObserverBaseResult", + "to": "framework/lit/reference/interfaces/InfiniteQueryObserverBaseResult" + }, + { + "label": "Interfaces / InfiniteQueryObserverLoadingErrorResult", + "to": "framework/lit/reference/interfaces/InfiniteQueryObserverLoadingErrorResult" + }, + { + "label": "Interfaces / InfiniteQueryObserverLoadingResult", + "to": "framework/lit/reference/interfaces/InfiniteQueryObserverLoadingResult" + }, + { + "label": "Interfaces / InfiniteQueryObserverOptions", + "to": "framework/lit/reference/interfaces/InfiniteQueryObserverOptions" + }, + { + "label": "Interfaces / InfiniteQueryObserverPendingResult", + "to": "framework/lit/reference/interfaces/InfiniteQueryObserverPendingResult" + }, + { + "label": "Interfaces / InfiniteQueryObserverPlaceholderResult", + "to": "framework/lit/reference/interfaces/InfiniteQueryObserverPlaceholderResult" + }, + { + "label": "Interfaces / InfiniteQueryObserverRefetchErrorResult", + "to": "framework/lit/reference/interfaces/InfiniteQueryObserverRefetchErrorResult" + }, + { + "label": "Interfaces / InfiniteQueryObserverSuccessResult", + "to": "framework/lit/reference/interfaces/InfiniteQueryObserverSuccessResult" + }, + { + "label": "Interfaces / InfiniteQueryPageParamsOptions", + "to": "framework/lit/reference/interfaces/InfiniteQueryPageParamsOptions" + }, + { + "label": "Interfaces / InitialPageParam", + "to": "framework/lit/reference/interfaces/InitialPageParam" + }, + { + "label": "Interfaces / InvalidateOptions", + "to": "framework/lit/reference/interfaces/InvalidateOptions" + }, + { + "label": "Interfaces / InvalidateQueryFilters", + "to": "framework/lit/reference/interfaces/InvalidateQueryFilters" + }, + { + "label": "Interfaces / MutateOptions", + "to": "framework/lit/reference/interfaces/MutateOptions" + }, + { + "label": "Interfaces / MutationCacheConfig", + "to": "framework/lit/reference/interfaces/MutationCacheConfig" + }, + { + "label": "Interfaces / MutationFilters", + "to": "framework/lit/reference/interfaces/MutationFilters" + }, + { + "label": "Interfaces / MutationObserverBaseResult", + "to": "framework/lit/reference/interfaces/MutationObserverBaseResult" + }, + { + "label": "Interfaces / MutationObserverErrorResult", + "to": "framework/lit/reference/interfaces/MutationObserverErrorResult" + }, + { + "label": "Interfaces / MutationObserverIdleResult", + "to": "framework/lit/reference/interfaces/MutationObserverIdleResult" + }, + { + "label": "Interfaces / MutationObserverLoadingResult", + "to": "framework/lit/reference/interfaces/MutationObserverLoadingResult" + }, + { + "label": "Interfaces / MutationObserverOptions", + "to": "framework/lit/reference/interfaces/MutationObserverOptions" + }, + { + "label": "Interfaces / MutationObserverSuccessResult", + "to": "framework/lit/reference/interfaces/MutationObserverSuccessResult" + }, + { + "label": "Interfaces / MutationOptions", + "to": "framework/lit/reference/interfaces/MutationOptions" + }, + { + "label": "Interfaces / MutationState", + "to": "framework/lit/reference/interfaces/MutationState" + }, + { + "label": "Interfaces / NotifyEvent", + "to": "framework/lit/reference/interfaces/NotifyEvent" + }, + { + "label": "Interfaces / OnlineManager", + "to": "framework/lit/reference/interfaces/OnlineManager" + }, + { + "label": "Interfaces / QueriesObserverOptions", + "to": "framework/lit/reference/interfaces/QueriesObserverOptions" + }, + { + "label": "Interfaces / QueryCacheConfig", + "to": "framework/lit/reference/interfaces/QueryCacheConfig" + }, + { + "label": "Interfaces / QueryClientConfig", + "to": "framework/lit/reference/interfaces/QueryClientConfig" + }, + { + "label": "Interfaces / QueryExecuteOptions", + "to": "framework/lit/reference/interfaces/QueryExecuteOptions" + }, + { + "label": "Interfaces / QueryFilters", + "to": "framework/lit/reference/interfaces/QueryFilters" + }, + { + "label": "Interfaces / QueryObserverBaseResult", + "to": "framework/lit/reference/interfaces/QueryObserverBaseResult" + }, + { + "label": "Interfaces / QueryObserverLoadingErrorResult", + "to": "framework/lit/reference/interfaces/QueryObserverLoadingErrorResult" + }, + { + "label": "Interfaces / QueryObserverLoadingResult", + "to": "framework/lit/reference/interfaces/QueryObserverLoadingResult" + }, + { + "label": "Interfaces / QueryObserverOptions", + "to": "framework/lit/reference/interfaces/QueryObserverOptions" + }, + { + "label": "Interfaces / QueryObserverPendingResult", + "to": "framework/lit/reference/interfaces/QueryObserverPendingResult" + }, + { + "label": "Interfaces / QueryObserverPlaceholderResult", + "to": "framework/lit/reference/interfaces/QueryObserverPlaceholderResult" + }, + { + "label": "Interfaces / QueryObserverRefetchErrorResult", + "to": "framework/lit/reference/interfaces/QueryObserverRefetchErrorResult" + }, + { + "label": "Interfaces / QueryObserverSuccessResult", + "to": "framework/lit/reference/interfaces/QueryObserverSuccessResult" + }, + { + "label": "Interfaces / QueryOptions", + "to": "framework/lit/reference/interfaces/QueryOptions" + }, + { + "label": "Interfaces / QueryState", + "to": "framework/lit/reference/interfaces/QueryState" + }, + { + "label": "Interfaces / RefetchOptions", + "to": "framework/lit/reference/interfaces/RefetchOptions" + }, + { + "label": "Interfaces / RefetchQueryFilters", + "to": "framework/lit/reference/interfaces/RefetchQueryFilters" + }, + { + "label": "Interfaces / Register", + "to": "framework/lit/reference/interfaces/Register" + }, + { + "label": "Interfaces / ResetOptions", + "to": "framework/lit/reference/interfaces/ResetOptions" + }, + { + "label": "Interfaces / ResultOptions", + "to": "framework/lit/reference/interfaces/ResultOptions" + }, + { + "label": "Interfaces / SetDataOptions", + "to": "framework/lit/reference/interfaces/SetDataOptions" + }, + { + "label": "Interfaces / TimeoutManager", + "to": "framework/lit/reference/interfaces/TimeoutManager" + }, + { + "label": "Types / Accessor", + "to": "framework/lit/reference/type-aliases/Accessor" + }, + { + "label": "Types / AnyDataTag", + "to": "framework/lit/reference/type-aliases/AnyDataTag" + }, + { + "label": "Types / CreateInfiniteQueryOptions", + "to": "framework/lit/reference/type-aliases/CreateInfiniteQueryOptions" + }, + { + "label": "Types / CreateMutationOptions", + "to": "framework/lit/reference/type-aliases/CreateMutationOptions" + }, + { + "label": "Types / CreateQueriesControllerOptions", + "to": "framework/lit/reference/type-aliases/CreateQueriesControllerOptions" + }, + { + "label": "Types / CreateQueriesInput", + "to": "framework/lit/reference/type-aliases/CreateQueriesInput" + }, + { + "label": "Types / CreateQueryOptions", + "to": "framework/lit/reference/type-aliases/CreateQueryOptions" + }, + { + "label": "Types / DataTag", + "to": "framework/lit/reference/type-aliases/DataTag" + }, + { + "label": "Types / DefaultError", + "to": "framework/lit/reference/type-aliases/DefaultError" + }, + { + "label": "Types / DefaultedInfiniteQueryObserverOptions", + "to": "framework/lit/reference/type-aliases/DefaultedInfiniteQueryObserverOptions" + }, + { + "label": "Types / DefaultedQueryObserverOptions", + "to": "framework/lit/reference/type-aliases/DefaultedQueryObserverOptions" + }, + { + "label": "Types / DefinedInfiniteQueryObserverResult", + "to": "framework/lit/reference/type-aliases/DefinedInfiniteQueryObserverResult" + }, + { + "label": "Types / DefinedInitialDataOptions", + "to": "framework/lit/reference/type-aliases/DefinedInitialDataOptions" + }, + { + "label": "Types / DefinedQueryObserverResult", + "to": "framework/lit/reference/type-aliases/DefinedQueryObserverResult" + }, + { + "label": "Types / DistributiveOmit", + "to": "framework/lit/reference/type-aliases/DistributiveOmit" + }, + { + "label": "Types / EnsureInfiniteQueryDataOptions", + "to": "framework/lit/reference/type-aliases/EnsureInfiniteQueryDataOptions" + }, + { + "label": "Types / FetchInfiniteQueryOptions", + "to": "framework/lit/reference/type-aliases/FetchInfiniteQueryOptions" + }, + { + "label": "Types / FetchStatus", + "to": "framework/lit/reference/type-aliases/FetchStatus" + }, + { + "label": "Types / GetNextPageParamFunction", + "to": "framework/lit/reference/type-aliases/GetNextPageParamFunction" + }, + { + "label": "Types / GetPreviousPageParamFunction", + "to": "framework/lit/reference/type-aliases/GetPreviousPageParamFunction" + }, + { + "label": "Types / InferDataFromTag", + "to": "framework/lit/reference/type-aliases/InferDataFromTag" + }, + { + "label": "Types / InferErrorFromTag", + "to": "framework/lit/reference/type-aliases/InferErrorFromTag" + }, + { + "label": "Types / InfiniteQueryControllerOptions", + "to": "framework/lit/reference/type-aliases/InfiniteQueryControllerOptions" + }, + { + "label": "Types / InfiniteQueryExecuteOptions", + "to": "framework/lit/reference/type-aliases/InfiniteQueryExecuteOptions" + }, + { + "label": "Types / InfiniteQueryObserverResult", + "to": "framework/lit/reference/type-aliases/InfiniteQueryObserverResult" + }, + { + "label": "Types / InfiniteQueryResultAccessor", + "to": "framework/lit/reference/type-aliases/InfiniteQueryResultAccessor" + }, + { + "label": "Types / InitialDataFunction", + "to": "framework/lit/reference/type-aliases/InitialDataFunction" + }, + { + "label": "Types / IsFetchingAccessor", + "to": "framework/lit/reference/type-aliases/IsFetchingAccessor" + }, + { + "label": "Types / IsMutatingAccessor", + "to": "framework/lit/reference/type-aliases/IsMutatingAccessor" + }, + { + "label": "Types / ManagedTimerId", + "to": "framework/lit/reference/type-aliases/ManagedTimerId" + }, + { + "label": "Types / MutateFunction", + "to": "framework/lit/reference/type-aliases/MutateFunction" + }, + { + "label": "Types / MutateFunctionRest", + "to": "framework/lit/reference/type-aliases/MutateFunctionRest" + }, + { + "label": "Types / MutationCacheNotifyEvent", + "to": "framework/lit/reference/type-aliases/MutationCacheNotifyEvent" + }, + { + "label": "Types / MutationControllerOptions", + "to": "framework/lit/reference/type-aliases/MutationControllerOptions" + }, + { + "label": "Types / MutationControllerResult", + "to": "framework/lit/reference/type-aliases/MutationControllerResult" + }, + { + "label": "Types / MutationFunction", + "to": "framework/lit/reference/type-aliases/MutationFunction" + }, + { + "label": "Types / MutationFunctionContext", + "to": "framework/lit/reference/type-aliases/MutationFunctionContext" + }, + { + "label": "Types / MutationKey", + "to": "framework/lit/reference/type-aliases/MutationKey" + }, + { + "label": "Types / MutationMeta", + "to": "framework/lit/reference/type-aliases/MutationMeta" + }, + { + "label": "Types / MutationObserverResult", + "to": "framework/lit/reference/type-aliases/MutationObserverResult" + }, + { + "label": "Types / MutationResultAccessor", + "to": "framework/lit/reference/type-aliases/MutationResultAccessor" + }, + { + "label": "Types / MutationScope", + "to": "framework/lit/reference/type-aliases/MutationScope" + }, + { + "label": "Types / MutationStateAccessor", + "to": "framework/lit/reference/type-aliases/MutationStateAccessor" + }, + { + "label": "Types / MutationStateOptions", + "to": "framework/lit/reference/type-aliases/MutationStateOptions" + }, + { + "label": "Types / MutationStatus", + "to": "framework/lit/reference/type-aliases/MutationStatus" + }, + { + "label": "Types / NetworkMode", + "to": "framework/lit/reference/type-aliases/NetworkMode" + }, + { + "label": "Types / NonUndefinedGuard", + "to": "framework/lit/reference/type-aliases/NonUndefinedGuard" + }, + { + "label": "Types / NotifyEventType", + "to": "framework/lit/reference/type-aliases/NotifyEventType" + }, + { + "label": "Types / NotifyOnChangeProps", + "to": "framework/lit/reference/type-aliases/NotifyOnChangeProps" + }, + { + "label": "Types / OmitKeyof", + "to": "framework/lit/reference/type-aliases/OmitKeyof" + }, + { + "label": "Types / Override", + "to": "framework/lit/reference/type-aliases/Override" + }, + { + "label": "Types / PlaceholderDataFunction", + "to": "framework/lit/reference/type-aliases/PlaceholderDataFunction" + }, + { + "label": "Types / QueriesControllerOptions", + "to": "framework/lit/reference/type-aliases/QueriesControllerOptions" + }, + { + "label": "Types / QueriesPlaceholderDataFunction", + "to": "framework/lit/reference/type-aliases/QueriesPlaceholderDataFunction" + }, + { + "label": "Types / QueriesResultAccessor", + "to": "framework/lit/reference/type-aliases/QueriesResultAccessor" + }, + { + "label": "Types / QueryBooleanOption", + "to": "framework/lit/reference/type-aliases/QueryBooleanOption" + }, + { + "label": "Types / QueryCacheNotifyEvent", + "to": "framework/lit/reference/type-aliases/QueryCacheNotifyEvent" + }, + { + "label": "Types / QueryControllerOptions", + "to": "framework/lit/reference/type-aliases/QueryControllerOptions" + }, + { + "label": "Types / QueryControllerResult", + "to": "framework/lit/reference/type-aliases/QueryControllerResult" + }, + { + "label": "Types / QueryFunction", + "to": "framework/lit/reference/type-aliases/QueryFunction" + }, + { + "label": "Types / QueryFunctionContext", + "to": "framework/lit/reference/type-aliases/QueryFunctionContext" + }, + { + "label": "Types / QueryKey", + "to": "framework/lit/reference/type-aliases/QueryKey" + }, + { + "label": "Types / QueryKeyHashFunction", + "to": "framework/lit/reference/type-aliases/QueryKeyHashFunction" + }, + { + "label": "Types / QueryKeyWithDataTag", + "to": "framework/lit/reference/type-aliases/QueryKeyWithDataTag" + }, + { + "label": "Types / QueryMeta", + "to": "framework/lit/reference/type-aliases/QueryMeta" + }, + { + "label": "Types / QueryObserverResult", + "to": "framework/lit/reference/type-aliases/QueryObserverResult" + }, + { + "label": "Types / QueryPersister", + "to": "framework/lit/reference/type-aliases/QueryPersister" + }, + { + "label": "Types / QueryResultAccessor", + "to": "framework/lit/reference/type-aliases/QueryResultAccessor" + }, + { + "label": "Types / QueryStatus", + "to": "framework/lit/reference/type-aliases/QueryStatus" + }, + { + "label": "Types / SkipToken", + "to": "framework/lit/reference/type-aliases/SkipToken" + }, + { + "label": "Types / StaleTime", + "to": "framework/lit/reference/type-aliases/StaleTime" + }, + { + "label": "Types / StaleTimeFunction", + "to": "framework/lit/reference/type-aliases/StaleTimeFunction" + }, + { + "label": "Types / ThrowOnError", + "to": "framework/lit/reference/type-aliases/ThrowOnError" + }, + { + "label": "Types / TimeoutCallback", + "to": "framework/lit/reference/type-aliases/TimeoutCallback" + }, + { + "label": "Types / TimeoutProvider", + "to": "framework/lit/reference/type-aliases/TimeoutProvider" + }, + { + "label": "Types / UndefinedInitialDataOptions", + "to": "framework/lit/reference/type-aliases/UndefinedInitialDataOptions" + }, + { + "label": "Types / UnsetMarker", + "to": "framework/lit/reference/type-aliases/UnsetMarker" + }, + { + "label": "Types / UnusedSkipTokenOptions", + "to": "framework/lit/reference/type-aliases/UnusedSkipTokenOptions" + }, + { + "label": "Types / Updater", + "to": "framework/lit/reference/type-aliases/Updater" + }, + { + "label": "Types / ValueAccessor", + "to": "framework/lit/reference/type-aliases/ValueAccessor" + }, + { + "label": "Types / WithRequired", + "to": "framework/lit/reference/type-aliases/WithRequired" + }, + { + "label": "Types / dataTagErrorSymbol", + "to": "framework/lit/reference/type-aliases/dataTagErrorSymbol" + }, + { + "label": "Types / dataTagSymbol", + "to": "framework/lit/reference/type-aliases/dataTagSymbol" + }, + { + "label": "Variables / dataTagErrorSymbol", + "to": "framework/lit/reference/variables/dataTagErrorSymbol" + }, + { + "label": "Variables / dataTagSymbol", + "to": "framework/lit/reference/variables/dataTagSymbol" + }, + { + "label": "Variables / defaultScheduler", + "to": "framework/lit/reference/variables/defaultScheduler" + }, + { + "label": "Variables / environmentManager", + "to": "framework/lit/reference/variables/environmentManager" + }, + { + "label": "Variables / focusManager", + "to": "framework/lit/reference/variables/focusManager" + }, + { + "label": "Variables / isServer", + "to": "framework/lit/reference/variables/isServer" + }, + { + "label": "Variables / notifyManager", + "to": "framework/lit/reference/variables/notifyManager" + }, + { + "label": "Variables / onlineManager", + "to": "framework/lit/reference/variables/onlineManager" + }, + { + "label": "Variables / skipToken", + "to": "framework/lit/reference/variables/skipToken" + }, + { + "label": "Variables / timeoutManager", + "to": "framework/lit/reference/variables/timeoutManager" + }, + { + "label": "Variables / unsetMarker", + "to": "framework/lit/reference/variables/unsetMarker" + } + ] + }, + { + "label": "angular", + "children": [ + { + "label": "Angular Reference", + "to": "framework/angular/reference/index" + }, + { + "label": "Functions / defaultShouldDehydrateMutation", + "to": "framework/angular/reference/functions/defaultShouldDehydrateMutation" + }, + { + "label": "Functions / defaultShouldDehydrateQuery", + "to": "framework/angular/reference/functions/defaultShouldDehydrateQuery" + }, + { + "label": "Functions / dehydrate", + "to": "framework/angular/reference/functions/dehydrate" + }, + { + "label": "Functions / dehydrateQuery", + "to": "framework/angular/reference/functions/dehydrateQuery" + }, + { + "label": "Functions / experimental_streamedQuery", + "to": "framework/angular/reference/functions/experimental_streamedQuery" + }, + { + "label": "Functions / hashKey", + "to": "framework/angular/reference/functions/hashKey" + }, + { + "label": "Functions / hydrate", + "to": "framework/angular/reference/functions/hydrate" + }, + { + "label": "Functions / infiniteQueryOptions", + "to": "framework/angular/reference/functions/infiniteQueryOptions" + }, + { + "label": "Functions / injectInfiniteQuery", + "to": "framework/angular/reference/functions/injectInfiniteQuery" + }, + { + "label": "Functions / injectIsFetching", + "to": "framework/angular/reference/functions/injectIsFetching" + }, + { + "label": "Functions / injectIsMutating", + "to": "framework/angular/reference/functions/injectIsMutating" + }, + { + "label": "Functions / injectIsRestoring", + "to": "framework/angular/reference/functions/injectIsRestoring" + }, + { + "label": "Functions / injectMutation", + "to": "framework/angular/reference/functions/injectMutation" + }, + { + "label": "Functions / injectMutationState", + "to": "framework/angular/reference/functions/injectMutationState" + }, + { + "label": "Functions / injectQuery", + "to": "framework/angular/reference/functions/injectQuery" + }, + { + "label": "Functions / injectQueryClient", + "to": "framework/angular/reference/functions/injectQueryClient" + }, + { + "label": "Functions / isCancelledError", + "to": "framework/angular/reference/functions/isCancelledError" + }, + { + "label": "Functions / keepPreviousData", + "to": "framework/angular/reference/functions/keepPreviousData" + }, + { + "label": "Functions / matchMutation", + "to": "framework/angular/reference/functions/matchMutation" + }, + { + "label": "Functions / matchQuery", + "to": "framework/angular/reference/functions/matchQuery" + }, + { + "label": "Functions / mutationOptions", + "to": "framework/angular/reference/functions/mutationOptions" + }, + { + "label": "Functions / noop", + "to": "framework/angular/reference/functions/noop" + }, + { + "label": "Functions / partialMatchKey", + "to": "framework/angular/reference/functions/partialMatchKey" + }, + { + "label": "Functions / provideAngularQuery", + "to": "framework/angular/reference/functions/provideAngularQuery" + }, + { + "label": "Functions / provideIsRestoring", + "to": "framework/angular/reference/functions/provideIsRestoring" + }, + { + "label": "Functions / provideQueryClient", + "to": "framework/angular/reference/functions/provideQueryClient" + }, + { + "label": "Functions / provideTanStackQuery", + "to": "framework/angular/reference/functions/provideTanStackQuery" + }, + { + "label": "Functions / queryFeature", + "to": "framework/angular/reference/functions/queryFeature" + }, + { + "label": "Functions / queryOptions", + "to": "framework/angular/reference/functions/queryOptions" + }, + { + "label": "Functions / replaceEqualDeep", + "to": "framework/angular/reference/functions/replaceEqualDeep" + }, + { + "label": "Functions / shouldThrowError", + "to": "framework/angular/reference/functions/shouldThrowError" + }, + { + "label": "Classes / CancelledError", + "to": "framework/angular/reference/classes/CancelledError" + }, + { + "label": "Classes / InfiniteQueryObserver", + "to": "framework/angular/reference/classes/InfiniteQueryObserver" + }, + { + "label": "Classes / Mutation", + "to": "framework/angular/reference/classes/Mutation" + }, + { + "label": "Classes / MutationCache", + "to": "framework/angular/reference/classes/MutationCache" + }, + { + "label": "Classes / MutationObserver", + "to": "framework/angular/reference/classes/MutationObserver" + }, + { + "label": "Classes / QueriesObserver", + "to": "framework/angular/reference/classes/QueriesObserver" + }, + { + "label": "Classes / Query", + "to": "framework/angular/reference/classes/Query" + }, + { + "label": "Classes / QueryCache", + "to": "framework/angular/reference/classes/QueryCache" + }, + { + "label": "Classes / QueryClient", + "to": "framework/angular/reference/classes/QueryClient" + }, + { + "label": "Classes / QueryObserver", + "to": "framework/angular/reference/classes/QueryObserver" + }, + { + "label": "Interfaces / BaseMutationNarrowing", + "to": "framework/angular/reference/interfaces/BaseMutationNarrowing" + }, + { + "label": "Interfaces / BaseQueryNarrowing", + "to": "framework/angular/reference/interfaces/BaseQueryNarrowing" + }, + { + "label": "Interfaces / CancelOptions", + "to": "framework/angular/reference/interfaces/CancelOptions" + }, + { + "label": "Interfaces / CreateBaseQueryOptions", + "to": "framework/angular/reference/interfaces/CreateBaseQueryOptions" + }, + { + "label": "Interfaces / CreateInfiniteQueryOptions", + "to": "framework/angular/reference/interfaces/CreateInfiniteQueryOptions" + }, + { + "label": "Interfaces / CreateMutationOptions", + "to": "framework/angular/reference/interfaces/CreateMutationOptions" + }, + { + "label": "Interfaces / CreateQueryOptions", + "to": "framework/angular/reference/interfaces/CreateQueryOptions" + }, + { + "label": "Interfaces / DefaultOptions", + "to": "framework/angular/reference/interfaces/DefaultOptions" + }, + { + "label": "Interfaces / DehydrateOptions", + "to": "framework/angular/reference/interfaces/DehydrateOptions" + }, + { + "label": "Interfaces / DehydratedState", + "to": "framework/angular/reference/interfaces/DehydratedState" + }, + { + "label": "Interfaces / EnsureQueryDataOptions", + "to": "framework/angular/reference/interfaces/EnsureQueryDataOptions" + }, + { + "label": "Interfaces / FetchNextPageOptions", + "to": "framework/angular/reference/interfaces/FetchNextPageOptions" + }, + { + "label": "Interfaces / FetchPreviousPageOptions", + "to": "framework/angular/reference/interfaces/FetchPreviousPageOptions" + }, + { + "label": "Interfaces / FetchQueryOptions", + "to": "framework/angular/reference/interfaces/FetchQueryOptions" + }, + { + "label": "Interfaces / FocusManager", + "to": "framework/angular/reference/interfaces/FocusManager" + }, + { + "label": "Interfaces / HydrateOptions", + "to": "framework/angular/reference/interfaces/HydrateOptions" + }, + { + "label": "Interfaces / InfiniteData", + "to": "framework/angular/reference/interfaces/InfiniteData" + }, + { + "label": "Interfaces / InfiniteQueryObserverBaseResult", + "to": "framework/angular/reference/interfaces/InfiniteQueryObserverBaseResult" + }, + { + "label": "Interfaces / InfiniteQueryObserverLoadingErrorResult", + "to": "framework/angular/reference/interfaces/InfiniteQueryObserverLoadingErrorResult" + }, + { + "label": "Interfaces / InfiniteQueryObserverLoadingResult", + "to": "framework/angular/reference/interfaces/InfiniteQueryObserverLoadingResult" + }, + { + "label": "Interfaces / InfiniteQueryObserverOptions", + "to": "framework/angular/reference/interfaces/InfiniteQueryObserverOptions" + }, + { + "label": "Interfaces / InfiniteQueryObserverPendingResult", + "to": "framework/angular/reference/interfaces/InfiniteQueryObserverPendingResult" + }, + { + "label": "Interfaces / InfiniteQueryObserverPlaceholderResult", + "to": "framework/angular/reference/interfaces/InfiniteQueryObserverPlaceholderResult" + }, + { + "label": "Interfaces / InfiniteQueryObserverRefetchErrorResult", + "to": "framework/angular/reference/interfaces/InfiniteQueryObserverRefetchErrorResult" + }, + { + "label": "Interfaces / InfiniteQueryObserverSuccessResult", + "to": "framework/angular/reference/interfaces/InfiniteQueryObserverSuccessResult" + }, + { + "label": "Interfaces / InfiniteQueryPageParamsOptions", + "to": "framework/angular/reference/interfaces/InfiniteQueryPageParamsOptions" + }, + { + "label": "Interfaces / InitialPageParam", + "to": "framework/angular/reference/interfaces/InitialPageParam" + }, + { + "label": "Interfaces / InjectInfiniteQueryOptions", + "to": "framework/angular/reference/interfaces/InjectInfiniteQueryOptions" + }, + { + "label": "Interfaces / InjectIsFetchingOptions", + "to": "framework/angular/reference/interfaces/InjectIsFetchingOptions" + }, + { + "label": "Interfaces / InjectIsMutatingOptions", + "to": "framework/angular/reference/interfaces/InjectIsMutatingOptions" + }, + { + "label": "Interfaces / InjectMutationOptions", + "to": "framework/angular/reference/interfaces/InjectMutationOptions" + }, + { + "label": "Interfaces / InjectMutationStateOptions", + "to": "framework/angular/reference/interfaces/InjectMutationStateOptions" + }, + { + "label": "Interfaces / InjectQueryOptions", + "to": "framework/angular/reference/interfaces/InjectQueryOptions" + }, + { + "label": "Interfaces / InvalidateOptions", + "to": "framework/angular/reference/interfaces/InvalidateOptions" + }, + { + "label": "Interfaces / InvalidateQueryFilters", + "to": "framework/angular/reference/interfaces/InvalidateQueryFilters" + }, + { + "label": "Interfaces / MutateOptions", + "to": "framework/angular/reference/interfaces/MutateOptions" + }, + { + "label": "Interfaces / MutationCacheConfig", + "to": "framework/angular/reference/interfaces/MutationCacheConfig" + }, + { + "label": "Interfaces / MutationFilters", + "to": "framework/angular/reference/interfaces/MutationFilters" + }, + { + "label": "Interfaces / MutationObserverBaseResult", + "to": "framework/angular/reference/interfaces/MutationObserverBaseResult" + }, + { + "label": "Interfaces / MutationObserverErrorResult", + "to": "framework/angular/reference/interfaces/MutationObserverErrorResult" + }, + { + "label": "Interfaces / MutationObserverIdleResult", + "to": "framework/angular/reference/interfaces/MutationObserverIdleResult" + }, + { + "label": "Interfaces / MutationObserverLoadingResult", + "to": "framework/angular/reference/interfaces/MutationObserverLoadingResult" + }, + { + "label": "Interfaces / MutationObserverOptions", + "to": "framework/angular/reference/interfaces/MutationObserverOptions" + }, + { + "label": "Interfaces / MutationObserverSuccessResult", + "to": "framework/angular/reference/interfaces/MutationObserverSuccessResult" + }, + { + "label": "Interfaces / MutationOptions", + "to": "framework/angular/reference/interfaces/MutationOptions" + }, + { + "label": "Interfaces / MutationState", + "to": "framework/angular/reference/interfaces/MutationState" + }, + { + "label": "Interfaces / NotifyEvent", + "to": "framework/angular/reference/interfaces/NotifyEvent" + }, + { + "label": "Interfaces / OnlineManager", + "to": "framework/angular/reference/interfaces/OnlineManager" + }, + { + "label": "Interfaces / QueriesObserverOptions", + "to": "framework/angular/reference/interfaces/QueriesObserverOptions" + }, + { + "label": "Interfaces / QueryCacheConfig", + "to": "framework/angular/reference/interfaces/QueryCacheConfig" + }, + { + "label": "Interfaces / QueryClientConfig", + "to": "framework/angular/reference/interfaces/QueryClientConfig" + }, + { + "label": "Interfaces / QueryExecuteOptions", + "to": "framework/angular/reference/interfaces/QueryExecuteOptions" + }, + { + "label": "Interfaces / QueryFeature", + "to": "framework/angular/reference/interfaces/QueryFeature" + }, + { + "label": "Interfaces / QueryFilters", + "to": "framework/angular/reference/interfaces/QueryFilters" + }, + { + "label": "Interfaces / QueryObserverBaseResult", + "to": "framework/angular/reference/interfaces/QueryObserverBaseResult" + }, + { + "label": "Interfaces / QueryObserverLoadingErrorResult", + "to": "framework/angular/reference/interfaces/QueryObserverLoadingErrorResult" + }, + { + "label": "Interfaces / QueryObserverLoadingResult", + "to": "framework/angular/reference/interfaces/QueryObserverLoadingResult" + }, + { + "label": "Interfaces / QueryObserverOptions", + "to": "framework/angular/reference/interfaces/QueryObserverOptions" + }, + { + "label": "Interfaces / QueryObserverPendingResult", + "to": "framework/angular/reference/interfaces/QueryObserverPendingResult" + }, + { + "label": "Interfaces / QueryObserverPlaceholderResult", + "to": "framework/angular/reference/interfaces/QueryObserverPlaceholderResult" + }, + { + "label": "Interfaces / QueryObserverRefetchErrorResult", + "to": "framework/angular/reference/interfaces/QueryObserverRefetchErrorResult" + }, + { + "label": "Interfaces / QueryObserverSuccessResult", + "to": "framework/angular/reference/interfaces/QueryObserverSuccessResult" + }, + { + "label": "Interfaces / QueryOptions", + "to": "framework/angular/reference/interfaces/QueryOptions" + }, + { + "label": "Interfaces / QueryState", + "to": "framework/angular/reference/interfaces/QueryState" + }, + { + "label": "Interfaces / RefetchOptions", + "to": "framework/angular/reference/interfaces/RefetchOptions" + }, + { + "label": "Interfaces / RefetchQueryFilters", + "to": "framework/angular/reference/interfaces/RefetchQueryFilters" + }, + { + "label": "Interfaces / Register", + "to": "framework/angular/reference/interfaces/Register" + }, + { + "label": "Interfaces / ResetOptions", + "to": "framework/angular/reference/interfaces/ResetOptions" + }, + { + "label": "Interfaces / ResultOptions", + "to": "framework/angular/reference/interfaces/ResultOptions" + }, + { + "label": "Interfaces / SetDataOptions", + "to": "framework/angular/reference/interfaces/SetDataOptions" + }, + { + "label": "Interfaces / TimeoutManager", + "to": "framework/angular/reference/interfaces/TimeoutManager" + }, + { + "label": "Types / AnyDataTag", + "to": "framework/angular/reference/type-aliases/AnyDataTag" + }, + { + "label": "Types / CreateBaseMutationResult", + "to": "framework/angular/reference/type-aliases/CreateBaseMutationResult" + }, + { + "label": "Types / CreateBaseQueryResult", + "to": "framework/angular/reference/type-aliases/CreateBaseQueryResult" + }, + { + "label": "Types / CreateInfiniteQueryResult", + "to": "framework/angular/reference/type-aliases/CreateInfiniteQueryResult" + }, + { + "label": "Types / CreateMutateAsyncFunction", + "to": "framework/angular/reference/type-aliases/CreateMutateAsyncFunction" + }, + { + "label": "Types / CreateMutateFunction", + "to": "framework/angular/reference/type-aliases/CreateMutateFunction" + }, + { + "label": "Types / CreateMutationResult", + "to": "framework/angular/reference/type-aliases/CreateMutationResult" }, { "label": "Types / CreateQueryResult", - "to": "framework/svelte/reference/type-aliases/CreateQueryResult" + "to": "framework/angular/reference/type-aliases/CreateQueryResult" + }, + { + "label": "Types / DataTag", + "to": "framework/angular/reference/type-aliases/DataTag" + }, + { + "label": "Types / DefaultError", + "to": "framework/angular/reference/type-aliases/DefaultError" + }, + { + "label": "Types / DefaultedInfiniteQueryObserverOptions", + "to": "framework/angular/reference/type-aliases/DefaultedInfiniteQueryObserverOptions" + }, + { + "label": "Types / DefaultedQueryObserverOptions", + "to": "framework/angular/reference/type-aliases/DefaultedQueryObserverOptions" + }, + { + "label": "Types / DefinedCreateInfiniteQueryResult", + "to": "framework/angular/reference/type-aliases/DefinedCreateInfiniteQueryResult" + }, + { + "label": "Types / DefinedCreateQueryResult", + "to": "framework/angular/reference/type-aliases/DefinedCreateQueryResult" + }, + { + "label": "Types / DefinedInfiniteQueryObserverResult", + "to": "framework/angular/reference/type-aliases/DefinedInfiniteQueryObserverResult" + }, + { + "label": "Types / DefinedInitialDataInfiniteOptions", + "to": "framework/angular/reference/type-aliases/DefinedInitialDataInfiniteOptions" + }, + { + "label": "Types / DefinedInitialDataOptions", + "to": "framework/angular/reference/type-aliases/DefinedInitialDataOptions" + }, + { + "label": "Types / DefinedQueryObserverResult", + "to": "framework/angular/reference/type-aliases/DefinedQueryObserverResult" + }, + { + "label": "Types / DevtoolsFeature", + "to": "framework/angular/reference/type-aliases/DevtoolsFeature" + }, + { + "label": "Types / DistributiveOmit", + "to": "framework/angular/reference/type-aliases/DistributiveOmit" + }, + { + "label": "Types / EnsureInfiniteQueryDataOptions", + "to": "framework/angular/reference/type-aliases/EnsureInfiniteQueryDataOptions" + }, + { + "label": "Types / FetchInfiniteQueryOptions", + "to": "framework/angular/reference/type-aliases/FetchInfiniteQueryOptions" + }, + { + "label": "Types / FetchStatus", + "to": "framework/angular/reference/type-aliases/FetchStatus" + }, + { + "label": "Types / GetNextPageParamFunction", + "to": "framework/angular/reference/type-aliases/GetNextPageParamFunction" + }, + { + "label": "Types / GetPreviousPageParamFunction", + "to": "framework/angular/reference/type-aliases/GetPreviousPageParamFunction" + }, + { + "label": "Types / InferDataFromTag", + "to": "framework/angular/reference/type-aliases/InferDataFromTag" + }, + { + "label": "Types / InferErrorFromTag", + "to": "framework/angular/reference/type-aliases/InferErrorFromTag" + }, + { + "label": "Types / InfiniteQueryExecuteOptions", + "to": "framework/angular/reference/type-aliases/InfiniteQueryExecuteOptions" + }, + { + "label": "Types / InfiniteQueryObserverResult", + "to": "framework/angular/reference/type-aliases/InfiniteQueryObserverResult" + }, + { + "label": "Types / InitialDataFunction", + "to": "framework/angular/reference/type-aliases/InitialDataFunction" + }, + { + "label": "Types / ManagedTimerId", + "to": "framework/angular/reference/type-aliases/ManagedTimerId" + }, + { + "label": "Types / MutateFunction", + "to": "framework/angular/reference/type-aliases/MutateFunction" + }, + { + "label": "Types / MutateFunctionRest", + "to": "framework/angular/reference/type-aliases/MutateFunctionRest" + }, + { + "label": "Types / MutationCacheNotifyEvent", + "to": "framework/angular/reference/type-aliases/MutationCacheNotifyEvent" + }, + { + "label": "Types / MutationFunction", + "to": "framework/angular/reference/type-aliases/MutationFunction" + }, + { + "label": "Types / MutationFunctionContext", + "to": "framework/angular/reference/type-aliases/MutationFunctionContext" + }, + { + "label": "Types / MutationKey", + "to": "framework/angular/reference/type-aliases/MutationKey" + }, + { + "label": "Types / MutationMeta", + "to": "framework/angular/reference/type-aliases/MutationMeta" + }, + { + "label": "Types / MutationObserverResult", + "to": "framework/angular/reference/type-aliases/MutationObserverResult" + }, + { + "label": "Types / MutationScope", + "to": "framework/angular/reference/type-aliases/MutationScope" + }, + { + "label": "Types / MutationStatus", + "to": "framework/angular/reference/type-aliases/MutationStatus" + }, + { + "label": "Types / NetworkMode", + "to": "framework/angular/reference/type-aliases/NetworkMode" + }, + { + "label": "Types / NonUndefinedGuard", + "to": "framework/angular/reference/type-aliases/NonUndefinedGuard" + }, + { + "label": "Types / NotifyEventType", + "to": "framework/angular/reference/type-aliases/NotifyEventType" + }, + { + "label": "Types / NotifyOnChangeProps", + "to": "framework/angular/reference/type-aliases/NotifyOnChangeProps" + }, + { + "label": "Types / OmitKeyof", + "to": "framework/angular/reference/type-aliases/OmitKeyof" + }, + { + "label": "Types / Override", + "to": "framework/angular/reference/type-aliases/Override" + }, + { + "label": "Types / PersistQueryClientFeature", + "to": "framework/angular/reference/type-aliases/PersistQueryClientFeature" + }, + { + "label": "Types / PlaceholderDataFunction", + "to": "framework/angular/reference/type-aliases/PlaceholderDataFunction" + }, + { + "label": "Types / QueriesOptions", + "to": "framework/angular/reference/type-aliases/QueriesOptions" + }, + { + "label": "Types / QueriesPlaceholderDataFunction", + "to": "framework/angular/reference/type-aliases/QueriesPlaceholderDataFunction" + }, + { + "label": "Types / QueriesResults", + "to": "framework/angular/reference/type-aliases/QueriesResults" + }, + { + "label": "Types / QueryBooleanOption", + "to": "framework/angular/reference/type-aliases/QueryBooleanOption" + }, + { + "label": "Types / QueryCacheNotifyEvent", + "to": "framework/angular/reference/type-aliases/QueryCacheNotifyEvent" + }, + { + "label": "Types / QueryFeatures", + "to": "framework/angular/reference/type-aliases/QueryFeatures" + }, + { + "label": "Types / QueryFunction", + "to": "framework/angular/reference/type-aliases/QueryFunction" }, { - "label": "Types / DefinedCreateBaseQueryResult", - "to": "framework/svelte/reference/type-aliases/DefinedCreateBaseQueryResult" + "label": "Types / QueryFunctionContext", + "to": "framework/angular/reference/type-aliases/QueryFunctionContext" }, { - "label": "Types / DefinedCreateQueryResult", - "to": "framework/svelte/reference/type-aliases/DefinedCreateQueryResult" + "label": "Types / QueryKey", + "to": "framework/angular/reference/type-aliases/QueryKey" }, { - "label": "Types / DefinedInitialDataOptions", - "to": "framework/svelte/reference/type-aliases/DefinedInitialDataOptions" + "label": "Types / QueryKeyHashFunction", + "to": "framework/angular/reference/type-aliases/QueryKeyHashFunction" }, { - "label": "Types / HydrationBoundary", - "to": "framework/svelte/reference/type-aliases/HydrationBoundary" + "label": "Types / QueryKeyWithDataTag", + "to": "framework/angular/reference/type-aliases/QueryKeyWithDataTag" }, { - "label": "Types / MutationStateOptions", - "to": "framework/svelte/reference/type-aliases/MutationStateOptions" + "label": "Types / QueryMeta", + "to": "framework/angular/reference/type-aliases/QueryMeta" }, { - "label": "Types / MutationTypeFromResult", - "to": "framework/svelte/reference/type-aliases/MutationTypeFromResult" + "label": "Types / QueryObserverResult", + "to": "framework/angular/reference/type-aliases/QueryObserverResult" }, { - "label": "Types / QueriesOptions", - "to": "framework/svelte/reference/type-aliases/QueriesOptions" + "label": "Types / QueryPersister", + "to": "framework/angular/reference/type-aliases/QueryPersister" }, { - "label": "Types / QueriesResults", - "to": "framework/svelte/reference/type-aliases/QueriesResults" + "label": "Types / QueryStatus", + "to": "framework/angular/reference/type-aliases/QueryStatus" }, { - "label": "Types / QueryClientProviderProps", - "to": "framework/svelte/reference/type-aliases/QueryClientProviderProps" + "label": "Types / SkipToken", + "to": "framework/angular/reference/type-aliases/SkipToken" + }, + { + "label": "Types / StaleTime", + "to": "framework/angular/reference/type-aliases/StaleTime" + }, + { + "label": "Types / StaleTimeFunction", + "to": "framework/angular/reference/type-aliases/StaleTimeFunction" + }, + { + "label": "Types / ThrowOnError", + "to": "framework/angular/reference/type-aliases/ThrowOnError" + }, + { + "label": "Types / TimeoutCallback", + "to": "framework/angular/reference/type-aliases/TimeoutCallback" + }, + { + "label": "Types / TimeoutProvider", + "to": "framework/angular/reference/type-aliases/TimeoutProvider" + }, + { + "label": "Types / UndefinedInitialDataInfiniteOptions", + "to": "framework/angular/reference/type-aliases/UndefinedInitialDataInfiniteOptions" }, { "label": "Types / UndefinedInitialDataOptions", - "to": "framework/svelte/reference/type-aliases/UndefinedInitialDataOptions" + "to": "framework/angular/reference/type-aliases/UndefinedInitialDataOptions" }, { - "label": "Variables / HydrationBoundary", - "to": "framework/svelte/reference/variables/HydrationBoundary" - } - ] - }, - { - "label": "lit", - "children": [ + "label": "Types / UnsetMarker", + "to": "framework/angular/reference/type-aliases/UnsetMarker" + }, { - "label": "Lit Reference", - "to": "framework/lit/reference/index" + "label": "Types / UnusedSkipTokenInfiniteOptions", + "to": "framework/angular/reference/type-aliases/UnusedSkipTokenInfiniteOptions" }, { - "label": "Classes / QueryClientProvider", - "to": "framework/lit/reference/classes/QueryClientProvider" + "label": "Types / UnusedSkipTokenOptions", + "to": "framework/angular/reference/type-aliases/UnusedSkipTokenOptions" }, { - "label": "Functions / createQueryController", - "to": "framework/lit/reference/functions/createQueryController" + "label": "Types / Updater", + "to": "framework/angular/reference/type-aliases/Updater" }, { - "label": "Functions / createQueriesController", - "to": "framework/lit/reference/functions/createQueriesController" + "label": "Types / WithRequired", + "to": "framework/angular/reference/type-aliases/WithRequired" }, { - "label": "Functions / createInfiniteQueryController", - "to": "framework/lit/reference/functions/createInfiniteQueryController" + "label": "Types / dataTagErrorSymbol", + "to": "framework/angular/reference/type-aliases/dataTagErrorSymbol" }, { - "label": "Functions / createMutationController", - "to": "framework/lit/reference/functions/createMutationController" + "label": "Types / dataTagSymbol", + "to": "framework/angular/reference/type-aliases/dataTagSymbol" }, { - "label": "Functions / useIsFetching", - "to": "framework/lit/reference/functions/useIsFetching" + "label": "Variables / dataTagErrorSymbol", + "to": "framework/angular/reference/variables/dataTagErrorSymbol" }, { - "label": "Functions / useIsMutating", - "to": "framework/lit/reference/functions/useIsMutating" + "label": "Variables / dataTagSymbol", + "to": "framework/angular/reference/variables/dataTagSymbol" }, { - "label": "Functions / useMutationState", - "to": "framework/lit/reference/functions/useMutationState" + "label": "Variables / defaultScheduler", + "to": "framework/angular/reference/variables/defaultScheduler" }, { - "label": "Functions / useQueryClient", - "to": "framework/lit/reference/functions/useQueryClient" + "label": "Variables / environmentManager", + "to": "framework/angular/reference/variables/environmentManager" }, { - "label": "Functions / queryOptions", - "to": "framework/lit/reference/functions/queryOptions" + "label": "Variables / focusManager", + "to": "framework/angular/reference/variables/focusManager" }, { - "label": "Functions / infiniteQueryOptions", - "to": "framework/lit/reference/functions/infiniteQueryOptions" + "label": "Variables / isServer", + "to": "framework/angular/reference/variables/isServer" }, { - "label": "Functions / mutationOptions", - "to": "framework/lit/reference/functions/mutationOptions" + "label": "Variables / notifyManager", + "to": "framework/angular/reference/variables/notifyManager" }, { - "label": "Context / queryClientContext", - "to": "framework/lit/reference/variables/queryClientContext" + "label": "Variables / onlineManager", + "to": "framework/angular/reference/variables/onlineManager" }, { - "label": "Context / getDefaultQueryClient", - "to": "framework/lit/reference/functions/getDefaultQueryClient" + "label": "Variables / skipToken", + "to": "framework/angular/reference/variables/skipToken" }, { - "label": "Context / registerDefaultQueryClient", - "to": "framework/lit/reference/functions/registerDefaultQueryClient" + "label": "Variables / timeoutManager", + "to": "framework/angular/reference/variables/timeoutManager" }, { - "label": "Context / unregisterDefaultQueryClient", - "to": "framework/lit/reference/functions/unregisterDefaultQueryClient" + "label": "Variables / unsetMarker", + "to": "framework/angular/reference/variables/unsetMarker" + } + ] + }, + { + "label": "preact", + "children": [ + { + "label": "Preact Reference", + "to": "framework/preact/reference/index" }, { - "label": "Context / resolveQueryClient", - "to": "framework/lit/reference/functions/resolveQueryClient" + "label": "Functions / HydrationBoundary", + "to": "framework/preact/reference/functions/HydrationBoundary" }, { - "label": "Types / Accessor", - "to": "framework/lit/reference/type-aliases/Accessor" + "label": "Functions / QueryClientProvider", + "to": "framework/preact/reference/functions/QueryClientProvider" }, { - "label": "Types / CreateInfiniteQueryOptions", - "to": "framework/lit/reference/type-aliases/CreateInfiniteQueryOptions" + "label": "Functions / QueryErrorResetBoundary", + "to": "framework/preact/reference/functions/QueryErrorResetBoundary" }, { - "label": "Types / CreateMutationOptions", - "to": "framework/lit/reference/type-aliases/CreateMutationOptions" + "label": "Functions / defaultShouldDehydrateMutation", + "to": "framework/preact/reference/functions/defaultShouldDehydrateMutation" }, { - "label": "Types / CreateQueriesControllerOptions", - "to": "framework/lit/reference/type-aliases/CreateQueriesControllerOptions" + "label": "Functions / defaultShouldDehydrateQuery", + "to": "framework/preact/reference/functions/defaultShouldDehydrateQuery" }, { - "label": "Types / CreateQueriesInput", - "to": "framework/lit/reference/type-aliases/CreateQueriesInput" + "label": "Functions / dehydrate", + "to": "framework/preact/reference/functions/dehydrate" }, { - "label": "Types / CreateQueryOptions", - "to": "framework/lit/reference/type-aliases/CreateQueryOptions" + "label": "Functions / dehydrateQuery", + "to": "framework/preact/reference/functions/dehydrateQuery" }, { - "label": "Types / DefinedInitialDataOptions", - "to": "framework/lit/reference/type-aliases/DefinedInitialDataOptions" + "label": "Functions / experimental_streamedQuery", + "to": "framework/preact/reference/functions/experimental_streamedQuery" }, { - "label": "Types / InfiniteQueryControllerOptions", - "to": "framework/lit/reference/type-aliases/InfiniteQueryControllerOptions" + "label": "Functions / hashKey", + "to": "framework/preact/reference/functions/hashKey" }, { - "label": "Types / InfiniteQueryResultAccessor", - "to": "framework/lit/reference/type-aliases/InfiniteQueryResultAccessor" + "label": "Functions / hydrate", + "to": "framework/preact/reference/functions/hydrate" }, { - "label": "Types / IsFetchingAccessor", - "to": "framework/lit/reference/type-aliases/IsFetchingAccessor" + "label": "Functions / infiniteQueryOptions", + "to": "framework/preact/reference/functions/infiniteQueryOptions" }, { - "label": "Types / IsMutatingAccessor", - "to": "framework/lit/reference/type-aliases/IsMutatingAccessor" + "label": "Functions / isCancelledError", + "to": "framework/preact/reference/functions/isCancelledError" }, { - "label": "Types / MutationControllerOptions", - "to": "framework/lit/reference/type-aliases/MutationControllerOptions" + "label": "Functions / keepPreviousData", + "to": "framework/preact/reference/functions/keepPreviousData" }, { - "label": "Types / MutationControllerResult", - "to": "framework/lit/reference/type-aliases/MutationControllerResult" + "label": "Functions / matchMutation", + "to": "framework/preact/reference/functions/matchMutation" }, { - "label": "Types / MutationResultAccessor", - "to": "framework/lit/reference/type-aliases/MutationResultAccessor" + "label": "Functions / matchQuery", + "to": "framework/preact/reference/functions/matchQuery" }, { - "label": "Types / MutationStateAccessor", - "to": "framework/lit/reference/type-aliases/MutationStateAccessor" + "label": "Functions / mutationOptions", + "to": "framework/preact/reference/functions/mutationOptions" }, { - "label": "Types / MutationStateOptions", - "to": "framework/lit/reference/type-aliases/MutationStateOptions" + "label": "Functions / noop", + "to": "framework/preact/reference/functions/noop" }, { - "label": "Types / QueriesControllerOptions", - "to": "framework/lit/reference/type-aliases/QueriesControllerOptions" + "label": "Functions / partialMatchKey", + "to": "framework/preact/reference/functions/partialMatchKey" }, { - "label": "Types / QueriesResultAccessor", - "to": "framework/lit/reference/type-aliases/QueriesResultAccessor" + "label": "Functions / queryOptions", + "to": "framework/preact/reference/functions/queryOptions" }, { - "label": "Types / QueryControllerOptions", - "to": "framework/lit/reference/type-aliases/QueryControllerOptions" + "label": "Functions / replaceEqualDeep", + "to": "framework/preact/reference/functions/replaceEqualDeep" }, { - "label": "Types / QueryControllerResult", - "to": "framework/lit/reference/type-aliases/QueryControllerResult" + "label": "Functions / shouldThrowError", + "to": "framework/preact/reference/functions/shouldThrowError" }, { - "label": "Types / QueryResultAccessor", - "to": "framework/lit/reference/type-aliases/QueryResultAccessor" + "label": "Functions / useInfiniteQuery", + "to": "framework/preact/reference/functions/useInfiniteQuery" }, { - "label": "Types / UndefinedInitialDataOptions", - "to": "framework/lit/reference/type-aliases/UndefinedInitialDataOptions" + "label": "Functions / useIsFetching", + "to": "framework/preact/reference/functions/useIsFetching" }, { - "label": "Types / UnusedSkipTokenOptions", - "to": "framework/lit/reference/type-aliases/UnusedSkipTokenOptions" + "label": "Functions / useIsMutating", + "to": "framework/preact/reference/functions/useIsMutating" }, { - "label": "Types / ValueAccessor", - "to": "framework/lit/reference/type-aliases/ValueAccessor" - } - ] - }, - { - "label": "angular", - "children": [ + "label": "Functions / useIsRestoring", + "to": "framework/preact/reference/functions/useIsRestoring" + }, { - "label": "Angular Reference", - "to": "framework/angular/reference/index" + "label": "Functions / useMutation", + "to": "framework/preact/reference/functions/useMutation" }, { - "label": "Functions / infiniteQueryOptions", - "to": "framework/angular/reference/functions/infiniteQueryOptions" + "label": "Functions / useMutationState", + "to": "framework/preact/reference/functions/useMutationState" }, { - "label": "Functions / injectInfiniteQuery", - "to": "framework/angular/reference/functions/injectInfiniteQuery" + "label": "Functions / usePrefetchInfiniteQuery", + "to": "framework/preact/reference/functions/usePrefetchInfiniteQuery" }, { - "label": "Functions / injectIsFetching", - "to": "framework/angular/reference/functions/injectIsFetching" + "label": "Functions / usePrefetchQuery", + "to": "framework/preact/reference/functions/usePrefetchQuery" }, { - "label": "Functions / injectIsMutating", - "to": "framework/angular/reference/functions/injectIsMutating" + "label": "Functions / useQueries", + "to": "framework/preact/reference/functions/useQueries" }, { - "label": "Functions / injectIsRestoring", - "to": "framework/angular/reference/functions/injectIsRestoring" + "label": "Functions / useQuery", + "to": "framework/preact/reference/functions/useQuery" }, { - "label": "Functions / injectMutation", - "to": "framework/angular/reference/functions/injectMutation" + "label": "Functions / useQueryClient", + "to": "framework/preact/reference/functions/useQueryClient" }, { - "label": "Functions / injectMutationState", - "to": "framework/angular/reference/functions/injectMutationState" + "label": "Functions / useQueryErrorResetBoundary", + "to": "framework/preact/reference/functions/useQueryErrorResetBoundary" }, { - "label": "Functions / injectQuery", - "to": "framework/angular/reference/functions/injectQuery" + "label": "Functions / useSuspenseInfiniteQuery", + "to": "framework/preact/reference/functions/useSuspenseInfiniteQuery" }, { - "label": "Functions / mutationOptions", - "to": "framework/angular/reference/functions/mutationOptions" + "label": "Functions / useSuspenseQueries", + "to": "framework/preact/reference/functions/useSuspenseQueries" }, { - "label": "Functions / provideIsRestoring", - "to": "framework/angular/reference/functions/provideIsRestoring" + "label": "Functions / useSuspenseQuery", + "to": "framework/preact/reference/functions/useSuspenseQuery" }, { - "label": "Functions / provideQueryClient", - "to": "framework/angular/reference/functions/provideQueryClient" + "label": "Classes / CancelledError", + "to": "framework/preact/reference/classes/CancelledError" }, { - "label": "Functions / provideTanStackQuery", - "to": "framework/angular/reference/functions/provideTanStackQuery" + "label": "Classes / InfiniteQueryObserver", + "to": "framework/preact/reference/classes/InfiniteQueryObserver" }, { - "label": "Functions / queryFeature", - "to": "framework/angular/reference/functions/queryFeature" + "label": "Classes / Mutation", + "to": "framework/preact/reference/classes/Mutation" }, { - "label": "Functions / queryOptions", - "to": "framework/angular/reference/functions/queryOptions" + "label": "Classes / MutationCache", + "to": "framework/preact/reference/classes/MutationCache" }, { - "label": "Functions / injectQueryClient", - "to": "framework/angular/reference/functions/injectQueryClient" + "label": "Classes / MutationObserver", + "to": "framework/preact/reference/classes/MutationObserver" }, { - "label": "Functions / provideAngularQuery", - "to": "framework/angular/reference/functions/provideAngularQuery" + "label": "Classes / QueriesObserver", + "to": "framework/preact/reference/classes/QueriesObserver" }, { - "label": "Interfaces / BaseMutationNarrowing", - "to": "framework/angular/reference/interfaces/BaseMutationNarrowing" + "label": "Classes / Query", + "to": "framework/preact/reference/classes/Query" }, { - "label": "Interfaces / BaseQueryNarrowing", - "to": "framework/angular/reference/interfaces/BaseQueryNarrowing" + "label": "Classes / QueryCache", + "to": "framework/preact/reference/classes/QueryCache" }, { - "label": "Interfaces / CreateBaseQueryOptions", - "to": "framework/angular/reference/interfaces/CreateBaseQueryOptions" + "label": "Classes / QueryClient", + "to": "framework/preact/reference/classes/QueryClient" }, { - "label": "Interfaces / CreateInfiniteQueryOptions", - "to": "framework/angular/reference/interfaces/CreateInfiniteQueryOptions" + "label": "Classes / QueryObserver", + "to": "framework/preact/reference/classes/QueryObserver" }, { - "label": "Interfaces / CreateMutationOptions", - "to": "framework/angular/reference/interfaces/CreateMutationOptions" + "label": "Interfaces / CancelOptions", + "to": "framework/preact/reference/interfaces/CancelOptions" }, { - "label": "Interfaces / CreateQueryOptions", - "to": "framework/angular/reference/interfaces/CreateQueryOptions" + "label": "Interfaces / DefaultOptions", + "to": "framework/preact/reference/interfaces/DefaultOptions" }, { - "label": "Interfaces / InjectInfiniteQueryOptions", - "to": "framework/angular/reference/interfaces/InjectInfiniteQueryOptions" + "label": "Interfaces / DehydrateOptions", + "to": "framework/preact/reference/interfaces/DehydrateOptions" + }, + { + "label": "Interfaces / DehydratedState", + "to": "framework/preact/reference/interfaces/DehydratedState" + }, + { + "label": "Interfaces / EnsureQueryDataOptions", + "to": "framework/preact/reference/interfaces/EnsureQueryDataOptions" + }, + { + "label": "Interfaces / FetchNextPageOptions", + "to": "framework/preact/reference/interfaces/FetchNextPageOptions" + }, + { + "label": "Interfaces / FetchPreviousPageOptions", + "to": "framework/preact/reference/interfaces/FetchPreviousPageOptions" + }, + { + "label": "Interfaces / FetchQueryOptions", + "to": "framework/preact/reference/interfaces/FetchQueryOptions" + }, + { + "label": "Interfaces / FocusManager", + "to": "framework/preact/reference/interfaces/FocusManager" + }, + { + "label": "Interfaces / HydrateOptions", + "to": "framework/preact/reference/interfaces/HydrateOptions" }, { - "label": "Interfaces / InjectIsFetchingOptions", - "to": "framework/angular/reference/interfaces/InjectIsFetchingOptions" + "label": "Interfaces / HydrationBoundaryProps", + "to": "framework/preact/reference/interfaces/HydrationBoundaryProps" }, { - "label": "Interfaces / InjectIsMutatingOptions", - "to": "framework/angular/reference/interfaces/InjectIsMutatingOptions" + "label": "Interfaces / InfiniteData", + "to": "framework/preact/reference/interfaces/InfiniteData" }, { - "label": "Interfaces / InjectMutationOptions", - "to": "framework/angular/reference/interfaces/InjectMutationOptions" + "label": "Interfaces / InfiniteQueryObserverBaseResult", + "to": "framework/preact/reference/interfaces/InfiniteQueryObserverBaseResult" }, { - "label": "Interfaces / InjectMutationStateOptions", - "to": "framework/angular/reference/interfaces/InjectMutationStateOptions" + "label": "Interfaces / InfiniteQueryObserverLoadingErrorResult", + "to": "framework/preact/reference/interfaces/InfiniteQueryObserverLoadingErrorResult" }, { - "label": "Interfaces / InjectQueryOptions", - "to": "framework/angular/reference/interfaces/InjectQueryOptions" + "label": "Interfaces / InfiniteQueryObserverLoadingResult", + "to": "framework/preact/reference/interfaces/InfiniteQueryObserverLoadingResult" }, { - "label": "Interfaces / QueryFeature", - "to": "framework/angular/reference/interfaces/QueryFeature" + "label": "Interfaces / InfiniteQueryObserverOptions", + "to": "framework/preact/reference/interfaces/InfiniteQueryObserverOptions" }, { - "label": "Types / CreateBaseMutationResult", - "to": "framework/angular/reference/type-aliases/CreateBaseMutationResult" + "label": "Interfaces / InfiniteQueryObserverPendingResult", + "to": "framework/preact/reference/interfaces/InfiniteQueryObserverPendingResult" }, { - "label": "Types / CreateBaseQueryResult", - "to": "framework/angular/reference/type-aliases/CreateBaseQueryResult" + "label": "Interfaces / InfiniteQueryObserverPlaceholderResult", + "to": "framework/preact/reference/interfaces/InfiniteQueryObserverPlaceholderResult" }, { - "label": "Types / CreateInfiniteQueryResult", - "to": "framework/angular/reference/type-aliases/CreateInfiniteQueryResult" + "label": "Interfaces / InfiniteQueryObserverRefetchErrorResult", + "to": "framework/preact/reference/interfaces/InfiniteQueryObserverRefetchErrorResult" }, { - "label": "Types / CreateMutateAsyncFunction", - "to": "framework/angular/reference/type-aliases/CreateMutateAsyncFunction" + "label": "Interfaces / InfiniteQueryObserverSuccessResult", + "to": "framework/preact/reference/interfaces/InfiniteQueryObserverSuccessResult" }, { - "label": "Types / CreateMutateFunction", - "to": "framework/angular/reference/type-aliases/CreateMutateFunction" + "label": "Interfaces / InfiniteQueryPageParamsOptions", + "to": "framework/preact/reference/interfaces/InfiniteQueryPageParamsOptions" }, { - "label": "Types / CreateMutationResult", - "to": "framework/angular/reference/type-aliases/CreateMutationResult" + "label": "Interfaces / InitialPageParam", + "to": "framework/preact/reference/interfaces/InitialPageParam" }, { - "label": "Types / CreateQueryResult", - "to": "framework/angular/reference/type-aliases/CreateQueryResult" + "label": "Interfaces / InvalidateOptions", + "to": "framework/preact/reference/interfaces/InvalidateOptions" }, { - "label": "Types / DefinedCreateInfiniteQueryResult", - "to": "framework/angular/reference/type-aliases/DefinedCreateInfiniteQueryResult" + "label": "Interfaces / InvalidateQueryFilters", + "to": "framework/preact/reference/interfaces/InvalidateQueryFilters" }, { - "label": "Types / DefinedCreateQueryResult", - "to": "framework/angular/reference/type-aliases/DefinedCreateQueryResult" + "label": "Interfaces / MutateOptions", + "to": "framework/preact/reference/interfaces/MutateOptions" }, { - "label": "Types / DefinedInitialDataInfiniteOptions", - "to": "framework/angular/reference/type-aliases/DefinedInitialDataInfiniteOptions" + "label": "Interfaces / MutationCacheConfig", + "to": "framework/preact/reference/interfaces/MutationCacheConfig" }, { - "label": "Types / DefinedInitialDataOptions", - "to": "framework/angular/reference/type-aliases/DefinedInitialDataOptions" + "label": "Interfaces / MutationFilters", + "to": "framework/preact/reference/interfaces/MutationFilters" }, { - "label": "Types / DevtoolsFeature", - "to": "framework/angular/reference/type-aliases/DevtoolsFeature" + "label": "Interfaces / MutationObserverBaseResult", + "to": "framework/preact/reference/interfaces/MutationObserverBaseResult" }, { - "label": "Types / PersistQueryClientFeature", - "to": "framework/angular/reference/type-aliases/PersistQueryClientFeature" + "label": "Interfaces / MutationObserverErrorResult", + "to": "framework/preact/reference/interfaces/MutationObserverErrorResult" }, { - "label": "Types / QueriesOptions", - "to": "framework/angular/reference/type-aliases/QueriesOptions" + "label": "Interfaces / MutationObserverIdleResult", + "to": "framework/preact/reference/interfaces/MutationObserverIdleResult" }, { - "label": "Types / QueriesResults", - "to": "framework/angular/reference/type-aliases/QueriesResults" + "label": "Interfaces / MutationObserverLoadingResult", + "to": "framework/preact/reference/interfaces/MutationObserverLoadingResult" }, { - "label": "Types / QueryFeatures", - "to": "framework/angular/reference/type-aliases/QueryFeatures" + "label": "Interfaces / MutationObserverOptions", + "to": "framework/preact/reference/interfaces/MutationObserverOptions" }, { - "label": "Types / UndefinedInitialDataInfiniteOptions", - "to": "framework/angular/reference/type-aliases/UndefinedInitialDataInfiniteOptions" + "label": "Interfaces / MutationObserverSuccessResult", + "to": "framework/preact/reference/interfaces/MutationObserverSuccessResult" }, { - "label": "Types / UndefinedInitialDataOptions", - "to": "framework/angular/reference/type-aliases/UndefinedInitialDataOptions" + "label": "Interfaces / MutationOptions", + "to": "framework/preact/reference/interfaces/MutationOptions" }, { - "label": "Types / UnusedSkipTokenInfiniteOptions", - "to": "framework/angular/reference/type-aliases/UnusedSkipTokenInfiniteOptions" + "label": "Interfaces / MutationState", + "to": "framework/preact/reference/interfaces/MutationState" }, { - "label": "Types / UnusedSkipTokenOptions", - "to": "framework/angular/reference/type-aliases/UnusedSkipTokenOptions" - } - ] - }, - { - "label": "preact", - "children": [ + "label": "Interfaces / NotifyEvent", + "to": "framework/preact/reference/interfaces/NotifyEvent" + }, { - "label": "Preact Reference", - "to": "framework/preact/reference/index" + "label": "Interfaces / OnlineManager", + "to": "framework/preact/reference/interfaces/OnlineManager" }, { - "label": "Functions / useQuery", - "to": "framework/preact/reference/functions/useQuery" + "label": "Interfaces / QueriesObserverOptions", + "to": "framework/preact/reference/interfaces/QueriesObserverOptions" }, { - "label": "Functions / useQueries", - "to": "framework/preact/reference/functions/useQueries" + "label": "Interfaces / QueryCacheConfig", + "to": "framework/preact/reference/interfaces/QueryCacheConfig" }, { - "label": "Functions / useInfiniteQuery", - "to": "framework/preact/reference/functions/useInfiniteQuery" + "label": "Interfaces / QueryClientConfig", + "to": "framework/preact/reference/interfaces/QueryClientConfig" }, { - "label": "Functions / useMutation", - "to": "framework/preact/reference/functions/useMutation" + "label": "Interfaces / QueryErrorResetBoundaryProps", + "to": "framework/preact/reference/interfaces/QueryErrorResetBoundaryProps" }, { - "label": "Functions / useIsFetching", - "to": "framework/preact/reference/functions/useIsFetching" + "label": "Interfaces / QueryExecuteOptions", + "to": "framework/preact/reference/interfaces/QueryExecuteOptions" }, { - "label": "Functions / useIsMutating", - "to": "framework/preact/reference/functions/useIsMutating" + "label": "Interfaces / QueryFilters", + "to": "framework/preact/reference/interfaces/QueryFilters" }, { - "label": "Functions / useMutationState", - "to": "framework/preact/reference/functions/useMutationState" + "label": "Interfaces / QueryObserverBaseResult", + "to": "framework/preact/reference/interfaces/QueryObserverBaseResult" }, { - "label": "Functions / useSuspenseQuery", - "to": "framework/preact/reference/functions/useSuspenseQuery" + "label": "Interfaces / QueryObserverLoadingErrorResult", + "to": "framework/preact/reference/interfaces/QueryObserverLoadingErrorResult" }, { - "label": "Functions / useSuspenseInfiniteQuery", - "to": "framework/preact/reference/functions/useSuspenseInfiniteQuery" + "label": "Interfaces / QueryObserverLoadingResult", + "to": "framework/preact/reference/interfaces/QueryObserverLoadingResult" }, { - "label": "Functions / useSuspenseQueries", - "to": "framework/preact/reference/functions/useSuspenseQueries" + "label": "Interfaces / QueryObserverOptions", + "to": "framework/preact/reference/interfaces/QueryObserverOptions" }, { - "label": "Functions / QueryClientProvider", - "to": "framework/preact/reference/functions/QueryClientProvider" + "label": "Interfaces / QueryObserverPendingResult", + "to": "framework/preact/reference/interfaces/QueryObserverPendingResult" }, { - "label": "Functions / useQueryClient", - "to": "framework/preact/reference/functions/useQueryClient" + "label": "Interfaces / QueryObserverPlaceholderResult", + "to": "framework/preact/reference/interfaces/QueryObserverPlaceholderResult" }, { - "label": "Functions / queryOptions", - "to": "framework/preact/reference/functions/queryOptions" + "label": "Interfaces / QueryObserverRefetchErrorResult", + "to": "framework/preact/reference/interfaces/QueryObserverRefetchErrorResult" }, { - "label": "Functions / infiniteQueryOptions", - "to": "framework/preact/reference/functions/infiniteQueryOptions" + "label": "Interfaces / QueryObserverSuccessResult", + "to": "framework/preact/reference/interfaces/QueryObserverSuccessResult" }, { - "label": "Functions / mutationOptions", - "to": "framework/preact/reference/functions/mutationOptions" + "label": "Interfaces / QueryOptions", + "to": "framework/preact/reference/interfaces/QueryOptions" }, { - "label": "Functions / usePrefetchQuery", - "to": "framework/preact/reference/functions/usePrefetchQuery" + "label": "Interfaces / QueryState", + "to": "framework/preact/reference/interfaces/QueryState" }, { - "label": "Functions / usePrefetchInfiniteQuery", - "to": "framework/preact/reference/functions/usePrefetchInfiniteQuery" + "label": "Interfaces / RefetchOptions", + "to": "framework/preact/reference/interfaces/RefetchOptions" }, { - "label": "Functions / QueryErrorResetBoundary", - "to": "framework/preact/reference/functions/QueryErrorResetBoundary" + "label": "Interfaces / RefetchQueryFilters", + "to": "framework/preact/reference/interfaces/RefetchQueryFilters" }, { - "label": "Functions / useQueryErrorResetBoundary", - "to": "framework/preact/reference/functions/useQueryErrorResetBoundary" + "label": "Interfaces / Register", + "to": "framework/preact/reference/interfaces/Register" }, { - "label": "Functions / HydrationBoundary", - "to": "framework/preact/reference/functions/HydrationBoundary" + "label": "Interfaces / ResetOptions", + "to": "framework/preact/reference/interfaces/ResetOptions" }, { - "label": "Functions / useIsRestoring", - "to": "framework/preact/reference/functions/useIsRestoring" + "label": "Interfaces / ResultOptions", + "to": "framework/preact/reference/interfaces/ResultOptions" }, { - "label": "Interfaces / HydrationBoundaryProps", - "to": "framework/preact/reference/interfaces/HydrationBoundaryProps" + "label": "Interfaces / SetDataOptions", + "to": "framework/preact/reference/interfaces/SetDataOptions" }, { - "label": "Interfaces / QueryErrorResetBoundaryProps", - "to": "framework/preact/reference/interfaces/QueryErrorResetBoundaryProps" + "label": "Interfaces / TimeoutManager", + "to": "framework/preact/reference/interfaces/TimeoutManager" }, { "label": "Interfaces / UseBaseQueryOptions", @@ -2322,6 +6221,10 @@ "label": "Interfaces / UseSuspenseQueryOptions", "to": "framework/preact/reference/interfaces/UseSuspenseQueryOptions" }, + { + "label": "Types / AnyDataTag", + "to": "framework/preact/reference/type-aliases/AnyDataTag" + }, { "label": "Types / AnyUseBaseQueryOptions", "to": "framework/preact/reference/type-aliases/AnyUseBaseQueryOptions" @@ -2346,6 +6249,26 @@ "label": "Types / AnyUseSuspenseQueryOptions", "to": "framework/preact/reference/type-aliases/AnyUseSuspenseQueryOptions" }, + { + "label": "Types / DataTag", + "to": "framework/preact/reference/type-aliases/DataTag" + }, + { + "label": "Types / DefaultError", + "to": "framework/preact/reference/type-aliases/DefaultError" + }, + { + "label": "Types / DefaultedInfiniteQueryObserverOptions", + "to": "framework/preact/reference/type-aliases/DefaultedInfiniteQueryObserverOptions" + }, + { + "label": "Types / DefaultedQueryObserverOptions", + "to": "framework/preact/reference/type-aliases/DefaultedQueryObserverOptions" + }, + { + "label": "Types / DefinedInfiniteQueryObserverResult", + "to": "framework/preact/reference/type-aliases/DefinedInfiniteQueryObserverResult" + }, { "label": "Types / DefinedInitialDataInfiniteOptions", "to": "framework/preact/reference/type-aliases/DefinedInitialDataInfiniteOptions" @@ -2354,6 +6277,10 @@ "label": "Types / DefinedInitialDataOptions", "to": "framework/preact/reference/type-aliases/DefinedInitialDataOptions" }, + { + "label": "Types / DefinedQueryObserverResult", + "to": "framework/preact/reference/type-aliases/DefinedQueryObserverResult" + }, { "label": "Types / DefinedUseInfiniteQueryResult", "to": "framework/preact/reference/type-aliases/DefinedUseInfiniteQueryResult" @@ -2362,14 +6289,142 @@ "label": "Types / DefinedUseQueryResult", "to": "framework/preact/reference/type-aliases/DefinedUseQueryResult" }, + { + "label": "Types / DistributiveOmit", + "to": "framework/preact/reference/type-aliases/DistributiveOmit" + }, + { + "label": "Types / EnsureInfiniteQueryDataOptions", + "to": "framework/preact/reference/type-aliases/EnsureInfiniteQueryDataOptions" + }, + { + "label": "Types / FetchInfiniteQueryOptions", + "to": "framework/preact/reference/type-aliases/FetchInfiniteQueryOptions" + }, + { + "label": "Types / FetchStatus", + "to": "framework/preact/reference/type-aliases/FetchStatus" + }, + { + "label": "Types / GetNextPageParamFunction", + "to": "framework/preact/reference/type-aliases/GetNextPageParamFunction" + }, + { + "label": "Types / GetPreviousPageParamFunction", + "to": "framework/preact/reference/type-aliases/GetPreviousPageParamFunction" + }, + { + "label": "Types / InferDataFromTag", + "to": "framework/preact/reference/type-aliases/InferDataFromTag" + }, + { + "label": "Types / InferErrorFromTag", + "to": "framework/preact/reference/type-aliases/InferErrorFromTag" + }, + { + "label": "Types / InfiniteQueryExecuteOptions", + "to": "framework/preact/reference/type-aliases/InfiniteQueryExecuteOptions" + }, + { + "label": "Types / InfiniteQueryObserverResult", + "to": "framework/preact/reference/type-aliases/InfiniteQueryObserverResult" + }, + { + "label": "Types / InitialDataFunction", + "to": "framework/preact/reference/type-aliases/InitialDataFunction" + }, + { + "label": "Types / ManagedTimerId", + "to": "framework/preact/reference/type-aliases/ManagedTimerId" + }, + { + "label": "Types / MutateFunction", + "to": "framework/preact/reference/type-aliases/MutateFunction" + }, + { + "label": "Types / MutateFunctionRest", + "to": "framework/preact/reference/type-aliases/MutateFunctionRest" + }, + { + "label": "Types / MutationCacheNotifyEvent", + "to": "framework/preact/reference/type-aliases/MutationCacheNotifyEvent" + }, + { + "label": "Types / MutationFunction", + "to": "framework/preact/reference/type-aliases/MutationFunction" + }, + { + "label": "Types / MutationFunctionContext", + "to": "framework/preact/reference/type-aliases/MutationFunctionContext" + }, + { + "label": "Types / MutationKey", + "to": "framework/preact/reference/type-aliases/MutationKey" + }, + { + "label": "Types / MutationMeta", + "to": "framework/preact/reference/type-aliases/MutationMeta" + }, + { + "label": "Types / MutationObserverResult", + "to": "framework/preact/reference/type-aliases/MutationObserverResult" + }, + { + "label": "Types / MutationScope", + "to": "framework/preact/reference/type-aliases/MutationScope" + }, + { + "label": "Types / MutationStatus", + "to": "framework/preact/reference/type-aliases/MutationStatus" + }, + { + "label": "Types / NetworkMode", + "to": "framework/preact/reference/type-aliases/NetworkMode" + }, + { + "label": "Types / NonUndefinedGuard", + "to": "framework/preact/reference/type-aliases/NonUndefinedGuard" + }, + { + "label": "Types / NotifyEventType", + "to": "framework/preact/reference/type-aliases/NotifyEventType" + }, + { + "label": "Types / NotifyOnChangeProps", + "to": "framework/preact/reference/type-aliases/NotifyOnChangeProps" + }, + { + "label": "Types / OmitKeyof", + "to": "framework/preact/reference/type-aliases/OmitKeyof" + }, + { + "label": "Types / Override", + "to": "framework/preact/reference/type-aliases/Override" + }, + { + "label": "Types / PlaceholderDataFunction", + "to": "framework/preact/reference/type-aliases/PlaceholderDataFunction" + }, { "label": "Types / QueriesOptions", "to": "framework/preact/reference/type-aliases/QueriesOptions" }, + { + "label": "Types / QueriesPlaceholderDataFunction", + "to": "framework/preact/reference/type-aliases/QueriesPlaceholderDataFunction" + }, { "label": "Types / QueriesResults", "to": "framework/preact/reference/type-aliases/QueriesResults" }, + { + "label": "Types / QueryBooleanOption", + "to": "framework/preact/reference/type-aliases/QueryBooleanOption" + }, + { + "label": "Types / QueryCacheNotifyEvent", + "to": "framework/preact/reference/type-aliases/QueryCacheNotifyEvent" + }, { "label": "Types / QueryClientProviderProps", "to": "framework/preact/reference/type-aliases/QueryClientProviderProps" @@ -2390,6 +6445,54 @@ "label": "Types / QueryErrorResetFunction", "to": "framework/preact/reference/type-aliases/QueryErrorResetFunction" }, + { + "label": "Types / QueryFunction", + "to": "framework/preact/reference/type-aliases/QueryFunction" + }, + { + "label": "Types / QueryFunctionContext", + "to": "framework/preact/reference/type-aliases/QueryFunctionContext" + }, + { + "label": "Types / QueryKey", + "to": "framework/preact/reference/type-aliases/QueryKey" + }, + { + "label": "Types / QueryKeyHashFunction", + "to": "framework/preact/reference/type-aliases/QueryKeyHashFunction" + }, + { + "label": "Types / QueryKeyWithDataTag", + "to": "framework/preact/reference/type-aliases/QueryKeyWithDataTag" + }, + { + "label": "Types / QueryMeta", + "to": "framework/preact/reference/type-aliases/QueryMeta" + }, + { + "label": "Types / QueryObserverResult", + "to": "framework/preact/reference/type-aliases/QueryObserverResult" + }, + { + "label": "Types / QueryPersister", + "to": "framework/preact/reference/type-aliases/QueryPersister" + }, + { + "label": "Types / QueryStatus", + "to": "framework/preact/reference/type-aliases/QueryStatus" + }, + { + "label": "Types / SkipToken", + "to": "framework/preact/reference/type-aliases/SkipToken" + }, + { + "label": "Types / StaleTime", + "to": "framework/preact/reference/type-aliases/StaleTime" + }, + { + "label": "Types / StaleTimeFunction", + "to": "framework/preact/reference/type-aliases/StaleTimeFunction" + }, { "label": "Types / SuspenseQueriesOptions", "to": "framework/preact/reference/type-aliases/SuspenseQueriesOptions" @@ -2398,6 +6501,18 @@ "label": "Types / SuspenseQueriesResults", "to": "framework/preact/reference/type-aliases/SuspenseQueriesResults" }, + { + "label": "Types / ThrowOnError", + "to": "framework/preact/reference/type-aliases/ThrowOnError" + }, + { + "label": "Types / TimeoutCallback", + "to": "framework/preact/reference/type-aliases/TimeoutCallback" + }, + { + "label": "Types / TimeoutProvider", + "to": "framework/preact/reference/type-aliases/TimeoutProvider" + }, { "label": "Types / UndefinedInitialDataInfiniteOptions", "to": "framework/preact/reference/type-aliases/UndefinedInitialDataInfiniteOptions" @@ -2406,6 +6521,10 @@ "label": "Types / UndefinedInitialDataOptions", "to": "framework/preact/reference/type-aliases/UndefinedInitialDataOptions" }, + { + "label": "Types / UnsetMarker", + "to": "framework/preact/reference/type-aliases/UnsetMarker" + }, { "label": "Types / UnusedSkipTokenInfiniteOptions", "to": "framework/preact/reference/type-aliases/UnusedSkipTokenInfiniteOptions" @@ -2414,6 +6533,10 @@ "label": "Types / UnusedSkipTokenOptions", "to": "framework/preact/reference/type-aliases/UnusedSkipTokenOptions" }, + { + "label": "Types / Updater", + "to": "framework/preact/reference/type-aliases/Updater" + }, { "label": "Types / UseBaseMutationResult", "to": "framework/preact/reference/type-aliases/UseBaseMutationResult" @@ -2458,6 +6581,18 @@ "label": "Types / UseSuspenseQueryResult", "to": "framework/preact/reference/type-aliases/UseSuspenseQueryResult" }, + { + "label": "Types / WithRequired", + "to": "framework/preact/reference/type-aliases/WithRequired" + }, + { + "label": "Types / dataTagErrorSymbol", + "to": "framework/preact/reference/type-aliases/dataTagErrorSymbol" + }, + { + "label": "Types / dataTagSymbol", + "to": "framework/preact/reference/type-aliases/dataTagSymbol" + }, { "label": "Variables / IsRestoringProvider", "to": "framework/preact/reference/variables/IsRestoringProvider" @@ -2465,6 +6600,50 @@ { "label": "Variables / QueryClientContext", "to": "framework/preact/reference/variables/QueryClientContext" + }, + { + "label": "Variables / dataTagErrorSymbol", + "to": "framework/preact/reference/variables/dataTagErrorSymbol" + }, + { + "label": "Variables / dataTagSymbol", + "to": "framework/preact/reference/variables/dataTagSymbol" + }, + { + "label": "Variables / defaultScheduler", + "to": "framework/preact/reference/variables/defaultScheduler" + }, + { + "label": "Variables / environmentManager", + "to": "framework/preact/reference/variables/environmentManager" + }, + { + "label": "Variables / focusManager", + "to": "framework/preact/reference/variables/focusManager" + }, + { + "label": "Variables / isServer", + "to": "framework/preact/reference/variables/isServer" + }, + { + "label": "Variables / notifyManager", + "to": "framework/preact/reference/variables/notifyManager" + }, + { + "label": "Variables / onlineManager", + "to": "framework/preact/reference/variables/onlineManager" + }, + { + "label": "Variables / skipToken", + "to": "framework/preact/reference/variables/skipToken" + }, + { + "label": "Variables / timeoutManager", + "to": "framework/preact/reference/variables/timeoutManager" + }, + { + "label": "Variables / unsetMarker", + "to": "framework/preact/reference/variables/unsetMarker" } ] } diff --git a/docs/framework/angular/reference/classes/CancelledError.md b/docs/framework/angular/reference/classes/CancelledError.md new file mode 100644 index 00000000000..7fded5da20f --- /dev/null +++ b/docs/framework/angular/reference/classes/CancelledError.md @@ -0,0 +1,273 @@ +--- +id: CancelledError +title: CancelledError +--- + +Defined in: [packages/query-core/src/retryer.ts:77](https://github.com/TanStack/query/blob/main/packages/query-core/src/retryer.ts#L77) + +The error thrown by a `Retryer` (and surfaced to `query.promise`/`mutation`) when a fetch is cancelled, e.g. via +`query.cancel()`. `revert`, if `true`, tells the caller to restore the state the query was in before the fetch +started instead of surfacing the error. `silent`, if `true`, tells the caller to suppress this error and instead +resolve with the promise of the fetch that triggered the cancellation. + +## Example + +```ts +query.cancel() + +try { + await query.promise +} catch (error) { + if (error instanceof CancelledError) { + // the fetch was cancelled, e.g. via `query.cancel()` + } +} +``` + +## Extends + +- `Error` + +## Constructors + +### Constructor + +```ts +new CancelledError(options?): CancelledError; +``` + +Defined in: [packages/query-core/src/retryer.ts:80](https://github.com/TanStack/query/blob/main/packages/query-core/src/retryer.ts#L80) + +#### Parameters + +##### options? + +[`CancelOptions`](../interfaces/CancelOptions.md) + +#### Returns + +`CancelledError` + +#### Overrides + +```ts +Error.constructor +``` + +## Properties + +### cause? + +```ts +optional cause: unknown; +``` + +Defined in: node\_modules/.pnpm/typescript@6.0.3/node\_modules/typescript/lib/lib.es2022.error.d.ts:24 + +#### Inherited from + +```ts +Error.cause +``` + +*** + +### message + +```ts +message: string; +``` + +Defined in: node\_modules/.pnpm/typescript@6.0.3/node\_modules/typescript/lib/lib.es5.d.ts:1075 + +#### Inherited from + +```ts +Error.message +``` + +*** + +### name + +```ts +name: string; +``` + +Defined in: node\_modules/.pnpm/typescript@6.0.3/node\_modules/typescript/lib/lib.es5.d.ts:1074 + +#### Inherited from + +```ts +Error.name +``` + +*** + +### revert? + +```ts +optional revert: boolean; +``` + +Defined in: [packages/query-core/src/retryer.ts:78](https://github.com/TanStack/query/blob/main/packages/query-core/src/retryer.ts#L78) + +*** + +### silent? + +```ts +optional silent: boolean; +``` + +Defined in: [packages/query-core/src/retryer.ts:79](https://github.com/TanStack/query/blob/main/packages/query-core/src/retryer.ts#L79) + +*** + +### stack? + +```ts +optional stack: string; +``` + +Defined in: node\_modules/.pnpm/typescript@6.0.3/node\_modules/typescript/lib/lib.es5.d.ts:1076 + +#### Inherited from + +```ts +Error.stack +``` + +*** + +### stackTraceLimit + +```ts +static stackTraceLimit: number; +``` + +Defined in: node\_modules/.pnpm/@types+node@22.19.15/node\_modules/@types/node/globals.d.ts:68 + +The `Error.stackTraceLimit` property specifies the number of stack frames +collected by a stack trace (whether generated by `new Error().stack` or +`Error.captureStackTrace(obj)`). + +The default value is `10` but may be set to any valid JavaScript number. Changes +will affect any stack trace captured _after_ the value has been changed. + +If set to a non-number value, or set to a negative number, stack traces will +not capture any frames. + +#### Inherited from + +```ts +Error.stackTraceLimit +``` + +## Methods + +### captureStackTrace() + +```ts +static captureStackTrace(targetObject, constructorOpt?): void; +``` + +Defined in: node\_modules/.pnpm/@types+node@22.19.15/node\_modules/@types/node/globals.d.ts:52 + +Creates a `.stack` property on `targetObject`, which when accessed returns +a string representing the location in the code at which +`Error.captureStackTrace()` was called. + +```js +const myObject = {}; +Error.captureStackTrace(myObject); +myObject.stack; // Similar to `new Error().stack` +``` + +The first line of the trace will be prefixed with +`${myObject.name}: ${myObject.message}`. + +The optional `constructorOpt` argument accepts a function. If given, all frames +above `constructorOpt`, including `constructorOpt`, will be omitted from the +generated stack trace. + +The `constructorOpt` argument is useful for hiding implementation +details of error generation from the user. For instance: + +```js +function a() { + b(); +} + +function b() { + c(); +} + +function c() { + // Create an error without stack trace to avoid calculating the stack trace twice. + const { stackTraceLimit } = Error; + Error.stackTraceLimit = 0; + const error = new Error(); + Error.stackTraceLimit = stackTraceLimit; + + // Capture the stack trace above function b + Error.captureStackTrace(error, b); // Neither function c, nor b is included in the stack trace + throw error; +} + +a(); +``` + +#### Parameters + +##### targetObject + +`object` + +##### constructorOpt? + +`Function` + +#### Returns + +`void` + +#### Inherited from + +```ts +Error.captureStackTrace +``` + +*** + +### prepareStackTrace() + +```ts +static prepareStackTrace(err, stackTraces): any; +``` + +Defined in: node\_modules/.pnpm/@types+node@22.19.15/node\_modules/@types/node/globals.d.ts:56 + +#### Parameters + +##### err + +`Error` + +##### stackTraces + +`CallSite`[] + +#### Returns + +`any` + +#### See + +https://v8.dev/docs/stack-trace-api#customizing-stack-traces + +#### Inherited from + +```ts +Error.prepareStackTrace +``` diff --git a/docs/framework/angular/reference/classes/InfiniteQueryObserver.md b/docs/framework/angular/reference/classes/InfiniteQueryObserver.md new file mode 100644 index 00000000000..af43087a3ad --- /dev/null +++ b/docs/framework/angular/reference/classes/InfiniteQueryObserver.md @@ -0,0 +1,665 @@ +--- +id: InfiniteQueryObserver +title: InfiniteQueryObserver +--- + +Defined in: [packages/query-core/src/infiniteQueryObserver.ts:41](https://github.com/TanStack/query/blob/main/packages/query-core/src/infiniteQueryObserver.ts#L41) + +An `InfiniteQueryObserver` extends `QueryObserver` to observe and switch +between infinite queries. It augments the base `QueryObserverResult` with +infinite-query-specific fields and methods, such as `hasNextPage` and +`fetchNextPage`, and is the primitive that framework adapters (e.g. +`useInfiniteQuery`) build their hooks on top of. + +## Example + +```ts +const observer = new InfiniteQueryObserver(queryClient, { + queryKey: ['projects'], + queryFn: ({ pageParam }) => fetchProjects(pageParam), + initialPageParam: 0, + getNextPageParam: (lastPage) => lastPage.nextCursor, +}) + +const unsubscribe = observer.subscribe((result) => console.log(result)) +``` + +## Extends + +- [`QueryObserver`](QueryObserver.md)\<`TQueryFnData`, `TError`, `TData`, [`InfiniteData`](../interfaces/InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\> + +## Type Parameters + +### TQueryFnData + +`TQueryFnData` = `unknown` + +### TError + +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) + +### TData + +`TData` = [`InfiniteData`](../interfaces/InfiniteData.md)\<`TQueryFnData`\> + +### TQueryKey + +`TQueryKey` *extends* [`QueryKey`](../type-aliases/QueryKey.md) = [`QueryKey`](../type-aliases/QueryKey.md) + +### TPageParam + +`TPageParam` = `unknown` + +## Constructors + +### Constructor + +```ts +new InfiniteQueryObserver(client, options): InfiniteQueryObserver; +``` + +Defined in: [packages/query-core/src/infiniteQueryObserver.ts:83](https://github.com/TanStack/query/blob/main/packages/query-core/src/infiniteQueryObserver.ts#L83) + +#### Parameters + +##### client + +[`QueryClient`](QueryClient.md) + +##### options + +[`InfiniteQueryObserverOptions`](../interfaces/InfiniteQueryObserverOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`, `TPageParam`\> + +#### Returns + +`InfiniteQueryObserver`\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`, `TPageParam`\> + +#### Overrides + +[`QueryObserver`](QueryObserver.md).[`constructor`](QueryObserver.md#constructor) + +## Properties + +### fetch + +```ts +protected fetch: ReplaceReturnType<(fetchOptions) => Promise>, Promise>>; +``` + +Defined in: [packages/query-core/src/infiniteQueryObserver.ts:72](https://github.com/TanStack/query/blob/main/packages/query-core/src/infiniteQueryObserver.ts#L72) + +#### Overrides + +```ts +QueryObserver.fetch +``` + +*** + +### getCurrentResult + +```ts +getCurrentResult: ReplaceReturnType<() => QueryObserverResult, InfiniteQueryObserverResult>; +``` + +Defined in: [packages/query-core/src/infiniteQueryObserver.ts:60](https://github.com/TanStack/query/blob/main/packages/query-core/src/infiniteQueryObserver.ts#L60) + +Returns the most recently computed `QueryObserverResult` for the +observed query. This is a point-in-time read; to be notified of updates +as they happen, subscribe to the observer instead (its inherited +`subscribe` method). + +#### Example + +```ts +const result = observer.getCurrentResult() +console.log(result.status, result.data) +``` + +#### Overrides + +```ts +QueryObserver.getCurrentResult +``` + +*** + +### listeners + +```ts +protected listeners: Set>; +``` + +Defined in: [packages/query-core/src/subscribable.ts:2](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L2) + +#### Inherited from + +[`QueryObserver`](QueryObserver.md).[`listeners`](QueryObserver.md#listeners) + +*** + +### options + +```ts +options: QueryObserverOptions, TQueryKey>; +``` + +Defined in: [packages/query-core/src/queryObserver.ts:89](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L89) + +#### Inherited from + +[`QueryObserver`](QueryObserver.md).[`options`](QueryObserver.md#options) + +*** + +### subscribe() + +```ts +subscribe: (listener) => () => void; +``` + +Defined in: [packages/query-core/src/infiniteQueryObserver.ts:55](https://github.com/TanStack/query/blob/main/packages/query-core/src/infiniteQueryObserver.ts#L55) + +#### Parameters + +##### listener + +`InfiniteQueryObserverListener` + +#### Returns + +```ts +(): void; +``` + +##### Returns + +`void` + +#### Overrides + +```ts +QueryObserver.subscribe +``` + +## Methods + +### bindMethods() + +```ts +protected bindMethods(): void; +``` + +Defined in: [packages/query-core/src/infiniteQueryObserver.ts:96](https://github.com/TanStack/query/blob/main/packages/query-core/src/infiniteQueryObserver.ts#L96) + +#### Returns + +`void` + +#### Overrides + +[`QueryObserver`](QueryObserver.md).[`bindMethods`](QueryObserver.md#bindmethods) + +*** + +### createResult() + +```ts +protected createResult(query, options): InfiniteQueryObserverResult; +``` + +Defined in: [packages/query-core/src/infiniteQueryObserver.ts:201](https://github.com/TanStack/query/blob/main/packages/query-core/src/infiniteQueryObserver.ts#L201) + +#### Parameters + +##### query + +[`Query`](Query.md)\<`TQueryFnData`, `TError`, [`InfiniteData`](../interfaces/InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\> + +##### options + +[`InfiniteQueryObserverOptions`](../interfaces/InfiniteQueryObserverOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`, `TPageParam`\> + +#### Returns + +[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\> + +#### Overrides + +[`QueryObserver`](QueryObserver.md).[`createResult`](QueryObserver.md#createresult) + +*** + +### destroy() + +```ts +destroy(): void; +``` + +Defined in: [packages/query-core/src/queryObserver.ts:161](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L161) + +Stops observing the current query: clears all listeners, cancels the +stale and refetch-interval timers, and removes this observer from the +query it was observing. + +#### Returns + +`void` + +#### Inherited from + +[`QueryObserver`](QueryObserver.md).[`destroy`](QueryObserver.md#destroy) + +*** + +### fetchNextPage() + +```ts +fetchNextPage(options?): Promise>; +``` + +Defined in: [packages/query-core/src/infiniteQueryObserver.ts:161](https://github.com/TanStack/query/blob/main/packages/query-core/src/infiniteQueryObserver.ts#L161) + +Fetches the next page of the infinite query and returns a promise that +resolves with the resulting `InfiniteQueryObserverResult`. The page +param used for the fetch is determined by `getNextPageParam`, which +receives the current pages/page params and whose result also determines +`hasNextPage`. + +#### Parameters + +##### options? + +[`FetchNextPageOptions`](../interfaces/FetchNextPageOptions.md) + +#### Returns + +`Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> + +#### Example + +```ts +const { hasNextPage } = observer.getCurrentResult() + +if (hasNextPage) { + await observer.fetchNextPage() +} +``` + +#### See + +[InfiniteQueryObserver#fetchPreviousPage](#fetchpreviouspage) + +*** + +### fetchOptimistic() + +```ts +fetchOptimistic(options): Promise>; +``` + +Defined in: [packages/query-core/src/queryObserver.ts:395](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L395) + +Fetches a query defined by the given options without affecting this +observer's own tracked query or result, and returns a promise that +resolves with the `QueryObserverResult` for that fetch. This is useful +for prefetching data that another observer (e.g. a query about to be +navigated to) will need, ahead of time. + +#### Parameters + +##### options + +[`QueryObserverOptions`](../interfaces/QueryObserverOptions.md)\<`TQueryFnData`, `TError`, `TData`, [`InfiniteData`](../interfaces/InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\> + +#### Returns + +`Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> + +#### Example + +```ts +const result = await observer.fetchOptimistic({ + queryKey: ['posts', 2], + queryFn: () => fetchPost(2), +}) +console.log(result.data) +``` + +#### Inherited from + +[`QueryObserver`](QueryObserver.md).[`fetchOptimistic`](QueryObserver.md#fetchoptimistic) + +*** + +### fetchPreviousPage() + +```ts +fetchPreviousPage(options?): Promise>; +``` + +Defined in: [packages/query-core/src/infiniteQueryObserver.ts:190](https://github.com/TanStack/query/blob/main/packages/query-core/src/infiniteQueryObserver.ts#L190) + +Fetches the previous page of the infinite query and returns a promise +that resolves with the resulting `InfiniteQueryObserverResult`. The page +param used for the fetch is determined by `getPreviousPageParam`, which +receives the current pages/page params and whose result also determines +`hasPreviousPage`. + +#### Parameters + +##### options? + +[`FetchPreviousPageOptions`](../interfaces/FetchPreviousPageOptions.md) + +#### Returns + +`Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> + +#### Example + +```ts +const { hasPreviousPage } = observer.getCurrentResult() + +if (hasPreviousPage) { + await observer.fetchPreviousPage() +} +``` + +#### See + +[InfiniteQueryObserver#fetchNextPage](#fetchnextpage) + +*** + +### getCurrentQuery() + +```ts +getCurrentQuery(): Query, TQueryKey>; +``` + +Defined in: [packages/query-core/src/queryObserver.ts:357](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L357) + +Returns the `Query` instance this observer is currently observing. + +#### Returns + +[`Query`](Query.md)\<`TQueryFnData`, `TError`, [`InfiniteData`](../interfaces/InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\> + +#### Inherited from + +[`QueryObserver`](QueryObserver.md).[`getCurrentQuery`](QueryObserver.md#getcurrentquery) + +*** + +### getOptimisticResult() + +```ts +getOptimisticResult(options): InfiniteQueryObserverResult; +``` + +Defined in: [packages/query-core/src/infiniteQueryObserver.ts:127](https://github.com/TanStack/query/blob/main/packages/query-core/src/infiniteQueryObserver.ts#L127) + +The infinite-query counterpart of [QueryObserver#getOptimisticResult](QueryObserver.md#getoptimisticresult), marking the +options as an infinite query before delegating to it. Called by framework adapters (e.g. +`useInfiniteQuery`) ahead of subscribing, to compute the current `InfiniteQueryObserverResult` +synchronously. + +#### Parameters + +##### options + +[`DefaultedInfiniteQueryObserverOptions`](../type-aliases/DefaultedInfiniteQueryObserverOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`, `TPageParam`\> + +#### Returns + +[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\> + +#### Overrides + +[`QueryObserver`](QueryObserver.md).[`getOptimisticResult`](QueryObserver.md#getoptimisticresult) + +*** + +### hasListeners() + +```ts +hasListeners(): boolean; +``` + +Defined in: [packages/query-core/src/subscribable.ts:19](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L19) + +#### Returns + +`boolean` + +#### Inherited from + +[`QueryObserver`](QueryObserver.md).[`hasListeners`](QueryObserver.md#haslisteners) + +*** + +### onSubscribe() + +```ts +protected onSubscribe(): void; +``` + +Defined in: [packages/query-core/src/queryObserver.ts:110](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L110) + +#### Returns + +`void` + +#### Inherited from + +[`QueryObserver`](QueryObserver.md).[`onSubscribe`](QueryObserver.md#onsubscribe) + +*** + +### onUnsubscribe() + +```ts +protected onUnsubscribe(): void; +``` + +Defined in: [packages/query-core/src/queryObserver.ts:124](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L124) + +#### Returns + +`void` + +#### Inherited from + +[`QueryObserver`](QueryObserver.md).[`onUnsubscribe`](QueryObserver.md#onunsubscribe) + +*** + +### refetch() + +```ts +refetch(__namedParameters): Promise>; +``` + +Defined in: [packages/query-core/src/queryObserver.ts:371](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L371) + +Refetches the observed query and returns a promise that resolves with +the resulting `QueryObserverResult`. + +#### Parameters + +##### \_\_namedParameters + +[`RefetchOptions`](../interfaces/RefetchOptions.md) = `{}` + +#### Returns + +`Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> + +#### Example + +```ts +const result = await observer.refetch({ cancelRefetch: false }) +console.log(result.data) +``` + +#### Inherited from + +[`QueryObserver`](QueryObserver.md).[`refetch`](QueryObserver.md#refetch) + +*** + +### setOptions() + +```ts +setOptions(options): void; +``` + +Defined in: [packages/query-core/src/infiniteQueryObserver.ts:108](https://github.com/TanStack/query/blob/main/packages/query-core/src/infiniteQueryObserver.ts#L108) + +Updates the observer's options. Behaves the same as +`QueryObserver.setOptions`, additionally marking the options as +belonging to an infinite query before delegating to the base +implementation. + +#### Parameters + +##### options + +[`InfiniteQueryObserverOptions`](../interfaces/InfiniteQueryObserverOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`, `TPageParam`\> + +#### Returns + +`void` + +#### Overrides + +[`QueryObserver`](QueryObserver.md).[`setOptions`](QueryObserver.md#setoptions) + +*** + +### shouldFetchOnReconnect() + +```ts +shouldFetchOnReconnect(): boolean; +``` + +Defined in: [packages/query-core/src/queryObserver.ts:135](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L135) + +Returns whether the observed query is currently stale and configured +(via the `refetchOnReconnect` option) to refetch when the network +reconnects. + +#### Returns + +`boolean` + +#### Inherited from + +[`QueryObserver`](QueryObserver.md).[`shouldFetchOnReconnect`](QueryObserver.md#shouldfetchonreconnect) + +*** + +### shouldFetchOnWindowFocus() + +```ts +shouldFetchOnWindowFocus(): boolean; +``` + +Defined in: [packages/query-core/src/queryObserver.ts:148](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L148) + +Returns whether the observed query is currently stale and configured +(via the `refetchOnWindowFocus` option) to refetch when the window +regains focus. + +#### Returns + +`boolean` + +#### Inherited from + +[`QueryObserver`](QueryObserver.md).[`shouldFetchOnWindowFocus`](QueryObserver.md#shouldfetchonwindowfocus) + +*** + +### trackProp() + +```ts +trackProp(key): void; +``` + +Defined in: [packages/query-core/src/queryObserver.ts:350](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L350) + +Records that the given `QueryObserverResult` property was read, so a subsequent update only +notifies this observer if a tracked property actually changed. Normally called indirectly via +[QueryObserver#trackResult](QueryObserver.md#trackresult)'s proxy; exposed directly for adapters that track property +access themselves (e.g. through their own reactivity system) instead of via the proxy. + +#### Parameters + +##### key + +`"error"` | `"data"` | `"isError"` | `"isPending"` | `"isLoading"` | `"isLoadingError"` | `"isRefetchError"` | `"isSuccess"` | `"isPlaceholderData"` | `"status"` | `"dataUpdatedAt"` | `"errorUpdatedAt"` | `"failureCount"` | `"failureReason"` | `"errorUpdateCount"` | `"isFetched"` | `"isFetchedAfterMount"` | `"isFetching"` | `"isInitialLoading"` | `"isPaused"` | `"isRefetching"` | `"isStale"` | `"isEnabled"` | `"refetch"` | `"fetchStatus"` + +#### Returns + +`void` + +#### Inherited from + +[`QueryObserver`](QueryObserver.md).[`trackProp`](QueryObserver.md#trackprop) + +*** + +### trackResult() + +```ts +trackResult(result, onPropTracked?): QueryObserverResult; +``` + +Defined in: [packages/query-core/src/queryObserver.ts:331](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L331) + +Wraps a `QueryObserverResult` in a `Proxy` that records which properties are read, via +[QueryObserver#trackProp](QueryObserver.md#trackprop) (and an optional `onPropTracked` callback). Used by framework +adapters when `notifyOnChangeProps` is not set, to implement its default "only re-render on +properties you actually read" behavior. + +#### Parameters + +##### result + +[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\> + +##### onPropTracked? + +(`key`) => `void` + +#### Returns + +[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\> + +#### Inherited from + +[`QueryObserver`](QueryObserver.md).[`trackResult`](QueryObserver.md#trackresult) + +*** + +### updateResult() + +```ts +updateResult(): void; +``` + +Defined in: [packages/query-core/src/queryObserver.ts:735](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L735) + +Recomputes and stores the current result from the current query/options, notifying listeners +if it changed. Framework adapters call this right after subscribing to make sure no query +update was missed in the gap between creating the observer and subscribing to it. + +#### Returns + +`void` + +#### Inherited from + +[`QueryObserver`](QueryObserver.md).[`updateResult`](QueryObserver.md#updateresult) diff --git a/docs/framework/angular/reference/classes/Mutation.md b/docs/framework/angular/reference/classes/Mutation.md new file mode 100644 index 00000000000..e038a9cd394 --- /dev/null +++ b/docs/framework/angular/reference/classes/Mutation.md @@ -0,0 +1,330 @@ +--- +id: Mutation +title: Mutation +--- + +Defined in: [packages/query-core/src/mutation.ts:135](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L135) + +Represents a single mutation attempt. A `Mutation` holds the mutation's +options, state (data/error/status), and the `MutationObserver`s currently +subscribed to it. + +Instances are created and managed internally by `MutationCache`; application +code typically interacts with mutations indirectly through `QueryClient` or +a framework hook like `useMutation`. Direct access to a `Mutation` instance +is possible via `mutationCache.find()`/`getAll()` for inspecting cache state. + +## Example + +```ts +const mutationCache = queryClient.getMutationCache() + +const mutation = mutationCache.find({ mutationKey: ['addPost'] }) +``` + +## Extends + +- `Removable` + +## Type Parameters + +### TData + +`TData` = `unknown` + +### TError + +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) + +### TVariables + +`TVariables` = `unknown` + +### TOnMutateResult + +`TOnMutateResult` = `unknown` + +## Constructors + +### Constructor + +```ts +new Mutation(config): Mutation; +``` + +Defined in: [packages/query-core/src/mutation.ts:152](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L152) + +#### Parameters + +##### config + +`MutationConfig`\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\> + +#### Returns + +`Mutation`\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\> + +#### Overrides + +```ts +Removable.constructor +``` + +## Properties + +### gcTime + +```ts +gcTime: number; +``` + +Defined in: [packages/query-core/src/removable.ts:7](https://github.com/TanStack/query/blob/main/packages/query-core/src/removable.ts#L7) + +#### Inherited from + +```ts +Removable.gcTime +``` + +*** + +### mutationId + +```ts +readonly mutationId: number; +``` + +Defined in: [packages/query-core/src/mutation.ts:143](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L143) + +*** + +### options + +```ts +options: MutationOptions; +``` + +Defined in: [packages/query-core/src/mutation.ts:142](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L142) + +*** + +### state + +```ts +state: MutationState; +``` + +Defined in: [packages/query-core/src/mutation.ts:141](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L141) + +## Accessors + +### meta + +#### Get Signature + +```ts +get meta(): Record | undefined; +``` + +Defined in: [packages/query-core/src/mutation.ts:179](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L179) + +The `meta` object passed in the mutation's options, if any. + +##### Returns + +`Record`\<`string`, `unknown`\> \| `undefined` + +## Methods + +### clearGcTimeout() + +```ts +protected clearGcTimeout(): void; +``` + +Defined in: [packages/query-core/src/removable.ts:32](https://github.com/TanStack/query/blob/main/packages/query-core/src/removable.ts#L32) + +#### Returns + +`void` + +#### Inherited from + +```ts +Removable.clearGcTimeout +``` + +*** + +### continue() + +```ts +continue(): Promise; +``` + +Defined in: [packages/query-core/src/mutation.ts:243](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L243) + +Resumes a mutation that is currently paused or was restored from a +dehydrated, still-`pending` state. + +- If this mutation has an active retryer (it paused mid-attempt, e.g. due + to the network mode or scope-based queuing), its retryer is resumed. +- Otherwise, if the mutation's status is still `pending` (e.g. it was + dehydrated while an attempt was in flight and never got a retryer in + this instance), `execute` is called again with the last known variables. +- Otherwise the mutation has already settled and this resolves immediately + without running anything again. + +#### Returns + +`Promise`\<`unknown`\> + +#### Example + +```ts +// typically driven by reconnect handling, e.g. queryClient.resumePausedMutations() +const mutation = mutationCache.find({ mutationKey: ['addPost'] }) +await mutation?.continue() +``` + +#### See + +[Mutation#execute](#execute) + +*** + +### destroy() + +```ts +destroy(): void; +``` + +Defined in: [packages/query-core/src/removable.ts:10](https://github.com/TanStack/query/blob/main/packages/query-core/src/removable.ts#L10) + +#### Returns + +`void` + +#### Inherited from + +```ts +Removable.destroy +``` + +*** + +### execute() + +```ts +execute(variables): Promise; +``` + +Defined in: [packages/query-core/src/mutation.ts:284](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L284) + +Runs the mutation function for the given variables through a retryer, and +drives the mutation's state and lifecycle callbacks through to settlement. + +If this mutation's state is already `pending` when `execute` is called +(i.e. it was restored, still in-flight, from a dehydrated state), the +`onMutate` step is skipped and a `continue` action is dispatched to +unpause it; otherwise a `pending` action is dispatched first, then the +mutation cache's `onMutate` and the mutation's own `onMutate` option are +awaited in that order, and the resulting context is stored. + +The mutation function is then run (subject to `retry`/`retryDelay`/ +`networkMode`, and to the mutation cache's scope-based serialization). +On success, the cache's `onSuccess`/`onSettled` callbacks run before the +mutation's own `onSuccess`/`onSettled` options, a `success` action is +dispatched, and the resolved data is returned. On failure, the same +cache-then-option ordering is used for `onError`/`onSettled`, but each of +those four callbacks is individually caught so that a throwing callback +cannot mask the original error; an `error` action is then dispatched and +the original error is re-thrown. + +#### Parameters + +##### variables + +`TVariables` + +#### Returns + +`Promise`\<`TData`\> + +#### Example + +```ts +// Called internally by `MutationObserver.mutate` and `Mutation.continue` — +// applications normally trigger mutations through those, not this method. +const data = await mutation.execute(variables) +``` + +#### See + +[Mutation#continue](#continue) + +*** + +### optionalRemove() + +```ts +protected optionalRemove(): void; +``` + +Defined in: [packages/query-core/src/mutation.ts:212](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L212) + +#### Returns + +`void` + +#### Overrides + +```ts +Removable.optionalRemove +``` + +*** + +### scheduleGc() + +```ts +protected scheduleGc(): void; +``` + +Defined in: [packages/query-core/src/removable.ts:14](https://github.com/TanStack/query/blob/main/packages/query-core/src/removable.ts#L14) + +#### Returns + +`void` + +#### Inherited from + +```ts +Removable.scheduleGc +``` + +*** + +### updateGcTime() + +```ts +protected updateGcTime(newGcTime): void; +``` + +Defined in: [packages/query-core/src/removable.ts:24](https://github.com/TanStack/query/blob/main/packages/query-core/src/removable.ts#L24) + +#### Parameters + +##### newGcTime + +`number` | `undefined` + +#### Returns + +`void` + +#### Inherited from + +```ts +Removable.updateGcTime +``` diff --git a/docs/framework/angular/reference/classes/MutationCache.md b/docs/framework/angular/reference/classes/MutationCache.md new file mode 100644 index 00000000000..5a172b4cb9b --- /dev/null +++ b/docs/framework/angular/reference/classes/MutationCache.md @@ -0,0 +1,316 @@ +--- +id: MutationCache +title: MutationCache +--- + +Defined in: [packages/query-core/src/mutationCache.ts:124](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationCache.ts#L124) + +The `MutationCache` is the storage for mutations. + +Normally, you will not interact with the `MutationCache` directly and instead use a +`QueryClient`. You can subscribe to it (inherited from `Subscribable`) to be informed of +safe/known updates to the cache, such as mutations being added, removed, or updated. + +## Example + +```ts +const unsubscribe = mutationCache.subscribe((event) => { + console.log(event.type, event.mutation) +}) +``` + +## Extends + +- `Subscribable`\<`MutationCacheListener`\> + +## Constructors + +### Constructor + +```ts +new MutationCache(config): MutationCache; +``` + +Defined in: [packages/query-core/src/mutationCache.ts:129](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationCache.ts#L129) + +#### Parameters + +##### config + +[`MutationCacheConfig`](../interfaces/MutationCacheConfig.md) = `{}` + +#### Returns + +`MutationCache` + +#### Overrides + +```ts +Subscribable.constructor +``` + +## Properties + +### config + +```ts +config: MutationCacheConfig = {}; +``` + +Defined in: [packages/query-core/src/mutationCache.ts:129](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationCache.ts#L129) + +*** + +### listeners + +```ts +protected listeners: Set; +``` + +Defined in: [packages/query-core/src/subscribable.ts:2](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L2) + +#### Inherited from + +```ts +Subscribable.listeners +``` + +## Methods + +### clear() + +```ts +clear(): void; +``` + +Defined in: [packages/query-core/src/mutationCache.ts:236](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationCache.ts#L236) + +Removes all mutations from the cache. + +#### Returns + +`void` + +#### Example + +```ts +const mutationCache = queryClient.getMutationCache() + +mutationCache.clear() +``` + +*** + +### find() + +```ts +find(filters): + | Mutation + | undefined; +``` + +Defined in: [packages/query-core/src/mutationCache.ts:278](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationCache.ts#L278) + +A slightly more advanced method that can be used to get an existing mutation instance from +the cache. If the mutation does not exist, `undefined` is returned. + +This is not typically needed for most applications, but can come in handy when needing more +information about a mutation in rare scenarios. + +#### Type Parameters + +##### TData + +`TData` = `unknown` + +##### TError + +`TError` = `Error` + +##### TVariables + +`TVariables` = `any` + +##### TOnMutateResult + +`TOnMutateResult` = `unknown` + +#### Parameters + +##### filters + +[`MutationFilters`](../interfaces/MutationFilters.md) + +#### Returns + + \| [`Mutation`](Mutation.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\> + \| `undefined` + +#### See + +[MutationCache#findAll](#findall) + +#### Example + +```ts +const mutationCache = queryClient.getMutationCache() + +const mutation = mutationCache.find({ mutationKey: ['addPost'] }) +``` + +*** + +### findAll() + +```ts +findAll(filters): Mutation[]; +``` + +Defined in: [packages/query-core/src/mutationCache.ts:308](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationCache.ts#L308) + +An even more advanced method that can be used to get existing mutation instances from the +cache that match the given filters. If no mutations match, an empty array is returned. + +This is not typically needed for most applications, but can come in handy when needing more +information about mutations in rare scenarios. + +#### Parameters + +##### filters + +[`MutationFilters`](../interfaces/MutationFilters.md) = `{}` + +#### Returns + +[`Mutation`](Mutation.md)\<`unknown`, `Error`, `unknown`, `unknown`\>[] + +#### See + +[MutationCache#find](#find) + +#### Example + +```ts +const mutationCache = queryClient.getMutationCache() + +const mutations = mutationCache.findAll({ mutationKey: ['addPost'] }) +``` + +*** + +### getAll() + +```ts +getAll(): Mutation[]; +``` + +Defined in: [packages/query-core/src/mutationCache.ts:259](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationCache.ts#L259) + +Returns all mutations within the cache. + +This is not typically needed for most applications, but can come in handy when needing more +information about a mutation in rare scenarios. + +#### Returns + +[`Mutation`](Mutation.md)\<`unknown`, `Error`, `unknown`, `unknown`\>[] + +#### Example + +```ts +const mutationCache = queryClient.getMutationCache() + +const mutations = mutationCache.getAll() +``` + +*** + +### hasListeners() + +```ts +hasListeners(): boolean; +``` + +Defined in: [packages/query-core/src/subscribable.ts:19](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L19) + +#### Returns + +`boolean` + +#### Inherited from + +```ts +Subscribable.hasListeners +``` + +*** + +### onSubscribe() + +```ts +protected onSubscribe(): void; +``` + +Defined in: [packages/query-core/src/subscribable.ts:23](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L23) + +#### Returns + +`void` + +#### Inherited from + +```ts +Subscribable.onSubscribe +``` + +*** + +### onUnsubscribe() + +```ts +protected onUnsubscribe(): void; +``` + +Defined in: [packages/query-core/src/subscribable.ts:27](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L27) + +#### Returns + +`void` + +#### Inherited from + +```ts +Subscribable.onUnsubscribe +``` + +*** + +### subscribe() + +```ts +subscribe(listener): () => void; +``` + +Defined in: [packages/query-core/src/subscribable.ts:8](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L8) + +#### Parameters + +##### listener + +`MutationCacheListener` + +#### Returns + +```ts +(): void; +``` + +##### Returns + +`void` + +#### Inherited from + +```ts +Subscribable.subscribe +``` diff --git a/docs/framework/angular/reference/classes/MutationObserver.md b/docs/framework/angular/reference/classes/MutationObserver.md new file mode 100644 index 00000000000..a121c67b0e8 --- /dev/null +++ b/docs/framework/angular/reference/classes/MutationObserver.md @@ -0,0 +1,335 @@ +--- +id: MutationObserver +title: MutationObserver +--- + +Defined in: [packages/query-core/src/mutationObserver.ts:38](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationObserver.ts#L38) + +Observes a single mutation and derives a `MutationObserverResult` from it. +A framework hook like `useMutation` creates one `MutationObserver` per hook +call, keeps it stable across re-renders, calls `setOptions` when the options +passed to the hook change, subscribes to it to re-render on updates, and +reads `getCurrentResult()` for the value to return. Calling `mutate()` +builds a new underlying `Mutation` in the `MutationCache` and executes it. + +## Example + +```ts +const observer = new MutationObserver(queryClient, { + mutationFn: (variables: { title: string }) => addPost(variables), +}) +``` + +## Extends + +- `Subscribable`\<`MutationObserverListener`\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\>\> + +## Type Parameters + +### TData + +`TData` = `unknown` + +### TError + +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) + +### TVariables + +`TVariables` = `void` + +### TOnMutateResult + +`TOnMutateResult` = `unknown` + +## Constructors + +### Constructor + +```ts +new MutationObserver(client, options): MutationObserver; +``` + +Defined in: [packages/query-core/src/mutationObserver.ts:58](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationObserver.ts#L58) + +#### Parameters + +##### client + +[`QueryClient`](QueryClient.md) + +##### options + +[`MutationObserverOptions`](../interfaces/MutationObserverOptions.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\> + +#### Returns + +`MutationObserver`\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\> + +#### Overrides + +```ts +Subscribable< + MutationObserverListener +>.constructor +``` + +## Properties + +### listeners + +```ts +protected listeners: Set>; +``` + +Defined in: [packages/query-core/src/subscribable.ts:2](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L2) + +#### Inherited from + +```ts +Subscribable.listeners +``` + +*** + +### options + +```ts +options: MutationObserverOptions; +``` + +Defined in: [packages/query-core/src/mutationObserver.ts:46](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationObserver.ts#L46) + +## Methods + +### bindMethods() + +```ts +protected bindMethods(): void; +``` + +Defined in: [packages/query-core/src/mutationObserver.ts:75](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationObserver.ts#L75) + +#### Returns + +`void` + +*** + +### getCurrentResult() + +```ts +getCurrentResult(): MutationObserverResult; +``` + +Defined in: [packages/query-core/src/mutationObserver.ts:155](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationObserver.ts#L155) + +Returns the observer's current result, derived from the observed +mutation's state (or the default, `idle` state if no mutation has been +built yet, e.g. before the first `mutate()` call or after `reset()`). + +#### Returns + +[`MutationObserverResult`](../type-aliases/MutationObserverResult.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\> + +*** + +### hasListeners() + +```ts +hasListeners(): boolean; +``` + +Defined in: [packages/query-core/src/subscribable.ts:19](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L19) + +#### Returns + +`boolean` + +#### Inherited from + +```ts +Subscribable.hasListeners +``` + +*** + +### mutate() + +```ts +mutate(variables, options?): Promise; +``` + +Defined in: [packages/query-core/src/mutationObserver.ts:207](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationObserver.ts#L207) + +Builds a new `Mutation` in the `MutationCache` using the observer's +current options, detaches this observer from any previously observed +mutation, attaches it to the new one, and executes it with the given +variables. + +The optional per-call `options` (`onSuccess`/`onError`/`onSettled`) are +invoked once the mutation settles, in addition to any callbacks defined +on the observer's own options. + +#### Parameters + +##### variables + +`TVariables` + +##### options? + +[`MutateOptions`](../interfaces/MutateOptions.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\> + +#### Returns + +`Promise`\<`TData`\> + +#### Example + +```ts +await observer.mutate( + { title: 'New post' }, + { onSuccess: (data) => console.log(data) }, +) +``` + +*** + +### onSubscribe() + +```ts +protected onSubscribe(): void; +``` + +Defined in: [packages/query-core/src/mutationObserver.ts:127](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationObserver.ts#L127) + +#### Returns + +`void` + +#### Overrides + +```ts +Subscribable.onSubscribe +``` + +*** + +### onUnsubscribe() + +```ts +protected onUnsubscribe(): void; +``` + +Defined in: [packages/query-core/src/mutationObserver.ts:135](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationObserver.ts#L135) + +#### Returns + +`void` + +#### Overrides + +```ts +Subscribable.onUnsubscribe +``` + +*** + +### reset() + +```ts +reset(): void; +``` + +Defined in: [packages/query-core/src/mutationObserver.ts:180](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationObserver.ts#L180) + +Detaches the observer from the mutation it is currently observing (if +any) and resets the observed result back to its default, `idle` state. + +This does not cancel an in-flight mutation; the mutation itself keeps +running to completion and its own callbacks still fire, but this +observer stops reflecting its state and a subsequent `mutate()` call +will build a brand new mutation. + +#### Returns + +`void` + +#### Example + +```ts +observer.reset() +``` + +#### See + +[MutationObserver#mutate](#mutate) + +*** + +### setOptions() + +```ts +setOptions(options): void; +``` + +Defined in: [packages/query-core/src/mutationObserver.ts:96](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationObserver.ts#L96) + +Updates the observer's options. + +If the new `mutationKey` differs from the previous one (and both were +defined), the observer is reset, detaching it from the mutation it was +observing. Otherwise, if the currently observed mutation is still +`pending`, its options are updated in place as well. + +#### Parameters + +##### options + +[`MutationObserverOptions`](../interfaces/MutationObserverOptions.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\> + +#### Returns + +`void` + +#### Example + +```ts +observer.setOptions({ + mutationFn: (variables: { title: string }) => addPost(variables), + onSuccess: (data) => console.log(data), +}) +``` + +*** + +### subscribe() + +```ts +subscribe(listener): () => void; +``` + +Defined in: [packages/query-core/src/subscribable.ts:8](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L8) + +#### Parameters + +##### listener + +`MutationObserverListener` + +#### Returns + +```ts +(): void; +``` + +##### Returns + +`void` + +#### Inherited from + +```ts +Subscribable.subscribe +``` diff --git a/docs/framework/angular/reference/classes/QueriesObserver.md b/docs/framework/angular/reference/classes/QueriesObserver.md new file mode 100644 index 00000000000..379e6fc95ee --- /dev/null +++ b/docs/framework/angular/reference/classes/QueriesObserver.md @@ -0,0 +1,325 @@ +--- +id: QueriesObserver +title: QueriesObserver +--- + +Defined in: [packages/query-core/src/queriesObserver.ts:56](https://github.com/TanStack/query/blob/main/packages/query-core/src/queriesObserver.ts#L56) + +A `QueriesObserver` watches an array of queries at once, exposing them as +a single array of `QueryObserverResult`s (or, when a `combine` option is +given, as a combined value derived from that array). It manages one +internal `QueryObserver` per query, and is the primitive that framework +adapters (e.g. `useQueries`) build their hooks on top of. + +## Example + +```ts +const observer = new QueriesObserver(queryClient, [ + { queryKey: ['post', 1], queryFn: fetchPost }, + { queryKey: ['post', 2], queryFn: fetchPost }, +]) + +const unsubscribe = observer.subscribe((result) => { + console.log(result) +}) +``` + +## Extends + +- `Subscribable`\<`QueriesObserverListener`\> + +## Type Parameters + +### TCombinedResult + +`TCombinedResult` = [`QueryObserverResult`](../type-aliases/QueryObserverResult.md)[] + +## Constructors + +### Constructor + +```ts +new QueriesObserver( + client, + queries, +options?): QueriesObserver; +``` + +Defined in: [packages/query-core/src/queriesObserver.ts:70](https://github.com/TanStack/query/blob/main/packages/query-core/src/queriesObserver.ts#L70) + +#### Parameters + +##### client + +[`QueryClient`](QueryClient.md) + +##### queries + +[`QueryObserverOptions`](../interfaces/QueryObserverOptions.md)\<`any`, `any`, `any`, `any`, `any`, `never`\>[] + +##### options? + +[`QueriesObserverOptions`](../interfaces/QueriesObserverOptions.md)\<`TCombinedResult`\> + +#### Returns + +`QueriesObserver`\<`TCombinedResult`\> + +#### Overrides + +```ts +Subscribable.constructor +``` + +## Properties + +### listeners + +```ts +protected listeners: Set; +``` + +Defined in: [packages/query-core/src/subscribable.ts:2](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L2) + +#### Inherited from + +```ts +Subscribable.listeners +``` + +## Methods + +### destroy() + +```ts +destroy(): void; +``` + +Defined in: [packages/query-core/src/queriesObserver.ts:106](https://github.com/TanStack/query/blob/main/packages/query-core/src/queriesObserver.ts#L106) + +Stops observing all queries: clears all listeners and destroys every +underlying `QueryObserver` this observer manages. + +#### Returns + +`void` + +*** + +### getCurrentResult() + +```ts +getCurrentResult(): QueryObserverResult[]; +``` + +Defined in: [packages/query-core/src/queriesObserver.ts:210](https://github.com/TanStack/query/blob/main/packages/query-core/src/queriesObserver.ts#L210) + +Returns the most recently computed array of `QueryObserverResult`s, one +per observed query, in the same order as the queries passed to the +constructor or `setQueries`. + +#### Returns + +[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)[] + +#### Example + +```ts +const results = observer.getCurrentResult() +const data = results.map((result) => result.data) +``` + +*** + +### getObservers() + +```ts +getObservers(): QueryObserver[]; +``` + +Defined in: [packages/query-core/src/queriesObserver.ts:227](https://github.com/TanStack/query/blob/main/packages/query-core/src/queriesObserver.ts#L227) + +Returns the underlying `QueryObserver` instances this observer manages, +in the same order as the queries passed to the constructor or +`setQueries`. + +#### Returns + +[`QueryObserver`](QueryObserver.md)\<`unknown`, `Error`, `unknown`, `unknown`, readonly `unknown`[]\>[] + +*** + +### getOptimisticResult() + +```ts +getOptimisticResult(queries, combine): [QueryObserverResult[], (r?) => TCombinedResult, () => QueryObserverResult[]]; +``` + +Defined in: [packages/query-core/src/queriesObserver.ts:238](https://github.com/TanStack/query/blob/main/packages/query-core/src/queriesObserver.ts#L238) + +The `QueriesObserver` counterpart of [QueryObserver#getOptimisticResult](QueryObserver.md#getoptimisticresult) — computes +the result for the given (already-defaulted) queries right now, synchronously. Called by +framework adapters (e.g. `useQueries`) ahead of subscribing, returning a tuple of the raw +per-query results, a function to compute the combined result from them, and a function to +wrap the results for property-access tracking. + +#### Parameters + +##### queries + +[`QueryObserverOptions`](../interfaces/QueryObserverOptions.md)\<`unknown`, `Error`, `unknown`, `unknown`, readonly `unknown`[], `never`\>[] + +##### combine + +`CombineFn`\<`TCombinedResult`\> | `undefined` + +#### Returns + +\[[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)[], (`r?`) => `TCombinedResult`, () => [`QueryObserverResult`](../type-aliases/QueryObserverResult.md)[]\] + +*** + +### getQueries() + +```ts +getQueries(): Query[]; +``` + +Defined in: [packages/query-core/src/queriesObserver.ts:218](https://github.com/TanStack/query/blob/main/packages/query-core/src/queriesObserver.ts#L218) + +Returns the underlying `Query` instances currently being observed, in +the same order as the queries passed to the constructor or `setQueries`. + +#### Returns + +[`Query`](Query.md)\<`unknown`, `Error`, `unknown`, readonly `unknown`[]\>[] + +*** + +### hasListeners() + +```ts +hasListeners(): boolean; +``` + +Defined in: [packages/query-core/src/subscribable.ts:19](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L19) + +#### Returns + +`boolean` + +#### Inherited from + +```ts +Subscribable.hasListeners +``` + +*** + +### onSubscribe() + +```ts +protected onSubscribe(): void; +``` + +Defined in: [packages/query-core/src/queriesObserver.ts:86](https://github.com/TanStack/query/blob/main/packages/query-core/src/queriesObserver.ts#L86) + +#### Returns + +`void` + +#### Overrides + +```ts +Subscribable.onSubscribe +``` + +*** + +### onUnsubscribe() + +```ts +protected onUnsubscribe(): void; +``` + +Defined in: [packages/query-core/src/queriesObserver.ts:96](https://github.com/TanStack/query/blob/main/packages/query-core/src/queriesObserver.ts#L96) + +#### Returns + +`void` + +#### Overrides + +```ts +Subscribable.onUnsubscribe +``` + +*** + +### setQueries() + +```ts +setQueries(queries, options?): void; +``` + +Defined in: [packages/query-core/src/queriesObserver.ts:127](https://github.com/TanStack/query/blob/main/packages/query-core/src/queriesObserver.ts#L127) + +Replaces the set of queries being observed. Existing `QueryObserver`s +are reused for queries that match an already-observed query hash; +observers for queries that are no longer present are destroyed, and new +observers are created and subscribed to for newly added queries. + +#### Parameters + +##### queries + +[`QueryObserverOptions`](../interfaces/QueryObserverOptions.md)\<`unknown`, `Error`, `unknown`, `unknown`, readonly `unknown`[], `never`\>[] + +##### options? + +[`QueriesObserverOptions`](../interfaces/QueriesObserverOptions.md)\<`TCombinedResult`\> + +#### Returns + +`void` + +#### Example + +```ts +observer.setQueries([ + { queryKey: ['post', 1], queryFn: fetchPost }, + { queryKey: ['post', 3], queryFn: fetchPost }, +]) +``` + +*** + +### subscribe() + +```ts +subscribe(listener): () => void; +``` + +Defined in: [packages/query-core/src/subscribable.ts:8](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L8) + +#### Parameters + +##### listener + +`QueriesObserverListener` + +#### Returns + +```ts +(): void; +``` + +##### Returns + +`void` + +#### Inherited from + +```ts +Subscribable.subscribe +``` diff --git a/docs/framework/angular/reference/classes/Query.md b/docs/framework/angular/reference/classes/Query.md new file mode 100644 index 00000000000..bc15461e541 --- /dev/null +++ b/docs/framework/angular/reference/classes/Query.md @@ -0,0 +1,585 @@ +--- +id: Query +title: Query +--- + +Defined in: [packages/query-core/src/query.ts:225](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L225) + +Represents a single cached query. A `Query` holds the query's key, options, +state (data/error/status), and the observers currently subscribed to it. + +Instances are created and managed internally by `QueryCache`; application +code typically interacts with queries indirectly through `QueryClient` or +a framework hook like `useQuery`. Direct access to a `Query` instance is +possible via `queryCache.find()`/`findAll()` for inspecting cache state. + +## Example + +```ts +const queryCache = queryClient.getQueryCache() +const query = queryCache.find({ queryKey: ['posts'] }) + +if (query) { + console.log(query.state.dataUpdatedAt) +} +``` + +## Extends + +- `Removable` + +## Type Parameters + +### TQueryFnData + +`TQueryFnData` = `unknown` + +### TError + +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) + +### TData + +`TData` = `TQueryFnData` + +### TQueryKey + +`TQueryKey` *extends* [`QueryKey`](../type-aliases/QueryKey.md) = [`QueryKey`](../type-aliases/QueryKey.md) + +## Constructors + +### Constructor + +```ts +new Query(config): Query; +``` + +Defined in: [packages/query-core/src/query.ts:246](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L246) + +#### Parameters + +##### config + +`QueryConfig`\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`\> + +#### Returns + +`Query`\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`\> + +#### Overrides + +```ts +Removable.constructor +``` + +## Properties + +### gcTime + +```ts +gcTime: number; +``` + +Defined in: [packages/query-core/src/removable.ts:7](https://github.com/TanStack/query/blob/main/packages/query-core/src/removable.ts#L7) + +#### Inherited from + +```ts +Removable.gcTime +``` + +*** + +### observers + +```ts +observers: QueryObserver[]; +``` + +Defined in: [packages/query-core/src/query.ts:242](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L242) + +*** + +### options + +```ts +options: QueryOptions; +``` + +Defined in: [packages/query-core/src/query.ts:233](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L233) + +*** + +### queryHash + +```ts +queryHash: string; +``` + +Defined in: [packages/query-core/src/query.ts:232](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L232) + +*** + +### queryKey + +```ts +queryKey: TQueryKey; +``` + +Defined in: [packages/query-core/src/query.ts:231](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L231) + +*** + +### state + +```ts +state: QueryState; +``` + +Defined in: [packages/query-core/src/query.ts:234](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L234) + +## Accessors + +### meta + +#### Get Signature + +```ts +get meta(): Record | undefined; +``` + +Defined in: [packages/query-core/src/query.ts:264](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L264) + +The `meta` object passed in the query's options, if any. + +##### Returns + +`Record`\<`string`, `unknown`\> \| `undefined` + +*** + +### promise + +#### Get Signature + +```ts +get promise(): Promise | undefined; +``` + +Defined in: [packages/query-core/src/query.ts:277](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L277) + +The promise for the currently in-flight fetch, if the query is fetching. +`undefined` when the query is not fetching. + +##### Returns + +`Promise`\<`TData`\> \| `undefined` + +## Methods + +### cancel() + +```ts +cancel(options?): Promise; +``` + +Defined in: [packages/query-core/src/query.ts:348](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L348) + +Cancels the query's currently in-flight fetch, if any. +- Returns a promise that resolves once the cancellation has settled. +- If no fetch is in progress, resolves immediately. + +#### Parameters + +##### options? + +[`CancelOptions`](../interfaces/CancelOptions.md) + +#### Returns + +`Promise`\<`void`\> + +#### Example + +```ts +await query.cancel() +``` + +*** + +### clearGcTimeout() + +```ts +protected clearGcTimeout(): void; +``` + +Defined in: [packages/query-core/src/removable.ts:32](https://github.com/TanStack/query/blob/main/packages/query-core/src/removable.ts#L32) + +#### Returns + +`void` + +#### Inherited from + +```ts +Removable.clearGcTimeout +``` + +*** + +### destroy() + +```ts +destroy(): void; +``` + +Defined in: [packages/query-core/src/query.ts:361](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L361) + +Clears the query's garbage collection timeout and silently cancels any +in-flight fetch. Called by `QueryCache` when the query is removed from +the cache. + +#### Returns + +`void` + +#### See + +[Query#cancel](#cancel) + +#### Overrides + +```ts +Removable.destroy +``` + +*** + +### fetch() + +```ts +fetch(options?, fetchOptions?): Promise; +``` + +Defined in: [packages/query-core/src/query.ts:590](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L590) + +Fetches the query, i.e. runs its `queryFn` (through any configured +retryer/behavior) and updates the query's state with the result. +- If a fetch is already in flight, returns its promise instead of + starting a new one, unless `fetchOptions.cancelRefetch` is set and the + query already has data, in which case the current fetch is silently + cancelled first. +- If `options` is passed, it replaces the query's current options + before fetching. + +#### Parameters + +##### options? + +[`QueryOptions`](../interfaces/QueryOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`, `never`\> + +##### fetchOptions? + +`FetchOptions`\<`TQueryFnData`\> + +#### Returns + +`Promise`\<`TData`\> + +*** + +### getObserversCount() + +```ts +getObserversCount(): number; +``` + +Defined in: [packages/query-core/src/query.ts:560](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L560) + +Returns the number of observers currently subscribed to this query. + +#### Returns + +`number` + +#### Example + +```ts +if (query.getObserversCount() === 0) { + // no component is currently watching this query +} +``` + +*** + +### invalidate() + +```ts +invalidate(): void; +``` + +Defined in: [packages/query-core/src/query.ts:574](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L574) + +Marks the query as invalidated, unless it is already invalidated. This +updates `state.isInvalidated` and notifies observers, but does not by +itself trigger a refetch. + +#### Returns + +`void` + +#### Example + +```ts +query.invalidate() +``` + +*** + +### isActive() + +```ts +isActive(): boolean; +``` + +Defined in: [packages/query-core/src/query.ts:386](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L386) + +Returns `true` if the query has at least one observer for which `enabled` +does not resolve to `false`. + +#### Returns + +`boolean` + +*** + +### isDisabled() + +```ts +isDisabled(): boolean; +``` + +Defined in: [packages/query-core/src/query.ts:400](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L400) + +Returns `true` if the query is disabled, meaning it will not fetch +automatically. +- If the query has observers, it is disabled when none of them are active + (see `isActive`). +- If the query has no observers, it is disabled when its `queryFn` is + `skipToken` or it has never been fetched. + +#### Returns + +`boolean` + +*** + +### isFetched() + +```ts +isFetched(): boolean; +``` + +Defined in: [packages/query-core/src/query.ts:412](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L412) + +Returns `true` if the query has been fetched, i.e. it has resolved with +either data or an error at least once. + +#### Returns + +`boolean` + +*** + +### isStale() + +```ts +isStale(): boolean; +``` + +Defined in: [packages/query-core/src/query.ts:447](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L447) + +Returns `true` if the query is stale. +- If the query has observers, defers to whether any observer's current + result reports `isStale` (which accounts for each observer's own + `staleTime` and `enabled` state). +- If the query has no observers, it is considered stale when it has no + data or has been invalidated. + +#### Returns + +`boolean` + +#### See + +[Query#isStaleByTime](#isstalebytime) + +#### Example + +```ts +if (query.isStale()) { + // refetch or otherwise treat the cached data as outdated +} +``` + +*** + +### isStaleByTime() + +```ts +isStaleByTime(staleTime): boolean; +``` + +Defined in: [packages/query-core/src/query.ts:473](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L473) + +Returns `true` if the query's data is stale relative to the given +`staleTime` (defaults to `0`). +- A query with no data is always stale. +- `staleTime: 'static'` is never stale. +- An invalidated query is always stale. +- Otherwise, staleness is based on elapsed time since `dataUpdatedAt`. + +#### Parameters + +##### staleTime + +[`StaleTime`](../type-aliases/StaleTime.md) = `0` + +#### Returns + +`boolean` + +#### See + +[Query#isStale](#isstale) + +#### Example + +```ts +const isStale = query.isStaleByTime(1000 * 60) +``` + +*** + +### isStatic() + +```ts +isStatic(): boolean; +``` + +Defined in: [packages/query-core/src/query.ts:420](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L420) + +Returns `true` if the query has at least one observer configured with +`staleTime: 'static'`, meaning it is treated as never stale. + +#### Returns + +`boolean` + +*** + +### optionalRemove() + +```ts +protected optionalRemove(): void; +``` + +Defined in: [packages/query-core/src/query.ts:305](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L305) + +#### Returns + +`void` + +#### Overrides + +```ts +Removable.optionalRemove +``` + +*** + +### reset() + +```ts +reset(): void; +``` + +Defined in: [packages/query-core/src/query.ts:377](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L377) + +Resets the query back to its initial state (the state it had when it was +first created, e.g. any `initialData`), destroying it first to cancel any +in-flight fetch. + +#### Returns + +`void` + +*** + +### scheduleGc() + +```ts +protected scheduleGc(): void; +``` + +Defined in: [packages/query-core/src/removable.ts:14](https://github.com/TanStack/query/blob/main/packages/query-core/src/removable.ts#L14) + +#### Returns + +`void` + +#### Inherited from + +```ts +Removable.scheduleGc +``` + +*** + +### setState() + +```ts +setState(state): void; +``` + +Defined in: [packages/query-core/src/query.ts:334](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L334) + +Merges the given partial state directly into this query's state, notifying observers. Used +by persistence and broadcast plugins to restore a state snapshot, and by devtools to let a +user manually trigger a loading/error state or edit the cached data. + +#### Parameters + +##### state + +`Partial`\<[`QueryState`](../interfaces/QueryState.md)\<`TData`, `TError`\>\> + +#### Returns + +`void` + +*** + +### updateGcTime() + +```ts +protected updateGcTime(newGcTime): void; +``` + +Defined in: [packages/query-core/src/removable.ts:24](https://github.com/TanStack/query/blob/main/packages/query-core/src/removable.ts#L24) + +#### Parameters + +##### newGcTime + +`number` | `undefined` + +#### Returns + +`void` + +#### Inherited from + +```ts +Removable.updateGcTime +``` diff --git a/docs/framework/angular/reference/classes/QueryCache.md b/docs/framework/angular/reference/classes/QueryCache.md new file mode 100644 index 00000000000..b7a577b5e54 --- /dev/null +++ b/docs/framework/angular/reference/classes/QueryCache.md @@ -0,0 +1,471 @@ +--- +id: QueryCache +title: QueryCache +--- + +Defined in: [packages/query-core/src/queryCache.ts:123](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryCache.ts#L123) + +The `QueryCache` is the storage mechanism for TanStack Query. It stores all the data, meta +information, and state of the queries it contains. + +Normally, you will not interact with the `QueryCache` directly and instead use a `QueryClient` +for a specific cache. You can subscribe to it (inherited from `Subscribable`) to be informed of +safe/known updates to the cache, such as queries being added, removed, or updated — updates made +outside of the cache's own tracked mechanisms (e.g. mutating a query's state object directly) do +not notify subscribers. + +## Example + +```ts +const unsubscribe = queryCache.subscribe((event) => { + console.log(event.type, event.query) +}) +``` + +## Extends + +- `Subscribable`\<`QueryCacheListener`\> + +## Constructors + +### Constructor + +```ts +new QueryCache(config): QueryCache; +``` + +Defined in: [packages/query-core/src/queryCache.ts:126](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryCache.ts#L126) + +#### Parameters + +##### config + +[`QueryCacheConfig`](../interfaces/QueryCacheConfig.md) = `{}` + +#### Returns + +`QueryCache` + +#### Overrides + +```ts +Subscribable.constructor +``` + +## Properties + +### config + +```ts +config: QueryCacheConfig = {}; +``` + +Defined in: [packages/query-core/src/queryCache.ts:126](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryCache.ts#L126) + +*** + +### listeners + +```ts +protected listeners: Set; +``` + +Defined in: [packages/query-core/src/subscribable.ts:2](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L2) + +#### Inherited from + +```ts +Subscribable.listeners +``` + +## Methods + +### build() + +```ts +build( + client, + options, +state?): Query; +``` + +Defined in: [packages/query-core/src/queryCache.ts:147](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryCache.ts#L147) + +Returns the existing `Query` instance for the given options' `queryKey`/`queryHash`, or +builds and adds a new one to the cache if none exists yet. Used by framework adapters and +plugins (e.g. broadcast/persistence) that need to get-or-create a `Query` directly, bypassing +the reactive `QueryObserver` machinery. + +#### Type Parameters + +##### TQueryFnData + +`TQueryFnData` = `unknown` + +##### TError + +`TError` = `Error` + +##### TData + +`TData` = `TQueryFnData` + +##### TQueryKey + +`TQueryKey` *extends* readonly `unknown`[] = readonly `unknown`[] + +#### Parameters + +##### client + +[`QueryClient`](QueryClient.md) + +##### options + +[`WithRequired`](../type-aliases/WithRequired.md)\<[`QueryOptions`](../interfaces/QueryOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`, `never`\>, `"queryKey"`\> + +##### state? + +[`QueryState`](../interfaces/QueryState.md)\<`TData`, `TError`\> + +#### Returns + +[`Query`](Query.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`\> + +#### Example + +```ts +const queryCache = queryClient.getQueryCache() + +const query = queryCache.build(queryClient, { + queryKey: ['posts'], + queryFn: fetchPosts, +}) +``` + +*** + +### clear() + +```ts +clear(): void; +``` + +Defined in: [packages/query-core/src/queryCache.ts:232](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryCache.ts#L232) + +Removes all queries from the cache. + +#### Returns + +`void` + +#### Example + +```ts +const queryCache = queryClient.getQueryCache() + +queryCache.clear() +``` + +*** + +### find() + +```ts +find(filters): + | Query + | undefined; +``` + +Defined in: [packages/query-core/src/queryCache.ts:299](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryCache.ts#L299) + +A slightly more advanced method that can be used to get an existing query instance from the +cache. This instance not only contains all the state for the query, but all of the instances, +and underlying guts of the query as well. If the query does not exist, `undefined` is +returned. + +This is not typically needed for most applications, but can come in handy when needing more +information about a query in rare scenarios (e.g. looking at `query.state.dataUpdatedAt` to +decide whether a query is fresh enough to be used as an initial value). + +#### Type Parameters + +##### TQueryFnData + +`TQueryFnData` = `unknown` + +##### TError + +`TError` = `Error` + +##### TData + +`TData` = `TQueryFnData` + +#### Parameters + +##### filters + +[`WithRequired`](../type-aliases/WithRequired.md)\<[`QueryFilters`](../interfaces/QueryFilters.md)\, `"queryKey"`\> + +#### Returns + + \| [`Query`](Query.md)\<`TQueryFnData`, `TError`, `TData`, readonly `unknown`[]\> + \| `undefined` + +#### See + +[QueryCache#findAll](#findall) + +#### Example + +```ts +const queryCache = queryClient.getQueryCache() + +const query = queryCache.find({ queryKey: ['posts'] }) +``` + +*** + +### findAll() + +```ts +findAll(filters): Query[]; +``` + +Defined in: [packages/query-core/src/queryCache.ts:324](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryCache.ts#L324) + +An even more advanced method that can be used to get existing query instances from the cache +that partially match a query key. If no queries match, an empty array is returned. + +This is not typically needed for most applications, but can come in handy when needing more +information about queries in rare scenarios. + +#### Parameters + +##### filters + +[`QueryFilters`](../interfaces/QueryFilters.md)\<`any`\> = `{}` + +#### Returns + +[`Query`](Query.md)\<`unknown`, `Error`, `unknown`, readonly `unknown`[]\>[] + +#### See + +[QueryCache#find](#find) + +#### Example + +```ts +const queryCache = queryClient.getQueryCache() + +const queries = queryCache.findAll({ queryKey: ['posts'] }) +``` + +*** + +### get() + +```ts +get(queryHash): + | Query + | undefined; +``` + +Defined in: [packages/query-core/src/queryCache.ts:254](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryCache.ts#L254) + +Returns the `Query` instance stored under the given `queryHash`, or `undefined` if none +exists. Unlike [QueryCache#find](#find), this looks up by the already-computed hash rather +than by `QueryFilters`. Used by plugins (e.g. broadcast/hydration) that already have a hash +to look up directly. + +#### Type Parameters + +##### TQueryFnData + +`TQueryFnData` = `unknown` + +##### TError + +`TError` = `Error` + +##### TData + +`TData` = `TQueryFnData` + +##### TQueryKey + +`TQueryKey` *extends* readonly `unknown`[] = readonly `unknown`[] + +#### Parameters + +##### queryHash + +`string` + +#### Returns + + \| [`Query`](Query.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`\> + \| `undefined` + +#### Example + +```ts +const queryCache = queryClient.getQueryCache() +const queryHash = hashKey(['posts']) + +const query = queryCache.get(queryHash) +``` + +*** + +### getAll() + +```ts +getAll(): Query[]; +``` + +Defined in: [packages/query-core/src/queryCache.ts:277](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryCache.ts#L277) + +Returns all queries within the cache. + +#### Returns + +[`Query`](Query.md)\<`unknown`, `Error`, `unknown`, readonly `unknown`[]\>[] + +#### Example + +```ts +const queryCache = queryClient.getQueryCache() + +const queries = queryCache.getAll() +``` + +*** + +### hasListeners() + +```ts +hasListeners(): boolean; +``` + +Defined in: [packages/query-core/src/subscribable.ts:19](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L19) + +#### Returns + +`boolean` + +#### Inherited from + +```ts +Subscribable.hasListeners +``` + +*** + +### onSubscribe() + +```ts +protected onSubscribe(): void; +``` + +Defined in: [packages/query-core/src/subscribable.ts:23](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L23) + +#### Returns + +`void` + +#### Inherited from + +```ts +Subscribable.onSubscribe +``` + +*** + +### onUnsubscribe() + +```ts +protected onUnsubscribe(): void; +``` + +Defined in: [packages/query-core/src/subscribable.ts:27](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L27) + +#### Returns + +`void` + +#### Inherited from + +```ts +Subscribable.onUnsubscribe +``` + +*** + +### remove() + +```ts +remove(query): void; +``` + +Defined in: [packages/query-core/src/queryCache.ts:208](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryCache.ts#L208) + +Destroys the given `Query` and removes it from the cache, notifying subscribers with a +`'removed'` event. A no-op if the query is no longer the one currently stored under its hash +(e.g. it was already replaced). Used by plugins (e.g. the broadcast client) that mirror +removals across `QueryCache` instances. + +#### Parameters + +##### query + +[`Query`](Query.md)\<`any`, `any`, `any`, `any`\> + +#### Returns + +`void` + +#### Example + +```ts +const queryCache = queryClient.getQueryCache() +const query = queryCache.find({ queryKey: ['posts'] }) + +if (query) { + queryCache.remove(query) +} +``` + +*** + +### subscribe() + +```ts +subscribe(listener): () => void; +``` + +Defined in: [packages/query-core/src/subscribable.ts:8](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L8) + +#### Parameters + +##### listener + +`QueryCacheListener` + +#### Returns + +```ts +(): void; +``` + +##### Returns + +`void` + +#### Inherited from + +```ts +Subscribable.subscribe +``` diff --git a/docs/framework/angular/reference/classes/QueryClient.md b/docs/framework/angular/reference/classes/QueryClient.md new file mode 100644 index 00000000000..c7d1a034545 --- /dev/null +++ b/docs/framework/angular/reference/classes/QueryClient.md @@ -0,0 +1,1466 @@ +--- +id: QueryClient +title: QueryClient +--- + +Defined in: [packages/query-core/src/queryClient.ts:79](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L79) + +`QueryClient` is used to interact with a cache of queries and mutations. It owns a +`QueryCache` and a `MutationCache` (creating default ones if none are passed in) and holds +the default options that are applied to queries and mutations created through it. + +## Example + +```ts +const queryClient = new QueryClient({ + defaultOptions: { + queries: { + staleTime: Infinity, + }, + }, +}) + +await queryClient.query({ queryKey: ['posts'], queryFn: fetchPosts }) +``` + +## Constructors + +### Constructor + +```ts +new QueryClient(config): QueryClient; +``` + +Defined in: [packages/query-core/src/queryClient.ts:89](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L89) + +#### Parameters + +##### config + +[`QueryClientConfig`](../interfaces/QueryClientConfig.md) = `{}` + +#### Returns + +`QueryClient` + +## Methods + +### cancelQueries() + +```ts +cancelQueries(filters?, cancelOptions?): Promise; +``` + +Defined in: [packages/query-core/src/queryClient.ts:432](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L432) + +Cancels outgoing fetches for queries matching the given filters. Most useful when performing +optimistic updates, since any outgoing refetch that resolves afterwards would otherwise +overwrite the optimistic update. By default (`revert: true`), a cancelled query's data is +reverted to its state before the outgoing fetch started. + +The returned promise never rejects, even if individual cancellations fail. + +#### Type Parameters + +##### TTaggedQueryKey + +`TTaggedQueryKey` *extends* readonly `unknown`[] = readonly `unknown`[] + +#### Parameters + +##### filters? + +[`QueryFilters`](../interfaces/QueryFilters.md)\<`TTaggedQueryKey`\> + +##### cancelOptions? + +[`CancelOptions`](../interfaces/CancelOptions.md) = `{}` + +#### Returns + +`Promise`\<`void`\> + +#### Example + +```ts +await queryClient.cancelQueries({ queryKey: ['posts'], exact: true }) +``` + +*** + +### clear() + +```ts +clear(): void; +``` + +Defined in: [packages/query-core/src/queryClient.ts:1083](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L1083) + +Clears both the query cache and the mutation cache this client is connected to. + +#### Returns + +`void` + +#### Example + +```ts +import { QueryClient } from '@tanstack/query-core' + +const queryClient = new QueryClient() +queryClient.clear() +``` + +*** + +### defaultMutationOptions() + +```ts +defaultMutationOptions(options?): T; +``` + +Defined in: [packages/query-core/src/queryClient.ts:1057](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L1057) + +The mutation counterpart of [QueryClient#defaultQueryOptions](#defaultqueryoptions). Called by framework +adapters (e.g. inside `useMutation`) to merge `queryClient.setMutationDefaults` for the +given `mutationKey`, then the client's `defaultOptions.mutations`, then the caller's options +on top. A no-op if the options are already defaulted (`_defaulted: true`). + +#### Type Parameters + +##### T + +`T` *extends* [`MutationOptions`](../interfaces/MutationOptions.md)\<`any`, `any`, `any`, `any`\> + +#### Parameters + +##### options? + +`T` + +#### Returns + +`T` + +*** + +### defaultQueryOptions() + +```ts +defaultQueryOptions(options): DefaultedQueryObserverOptions; +``` + +Defined in: [packages/query-core/src/queryClient.ts:970](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L970) + +Called by framework adapters (e.g. inside `useQuery`) to resolve the options passed by the +caller into their final, defaulted form: merging `queryClient.setQueryDefaults` for the +given `queryKey`, then the client's own `defaultOptions.queries`, then the caller's options +on top. A no-op if the options are already defaulted (`_defaulted: true`). + +#### Type Parameters + +##### TQueryFnData + +`TQueryFnData` = `unknown` + +##### TError + +`TError` = `Error` + +##### TData + +`TData` = `TQueryFnData` + +##### TQueryData + +`TQueryData` = `TQueryFnData` + +##### TQueryKey + +`TQueryKey` *extends* readonly `unknown`[] = readonly `unknown`[] + +##### TPageParam + +`TPageParam` = `never` + +#### Parameters + +##### options + +[`QueryObserverOptions`](../interfaces/QueryObserverOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryData`, `TQueryKey`, `TPageParam`\> | [`DefaultedQueryObserverOptions`](../type-aliases/DefaultedQueryObserverOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryData`, `TQueryKey`\> + +#### Returns + +[`DefaultedQueryObserverOptions`](../type-aliases/DefaultedQueryObserverOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryData`, `TQueryKey`\> + +*** + +### ~~ensureInfiniteQueryData()~~ + +```ts +ensureInfiniteQueryData(options): Promise>; +``` + +Defined in: [packages/query-core/src/queryClient.ts:735](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L735) + +#### Type Parameters + +##### TQueryFnData + +`TQueryFnData` + +##### TError + +`TError` = `Error` + +##### TData + +`TData` = `TQueryFnData` + +##### TQueryKey + +`TQueryKey` *extends* readonly `unknown`[] = readonly `unknown`[] + +##### TPageParam + +`TPageParam` = `unknown` + +#### Parameters + +##### options + +[`EnsureInfiniteQueryDataOptions`](../type-aliases/EnsureInfiniteQueryDataOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`, `TPageParam`\> + +#### Returns + +`Promise`\<[`InfiniteData`](../interfaces/InfiniteData.md)\<`TData`, `TPageParam`\>\> + +#### Deprecated + +Use queryClient.infiniteQuery({ ...options, staleTime: 'static' }) instead. This method will be removed in the next major version. + +*** + +### ~~ensureQueryData()~~ + +```ts +ensureQueryData(options): Promise; +``` + +Defined in: [packages/query-core/src/queryClient.ts:197](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L197) + +#### Type Parameters + +##### TQueryFnData + +`TQueryFnData` + +##### TError + +`TError` = `Error` + +##### TData + +`TData` = `TQueryFnData` + +##### TQueryKey + +`TQueryKey` *extends* readonly `unknown`[] = readonly `unknown`[] + +#### Parameters + +##### options + +[`EnsureQueryDataOptions`](../interfaces/EnsureQueryDataOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`\> + +#### Returns + +`Promise`\<`TData`\> + +#### Deprecated + +Use queryClient.query({ ...options, staleTime: 'static' }) instead. This method will be removed in the next major version. + +*** + +### ~~fetchInfiniteQuery()~~ + +```ts +fetchInfiniteQuery(options): Promise>; +``` + +Defined in: [packages/query-core/src/queryClient.ts:692](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L692) + +#### Type Parameters + +##### TQueryFnData + +`TQueryFnData` + +##### TError + +`TError` = `Error` + +##### TData + +`TData` = `TQueryFnData` + +##### TQueryKey + +`TQueryKey` *extends* readonly `unknown`[] = readonly `unknown`[] + +##### TPageParam + +`TPageParam` = `unknown` + +#### Parameters + +##### options + +[`FetchInfiniteQueryOptions`](../type-aliases/FetchInfiniteQueryOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`, `TPageParam`\> + +#### Returns + +`Promise`\<[`InfiniteData`](../interfaces/InfiniteData.md)\<`TData`, `TPageParam`\>\> + +#### Deprecated + +Use queryClient.infiniteQuery(options) instead. This method will be removed in the next major version. + +*** + +### ~~fetchQuery()~~ + +```ts +fetchQuery(options): Promise; +``` + +Defined in: [packages/query-core/src/queryClient.ts:600](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L600) + +#### Type Parameters + +##### TQueryFnData + +`TQueryFnData` + +##### TError + +`TError` = `Error` + +##### TData + +`TData` = `TQueryFnData` + +##### TQueryKey + +`TQueryKey` *extends* readonly `unknown`[] = readonly `unknown`[] + +##### TPageParam + +`TPageParam` = `never` + +#### Parameters + +##### options + +[`FetchQueryOptions`](../interfaces/FetchQueryOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`, `TPageParam`\> + +#### Returns + +`Promise`\<`TData`\> + +#### Deprecated + +Use queryClient.query(options) instead. This method will be removed in the next major version. + +*** + +### getDefaultOptions() + +```ts +getDefaultOptions(): DefaultOptions; +``` + +Defined in: [packages/query-core/src/queryClient.ts:818](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L818) + +Returns the default options that were set when creating the client, or via +[QueryClient#setDefaultOptions](#setdefaultoptions). + +#### Returns + +[`DefaultOptions`](../interfaces/DefaultOptions.md) + +#### Example + +```ts +import { QueryClient } from '@tanstack/query-core' + +const queryClient = new QueryClient() +const defaultOptions = queryClient.getDefaultOptions() +``` + +*** + +### getMutationCache() + +```ts +getMutationCache(): MutationCache; +``` + +Defined in: [packages/query-core/src/queryClient.ts:802](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L802) + +Returns the mutation cache this client is connected to. + +#### Returns + +[`MutationCache`](MutationCache.md) + +#### Example + +```ts +import { QueryClient } from '@tanstack/query-core' + +const queryClient = new QueryClient() +const mutationCache = queryClient.getMutationCache() +const mutations = mutationCache.findAll({ status: 'pending' }) +``` + +*** + +### getMutationDefaults() + +```ts +getMutationDefaults(mutationKey): OmitKeyof, "mutationKey">; +``` + +Defined in: [packages/query-core/src/queryClient.ts:945](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L945) + +Returns the default options registered for mutations whose mutation key partially matches +the given `mutationKey`, via [QueryClient#setMutationDefaults](#setmutationdefaults). If multiple registered +defaults match, they are merged together in registration order. + +#### Parameters + +##### mutationKey + +readonly `unknown`[] + +#### Returns + +[`OmitKeyof`](../type-aliases/OmitKeyof.md)\<[`MutationObserverOptions`](../interfaces/MutationObserverOptions.md)\<`any`, `any`, `any`, `any`\>, `"mutationKey"`\> + +#### Example + +```ts +const defaultOptions = queryClient.getMutationDefaults(['addPost']) +``` + +*** + +### getQueriesData() + +```ts +getQueriesData(filters): [readonly unknown[], TQueryFnData | undefined][]; +``` + +Defined in: [packages/query-core/src/queryClient.ts:240](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L240) + +Imperative (non-reactive) way to retrieve the cached data of multiple queries at once. +Only queries matching the given filters are returned; if none match, an empty array is +returned. + +Because the matched queries can hold data of different shapes (e.g. a broad filter can match +queries with unrelated data types), the `TQueryFnData` generic defaults to `unknown` rather +than being inferred. Passing a more specific type is a convenience for call sites that know +every matched query holds the same shape — it is not checked against the actual cache +contents. + +#### Type Parameters + +##### TQueryFnData + +`TQueryFnData` = `unknown` + +##### TQueryFilters + +`TQueryFilters` *extends* [`QueryFilters`](../interfaces/QueryFilters.md)\<`any`\> = [`QueryFilters`](../interfaces/QueryFilters.md)\ + +#### Parameters + +##### filters + +`TQueryFilters` + +#### Returns + +\[readonly `unknown`[], `TQueryFnData` \| `undefined`\][] + +#### See + +[QueryClient#getQueryData](#getquerydata) + +#### Example + +```ts +const data = queryClient.getQueriesData({ queryKey: ['posts'] }) +``` + +*** + +### getQueryCache() + +```ts +getQueryCache(): QueryCache; +``` + +Defined in: [packages/query-core/src/queryClient.ts:786](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L786) + +Returns the query cache this client is connected to. + +#### Returns + +[`QueryCache`](QueryCache.md) + +#### Example + +```ts +import { QueryClient } from '@tanstack/query-core' + +const queryClient = new QueryClient() +const queryCache = queryClient.getQueryCache() +const queries = queryCache.findAll({ queryKey: ['posts'] }) +``` + +*** + +### getQueryData() + +```ts +getQueryData(queryKey): TInferredQueryFnData | undefined; +``` + +Defined in: [packages/query-core/src/queryClient.ts:183](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L183) + +Imperative (non-reactive) way to retrieve data for a QueryKey. +Should only be used in callbacks or functions where reading the latest data is necessary, e.g. for optimistic updates. + +Hint: Do not use this function inside a component, because it won't receive updates. +Use `useQuery` to create a `QueryObserver` that subscribes to changes. + +#### Type Parameters + +##### TQueryFnData + +`TQueryFnData` = `unknown` + +##### TTaggedQueryKey + +`TTaggedQueryKey` *extends* readonly `unknown`[] = readonly `unknown`[] + +##### TInferredQueryFnData + +`TInferredQueryFnData` = [`InferDataFromTag`](../type-aliases/InferDataFromTag.md)\<`TQueryFnData`, `TTaggedQueryKey`\> + +#### Parameters + +##### queryKey + +`TTaggedQueryKey` + +#### Returns + +`TInferredQueryFnData` \| `undefined` + +#### See + +[QueryClient#getQueriesData](#getqueriesdata) + +*** + +### getQueryDefaults() + +```ts +getQueryDefaults(queryKey): OmitKeyof, "queryKey">; +``` + +Defined in: [packages/query-core/src/queryClient.ts:888](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L888) + +Returns the default options registered for queries whose query key partially matches the +given `queryKey`, via [QueryClient#setQueryDefaults](#setquerydefaults). If multiple registered defaults +match, they are merged together in registration order. + +#### Parameters + +##### queryKey + +readonly `unknown`[] + +#### Returns + +[`OmitKeyof`](../type-aliases/OmitKeyof.md)\<[`QueryObserverOptions`](../interfaces/QueryObserverOptions.md)\<`any`, `any`, `any`, `any`, `any`\>, `"queryKey"`\> + +#### Example + +```ts +const defaultOptions = queryClient.getQueryDefaults(['posts']) +``` + +*** + +### getQueryState() + +```ts +getQueryState(queryKey): + | QueryState + | undefined; +``` + +Defined in: [packages/query-core/src/queryClient.ts:350](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L350) + +Imperative (non-reactive) way to retrieve an existing query's state. If the query does not +exist, `undefined` is returned. + +#### Type Parameters + +##### TQueryFnData + +`TQueryFnData` = `unknown` + +##### TError + +`TError` = `Error` + +##### TTaggedQueryKey + +`TTaggedQueryKey` *extends* readonly `unknown`[] = readonly `unknown`[] + +##### TInferredQueryFnData + +`TInferredQueryFnData` = [`InferDataFromTag`](../type-aliases/InferDataFromTag.md)\<`TQueryFnData`, `TTaggedQueryKey`\> + +##### TInferredError + +`TInferredError` = [`InferErrorFromTag`](../type-aliases/InferErrorFromTag.md)\<`TError`, `TTaggedQueryKey`\> + +#### Parameters + +##### queryKey + +`TTaggedQueryKey` + +#### Returns + + \| [`QueryState`](../interfaces/QueryState.md)\<`TInferredQueryFnData`, `TInferredError`\> + \| `undefined` + +#### Example + +```ts +const state = queryClient.getQueryState(['posts']) +console.log(state?.dataUpdatedAt) +``` + +*** + +### infiniteQuery() + +```ts +infiniteQuery(options): Promise[] ? InfiniteData : TData>; +``` + +Defined in: [packages/query-core/src/queryClient.ts:666](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L666) + +Asynchronous method to fetch and cache an infinite query, resolving with an +[InfiniteData](../interfaces/InfiniteData.md) object or throwing with the error. + +Behaves like [QueryClient#query](#query), accepting the same options (minus +`initialPageParam`), plus the required `initialPageParam`, and an optional `pages` / +`getNextPageParam` pair used to refetch a fixed number of pages from the start. + +This method replaces the deprecated `fetchInfiniteQuery`, and — combined with +`{ staleTime: 'static' }` — the deprecated `ensureInfiniteQueryData`. + +#### Type Parameters + +##### TQueryFnData + +`TQueryFnData` + +##### TError + +`TError` = `Error` + +##### TData + +`TData` = [`InfiniteData`](../interfaces/InfiniteData.md)\<`TQueryFnData`, `unknown`\> + +##### TQueryKey + +`TQueryKey` *extends* readonly `unknown`[] = readonly `unknown`[] + +##### TPageParam + +`TPageParam` = `unknown` + +#### Parameters + +##### options + +[`InfiniteQueryExecuteOptions`](../type-aliases/InfiniteQueryExecuteOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`, `TPageParam`\> + +#### Returns + +`Promise`\<`TData`[] *extends* [`InfiniteData`](../interfaces/InfiniteData.md)\<`TQueryFnData`, `unknown`\>[] ? [`InfiniteData`](../interfaces/InfiniteData.md)\<`TQueryFnData`, `TPageParam`\> : `TData`\> + +#### Example + +```ts +try { + const data = await queryClient.infiniteQuery({ queryKey, queryFn, initialPageParam: 0 }) + console.log(data.pages) +} catch (error) { + console.log(error) +} +``` + +*** + +### invalidateQueries() + +```ts +invalidateQueries(filters?, options?): Promise; +``` + +Defined in: [packages/query-core/src/queryClient.ts:460](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L460) + +Marks queries matching the given filters as invalidated. Unlike +[QueryClient#removeQueries](#removequeries), invalidated queries stay in the cache. + +Unless `filters.refetchType` is `'none'`, matching queries are then refetched via +[QueryClient#refetchQueries](#refetchqueries), using `filters.refetchType` if set, otherwise +`filters.type`, otherwise `'active'`. + +#### Type Parameters + +##### TTaggedQueryKey + +`TTaggedQueryKey` *extends* readonly `unknown`[] = readonly `unknown`[] + +#### Parameters + +##### filters? + +[`InvalidateQueryFilters`](../interfaces/InvalidateQueryFilters.md)\<`TTaggedQueryKey`\> + +##### options? + +[`InvalidateOptions`](../interfaces/InvalidateOptions.md) = `{}` + +#### Returns + +`Promise`\<`void`\> + +#### Example + +```ts +await queryClient.invalidateQueries({ queryKey: ['posts'], refetchType: 'active' }) +``` + +*** + +### isFetching() + +```ts +isFetching(filters?): number; +``` + +Defined in: [packages/query-core/src/queryClient.ts:150](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L150) + +Returns the number of queries in the cache that are currently fetching, optionally +matching a set of filters. This includes background-fetching, loading new pages, and +loading more infinite query results. + +#### Type Parameters + +##### TQueryFilters + +`TQueryFilters` *extends* [`QueryFilters`](../interfaces/QueryFilters.md)\<`any`\> = [`QueryFilters`](../interfaces/QueryFilters.md)\ + +#### Parameters + +##### filters? + +`TQueryFilters` + +#### Returns + +`number` + +#### Example + +```ts +if (queryClient.isFetching()) { + console.log('At least one query is fetching!') +} +``` + +*** + +### isMutating() + +```ts +isMutating(filters?): number; +``` + +Defined in: [packages/query-core/src/queryClient.ts:168](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L168) + +Returns the number of mutations in the cache that are currently pending, optionally +matching a set of filters. + +#### Type Parameters + +##### TMutationFilters + +`TMutationFilters` *extends* [`MutationFilters`](../interfaces/MutationFilters.md)\<`any`, `any`, `unknown`, `unknown`\> = [`MutationFilters`](../interfaces/MutationFilters.md)\<`unknown`, `Error`, `unknown`, `unknown`\> + +#### Parameters + +##### filters? + +`TMutationFilters` + +#### Returns + +`number` + +#### Example + +```ts +if (queryClient.isMutating()) { + console.log('At least one mutation is pending!') +} +``` + +*** + +### mount() + +```ts +mount(): void; +``` + +Defined in: [packages/query-core/src/queryClient.ts:104](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L104) + +Called by a framework adapter's `QueryClientProvider`-equivalent when it mounts, to start +listening for focus/online events and resume paused mutations. Ref-counted via an internal +mount count, so nested or multiple providers sharing the same `QueryClient` don't tear down +the shared listeners until the last one unmounts. + +#### Returns + +`void` + +*** + +### ~~prefetchInfiniteQuery()~~ + +```ts +prefetchInfiniteQuery(options): Promise; +``` + +Defined in: [packages/query-core/src/queryClient.ts:714](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L714) + +#### Type Parameters + +##### TQueryFnData + +`TQueryFnData` + +##### TError + +`TError` = `Error` + +##### TData + +`TData` = `TQueryFnData` + +##### TQueryKey + +`TQueryKey` *extends* readonly `unknown`[] = readonly `unknown`[] + +##### TPageParam + +`TPageParam` = `unknown` + +#### Parameters + +##### options + +[`FetchInfiniteQueryOptions`](../type-aliases/FetchInfiniteQueryOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`, `TPageParam`\> + +#### Returns + +`Promise`\<`void`\> + +#### Deprecated + +Use queryClient.infiniteQuery(options) instead. You can swallow errors with `.catch(noop)`. This method will be removed in the next major version. + +*** + +### ~~prefetchQuery()~~ + +```ts +prefetchQuery(options): Promise; +``` + +Defined in: [packages/query-core/src/queryClient.ts:634](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L634) + +#### Type Parameters + +##### TQueryFnData + +`TQueryFnData` = `unknown` + +##### TError + +`TError` = `Error` + +##### TData + +`TData` = `TQueryFnData` + +##### TQueryKey + +`TQueryKey` *extends* readonly `unknown`[] = readonly `unknown`[] + +#### Parameters + +##### options + +[`FetchQueryOptions`](../interfaces/FetchQueryOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`\> + +#### Returns + +`Promise`\<`void`\> + +#### Deprecated + +Use queryClient.query(options) instead. You can swallow errors with `.catch(noop)`. This method will be removed in the next major version. + +*** + +### query() + +```ts +query(options): Promise; +``` + +Defined in: [packages/query-core/src/queryClient.ts:554](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L554) + +Asynchronous method to fetch and cache a query, resolving with the data or throwing with +the error. + +If the query already exists in the cache and its data is not stale (per the given +`staleTime`), the cached data is returned without fetching. Otherwise, the query is fetched +and the promise resolves once the fetch settles. If a `select` function is provided, it is +applied to the data in both cases (cached or freshly fetched) before it is returned. + +Unlike a reactive observer, retries are disabled by default here (`retry: false`) unless +explicitly configured, since there is no component to catch a thrown error and retry through +re-render. + +The accepted options are `QueryObserverOptions` minus the fields that only make sense for a +reactive observer — `enabled`, `refetchInterval`, `refetchIntervalInBackground`, +`refetchOnWindowFocus`, `refetchOnReconnect`, `refetchOnMount`, `retryOnMount`, +`notifyOnChangeProps`, `throwOnError`, `suspense`, and `placeholderData` are not part of this +method's options. + +This method replaces the deprecated `fetchQuery`, and — combined with +`{ staleTime: 'static' }` — the deprecated `ensureQueryData`. + +#### Type Parameters + +##### TQueryFnData + +`TQueryFnData` + +##### TError + +`TError` = `Error` + +##### TData + +`TData` = `TQueryFnData` + +##### TQueryData + +`TQueryData` = `TQueryFnData` + +##### TQueryKey + +`TQueryKey` *extends* readonly `unknown`[] = readonly `unknown`[] + +##### TPageParam + +`TPageParam` = `never` + +#### Parameters + +##### options + +[`QueryExecuteOptions`](../interfaces/QueryExecuteOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryData`, `TQueryKey`, `TPageParam`\> + +#### Returns + +`Promise`\<`TData`\> + +#### Example + +```ts +try { + const data = await queryClient.query({ queryKey, queryFn, staleTime: 10000 }) +} catch (error) { + console.log(error) +} +``` + +*** + +### refetchQueries() + +```ts +refetchQueries(filters?, options?): Promise; +``` + +Defined in: [packages/query-core/src/queryClient.ts:497](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L497) + +Refetches queries matching the given filters, regardless of whether they are stale. Without +filters, every query in the cache is refetched. Queries that are disabled, or static (only +have observers with a static `staleTime`), are never refetched. + +By default (`cancelRefetch: true`), a currently running fetch is cancelled before the new +one starts. The returned promise resolves once all matching queries have settled; it does +not reject on individual query failures unless `throwOnError` is set. + +#### Type Parameters + +##### TTaggedQueryKey + +`TTaggedQueryKey` *extends* readonly `unknown`[] = readonly `unknown`[] + +#### Parameters + +##### filters? + +[`RefetchQueryFilters`](../interfaces/RefetchQueryFilters.md)\<`TTaggedQueryKey`\> + +##### options? + +[`RefetchOptions`](../interfaces/RefetchOptions.md) = `{}` + +#### Returns + +`Promise`\<`void`\> + +#### Example + +```ts +// refetch all active queries partially matching a query key: +await queryClient.refetchQueries({ queryKey: ['posts'], type: 'active' }) +``` + +*** + +### removeQueries() + +```ts +removeQueries(filters?): void; +``` + +Defined in: [packages/query-core/src/queryClient.ts:376](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L376) + +Removes queries from the cache that match the given filters. Unlike +[QueryClient#invalidateQueries](#invalidatequeries) or [QueryClient#refetchQueries](#refetchqueries), this removes +matching queries from the cache instead of refetching them. Without filters, every query in +the cache is removed. + +#### Type Parameters + +##### TTaggedQueryKey + +`TTaggedQueryKey` *extends* readonly `unknown`[] = readonly `unknown`[] + +#### Parameters + +##### filters? + +[`QueryFilters`](../interfaces/QueryFilters.md)\<`TTaggedQueryKey`\> + +#### Returns + +`void` + +#### Example + +```ts +queryClient.removeQueries({ queryKey: ['posts'], exact: true }) +``` + +*** + +### resetQueries() + +```ts +resetQueries(filters?, options?): Promise; +``` + +Defined in: [packages/query-core/src/queryClient.ts:397](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L397) + +Resets queries matching the given filters back to their initial state (e.g. any +`initialData`), notifying subscribers rather than removing them. Active queries among the +matched set are then refetched, and the returned promise resolves once that refetch settles. + +#### Type Parameters + +##### TTaggedQueryKey + +`TTaggedQueryKey` *extends* readonly `unknown`[] = readonly `unknown`[] + +#### Parameters + +##### filters? + +[`QueryFilters`](../interfaces/QueryFilters.md)\<`TTaggedQueryKey`\> + +##### options? + +[`ResetOptions`](../interfaces/ResetOptions.md) + +#### Returns + +`Promise`\<`void`\> + +#### Example + +```ts +await queryClient.resetQueries({ queryKey: ['posts'], exact: true }) +``` + +*** + +### resumePausedMutations() + +```ts +resumePausedMutations(): Promise; +``` + +Defined in: [packages/query-core/src/queryClient.ts:767](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L767) + +Resumes mutations that were paused because there was no network connection. Does nothing +(resolving immediately) if the client is currently offline. + +#### Returns + +`Promise`\<`unknown`\> + +#### Example + +```ts +import { QueryClient } from '@tanstack/query-core' + +const queryClient = new QueryClient() +await queryClient.resumePausedMutations() +``` + +*** + +### setDefaultOptions() + +```ts +setDefaultOptions(options): void; +``` + +Defined in: [packages/query-core/src/queryClient.ts:839](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L839) + +Dynamically sets the default options for this client, overwriting any previously defined +default options. + +#### Parameters + +##### options + +[`DefaultOptions`](../interfaces/DefaultOptions.md) + +#### Returns + +`void` + +#### See + +[QueryClient#getDefaultOptions](#getdefaultoptions) + +#### Example + +```ts +import { QueryClient } from '@tanstack/query-core' + +const queryClient = new QueryClient() +queryClient.setDefaultOptions({ + queries: { + staleTime: Infinity, + }, +}) +``` + +*** + +### setMutationDefaults() + +```ts +setMutationDefaults(mutationKey, options): void; +``` + +Defined in: [packages/query-core/src/queryClient.ts:917](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L917) + +Sets default options for mutations whose mutation key partially matches the given +`mutationKey`. As with [QueryClient#setQueryDefaults](#setquerydefaults), the order of registration +matters when several registered defaults match the same mutation key. + +#### Type Parameters + +##### TData + +`TData` = `unknown` + +##### TError + +`TError` = `Error` + +##### TVariables + +`TVariables` = `void` + +##### TOnMutateResult + +`TOnMutateResult` = `unknown` + +#### Parameters + +##### mutationKey + +readonly `unknown`[] + +##### options + +[`OmitKeyof`](../type-aliases/OmitKeyof.md)\<[`MutationObserverOptions`](../interfaces/MutationObserverOptions.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\>, `"mutationKey"`\> + +#### Returns + +`void` + +#### See + +[QueryClient#getMutationDefaults](#getmutationdefaults) + +#### Example + +```ts +queryClient.setMutationDefaults(['addPost'], { mutationFn: addPost }) +``` + +*** + +### setQueriesData() + +```ts +setQueriesData( + filters, + updater, + options?): [readonly unknown[], TQueryFnData | undefined][]; +``` + +Defined in: [packages/query-core/src/queryClient.ts:319](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L319) + +Synchronous way to immediately update the cached data of multiple queries at once, using +filters or partial query key matching. Only queries that already exist and match the given +filters are updated; no new cache entries are created. Internally this calls +[QueryClient#setQueryData](#setquerydata) for each matching query. + +#### Type Parameters + +##### TQueryFnData + +`TQueryFnData` + +##### TQueryFilters + +`TQueryFilters` *extends* [`QueryFilters`](../interfaces/QueryFilters.md)\<`any`\> = [`QueryFilters`](../interfaces/QueryFilters.md)\ + +#### Parameters + +##### filters + +`TQueryFilters` + +##### updater + +[`Updater`](../type-aliases/Updater.md)\<`NoInfer`\<`TQueryFnData`\> \| `undefined`, `NoInfer`\<`TQueryFnData`\> \| `undefined`\> + +##### options? + +[`SetDataOptions`](../interfaces/SetDataOptions.md) + +#### Returns + +\[readonly `unknown`[], `TQueryFnData` \| `undefined`\][] + +#### Example + +```ts +queryClient.setQueriesData({ queryKey: ['posts'] }, (oldPosts) => + oldPosts ? oldPosts.filter((post) => post.id !== deletedId) : oldPosts, +) +``` + +*** + +### setQueryData() + +```ts +setQueryData( + queryKey, + updater, + options?): NoInfer | undefined; +``` + +Defined in: [packages/query-core/src/queryClient.ts:271](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L271) + +Synchronous way to immediately update a query's cached data. If the updater (or the value +passed) resolves to `undefined`, the cache is left untouched and no query is created; +otherwise, if the query does not exist yet, it will be created. To update multiple queries +at once by partially matching query keys, use [QueryClient#setQueriesData](#setqueriesdata) instead. + +Updates must be performed immutably: do not mutate `oldData`, or data previously retrieved +via [QueryClient#getQueryData](#getquerydata), in place. + +#### Type Parameters + +##### TQueryFnData + +`TQueryFnData` = `unknown` + +##### TTaggedQueryKey + +`TTaggedQueryKey` *extends* readonly `unknown`[] = readonly `unknown`[] + +##### TInferredQueryFnData + +`TInferredQueryFnData` = [`InferDataFromTag`](../type-aliases/InferDataFromTag.md)\<`TQueryFnData`, `TTaggedQueryKey`\> + +#### Parameters + +##### queryKey + +`TTaggedQueryKey` + +The query key to set data for. + +##### updater + +[`Updater`](../type-aliases/Updater.md)\<`NoInfer`\<`TInferredQueryFnData`\> \| `undefined`, `NoInfer`\<`TInferredQueryFnData`\> \| `undefined`\> + +Either the new data, or a function that receives the current data (which +may be `undefined`) and returns the new data. + +##### options? + +[`SetDataOptions`](../interfaces/SetDataOptions.md) + +#### Returns + +`NoInfer`\<`TInferredQueryFnData`\> \| `undefined` + +#### Example + +```ts +queryClient.setQueryData(['posts'], newPosts) + +// Or, using an updater function that receives the current data: +queryClient.setQueryData(['posts'], (oldPosts) => [...oldPosts, newPost]) +``` + +*** + +### setQueryDefaults() + +```ts +setQueryDefaults(queryKey, options): void; +``` + +Defined in: [packages/query-core/src/queryClient.ts:858](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L858) + +Sets default options for queries whose query key partially matches the given `queryKey`. + +If several registered query defaults match a given query key, they are merged together in +registration order by [QueryClient#getQueryDefaults](#getquerydefaults), so register defaults from the +most generic key to the least generic one — more specific defaults should be registered +after more generic ones so they take precedence. + +#### Type Parameters + +##### TQueryFnData + +`TQueryFnData` = `unknown` + +##### TError + +`TError` = `Error` + +##### TData + +`TData` = `TQueryFnData` + +##### TQueryData + +`TQueryData` = `TQueryFnData` + +#### Parameters + +##### queryKey + +readonly `unknown`[] + +##### options + +`Partial`\<[`OmitKeyof`](../type-aliases/OmitKeyof.md)\<[`QueryObserverOptions`](../interfaces/QueryObserverOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryData`\>, `"queryKey"`\>\> + +#### Returns + +`void` + +#### Example + +```ts +queryClient.setQueryDefaults(['posts'], { queryFn: fetchPosts }) + +await queryClient.query({ queryKey: ['posts'] }) +``` + +*** + +### unmount() + +```ts +unmount(): void; +``` + +Defined in: [packages/query-core/src/queryClient.ts:127](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L127) + +The inverse of [QueryClient#mount](#mount) — called by a framework adapter's +`QueryClientProvider`-equivalent when it unmounts. Only tears down the focus/online +listeners once the mount count returns to `0`. + +#### Returns + +`void` diff --git a/docs/framework/angular/reference/classes/QueryObserver.md b/docs/framework/angular/reference/classes/QueryObserver.md new file mode 100644 index 00000000000..51ff16910df --- /dev/null +++ b/docs/framework/angular/reference/classes/QueryObserver.md @@ -0,0 +1,555 @@ +--- +id: QueryObserver +title: QueryObserver +--- + +Defined in: [packages/query-core/src/queryObserver.ts:57](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L57) + +A `QueryObserver` watches a single query in the `QueryCache` and computes a +`QueryObserverResult` from its state, recomputing and notifying subscribers +whenever the underlying query (or the observer's options) changes. It is +the primitive that framework adapters (e.g. `useQuery`) build their hooks +on top of, but it can also be used directly to observe and switch between +queries outside of any framework. + +## Example + +```ts +const observer = new QueryObserver(queryClient, { + queryKey: ['posts'], + queryFn: fetchPosts, +}) + +const unsubscribe = observer.subscribe((result) => { + console.log(result.data) +}) +``` + +## Extends + +- `Subscribable`\<`QueryObserverListener`\<`TData`, `TError`\>\> + +## Extended by + +- [`InfiniteQueryObserver`](InfiniteQueryObserver.md) + +## Type Parameters + +### TQueryFnData + +`TQueryFnData` = `unknown` + +### TError + +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) + +### TData + +`TData` = `TQueryFnData` + +### TQueryData + +`TQueryData` = `TQueryFnData` + +### TQueryKey + +`TQueryKey` *extends* [`QueryKey`](../type-aliases/QueryKey.md) = [`QueryKey`](../type-aliases/QueryKey.md) + +## Constructors + +### Constructor + +```ts +new QueryObserver(client, options): QueryObserver; +``` + +Defined in: [packages/query-core/src/queryObserver.ts:87](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L87) + +#### Parameters + +##### client + +[`QueryClient`](QueryClient.md) + +##### options + +[`QueryObserverOptions`](../interfaces/QueryObserverOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryData`, `TQueryKey`\> + +#### Returns + +`QueryObserver`\<`TQueryFnData`, `TError`, `TData`, `TQueryData`, `TQueryKey`\> + +#### Overrides + +```ts +Subscribable>.constructor +``` + +## Properties + +### listeners + +```ts +protected listeners: Set>; +``` + +Defined in: [packages/query-core/src/subscribable.ts:2](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L2) + +#### Inherited from + +```ts +Subscribable.listeners +``` + +*** + +### options + +```ts +options: QueryObserverOptions; +``` + +Defined in: [packages/query-core/src/queryObserver.ts:89](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L89) + +## Methods + +### bindMethods() + +```ts +protected bindMethods(): void; +``` + +Defined in: [packages/query-core/src/queryObserver.ts:106](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L106) + +#### Returns + +`void` + +*** + +### createResult() + +```ts +protected createResult(query, options): QueryObserverResult; +``` + +Defined in: [packages/query-core/src/queryObserver.ts:559](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L559) + +#### Parameters + +##### query + +[`Query`](Query.md)\<`TQueryFnData`, `TError`, `TQueryData`, `TQueryKey`\> + +##### options + +[`QueryObserverOptions`](../interfaces/QueryObserverOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryData`, `TQueryKey`\> + +#### Returns + +[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\> + +*** + +### destroy() + +```ts +destroy(): void; +``` + +Defined in: [packages/query-core/src/queryObserver.ts:161](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L161) + +Stops observing the current query: clears all listeners, cancels the +stale and refetch-interval timers, and removes this observer from the +query it was observing. + +#### Returns + +`void` + +*** + +### fetch() + +```ts +protected fetch(fetchOptions): Promise>; +``` + +Defined in: [packages/query-core/src/queryObserver.ts:448](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L448) + +#### Parameters + +##### fetchOptions + +`ObserverFetchOptions` + +#### Returns + +`Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> + +*** + +### fetchOptimistic() + +```ts +fetchOptimistic(options): Promise>; +``` + +Defined in: [packages/query-core/src/queryObserver.ts:395](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L395) + +Fetches a query defined by the given options without affecting this +observer's own tracked query or result, and returns a promise that +resolves with the `QueryObserverResult` for that fetch. This is useful +for prefetching data that another observer (e.g. a query about to be +navigated to) will need, ahead of time. + +#### Parameters + +##### options + +[`QueryObserverOptions`](../interfaces/QueryObserverOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryData`, `TQueryKey`\> + +#### Returns + +`Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> + +#### Example + +```ts +const result = await observer.fetchOptimistic({ + queryKey: ['posts', 2], + queryFn: () => fetchPost(2), +}) +console.log(result.data) +``` + +*** + +### getCurrentQuery() + +```ts +getCurrentQuery(): Query; +``` + +Defined in: [packages/query-core/src/queryObserver.ts:357](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L357) + +Returns the `Query` instance this observer is currently observing. + +#### Returns + +[`Query`](Query.md)\<`TQueryFnData`, `TError`, `TQueryData`, `TQueryKey`\> + +*** + +### getCurrentResult() + +```ts +getCurrentResult(): QueryObserverResult; +``` + +Defined in: [packages/query-core/src/queryObserver.ts:321](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L321) + +Returns the most recently computed `QueryObserverResult` for the +observed query. This is a point-in-time read; to be notified of updates +as they happen, subscribe to the observer instead (its inherited +`subscribe` method). + +#### Returns + +[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\> + +#### Example + +```ts +const result = observer.getCurrentResult() +console.log(result.status, result.data) +``` + +*** + +### getOptimisticResult() + +```ts +getOptimisticResult(options): QueryObserverResult; +``` + +Defined in: [packages/query-core/src/queryObserver.ts:272](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L272) + +Computes the result the observer would produce for the given (already-defaulted) options +right now, building the underlying `Query` if it doesn't exist yet, without waiting for a +subscription callback. Called by framework adapters on every render (e.g. `useQuery`) so the +returned value is available synchronously, ahead of `setOptions` triggering an actual fetch. + +#### Parameters + +##### options + +[`DefaultedQueryObserverOptions`](../type-aliases/DefaultedQueryObserverOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryData`, `TQueryKey`\> + +#### Returns + +[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\> + +*** + +### hasListeners() + +```ts +hasListeners(): boolean; +``` + +Defined in: [packages/query-core/src/subscribable.ts:19](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L19) + +#### Returns + +`boolean` + +#### Inherited from + +```ts +Subscribable.hasListeners +``` + +*** + +### onSubscribe() + +```ts +protected onSubscribe(): void; +``` + +Defined in: [packages/query-core/src/queryObserver.ts:110](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L110) + +#### Returns + +`void` + +#### Overrides + +```ts +Subscribable.onSubscribe +``` + +*** + +### onUnsubscribe() + +```ts +protected onUnsubscribe(): void; +``` + +Defined in: [packages/query-core/src/queryObserver.ts:124](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L124) + +#### Returns + +`void` + +#### Overrides + +```ts +Subscribable.onUnsubscribe +``` + +*** + +### refetch() + +```ts +refetch(__namedParameters): Promise>; +``` + +Defined in: [packages/query-core/src/queryObserver.ts:371](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L371) + +Refetches the observed query and returns a promise that resolves with +the resulting `QueryObserverResult`. + +#### Parameters + +##### \_\_namedParameters + +[`RefetchOptions`](../interfaces/RefetchOptions.md) = `{}` + +#### Returns + +`Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> + +#### Example + +```ts +const result = await observer.refetch({ cancelRefetch: false }) +console.log(result.data) +``` + +*** + +### setOptions() + +```ts +setOptions(options): void; +``` + +Defined in: [packages/query-core/src/queryObserver.ts:182](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L182) + +Updates the observer's options. This will re-resolve the query being +observed (switching to a different query if the `queryKey` changed), +trigger a fetch if the new options require one and the observer has +subscribers, recompute the current result, and reschedule the stale and +refetch-interval timers as needed. + +#### Parameters + +##### options + +[`QueryObserverOptions`](../interfaces/QueryObserverOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryData`, `TQueryKey`\> + +#### Returns + +`void` + +#### Example + +```ts +observer.setOptions({ queryKey: ['posts', 1], queryFn: () => fetchPost(1) }) +// later: switch to a different query, reusing the same observer +observer.setOptions({ queryKey: ['posts', 2], queryFn: () => fetchPost(2) }) +``` + +*** + +### shouldFetchOnReconnect() + +```ts +shouldFetchOnReconnect(): boolean; +``` + +Defined in: [packages/query-core/src/queryObserver.ts:135](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L135) + +Returns whether the observed query is currently stale and configured +(via the `refetchOnReconnect` option) to refetch when the network +reconnects. + +#### Returns + +`boolean` + +*** + +### shouldFetchOnWindowFocus() + +```ts +shouldFetchOnWindowFocus(): boolean; +``` + +Defined in: [packages/query-core/src/queryObserver.ts:148](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L148) + +Returns whether the observed query is currently stale and configured +(via the `refetchOnWindowFocus` option) to refetch when the window +regains focus. + +#### Returns + +`boolean` + +*** + +### subscribe() + +```ts +subscribe(listener): () => void; +``` + +Defined in: [packages/query-core/src/subscribable.ts:8](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L8) + +#### Parameters + +##### listener + +`QueryObserverListener` + +#### Returns + +```ts +(): void; +``` + +##### Returns + +`void` + +#### Inherited from + +```ts +Subscribable.subscribe +``` + +*** + +### trackProp() + +```ts +trackProp(key): void; +``` + +Defined in: [packages/query-core/src/queryObserver.ts:350](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L350) + +Records that the given `QueryObserverResult` property was read, so a subsequent update only +notifies this observer if a tracked property actually changed. Normally called indirectly via +[QueryObserver#trackResult](#trackresult)'s proxy; exposed directly for adapters that track property +access themselves (e.g. through their own reactivity system) instead of via the proxy. + +#### Parameters + +##### key + +`"error"` | `"data"` | `"isError"` | `"isPending"` | `"isLoading"` | `"isLoadingError"` | `"isRefetchError"` | `"isSuccess"` | `"isPlaceholderData"` | `"status"` | `"dataUpdatedAt"` | `"errorUpdatedAt"` | `"failureCount"` | `"failureReason"` | `"errorUpdateCount"` | `"isFetched"` | `"isFetchedAfterMount"` | `"isFetching"` | `"isInitialLoading"` | `"isPaused"` | `"isRefetching"` | `"isStale"` | `"isEnabled"` | `"refetch"` | `"fetchStatus"` + +#### Returns + +`void` + +*** + +### trackResult() + +```ts +trackResult(result, onPropTracked?): QueryObserverResult; +``` + +Defined in: [packages/query-core/src/queryObserver.ts:331](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L331) + +Wraps a `QueryObserverResult` in a `Proxy` that records which properties are read, via +[QueryObserver#trackProp](#trackprop) (and an optional `onPropTracked` callback). Used by framework +adapters when `notifyOnChangeProps` is not set, to implement its default "only re-render on +properties you actually read" behavior. + +#### Parameters + +##### result + +[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\> + +##### onPropTracked? + +(`key`) => `void` + +#### Returns + +[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\> + +*** + +### updateResult() + +```ts +updateResult(): void; +``` + +Defined in: [packages/query-core/src/queryObserver.ts:735](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L735) + +Recomputes and stores the current result from the current query/options, notifying listeners +if it changed. Framework adapters call this right after subscribing to make sure no query +update was missed in the gap between creating the observer and subscribing to it. + +#### Returns + +`void` diff --git a/docs/framework/angular/reference/functions/defaultShouldDehydrateMutation.md b/docs/framework/angular/reference/functions/defaultShouldDehydrateMutation.md new file mode 100644 index 00000000000..940f8745a5d --- /dev/null +++ b/docs/framework/angular/reference/functions/defaultShouldDehydrateMutation.md @@ -0,0 +1,23 @@ +--- +id: defaultShouldDehydrateMutation +title: defaultShouldDehydrateMutation +--- + +```ts +function defaultShouldDehydrateMutation(mutation): boolean; +``` + +Defined in: [packages/query-core/src/hydration.ts:177](https://github.com/TanStack/query/blob/main/packages/query-core/src/hydration.ts#L177) + +The default `shouldDehydrateMutation` predicate used by `dehydrate`. Only dehydrates mutations that are +currently paused (e.g. paused by `networkMode` while offline). + +## Parameters + +### mutation + +[`Mutation`](../classes/Mutation.md) + +## Returns + +`boolean` diff --git a/docs/framework/angular/reference/functions/defaultShouldDehydrateQuery.md b/docs/framework/angular/reference/functions/defaultShouldDehydrateQuery.md new file mode 100644 index 00000000000..abf19439d8a --- /dev/null +++ b/docs/framework/angular/reference/functions/defaultShouldDehydrateQuery.md @@ -0,0 +1,23 @@ +--- +id: defaultShouldDehydrateQuery +title: defaultShouldDehydrateQuery +--- + +```ts +function defaultShouldDehydrateQuery(query): boolean; +``` + +Defined in: [packages/query-core/src/hydration.ts:185](https://github.com/TanStack/query/blob/main/packages/query-core/src/hydration.ts#L185) + +The default `shouldDehydrateQuery` predicate used by `dehydrate`. Only dehydrates queries whose status is +`'success'`. + +## Parameters + +### query + +[`Query`](../classes/Query.md) + +## Returns + +`boolean` diff --git a/docs/framework/angular/reference/functions/dehydrate.md b/docs/framework/angular/reference/functions/dehydrate.md new file mode 100644 index 00000000000..33cdcd3940d --- /dev/null +++ b/docs/framework/angular/reference/functions/dehydrate.md @@ -0,0 +1,43 @@ +--- +id: dehydrate +title: dehydrate +--- + +```ts +function dehydrate(client, options): DehydratedState; +``` + +Defined in: [packages/query-core/src/hydration.ts:207](https://github.com/TanStack/query/blob/main/packages/query-core/src/hydration.ts#L207) + +Dehydrates a `QueryClient`'s cache (queries and mutations) into a plain, serializable `DehydratedState`, +typically to embed in server-rendered markup and later restore into a client-side `QueryClient` via `hydrate`. +Which queries/mutations are included, and how their data/errors are transformed, is controlled by `options`, +falling back to the client's `dehydrate` default options, and finally to `defaultShouldDehydrateQuery` / +`defaultShouldDehydrateMutation`. + +## Parameters + +### client + +[`QueryClient`](../classes/QueryClient.md) + +### options + +[`DehydrateOptions`](../interfaces/DehydrateOptions.md) = `{}` + +## Returns + +[`DehydratedState`](../interfaces/DehydratedState.md) + +## Example + +```ts +const queryClient = new QueryClient() + +await queryClient.prefetchQuery({ + queryKey: ['posts'], + queryFn: getPosts, +}) + +const dehydratedState = dehydrate(queryClient) +``` diff --git a/docs/framework/angular/reference/functions/dehydrateQuery.md b/docs/framework/angular/reference/functions/dehydrateQuery.md new file mode 100644 index 00000000000..2314f52fd91 --- /dev/null +++ b/docs/framework/angular/reference/functions/dehydrateQuery.md @@ -0,0 +1,43 @@ +--- +id: dehydrateQuery +title: dehydrateQuery +--- + +```ts +function dehydrateQuery( + query, + serializeData?, + shouldRedactErrors?): DehydratedQuery; +``` + +Defined in: [packages/query-core/src/hydration.ts:148](https://github.com/TanStack/query/blob/main/packages/query-core/src/hydration.ts#L148) + +Dehydrates a single `Query` into a serializable `DehydratedQuery` snapshot. Note that most query config (e.g. +`queryFn`, `staleTime`) is not dehydrated but instead meant to be configured again when consuming the +de/rehydrated data, typically with `useQuery` on the client. If the query is still `pending`, its in-flight +promise is dehydrated too so it can be resumed on the other side instead of re-fetched. + +## Parameters + +### query + +[`Query`](../classes/Query.md) + +The query to dehydrate. + +### serializeData? + +`TransformerFn` + +Optional transform applied to `query.state.data` before it is included in the snapshot. + +### shouldRedactErrors? + +(`error`) => `boolean` + +Optional predicate; if it returns `false` for the promise's rejection error, that +error is kept as-is instead of being redacted. + +## Returns + +`DehydratedQuery` diff --git a/docs/framework/angular/reference/functions/experimental_streamedQuery.md b/docs/framework/angular/reference/functions/experimental_streamedQuery.md new file mode 100644 index 00000000000..4c490322d60 --- /dev/null +++ b/docs/framework/angular/reference/functions/experimental_streamedQuery.md @@ -0,0 +1,52 @@ +--- +id: experimental_streamedQuery +title: experimental_streamedQuery +--- + +```ts +function experimental_streamedQuery(streamFn): QueryFunction; +``` + +Defined in: [packages/query-core/src/streamedQuery.ts:75](https://github.com/TanStack/query/blob/main/packages/query-core/src/streamedQuery.ts#L75) + +This is a helper function to create a query function that streams data from an AsyncIterable. +Data will be an Array of all the chunks received. +The query will be in a 'pending' state until the first chunk of data is received, but will go to 'success' after that. +The query will stay in fetchStatus 'fetching' until the stream ends. + +## Type Parameters + +### TQueryFnData + +`TQueryFnData` = `unknown` + +### TData + +`TData` = `TQueryFnData`[] + +### TQueryKey + +`TQueryKey` *extends* readonly `unknown`[] = readonly `unknown`[] + +## Parameters + +### streamFn + +`StreamedQueryParams`\<`TQueryFnData`, `TData`, `TQueryKey`\> + +The function that returns an AsyncIterable to stream data from. + +## Returns + +[`QueryFunction`](../type-aliases/QueryFunction.md)\<`TData`, `TQueryKey`\> + +## Example + +```ts +await queryClient.query({ + queryKey: ['data'], + queryFn: streamedQuery({ + streamFn: fetchDataInChunks, + }), +}) +``` diff --git a/docs/framework/angular/reference/functions/hashKey.md b/docs/framework/angular/reference/functions/hashKey.md new file mode 100644 index 00000000000..dc774c032ce --- /dev/null +++ b/docs/framework/angular/reference/functions/hashKey.md @@ -0,0 +1,30 @@ +--- +id: hashKey +title: hashKey +--- + +```ts +function hashKey(queryKey): string; +``` + +Defined in: [packages/query-core/src/utils.ts:284](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L284) + +Default query & mutation keys hash function. +Hashes the value into a stable hash. + +## Parameters + +### queryKey + +readonly `unknown`[] + +## Returns + +`string` + +## Example + +```ts +// Object keys are sorted, so key order doesn't affect the hash: +hashKey(['todos', { page: 1, filter: 'done' }]) // === '["todos",{"filter":"done","page":1}]' +``` diff --git a/docs/framework/angular/reference/functions/hydrate.md b/docs/framework/angular/reference/functions/hydrate.md new file mode 100644 index 00000000000..c0093b57457 --- /dev/null +++ b/docs/framework/angular/reference/functions/hydrate.md @@ -0,0 +1,49 @@ +--- +id: hydrate +title: hydrate +--- + +```ts +function hydrate( + client, + dehydratedState, + options?): void; +``` + +Defined in: [packages/query-core/src/hydration.ts:264](https://github.com/TanStack/query/blob/main/packages/query-core/src/hydration.ts#L264) + +Restores a `DehydratedState` (as produced by `dehydrate`) into a `QueryClient`'s cache, typically to seed the +client with data already fetched on the server. `mutations` and `queries` are each optional on `dehydratedState`. +Queries not yet in the cache are built from the dehydrated snapshot; queries that already exist are only updated +when the dehydrated data is newer than what's already cached. Newly built queries have their `fetchStatus` reset +to `'idle'` so they don't hydrate stuck in a fetching state. If a dehydrated query still had an in-flight +promise, it is resumed via `query.fetch()` (reusing that promise as `initialPromise`) rather than re-invoking +`queryFn`. + +## Parameters + +### client + +[`QueryClient`](../classes/QueryClient.md) + +### dehydratedState + +`Partial`\<[`DehydratedState`](../interfaces/DehydratedState.md)\> + +### options? + +[`HydrateOptions`](../interfaces/HydrateOptions.md) + +## Returns + +`void` + +## Example + +```ts +// dehydratedState was produced by `dehydrate` on the server +// and sent to the client, e.g. embedded in server-rendered markup. +const queryClient = new QueryClient() + +hydrate(queryClient, dehydratedState) +``` diff --git a/docs/framework/angular/reference/functions/infiniteQueryOptions.md b/docs/framework/angular/reference/functions/infiniteQueryOptions.md index f1e3a235d48..1011653b452 100644 --- a/docs/framework/angular/reference/functions/infiniteQueryOptions.md +++ b/docs/framework/angular/reference/functions/infiniteQueryOptions.md @@ -9,7 +9,7 @@ title: infiniteQueryOptions function infiniteQueryOptions(options): CreateInfiniteQueryOptions & object & QueryKeyWithDataTag, TError>; ``` -Defined in: [infinite-query-options.ts:181](https://github.com/TanStack/query/blob/main/packages/angular-query-experimental/src/infinite-query-options.ts#L181) +Defined in: [packages/angular-query-experimental/src/infinite-query-options.ts:181](https://github.com/TanStack/query/blob/main/packages/angular-query-experimental/src/infinite-query-options.ts#L181) You can generally pass everything to `infiniteQueryOptions` that you can also pass to `injectInfiniteQuery`. These options can be shared across functions and imperative APIs such as @@ -30,7 +30,7 @@ This overload is selected when `initialData` is set. #### TData -`TData` = `InfiniteData`\<`TQueryFnData`, `unknown`\> +`TData` = [`InfiniteData`](../interfaces/InfiniteData.md)\<`TQueryFnData`, `unknown`\> #### TQueryKey @@ -100,7 +100,7 @@ export class Projects { function infiniteQueryOptions(options): OmitKeyof, "queryFn"> & object & QueryKeyWithDataTag, TError>; ``` -Defined in: [infinite-query-options.ts:255](https://github.com/TanStack/query/blob/main/packages/angular-query-experimental/src/infinite-query-options.ts#L255) +Defined in: [packages/angular-query-experimental/src/infinite-query-options.ts:255](https://github.com/TanStack/query/blob/main/packages/angular-query-experimental/src/infinite-query-options.ts#L255) You can generally pass everything to `infiniteQueryOptions` that you can also pass to `injectInfiniteQuery`. These options can be shared across functions and imperative APIs such as @@ -119,7 +119,7 @@ for. #### TData -`TData` = `InfiniteData`\<`TQueryFnData`, `unknown`\> +`TData` = [`InfiniteData`](../interfaces/InfiniteData.md)\<`TQueryFnData`, `unknown`\> #### TQueryKey @@ -195,7 +195,7 @@ export class Comments { function infiniteQueryOptions(options): CreateInfiniteQueryOptions & object & QueryKeyWithDataTag, TError>; ``` -Defined in: [infinite-query-options.ts:329](https://github.com/TanStack/query/blob/main/packages/angular-query-experimental/src/infinite-query-options.ts#L329) +Defined in: [packages/angular-query-experimental/src/infinite-query-options.ts:329](https://github.com/TanStack/query/blob/main/packages/angular-query-experimental/src/infinite-query-options.ts#L329) You can generally pass everything to `infiniteQueryOptions` that you can also pass to `injectInfiniteQuery`. These options can be shared across functions and imperative APIs such as @@ -214,7 +214,7 @@ for. #### TData -`TData` = `InfiniteData`\<`TQueryFnData`, `unknown`\> +`TData` = [`InfiniteData`](../interfaces/InfiniteData.md)\<`TQueryFnData`, `unknown`\> #### TQueryKey diff --git a/docs/framework/angular/reference/functions/injectInfiniteQuery.md b/docs/framework/angular/reference/functions/injectInfiniteQuery.md index 8f80b177691..2b121d5e4ac 100644 --- a/docs/framework/angular/reference/functions/injectInfiniteQuery.md +++ b/docs/framework/angular/reference/functions/injectInfiniteQuery.md @@ -9,7 +9,7 @@ title: injectInfiniteQuery function injectInfiniteQuery(injectInfiniteQueryFn, options?): DefinedCreateInfiniteQueryResult; ``` -Defined in: [inject-infinite-query.ts:83](https://github.com/TanStack/query/blob/main/packages/angular-query-experimental/src/inject-infinite-query.ts#L83) +Defined in: [packages/angular-query-experimental/src/inject-infinite-query.ts:83](https://github.com/TanStack/query/blob/main/packages/angular-query-experimental/src/inject-infinite-query.ts#L83) The options for `injectInfiniteQuery` are identical to `injectQuery`, with the addition of `initialPageParam`, `getNextPageParam`, `getPreviousPageParam`, and `maxPages`. Infinite queries can @@ -30,7 +30,7 @@ so the resulting `data` signal is never `undefined` (unless a `select` changes ` #### TData -`TData` = `InfiniteData`\<`TQueryFnData`, `unknown`\> +`TData` = [`InfiniteData`](../interfaces/InfiniteData.md)\<`TQueryFnData`, `unknown`\> #### TQueryKey @@ -110,7 +110,7 @@ export class Projects { function injectInfiniteQuery(injectInfiniteQueryFn, options?): CreateInfiniteQueryResult; ``` -Defined in: [inject-infinite-query.ts:239](https://github.com/TanStack/query/blob/main/packages/angular-query-experimental/src/inject-infinite-query.ts#L239) +Defined in: [packages/angular-query-experimental/src/inject-infinite-query.ts:239](https://github.com/TanStack/query/blob/main/packages/angular-query-experimental/src/inject-infinite-query.ts#L239) Injects an infinite query: a declarative dependency on an asynchronous source of data that is tied to a unique key. Infinite queries can additively "load more" data onto an existing set of data, or @@ -128,7 +128,7 @@ unique key. Infinite queries can additively "load more" data onto an existing se #### TData -`TData` = `InfiniteData`\<`TQueryFnData`, `unknown`\> +`TData` = [`InfiniteData`](../interfaces/InfiniteData.md)\<`TQueryFnData`, `unknown`\> #### TQueryKey @@ -299,7 +299,7 @@ export class Comments { function injectInfiniteQuery(injectInfiniteQueryFn, options?): CreateInfiniteQueryResult; ``` -Defined in: [inject-infinite-query.ts:267](https://github.com/TanStack/query/blob/main/packages/angular-query-experimental/src/inject-infinite-query.ts#L267) +Defined in: [packages/angular-query-experimental/src/inject-infinite-query.ts:267](https://github.com/TanStack/query/blob/main/packages/angular-query-experimental/src/inject-infinite-query.ts#L267) This overload accepts the general [CreateInfiniteQueryOptions](../interfaces/CreateInfiniteQueryOptions.md) shape rather than the `initialData`-aware overloads above, so whether `data` is defined can't be inferred from the call site — @@ -318,7 +318,7 @@ options. #### TData -`TData` = `InfiniteData`\<`TQueryFnData`, `unknown`\> +`TData` = [`InfiniteData`](../interfaces/InfiniteData.md)\<`TQueryFnData`, `unknown`\> #### TQueryKey diff --git a/docs/framework/angular/reference/functions/injectIsFetching.md b/docs/framework/angular/reference/functions/injectIsFetching.md index abe3e4e8837..1d121851e47 100644 --- a/docs/framework/angular/reference/functions/injectIsFetching.md +++ b/docs/framework/angular/reference/functions/injectIsFetching.md @@ -7,7 +7,7 @@ title: injectIsFetching function injectIsFetching(filters?, options?): Signal; ``` -Defined in: [inject-is-fetching.ts:63](https://github.com/TanStack/query/blob/main/packages/angular-query-experimental/src/inject-is-fetching.ts#L63) +Defined in: [packages/angular-query-experimental/src/inject-is-fetching.ts:63](https://github.com/TanStack/query/blob/main/packages/angular-query-experimental/src/inject-is-fetching.ts#L63) Injects a signal that tracks the number of queries that your application is loading or fetching in the background (useful for app-wide loading indicators). @@ -16,9 +16,9 @@ background (useful for app-wide loading indicators). ### filters? -`QueryFilters`\ +[`QueryFilters`](../interfaces/QueryFilters.md)\ -The QueryFilters to narrow down the matched queries. +The [QueryFilters](../interfaces/QueryFilters.md) to narrow down the matched queries. ### options? diff --git a/docs/framework/angular/reference/functions/injectIsMutating.md b/docs/framework/angular/reference/functions/injectIsMutating.md index 2879f5986de..b3a8b063e60 100644 --- a/docs/framework/angular/reference/functions/injectIsMutating.md +++ b/docs/framework/angular/reference/functions/injectIsMutating.md @@ -7,7 +7,7 @@ title: injectIsMutating function injectIsMutating(filters?, options?): Signal; ``` -Defined in: [inject-is-mutating.ts:46](https://github.com/TanStack/query/blob/main/packages/angular-query-experimental/src/inject-is-mutating.ts#L46) +Defined in: [packages/angular-query-experimental/src/inject-is-mutating.ts:46](https://github.com/TanStack/query/blob/main/packages/angular-query-experimental/src/inject-is-mutating.ts#L46) Injects a signal that tracks the number of mutations that your application currently has `pending` (useful for app-wide loading indicators). @@ -16,9 +16,9 @@ Injects a signal that tracks the number of mutations that your application curre ### filters? -`MutationFilters`\<`unknown`, `Error`, `unknown`, `unknown`\> +[`MutationFilters`](../interfaces/MutationFilters.md)\<`unknown`, `Error`, `unknown`, `unknown`\> -The MutationFilters to narrow down the matched mutations. +The [MutationFilters](../interfaces/MutationFilters.md) to narrow down the matched mutations. ### options? diff --git a/docs/framework/angular/reference/functions/injectIsRestoring.md b/docs/framework/angular/reference/functions/injectIsRestoring.md index d3b3182cafe..c66a4901ce0 100644 --- a/docs/framework/angular/reference/functions/injectIsRestoring.md +++ b/docs/framework/angular/reference/functions/injectIsRestoring.md @@ -7,7 +7,7 @@ title: injectIsRestoring function injectIsRestoring(options?): Signal; ``` -Defined in: [inject-is-restoring.ts:35](https://github.com/TanStack/query/blob/main/packages/angular-query-experimental/src/inject-is-restoring.ts#L35) +Defined in: [packages/angular-query-experimental/src/inject-is-restoring.ts:35](https://github.com/TanStack/query/blob/main/packages/angular-query-experimental/src/inject-is-restoring.ts#L35) Injects a signal that tracks whether a restore (e.g. from a persisted client, wired up via `provideIsRestoring`) is currently in progress. `injectQuery` and friends also check this internally to diff --git a/docs/framework/angular/reference/functions/injectMutation.md b/docs/framework/angular/reference/functions/injectMutation.md index f5e5169d1c6..b4cca9d4cb3 100644 --- a/docs/framework/angular/reference/functions/injectMutation.md +++ b/docs/framework/angular/reference/functions/injectMutation.md @@ -7,7 +7,7 @@ title: injectMutation function injectMutation(injectMutationFn, options?): CreateMutationResult; ``` -Defined in: [inject-mutation.ts:174](https://github.com/TanStack/query/blob/main/packages/angular-query-experimental/src/inject-mutation.ts#L174) +Defined in: [packages/angular-query-experimental/src/inject-mutation.ts:174](https://github.com/TanStack/query/blob/main/packages/angular-query-experimental/src/inject-mutation.ts#L174) Unlike queries, mutations are typically used to create/update/delete data or perform server side-effects. `injectMutation` is the function for that. Unlike queries, mutations are not run automatically. diff --git a/docs/framework/angular/reference/functions/injectMutationState.md b/docs/framework/angular/reference/functions/injectMutationState.md index 88c3abd5f6a..a96ac308998 100644 --- a/docs/framework/angular/reference/functions/injectMutationState.md +++ b/docs/framework/angular/reference/functions/injectMutationState.md @@ -7,16 +7,16 @@ title: injectMutationState function injectMutationState(injectMutationStateFn, options?): Signal; ``` -Defined in: [inject-mutation-state.ts:106](https://github.com/TanStack/query/blob/main/packages/angular-query-experimental/src/inject-mutation-state.ts#L106) +Defined in: [packages/angular-query-experimental/src/inject-mutation-state.ts:106](https://github.com/TanStack/query/blob/main/packages/angular-query-experimental/src/inject-mutation-state.ts#L106) Injects a signal that gives you access to all mutations in the `MutationCache`. You can pass `filters` -(MutationFilters) to narrow down your mutations, and `select` to transform the mutation state. +([MutationFilters](../interfaces/MutationFilters.md)) to narrow down your mutations, and `select` to transform the mutation state. ## Type Parameters ### TResult -`TResult` = `MutationState`\<`unknown`, `Error`, `unknown`, `unknown`\> +`TResult` = [`MutationState`](../interfaces/MutationState.md)\<`unknown`, `Error`, `unknown`, `unknown`\> ## Parameters diff --git a/docs/framework/angular/reference/functions/injectQuery.md b/docs/framework/angular/reference/functions/injectQuery.md index 8ef9d49cbfa..2dca2d7fb19 100644 --- a/docs/framework/angular/reference/functions/injectQuery.md +++ b/docs/framework/angular/reference/functions/injectQuery.md @@ -9,7 +9,7 @@ title: injectQuery function injectQuery(injectQueryFn, options?): DefinedCreateQueryResult; ``` -Defined in: [inject-query.ts:69](https://github.com/TanStack/query/blob/main/packages/angular-query-experimental/src/inject-query.ts#L69) +Defined in: [packages/angular-query-experimental/src/inject-query.ts:69](https://github.com/TanStack/query/blob/main/packages/angular-query-experimental/src/inject-query.ts#L69) This overload is selected when `initialData` is set on the options returned by `injectQueryFn`, so the resulting `data` signal is never `undefined` (unless a `select` changes `TData` to include `undefined`). @@ -94,7 +94,7 @@ export class Posts { function injectQuery(injectQueryFn, options?): CreateQueryResult; ``` -Defined in: [inject-query.ts:158](https://github.com/TanStack/query/blob/main/packages/angular-query-experimental/src/inject-query.ts#L158) +Defined in: [packages/angular-query-experimental/src/inject-query.ts:158](https://github.com/TanStack/query/blob/main/packages/angular-query-experimental/src/inject-query.ts#L158) Injects a query: a declarative dependency on an asynchronous source of data that is tied to a unique key. @@ -212,7 +212,7 @@ export class Posts { function injectQuery(injectQueryFn, options?): CreateQueryResult; ``` -Defined in: [inject-query.ts:185](https://github.com/TanStack/query/blob/main/packages/angular-query-experimental/src/inject-query.ts#L185) +Defined in: [packages/angular-query-experimental/src/inject-query.ts:185](https://github.com/TanStack/query/blob/main/packages/angular-query-experimental/src/inject-query.ts#L185) This overload accepts the general [CreateQueryOptions](../interfaces/CreateQueryOptions.md) shape rather than the `initialData`-aware overloads above, so whether `data` is defined can't be inferred from the call site — useful when wrapping diff --git a/docs/framework/angular/reference/functions/injectQueryClient.md b/docs/framework/angular/reference/functions/injectQueryClient.md index 58fd08281c1..a6f475f5e62 100644 --- a/docs/framework/angular/reference/functions/injectQueryClient.md +++ b/docs/framework/angular/reference/functions/injectQueryClient.md @@ -7,7 +7,7 @@ title: injectQueryClient function injectQueryClient(injectOptions): QueryClient; ``` -Defined in: [inject-query-client.ts:18](https://github.com/TanStack/query/blob/main/packages/angular-query-experimental/src/inject-query-client.ts#L18) +Defined in: [packages/angular-query-experimental/src/inject-query-client.ts:18](https://github.com/TanStack/query/blob/main/packages/angular-query-experimental/src/inject-query-client.ts#L18) Injects a `QueryClient` instance and allows passing a custom injector. @@ -21,7 +21,7 @@ Type of the options argument to inject and optionally a custom injector. ## Returns -`QueryClient` +[`QueryClient`](../classes/QueryClient.md) The `QueryClient` instance. diff --git a/docs/framework/angular/reference/functions/isCancelledError.md b/docs/framework/angular/reference/functions/isCancelledError.md new file mode 100644 index 00000000000..c8f57c4b94d --- /dev/null +++ b/docs/framework/angular/reference/functions/isCancelledError.md @@ -0,0 +1,24 @@ +--- +id: isCancelledError +title: isCancelledError +--- + +```ts +function isCancelledError(value): value is CancelledError; +``` + +Defined in: [packages/query-core/src/retryer.ts:90](https://github.com/TanStack/query/blob/main/packages/query-core/src/retryer.ts#L90) + +## Parameters + +### value + +`any` + +## Returns + +`value is CancelledError` + +## Deprecated + +Use instanceof `CancelledError` instead. diff --git a/docs/framework/angular/reference/functions/keepPreviousData.md b/docs/framework/angular/reference/functions/keepPreviousData.md new file mode 100644 index 00000000000..6a84f4c5970 --- /dev/null +++ b/docs/framework/angular/reference/functions/keepPreviousData.md @@ -0,0 +1,40 @@ +--- +id: keepPreviousData +title: keepPreviousData +--- + +```ts +function keepPreviousData(previousData): T | undefined; +``` + +Defined in: [packages/query-core/src/utils.ts:493](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L493) + +Intended to be passed as a query's `placeholderData` option, for example +`placeholderData: keepPreviousData`. Instead of resetting the query's data to `undefined` while a new +query key is fetching, it keeps displaying the previously fetched data until the new data arrives. + +## Type Parameters + +### T + +`T` + +## Parameters + +### previousData + +`T` | `undefined` + +## Returns + +`T` \| `undefined` + +## Example + +```ts +new QueryObserver(queryClient, { + queryKey: ['posts', page], + queryFn: () => fetchPosts(page), + placeholderData: keepPreviousData, +}) +``` diff --git a/docs/framework/angular/reference/functions/matchMutation.md b/docs/framework/angular/reference/functions/matchMutation.md new file mode 100644 index 00000000000..40210da4cf1 --- /dev/null +++ b/docs/framework/angular/reference/functions/matchMutation.md @@ -0,0 +1,38 @@ +--- +id: matchMutation +title: matchMutation +--- + +```ts +function matchMutation(filters, mutation): boolean; +``` + +Defined in: [packages/query-core/src/utils.ts:237](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L237) + +Checks whether a mutation matches the given [MutationFilters](../interfaces/MutationFilters.md). +Every filter that is specified must match; filters that are left unspecified are ignored. +If a `mutationKey` filter is provided but the mutation has no `mutationKey` of its own, it does not match. + +## Parameters + +### filters + +[`MutationFilters`](../interfaces/MutationFilters.md) + +### mutation + +[`Mutation`](../classes/Mutation.md)\<`any`, `any`\> + +## Returns + +`boolean` + +## Example + +```ts +const mutationCache = queryClient.getMutationCache() + +const matchingMutations = mutationCache + .getAll() + .filter((mutation) => matchMutation({ mutationKey: ['addPost'] }, mutation)) +``` diff --git a/docs/framework/angular/reference/functions/matchQuery.md b/docs/framework/angular/reference/functions/matchQuery.md new file mode 100644 index 00000000000..4c54b2df995 --- /dev/null +++ b/docs/framework/angular/reference/functions/matchQuery.md @@ -0,0 +1,37 @@ +--- +id: matchQuery +title: matchQuery +--- + +```ts +function matchQuery(filters, query): boolean; +``` + +Defined in: [packages/query-core/src/utils.ts:175](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L175) + +Checks whether a query matches the given [QueryFilters](../interfaces/QueryFilters.md). +Every filter that is specified must match; filters that are left unspecified are ignored. + +## Parameters + +### filters + +[`QueryFilters`](../interfaces/QueryFilters.md) + +### query + +[`Query`](../classes/Query.md)\<`any`, `any`, `any`, `any`\> + +## Returns + +`boolean` + +## Example + +```ts +const queryCache = queryClient.getQueryCache() + +const matchingQueries = queryCache + .getAll() + .filter((query) => matchQuery({ queryKey: ['posts'] }, query)) +``` diff --git a/docs/framework/angular/reference/functions/mutationOptions.md b/docs/framework/angular/reference/functions/mutationOptions.md index b18197c19ad..4b4a987169d 100644 --- a/docs/framework/angular/reference/functions/mutationOptions.md +++ b/docs/framework/angular/reference/functions/mutationOptions.md @@ -9,7 +9,7 @@ title: mutationOptions function mutationOptions(options): WithRequired, "mutationKey">; ``` -Defined in: [mutation-options.ts:40](https://github.com/TanStack/query/blob/main/packages/angular-query-experimental/src/mutation-options.ts#L40) +Defined in: [packages/angular-query-experimental/src/mutation-options.ts:40](https://github.com/TanStack/query/blob/main/packages/angular-query-experimental/src/mutation-options.ts#L40) You can generally pass everything to `mutationOptions` that you can also pass to `injectMutation`. A `mutationKey` is required on this overload so the mutation can be looked up later, e.g. with @@ -37,14 +37,14 @@ You can generally pass everything to `mutationOptions` that you can also pass to #### options -`WithRequired`\<[`CreateMutationOptions`](../interfaces/CreateMutationOptions.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\>, `"mutationKey"`\> +[`WithRequired`](../type-aliases/WithRequired.md)\<[`CreateMutationOptions`](../interfaces/CreateMutationOptions.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\>, `"mutationKey"`\> The mutation options to use, identical to what you'd pass to `injectMutation`, with a required `mutationKey`. ### Returns -`WithRequired`\<[`CreateMutationOptions`](../interfaces/CreateMutationOptions.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\>, `"mutationKey"`\> +[`WithRequired`](../type-aliases/WithRequired.md)\<[`CreateMutationOptions`](../interfaces/CreateMutationOptions.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\>, `"mutationKey"`\> The same options object, unchanged. @@ -85,7 +85,7 @@ export class SavingIndicator { function mutationOptions(options): Omit, "mutationKey">; ``` -Defined in: [mutation-options.ts:98](https://github.com/TanStack/query/blob/main/packages/angular-query-experimental/src/mutation-options.ts#L98) +Defined in: [packages/angular-query-experimental/src/mutation-options.ts:98](https://github.com/TanStack/query/blob/main/packages/angular-query-experimental/src/mutation-options.ts#L98) You can generally pass everything to `mutationOptions` that you can also pass to `injectMutation`. No `mutationKey` is required on this overload — use this when you don't need to target the mutation via a diff --git a/docs/framework/angular/reference/functions/noop.md b/docs/framework/angular/reference/functions/noop.md new file mode 100644 index 00000000000..01fb409f4e9 --- /dev/null +++ b/docs/framework/angular/reference/functions/noop.md @@ -0,0 +1,32 @@ +--- +id: noop +title: noop +--- + +## Call Signature + +```ts +function noop(): void; +``` + +Defined in: [packages/query-core/src/utils.ts:119](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L119) + +A function that does nothing. + +### Returns + +`void` + +## Call Signature + +```ts +function noop(): undefined; +``` + +Defined in: [packages/query-core/src/utils.ts:120](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L120) + +A function that does nothing. + +### Returns + +`undefined` diff --git a/docs/framework/angular/reference/functions/partialMatchKey.md b/docs/framework/angular/reference/functions/partialMatchKey.md new file mode 100644 index 00000000000..4db67323e9b --- /dev/null +++ b/docs/framework/angular/reference/functions/partialMatchKey.md @@ -0,0 +1,26 @@ +--- +id: partialMatchKey +title: partialMatchKey +--- + +```ts +function partialMatchKey(a, b): boolean; +``` + +Defined in: [packages/query-core/src/utils.ts:300](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L300) + +Checks if key `b` partially matches with key `a`. + +## Parameters + +### a + +readonly `unknown`[] + +### b + +readonly `unknown`[] + +## Returns + +`boolean` diff --git a/docs/framework/angular/reference/functions/provideAngularQuery.md b/docs/framework/angular/reference/functions/provideAngularQuery.md index 0efb348b8a0..d77bb0c7b7e 100644 --- a/docs/framework/angular/reference/functions/provideAngularQuery.md +++ b/docs/framework/angular/reference/functions/provideAngularQuery.md @@ -7,7 +7,7 @@ title: provideAngularQuery function provideAngularQuery(queryClient): Provider[]; ``` -Defined in: [providers.ts:121](https://github.com/TanStack/query/blob/main/packages/angular-query-experimental/src/providers.ts#L121) +Defined in: [packages/angular-query-experimental/src/providers.ts:121](https://github.com/TanStack/query/blob/main/packages/angular-query-experimental/src/providers.ts#L121) Sets up providers necessary to enable TanStack Query functionality for Angular applications. @@ -17,7 +17,7 @@ Allows configuring a `QueryClient`. ### queryClient -`QueryClient` +[`QueryClient`](../classes/QueryClient.md) A `QueryClient` instance. diff --git a/docs/framework/angular/reference/functions/provideIsRestoring.md b/docs/framework/angular/reference/functions/provideIsRestoring.md index 44f5f476d3e..cd2847e5ddc 100644 --- a/docs/framework/angular/reference/functions/provideIsRestoring.md +++ b/docs/framework/angular/reference/functions/provideIsRestoring.md @@ -7,7 +7,7 @@ title: provideIsRestoring function provideIsRestoring(isRestoring): Provider; ``` -Defined in: [inject-is-restoring.ts:48](https://github.com/TanStack/query/blob/main/packages/angular-query-experimental/src/inject-is-restoring.ts#L48) +Defined in: [packages/angular-query-experimental/src/inject-is-restoring.ts:48](https://github.com/TanStack/query/blob/main/packages/angular-query-experimental/src/inject-is-restoring.ts#L48) Registers a provider for the restore state read by `injectIsRestoring`. Wire this up wherever you drive a restore yourself — e.g. a persist-client integration — so `injectQuery` and friends can defer subscribing diff --git a/docs/framework/angular/reference/functions/provideQueryClient.md b/docs/framework/angular/reference/functions/provideQueryClient.md index 76ae784100d..a599930ff20 100644 --- a/docs/framework/angular/reference/functions/provideQueryClient.md +++ b/docs/framework/angular/reference/functions/provideQueryClient.md @@ -7,7 +7,7 @@ title: provideQueryClient function provideQueryClient(queryClient): Provider; ``` -Defined in: [providers.ts:22](https://github.com/TanStack/query/blob/main/packages/angular-query-experimental/src/providers.ts#L22) +Defined in: [packages/angular-query-experimental/src/providers.ts:22](https://github.com/TanStack/query/blob/main/packages/angular-query-experimental/src/providers.ts#L22) Usually [provideTanStackQuery](provideTanStackQuery.md) is used once to set up TanStack Query and the [`QueryClient`](https://tanstack.com/query/latest/docs/reference/QueryClient) for the entire application — @@ -20,7 +20,7 @@ it calls `provideQueryClient` internally. Use `provideQueryClient` directly to p A `QueryClient` instance, or an `InjectionToken` which provides a `QueryClient`. -`QueryClient` | `InjectionToken`\<`QueryClient`\> +[`QueryClient`](../classes/QueryClient.md) | `InjectionToken`\<[`QueryClient`](../classes/QueryClient.md)\> ## Returns diff --git a/docs/framework/angular/reference/functions/provideTanStackQuery.md b/docs/framework/angular/reference/functions/provideTanStackQuery.md index e94975d12f8..0113a274dff 100644 --- a/docs/framework/angular/reference/functions/provideTanStackQuery.md +++ b/docs/framework/angular/reference/functions/provideTanStackQuery.md @@ -7,7 +7,7 @@ title: provideTanStackQuery function provideTanStackQuery(queryClient, ...features): Provider[]; ``` -Defined in: [providers.ts:102](https://github.com/TanStack/query/blob/main/packages/angular-query-experimental/src/providers.ts#L102) +Defined in: [packages/angular-query-experimental/src/providers.ts:102](https://github.com/TanStack/query/blob/main/packages/angular-query-experimental/src/providers.ts#L102) Sets up providers necessary to enable TanStack Query functionality for Angular applications. Allows configuring a `QueryClient` and optional features such as developer tools. @@ -18,7 +18,7 @@ configuring a `QueryClient` and optional features such as developer tools. A `QueryClient` instance, or an `InjectionToken` which provides a `QueryClient`. -`QueryClient` | `InjectionToken`\<`QueryClient`\> +[`QueryClient`](../classes/QueryClient.md) | `InjectionToken`\<[`QueryClient`](../classes/QueryClient.md)\> ### features diff --git a/docs/framework/angular/reference/functions/queryFeature.md b/docs/framework/angular/reference/functions/queryFeature.md index 86ef8b1543b..bd2bd0932c0 100644 --- a/docs/framework/angular/reference/functions/queryFeature.md +++ b/docs/framework/angular/reference/functions/queryFeature.md @@ -7,7 +7,7 @@ title: queryFeature function queryFeature(kind, providers): QueryFeature; ``` -Defined in: [providers.ts:143](https://github.com/TanStack/query/blob/main/packages/angular-query-experimental/src/providers.ts#L143) +Defined in: [packages/angular-query-experimental/src/providers.ts:143](https://github.com/TanStack/query/blob/main/packages/angular-query-experimental/src/providers.ts#L143) Helper function to create an object that represents a Query feature. diff --git a/docs/framework/angular/reference/functions/queryOptions.md b/docs/framework/angular/reference/functions/queryOptions.md index c3e6ce6229d..a1c901882e6 100644 --- a/docs/framework/angular/reference/functions/queryOptions.md +++ b/docs/framework/angular/reference/functions/queryOptions.md @@ -9,7 +9,7 @@ title: queryOptions function queryOptions(options): Omit, "queryFn"> & object & QueryKeyWithDataTag; ``` -Defined in: [query-options.ts:151](https://github.com/TanStack/query/blob/main/packages/angular-query-experimental/src/query-options.ts#L151) +Defined in: [packages/angular-query-experimental/src/query-options.ts:151](https://github.com/TanStack/query/blob/main/packages/angular-query-experimental/src/query-options.ts#L151) You can generally pass everything to `queryOptions` that you can also pass to `injectQuery`. These options can be shared across functions and imperative APIs such as `queryClient.fetchQuery`. `options.queryKey` is @@ -91,7 +91,7 @@ export class Posts { function queryOptions(options): OmitKeyof, "queryFn"> & object & QueryKeyWithDataTag; ``` -Defined in: [query-options.ts:200](https://github.com/TanStack/query/blob/main/packages/angular-query-experimental/src/query-options.ts#L200) +Defined in: [packages/angular-query-experimental/src/query-options.ts:200](https://github.com/TanStack/query/blob/main/packages/angular-query-experimental/src/query-options.ts#L200) You can generally pass everything to `queryOptions` that you can also pass to `injectQuery`. These options can be shared across functions and imperative APIs such as `queryClient.fetchQuery`. `options.queryKey` is @@ -168,7 +168,7 @@ export class Post { function queryOptions(options): CreateQueryOptions & object & QueryKeyWithDataTag; ``` -Defined in: [query-options.ts:281](https://github.com/TanStack/query/blob/main/packages/angular-query-experimental/src/query-options.ts#L281) +Defined in: [packages/angular-query-experimental/src/query-options.ts:281](https://github.com/TanStack/query/blob/main/packages/angular-query-experimental/src/query-options.ts#L281) You can generally pass everything to `queryOptions` that you can also pass to `injectQuery`. These options can be shared across functions and imperative APIs such as `queryClient.fetchQuery`. `options.queryKey` is diff --git a/docs/framework/angular/reference/functions/replaceEqualDeep.md b/docs/framework/angular/reference/functions/replaceEqualDeep.md new file mode 100644 index 00000000000..6a81c3907fb --- /dev/null +++ b/docs/framework/angular/reference/functions/replaceEqualDeep.md @@ -0,0 +1,41 @@ +--- +id: replaceEqualDeep +title: replaceEqualDeep +--- + +```ts +function replaceEqualDeep( + a, + b, + depth?): T; +``` + +Defined in: [packages/query-core/src/utils.ts:339](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L339) + +This function returns `a` if `b` is deeply equal. +If not, it will replace any deeply equal children of `b` with those of `a`. +This can be used for structural sharing between JSON values for example. + +## Type Parameters + +### T + +`T` + +## Parameters + +### a + +`unknown` + +### b + +`T` + +### depth? + +`number` + +## Returns + +`T` diff --git a/docs/framework/angular/reference/functions/shouldThrowError.md b/docs/framework/angular/reference/functions/shouldThrowError.md new file mode 100644 index 00000000000..1f1e62a8d0e --- /dev/null +++ b/docs/framework/angular/reference/functions/shouldThrowError.md @@ -0,0 +1,45 @@ +--- +id: shouldThrowError +title: shouldThrowError +--- + +```ts +function shouldThrowError(throwOnError, params): boolean; +``` + +Defined in: [packages/query-core/src/utils.ts:576](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L576) + +Resolves a `throwOnError` option to a boolean. +If `throwOnError` is a function, it is called with `params` (e.g. the error and, depending on the caller, +additional context such as the query or mutation) and its result is returned, allowing the throwing +behavior to be decided per error. Otherwise, `throwOnError` itself is coerced to a boolean (`undefined` +resolves to `false`). + +## Type Parameters + +### T + +`T` *extends* (...`args`) => `boolean` + +## Parameters + +### throwOnError + +`boolean` | `T` | `undefined` + +### params + +`Parameters`\<`T`\> + +## Returns + +`boolean` + +## Example + +```ts +const throwOnError = + query.state.error && typeof options.throwOnError === 'function' + ? shouldThrowError(options.throwOnError, [query.state.error, query]) + : options.throwOnError +``` diff --git a/docs/framework/angular/reference/index.md b/docs/framework/angular/reference/index.md index 12ae163fcd1..4b10910da24 100644 --- a/docs/framework/angular/reference/index.md +++ b/docs/framework/angular/reference/index.md @@ -3,24 +3,96 @@ id: "@tanstack/angular-query-experimental" title: "@tanstack/angular-query-experimental" --- +## Classes + +- [CancelledError](classes/CancelledError.md) +- [InfiniteQueryObserver](classes/InfiniteQueryObserver.md) +- [Mutation](classes/Mutation.md) +- [MutationCache](classes/MutationCache.md) +- [MutationObserver](classes/MutationObserver.md) +- [QueriesObserver](classes/QueriesObserver.md) +- [Query](classes/Query.md) +- [QueryCache](classes/QueryCache.md) +- [QueryClient](classes/QueryClient.md) +- [QueryObserver](classes/QueryObserver.md) + ## Interfaces - [BaseMutationNarrowing](interfaces/BaseMutationNarrowing.md) - [BaseQueryNarrowing](interfaces/BaseQueryNarrowing.md) +- [CancelOptions](interfaces/CancelOptions.md) - [CreateBaseQueryOptions](interfaces/CreateBaseQueryOptions.md) - [CreateInfiniteQueryOptions](interfaces/CreateInfiniteQueryOptions.md) - [CreateMutationOptions](interfaces/CreateMutationOptions.md) - [CreateQueryOptions](interfaces/CreateQueryOptions.md) +- [DefaultOptions](interfaces/DefaultOptions.md) +- [DehydratedState](interfaces/DehydratedState.md) +- [DehydrateOptions](interfaces/DehydrateOptions.md) +- [~~EnsureQueryDataOptions~~](interfaces/EnsureQueryDataOptions.md) +- [FetchNextPageOptions](interfaces/FetchNextPageOptions.md) +- [FetchPreviousPageOptions](interfaces/FetchPreviousPageOptions.md) +- [~~FetchQueryOptions~~](interfaces/FetchQueryOptions.md) +- [FocusManager](interfaces/FocusManager.md) +- [HydrateOptions](interfaces/HydrateOptions.md) +- [InfiniteData](interfaces/InfiniteData.md) +- [InfiniteQueryObserverBaseResult](interfaces/InfiniteQueryObserverBaseResult.md) +- [InfiniteQueryObserverLoadingErrorResult](interfaces/InfiniteQueryObserverLoadingErrorResult.md) +- [InfiniteQueryObserverLoadingResult](interfaces/InfiniteQueryObserverLoadingResult.md) +- [InfiniteQueryObserverOptions](interfaces/InfiniteQueryObserverOptions.md) +- [InfiniteQueryObserverPendingResult](interfaces/InfiniteQueryObserverPendingResult.md) +- [InfiniteQueryObserverPlaceholderResult](interfaces/InfiniteQueryObserverPlaceholderResult.md) +- [InfiniteQueryObserverRefetchErrorResult](interfaces/InfiniteQueryObserverRefetchErrorResult.md) +- [InfiniteQueryObserverSuccessResult](interfaces/InfiniteQueryObserverSuccessResult.md) +- [InfiniteQueryPageParamsOptions](interfaces/InfiniteQueryPageParamsOptions.md) +- [InitialPageParam](interfaces/InitialPageParam.md) - [InjectInfiniteQueryOptions](interfaces/InjectInfiniteQueryOptions.md) - [InjectIsFetchingOptions](interfaces/InjectIsFetchingOptions.md) - [InjectIsMutatingOptions](interfaces/InjectIsMutatingOptions.md) - [InjectMutationOptions](interfaces/InjectMutationOptions.md) - [InjectMutationStateOptions](interfaces/InjectMutationStateOptions.md) - [InjectQueryOptions](interfaces/InjectQueryOptions.md) +- [InvalidateOptions](interfaces/InvalidateOptions.md) +- [InvalidateQueryFilters](interfaces/InvalidateQueryFilters.md) +- [MutateOptions](interfaces/MutateOptions.md) +- [MutationCacheConfig](interfaces/MutationCacheConfig.md) +- [MutationFilters](interfaces/MutationFilters.md) +- [MutationObserverBaseResult](interfaces/MutationObserverBaseResult.md) +- [MutationObserverErrorResult](interfaces/MutationObserverErrorResult.md) +- [MutationObserverIdleResult](interfaces/MutationObserverIdleResult.md) +- [MutationObserverLoadingResult](interfaces/MutationObserverLoadingResult.md) +- [MutationObserverOptions](interfaces/MutationObserverOptions.md) +- [MutationObserverSuccessResult](interfaces/MutationObserverSuccessResult.md) +- [MutationOptions](interfaces/MutationOptions.md) +- [MutationState](interfaces/MutationState.md) +- [NotifyEvent](interfaces/NotifyEvent.md) +- [OnlineManager](interfaces/OnlineManager.md) +- [QueriesObserverOptions](interfaces/QueriesObserverOptions.md) +- [QueryCacheConfig](interfaces/QueryCacheConfig.md) +- [QueryClientConfig](interfaces/QueryClientConfig.md) +- [QueryExecuteOptions](interfaces/QueryExecuteOptions.md) - [QueryFeature](interfaces/QueryFeature.md) +- [QueryFilters](interfaces/QueryFilters.md) +- [QueryObserverBaseResult](interfaces/QueryObserverBaseResult.md) +- [QueryObserverLoadingErrorResult](interfaces/QueryObserverLoadingErrorResult.md) +- [QueryObserverLoadingResult](interfaces/QueryObserverLoadingResult.md) +- [QueryObserverOptions](interfaces/QueryObserverOptions.md) +- [QueryObserverPendingResult](interfaces/QueryObserverPendingResult.md) +- [QueryObserverPlaceholderResult](interfaces/QueryObserverPlaceholderResult.md) +- [QueryObserverRefetchErrorResult](interfaces/QueryObserverRefetchErrorResult.md) +- [QueryObserverSuccessResult](interfaces/QueryObserverSuccessResult.md) +- [QueryOptions](interfaces/QueryOptions.md) +- [QueryState](interfaces/QueryState.md) +- [RefetchOptions](interfaces/RefetchOptions.md) +- [RefetchQueryFilters](interfaces/RefetchQueryFilters.md) +- [Register](interfaces/Register.md) +- [ResetOptions](interfaces/ResetOptions.md) +- [ResultOptions](interfaces/ResultOptions.md) +- [SetDataOptions](interfaces/SetDataOptions.md) +- [TimeoutManager](interfaces/TimeoutManager.md) ## Type Aliases +- [AnyDataTag](type-aliases/AnyDataTag.md) - [CreateBaseMutationResult](type-aliases/CreateBaseMutationResult.md) - [CreateBaseQueryResult](type-aliases/CreateBaseQueryResult.md) - [CreateInfiniteQueryResult](type-aliases/CreateInfiniteQueryResult.md) @@ -28,22 +100,101 @@ title: "@tanstack/angular-query-experimental" - [CreateMutateFunction](type-aliases/CreateMutateFunction.md) - [CreateMutationResult](type-aliases/CreateMutationResult.md) - [CreateQueryResult](type-aliases/CreateQueryResult.md) +- [DataTag](type-aliases/DataTag.md) +- [dataTagErrorSymbol](type-aliases/dataTagErrorSymbol.md) +- [dataTagSymbol](type-aliases/dataTagSymbol.md) +- [DefaultedInfiniteQueryObserverOptions](type-aliases/DefaultedInfiniteQueryObserverOptions.md) +- [DefaultedQueryObserverOptions](type-aliases/DefaultedQueryObserverOptions.md) +- [DefaultError](type-aliases/DefaultError.md) - [DefinedCreateInfiniteQueryResult](type-aliases/DefinedCreateInfiniteQueryResult.md) - [DefinedCreateQueryResult](type-aliases/DefinedCreateQueryResult.md) +- [DefinedInfiniteQueryObserverResult](type-aliases/DefinedInfiniteQueryObserverResult.md) - [DefinedInitialDataInfiniteOptions](type-aliases/DefinedInitialDataInfiniteOptions.md) - [DefinedInitialDataOptions](type-aliases/DefinedInitialDataOptions.md) +- [DefinedQueryObserverResult](type-aliases/DefinedQueryObserverResult.md) - [DevtoolsFeature](type-aliases/DevtoolsFeature.md) +- [DistributiveOmit](type-aliases/DistributiveOmit.md) +- [~~EnsureInfiniteQueryDataOptions~~](type-aliases/EnsureInfiniteQueryDataOptions.md) +- [~~FetchInfiniteQueryOptions~~](type-aliases/FetchInfiniteQueryOptions.md) +- [FetchStatus](type-aliases/FetchStatus.md) +- [GetNextPageParamFunction](type-aliases/GetNextPageParamFunction.md) +- [GetPreviousPageParamFunction](type-aliases/GetPreviousPageParamFunction.md) +- [InferDataFromTag](type-aliases/InferDataFromTag.md) +- [InferErrorFromTag](type-aliases/InferErrorFromTag.md) +- [InfiniteQueryExecuteOptions](type-aliases/InfiniteQueryExecuteOptions.md) +- [InfiniteQueryObserverResult](type-aliases/InfiniteQueryObserverResult.md) +- [InitialDataFunction](type-aliases/InitialDataFunction.md) +- [ManagedTimerId](type-aliases/ManagedTimerId.md) +- [MutateFunction](type-aliases/MutateFunction.md) +- [MutateFunctionRest](type-aliases/MutateFunctionRest.md) +- [MutationCacheNotifyEvent](type-aliases/MutationCacheNotifyEvent.md) +- [MutationFunction](type-aliases/MutationFunction.md) +- [MutationFunctionContext](type-aliases/MutationFunctionContext.md) +- [MutationKey](type-aliases/MutationKey.md) +- [MutationMeta](type-aliases/MutationMeta.md) +- [MutationObserverResult](type-aliases/MutationObserverResult.md) +- [MutationScope](type-aliases/MutationScope.md) +- [MutationStatus](type-aliases/MutationStatus.md) +- [NetworkMode](type-aliases/NetworkMode.md) +- [NonUndefinedGuard](type-aliases/NonUndefinedGuard.md) +- [NotifyEventType](type-aliases/NotifyEventType.md) +- [NotifyOnChangeProps](type-aliases/NotifyOnChangeProps.md) +- [OmitKeyof](type-aliases/OmitKeyof.md) +- [Override](type-aliases/Override.md) - [PersistQueryClientFeature](type-aliases/PersistQueryClientFeature.md) +- [PlaceholderDataFunction](type-aliases/PlaceholderDataFunction.md) - [QueriesOptions](type-aliases/QueriesOptions.md) +- [QueriesPlaceholderDataFunction](type-aliases/QueriesPlaceholderDataFunction.md) - [QueriesResults](type-aliases/QueriesResults.md) +- [QueryBooleanOption](type-aliases/QueryBooleanOption.md) +- [QueryCacheNotifyEvent](type-aliases/QueryCacheNotifyEvent.md) - [QueryFeatures](type-aliases/QueryFeatures.md) +- [QueryFunction](type-aliases/QueryFunction.md) +- [QueryFunctionContext](type-aliases/QueryFunctionContext.md) +- [QueryKey](type-aliases/QueryKey.md) +- [QueryKeyHashFunction](type-aliases/QueryKeyHashFunction.md) +- [QueryKeyWithDataTag](type-aliases/QueryKeyWithDataTag.md) +- [QueryMeta](type-aliases/QueryMeta.md) +- [QueryObserverResult](type-aliases/QueryObserverResult.md) +- [QueryPersister](type-aliases/QueryPersister.md) +- [QueryStatus](type-aliases/QueryStatus.md) +- [SkipToken](type-aliases/SkipToken.md) +- [StaleTime](type-aliases/StaleTime.md) +- [StaleTimeFunction](type-aliases/StaleTimeFunction.md) +- [ThrowOnError](type-aliases/ThrowOnError.md) +- [TimeoutCallback](type-aliases/TimeoutCallback.md) +- [TimeoutProvider](type-aliases/TimeoutProvider.md) - [UndefinedInitialDataInfiniteOptions](type-aliases/UndefinedInitialDataInfiniteOptions.md) - [UndefinedInitialDataOptions](type-aliases/UndefinedInitialDataOptions.md) +- [UnsetMarker](type-aliases/UnsetMarker.md) - [UnusedSkipTokenInfiniteOptions](type-aliases/UnusedSkipTokenInfiniteOptions.md) - [UnusedSkipTokenOptions](type-aliases/UnusedSkipTokenOptions.md) +- [Updater](type-aliases/Updater.md) +- [WithRequired](type-aliases/WithRequired.md) + +## Variables + +- [dataTagErrorSymbol](variables/dataTagErrorSymbol.md) +- [dataTagSymbol](variables/dataTagSymbol.md) +- [defaultScheduler](variables/defaultScheduler.md) +- [environmentManager](variables/environmentManager.md) +- [focusManager](variables/focusManager.md) +- [~~isServer~~](variables/isServer.md) +- [notifyManager](variables/notifyManager.md) +- [onlineManager](variables/onlineManager.md) +- [skipToken](variables/skipToken.md) +- [timeoutManager](variables/timeoutManager.md) +- [unsetMarker](variables/unsetMarker.md) ## Functions +- [defaultShouldDehydrateMutation](functions/defaultShouldDehydrateMutation.md) +- [defaultShouldDehydrateQuery](functions/defaultShouldDehydrateQuery.md) +- [dehydrate](functions/dehydrate.md) +- [dehydrateQuery](functions/dehydrateQuery.md) +- [experimental\_streamedQuery](functions/experimental_streamedQuery.md) +- [hashKey](functions/hashKey.md) +- [hydrate](functions/hydrate.md) - [infiniteQueryOptions](functions/infiniteQueryOptions.md) - [injectInfiniteQuery](functions/injectInfiniteQuery.md) - [injectIsFetching](functions/injectIsFetching.md) @@ -53,10 +204,18 @@ title: "@tanstack/angular-query-experimental" - [injectMutationState](functions/injectMutationState.md) - [injectQuery](functions/injectQuery.md) - [~~injectQueryClient~~](functions/injectQueryClient.md) +- [~~isCancelledError~~](functions/isCancelledError.md) +- [keepPreviousData](functions/keepPreviousData.md) +- [matchMutation](functions/matchMutation.md) +- [matchQuery](functions/matchQuery.md) - [mutationOptions](functions/mutationOptions.md) +- [noop](functions/noop.md) +- [partialMatchKey](functions/partialMatchKey.md) - [~~provideAngularQuery~~](functions/provideAngularQuery.md) - [provideIsRestoring](functions/provideIsRestoring.md) - [provideQueryClient](functions/provideQueryClient.md) - [provideTanStackQuery](functions/provideTanStackQuery.md) - [queryFeature](functions/queryFeature.md) - [queryOptions](functions/queryOptions.md) +- [replaceEqualDeep](functions/replaceEqualDeep.md) +- [shouldThrowError](functions/shouldThrowError.md) diff --git a/docs/framework/angular/reference/interfaces/BaseMutationNarrowing.md b/docs/framework/angular/reference/interfaces/BaseMutationNarrowing.md index 5ea77a60815..6a148af0310 100644 --- a/docs/framework/angular/reference/interfaces/BaseMutationNarrowing.md +++ b/docs/framework/angular/reference/interfaces/BaseMutationNarrowing.md @@ -3,7 +3,7 @@ id: BaseMutationNarrowing title: BaseMutationNarrowing --- -Defined in: [types.ts:328](https://github.com/TanStack/query/blob/main/packages/angular-query-experimental/src/types.ts#L328) +Defined in: [packages/angular-query-experimental/src/types.ts:328](https://github.com/TanStack/query/blob/main/packages/angular-query-experimental/src/types.ts#L328) The `isSuccess`/`isError`/`isPending`/`isIdle` methods on a mutation result. Each is both a `Signal` (its current boolean value is read reactively without calling it) and a type-guard function you can @@ -19,7 +19,7 @@ The type your mutation function resolves to. ### TError -`TError` = `DefaultError` +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) The type of errors your mutation function may throw. @@ -44,7 +44,7 @@ their `onMutateResult` parameter — useful for optimistic-update rollback data. isError: SignalFunction<(this) => this is CreateMutationResult, { mutate: CreateMutateFunction }> & { mutateAsync: CreateMutateAsyncFunction }>>; ``` -Defined in: [types.ts:351](https://github.com/TanStack/query/blob/main/packages/angular-query-experimental/src/types.ts#L351) +Defined in: [packages/angular-query-experimental/src/types.ts:351](https://github.com/TanStack/query/blob/main/packages/angular-query-experimental/src/types.ts#L351) *** @@ -54,7 +54,7 @@ Defined in: [types.ts:351](https://github.com/TanStack/query/blob/main/packages/ isIdle: SignalFunction<(this) => this is CreateMutationResult, { mutate: CreateMutateFunction }> & { mutateAsync: CreateMutateAsyncFunction }>>; ``` -Defined in: [types.ts:385](https://github.com/TanStack/query/blob/main/packages/angular-query-experimental/src/types.ts#L385) +Defined in: [packages/angular-query-experimental/src/types.ts:385](https://github.com/TanStack/query/blob/main/packages/angular-query-experimental/src/types.ts#L385) *** @@ -64,7 +64,7 @@ Defined in: [types.ts:385](https://github.com/TanStack/query/blob/main/packages/ isPending: SignalFunction<(this) => this is CreateMutationResult, { mutate: CreateMutateFunction }> & { mutateAsync: CreateMutateAsyncFunction }>>; ``` -Defined in: [types.ts:368](https://github.com/TanStack/query/blob/main/packages/angular-query-experimental/src/types.ts#L368) +Defined in: [packages/angular-query-experimental/src/types.ts:368](https://github.com/TanStack/query/blob/main/packages/angular-query-experimental/src/types.ts#L368) *** @@ -74,4 +74,4 @@ Defined in: [types.ts:368](https://github.com/TanStack/query/blob/main/packages/ isSuccess: SignalFunction<(this) => this is CreateMutationResult, { mutate: CreateMutateFunction }> & { mutateAsync: CreateMutateAsyncFunction }>>; ``` -Defined in: [types.ts:334](https://github.com/TanStack/query/blob/main/packages/angular-query-experimental/src/types.ts#L334) +Defined in: [packages/angular-query-experimental/src/types.ts:334](https://github.com/TanStack/query/blob/main/packages/angular-query-experimental/src/types.ts#L334) diff --git a/docs/framework/angular/reference/interfaces/BaseQueryNarrowing.md b/docs/framework/angular/reference/interfaces/BaseQueryNarrowing.md index eaf5decb7bf..48ebe0aa8c7 100644 --- a/docs/framework/angular/reference/interfaces/BaseQueryNarrowing.md +++ b/docs/framework/angular/reference/interfaces/BaseQueryNarrowing.md @@ -3,7 +3,7 @@ id: BaseQueryNarrowing title: BaseQueryNarrowing --- -Defined in: [types.ts:83](https://github.com/TanStack/query/blob/main/packages/angular-query-experimental/src/types.ts#L83) +Defined in: [packages/angular-query-experimental/src/types.ts:83](https://github.com/TanStack/query/blob/main/packages/angular-query-experimental/src/types.ts#L83) The `isSuccess`/`isError`/`isPending` methods on a query result. Unlike `react-query`'s derived booleans, these are type-guard methods you call — `if (query.isSuccess())` — so that `query.data` narrows away @@ -20,7 +20,7 @@ The type `data` ends up as after `select` runs. ### TError -`TError` = `DefaultError` +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) The type of errors your `queryFn` may throw. @@ -32,7 +32,7 @@ The type of errors your `queryFn` may throw. isError: (this) => this is CreateBaseQueryResult>; ``` -Defined in: [types.ts:91](https://github.com/TanStack/query/blob/main/packages/angular-query-experimental/src/types.ts#L91) +Defined in: [packages/angular-query-experimental/src/types.ts:91](https://github.com/TanStack/query/blob/main/packages/angular-query-experimental/src/types.ts#L91) #### Parameters @@ -52,7 +52,7 @@ Defined in: [types.ts:91](https://github.com/TanStack/query/blob/main/packages/a isPending: (this) => this is CreateBaseQueryResult>; ``` -Defined in: [types.ts:98](https://github.com/TanStack/query/blob/main/packages/angular-query-experimental/src/types.ts#L98) +Defined in: [packages/angular-query-experimental/src/types.ts:98](https://github.com/TanStack/query/blob/main/packages/angular-query-experimental/src/types.ts#L98) #### Parameters @@ -72,7 +72,7 @@ Defined in: [types.ts:98](https://github.com/TanStack/query/blob/main/packages/a isSuccess: (this) => this is CreateBaseQueryResult>; ``` -Defined in: [types.ts:84](https://github.com/TanStack/query/blob/main/packages/angular-query-experimental/src/types.ts#L84) +Defined in: [packages/angular-query-experimental/src/types.ts:84](https://github.com/TanStack/query/blob/main/packages/angular-query-experimental/src/types.ts#L84) #### Parameters diff --git a/docs/framework/angular/reference/interfaces/CancelOptions.md b/docs/framework/angular/reference/interfaces/CancelOptions.md new file mode 100644 index 00000000000..b7464c48e50 --- /dev/null +++ b/docs/framework/angular/reference/interfaces/CancelOptions.md @@ -0,0 +1,26 @@ +--- +id: CancelOptions +title: CancelOptions +--- + +Defined in: [packages/query-core/src/types.ts:1521](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1521) + +## Properties + +### revert? + +```ts +optional revert: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1522](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1522) + +*** + +### silent? + +```ts +optional silent: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1523](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1523) diff --git a/docs/framework/angular/reference/interfaces/CreateBaseQueryOptions.md b/docs/framework/angular/reference/interfaces/CreateBaseQueryOptions.md index f563462798b..c2f4508ffbc 100644 --- a/docs/framework/angular/reference/interfaces/CreateBaseQueryOptions.md +++ b/docs/framework/angular/reference/interfaces/CreateBaseQueryOptions.md @@ -3,15 +3,15 @@ id: CreateBaseQueryOptions title: CreateBaseQueryOptions --- -Defined in: [types.ts:34](https://github.com/TanStack/query/blob/main/packages/angular-query-experimental/src/types.ts#L34) +Defined in: [packages/angular-query-experimental/src/types.ts:34](https://github.com/TanStack/query/blob/main/packages/angular-query-experimental/src/types.ts#L34) The options shared across `angular-query-experimental`'s query functions. Extends -QueryObserverOptions from `@tanstack/query-core` as-is — unlike `react-query`, +[QueryObserverOptions](QueryObserverOptions.md) from `@tanstack/query-core` as-is — unlike `react-query`, `angular-query-experimental` has no extra framework-specific option here. ## Extends -- `QueryObserverOptions`\<`TQueryFnData`, `TError`, `TData`, `TQueryData`, `TQueryKey`\> +- [`QueryObserverOptions`](QueryObserverOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryData`, `TQueryKey`\> ## Type Parameters @@ -23,7 +23,7 @@ The type your `queryFn` resolves to. ### TError -`TError` = `DefaultError` +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) The type of errors your `queryFn` may throw. @@ -43,6 +43,594 @@ The type of the data actually held in the query cache — the input to `select` ### TQueryKey -`TQueryKey` *extends* `QueryKey` = `QueryKey` +`TQueryKey` *extends* [`QueryKey`](../type-aliases/QueryKey.md) = [`QueryKey`](../type-aliases/QueryKey.md) The type of your `queryKey`. + +## Properties + +### enabled? + +```ts +optional enabled: QueryBooleanOption; +``` + +Defined in: [packages/query-core/src/types.ts:398](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L398) + +Set this to `false` or a function that returns `false` to disable automatic refetching when the query mounts or changes query keys. +To refetch the query, use the `refetch` method returned from the `useQuery` instance. +Accepts a boolean or function that returns a boolean. + +Defaults to `true`. + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`enabled`](QueryObserverOptions.md#enabled) + +*** + +### gcTime? + +```ts +optional gcTime: number; +``` + +Defined in: [packages/query-core/src/types.ts:277](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L277) + +The time in milliseconds that unused/inactive cache data remains in memory. +When a query's cache becomes unused or inactive, that cache data will be garbage collected after this duration. +When different garbage collection times are specified, the longest one will be used. +Setting it to `Infinity` will disable garbage collection. + +Defaults to `5 * 60 * 1000` (5 minutes), or `Infinity` during SSR. + +Note: the maximum allowed time is about 24 days, imposed by `setTimeout`'s 32-bit signed integer delay — see +`timeoutManager.setTimeoutProvider` for a workaround. + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`gcTime`](QueryObserverOptions.md#gctime) + +*** + +### initialData? + +```ts +optional initialData: + | TQueryData +| InitialDataFunction; +``` + +Defined in: [packages/query-core/src/types.ts:317](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L317) + +If set, this value will be used as the initial data for the query cache (as long as the query hasn't been +created or cached yet). +If set to a function, the function will be called **once** during the shared/root query initialization, and be +expected to synchronously return the initial data. +Initial data is considered stale by default unless a `staleTime` has been set. +`initialData` **is persisted** to the cache. + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`initialData`](QueryObserverOptions.md#initialdata) + +*** + +### initialDataUpdatedAt? + +```ts +optional initialDataUpdatedAt: number | () => number | undefined; +``` + +Defined in: [packages/query-core/src/types.ts:321](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L321) + +If set, this value will be used as the time (in milliseconds) of when the `initialData` itself was last updated. + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`initialDataUpdatedAt`](QueryObserverOptions.md#initialdataupdatedat) + +*** + +### maxPages? + +```ts +optional maxPages: number; +``` + +Defined in: [packages/query-core/src/types.ts:345](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L345) + +Maximum number of pages to store in the data of an infinite query. + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`maxPages`](QueryObserverOptions.md#maxpages) + +*** + +### meta? + +```ts +optional meta: Record; +``` + +Defined in: [packages/query-core/src/types.ts:341](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L341) + +Additional payload to be stored on each query. +Use this property to pass information that can be used in other places. + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`meta`](QueryObserverOptions.md#meta) + +*** + +### networkMode? + +```ts +optional networkMode: NetworkMode; +``` + +Defined in: [packages/query-core/src/types.ts:265](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L265) + +Controls whether a query is allowed to run based on the current network connectivity. + +Defaults to `'online'`. + +#### See + +[Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`networkMode`](QueryObserverOptions.md#networkmode) + +*** + +### notifyOnChangeProps? + +```ts +optional notifyOnChangeProps: NotifyOnChangeProps; +``` + +Defined in: [packages/query-core/src/types.ts:484](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L484) + +If set, the component will only re-render if any of the listed properties change. +When set to `['data', 'error']`, the component will only re-render when the `data` or `error` properties change. +When set to `'all'`, the component will re-render whenever a query is updated. +When set to a function, the function will be executed to compute the list of properties. + +Defaults to `undefined`, in which case property access is tracked automatically, and the +component only re-renders when one of the tracked properties changes. + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`notifyOnChangeProps`](QueryObserverOptions.md#notifyonchangeprops) + +*** + +### persister()? + +```ts +optional persister: (queryFn, context, query) => TQueryFnData | Promise; +``` + +Defined in: [packages/query-core/src/types.ts:290](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L290) + +This option can be used to persist the result of a query to an external storage, bypassing the need to actually +call the `queryFn`. Useful for persisting a query's data across e.g. server/client boundaries. + +#### Parameters + +##### queryFn + +[`QueryFunction`](../type-aliases/QueryFunction.md)\<`TQueryFnData`, `NoInfer`\<`TQueryKey`\>, `never`\> + +##### context + +###### client + +[`QueryClient`](../classes/QueryClient.md) + +###### direction? + +`unknown` + +**Deprecated** + +if you want access to the direction, you can add it to the pageParam + +###### meta + +`Record`\<`string`, `unknown`\> \| `undefined` + +###### pageParam? + +`unknown` + +###### queryKey + +`NoInfer`\<`TQueryKey`\> + +###### signal + +`AbortSignal` + +##### query + +[`Query`](../classes/Query.md) + +#### Returns + +`TQueryFnData` \| `Promise`\<`TQueryFnData`\> + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`persister`](QueryObserverOptions.md#persister) + +*** + +### placeholderData? + +```ts +optional placeholderData: + | NonFunctionGuard +| PlaceholderDataFunction, TError, NonFunctionGuard, TQueryKey>; +``` + +Defined in: [packages/query-core/src/types.ts:511](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L511) + +If set, this value will be used as the placeholder data for this particular query observer while the query is still in the `loading` data and no initialData has been provided. + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`placeholderData`](QueryObserverOptions.md#placeholderdata) + +*** + +### queryFn? + +```ts +optional queryFn: + | typeof skipToken +| QueryFunction; +``` + +Defined in: [packages/query-core/src/types.ts:285](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L285) + +The function that the query will use to request data. +Required, unless a default query function has been set via `queryClient.setQueryDefaults` or +`queryClient.setDefaultOptions`. +Receives a [QueryFunctionContext](../type-aliases/QueryFunctionContext.md). +Must return a promise that will either resolve data or throw an error. The data cannot be `undefined`. + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`queryFn`](QueryObserverOptions.md#queryfn) + +*** + +### queryHash? + +```ts +optional queryHash: string; +``` + +Defined in: [packages/query-core/src/types.ts:295](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L295) + +The hashed form of `queryKey`, computed with `queryKeyHashFn` (or the default hashing function otherwise). Used +as the actual cache key internally. + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`queryHash`](QueryObserverOptions.md#queryhash) + +*** + +### queryKey + +```ts +queryKey: TQueryKey & object; +``` + +Defined in: [packages/query-core/src/types.ts:304](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L304) + +The query key to use for this query. + +The query key will be hashed into a stable hash. See [Query Keys](https://tanstack.com/query/latest/docs/framework/react/guides/query-keys) +for more information. + +The query will automatically update when this key changes (as long as `enabled` is not set to `false`). + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`queryKey`](QueryObserverOptions.md#querykey) + +*** + +### queryKeyHashFn? + +```ts +optional queryKeyHashFn: QueryKeyHashFunction; +``` + +Defined in: [packages/query-core/src/types.ts:308](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L308) + +If specified, this function is used to hash the `queryKey` to a string. + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`queryKeyHashFn`](QueryObserverOptions.md#querykeyhashfn) + +*** + +### refetchInterval? + +```ts +optional refetchInterval: number | false | (query) => number | false | undefined; +``` + +Defined in: [packages/query-core/src/types.ts:414](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L414) + +If set to a number, the query will continuously refetch at this frequency in milliseconds. +If set to a function, the function will be executed with the latest data and query to compute a frequency + +Defaults to `false`. + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`refetchInterval`](QueryObserverOptions.md#refetchinterval) + +*** + +### refetchIntervalInBackground? + +```ts +optional refetchIntervalInBackground: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:425](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L425) + +If set to `true`, the query will continue to refetch while their tab/window is in the background. + +Defaults to `false`. + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`refetchIntervalInBackground`](QueryObserverOptions.md#refetchintervalinbackground) + +*** + +### refetchOnMount? + +```ts +optional refetchOnMount: boolean | "always" | (query) => boolean | "always"; +``` + +Defined in: [packages/query-core/src/types.ts:462](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L462) + +If set to `true`, the query will refetch on mount if the data is stale. +If set to `false`, will disable additional instances of a query to trigger background refetch. +If set to `'always'`, the query will always refetch on mount (except when `staleTime: 'static'` is used). +If set to a function, the function will be executed with the latest data and query to compute the value + +Defaults to `true`. + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`refetchOnMount`](QueryObserverOptions.md#refetchonmount) + +*** + +### refetchOnReconnect? + +```ts +optional refetchOnReconnect: boolean | "always" | (query) => boolean | "always"; +``` + +Defined in: [packages/query-core/src/types.ts:448](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L448) + +If set to `true`, the query will refetch on reconnect if the data is stale. +If set to `false`, the query will not refetch on reconnect. +If set to `'always'`, the query will always refetch on reconnect (except when `staleTime: 'static'` is used). +If set to a function, the function will be executed with the latest data and query to compute the value. + +Defaults to `true` unless `networkMode` is `'always'`. + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`refetchOnReconnect`](QueryObserverOptions.md#refetchonreconnect) + +*** + +### refetchOnWindowFocus? + +```ts +optional refetchOnWindowFocus: boolean | "always" | (query) => boolean | "always"; +``` + +Defined in: [packages/query-core/src/types.ts:434](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L434) + +If set to `true`, the query will refetch on window focus if the data is stale. +If set to `false`, the query will not refetch on window focus. +If set to `'always'`, the query will always refetch on window focus (except when `staleTime: 'static'` is used). +If set to a function, the function will be executed with the latest data and query to compute the value. + +Defaults to `true`. + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`refetchOnWindowFocus`](QueryObserverOptions.md#refetchonwindowfocus) + +*** + +### retry? + +```ts +optional retry: RetryValue; +``` + +Defined in: [packages/query-core/src/types.ts:246](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L246) + +If `false`, failed queries will not retry by default. +If `true`, failed queries will retry infinitely. +If set to an integer number, e.g. 3, failed queries will retry until the failed query count meets that number. +If set to a function `(failureCount, error) => boolean` failed queries will retry until the function returns false. + +Defaults to `3` on the client and `0` on the server. + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`retry`](QueryObserverOptions.md#retry) + +*** + +### retryDelay? + +```ts +optional retryDelay: RetryDelayValue; +``` + +Defined in: [packages/query-core/src/types.ts:258](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L258) + +This function receives a `retryAttempt` integer and the actual Error and returns the delay to apply before the +next attempt in milliseconds. + +A function like `attempt => Math.min(attempt > 1 ? 2 ** attempt * 1000 : 1000, 30 * 1000)` applies exponential +backoff. + +A function like `attempt => attempt * 1000` applies linear backoff. + +Defaults to a function that applies exponential backoff, capped at 30 seconds. + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`retryDelay`](QueryObserverOptions.md#retrydelay) + +*** + +### retryOnMount? + +```ts +optional retryOnMount: QueryBooleanOption; +``` + +Defined in: [packages/query-core/src/types.ts:474](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L474) + +If set to `false`, the query will not be retried on mount if it contains an error. +If set to a function, the function will be executed with the query to compute the value. + +Defaults to `true`. + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`retryOnMount`](QueryObserverOptions.md#retryonmount) + +*** + +### select()? + +```ts +optional select: (data) => TData; +``` + +Defined in: [packages/query-core/src/types.ts:500](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L500) + +This option can be used to transform or select a part of the data returned by the query function. It affects +the returned `data` value, but does not affect what gets stored in the query cache. +The `select` function will only run if `data` changed, or if the reference to the `select` function itself +changes. To optimize, memoize the function so its reference stays stable across calls. + +#### Parameters + +##### data + +`TQueryData` + +#### Returns + +`TData` + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`select`](QueryObserverOptions.md#select) + +*** + +### staleTime? + +```ts +optional staleTime: StaleTimeFunction; +``` + +Defined in: [packages/query-core/src/types.ts:407](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L407) + +The time in milliseconds after data is considered stale. +If set to `Infinity`, the data will never be considered stale. +If set to `'static'`, the data will never be considered stale. +If set to a function, the function will be executed with the query to compute a `staleTime`. + +Defaults to `0`. + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`staleTime`](QueryObserverOptions.md#staletime) + +*** + +### structuralSharing? + +```ts +optional structuralSharing: boolean | (oldData, newData) => unknown; +``` + +Defined in: [packages/query-core/src/types.ts:330](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L330) + +Set this to `false` to disable structural sharing between query results. +Set this to a function which accepts the old and new data and returns resolved data of the same type to implement custom structural sharing logic. + +Defaults to `true`. + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`structuralSharing`](QueryObserverOptions.md#structuralsharing) + +*** + +### suspense? + +```ts +optional suspense: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:507](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L507) + +If set to `true`, the query will suspend when `status === 'pending'` +and throw errors when `status === 'error'`. + +Defaults to `false`. + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`suspense`](QueryObserverOptions.md#suspense) + +*** + +### throwOnError? + +```ts +optional throwOnError: ThrowOnError; +``` + +Defined in: [packages/query-core/src/types.ts:493](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L493) + +Whether errors should be thrown instead of setting the `error` property. +If set to `true` or `suspense` is `true`, all errors will be thrown to the error boundary. +If set to `false` and `suspense` is `false`, errors are returned as state. +If set to a function, it will be passed the error and the query, and it should return a boolean indicating whether to show the error in an error boundary (`true`) or return the error as state (`false`). + +Defaults to `false`. + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`throwOnError`](QueryObserverOptions.md#throwonerror) diff --git a/docs/framework/angular/reference/interfaces/CreateInfiniteQueryOptions.md b/docs/framework/angular/reference/interfaces/CreateInfiniteQueryOptions.md index 5dba1476e96..a56340bfd6c 100644 --- a/docs/framework/angular/reference/interfaces/CreateInfiniteQueryOptions.md +++ b/docs/framework/angular/reference/interfaces/CreateInfiniteQueryOptions.md @@ -3,16 +3,16 @@ id: CreateInfiniteQueryOptions title: CreateInfiniteQueryOptions --- -Defined in: [types.ts:121](https://github.com/TanStack/query/blob/main/packages/angular-query-experimental/src/types.ts#L121) +Defined in: [packages/angular-query-experimental/src/types.ts:121](https://github.com/TanStack/query/blob/main/packages/angular-query-experimental/src/types.ts#L121) The options accepted by `injectInfiniteQuery`. Same as [CreateBaseQueryOptions](CreateBaseQueryOptions.md), minus `suspense` — which `angular-query-experimental` doesn't support, unlike `react-query` — extends -InfiniteQueryObserverOptions from `@tanstack/query-core` for the infinite-query-specific options +[InfiniteQueryObserverOptions](InfiniteQueryObserverOptions.md) from `@tanstack/query-core` for the infinite-query-specific options (`getNextPageParam`, `initialPageParam`, etc.). ## Extends -- `OmitKeyof`\<`InfiniteQueryObserverOptions`\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`, `TPageParam`\>, `"suspense"`\> +- [`OmitKeyof`](../type-aliases/OmitKeyof.md)\<[`InfiniteQueryObserverOptions`](InfiniteQueryObserverOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`, `TPageParam`\>, `"suspense"`\> ## Type Parameters @@ -24,7 +24,7 @@ The type of a single page, as your `queryFn` resolves it. ### TError -`TError` = `DefaultError` +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) The type of errors your `queryFn` may throw. @@ -38,7 +38,7 @@ when no `select` is used. ### TQueryKey -`TQueryKey` *extends* `QueryKey` = `QueryKey` +`TQueryKey` *extends* [`QueryKey`](../type-aliases/QueryKey.md) = [`QueryKey`](../type-aliases/QueryKey.md) The type of your `queryKey`. @@ -47,3 +47,620 @@ The type of your `queryKey`. `TPageParam` = `unknown` The type of the parameter passed to `queryFn` to fetch a given page. + +## Properties + +### enabled? + +```ts +optional enabled: QueryBooleanOption, TQueryKey>; +``` + +Defined in: [packages/query-core/src/types.ts:398](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L398) + +Set this to `false` or a function that returns `false` to disable automatic refetching when the query mounts or changes query keys. +To refetch the query, use the `refetch` method returned from the `useQuery` instance. +Accepts a boolean or function that returns a boolean. + +Defaults to `true`. + +#### Inherited from + +```ts +OmitKeyof.enabled +``` + +*** + +### gcTime? + +```ts +optional gcTime: number; +``` + +Defined in: [packages/query-core/src/types.ts:277](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L277) + +The time in milliseconds that unused/inactive cache data remains in memory. +When a query's cache becomes unused or inactive, that cache data will be garbage collected after this duration. +When different garbage collection times are specified, the longest one will be used. +Setting it to `Infinity` will disable garbage collection. + +Defaults to `5 * 60 * 1000` (5 minutes), or `Infinity` during SSR. + +Note: the maximum allowed time is about 24 days, imposed by `setTimeout`'s 32-bit signed integer delay — see +`timeoutManager.setTimeoutProvider` for a workaround. + +#### Inherited from + +[`QueryOptions`](QueryOptions.md).[`gcTime`](QueryOptions.md#gctime) + +*** + +### getNextPageParam + +```ts +getNextPageParam: GetNextPageParamFunction; +``` + +Defined in: [packages/query-core/src/types.ts:365](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L365) + +This function can be set to automatically get the next cursor for infinite queries. +The result will also be used to determine the value of `hasNextPage`. + +#### Inherited from + +```ts +OmitKeyof.getNextPageParam +``` + +*** + +### getPreviousPageParam? + +```ts +optional getPreviousPageParam: GetPreviousPageParamFunction; +``` + +Defined in: [packages/query-core/src/types.ts:360](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L360) + +This function can be set to automatically get the previous cursor for infinite queries. +The result will also be used to determine the value of `hasPreviousPage`. + +#### Inherited from + +```ts +OmitKeyof.getPreviousPageParam +``` + +*** + +### initialData? + +```ts +optional initialData: + | InfiniteData +| InitialDataFunction>; +``` + +Defined in: [packages/query-core/src/types.ts:317](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L317) + +If set, this value will be used as the initial data for the query cache (as long as the query hasn't been +created or cached yet). +If set to a function, the function will be called **once** during the shared/root query initialization, and be +expected to synchronously return the initial data. +Initial data is considered stale by default unless a `staleTime` has been set. +`initialData` **is persisted** to the cache. + +#### Inherited from + +```ts +OmitKeyof.initialData +``` + +*** + +### initialDataUpdatedAt? + +```ts +optional initialDataUpdatedAt: number | () => number | undefined; +``` + +Defined in: [packages/query-core/src/types.ts:321](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L321) + +If set, this value will be used as the time (in milliseconds) of when the `initialData` itself was last updated. + +#### Inherited from + +```ts +OmitKeyof.initialDataUpdatedAt +``` + +*** + +### initialPageParam + +```ts +initialPageParam: TPageParam; +``` + +Defined in: [packages/query-core/src/types.ts:349](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L349) + +#### Inherited from + +```ts +OmitKeyof.initialPageParam +``` + +*** + +### maxPages? + +```ts +optional maxPages: number; +``` + +Defined in: [packages/query-core/src/types.ts:345](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L345) + +Maximum number of pages to store in the data of an infinite query. + +#### Inherited from + +[`QueryOptions`](QueryOptions.md).[`maxPages`](QueryOptions.md#maxpages) + +*** + +### meta? + +```ts +optional meta: Record; +``` + +Defined in: [packages/query-core/src/types.ts:341](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L341) + +Additional payload to be stored on each query. +Use this property to pass information that can be used in other places. + +#### Inherited from + +[`QueryOptions`](QueryOptions.md).[`meta`](QueryOptions.md#meta) + +*** + +### networkMode? + +```ts +optional networkMode: NetworkMode; +``` + +Defined in: [packages/query-core/src/types.ts:265](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L265) + +Controls whether a query is allowed to run based on the current network connectivity. + +Defaults to `'online'`. + +#### See + +[Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. + +#### Inherited from + +[`QueryOptions`](QueryOptions.md).[`networkMode`](QueryOptions.md#networkmode) + +*** + +### notifyOnChangeProps? + +```ts +optional notifyOnChangeProps: NotifyOnChangeProps; +``` + +Defined in: [packages/query-core/src/types.ts:484](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L484) + +If set, the component will only re-render if any of the listed properties change. +When set to `['data', 'error']`, the component will only re-render when the `data` or `error` properties change. +When set to `'all'`, the component will re-render whenever a query is updated. +When set to a function, the function will be executed to compute the list of properties. + +Defaults to `undefined`, in which case property access is tracked automatically, and the +component only re-renders when one of the tracked properties changes. + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`notifyOnChangeProps`](QueryObserverOptions.md#notifyonchangeprops) + +*** + +### persister? + +```ts +optional persister: QueryPersister, TPageParam>; +``` + +Defined in: [packages/query-core/src/types.ts:290](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L290) + +This option can be used to persist the result of a query to an external storage, bypassing the need to actually +call the `queryFn`. Useful for persisting a query's data across e.g. server/client boundaries. + +#### Inherited from + +```ts +OmitKeyof.persister +``` + +*** + +### placeholderData? + +```ts +optional placeholderData: + | InfiniteData +| PlaceholderDataFunction, TError, InfiniteData, TQueryKey>; +``` + +Defined in: [packages/query-core/src/types.ts:511](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L511) + +If set, this value will be used as the placeholder data for this particular query observer while the query is still in the `loading` data and no initialData has been provided. + +#### Inherited from + +```ts +OmitKeyof.placeholderData +``` + +*** + +### queryFn? + +```ts +optional queryFn: + | typeof skipToken +| QueryFunction; +``` + +Defined in: [packages/query-core/src/types.ts:285](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L285) + +The function that the query will use to request data. +Required, unless a default query function has been set via `queryClient.setQueryDefaults` or +`queryClient.setDefaultOptions`. +Receives a [QueryFunctionContext](../type-aliases/QueryFunctionContext.md). +Must return a promise that will either resolve data or throw an error. The data cannot be `undefined`. + +#### Inherited from + +```ts +OmitKeyof.queryFn +``` + +*** + +### queryHash? + +```ts +optional queryHash: string; +``` + +Defined in: [packages/query-core/src/types.ts:295](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L295) + +The hashed form of `queryKey`, computed with `queryKeyHashFn` (or the default hashing function otherwise). Used +as the actual cache key internally. + +#### Inherited from + +[`QueryOptions`](QueryOptions.md).[`queryHash`](QueryOptions.md#queryhash) + +*** + +### queryKey + +```ts +queryKey: TQueryKey & object; +``` + +Defined in: [packages/query-core/src/types.ts:304](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L304) + +The query key to use for this query. + +The query key will be hashed into a stable hash. See [Query Keys](https://tanstack.com/query/latest/docs/framework/react/guides/query-keys) +for more information. + +The query will automatically update when this key changes (as long as `enabled` is not set to `false`). + +#### Inherited from + +```ts +OmitKeyof.queryKey +``` + +*** + +### queryKeyHashFn? + +```ts +optional queryKeyHashFn: QueryKeyHashFunction; +``` + +Defined in: [packages/query-core/src/types.ts:308](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L308) + +If specified, this function is used to hash the `queryKey` to a string. + +#### Inherited from + +```ts +OmitKeyof.queryKeyHashFn +``` + +*** + +### refetchInterval? + +```ts +optional refetchInterval: number | false | (query) => number | false | undefined; +``` + +Defined in: [packages/query-core/src/types.ts:414](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L414) + +If set to a number, the query will continuously refetch at this frequency in milliseconds. +If set to a function, the function will be executed with the latest data and query to compute a frequency + +Defaults to `false`. + +#### Inherited from + +```ts +OmitKeyof.refetchInterval +``` + +*** + +### refetchIntervalInBackground? + +```ts +optional refetchIntervalInBackground: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:425](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L425) + +If set to `true`, the query will continue to refetch while their tab/window is in the background. + +Defaults to `false`. + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`refetchIntervalInBackground`](QueryObserverOptions.md#refetchintervalinbackground) + +*** + +### refetchOnMount? + +```ts +optional refetchOnMount: boolean | "always" | (query) => boolean | "always"; +``` + +Defined in: [packages/query-core/src/types.ts:462](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L462) + +If set to `true`, the query will refetch on mount if the data is stale. +If set to `false`, will disable additional instances of a query to trigger background refetch. +If set to `'always'`, the query will always refetch on mount (except when `staleTime: 'static'` is used). +If set to a function, the function will be executed with the latest data and query to compute the value + +Defaults to `true`. + +#### Inherited from + +```ts +OmitKeyof.refetchOnMount +``` + +*** + +### refetchOnReconnect? + +```ts +optional refetchOnReconnect: boolean | "always" | (query) => boolean | "always"; +``` + +Defined in: [packages/query-core/src/types.ts:448](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L448) + +If set to `true`, the query will refetch on reconnect if the data is stale. +If set to `false`, the query will not refetch on reconnect. +If set to `'always'`, the query will always refetch on reconnect (except when `staleTime: 'static'` is used). +If set to a function, the function will be executed with the latest data and query to compute the value. + +Defaults to `true` unless `networkMode` is `'always'`. + +#### Inherited from + +```ts +OmitKeyof.refetchOnReconnect +``` + +*** + +### refetchOnWindowFocus? + +```ts +optional refetchOnWindowFocus: boolean | "always" | (query) => boolean | "always"; +``` + +Defined in: [packages/query-core/src/types.ts:434](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L434) + +If set to `true`, the query will refetch on window focus if the data is stale. +If set to `false`, the query will not refetch on window focus. +If set to `'always'`, the query will always refetch on window focus (except when `staleTime: 'static'` is used). +If set to a function, the function will be executed with the latest data and query to compute the value. + +Defaults to `true`. + +#### Inherited from + +```ts +OmitKeyof.refetchOnWindowFocus +``` + +*** + +### retry? + +```ts +optional retry: RetryValue; +``` + +Defined in: [packages/query-core/src/types.ts:246](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L246) + +If `false`, failed queries will not retry by default. +If `true`, failed queries will retry infinitely. +If set to an integer number, e.g. 3, failed queries will retry until the failed query count meets that number. +If set to a function `(failureCount, error) => boolean` failed queries will retry until the function returns false. + +Defaults to `3` on the client and `0` on the server. + +#### Inherited from + +```ts +OmitKeyof.retry +``` + +*** + +### retryDelay? + +```ts +optional retryDelay: RetryDelayValue; +``` + +Defined in: [packages/query-core/src/types.ts:258](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L258) + +This function receives a `retryAttempt` integer and the actual Error and returns the delay to apply before the +next attempt in milliseconds. + +A function like `attempt => Math.min(attempt > 1 ? 2 ** attempt * 1000 : 1000, 30 * 1000)` applies exponential +backoff. + +A function like `attempt => attempt * 1000` applies linear backoff. + +Defaults to a function that applies exponential backoff, capped at 30 seconds. + +#### Inherited from + +```ts +OmitKeyof.retryDelay +``` + +*** + +### retryOnMount? + +```ts +optional retryOnMount: QueryBooleanOption, TQueryKey>; +``` + +Defined in: [packages/query-core/src/types.ts:474](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L474) + +If set to `false`, the query will not be retried on mount if it contains an error. +If set to a function, the function will be executed with the query to compute the value. + +Defaults to `true`. + +#### Inherited from + +```ts +OmitKeyof.retryOnMount +``` + +*** + +### select()? + +```ts +optional select: (data) => TData; +``` + +Defined in: [packages/query-core/src/types.ts:500](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L500) + +This option can be used to transform or select a part of the data returned by the query function. It affects +the returned `data` value, but does not affect what gets stored in the query cache. +The `select` function will only run if `data` changed, or if the reference to the `select` function itself +changes. To optimize, memoize the function so its reference stays stable across calls. + +#### Parameters + +##### data + +[`InfiniteData`](InfiniteData.md) + +#### Returns + +`TData` + +#### Inherited from + +```ts +OmitKeyof.select +``` + +*** + +### staleTime? + +```ts +optional staleTime: StaleTimeFunction, TQueryKey>; +``` + +Defined in: [packages/query-core/src/types.ts:407](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L407) + +The time in milliseconds after data is considered stale. +If set to `Infinity`, the data will never be considered stale. +If set to `'static'`, the data will never be considered stale. +If set to a function, the function will be executed with the query to compute a `staleTime`. + +Defaults to `0`. + +#### Inherited from + +```ts +OmitKeyof.staleTime +``` + +*** + +### structuralSharing? + +```ts +optional structuralSharing: boolean | (oldData, newData) => unknown; +``` + +Defined in: [packages/query-core/src/types.ts:330](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L330) + +Set this to `false` to disable structural sharing between query results. +Set this to a function which accepts the old and new data and returns resolved data of the same type to implement custom structural sharing logic. + +Defaults to `true`. + +#### Inherited from + +```ts +OmitKeyof.structuralSharing +``` + +*** + +### throwOnError? + +```ts +optional throwOnError: ThrowOnError, TQueryKey>; +``` + +Defined in: [packages/query-core/src/types.ts:493](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L493) + +Whether errors should be thrown instead of setting the `error` property. +If set to `true` or `suspense` is `true`, all errors will be thrown to the error boundary. +If set to `false` and `suspense` is `false`, errors are returned as state. +If set to a function, it will be passed the error and the query, and it should return a boolean indicating whether to show the error in an error boundary (`true`) or return the error as state (`false`). + +Defaults to `false`. + +#### Inherited from + +```ts +OmitKeyof.throwOnError +``` diff --git a/docs/framework/angular/reference/interfaces/CreateMutationOptions.md b/docs/framework/angular/reference/interfaces/CreateMutationOptions.md index 91bfca38e06..b1f61fbbbb1 100644 --- a/docs/framework/angular/reference/interfaces/CreateMutationOptions.md +++ b/docs/framework/angular/reference/interfaces/CreateMutationOptions.md @@ -3,14 +3,14 @@ id: CreateMutationOptions title: CreateMutationOptions --- -Defined in: [types.ts:224](https://github.com/TanStack/query/blob/main/packages/angular-query-experimental/src/types.ts#L224) +Defined in: [packages/angular-query-experimental/src/types.ts:224](https://github.com/TanStack/query/blob/main/packages/angular-query-experimental/src/types.ts#L224) -The options accepted by `injectMutation`. Same as MutationObserverOptions from +The options accepted by `injectMutation`. Same as [MutationObserverOptions](MutationObserverOptions.md) from `@tanstack/query-core`, minus the internal `_defaulted` flag. ## Extends -- `OmitKeyof`\<`MutationObserverOptions`\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\>, `"_defaulted"`\> +- [`OmitKeyof`](../type-aliases/OmitKeyof.md)\<[`MutationObserverOptions`](MutationObserverOptions.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\>, `"_defaulted"`\> ## Type Parameters @@ -22,7 +22,7 @@ The type your mutation function resolves to. ### TError -`TError` = `DefaultError` +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) The type of errors your mutation function may throw. @@ -38,3 +38,317 @@ The type of the variable passed to `mutate`/`mutateAsync`. The type returned by `onMutate`, passed to `onSuccess`/`onError`/`onSettled` as their `onMutateResult` parameter — useful for optimistic-update rollback data. + +## Properties + +### gcTime? + +```ts +optional gcTime: number; +``` + +Defined in: [packages/query-core/src/types.ts:1260](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1260) + +The time in milliseconds that an unused/inactive mutation remains in memory before it is +garbage collected. + +Defaults to `5 * 60 * 1000` (5 minutes), or `Infinity` during SSR. + +#### Inherited from + +[`MutationOptions`](MutationOptions.md).[`gcTime`](MutationOptions.md#gctime) + +*** + +### meta? + +```ts +optional meta: Record; +``` + +Defined in: [packages/query-core/src/types.ts:1263](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1263) + +#### Inherited from + +[`MutationOptions`](MutationOptions.md).[`meta`](MutationOptions.md#meta) + +*** + +### mutationFn? + +```ts +optional mutationFn: MutationFunction; +``` + +Defined in: [packages/query-core/src/types.ts:1206](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1206) + +#### Inherited from + +```ts +OmitKeyof.mutationFn +``` + +*** + +### mutationKey? + +```ts +optional mutationKey: readonly unknown[]; +``` + +Defined in: [packages/query-core/src/types.ts:1207](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1207) + +#### Inherited from + +[`MutationOptions`](MutationOptions.md).[`mutationKey`](MutationOptions.md#mutationkey) + +*** + +### networkMode? + +```ts +optional networkMode: NetworkMode; +``` + +Defined in: [packages/query-core/src/types.ts:1253](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1253) + +Controls whether a mutation is allowed to run based on the current network connectivity. + +Defaults to `'online'`. + +#### See + +[Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. + +#### Inherited from + +[`MutationOptions`](MutationOptions.md).[`networkMode`](MutationOptions.md#networkmode) + +*** + +### onError()? + +```ts +optional onError: (error, variables, onMutateResult, context) => unknown; +``` + +Defined in: [packages/query-core/src/types.ts:1218](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1218) + +#### Parameters + +##### error + +`TError` + +##### variables + +`TVariables` + +##### onMutateResult + +`TOnMutateResult` | `undefined` + +##### context + +[`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md) + +#### Returns + +`unknown` + +#### Inherited from + +```ts +OmitKeyof.onError +``` + +*** + +### onMutate()? + +```ts +optional onMutate: (variables, context) => TOnMutateResult | Promise; +``` + +Defined in: [packages/query-core/src/types.ts:1208](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1208) + +#### Parameters + +##### variables + +`TVariables` + +##### context + +[`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md) + +#### Returns + +`TOnMutateResult` \| `Promise`\<`TOnMutateResult`\> + +#### Inherited from + +```ts +OmitKeyof.onMutate +``` + +*** + +### onSettled()? + +```ts +optional onSettled: (data, error, variables, onMutateResult, context) => unknown; +``` + +Defined in: [packages/query-core/src/types.ts:1224](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1224) + +#### Parameters + +##### data + +`TData` | `undefined` + +##### error + +`TError` | `null` + +##### variables + +`TVariables` + +##### onMutateResult + +`TOnMutateResult` | `undefined` + +##### context + +[`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md) + +#### Returns + +`unknown` + +#### Inherited from + +```ts +OmitKeyof.onSettled +``` + +*** + +### onSuccess()? + +```ts +optional onSuccess: (data, variables, onMutateResult, context) => unknown; +``` + +Defined in: [packages/query-core/src/types.ts:1212](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1212) + +#### Parameters + +##### data + +`TData` + +##### variables + +`TVariables` + +##### onMutateResult + +`TOnMutateResult` + +##### context + +[`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md) + +#### Returns + +`unknown` + +#### Inherited from + +```ts +OmitKeyof.onSuccess +``` + +*** + +### retry? + +```ts +optional retry: RetryValue; +``` + +Defined in: [packages/query-core/src/types.ts:1239](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1239) + +If `false`, failed mutations will not retry by default. +If `true`, failed mutations will retry infinitely. +If set to an integer number, e.g. 3, failed mutations will retry until the failed mutation count meets that number. +If set to a function `(failureCount, error) => boolean` failed mutations will retry until the function returns false. + +Defaults to `0`. + +#### Inherited from + +```ts +OmitKeyof.retry +``` + +*** + +### retryDelay? + +```ts +optional retryDelay: RetryDelayValue; +``` + +Defined in: [packages/query-core/src/types.ts:1246](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1246) + +This function receives a `retryAttempt` integer and the actual Error and returns the delay to apply before the +next attempt in milliseconds. + +Defaults to a function that applies exponential backoff, capped at 30 seconds. + +#### Inherited from + +```ts +OmitKeyof.retryDelay +``` + +*** + +### scope? + +```ts +optional scope: MutationScope; +``` + +Defined in: [packages/query-core/src/types.ts:1264](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1264) + +#### Inherited from + +[`MutationOptions`](MutationOptions.md).[`scope`](MutationOptions.md#scope) + +*** + +### throwOnError? + +```ts +optional throwOnError: boolean | (error) => boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1281](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1281) + +Whether errors should be thrown instead of setting the `error` property. +If set to `true`, all errors will be thrown to the nearest error boundary. +If set to a function, it will be passed the error and should return a boolean indicating whether to throw the +error (`true`) or return it as state (`false`). + +Defaults to `false`. + +#### Inherited from + +```ts +OmitKeyof.throwOnError +``` diff --git a/docs/framework/angular/reference/interfaces/CreateQueryOptions.md b/docs/framework/angular/reference/interfaces/CreateQueryOptions.md index 52a56d7e8fb..1982a488ea3 100644 --- a/docs/framework/angular/reference/interfaces/CreateQueryOptions.md +++ b/docs/framework/angular/reference/interfaces/CreateQueryOptions.md @@ -3,14 +3,14 @@ id: CreateQueryOptions title: CreateQueryOptions --- -Defined in: [types.ts:58](https://github.com/TanStack/query/blob/main/packages/angular-query-experimental/src/types.ts#L58) +Defined in: [packages/angular-query-experimental/src/types.ts:58](https://github.com/TanStack/query/blob/main/packages/angular-query-experimental/src/types.ts#L58) The options accepted by `injectQuery`. Same as [CreateBaseQueryOptions](CreateBaseQueryOptions.md), minus `suspense` — which `angular-query-experimental` doesn't support, unlike `react-query`. ## Extends -- `OmitKeyof`\<[`CreateBaseQueryOptions`](CreateBaseQueryOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryFnData`, `TQueryKey`\>, `"suspense"`\> +- [`OmitKeyof`](../type-aliases/OmitKeyof.md)\<[`CreateBaseQueryOptions`](CreateBaseQueryOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryFnData`, `TQueryKey`\>, `"suspense"`\> ## Type Parameters @@ -22,7 +22,7 @@ The type your `queryFn` resolves to. ### TError -`TError` = `DefaultError` +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) The type of errors your `queryFn` may throw. @@ -35,6 +35,613 @@ The type `data` ends up as after `select` runs. Defaults to `TQueryFnData` when ### TQueryKey -`TQueryKey` *extends* `QueryKey` = `QueryKey` +`TQueryKey` *extends* [`QueryKey`](../type-aliases/QueryKey.md) = [`QueryKey`](../type-aliases/QueryKey.md) The type of your `queryKey`. + +## Properties + +### enabled? + +```ts +optional enabled: QueryBooleanOption; +``` + +Defined in: [packages/query-core/src/types.ts:398](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L398) + +Set this to `false` or a function that returns `false` to disable automatic refetching when the query mounts or changes query keys. +To refetch the query, use the `refetch` method returned from the `useQuery` instance. +Accepts a boolean or function that returns a boolean. + +Defaults to `true`. + +#### Inherited from + +```ts +OmitKeyof.enabled +``` + +*** + +### gcTime? + +```ts +optional gcTime: number; +``` + +Defined in: [packages/query-core/src/types.ts:277](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L277) + +The time in milliseconds that unused/inactive cache data remains in memory. +When a query's cache becomes unused or inactive, that cache data will be garbage collected after this duration. +When different garbage collection times are specified, the longest one will be used. +Setting it to `Infinity` will disable garbage collection. + +Defaults to `5 * 60 * 1000` (5 minutes), or `Infinity` during SSR. + +Note: the maximum allowed time is about 24 days, imposed by `setTimeout`'s 32-bit signed integer delay — see +`timeoutManager.setTimeoutProvider` for a workaround. + +#### Inherited from + +[`QueryOptions`](QueryOptions.md).[`gcTime`](QueryOptions.md#gctime) + +*** + +### initialData? + +```ts +optional initialData: + | TQueryFnData +| InitialDataFunction; +``` + +Defined in: [packages/query-core/src/types.ts:317](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L317) + +If set, this value will be used as the initial data for the query cache (as long as the query hasn't been +created or cached yet). +If set to a function, the function will be called **once** during the shared/root query initialization, and be +expected to synchronously return the initial data. +Initial data is considered stale by default unless a `staleTime` has been set. +`initialData` **is persisted** to the cache. + +#### Inherited from + +```ts +OmitKeyof.initialData +``` + +*** + +### initialDataUpdatedAt? + +```ts +optional initialDataUpdatedAt: number | () => number | undefined; +``` + +Defined in: [packages/query-core/src/types.ts:321](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L321) + +If set, this value will be used as the time (in milliseconds) of when the `initialData` itself was last updated. + +#### Inherited from + +```ts +OmitKeyof.initialDataUpdatedAt +``` + +*** + +### maxPages? + +```ts +optional maxPages: number; +``` + +Defined in: [packages/query-core/src/types.ts:345](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L345) + +Maximum number of pages to store in the data of an infinite query. + +#### Inherited from + +[`QueryOptions`](QueryOptions.md).[`maxPages`](QueryOptions.md#maxpages) + +*** + +### meta? + +```ts +optional meta: Record; +``` + +Defined in: [packages/query-core/src/types.ts:341](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L341) + +Additional payload to be stored on each query. +Use this property to pass information that can be used in other places. + +#### Inherited from + +[`QueryOptions`](QueryOptions.md).[`meta`](QueryOptions.md#meta) + +*** + +### networkMode? + +```ts +optional networkMode: NetworkMode; +``` + +Defined in: [packages/query-core/src/types.ts:265](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L265) + +Controls whether a query is allowed to run based on the current network connectivity. + +Defaults to `'online'`. + +#### See + +[Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. + +#### Inherited from + +[`QueryOptions`](QueryOptions.md).[`networkMode`](QueryOptions.md#networkmode) + +*** + +### notifyOnChangeProps? + +```ts +optional notifyOnChangeProps: NotifyOnChangeProps; +``` + +Defined in: [packages/query-core/src/types.ts:484](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L484) + +If set, the component will only re-render if any of the listed properties change. +When set to `['data', 'error']`, the component will only re-render when the `data` or `error` properties change. +When set to `'all'`, the component will re-render whenever a query is updated. +When set to a function, the function will be executed to compute the list of properties. + +Defaults to `undefined`, in which case property access is tracked automatically, and the +component only re-renders when one of the tracked properties changes. + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`notifyOnChangeProps`](QueryObserverOptions.md#notifyonchangeprops) + +*** + +### persister()? + +```ts +optional persister: (queryFn, context, query) => TQueryFnData | Promise; +``` + +Defined in: [packages/query-core/src/types.ts:290](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L290) + +This option can be used to persist the result of a query to an external storage, bypassing the need to actually +call the `queryFn`. Useful for persisting a query's data across e.g. server/client boundaries. + +#### Parameters + +##### queryFn + +[`QueryFunction`](../type-aliases/QueryFunction.md)\<`TQueryFnData`, `NoInfer`\<`TQueryKey`\>, `never`\> + +##### context + +###### client + +[`QueryClient`](../classes/QueryClient.md) + +###### direction? + +`unknown` + +**Deprecated** + +if you want access to the direction, you can add it to the pageParam + +###### meta + +`Record`\<`string`, `unknown`\> \| `undefined` + +###### pageParam? + +`unknown` + +###### queryKey + +`NoInfer`\<`TQueryKey`\> + +###### signal + +`AbortSignal` + +##### query + +[`Query`](../classes/Query.md) + +#### Returns + +`TQueryFnData` \| `Promise`\<`TQueryFnData`\> + +#### Inherited from + +```ts +OmitKeyof.persister +``` + +*** + +### placeholderData? + +```ts +optional placeholderData: + | NonFunctionGuard +| PlaceholderDataFunction, TError, NonFunctionGuard, TQueryKey>; +``` + +Defined in: [packages/query-core/src/types.ts:511](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L511) + +If set, this value will be used as the placeholder data for this particular query observer while the query is still in the `loading` data and no initialData has been provided. + +#### Inherited from + +```ts +OmitKeyof.placeholderData +``` + +*** + +### queryFn? + +```ts +optional queryFn: + | typeof skipToken +| QueryFunction; +``` + +Defined in: [packages/query-core/src/types.ts:285](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L285) + +The function that the query will use to request data. +Required, unless a default query function has been set via `queryClient.setQueryDefaults` or +`queryClient.setDefaultOptions`. +Receives a [QueryFunctionContext](../type-aliases/QueryFunctionContext.md). +Must return a promise that will either resolve data or throw an error. The data cannot be `undefined`. + +#### Inherited from + +```ts +OmitKeyof.queryFn +``` + +*** + +### queryHash? + +```ts +optional queryHash: string; +``` + +Defined in: [packages/query-core/src/types.ts:295](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L295) + +The hashed form of `queryKey`, computed with `queryKeyHashFn` (or the default hashing function otherwise). Used +as the actual cache key internally. + +#### Inherited from + +[`QueryOptions`](QueryOptions.md).[`queryHash`](QueryOptions.md#queryhash) + +*** + +### queryKey + +```ts +queryKey: TQueryKey & object; +``` + +Defined in: [packages/query-core/src/types.ts:304](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L304) + +The query key to use for this query. + +The query key will be hashed into a stable hash. See [Query Keys](https://tanstack.com/query/latest/docs/framework/react/guides/query-keys) +for more information. + +The query will automatically update when this key changes (as long as `enabled` is not set to `false`). + +#### Inherited from + +```ts +OmitKeyof.queryKey +``` + +*** + +### queryKeyHashFn? + +```ts +optional queryKeyHashFn: QueryKeyHashFunction; +``` + +Defined in: [packages/query-core/src/types.ts:308](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L308) + +If specified, this function is used to hash the `queryKey` to a string. + +#### Inherited from + +```ts +OmitKeyof.queryKeyHashFn +``` + +*** + +### refetchInterval? + +```ts +optional refetchInterval: number | false | (query) => number | false | undefined; +``` + +Defined in: [packages/query-core/src/types.ts:414](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L414) + +If set to a number, the query will continuously refetch at this frequency in milliseconds. +If set to a function, the function will be executed with the latest data and query to compute a frequency + +Defaults to `false`. + +#### Inherited from + +```ts +OmitKeyof.refetchInterval +``` + +*** + +### refetchIntervalInBackground? + +```ts +optional refetchIntervalInBackground: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:425](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L425) + +If set to `true`, the query will continue to refetch while their tab/window is in the background. + +Defaults to `false`. + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`refetchIntervalInBackground`](QueryObserverOptions.md#refetchintervalinbackground) + +*** + +### refetchOnMount? + +```ts +optional refetchOnMount: boolean | "always" | (query) => boolean | "always"; +``` + +Defined in: [packages/query-core/src/types.ts:462](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L462) + +If set to `true`, the query will refetch on mount if the data is stale. +If set to `false`, will disable additional instances of a query to trigger background refetch. +If set to `'always'`, the query will always refetch on mount (except when `staleTime: 'static'` is used). +If set to a function, the function will be executed with the latest data and query to compute the value + +Defaults to `true`. + +#### Inherited from + +```ts +OmitKeyof.refetchOnMount +``` + +*** + +### refetchOnReconnect? + +```ts +optional refetchOnReconnect: boolean | "always" | (query) => boolean | "always"; +``` + +Defined in: [packages/query-core/src/types.ts:448](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L448) + +If set to `true`, the query will refetch on reconnect if the data is stale. +If set to `false`, the query will not refetch on reconnect. +If set to `'always'`, the query will always refetch on reconnect (except when `staleTime: 'static'` is used). +If set to a function, the function will be executed with the latest data and query to compute the value. + +Defaults to `true` unless `networkMode` is `'always'`. + +#### Inherited from + +```ts +OmitKeyof.refetchOnReconnect +``` + +*** + +### refetchOnWindowFocus? + +```ts +optional refetchOnWindowFocus: boolean | "always" | (query) => boolean | "always"; +``` + +Defined in: [packages/query-core/src/types.ts:434](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L434) + +If set to `true`, the query will refetch on window focus if the data is stale. +If set to `false`, the query will not refetch on window focus. +If set to `'always'`, the query will always refetch on window focus (except when `staleTime: 'static'` is used). +If set to a function, the function will be executed with the latest data and query to compute the value. + +Defaults to `true`. + +#### Inherited from + +```ts +OmitKeyof.refetchOnWindowFocus +``` + +*** + +### retry? + +```ts +optional retry: RetryValue; +``` + +Defined in: [packages/query-core/src/types.ts:246](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L246) + +If `false`, failed queries will not retry by default. +If `true`, failed queries will retry infinitely. +If set to an integer number, e.g. 3, failed queries will retry until the failed query count meets that number. +If set to a function `(failureCount, error) => boolean` failed queries will retry until the function returns false. + +Defaults to `3` on the client and `0` on the server. + +#### Inherited from + +```ts +OmitKeyof.retry +``` + +*** + +### retryDelay? + +```ts +optional retryDelay: RetryDelayValue; +``` + +Defined in: [packages/query-core/src/types.ts:258](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L258) + +This function receives a `retryAttempt` integer and the actual Error and returns the delay to apply before the +next attempt in milliseconds. + +A function like `attempt => Math.min(attempt > 1 ? 2 ** attempt * 1000 : 1000, 30 * 1000)` applies exponential +backoff. + +A function like `attempt => attempt * 1000` applies linear backoff. + +Defaults to a function that applies exponential backoff, capped at 30 seconds. + +#### Inherited from + +```ts +OmitKeyof.retryDelay +``` + +*** + +### retryOnMount? + +```ts +optional retryOnMount: QueryBooleanOption; +``` + +Defined in: [packages/query-core/src/types.ts:474](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L474) + +If set to `false`, the query will not be retried on mount if it contains an error. +If set to a function, the function will be executed with the query to compute the value. + +Defaults to `true`. + +#### Inherited from + +```ts +OmitKeyof.retryOnMount +``` + +*** + +### select()? + +```ts +optional select: (data) => TData; +``` + +Defined in: [packages/query-core/src/types.ts:500](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L500) + +This option can be used to transform or select a part of the data returned by the query function. It affects +the returned `data` value, but does not affect what gets stored in the query cache. +The `select` function will only run if `data` changed, or if the reference to the `select` function itself +changes. To optimize, memoize the function so its reference stays stable across calls. + +#### Parameters + +##### data + +`TQueryFnData` + +#### Returns + +`TData` + +#### Inherited from + +```ts +OmitKeyof.select +``` + +*** + +### staleTime? + +```ts +optional staleTime: StaleTimeFunction; +``` + +Defined in: [packages/query-core/src/types.ts:407](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L407) + +The time in milliseconds after data is considered stale. +If set to `Infinity`, the data will never be considered stale. +If set to `'static'`, the data will never be considered stale. +If set to a function, the function will be executed with the query to compute a `staleTime`. + +Defaults to `0`. + +#### Inherited from + +```ts +OmitKeyof.staleTime +``` + +*** + +### structuralSharing? + +```ts +optional structuralSharing: boolean | (oldData, newData) => unknown; +``` + +Defined in: [packages/query-core/src/types.ts:330](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L330) + +Set this to `false` to disable structural sharing between query results. +Set this to a function which accepts the old and new data and returns resolved data of the same type to implement custom structural sharing logic. + +Defaults to `true`. + +#### Inherited from + +```ts +OmitKeyof.structuralSharing +``` + +*** + +### throwOnError? + +```ts +optional throwOnError: ThrowOnError; +``` + +Defined in: [packages/query-core/src/types.ts:493](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L493) + +Whether errors should be thrown instead of setting the `error` property. +If set to `true` or `suspense` is `true`, all errors will be thrown to the error boundary. +If set to `false` and `suspense` is `false`, errors are returned as state. +If set to a function, it will be passed the error and the query, and it should return a boolean indicating whether to show the error in an error boundary (`true`) or return the error as state (`false`). + +Defaults to `false`. + +#### Inherited from + +```ts +OmitKeyof.throwOnError +``` diff --git a/docs/framework/angular/reference/interfaces/DefaultOptions.md b/docs/framework/angular/reference/interfaces/DefaultOptions.md new file mode 100644 index 00000000000..e45a56f075f --- /dev/null +++ b/docs/framework/angular/reference/interfaces/DefaultOptions.md @@ -0,0 +1,84 @@ +--- +id: DefaultOptions +title: DefaultOptions +--- + +Defined in: [packages/query-core/src/types.ts:1507](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1507) + +## Type Parameters + +### TError + +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) + +## Properties + +### dehydrate? + +```ts +optional dehydrate: DehydrateOptions; +``` + +Defined in: [packages/query-core/src/types.ts:1518](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1518) + +Default options used when dehydrating the client's caches; see [DehydrateOptions](DehydrateOptions.md). + +*** + +### hydrate? + +```ts +optional hydrate: object; +``` + +Defined in: [packages/query-core/src/types.ts:1516](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1516) + +Default options used when hydrating queries; see [HydrateOptions](HydrateOptions.md). + +#### deserializeData? + +```ts +optional deserializeData: TransformerFn; +``` + +Transforms a query's `data` after it is read from the dehydrated state, reversing `serializeData`. + +#### mutations? + +```ts +optional mutations: MutationOptions; +``` + +Default options merged into every mutation restored from the dehydrated state. + +#### queries? + +```ts +optional queries: QueryOptions; +``` + +Default options merged into every query restored from the dehydrated state. + +*** + +### mutations? + +```ts +optional mutations: MutationObserverOptions; +``` + +Defined in: [packages/query-core/src/types.ts:1514](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1514) + +Default options applied to every mutation, unless overridden per-mutation. + +*** + +### queries? + +```ts +optional queries: OmitKeyof, "queryKey" | "suspense", "strictly">; +``` + +Defined in: [packages/query-core/src/types.ts:1509](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1509) + +Default options applied to every query, unless overridden per-query. diff --git a/docs/framework/angular/reference/interfaces/DehydrateOptions.md b/docs/framework/angular/reference/interfaces/DehydrateOptions.md new file mode 100644 index 00000000000..e862ae88b43 --- /dev/null +++ b/docs/framework/angular/reference/interfaces/DehydrateOptions.md @@ -0,0 +1,89 @@ +--- +id: DehydrateOptions +title: DehydrateOptions +--- + +Defined in: [packages/query-core/src/hydration.ts:42](https://github.com/TanStack/query/blob/main/packages/query-core/src/hydration.ts#L42) + +Options for `dehydrate`, controlling which queries/mutations are included in the resulting `DehydratedState` and +how their data/errors are transformed before being serialized (e.g. for embedding in server-rendered markup). + +## Properties + +### serializeData? + +```ts +optional serializeData: TransformerFn; +``` + +Defined in: [packages/query-core/src/hydration.ts:44](https://github.com/TanStack/query/blob/main/packages/query-core/src/hydration.ts#L44) + +Transforms a query's `data` before it is dehydrated. Useful for non-JSON-serializable data. + +*** + +### shouldDehydrateMutation()? + +```ts +optional shouldDehydrateMutation: (mutation) => boolean; +``` + +Defined in: [packages/query-core/src/hydration.ts:46](https://github.com/TanStack/query/blob/main/packages/query-core/src/hydration.ts#L46) + +Predicate to decide whether a given `Mutation` should be dehydrated. Defaults to `defaultShouldDehydrateMutation`. + +#### Parameters + +##### mutation + +[`Mutation`](../classes/Mutation.md) + +#### Returns + +`boolean` + +*** + +### shouldDehydrateQuery()? + +```ts +optional shouldDehydrateQuery: (query) => boolean; +``` + +Defined in: [packages/query-core/src/hydration.ts:48](https://github.com/TanStack/query/blob/main/packages/query-core/src/hydration.ts#L48) + +Predicate to decide whether a given `Query` should be dehydrated. Defaults to `defaultShouldDehydrateQuery`. + +#### Parameters + +##### query + +[`Query`](../classes/Query.md) + +#### Returns + +`boolean` + +*** + +### shouldRedactErrors()? + +```ts +optional shouldRedactErrors: (error) => boolean; +``` + +Defined in: [packages/query-core/src/hydration.ts:54](https://github.com/TanStack/query/blob/main/packages/query-core/src/hydration.ts#L54) + +Predicate to decide whether a query's error should be redacted before dehydration. Errors are redacted +(replaced with a generic `Error('redacted')`) unless this function is provided and returns `false` for the +given error, in which case the original error is kept. + +#### Parameters + +##### error + +`unknown` + +#### Returns + +`boolean` diff --git a/docs/framework/angular/reference/interfaces/DehydratedState.md b/docs/framework/angular/reference/interfaces/DehydratedState.md new file mode 100644 index 00000000000..be034c9e8fd --- /dev/null +++ b/docs/framework/angular/reference/interfaces/DehydratedState.md @@ -0,0 +1,30 @@ +--- +id: DehydratedState +title: DehydratedState +--- + +Defined in: [packages/query-core/src/hydration.ts:94](https://github.com/TanStack/query/blob/main/packages/query-core/src/hydration.ts#L94) + +A serializable snapshot of a `QueryClient`'s cache, as produced by `dehydrate` and consumed by `hydrate`. Typically +transported from server to client (e.g. embedded in server-rendered markup) to seed the client's cache with data +that has already been fetched, avoiding a redundant fetch on the client. + +## Properties + +### mutations + +```ts +mutations: DehydratedMutation[]; +``` + +Defined in: [packages/query-core/src/hydration.ts:95](https://github.com/TanStack/query/blob/main/packages/query-core/src/hydration.ts#L95) + +*** + +### queries + +```ts +queries: DehydratedQuery[]; +``` + +Defined in: [packages/query-core/src/hydration.ts:96](https://github.com/TanStack/query/blob/main/packages/query-core/src/hydration.ts#L96) diff --git a/docs/framework/angular/reference/interfaces/EnsureQueryDataOptions.md b/docs/framework/angular/reference/interfaces/EnsureQueryDataOptions.md new file mode 100644 index 00000000000..a67082af57e --- /dev/null +++ b/docs/framework/angular/reference/interfaces/EnsureQueryDataOptions.md @@ -0,0 +1,350 @@ +--- +id: EnsureQueryDataOptions +title: EnsureQueryDataOptions +--- + +Defined in: [packages/query-core/src/types.ts:614](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L614) + +## Deprecated + +## Extends + +- [`FetchQueryOptions`](FetchQueryOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`, `TPageParam`\> + +## Type Parameters + +### TQueryFnData + +`TQueryFnData` = `unknown` + +### TError + +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) + +### TData + +`TData` = `TQueryFnData` + +### TQueryKey + +`TQueryKey` *extends* [`QueryKey`](../type-aliases/QueryKey.md) = [`QueryKey`](../type-aliases/QueryKey.md) + +### TPageParam + +`TPageParam` = `never` + +## Properties + +### ~~gcTime?~~ + +```ts +optional gcTime: number; +``` + +Defined in: [packages/query-core/src/types.ts:277](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L277) + +The time in milliseconds that unused/inactive cache data remains in memory. +When a query's cache becomes unused or inactive, that cache data will be garbage collected after this duration. +When different garbage collection times are specified, the longest one will be used. +Setting it to `Infinity` will disable garbage collection. + +Defaults to `5 * 60 * 1000` (5 minutes), or `Infinity` during SSR. + +Note: the maximum allowed time is about 24 days, imposed by `setTimeout`'s 32-bit signed integer delay — see +`timeoutManager.setTimeoutProvider` for a workaround. + +#### Inherited from + +[`FetchQueryOptions`](FetchQueryOptions.md).[`gcTime`](FetchQueryOptions.md#gctime) + +*** + +### ~~initialData?~~ + +```ts +optional initialData: + | TData +| InitialDataFunction; +``` + +Defined in: [packages/query-core/src/types.ts:317](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L317) + +If set, this value will be used as the initial data for the query cache (as long as the query hasn't been +created or cached yet). +If set to a function, the function will be called **once** during the shared/root query initialization, and be +expected to synchronously return the initial data. +Initial data is considered stale by default unless a `staleTime` has been set. +`initialData` **is persisted** to the cache. + +#### Inherited from + +[`FetchQueryOptions`](FetchQueryOptions.md).[`initialData`](FetchQueryOptions.md#initialdata) + +*** + +### ~~initialDataUpdatedAt?~~ + +```ts +optional initialDataUpdatedAt: number | () => number | undefined; +``` + +Defined in: [packages/query-core/src/types.ts:321](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L321) + +If set, this value will be used as the time (in milliseconds) of when the `initialData` itself was last updated. + +#### Inherited from + +[`FetchQueryOptions`](FetchQueryOptions.md).[`initialDataUpdatedAt`](FetchQueryOptions.md#initialdataupdatedat) + +*** + +### ~~initialPageParam?~~ + +```ts +optional initialPageParam: undefined; +``` + +Defined in: [packages/query-core/src/types.ts:605](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L605) + +#### Inherited from + +[`FetchQueryOptions`](FetchQueryOptions.md).[`initialPageParam`](FetchQueryOptions.md#initialpageparam) + +*** + +### ~~maxPages?~~ + +```ts +optional maxPages: number; +``` + +Defined in: [packages/query-core/src/types.ts:345](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L345) + +Maximum number of pages to store in the data of an infinite query. + +#### Inherited from + +[`FetchQueryOptions`](FetchQueryOptions.md).[`maxPages`](FetchQueryOptions.md#maxpages) + +*** + +### ~~meta?~~ + +```ts +optional meta: Record; +``` + +Defined in: [packages/query-core/src/types.ts:341](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L341) + +Additional payload to be stored on each query. +Use this property to pass information that can be used in other places. + +#### Inherited from + +[`FetchQueryOptions`](FetchQueryOptions.md).[`meta`](FetchQueryOptions.md#meta) + +*** + +### ~~networkMode?~~ + +```ts +optional networkMode: NetworkMode; +``` + +Defined in: [packages/query-core/src/types.ts:265](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L265) + +Controls whether a query is allowed to run based on the current network connectivity. + +Defaults to `'online'`. + +#### See + +[Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. + +#### Inherited from + +[`FetchQueryOptions`](FetchQueryOptions.md).[`networkMode`](FetchQueryOptions.md#networkmode) + +*** + +### ~~persister?~~ + +```ts +optional persister: QueryPersister, TPageParam>; +``` + +Defined in: [packages/query-core/src/types.ts:290](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L290) + +This option can be used to persist the result of a query to an external storage, bypassing the need to actually +call the `queryFn`. Useful for persisting a query's data across e.g. server/client boundaries. + +#### Inherited from + +[`FetchQueryOptions`](FetchQueryOptions.md).[`persister`](FetchQueryOptions.md#persister) + +*** + +### ~~queryFn?~~ + +```ts +optional queryFn: + | typeof skipToken +| QueryFunction; +``` + +Defined in: [packages/query-core/src/types.ts:285](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L285) + +The function that the query will use to request data. +Required, unless a default query function has been set via `queryClient.setQueryDefaults` or +`queryClient.setDefaultOptions`. +Receives a [QueryFunctionContext](../type-aliases/QueryFunctionContext.md). +Must return a promise that will either resolve data or throw an error. The data cannot be `undefined`. + +#### Inherited from + +[`FetchQueryOptions`](FetchQueryOptions.md).[`queryFn`](FetchQueryOptions.md#queryfn) + +*** + +### ~~queryHash?~~ + +```ts +optional queryHash: string; +``` + +Defined in: [packages/query-core/src/types.ts:295](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L295) + +The hashed form of `queryKey`, computed with `queryKeyHashFn` (or the default hashing function otherwise). Used +as the actual cache key internally. + +#### Inherited from + +[`FetchQueryOptions`](FetchQueryOptions.md).[`queryHash`](FetchQueryOptions.md#queryhash) + +*** + +### ~~queryKey~~ + +```ts +queryKey: TQueryKey & object; +``` + +Defined in: [packages/query-core/src/types.ts:304](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L304) + +The query key to use for this query. + +The query key will be hashed into a stable hash. See [Query Keys](https://tanstack.com/query/latest/docs/framework/react/guides/query-keys) +for more information. + +The query will automatically update when this key changes (as long as `enabled` is not set to `false`). + +#### Inherited from + +[`FetchQueryOptions`](FetchQueryOptions.md).[`queryKey`](FetchQueryOptions.md#querykey) + +*** + +### ~~queryKeyHashFn?~~ + +```ts +optional queryKeyHashFn: QueryKeyHashFunction; +``` + +Defined in: [packages/query-core/src/types.ts:308](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L308) + +If specified, this function is used to hash the `queryKey` to a string. + +#### Inherited from + +[`FetchQueryOptions`](FetchQueryOptions.md).[`queryKeyHashFn`](FetchQueryOptions.md#querykeyhashfn) + +*** + +### ~~retry?~~ + +```ts +optional retry: RetryValue; +``` + +Defined in: [packages/query-core/src/types.ts:246](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L246) + +If `false`, failed queries will not retry by default. +If `true`, failed queries will retry infinitely. +If set to an integer number, e.g. 3, failed queries will retry until the failed query count meets that number. +If set to a function `(failureCount, error) => boolean` failed queries will retry until the function returns false. + +Defaults to `3` on the client and `0` on the server. + +#### Inherited from + +[`FetchQueryOptions`](FetchQueryOptions.md).[`retry`](FetchQueryOptions.md#retry) + +*** + +### ~~retryDelay?~~ + +```ts +optional retryDelay: RetryDelayValue; +``` + +Defined in: [packages/query-core/src/types.ts:258](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L258) + +This function receives a `retryAttempt` integer and the actual Error and returns the delay to apply before the +next attempt in milliseconds. + +A function like `attempt => Math.min(attempt > 1 ? 2 ** attempt * 1000 : 1000, 30 * 1000)` applies exponential +backoff. + +A function like `attempt => attempt * 1000` applies linear backoff. + +Defaults to a function that applies exponential backoff, capped at 30 seconds. + +#### Inherited from + +[`FetchQueryOptions`](FetchQueryOptions.md).[`retryDelay`](FetchQueryOptions.md#retrydelay) + +*** + +### ~~revalidateIfStale?~~ + +```ts +optional revalidateIfStale: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:627](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L627) + +*** + +### ~~staleTime?~~ + +```ts +optional staleTime: StaleTimeFunction; +``` + +Defined in: [packages/query-core/src/types.ts:610](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L610) + +The time in milliseconds after data is considered stale. +If the data is fresh it will be returned from the cache. + +#### Inherited from + +[`FetchQueryOptions`](FetchQueryOptions.md).[`staleTime`](FetchQueryOptions.md#staletime) + +*** + +### ~~structuralSharing?~~ + +```ts +optional structuralSharing: boolean | (oldData, newData) => unknown; +``` + +Defined in: [packages/query-core/src/types.ts:330](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L330) + +Set this to `false` to disable structural sharing between query results. +Set this to a function which accepts the old and new data and returns resolved data of the same type to implement custom structural sharing logic. + +Defaults to `true`. + +#### Inherited from + +[`FetchQueryOptions`](FetchQueryOptions.md).[`structuralSharing`](FetchQueryOptions.md#structuralsharing) diff --git a/docs/framework/angular/reference/interfaces/FetchNextPageOptions.md b/docs/framework/angular/reference/interfaces/FetchNextPageOptions.md new file mode 100644 index 00000000000..b79cdbe19b3 --- /dev/null +++ b/docs/framework/angular/reference/interfaces/FetchNextPageOptions.md @@ -0,0 +1,46 @@ +--- +id: FetchNextPageOptions +title: FetchNextPageOptions +--- + +Defined in: [packages/query-core/src/types.ts:737](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L737) + +## Extends + +- [`ResultOptions`](ResultOptions.md) + +## Properties + +### cancelRefetch? + +```ts +optional cancelRefetch: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:746](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L746) + +If set to `true`, calling `fetchNextPage` repeatedly will invoke `queryFn` every time, +whether the previous invocation has resolved or not. Also, the result from previous invocations will be ignored. + +If set to `false`, calling `fetchNextPage` repeatedly won't have any effect until the first invocation has resolved. + +Defaults to `true`. + +*** + +### throwOnError? + +```ts +optional throwOnError: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:701](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L701) + +If set to `true`, the method throws if any of the underlying query refetch tasks fail. + +Defaults to `false`, in which case failed refetches are swallowed and not surfaced to the +caller. + +#### Inherited from + +[`ResultOptions`](ResultOptions.md).[`throwOnError`](ResultOptions.md#throwonerror) diff --git a/docs/framework/angular/reference/interfaces/FetchPreviousPageOptions.md b/docs/framework/angular/reference/interfaces/FetchPreviousPageOptions.md new file mode 100644 index 00000000000..fd5a08767b6 --- /dev/null +++ b/docs/framework/angular/reference/interfaces/FetchPreviousPageOptions.md @@ -0,0 +1,46 @@ +--- +id: FetchPreviousPageOptions +title: FetchPreviousPageOptions +--- + +Defined in: [packages/query-core/src/types.ts:749](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L749) + +## Extends + +- [`ResultOptions`](ResultOptions.md) + +## Properties + +### cancelRefetch? + +```ts +optional cancelRefetch: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:758](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L758) + +If set to `true`, calling `fetchPreviousPage` repeatedly will invoke `queryFn` every time, +whether the previous invocation has resolved or not. Also, the result from previous invocations will be ignored. + +If set to `false`, calling `fetchPreviousPage` repeatedly won't have any effect until the first invocation has resolved. + +Defaults to `true`. + +*** + +### throwOnError? + +```ts +optional throwOnError: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:701](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L701) + +If set to `true`, the method throws if any of the underlying query refetch tasks fail. + +Defaults to `false`, in which case failed refetches are swallowed and not surfaced to the +caller. + +#### Inherited from + +[`ResultOptions`](ResultOptions.md).[`throwOnError`](ResultOptions.md#throwonerror) diff --git a/docs/framework/angular/reference/interfaces/FetchQueryOptions.md b/docs/framework/angular/reference/interfaces/FetchQueryOptions.md new file mode 100644 index 00000000000..b00973badc0 --- /dev/null +++ b/docs/framework/angular/reference/interfaces/FetchQueryOptions.md @@ -0,0 +1,364 @@ +--- +id: FetchQueryOptions +title: FetchQueryOptions +--- + +Defined in: [packages/query-core/src/types.ts:595](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L595) + +## Deprecated + +## Extends + +- [`WithRequired`](../type-aliases/WithRequired.md)\<[`QueryOptions`](QueryOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`, `TPageParam`\>, `"queryKey"`\> + +## Extended by + +- [`EnsureQueryDataOptions`](EnsureQueryDataOptions.md) + +## Type Parameters + +### TQueryFnData + +`TQueryFnData` = `unknown` + +### TError + +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) + +### TData + +`TData` = `TQueryFnData` + +### TQueryKey + +`TQueryKey` *extends* [`QueryKey`](../type-aliases/QueryKey.md) = [`QueryKey`](../type-aliases/QueryKey.md) + +### TPageParam + +`TPageParam` = `never` + +## Properties + +### ~~gcTime?~~ + +```ts +optional gcTime: number; +``` + +Defined in: [packages/query-core/src/types.ts:277](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L277) + +The time in milliseconds that unused/inactive cache data remains in memory. +When a query's cache becomes unused or inactive, that cache data will be garbage collected after this duration. +When different garbage collection times are specified, the longest one will be used. +Setting it to `Infinity` will disable garbage collection. + +Defaults to `5 * 60 * 1000` (5 minutes), or `Infinity` during SSR. + +Note: the maximum allowed time is about 24 days, imposed by `setTimeout`'s 32-bit signed integer delay — see +`timeoutManager.setTimeoutProvider` for a workaround. + +#### Inherited from + +```ts +WithRequired.gcTime +``` + +*** + +### ~~initialData?~~ + +```ts +optional initialData: + | TData +| InitialDataFunction; +``` + +Defined in: [packages/query-core/src/types.ts:317](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L317) + +If set, this value will be used as the initial data for the query cache (as long as the query hasn't been +created or cached yet). +If set to a function, the function will be called **once** during the shared/root query initialization, and be +expected to synchronously return the initial data. +Initial data is considered stale by default unless a `staleTime` has been set. +`initialData` **is persisted** to the cache. + +#### Inherited from + +```ts +WithRequired.initialData +``` + +*** + +### ~~initialDataUpdatedAt?~~ + +```ts +optional initialDataUpdatedAt: number | () => number | undefined; +``` + +Defined in: [packages/query-core/src/types.ts:321](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L321) + +If set, this value will be used as the time (in milliseconds) of when the `initialData` itself was last updated. + +#### Inherited from + +```ts +WithRequired.initialDataUpdatedAt +``` + +*** + +### ~~initialPageParam?~~ + +```ts +optional initialPageParam: undefined; +``` + +Defined in: [packages/query-core/src/types.ts:605](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L605) + +*** + +### ~~maxPages?~~ + +```ts +optional maxPages: number; +``` + +Defined in: [packages/query-core/src/types.ts:345](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L345) + +Maximum number of pages to store in the data of an infinite query. + +#### Inherited from + +```ts +WithRequired.maxPages +``` + +*** + +### ~~meta?~~ + +```ts +optional meta: Record; +``` + +Defined in: [packages/query-core/src/types.ts:341](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L341) + +Additional payload to be stored on each query. +Use this property to pass information that can be used in other places. + +#### Inherited from + +```ts +WithRequired.meta +``` + +*** + +### ~~networkMode?~~ + +```ts +optional networkMode: NetworkMode; +``` + +Defined in: [packages/query-core/src/types.ts:265](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L265) + +Controls whether a query is allowed to run based on the current network connectivity. + +Defaults to `'online'`. + +#### See + +[Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. + +#### Inherited from + +```ts +WithRequired.networkMode +``` + +*** + +### ~~persister?~~ + +```ts +optional persister: QueryPersister, TPageParam>; +``` + +Defined in: [packages/query-core/src/types.ts:290](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L290) + +This option can be used to persist the result of a query to an external storage, bypassing the need to actually +call the `queryFn`. Useful for persisting a query's data across e.g. server/client boundaries. + +#### Inherited from + +```ts +WithRequired.persister +``` + +*** + +### ~~queryFn?~~ + +```ts +optional queryFn: + | typeof skipToken +| QueryFunction; +``` + +Defined in: [packages/query-core/src/types.ts:285](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L285) + +The function that the query will use to request data. +Required, unless a default query function has been set via `queryClient.setQueryDefaults` or +`queryClient.setDefaultOptions`. +Receives a [QueryFunctionContext](../type-aliases/QueryFunctionContext.md). +Must return a promise that will either resolve data or throw an error. The data cannot be `undefined`. + +#### Inherited from + +```ts +WithRequired.queryFn +``` + +*** + +### ~~queryHash?~~ + +```ts +optional queryHash: string; +``` + +Defined in: [packages/query-core/src/types.ts:295](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L295) + +The hashed form of `queryKey`, computed with `queryKeyHashFn` (or the default hashing function otherwise). Used +as the actual cache key internally. + +#### Inherited from + +```ts +WithRequired.queryHash +``` + +*** + +### ~~queryKey~~ + +```ts +queryKey: TQueryKey & object; +``` + +Defined in: [packages/query-core/src/types.ts:304](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L304) + +The query key to use for this query. + +The query key will be hashed into a stable hash. See [Query Keys](https://tanstack.com/query/latest/docs/framework/react/guides/query-keys) +for more information. + +The query will automatically update when this key changes (as long as `enabled` is not set to `false`). + +#### Inherited from + +```ts +WithRequired.queryKey +``` + +*** + +### ~~queryKeyHashFn?~~ + +```ts +optional queryKeyHashFn: QueryKeyHashFunction; +``` + +Defined in: [packages/query-core/src/types.ts:308](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L308) + +If specified, this function is used to hash the `queryKey` to a string. + +#### Inherited from + +```ts +WithRequired.queryKeyHashFn +``` + +*** + +### ~~retry?~~ + +```ts +optional retry: RetryValue; +``` + +Defined in: [packages/query-core/src/types.ts:246](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L246) + +If `false`, failed queries will not retry by default. +If `true`, failed queries will retry infinitely. +If set to an integer number, e.g. 3, failed queries will retry until the failed query count meets that number. +If set to a function `(failureCount, error) => boolean` failed queries will retry until the function returns false. + +Defaults to `3` on the client and `0` on the server. + +#### Inherited from + +```ts +WithRequired.retry +``` + +*** + +### ~~retryDelay?~~ + +```ts +optional retryDelay: RetryDelayValue; +``` + +Defined in: [packages/query-core/src/types.ts:258](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L258) + +This function receives a `retryAttempt` integer and the actual Error and returns the delay to apply before the +next attempt in milliseconds. + +A function like `attempt => Math.min(attempt > 1 ? 2 ** attempt * 1000 : 1000, 30 * 1000)` applies exponential +backoff. + +A function like `attempt => attempt * 1000` applies linear backoff. + +Defaults to a function that applies exponential backoff, capped at 30 seconds. + +#### Inherited from + +```ts +WithRequired.retryDelay +``` + +*** + +### ~~staleTime?~~ + +```ts +optional staleTime: StaleTimeFunction; +``` + +Defined in: [packages/query-core/src/types.ts:610](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L610) + +The time in milliseconds after data is considered stale. +If the data is fresh it will be returned from the cache. + +*** + +### ~~structuralSharing?~~ + +```ts +optional structuralSharing: boolean | (oldData, newData) => unknown; +``` + +Defined in: [packages/query-core/src/types.ts:330](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L330) + +Set this to `false` to disable structural sharing between query results. +Set this to a function which accepts the old and new data and returns resolved data of the same type to implement custom structural sharing logic. + +Defaults to `true`. + +#### Inherited from + +```ts +WithRequired.structuralSharing +``` diff --git a/docs/framework/angular/reference/interfaces/FocusManager.md b/docs/framework/angular/reference/interfaces/FocusManager.md new file mode 100644 index 00000000000..1ab81dc6357 --- /dev/null +++ b/docs/framework/angular/reference/interfaces/FocusManager.md @@ -0,0 +1,237 @@ +--- +id: FocusManager +title: FocusManager +--- + +Defined in: [packages/query-core/src/focusManager.ts:14](https://github.com/TanStack/query/blob/main/packages/query-core/src/focusManager.ts#L14) + +The `FocusManager` manages the focus state within TanStack Query. + +It can be used to change the default event listeners or to manually change the focus state. + +## Extends + +- `Subscribable`\<`Listener`\> + +## Properties + +### listeners + +```ts +protected listeners: Set; +``` + +Defined in: [packages/query-core/src/subscribable.ts:2](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L2) + +#### Inherited from + +```ts +Subscribable.listeners +``` + +## Methods + +### hasListeners() + +```ts +hasListeners(): boolean; +``` + +Defined in: [packages/query-core/src/subscribable.ts:19](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L19) + +#### Returns + +`boolean` + +#### Inherited from + +```ts +Subscribable.hasListeners +``` + +*** + +### isFocused() + +```ts +isFocused(): boolean; +``` + +Defined in: [packages/query-core/src/focusManager.ts:128](https://github.com/TanStack/query/blob/main/packages/query-core/src/focusManager.ts#L128) + +`isFocused` can be used to get the current focus state. + +#### Returns + +`boolean` + +*** + +### onFocus() + +```ts +onFocus(): void; +``` + +Defined in: [packages/query-core/src/focusManager.ts:118](https://github.com/TanStack/query/blob/main/packages/query-core/src/focusManager.ts#L118) + +`onFocus` notifies all subscribed listeners with the current focus state. + +#### Returns + +`void` + +*** + +### onSubscribe() + +```ts +protected onSubscribe(): void; +``` + +Defined in: [packages/query-core/src/focusManager.ts:39](https://github.com/TanStack/query/blob/main/packages/query-core/src/focusManager.ts#L39) + +#### Returns + +`void` + +#### Overrides + +```ts +Subscribable.onSubscribe +``` + +*** + +### onUnsubscribe() + +```ts +protected onUnsubscribe(): void; +``` + +Defined in: [packages/query-core/src/focusManager.ts:45](https://github.com/TanStack/query/blob/main/packages/query-core/src/focusManager.ts#L45) + +#### Returns + +`void` + +#### Overrides + +```ts +Subscribable.onUnsubscribe +``` + +*** + +### setEventListener() + +```ts +setEventListener(setup): void; +``` + +Defined in: [packages/query-core/src/focusManager.ts:77](https://github.com/TanStack/query/blob/main/packages/query-core/src/focusManager.ts#L77) + +`setEventListener` can be used to set a custom event listener that will +be used to determine the focus state. The provided `setup` function +receives a `setFocused` callback: call it with a `boolean` to manually +set the focus state, or with no arguments to re-evaluate the current +focus state and notify subscribers. + +#### Parameters + +##### setup + +`SetupFn` + +#### Returns + +`void` + +#### Example + +```ts +import { focusManager } from '@tanstack/query-core' + +focusManager.setEventListener((handleFocus) => { + const listener = () => handleFocus() + // Listen to visibilitychange + if (typeof window !== 'undefined' && window.addEventListener) { + window.addEventListener('visibilitychange', listener, false) + } + + return () => { + // Be sure to unsubscribe if a new handler is set + window.removeEventListener('visibilitychange', listener) + } +}) +``` + +*** + +### setFocused() + +```ts +setFocused(focused?): void; +``` + +Defined in: [packages/query-core/src/focusManager.ts:107](https://github.com/TanStack/query/blob/main/packages/query-core/src/focusManager.ts#L107) + +`setFocused` can be used to manually set the focus state. Set `undefined` +to fall back to the default focus check. + +#### Parameters + +##### focused? + +`boolean` + +#### Returns + +`void` + +#### Example + +```ts +import { focusManager } from '@tanstack/query-core' + +// Set focused +focusManager.setFocused(true) + +// Set unfocused +focusManager.setFocused(false) + +// Fallback to the default focus check +focusManager.setFocused(undefined) +``` + +*** + +### subscribe() + +```ts +subscribe(listener): () => void; +``` + +Defined in: [packages/query-core/src/subscribable.ts:8](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L8) + +#### Parameters + +##### listener + +`Listener` + +#### Returns + +```ts +(): void; +``` + +##### Returns + +`void` + +#### Inherited from + +```ts +Subscribable.subscribe +``` diff --git a/docs/framework/angular/reference/interfaces/HydrateOptions.md b/docs/framework/angular/reference/interfaces/HydrateOptions.md new file mode 100644 index 00000000000..fe8b92317e3 --- /dev/null +++ b/docs/framework/angular/reference/interfaces/HydrateOptions.md @@ -0,0 +1,43 @@ +--- +id: HydrateOptions +title: HydrateOptions +--- + +Defined in: [packages/query-core/src/hydration.ts:61](https://github.com/TanStack/query/blob/main/packages/query-core/src/hydration.ts#L61) + +Options for `hydrate`, controlling the default options applied to queries/mutations restored from a +`DehydratedState`, and how to reverse any transformation applied by `DehydrateOptions.serializeData`. + +## Properties + +### defaultOptions? + +```ts +optional defaultOptions: object; +``` + +Defined in: [packages/query-core/src/hydration.ts:62](https://github.com/TanStack/query/blob/main/packages/query-core/src/hydration.ts#L62) + +#### deserializeData? + +```ts +optional deserializeData: TransformerFn; +``` + +Transforms a query's `data` after it is read from the dehydrated state, reversing `serializeData`. + +#### mutations? + +```ts +optional mutations: MutationOptions; +``` + +Default options merged into every mutation restored from the dehydrated state. + +#### queries? + +```ts +optional queries: QueryOptions; +``` + +Default options merged into every query restored from the dehydrated state. diff --git a/docs/framework/angular/reference/interfaces/InfiniteData.md b/docs/framework/angular/reference/interfaces/InfiniteData.md new file mode 100644 index 00000000000..4d7ad595c2d --- /dev/null +++ b/docs/framework/angular/reference/interfaces/InfiniteData.md @@ -0,0 +1,36 @@ +--- +id: InfiniteData +title: InfiniteData +--- + +Defined in: [packages/query-core/src/types.ts:210](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L210) + +## Type Parameters + +### TData + +`TData` + +### TPageParam + +`TPageParam` = `unknown` + +## Properties + +### pageParams + +```ts +pageParams: TPageParam[]; +``` + +Defined in: [packages/query-core/src/types.ts:212](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L212) + +*** + +### pages + +```ts +pages: TData[]; +``` + +Defined in: [packages/query-core/src/types.ts:211](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L211) diff --git a/docs/framework/angular/reference/interfaces/InfiniteQueryObserverBaseResult.md b/docs/framework/angular/reference/interfaces/InfiniteQueryObserverBaseResult.md new file mode 100644 index 00000000000..0aa01962aa5 --- /dev/null +++ b/docs/framework/angular/reference/interfaces/InfiniteQueryObserverBaseResult.md @@ -0,0 +1,577 @@ +--- +id: InfiniteQueryObserverBaseResult +title: InfiniteQueryObserverBaseResult +--- + +Defined in: [packages/query-core/src/types.ts:1001](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1001) + +## Extends + +- [`QueryObserverBaseResult`](QueryObserverBaseResult.md)\<`TData`, `TError`\> + +## Extended by + +- [`InfiniteQueryObserverPendingResult`](InfiniteQueryObserverPendingResult.md) +- [`InfiniteQueryObserverLoadingResult`](InfiniteQueryObserverLoadingResult.md) +- [`InfiniteQueryObserverLoadingErrorResult`](InfiniteQueryObserverLoadingErrorResult.md) +- [`InfiniteQueryObserverRefetchErrorResult`](InfiniteQueryObserverRefetchErrorResult.md) +- [`InfiniteQueryObserverSuccessResult`](InfiniteQueryObserverSuccessResult.md) +- [`InfiniteQueryObserverPlaceholderResult`](InfiniteQueryObserverPlaceholderResult.md) + +## Type Parameters + +### TData + +`TData` = `unknown` + +### TError + +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) + +## Properties + +### data + +```ts +data: TData | undefined; +``` + +Defined in: [packages/query-core/src/types.ts:771](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L771) + +The last successfully resolved data for the query. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`data`](QueryObserverBaseResult.md#data) + +*** + +### dataUpdatedAt + +```ts +dataUpdatedAt: number; +``` + +Defined in: [packages/query-core/src/types.ts:775](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L775) + +The timestamp for when the query most recently returned the `status` as `"success"`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`dataUpdatedAt`](QueryObserverBaseResult.md#dataupdatedat) + +*** + +### error + +```ts +error: TError | null; +``` + +Defined in: [packages/query-core/src/types.ts:780](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L780) + +The error object for the query, if an error was thrown. +- Defaults to `null`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`error`](QueryObserverBaseResult.md#error) + +*** + +### errorUpdateCount + +```ts +errorUpdateCount: number; +``` + +Defined in: [packages/query-core/src/types.ts:799](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L799) + +The sum of all errors. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`errorUpdateCount`](QueryObserverBaseResult.md#errorupdatecount) + +*** + +### errorUpdatedAt + +```ts +errorUpdatedAt: number; +``` + +Defined in: [packages/query-core/src/types.ts:784](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L784) + +The timestamp for when the query most recently returned the `status` as `"error"`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`errorUpdatedAt`](QueryObserverBaseResult.md#errorupdatedat) + +*** + +### failureCount + +```ts +failureCount: number; +``` + +Defined in: [packages/query-core/src/types.ts:790](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L790) + +The failure count for the query. +- Incremented every time the query fails. +- Reset to `0` when the query succeeds. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`failureCount`](QueryObserverBaseResult.md#failurecount) + +*** + +### failureReason + +```ts +failureReason: TError | null; +``` + +Defined in: [packages/query-core/src/types.ts:795](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L795) + +The failure reason for the query retry. +- Reset to `null` when the query succeeds. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`failureReason`](QueryObserverBaseResult.md#failurereason) + +*** + +### fetchNextPage() + +```ts +fetchNextPage: (options?) => Promise>; +``` + +Defined in: [packages/query-core/src/types.ts:1008](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1008) + +This function allows you to fetch the next "page" of results. + +#### Parameters + +##### options? + +[`FetchNextPageOptions`](FetchNextPageOptions.md) + +#### Returns + +`Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> + +*** + +### fetchPreviousPage() + +```ts +fetchPreviousPage: (options?) => Promise>; +``` + +Defined in: [packages/query-core/src/types.ts:1014](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1014) + +This function allows you to fetch the previous "page" of results. + +#### Parameters + +##### options? + +[`FetchPreviousPageOptions`](FetchPreviousPageOptions.md) + +#### Returns + +`Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> + +*** + +### fetchStatus + +```ts +fetchStatus: FetchStatus; +``` + +Defined in: [packages/query-core/src/types.ts:889](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L889) + +The fetch status of the query. +- `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. +- `paused`: The query wanted to fetch, but has been `paused`. +- `idle`: The query is not fetching. +- See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`fetchStatus`](QueryObserverBaseResult.md#fetchstatus) + +*** + +### hasNextPage + +```ts +hasNextPage: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1020](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1020) + +Will be `true` if there is a next page to be fetched (known via the `getNextPageParam` option). + +*** + +### hasPreviousPage + +```ts +hasPreviousPage: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1024](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1024) + +Will be `true` if there is a previous page to be fetched (known via the `getPreviousPageParam` option). + +*** + +### isEnabled + +```ts +isEnabled: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:867](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L867) + +`true` if this observer is enabled, `false` otherwise. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isEnabled`](QueryObserverBaseResult.md#isenabled) + +*** + +### isError + +```ts +isError: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:804](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L804) + +A derived boolean from the `status` variable, provided for convenience. +- `true` if the query attempt resulted in an error. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isError`](QueryObserverBaseResult.md#iserror) + +*** + +### isFetched + +```ts +isFetched: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:808](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L808) + +Will be `true` if the query has been fetched. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isFetched`](QueryObserverBaseResult.md#isfetched) + +*** + +### isFetchedAfterMount + +```ts +isFetchedAfterMount: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:813](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L813) + +Will be `true` if the query has been fetched after the component mounted. +- This property can be used to not show any previously cached data. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isFetchedAfterMount`](QueryObserverBaseResult.md#isfetchedaftermount) + +*** + +### isFetching + +```ts +isFetching: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:818](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L818) + +A derived boolean from the `fetchStatus` variable, provided for convenience. +- `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isFetching`](QueryObserverBaseResult.md#isfetching) + +*** + +### isFetchingNextPage + +```ts +isFetchingNextPage: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1032](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1032) + +Will be `true` while fetching the next page with `fetchNextPage`. + +*** + +### isFetchingPreviousPage + +```ts +isFetchingPreviousPage: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1040](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1040) + +Will be `true` while fetching the previous page with `fetchPreviousPage`. + +*** + +### isFetchNextPageError + +```ts +isFetchNextPageError: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1028](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1028) + +Will be `true` if the query failed while fetching the next page. + +*** + +### isFetchPreviousPageError + +```ts +isFetchPreviousPageError: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1036](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1036) + +Will be `true` if the query failed while fetching the previous page. + +*** + +### ~~isInitialLoading~~ + +```ts +isInitialLoading: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:836](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L836) + +#### Deprecated + +`isInitialLoading` is being deprecated in favor of `isLoading` +and will be removed in the next major version. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isInitialLoading`](QueryObserverBaseResult.md#isinitialloading) + +*** + +### isLoading + +```ts +isLoading: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:823](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L823) + +Is `true` whenever the first fetch for a query is in-flight. +- Is the same as `isFetching && isPending`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoading`](QueryObserverBaseResult.md#isloading) + +*** + +### isLoadingError + +```ts +isLoadingError: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:831](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L831) + +Will be `true` if the query failed while fetching for the first time. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoadingError`](QueryObserverBaseResult.md#isloadingerror) + +*** + +### isPaused + +```ts +isPaused: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:841](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L841) + +A derived boolean from the `fetchStatus` variable, provided for convenience. +- The query wanted to fetch, but has been `paused`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPaused`](QueryObserverBaseResult.md#ispaused) + +*** + +### isPending + +```ts +isPending: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:827](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L827) + +Will be `pending` if there's no cached data and no query attempt was finished yet. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPending`](QueryObserverBaseResult.md#ispending) + +*** + +### isPlaceholderData + +```ts +isPlaceholderData: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:845](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L845) + +Will be `true` if the data shown is the placeholder data. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPlaceholderData`](QueryObserverBaseResult.md#isplaceholderdata) + +*** + +### isRefetchError + +```ts +isRefetchError: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:849](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L849) + +Will be `true` if the query failed while refetching. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetchError`](QueryObserverBaseResult.md#isrefetcherror) + +*** + +### isRefetching + +```ts +isRefetching: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:854](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L854) + +Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. +- Is the same as `isFetching && !isPending`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetching`](QueryObserverBaseResult.md#isrefetching) + +*** + +### isStale + +```ts +isStale: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:858](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L858) + +Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isStale`](QueryObserverBaseResult.md#isstale) + +*** + +### isSuccess + +```ts +isSuccess: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:863](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L863) + +A derived boolean from the `status` variable, provided for convenience. +- `true` if the query has received a response with no errors and is ready to display its data. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isSuccess`](QueryObserverBaseResult.md#issuccess) + +*** + +### refetch() + +```ts +refetch: (options?) => Promise>; +``` + +Defined in: [packages/query-core/src/types.ts:871](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L871) + +A function to manually refetch the query. + +#### Parameters + +##### options? + +[`RefetchOptions`](RefetchOptions.md) + +#### Returns + +`Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`refetch`](QueryObserverBaseResult.md#refetch) + +*** + +### status + +```ts +status: QueryStatus; +``` + +Defined in: [packages/query-core/src/types.ts:881](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L881) + +The status of the query. +- Will be: + - `pending` if there's no cached data and no query attempt was finished yet. + - `error` if the query attempt resulted in an error. + - `success` if the query has received a response with no errors and is ready to display its data. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`status`](QueryObserverBaseResult.md#status) diff --git a/docs/framework/angular/reference/interfaces/InfiniteQueryObserverLoadingErrorResult.md b/docs/framework/angular/reference/interfaces/InfiniteQueryObserverLoadingErrorResult.md new file mode 100644 index 00000000000..f5e3352f27c --- /dev/null +++ b/docs/framework/angular/reference/interfaces/InfiniteQueryObserverLoadingErrorResult.md @@ -0,0 +1,600 @@ +--- +id: InfiniteQueryObserverLoadingErrorResult +title: InfiniteQueryObserverLoadingErrorResult +--- + +Defined in: [packages/query-core/src/types.ts:1078](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1078) + +## Extends + +- [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md)\<`TData`, `TError`\> + +## Type Parameters + +### TData + +`TData` = `unknown` + +### TError + +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) + +## Properties + +### data + +```ts +data: undefined; +``` + +Defined in: [packages/query-core/src/types.ts:1082](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1082) + +The last successfully resolved data for the query. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`data`](InfiniteQueryObserverBaseResult.md#data) + +*** + +### dataUpdatedAt + +```ts +dataUpdatedAt: number; +``` + +Defined in: [packages/query-core/src/types.ts:775](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L775) + +The timestamp for when the query most recently returned the `status` as `"success"`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`dataUpdatedAt`](InfiniteQueryObserverBaseResult.md#dataupdatedat) + +*** + +### error + +```ts +error: TError; +``` + +Defined in: [packages/query-core/src/types.ts:1083](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1083) + +The error object for the query, if an error was thrown. +- Defaults to `null`. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`error`](InfiniteQueryObserverBaseResult.md#error) + +*** + +### errorUpdateCount + +```ts +errorUpdateCount: number; +``` + +Defined in: [packages/query-core/src/types.ts:799](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L799) + +The sum of all errors. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`errorUpdateCount`](InfiniteQueryObserverBaseResult.md#errorupdatecount) + +*** + +### errorUpdatedAt + +```ts +errorUpdatedAt: number; +``` + +Defined in: [packages/query-core/src/types.ts:784](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L784) + +The timestamp for when the query most recently returned the `status` as `"error"`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`errorUpdatedAt`](InfiniteQueryObserverBaseResult.md#errorupdatedat) + +*** + +### failureCount + +```ts +failureCount: number; +``` + +Defined in: [packages/query-core/src/types.ts:790](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L790) + +The failure count for the query. +- Incremented every time the query fails. +- Reset to `0` when the query succeeds. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`failureCount`](InfiniteQueryObserverBaseResult.md#failurecount) + +*** + +### failureReason + +```ts +failureReason: TError | null; +``` + +Defined in: [packages/query-core/src/types.ts:795](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L795) + +The failure reason for the query retry. +- Reset to `null` when the query succeeds. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`failureReason`](InfiniteQueryObserverBaseResult.md#failurereason) + +*** + +### fetchNextPage() + +```ts +fetchNextPage: (options?) => Promise>; +``` + +Defined in: [packages/query-core/src/types.ts:1008](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1008) + +This function allows you to fetch the next "page" of results. + +#### Parameters + +##### options? + +[`FetchNextPageOptions`](FetchNextPageOptions.md) + +#### Returns + +`Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`fetchNextPage`](InfiniteQueryObserverBaseResult.md#fetchnextpage) + +*** + +### fetchPreviousPage() + +```ts +fetchPreviousPage: (options?) => Promise>; +``` + +Defined in: [packages/query-core/src/types.ts:1014](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1014) + +This function allows you to fetch the previous "page" of results. + +#### Parameters + +##### options? + +[`FetchPreviousPageOptions`](FetchPreviousPageOptions.md) + +#### Returns + +`Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`fetchPreviousPage`](InfiniteQueryObserverBaseResult.md#fetchpreviouspage) + +*** + +### fetchStatus + +```ts +fetchStatus: FetchStatus; +``` + +Defined in: [packages/query-core/src/types.ts:889](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L889) + +The fetch status of the query. +- `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. +- `paused`: The query wanted to fetch, but has been `paused`. +- `idle`: The query is not fetching. +- See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`fetchStatus`](InfiniteQueryObserverBaseResult.md#fetchstatus) + +*** + +### hasNextPage + +```ts +hasNextPage: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1020](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1020) + +Will be `true` if there is a next page to be fetched (known via the `getNextPageParam` option). + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`hasNextPage`](InfiniteQueryObserverBaseResult.md#hasnextpage) + +*** + +### hasPreviousPage + +```ts +hasPreviousPage: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1024](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1024) + +Will be `true` if there is a previous page to be fetched (known via the `getPreviousPageParam` option). + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`hasPreviousPage`](InfiniteQueryObserverBaseResult.md#haspreviouspage) + +*** + +### isEnabled + +```ts +isEnabled: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:867](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L867) + +`true` if this observer is enabled, `false` otherwise. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isEnabled`](InfiniteQueryObserverBaseResult.md#isenabled) + +*** + +### isError + +```ts +isError: true; +``` + +Defined in: [packages/query-core/src/types.ts:1084](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1084) + +A derived boolean from the `status` variable, provided for convenience. +- `true` if the query attempt resulted in an error. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isError`](InfiniteQueryObserverBaseResult.md#iserror) + +*** + +### isFetched + +```ts +isFetched: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:808](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L808) + +Will be `true` if the query has been fetched. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetched`](InfiniteQueryObserverBaseResult.md#isfetched) + +*** + +### isFetchedAfterMount + +```ts +isFetchedAfterMount: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:813](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L813) + +Will be `true` if the query has been fetched after the component mounted. +- This property can be used to not show any previously cached data. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchedAfterMount`](InfiniteQueryObserverBaseResult.md#isfetchedaftermount) + +*** + +### isFetching + +```ts +isFetching: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:818](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L818) + +A derived boolean from the `fetchStatus` variable, provided for convenience. +- `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetching`](InfiniteQueryObserverBaseResult.md#isfetching) + +*** + +### isFetchingNextPage + +```ts +isFetchingNextPage: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1032](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1032) + +Will be `true` while fetching the next page with `fetchNextPage`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchingNextPage`](InfiniteQueryObserverBaseResult.md#isfetchingnextpage) + +*** + +### isFetchingPreviousPage + +```ts +isFetchingPreviousPage: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1040](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1040) + +Will be `true` while fetching the previous page with `fetchPreviousPage`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchingPreviousPage`](InfiniteQueryObserverBaseResult.md#isfetchingpreviouspage) + +*** + +### isFetchNextPageError + +```ts +isFetchNextPageError: false; +``` + +Defined in: [packages/query-core/src/types.ts:1089](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1089) + +Will be `true` if the query failed while fetching the next page. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchNextPageError`](InfiniteQueryObserverBaseResult.md#isfetchnextpageerror) + +*** + +### isFetchPreviousPageError + +```ts +isFetchPreviousPageError: false; +``` + +Defined in: [packages/query-core/src/types.ts:1090](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1090) + +Will be `true` if the query failed while fetching the previous page. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchPreviousPageError`](InfiniteQueryObserverBaseResult.md#isfetchpreviouspageerror) + +*** + +### ~~isInitialLoading~~ + +```ts +isInitialLoading: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:836](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L836) + +#### Deprecated + +`isInitialLoading` is being deprecated in favor of `isLoading` +and will be removed in the next major version. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isInitialLoading`](InfiniteQueryObserverBaseResult.md#isinitialloading) + +*** + +### isLoading + +```ts +isLoading: false; +``` + +Defined in: [packages/query-core/src/types.ts:1086](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1086) + +Is `true` whenever the first fetch for a query is in-flight. +- Is the same as `isFetching && isPending`. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoading`](InfiniteQueryObserverBaseResult.md#isloading) + +*** + +### isLoadingError + +```ts +isLoadingError: true; +``` + +Defined in: [packages/query-core/src/types.ts:1087](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1087) + +Will be `true` if the query failed while fetching for the first time. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoadingError`](InfiniteQueryObserverBaseResult.md#isloadingerror) + +*** + +### isPaused + +```ts +isPaused: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:841](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L841) + +A derived boolean from the `fetchStatus` variable, provided for convenience. +- The query wanted to fetch, but has been `paused`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPaused`](InfiniteQueryObserverBaseResult.md#ispaused) + +*** + +### isPending + +```ts +isPending: false; +``` + +Defined in: [packages/query-core/src/types.ts:1085](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1085) + +Will be `pending` if there's no cached data and no query attempt was finished yet. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPending`](InfiniteQueryObserverBaseResult.md#ispending) + +*** + +### isPlaceholderData + +```ts +isPlaceholderData: false; +``` + +Defined in: [packages/query-core/src/types.ts:1092](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1092) + +Will be `true` if the data shown is the placeholder data. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPlaceholderData`](InfiniteQueryObserverBaseResult.md#isplaceholderdata) + +*** + +### isRefetchError + +```ts +isRefetchError: false; +``` + +Defined in: [packages/query-core/src/types.ts:1088](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1088) + +Will be `true` if the query failed while refetching. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isRefetchError`](InfiniteQueryObserverBaseResult.md#isrefetcherror) + +*** + +### isRefetching + +```ts +isRefetching: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:854](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L854) + +Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. +- Is the same as `isFetching && !isPending`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isRefetching`](InfiniteQueryObserverBaseResult.md#isrefetching) + +*** + +### isStale + +```ts +isStale: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:858](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L858) + +Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isStale`](InfiniteQueryObserverBaseResult.md#isstale) + +*** + +### isSuccess + +```ts +isSuccess: false; +``` + +Defined in: [packages/query-core/src/types.ts:1091](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1091) + +A derived boolean from the `status` variable, provided for convenience. +- `true` if the query has received a response with no errors and is ready to display its data. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isSuccess`](InfiniteQueryObserverBaseResult.md#issuccess) + +*** + +### refetch() + +```ts +refetch: (options?) => Promise>; +``` + +Defined in: [packages/query-core/src/types.ts:871](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L871) + +A function to manually refetch the query. + +#### Parameters + +##### options? + +[`RefetchOptions`](RefetchOptions.md) + +#### Returns + +`Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`refetch`](InfiniteQueryObserverBaseResult.md#refetch) + +*** + +### status + +```ts +status: "error"; +``` + +Defined in: [packages/query-core/src/types.ts:1093](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1093) + +The status of the query. +- Will be: + - `pending` if there's no cached data and no query attempt was finished yet. + - `error` if the query attempt resulted in an error. + - `success` if the query has received a response with no errors and is ready to display its data. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`status`](InfiniteQueryObserverBaseResult.md#status) diff --git a/docs/framework/angular/reference/interfaces/InfiniteQueryObserverLoadingResult.md b/docs/framework/angular/reference/interfaces/InfiniteQueryObserverLoadingResult.md new file mode 100644 index 00000000000..b7aa67744c0 --- /dev/null +++ b/docs/framework/angular/reference/interfaces/InfiniteQueryObserverLoadingResult.md @@ -0,0 +1,600 @@ +--- +id: InfiniteQueryObserverLoadingResult +title: InfiniteQueryObserverLoadingResult +--- + +Defined in: [packages/query-core/src/types.ts:1060](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1060) + +## Extends + +- [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md)\<`TData`, `TError`\> + +## Type Parameters + +### TData + +`TData` = `unknown` + +### TError + +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) + +## Properties + +### data + +```ts +data: undefined; +``` + +Defined in: [packages/query-core/src/types.ts:1064](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1064) + +The last successfully resolved data for the query. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`data`](InfiniteQueryObserverBaseResult.md#data) + +*** + +### dataUpdatedAt + +```ts +dataUpdatedAt: number; +``` + +Defined in: [packages/query-core/src/types.ts:775](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L775) + +The timestamp for when the query most recently returned the `status` as `"success"`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`dataUpdatedAt`](InfiniteQueryObserverBaseResult.md#dataupdatedat) + +*** + +### error + +```ts +error: null; +``` + +Defined in: [packages/query-core/src/types.ts:1065](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1065) + +The error object for the query, if an error was thrown. +- Defaults to `null`. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`error`](InfiniteQueryObserverBaseResult.md#error) + +*** + +### errorUpdateCount + +```ts +errorUpdateCount: number; +``` + +Defined in: [packages/query-core/src/types.ts:799](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L799) + +The sum of all errors. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`errorUpdateCount`](InfiniteQueryObserverBaseResult.md#errorupdatecount) + +*** + +### errorUpdatedAt + +```ts +errorUpdatedAt: number; +``` + +Defined in: [packages/query-core/src/types.ts:784](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L784) + +The timestamp for when the query most recently returned the `status` as `"error"`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`errorUpdatedAt`](InfiniteQueryObserverBaseResult.md#errorupdatedat) + +*** + +### failureCount + +```ts +failureCount: number; +``` + +Defined in: [packages/query-core/src/types.ts:790](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L790) + +The failure count for the query. +- Incremented every time the query fails. +- Reset to `0` when the query succeeds. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`failureCount`](InfiniteQueryObserverBaseResult.md#failurecount) + +*** + +### failureReason + +```ts +failureReason: TError | null; +``` + +Defined in: [packages/query-core/src/types.ts:795](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L795) + +The failure reason for the query retry. +- Reset to `null` when the query succeeds. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`failureReason`](InfiniteQueryObserverBaseResult.md#failurereason) + +*** + +### fetchNextPage() + +```ts +fetchNextPage: (options?) => Promise>; +``` + +Defined in: [packages/query-core/src/types.ts:1008](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1008) + +This function allows you to fetch the next "page" of results. + +#### Parameters + +##### options? + +[`FetchNextPageOptions`](FetchNextPageOptions.md) + +#### Returns + +`Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`fetchNextPage`](InfiniteQueryObserverBaseResult.md#fetchnextpage) + +*** + +### fetchPreviousPage() + +```ts +fetchPreviousPage: (options?) => Promise>; +``` + +Defined in: [packages/query-core/src/types.ts:1014](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1014) + +This function allows you to fetch the previous "page" of results. + +#### Parameters + +##### options? + +[`FetchPreviousPageOptions`](FetchPreviousPageOptions.md) + +#### Returns + +`Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`fetchPreviousPage`](InfiniteQueryObserverBaseResult.md#fetchpreviouspage) + +*** + +### fetchStatus + +```ts +fetchStatus: FetchStatus; +``` + +Defined in: [packages/query-core/src/types.ts:889](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L889) + +The fetch status of the query. +- `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. +- `paused`: The query wanted to fetch, but has been `paused`. +- `idle`: The query is not fetching. +- See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`fetchStatus`](InfiniteQueryObserverBaseResult.md#fetchstatus) + +*** + +### hasNextPage + +```ts +hasNextPage: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1020](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1020) + +Will be `true` if there is a next page to be fetched (known via the `getNextPageParam` option). + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`hasNextPage`](InfiniteQueryObserverBaseResult.md#hasnextpage) + +*** + +### hasPreviousPage + +```ts +hasPreviousPage: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1024](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1024) + +Will be `true` if there is a previous page to be fetched (known via the `getPreviousPageParam` option). + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`hasPreviousPage`](InfiniteQueryObserverBaseResult.md#haspreviouspage) + +*** + +### isEnabled + +```ts +isEnabled: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:867](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L867) + +`true` if this observer is enabled, `false` otherwise. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isEnabled`](InfiniteQueryObserverBaseResult.md#isenabled) + +*** + +### isError + +```ts +isError: false; +``` + +Defined in: [packages/query-core/src/types.ts:1066](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1066) + +A derived boolean from the `status` variable, provided for convenience. +- `true` if the query attempt resulted in an error. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isError`](InfiniteQueryObserverBaseResult.md#iserror) + +*** + +### isFetched + +```ts +isFetched: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:808](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L808) + +Will be `true` if the query has been fetched. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetched`](InfiniteQueryObserverBaseResult.md#isfetched) + +*** + +### isFetchedAfterMount + +```ts +isFetchedAfterMount: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:813](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L813) + +Will be `true` if the query has been fetched after the component mounted. +- This property can be used to not show any previously cached data. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchedAfterMount`](InfiniteQueryObserverBaseResult.md#isfetchedaftermount) + +*** + +### isFetching + +```ts +isFetching: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:818](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L818) + +A derived boolean from the `fetchStatus` variable, provided for convenience. +- `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetching`](InfiniteQueryObserverBaseResult.md#isfetching) + +*** + +### isFetchingNextPage + +```ts +isFetchingNextPage: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1032](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1032) + +Will be `true` while fetching the next page with `fetchNextPage`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchingNextPage`](InfiniteQueryObserverBaseResult.md#isfetchingnextpage) + +*** + +### isFetchingPreviousPage + +```ts +isFetchingPreviousPage: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1040](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1040) + +Will be `true` while fetching the previous page with `fetchPreviousPage`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchingPreviousPage`](InfiniteQueryObserverBaseResult.md#isfetchingpreviouspage) + +*** + +### isFetchNextPageError + +```ts +isFetchNextPageError: false; +``` + +Defined in: [packages/query-core/src/types.ts:1071](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1071) + +Will be `true` if the query failed while fetching the next page. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchNextPageError`](InfiniteQueryObserverBaseResult.md#isfetchnextpageerror) + +*** + +### isFetchPreviousPageError + +```ts +isFetchPreviousPageError: false; +``` + +Defined in: [packages/query-core/src/types.ts:1072](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1072) + +Will be `true` if the query failed while fetching the previous page. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchPreviousPageError`](InfiniteQueryObserverBaseResult.md#isfetchpreviouspageerror) + +*** + +### ~~isInitialLoading~~ + +```ts +isInitialLoading: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:836](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L836) + +#### Deprecated + +`isInitialLoading` is being deprecated in favor of `isLoading` +and will be removed in the next major version. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isInitialLoading`](InfiniteQueryObserverBaseResult.md#isinitialloading) + +*** + +### isLoading + +```ts +isLoading: true; +``` + +Defined in: [packages/query-core/src/types.ts:1068](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1068) + +Is `true` whenever the first fetch for a query is in-flight. +- Is the same as `isFetching && isPending`. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoading`](InfiniteQueryObserverBaseResult.md#isloading) + +*** + +### isLoadingError + +```ts +isLoadingError: false; +``` + +Defined in: [packages/query-core/src/types.ts:1069](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1069) + +Will be `true` if the query failed while fetching for the first time. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoadingError`](InfiniteQueryObserverBaseResult.md#isloadingerror) + +*** + +### isPaused + +```ts +isPaused: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:841](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L841) + +A derived boolean from the `fetchStatus` variable, provided for convenience. +- The query wanted to fetch, but has been `paused`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPaused`](InfiniteQueryObserverBaseResult.md#ispaused) + +*** + +### isPending + +```ts +isPending: true; +``` + +Defined in: [packages/query-core/src/types.ts:1067](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1067) + +Will be `pending` if there's no cached data and no query attempt was finished yet. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPending`](InfiniteQueryObserverBaseResult.md#ispending) + +*** + +### isPlaceholderData + +```ts +isPlaceholderData: false; +``` + +Defined in: [packages/query-core/src/types.ts:1074](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1074) + +Will be `true` if the data shown is the placeholder data. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPlaceholderData`](InfiniteQueryObserverBaseResult.md#isplaceholderdata) + +*** + +### isRefetchError + +```ts +isRefetchError: false; +``` + +Defined in: [packages/query-core/src/types.ts:1070](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1070) + +Will be `true` if the query failed while refetching. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isRefetchError`](InfiniteQueryObserverBaseResult.md#isrefetcherror) + +*** + +### isRefetching + +```ts +isRefetching: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:854](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L854) + +Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. +- Is the same as `isFetching && !isPending`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isRefetching`](InfiniteQueryObserverBaseResult.md#isrefetching) + +*** + +### isStale + +```ts +isStale: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:858](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L858) + +Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isStale`](InfiniteQueryObserverBaseResult.md#isstale) + +*** + +### isSuccess + +```ts +isSuccess: false; +``` + +Defined in: [packages/query-core/src/types.ts:1073](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1073) + +A derived boolean from the `status` variable, provided for convenience. +- `true` if the query has received a response with no errors and is ready to display its data. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isSuccess`](InfiniteQueryObserverBaseResult.md#issuccess) + +*** + +### refetch() + +```ts +refetch: (options?) => Promise>; +``` + +Defined in: [packages/query-core/src/types.ts:871](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L871) + +A function to manually refetch the query. + +#### Parameters + +##### options? + +[`RefetchOptions`](RefetchOptions.md) + +#### Returns + +`Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`refetch`](InfiniteQueryObserverBaseResult.md#refetch) + +*** + +### status + +```ts +status: "pending"; +``` + +Defined in: [packages/query-core/src/types.ts:1075](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1075) + +The status of the query. +- Will be: + - `pending` if there's no cached data and no query attempt was finished yet. + - `error` if the query attempt resulted in an error. + - `success` if the query has received a response with no errors and is ready to display its data. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`status`](InfiniteQueryObserverBaseResult.md#status) diff --git a/docs/framework/angular/reference/interfaces/InfiniteQueryObserverOptions.md b/docs/framework/angular/reference/interfaces/InfiniteQueryObserverOptions.md new file mode 100644 index 00000000000..7670bd8e24b --- /dev/null +++ b/docs/framework/angular/reference/interfaces/InfiniteQueryObserverOptions.md @@ -0,0 +1,624 @@ +--- +id: InfiniteQueryObserverOptions +title: InfiniteQueryObserverOptions +--- + +Defined in: [packages/query-core/src/types.ts:539](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L539) + +## Extends + +- [`QueryObserverOptions`](QueryObserverOptions.md)\<`TQueryFnData`, `TError`, `TData`, [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`, `TPageParam`\>.[`InfiniteQueryPageParamsOptions`](InfiniteQueryPageParamsOptions.md)\<`TQueryFnData`, `TPageParam`\> + +## Type Parameters + +### TQueryFnData + +`TQueryFnData` = `unknown` + +### TError + +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) + +### TData + +`TData` = `TQueryFnData` + +### TQueryKey + +`TQueryKey` *extends* [`QueryKey`](../type-aliases/QueryKey.md) = [`QueryKey`](../type-aliases/QueryKey.md) + +### TPageParam + +`TPageParam` = `unknown` + +## Properties + +### enabled? + +```ts +optional enabled: QueryBooleanOption, TQueryKey>; +``` + +Defined in: [packages/query-core/src/types.ts:398](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L398) + +Set this to `false` or a function that returns `false` to disable automatic refetching when the query mounts or changes query keys. +To refetch the query, use the `refetch` method returned from the `useQuery` instance. +Accepts a boolean or function that returns a boolean. + +Defaults to `true`. + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`enabled`](QueryObserverOptions.md#enabled) + +*** + +### gcTime? + +```ts +optional gcTime: number; +``` + +Defined in: [packages/query-core/src/types.ts:277](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L277) + +The time in milliseconds that unused/inactive cache data remains in memory. +When a query's cache becomes unused or inactive, that cache data will be garbage collected after this duration. +When different garbage collection times are specified, the longest one will be used. +Setting it to `Infinity` will disable garbage collection. + +Defaults to `5 * 60 * 1000` (5 minutes), or `Infinity` during SSR. + +Note: the maximum allowed time is about 24 days, imposed by `setTimeout`'s 32-bit signed integer delay — see +`timeoutManager.setTimeoutProvider` for a workaround. + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`gcTime`](QueryObserverOptions.md#gctime) + +*** + +### getNextPageParam + +```ts +getNextPageParam: GetNextPageParamFunction; +``` + +Defined in: [packages/query-core/src/types.ts:365](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L365) + +This function can be set to automatically get the next cursor for infinite queries. +The result will also be used to determine the value of `hasNextPage`. + +#### Inherited from + +[`InfiniteQueryPageParamsOptions`](InfiniteQueryPageParamsOptions.md).[`getNextPageParam`](InfiniteQueryPageParamsOptions.md#getnextpageparam) + +*** + +### getPreviousPageParam? + +```ts +optional getPreviousPageParam: GetPreviousPageParamFunction; +``` + +Defined in: [packages/query-core/src/types.ts:360](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L360) + +This function can be set to automatically get the previous cursor for infinite queries. +The result will also be used to determine the value of `hasPreviousPage`. + +#### Inherited from + +[`InfiniteQueryPageParamsOptions`](InfiniteQueryPageParamsOptions.md).[`getPreviousPageParam`](InfiniteQueryPageParamsOptions.md#getpreviouspageparam) + +*** + +### initialData? + +```ts +optional initialData: + | InfiniteData +| InitialDataFunction>; +``` + +Defined in: [packages/query-core/src/types.ts:317](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L317) + +If set, this value will be used as the initial data for the query cache (as long as the query hasn't been +created or cached yet). +If set to a function, the function will be called **once** during the shared/root query initialization, and be +expected to synchronously return the initial data. +Initial data is considered stale by default unless a `staleTime` has been set. +`initialData` **is persisted** to the cache. + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`initialData`](QueryObserverOptions.md#initialdata) + +*** + +### initialDataUpdatedAt? + +```ts +optional initialDataUpdatedAt: number | () => number | undefined; +``` + +Defined in: [packages/query-core/src/types.ts:321](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L321) + +If set, this value will be used as the time (in milliseconds) of when the `initialData` itself was last updated. + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`initialDataUpdatedAt`](QueryObserverOptions.md#initialdataupdatedat) + +*** + +### initialPageParam + +```ts +initialPageParam: TPageParam; +``` + +Defined in: [packages/query-core/src/types.ts:349](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L349) + +#### Inherited from + +[`InfiniteQueryPageParamsOptions`](InfiniteQueryPageParamsOptions.md).[`initialPageParam`](InfiniteQueryPageParamsOptions.md#initialpageparam) + +*** + +### maxPages? + +```ts +optional maxPages: number; +``` + +Defined in: [packages/query-core/src/types.ts:345](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L345) + +Maximum number of pages to store in the data of an infinite query. + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`maxPages`](QueryObserverOptions.md#maxpages) + +*** + +### meta? + +```ts +optional meta: Record; +``` + +Defined in: [packages/query-core/src/types.ts:341](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L341) + +Additional payload to be stored on each query. +Use this property to pass information that can be used in other places. + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`meta`](QueryObserverOptions.md#meta) + +*** + +### networkMode? + +```ts +optional networkMode: NetworkMode; +``` + +Defined in: [packages/query-core/src/types.ts:265](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L265) + +Controls whether a query is allowed to run based on the current network connectivity. + +Defaults to `'online'`. + +#### See + +[Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`networkMode`](QueryObserverOptions.md#networkmode) + +*** + +### notifyOnChangeProps? + +```ts +optional notifyOnChangeProps: NotifyOnChangeProps; +``` + +Defined in: [packages/query-core/src/types.ts:484](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L484) + +If set, the component will only re-render if any of the listed properties change. +When set to `['data', 'error']`, the component will only re-render when the `data` or `error` properties change. +When set to `'all'`, the component will re-render whenever a query is updated. +When set to a function, the function will be executed to compute the list of properties. + +Defaults to `undefined`, in which case property access is tracked automatically, and the +component only re-renders when one of the tracked properties changes. + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`notifyOnChangeProps`](QueryObserverOptions.md#notifyonchangeprops) + +*** + +### persister? + +```ts +optional persister: QueryPersister, TPageParam>; +``` + +Defined in: [packages/query-core/src/types.ts:290](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L290) + +This option can be used to persist the result of a query to an external storage, bypassing the need to actually +call the `queryFn`. Useful for persisting a query's data across e.g. server/client boundaries. + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`persister`](QueryObserverOptions.md#persister) + +*** + +### placeholderData? + +```ts +optional placeholderData: + | InfiniteData +| PlaceholderDataFunction, TError, InfiniteData, TQueryKey>; +``` + +Defined in: [packages/query-core/src/types.ts:511](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L511) + +If set, this value will be used as the placeholder data for this particular query observer while the query is still in the `loading` data and no initialData has been provided. + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`placeholderData`](QueryObserverOptions.md#placeholderdata) + +*** + +### queryFn? + +```ts +optional queryFn: + | typeof skipToken +| QueryFunction; +``` + +Defined in: [packages/query-core/src/types.ts:285](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L285) + +The function that the query will use to request data. +Required, unless a default query function has been set via `queryClient.setQueryDefaults` or +`queryClient.setDefaultOptions`. +Receives a [QueryFunctionContext](../type-aliases/QueryFunctionContext.md). +Must return a promise that will either resolve data or throw an error. The data cannot be `undefined`. + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`queryFn`](QueryObserverOptions.md#queryfn) + +*** + +### queryHash? + +```ts +optional queryHash: string; +``` + +Defined in: [packages/query-core/src/types.ts:295](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L295) + +The hashed form of `queryKey`, computed with `queryKeyHashFn` (or the default hashing function otherwise). Used +as the actual cache key internally. + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`queryHash`](QueryObserverOptions.md#queryhash) + +*** + +### queryKey + +```ts +queryKey: TQueryKey & object; +``` + +Defined in: [packages/query-core/src/types.ts:304](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L304) + +The query key to use for this query. + +The query key will be hashed into a stable hash. See [Query Keys](https://tanstack.com/query/latest/docs/framework/react/guides/query-keys) +for more information. + +The query will automatically update when this key changes (as long as `enabled` is not set to `false`). + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`queryKey`](QueryObserverOptions.md#querykey) + +*** + +### queryKeyHashFn? + +```ts +optional queryKeyHashFn: QueryKeyHashFunction; +``` + +Defined in: [packages/query-core/src/types.ts:308](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L308) + +If specified, this function is used to hash the `queryKey` to a string. + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`queryKeyHashFn`](QueryObserverOptions.md#querykeyhashfn) + +*** + +### refetchInterval? + +```ts +optional refetchInterval: number | false | (query) => number | false | undefined; +``` + +Defined in: [packages/query-core/src/types.ts:414](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L414) + +If set to a number, the query will continuously refetch at this frequency in milliseconds. +If set to a function, the function will be executed with the latest data and query to compute a frequency + +Defaults to `false`. + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`refetchInterval`](QueryObserverOptions.md#refetchinterval) + +*** + +### refetchIntervalInBackground? + +```ts +optional refetchIntervalInBackground: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:425](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L425) + +If set to `true`, the query will continue to refetch while their tab/window is in the background. + +Defaults to `false`. + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`refetchIntervalInBackground`](QueryObserverOptions.md#refetchintervalinbackground) + +*** + +### refetchOnMount? + +```ts +optional refetchOnMount: boolean | "always" | (query) => boolean | "always"; +``` + +Defined in: [packages/query-core/src/types.ts:462](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L462) + +If set to `true`, the query will refetch on mount if the data is stale. +If set to `false`, will disable additional instances of a query to trigger background refetch. +If set to `'always'`, the query will always refetch on mount (except when `staleTime: 'static'` is used). +If set to a function, the function will be executed with the latest data and query to compute the value + +Defaults to `true`. + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`refetchOnMount`](QueryObserverOptions.md#refetchonmount) + +*** + +### refetchOnReconnect? + +```ts +optional refetchOnReconnect: boolean | "always" | (query) => boolean | "always"; +``` + +Defined in: [packages/query-core/src/types.ts:448](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L448) + +If set to `true`, the query will refetch on reconnect if the data is stale. +If set to `false`, the query will not refetch on reconnect. +If set to `'always'`, the query will always refetch on reconnect (except when `staleTime: 'static'` is used). +If set to a function, the function will be executed with the latest data and query to compute the value. + +Defaults to `true` unless `networkMode` is `'always'`. + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`refetchOnReconnect`](QueryObserverOptions.md#refetchonreconnect) + +*** + +### refetchOnWindowFocus? + +```ts +optional refetchOnWindowFocus: boolean | "always" | (query) => boolean | "always"; +``` + +Defined in: [packages/query-core/src/types.ts:434](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L434) + +If set to `true`, the query will refetch on window focus if the data is stale. +If set to `false`, the query will not refetch on window focus. +If set to `'always'`, the query will always refetch on window focus (except when `staleTime: 'static'` is used). +If set to a function, the function will be executed with the latest data and query to compute the value. + +Defaults to `true`. + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`refetchOnWindowFocus`](QueryObserverOptions.md#refetchonwindowfocus) + +*** + +### retry? + +```ts +optional retry: RetryValue; +``` + +Defined in: [packages/query-core/src/types.ts:246](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L246) + +If `false`, failed queries will not retry by default. +If `true`, failed queries will retry infinitely. +If set to an integer number, e.g. 3, failed queries will retry until the failed query count meets that number. +If set to a function `(failureCount, error) => boolean` failed queries will retry until the function returns false. + +Defaults to `3` on the client and `0` on the server. + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`retry`](QueryObserverOptions.md#retry) + +*** + +### retryDelay? + +```ts +optional retryDelay: RetryDelayValue; +``` + +Defined in: [packages/query-core/src/types.ts:258](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L258) + +This function receives a `retryAttempt` integer and the actual Error and returns the delay to apply before the +next attempt in milliseconds. + +A function like `attempt => Math.min(attempt > 1 ? 2 ** attempt * 1000 : 1000, 30 * 1000)` applies exponential +backoff. + +A function like `attempt => attempt * 1000` applies linear backoff. + +Defaults to a function that applies exponential backoff, capped at 30 seconds. + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`retryDelay`](QueryObserverOptions.md#retrydelay) + +*** + +### retryOnMount? + +```ts +optional retryOnMount: QueryBooleanOption, TQueryKey>; +``` + +Defined in: [packages/query-core/src/types.ts:474](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L474) + +If set to `false`, the query will not be retried on mount if it contains an error. +If set to a function, the function will be executed with the query to compute the value. + +Defaults to `true`. + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`retryOnMount`](QueryObserverOptions.md#retryonmount) + +*** + +### select()? + +```ts +optional select: (data) => TData; +``` + +Defined in: [packages/query-core/src/types.ts:500](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L500) + +This option can be used to transform or select a part of the data returned by the query function. It affects +the returned `data` value, but does not affect what gets stored in the query cache. +The `select` function will only run if `data` changed, or if the reference to the `select` function itself +changes. To optimize, memoize the function so its reference stays stable across calls. + +#### Parameters + +##### data + +[`InfiniteData`](InfiniteData.md) + +#### Returns + +`TData` + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`select`](QueryObserverOptions.md#select) + +*** + +### staleTime? + +```ts +optional staleTime: StaleTimeFunction, TQueryKey>; +``` + +Defined in: [packages/query-core/src/types.ts:407](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L407) + +The time in milliseconds after data is considered stale. +If set to `Infinity`, the data will never be considered stale. +If set to `'static'`, the data will never be considered stale. +If set to a function, the function will be executed with the query to compute a `staleTime`. + +Defaults to `0`. + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`staleTime`](QueryObserverOptions.md#staletime) + +*** + +### structuralSharing? + +```ts +optional structuralSharing: boolean | (oldData, newData) => unknown; +``` + +Defined in: [packages/query-core/src/types.ts:330](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L330) + +Set this to `false` to disable structural sharing between query results. +Set this to a function which accepts the old and new data and returns resolved data of the same type to implement custom structural sharing logic. + +Defaults to `true`. + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`structuralSharing`](QueryObserverOptions.md#structuralsharing) + +*** + +### suspense? + +```ts +optional suspense: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:507](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L507) + +If set to `true`, the query will suspend when `status === 'pending'` +and throw errors when `status === 'error'`. + +Defaults to `false`. + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`suspense`](QueryObserverOptions.md#suspense) + +*** + +### throwOnError? + +```ts +optional throwOnError: ThrowOnError, TQueryKey>; +``` + +Defined in: [packages/query-core/src/types.ts:493](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L493) + +Whether errors should be thrown instead of setting the `error` property. +If set to `true` or `suspense` is `true`, all errors will be thrown to the error boundary. +If set to `false` and `suspense` is `false`, errors are returned as state. +If set to a function, it will be passed the error and the query, and it should return a boolean indicating whether to show the error in an error boundary (`true`) or return the error as state (`false`). + +Defaults to `false`. + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`throwOnError`](QueryObserverOptions.md#throwonerror) diff --git a/docs/framework/angular/reference/interfaces/InfiniteQueryObserverPendingResult.md b/docs/framework/angular/reference/interfaces/InfiniteQueryObserverPendingResult.md new file mode 100644 index 00000000000..a09301ab6c4 --- /dev/null +++ b/docs/framework/angular/reference/interfaces/InfiniteQueryObserverPendingResult.md @@ -0,0 +1,600 @@ +--- +id: InfiniteQueryObserverPendingResult +title: InfiniteQueryObserverPendingResult +--- + +Defined in: [packages/query-core/src/types.ts:1043](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1043) + +## Extends + +- [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md)\<`TData`, `TError`\> + +## Type Parameters + +### TData + +`TData` = `unknown` + +### TError + +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) + +## Properties + +### data + +```ts +data: undefined; +``` + +Defined in: [packages/query-core/src/types.ts:1047](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1047) + +The last successfully resolved data for the query. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`data`](InfiniteQueryObserverBaseResult.md#data) + +*** + +### dataUpdatedAt + +```ts +dataUpdatedAt: number; +``` + +Defined in: [packages/query-core/src/types.ts:775](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L775) + +The timestamp for when the query most recently returned the `status` as `"success"`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`dataUpdatedAt`](InfiniteQueryObserverBaseResult.md#dataupdatedat) + +*** + +### error + +```ts +error: null; +``` + +Defined in: [packages/query-core/src/types.ts:1048](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1048) + +The error object for the query, if an error was thrown. +- Defaults to `null`. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`error`](InfiniteQueryObserverBaseResult.md#error) + +*** + +### errorUpdateCount + +```ts +errorUpdateCount: number; +``` + +Defined in: [packages/query-core/src/types.ts:799](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L799) + +The sum of all errors. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`errorUpdateCount`](InfiniteQueryObserverBaseResult.md#errorupdatecount) + +*** + +### errorUpdatedAt + +```ts +errorUpdatedAt: number; +``` + +Defined in: [packages/query-core/src/types.ts:784](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L784) + +The timestamp for when the query most recently returned the `status` as `"error"`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`errorUpdatedAt`](InfiniteQueryObserverBaseResult.md#errorupdatedat) + +*** + +### failureCount + +```ts +failureCount: number; +``` + +Defined in: [packages/query-core/src/types.ts:790](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L790) + +The failure count for the query. +- Incremented every time the query fails. +- Reset to `0` when the query succeeds. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`failureCount`](InfiniteQueryObserverBaseResult.md#failurecount) + +*** + +### failureReason + +```ts +failureReason: TError | null; +``` + +Defined in: [packages/query-core/src/types.ts:795](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L795) + +The failure reason for the query retry. +- Reset to `null` when the query succeeds. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`failureReason`](InfiniteQueryObserverBaseResult.md#failurereason) + +*** + +### fetchNextPage() + +```ts +fetchNextPage: (options?) => Promise>; +``` + +Defined in: [packages/query-core/src/types.ts:1008](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1008) + +This function allows you to fetch the next "page" of results. + +#### Parameters + +##### options? + +[`FetchNextPageOptions`](FetchNextPageOptions.md) + +#### Returns + +`Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`fetchNextPage`](InfiniteQueryObserverBaseResult.md#fetchnextpage) + +*** + +### fetchPreviousPage() + +```ts +fetchPreviousPage: (options?) => Promise>; +``` + +Defined in: [packages/query-core/src/types.ts:1014](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1014) + +This function allows you to fetch the previous "page" of results. + +#### Parameters + +##### options? + +[`FetchPreviousPageOptions`](FetchPreviousPageOptions.md) + +#### Returns + +`Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`fetchPreviousPage`](InfiniteQueryObserverBaseResult.md#fetchpreviouspage) + +*** + +### fetchStatus + +```ts +fetchStatus: FetchStatus; +``` + +Defined in: [packages/query-core/src/types.ts:889](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L889) + +The fetch status of the query. +- `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. +- `paused`: The query wanted to fetch, but has been `paused`. +- `idle`: The query is not fetching. +- See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`fetchStatus`](InfiniteQueryObserverBaseResult.md#fetchstatus) + +*** + +### hasNextPage + +```ts +hasNextPage: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1020](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1020) + +Will be `true` if there is a next page to be fetched (known via the `getNextPageParam` option). + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`hasNextPage`](InfiniteQueryObserverBaseResult.md#hasnextpage) + +*** + +### hasPreviousPage + +```ts +hasPreviousPage: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1024](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1024) + +Will be `true` if there is a previous page to be fetched (known via the `getPreviousPageParam` option). + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`hasPreviousPage`](InfiniteQueryObserverBaseResult.md#haspreviouspage) + +*** + +### isEnabled + +```ts +isEnabled: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:867](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L867) + +`true` if this observer is enabled, `false` otherwise. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isEnabled`](InfiniteQueryObserverBaseResult.md#isenabled) + +*** + +### isError + +```ts +isError: false; +``` + +Defined in: [packages/query-core/src/types.ts:1049](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1049) + +A derived boolean from the `status` variable, provided for convenience. +- `true` if the query attempt resulted in an error. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isError`](InfiniteQueryObserverBaseResult.md#iserror) + +*** + +### isFetched + +```ts +isFetched: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:808](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L808) + +Will be `true` if the query has been fetched. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetched`](InfiniteQueryObserverBaseResult.md#isfetched) + +*** + +### isFetchedAfterMount + +```ts +isFetchedAfterMount: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:813](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L813) + +Will be `true` if the query has been fetched after the component mounted. +- This property can be used to not show any previously cached data. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchedAfterMount`](InfiniteQueryObserverBaseResult.md#isfetchedaftermount) + +*** + +### isFetching + +```ts +isFetching: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:818](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L818) + +A derived boolean from the `fetchStatus` variable, provided for convenience. +- `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetching`](InfiniteQueryObserverBaseResult.md#isfetching) + +*** + +### isFetchingNextPage + +```ts +isFetchingNextPage: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1032](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1032) + +Will be `true` while fetching the next page with `fetchNextPage`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchingNextPage`](InfiniteQueryObserverBaseResult.md#isfetchingnextpage) + +*** + +### isFetchingPreviousPage + +```ts +isFetchingPreviousPage: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1040](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1040) + +Will be `true` while fetching the previous page with `fetchPreviousPage`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchingPreviousPage`](InfiniteQueryObserverBaseResult.md#isfetchingpreviouspage) + +*** + +### isFetchNextPageError + +```ts +isFetchNextPageError: false; +``` + +Defined in: [packages/query-core/src/types.ts:1053](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1053) + +Will be `true` if the query failed while fetching the next page. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchNextPageError`](InfiniteQueryObserverBaseResult.md#isfetchnextpageerror) + +*** + +### isFetchPreviousPageError + +```ts +isFetchPreviousPageError: false; +``` + +Defined in: [packages/query-core/src/types.ts:1054](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1054) + +Will be `true` if the query failed while fetching the previous page. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchPreviousPageError`](InfiniteQueryObserverBaseResult.md#isfetchpreviouspageerror) + +*** + +### ~~isInitialLoading~~ + +```ts +isInitialLoading: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:836](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L836) + +#### Deprecated + +`isInitialLoading` is being deprecated in favor of `isLoading` +and will be removed in the next major version. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isInitialLoading`](InfiniteQueryObserverBaseResult.md#isinitialloading) + +*** + +### isLoading + +```ts +isLoading: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:823](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L823) + +Is `true` whenever the first fetch for a query is in-flight. +- Is the same as `isFetching && isPending`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoading`](InfiniteQueryObserverBaseResult.md#isloading) + +*** + +### isLoadingError + +```ts +isLoadingError: false; +``` + +Defined in: [packages/query-core/src/types.ts:1051](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1051) + +Will be `true` if the query failed while fetching for the first time. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoadingError`](InfiniteQueryObserverBaseResult.md#isloadingerror) + +*** + +### isPaused + +```ts +isPaused: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:841](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L841) + +A derived boolean from the `fetchStatus` variable, provided for convenience. +- The query wanted to fetch, but has been `paused`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPaused`](InfiniteQueryObserverBaseResult.md#ispaused) + +*** + +### isPending + +```ts +isPending: true; +``` + +Defined in: [packages/query-core/src/types.ts:1050](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1050) + +Will be `pending` if there's no cached data and no query attempt was finished yet. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPending`](InfiniteQueryObserverBaseResult.md#ispending) + +*** + +### isPlaceholderData + +```ts +isPlaceholderData: false; +``` + +Defined in: [packages/query-core/src/types.ts:1056](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1056) + +Will be `true` if the data shown is the placeholder data. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPlaceholderData`](InfiniteQueryObserverBaseResult.md#isplaceholderdata) + +*** + +### isRefetchError + +```ts +isRefetchError: false; +``` + +Defined in: [packages/query-core/src/types.ts:1052](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1052) + +Will be `true` if the query failed while refetching. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isRefetchError`](InfiniteQueryObserverBaseResult.md#isrefetcherror) + +*** + +### isRefetching + +```ts +isRefetching: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:854](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L854) + +Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. +- Is the same as `isFetching && !isPending`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isRefetching`](InfiniteQueryObserverBaseResult.md#isrefetching) + +*** + +### isStale + +```ts +isStale: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:858](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L858) + +Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isStale`](InfiniteQueryObserverBaseResult.md#isstale) + +*** + +### isSuccess + +```ts +isSuccess: false; +``` + +Defined in: [packages/query-core/src/types.ts:1055](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1055) + +A derived boolean from the `status` variable, provided for convenience. +- `true` if the query has received a response with no errors and is ready to display its data. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isSuccess`](InfiniteQueryObserverBaseResult.md#issuccess) + +*** + +### refetch() + +```ts +refetch: (options?) => Promise>; +``` + +Defined in: [packages/query-core/src/types.ts:871](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L871) + +A function to manually refetch the query. + +#### Parameters + +##### options? + +[`RefetchOptions`](RefetchOptions.md) + +#### Returns + +`Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`refetch`](InfiniteQueryObserverBaseResult.md#refetch) + +*** + +### status + +```ts +status: "pending"; +``` + +Defined in: [packages/query-core/src/types.ts:1057](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1057) + +The status of the query. +- Will be: + - `pending` if there's no cached data and no query attempt was finished yet. + - `error` if the query attempt resulted in an error. + - `success` if the query has received a response with no errors and is ready to display its data. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`status`](InfiniteQueryObserverBaseResult.md#status) diff --git a/docs/framework/angular/reference/interfaces/InfiniteQueryObserverPlaceholderResult.md b/docs/framework/angular/reference/interfaces/InfiniteQueryObserverPlaceholderResult.md new file mode 100644 index 00000000000..58193a987d1 --- /dev/null +++ b/docs/framework/angular/reference/interfaces/InfiniteQueryObserverPlaceholderResult.md @@ -0,0 +1,600 @@ +--- +id: InfiniteQueryObserverPlaceholderResult +title: InfiniteQueryObserverPlaceholderResult +--- + +Defined in: [packages/query-core/src/types.ts:1130](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1130) + +## Extends + +- [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md)\<`TData`, `TError`\> + +## Type Parameters + +### TData + +`TData` = `unknown` + +### TError + +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) + +## Properties + +### data + +```ts +data: TData; +``` + +Defined in: [packages/query-core/src/types.ts:1134](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1134) + +The last successfully resolved data for the query. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`data`](InfiniteQueryObserverBaseResult.md#data) + +*** + +### dataUpdatedAt + +```ts +dataUpdatedAt: number; +``` + +Defined in: [packages/query-core/src/types.ts:775](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L775) + +The timestamp for when the query most recently returned the `status` as `"success"`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`dataUpdatedAt`](InfiniteQueryObserverBaseResult.md#dataupdatedat) + +*** + +### error + +```ts +error: null; +``` + +Defined in: [packages/query-core/src/types.ts:1136](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1136) + +The error object for the query, if an error was thrown. +- Defaults to `null`. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`error`](InfiniteQueryObserverBaseResult.md#error) + +*** + +### errorUpdateCount + +```ts +errorUpdateCount: number; +``` + +Defined in: [packages/query-core/src/types.ts:799](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L799) + +The sum of all errors. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`errorUpdateCount`](InfiniteQueryObserverBaseResult.md#errorupdatecount) + +*** + +### errorUpdatedAt + +```ts +errorUpdatedAt: number; +``` + +Defined in: [packages/query-core/src/types.ts:784](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L784) + +The timestamp for when the query most recently returned the `status` as `"error"`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`errorUpdatedAt`](InfiniteQueryObserverBaseResult.md#errorupdatedat) + +*** + +### failureCount + +```ts +failureCount: number; +``` + +Defined in: [packages/query-core/src/types.ts:790](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L790) + +The failure count for the query. +- Incremented every time the query fails. +- Reset to `0` when the query succeeds. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`failureCount`](InfiniteQueryObserverBaseResult.md#failurecount) + +*** + +### failureReason + +```ts +failureReason: TError | null; +``` + +Defined in: [packages/query-core/src/types.ts:795](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L795) + +The failure reason for the query retry. +- Reset to `null` when the query succeeds. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`failureReason`](InfiniteQueryObserverBaseResult.md#failurereason) + +*** + +### fetchNextPage() + +```ts +fetchNextPage: (options?) => Promise>; +``` + +Defined in: [packages/query-core/src/types.ts:1008](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1008) + +This function allows you to fetch the next "page" of results. + +#### Parameters + +##### options? + +[`FetchNextPageOptions`](FetchNextPageOptions.md) + +#### Returns + +`Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`fetchNextPage`](InfiniteQueryObserverBaseResult.md#fetchnextpage) + +*** + +### fetchPreviousPage() + +```ts +fetchPreviousPage: (options?) => Promise>; +``` + +Defined in: [packages/query-core/src/types.ts:1014](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1014) + +This function allows you to fetch the previous "page" of results. + +#### Parameters + +##### options? + +[`FetchPreviousPageOptions`](FetchPreviousPageOptions.md) + +#### Returns + +`Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`fetchPreviousPage`](InfiniteQueryObserverBaseResult.md#fetchpreviouspage) + +*** + +### fetchStatus + +```ts +fetchStatus: FetchStatus; +``` + +Defined in: [packages/query-core/src/types.ts:889](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L889) + +The fetch status of the query. +- `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. +- `paused`: The query wanted to fetch, but has been `paused`. +- `idle`: The query is not fetching. +- See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`fetchStatus`](InfiniteQueryObserverBaseResult.md#fetchstatus) + +*** + +### hasNextPage + +```ts +hasNextPage: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1020](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1020) + +Will be `true` if there is a next page to be fetched (known via the `getNextPageParam` option). + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`hasNextPage`](InfiniteQueryObserverBaseResult.md#hasnextpage) + +*** + +### hasPreviousPage + +```ts +hasPreviousPage: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1024](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1024) + +Will be `true` if there is a previous page to be fetched (known via the `getPreviousPageParam` option). + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`hasPreviousPage`](InfiniteQueryObserverBaseResult.md#haspreviouspage) + +*** + +### isEnabled + +```ts +isEnabled: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:867](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L867) + +`true` if this observer is enabled, `false` otherwise. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isEnabled`](InfiniteQueryObserverBaseResult.md#isenabled) + +*** + +### isError + +```ts +isError: false; +``` + +Defined in: [packages/query-core/src/types.ts:1135](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1135) + +A derived boolean from the `status` variable, provided for convenience. +- `true` if the query attempt resulted in an error. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isError`](InfiniteQueryObserverBaseResult.md#iserror) + +*** + +### isFetched + +```ts +isFetched: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:808](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L808) + +Will be `true` if the query has been fetched. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetched`](InfiniteQueryObserverBaseResult.md#isfetched) + +*** + +### isFetchedAfterMount + +```ts +isFetchedAfterMount: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:813](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L813) + +Will be `true` if the query has been fetched after the component mounted. +- This property can be used to not show any previously cached data. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchedAfterMount`](InfiniteQueryObserverBaseResult.md#isfetchedaftermount) + +*** + +### isFetching + +```ts +isFetching: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:818](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L818) + +A derived boolean from the `fetchStatus` variable, provided for convenience. +- `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetching`](InfiniteQueryObserverBaseResult.md#isfetching) + +*** + +### isFetchingNextPage + +```ts +isFetchingNextPage: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1032](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1032) + +Will be `true` while fetching the next page with `fetchNextPage`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchingNextPage`](InfiniteQueryObserverBaseResult.md#isfetchingnextpage) + +*** + +### isFetchingPreviousPage + +```ts +isFetchingPreviousPage: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1040](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1040) + +Will be `true` while fetching the previous page with `fetchPreviousPage`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchingPreviousPage`](InfiniteQueryObserverBaseResult.md#isfetchingpreviouspage) + +*** + +### isFetchNextPageError + +```ts +isFetchNextPageError: false; +``` + +Defined in: [packages/query-core/src/types.ts:1143](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1143) + +Will be `true` if the query failed while fetching the next page. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchNextPageError`](InfiniteQueryObserverBaseResult.md#isfetchnextpageerror) + +*** + +### isFetchPreviousPageError + +```ts +isFetchPreviousPageError: false; +``` + +Defined in: [packages/query-core/src/types.ts:1144](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1144) + +Will be `true` if the query failed while fetching the previous page. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchPreviousPageError`](InfiniteQueryObserverBaseResult.md#isfetchpreviouspageerror) + +*** + +### ~~isInitialLoading~~ + +```ts +isInitialLoading: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:836](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L836) + +#### Deprecated + +`isInitialLoading` is being deprecated in favor of `isLoading` +and will be removed in the next major version. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isInitialLoading`](InfiniteQueryObserverBaseResult.md#isinitialloading) + +*** + +### isLoading + +```ts +isLoading: false; +``` + +Defined in: [packages/query-core/src/types.ts:1138](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1138) + +Is `true` whenever the first fetch for a query is in-flight. +- Is the same as `isFetching && isPending`. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoading`](InfiniteQueryObserverBaseResult.md#isloading) + +*** + +### isLoadingError + +```ts +isLoadingError: false; +``` + +Defined in: [packages/query-core/src/types.ts:1139](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1139) + +Will be `true` if the query failed while fetching for the first time. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoadingError`](InfiniteQueryObserverBaseResult.md#isloadingerror) + +*** + +### isPaused + +```ts +isPaused: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:841](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L841) + +A derived boolean from the `fetchStatus` variable, provided for convenience. +- The query wanted to fetch, but has been `paused`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPaused`](InfiniteQueryObserverBaseResult.md#ispaused) + +*** + +### isPending + +```ts +isPending: false; +``` + +Defined in: [packages/query-core/src/types.ts:1137](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1137) + +Will be `pending` if there's no cached data and no query attempt was finished yet. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPending`](InfiniteQueryObserverBaseResult.md#ispending) + +*** + +### isPlaceholderData + +```ts +isPlaceholderData: true; +``` + +Defined in: [packages/query-core/src/types.ts:1142](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1142) + +Will be `true` if the data shown is the placeholder data. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPlaceholderData`](InfiniteQueryObserverBaseResult.md#isplaceholderdata) + +*** + +### isRefetchError + +```ts +isRefetchError: false; +``` + +Defined in: [packages/query-core/src/types.ts:1140](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1140) + +Will be `true` if the query failed while refetching. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isRefetchError`](InfiniteQueryObserverBaseResult.md#isrefetcherror) + +*** + +### isRefetching + +```ts +isRefetching: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:854](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L854) + +Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. +- Is the same as `isFetching && !isPending`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isRefetching`](InfiniteQueryObserverBaseResult.md#isrefetching) + +*** + +### isStale + +```ts +isStale: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:858](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L858) + +Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isStale`](InfiniteQueryObserverBaseResult.md#isstale) + +*** + +### isSuccess + +```ts +isSuccess: true; +``` + +Defined in: [packages/query-core/src/types.ts:1141](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1141) + +A derived boolean from the `status` variable, provided for convenience. +- `true` if the query has received a response with no errors and is ready to display its data. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isSuccess`](InfiniteQueryObserverBaseResult.md#issuccess) + +*** + +### refetch() + +```ts +refetch: (options?) => Promise>; +``` + +Defined in: [packages/query-core/src/types.ts:871](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L871) + +A function to manually refetch the query. + +#### Parameters + +##### options? + +[`RefetchOptions`](RefetchOptions.md) + +#### Returns + +`Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`refetch`](InfiniteQueryObserverBaseResult.md#refetch) + +*** + +### status + +```ts +status: "success"; +``` + +Defined in: [packages/query-core/src/types.ts:1145](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1145) + +The status of the query. +- Will be: + - `pending` if there's no cached data and no query attempt was finished yet. + - `error` if the query attempt resulted in an error. + - `success` if the query has received a response with no errors and is ready to display its data. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`status`](InfiniteQueryObserverBaseResult.md#status) diff --git a/docs/framework/angular/reference/interfaces/InfiniteQueryObserverRefetchErrorResult.md b/docs/framework/angular/reference/interfaces/InfiniteQueryObserverRefetchErrorResult.md new file mode 100644 index 00000000000..4ce469bceed --- /dev/null +++ b/docs/framework/angular/reference/interfaces/InfiniteQueryObserverRefetchErrorResult.md @@ -0,0 +1,600 @@ +--- +id: InfiniteQueryObserverRefetchErrorResult +title: InfiniteQueryObserverRefetchErrorResult +--- + +Defined in: [packages/query-core/src/types.ts:1096](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1096) + +## Extends + +- [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md)\<`TData`, `TError`\> + +## Type Parameters + +### TData + +`TData` = `unknown` + +### TError + +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) + +## Properties + +### data + +```ts +data: TData; +``` + +Defined in: [packages/query-core/src/types.ts:1100](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1100) + +The last successfully resolved data for the query. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`data`](InfiniteQueryObserverBaseResult.md#data) + +*** + +### dataUpdatedAt + +```ts +dataUpdatedAt: number; +``` + +Defined in: [packages/query-core/src/types.ts:775](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L775) + +The timestamp for when the query most recently returned the `status` as `"success"`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`dataUpdatedAt`](InfiniteQueryObserverBaseResult.md#dataupdatedat) + +*** + +### error + +```ts +error: TError; +``` + +Defined in: [packages/query-core/src/types.ts:1101](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1101) + +The error object for the query, if an error was thrown. +- Defaults to `null`. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`error`](InfiniteQueryObserverBaseResult.md#error) + +*** + +### errorUpdateCount + +```ts +errorUpdateCount: number; +``` + +Defined in: [packages/query-core/src/types.ts:799](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L799) + +The sum of all errors. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`errorUpdateCount`](InfiniteQueryObserverBaseResult.md#errorupdatecount) + +*** + +### errorUpdatedAt + +```ts +errorUpdatedAt: number; +``` + +Defined in: [packages/query-core/src/types.ts:784](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L784) + +The timestamp for when the query most recently returned the `status` as `"error"`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`errorUpdatedAt`](InfiniteQueryObserverBaseResult.md#errorupdatedat) + +*** + +### failureCount + +```ts +failureCount: number; +``` + +Defined in: [packages/query-core/src/types.ts:790](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L790) + +The failure count for the query. +- Incremented every time the query fails. +- Reset to `0` when the query succeeds. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`failureCount`](InfiniteQueryObserverBaseResult.md#failurecount) + +*** + +### failureReason + +```ts +failureReason: TError | null; +``` + +Defined in: [packages/query-core/src/types.ts:795](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L795) + +The failure reason for the query retry. +- Reset to `null` when the query succeeds. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`failureReason`](InfiniteQueryObserverBaseResult.md#failurereason) + +*** + +### fetchNextPage() + +```ts +fetchNextPage: (options?) => Promise>; +``` + +Defined in: [packages/query-core/src/types.ts:1008](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1008) + +This function allows you to fetch the next "page" of results. + +#### Parameters + +##### options? + +[`FetchNextPageOptions`](FetchNextPageOptions.md) + +#### Returns + +`Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`fetchNextPage`](InfiniteQueryObserverBaseResult.md#fetchnextpage) + +*** + +### fetchPreviousPage() + +```ts +fetchPreviousPage: (options?) => Promise>; +``` + +Defined in: [packages/query-core/src/types.ts:1014](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1014) + +This function allows you to fetch the previous "page" of results. + +#### Parameters + +##### options? + +[`FetchPreviousPageOptions`](FetchPreviousPageOptions.md) + +#### Returns + +`Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`fetchPreviousPage`](InfiniteQueryObserverBaseResult.md#fetchpreviouspage) + +*** + +### fetchStatus + +```ts +fetchStatus: FetchStatus; +``` + +Defined in: [packages/query-core/src/types.ts:889](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L889) + +The fetch status of the query. +- `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. +- `paused`: The query wanted to fetch, but has been `paused`. +- `idle`: The query is not fetching. +- See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`fetchStatus`](InfiniteQueryObserverBaseResult.md#fetchstatus) + +*** + +### hasNextPage + +```ts +hasNextPage: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1020](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1020) + +Will be `true` if there is a next page to be fetched (known via the `getNextPageParam` option). + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`hasNextPage`](InfiniteQueryObserverBaseResult.md#hasnextpage) + +*** + +### hasPreviousPage + +```ts +hasPreviousPage: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1024](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1024) + +Will be `true` if there is a previous page to be fetched (known via the `getPreviousPageParam` option). + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`hasPreviousPage`](InfiniteQueryObserverBaseResult.md#haspreviouspage) + +*** + +### isEnabled + +```ts +isEnabled: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:867](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L867) + +`true` if this observer is enabled, `false` otherwise. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isEnabled`](InfiniteQueryObserverBaseResult.md#isenabled) + +*** + +### isError + +```ts +isError: true; +``` + +Defined in: [packages/query-core/src/types.ts:1102](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1102) + +A derived boolean from the `status` variable, provided for convenience. +- `true` if the query attempt resulted in an error. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isError`](InfiniteQueryObserverBaseResult.md#iserror) + +*** + +### isFetched + +```ts +isFetched: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:808](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L808) + +Will be `true` if the query has been fetched. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetched`](InfiniteQueryObserverBaseResult.md#isfetched) + +*** + +### isFetchedAfterMount + +```ts +isFetchedAfterMount: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:813](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L813) + +Will be `true` if the query has been fetched after the component mounted. +- This property can be used to not show any previously cached data. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchedAfterMount`](InfiniteQueryObserverBaseResult.md#isfetchedaftermount) + +*** + +### isFetching + +```ts +isFetching: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:818](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L818) + +A derived boolean from the `fetchStatus` variable, provided for convenience. +- `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetching`](InfiniteQueryObserverBaseResult.md#isfetching) + +*** + +### isFetchingNextPage + +```ts +isFetchingNextPage: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1032](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1032) + +Will be `true` while fetching the next page with `fetchNextPage`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchingNextPage`](InfiniteQueryObserverBaseResult.md#isfetchingnextpage) + +*** + +### isFetchingPreviousPage + +```ts +isFetchingPreviousPage: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1040](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1040) + +Will be `true` while fetching the previous page with `fetchPreviousPage`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchingPreviousPage`](InfiniteQueryObserverBaseResult.md#isfetchingpreviouspage) + +*** + +### isFetchNextPageError + +```ts +isFetchNextPageError: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1028](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1028) + +Will be `true` if the query failed while fetching the next page. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchNextPageError`](InfiniteQueryObserverBaseResult.md#isfetchnextpageerror) + +*** + +### isFetchPreviousPageError + +```ts +isFetchPreviousPageError: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1036](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1036) + +Will be `true` if the query failed while fetching the previous page. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchPreviousPageError`](InfiniteQueryObserverBaseResult.md#isfetchpreviouspageerror) + +*** + +### ~~isInitialLoading~~ + +```ts +isInitialLoading: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:836](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L836) + +#### Deprecated + +`isInitialLoading` is being deprecated in favor of `isLoading` +and will be removed in the next major version. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isInitialLoading`](InfiniteQueryObserverBaseResult.md#isinitialloading) + +*** + +### isLoading + +```ts +isLoading: false; +``` + +Defined in: [packages/query-core/src/types.ts:1104](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1104) + +Is `true` whenever the first fetch for a query is in-flight. +- Is the same as `isFetching && isPending`. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoading`](InfiniteQueryObserverBaseResult.md#isloading) + +*** + +### isLoadingError + +```ts +isLoadingError: false; +``` + +Defined in: [packages/query-core/src/types.ts:1105](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1105) + +Will be `true` if the query failed while fetching for the first time. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoadingError`](InfiniteQueryObserverBaseResult.md#isloadingerror) + +*** + +### isPaused + +```ts +isPaused: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:841](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L841) + +A derived boolean from the `fetchStatus` variable, provided for convenience. +- The query wanted to fetch, but has been `paused`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPaused`](InfiniteQueryObserverBaseResult.md#ispaused) + +*** + +### isPending + +```ts +isPending: false; +``` + +Defined in: [packages/query-core/src/types.ts:1103](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1103) + +Will be `pending` if there's no cached data and no query attempt was finished yet. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPending`](InfiniteQueryObserverBaseResult.md#ispending) + +*** + +### isPlaceholderData + +```ts +isPlaceholderData: false; +``` + +Defined in: [packages/query-core/src/types.ts:1108](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1108) + +Will be `true` if the data shown is the placeholder data. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPlaceholderData`](InfiniteQueryObserverBaseResult.md#isplaceholderdata) + +*** + +### isRefetchError + +```ts +isRefetchError: true; +``` + +Defined in: [packages/query-core/src/types.ts:1106](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1106) + +Will be `true` if the query failed while refetching. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isRefetchError`](InfiniteQueryObserverBaseResult.md#isrefetcherror) + +*** + +### isRefetching + +```ts +isRefetching: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:854](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L854) + +Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. +- Is the same as `isFetching && !isPending`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isRefetching`](InfiniteQueryObserverBaseResult.md#isrefetching) + +*** + +### isStale + +```ts +isStale: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:858](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L858) + +Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isStale`](InfiniteQueryObserverBaseResult.md#isstale) + +*** + +### isSuccess + +```ts +isSuccess: false; +``` + +Defined in: [packages/query-core/src/types.ts:1107](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1107) + +A derived boolean from the `status` variable, provided for convenience. +- `true` if the query has received a response with no errors and is ready to display its data. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isSuccess`](InfiniteQueryObserverBaseResult.md#issuccess) + +*** + +### refetch() + +```ts +refetch: (options?) => Promise>; +``` + +Defined in: [packages/query-core/src/types.ts:871](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L871) + +A function to manually refetch the query. + +#### Parameters + +##### options? + +[`RefetchOptions`](RefetchOptions.md) + +#### Returns + +`Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`refetch`](InfiniteQueryObserverBaseResult.md#refetch) + +*** + +### status + +```ts +status: "error"; +``` + +Defined in: [packages/query-core/src/types.ts:1109](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1109) + +The status of the query. +- Will be: + - `pending` if there's no cached data and no query attempt was finished yet. + - `error` if the query attempt resulted in an error. + - `success` if the query has received a response with no errors and is ready to display its data. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`status`](InfiniteQueryObserverBaseResult.md#status) diff --git a/docs/framework/angular/reference/interfaces/InfiniteQueryObserverSuccessResult.md b/docs/framework/angular/reference/interfaces/InfiniteQueryObserverSuccessResult.md new file mode 100644 index 00000000000..131f6d01ae7 --- /dev/null +++ b/docs/framework/angular/reference/interfaces/InfiniteQueryObserverSuccessResult.md @@ -0,0 +1,600 @@ +--- +id: InfiniteQueryObserverSuccessResult +title: InfiniteQueryObserverSuccessResult +--- + +Defined in: [packages/query-core/src/types.ts:1112](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1112) + +## Extends + +- [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md)\<`TData`, `TError`\> + +## Type Parameters + +### TData + +`TData` = `unknown` + +### TError + +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) + +## Properties + +### data + +```ts +data: TData; +``` + +Defined in: [packages/query-core/src/types.ts:1116](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1116) + +The last successfully resolved data for the query. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`data`](InfiniteQueryObserverBaseResult.md#data) + +*** + +### dataUpdatedAt + +```ts +dataUpdatedAt: number; +``` + +Defined in: [packages/query-core/src/types.ts:775](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L775) + +The timestamp for when the query most recently returned the `status` as `"success"`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`dataUpdatedAt`](InfiniteQueryObserverBaseResult.md#dataupdatedat) + +*** + +### error + +```ts +error: null; +``` + +Defined in: [packages/query-core/src/types.ts:1117](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1117) + +The error object for the query, if an error was thrown. +- Defaults to `null`. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`error`](InfiniteQueryObserverBaseResult.md#error) + +*** + +### errorUpdateCount + +```ts +errorUpdateCount: number; +``` + +Defined in: [packages/query-core/src/types.ts:799](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L799) + +The sum of all errors. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`errorUpdateCount`](InfiniteQueryObserverBaseResult.md#errorupdatecount) + +*** + +### errorUpdatedAt + +```ts +errorUpdatedAt: number; +``` + +Defined in: [packages/query-core/src/types.ts:784](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L784) + +The timestamp for when the query most recently returned the `status` as `"error"`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`errorUpdatedAt`](InfiniteQueryObserverBaseResult.md#errorupdatedat) + +*** + +### failureCount + +```ts +failureCount: number; +``` + +Defined in: [packages/query-core/src/types.ts:790](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L790) + +The failure count for the query. +- Incremented every time the query fails. +- Reset to `0` when the query succeeds. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`failureCount`](InfiniteQueryObserverBaseResult.md#failurecount) + +*** + +### failureReason + +```ts +failureReason: TError | null; +``` + +Defined in: [packages/query-core/src/types.ts:795](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L795) + +The failure reason for the query retry. +- Reset to `null` when the query succeeds. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`failureReason`](InfiniteQueryObserverBaseResult.md#failurereason) + +*** + +### fetchNextPage() + +```ts +fetchNextPage: (options?) => Promise>; +``` + +Defined in: [packages/query-core/src/types.ts:1008](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1008) + +This function allows you to fetch the next "page" of results. + +#### Parameters + +##### options? + +[`FetchNextPageOptions`](FetchNextPageOptions.md) + +#### Returns + +`Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`fetchNextPage`](InfiniteQueryObserverBaseResult.md#fetchnextpage) + +*** + +### fetchPreviousPage() + +```ts +fetchPreviousPage: (options?) => Promise>; +``` + +Defined in: [packages/query-core/src/types.ts:1014](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1014) + +This function allows you to fetch the previous "page" of results. + +#### Parameters + +##### options? + +[`FetchPreviousPageOptions`](FetchPreviousPageOptions.md) + +#### Returns + +`Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`fetchPreviousPage`](InfiniteQueryObserverBaseResult.md#fetchpreviouspage) + +*** + +### fetchStatus + +```ts +fetchStatus: FetchStatus; +``` + +Defined in: [packages/query-core/src/types.ts:889](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L889) + +The fetch status of the query. +- `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. +- `paused`: The query wanted to fetch, but has been `paused`. +- `idle`: The query is not fetching. +- See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`fetchStatus`](InfiniteQueryObserverBaseResult.md#fetchstatus) + +*** + +### hasNextPage + +```ts +hasNextPage: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1020](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1020) + +Will be `true` if there is a next page to be fetched (known via the `getNextPageParam` option). + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`hasNextPage`](InfiniteQueryObserverBaseResult.md#hasnextpage) + +*** + +### hasPreviousPage + +```ts +hasPreviousPage: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1024](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1024) + +Will be `true` if there is a previous page to be fetched (known via the `getPreviousPageParam` option). + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`hasPreviousPage`](InfiniteQueryObserverBaseResult.md#haspreviouspage) + +*** + +### isEnabled + +```ts +isEnabled: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:867](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L867) + +`true` if this observer is enabled, `false` otherwise. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isEnabled`](InfiniteQueryObserverBaseResult.md#isenabled) + +*** + +### isError + +```ts +isError: false; +``` + +Defined in: [packages/query-core/src/types.ts:1118](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1118) + +A derived boolean from the `status` variable, provided for convenience. +- `true` if the query attempt resulted in an error. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isError`](InfiniteQueryObserverBaseResult.md#iserror) + +*** + +### isFetched + +```ts +isFetched: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:808](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L808) + +Will be `true` if the query has been fetched. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetched`](InfiniteQueryObserverBaseResult.md#isfetched) + +*** + +### isFetchedAfterMount + +```ts +isFetchedAfterMount: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:813](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L813) + +Will be `true` if the query has been fetched after the component mounted. +- This property can be used to not show any previously cached data. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchedAfterMount`](InfiniteQueryObserverBaseResult.md#isfetchedaftermount) + +*** + +### isFetching + +```ts +isFetching: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:818](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L818) + +A derived boolean from the `fetchStatus` variable, provided for convenience. +- `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetching`](InfiniteQueryObserverBaseResult.md#isfetching) + +*** + +### isFetchingNextPage + +```ts +isFetchingNextPage: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1032](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1032) + +Will be `true` while fetching the next page with `fetchNextPage`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchingNextPage`](InfiniteQueryObserverBaseResult.md#isfetchingnextpage) + +*** + +### isFetchingPreviousPage + +```ts +isFetchingPreviousPage: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1040](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1040) + +Will be `true` while fetching the previous page with `fetchPreviousPage`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchingPreviousPage`](InfiniteQueryObserverBaseResult.md#isfetchingpreviouspage) + +*** + +### isFetchNextPageError + +```ts +isFetchNextPageError: false; +``` + +Defined in: [packages/query-core/src/types.ts:1123](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1123) + +Will be `true` if the query failed while fetching the next page. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchNextPageError`](InfiniteQueryObserverBaseResult.md#isfetchnextpageerror) + +*** + +### isFetchPreviousPageError + +```ts +isFetchPreviousPageError: false; +``` + +Defined in: [packages/query-core/src/types.ts:1124](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1124) + +Will be `true` if the query failed while fetching the previous page. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchPreviousPageError`](InfiniteQueryObserverBaseResult.md#isfetchpreviouspageerror) + +*** + +### ~~isInitialLoading~~ + +```ts +isInitialLoading: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:836](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L836) + +#### Deprecated + +`isInitialLoading` is being deprecated in favor of `isLoading` +and will be removed in the next major version. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isInitialLoading`](InfiniteQueryObserverBaseResult.md#isinitialloading) + +*** + +### isLoading + +```ts +isLoading: false; +``` + +Defined in: [packages/query-core/src/types.ts:1120](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1120) + +Is `true` whenever the first fetch for a query is in-flight. +- Is the same as `isFetching && isPending`. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoading`](InfiniteQueryObserverBaseResult.md#isloading) + +*** + +### isLoadingError + +```ts +isLoadingError: false; +``` + +Defined in: [packages/query-core/src/types.ts:1121](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1121) + +Will be `true` if the query failed while fetching for the first time. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoadingError`](InfiniteQueryObserverBaseResult.md#isloadingerror) + +*** + +### isPaused + +```ts +isPaused: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:841](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L841) + +A derived boolean from the `fetchStatus` variable, provided for convenience. +- The query wanted to fetch, but has been `paused`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPaused`](InfiniteQueryObserverBaseResult.md#ispaused) + +*** + +### isPending + +```ts +isPending: false; +``` + +Defined in: [packages/query-core/src/types.ts:1119](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1119) + +Will be `pending` if there's no cached data and no query attempt was finished yet. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPending`](InfiniteQueryObserverBaseResult.md#ispending) + +*** + +### isPlaceholderData + +```ts +isPlaceholderData: false; +``` + +Defined in: [packages/query-core/src/types.ts:1126](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1126) + +Will be `true` if the data shown is the placeholder data. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPlaceholderData`](InfiniteQueryObserverBaseResult.md#isplaceholderdata) + +*** + +### isRefetchError + +```ts +isRefetchError: false; +``` + +Defined in: [packages/query-core/src/types.ts:1122](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1122) + +Will be `true` if the query failed while refetching. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isRefetchError`](InfiniteQueryObserverBaseResult.md#isrefetcherror) + +*** + +### isRefetching + +```ts +isRefetching: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:854](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L854) + +Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. +- Is the same as `isFetching && !isPending`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isRefetching`](InfiniteQueryObserverBaseResult.md#isrefetching) + +*** + +### isStale + +```ts +isStale: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:858](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L858) + +Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isStale`](InfiniteQueryObserverBaseResult.md#isstale) + +*** + +### isSuccess + +```ts +isSuccess: true; +``` + +Defined in: [packages/query-core/src/types.ts:1125](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1125) + +A derived boolean from the `status` variable, provided for convenience. +- `true` if the query has received a response with no errors and is ready to display its data. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isSuccess`](InfiniteQueryObserverBaseResult.md#issuccess) + +*** + +### refetch() + +```ts +refetch: (options?) => Promise>; +``` + +Defined in: [packages/query-core/src/types.ts:871](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L871) + +A function to manually refetch the query. + +#### Parameters + +##### options? + +[`RefetchOptions`](RefetchOptions.md) + +#### Returns + +`Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`refetch`](InfiniteQueryObserverBaseResult.md#refetch) + +*** + +### status + +```ts +status: "success"; +``` + +Defined in: [packages/query-core/src/types.ts:1127](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1127) + +The status of the query. +- Will be: + - `pending` if there's no cached data and no query attempt was finished yet. + - `error` if the query attempt resulted in an error. + - `success` if the query has received a response with no errors and is ready to display its data. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`status`](InfiniteQueryObserverBaseResult.md#status) diff --git a/docs/framework/angular/reference/interfaces/InfiniteQueryPageParamsOptions.md b/docs/framework/angular/reference/interfaces/InfiniteQueryPageParamsOptions.md new file mode 100644 index 00000000000..c091cc15456 --- /dev/null +++ b/docs/framework/angular/reference/interfaces/InfiniteQueryPageParamsOptions.md @@ -0,0 +1,64 @@ +--- +id: InfiniteQueryPageParamsOptions +title: InfiniteQueryPageParamsOptions +--- + +Defined in: [packages/query-core/src/types.ts:352](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L352) + +## Extends + +- [`InitialPageParam`](InitialPageParam.md)\<`TPageParam`\> + +## Extended by + +- [`InfiniteQueryObserverOptions`](InfiniteQueryObserverOptions.md) + +## Type Parameters + +### TQueryFnData + +`TQueryFnData` = `unknown` + +### TPageParam + +`TPageParam` = `unknown` + +## Properties + +### getNextPageParam + +```ts +getNextPageParam: GetNextPageParamFunction; +``` + +Defined in: [packages/query-core/src/types.ts:365](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L365) + +This function can be set to automatically get the next cursor for infinite queries. +The result will also be used to determine the value of `hasNextPage`. + +*** + +### getPreviousPageParam? + +```ts +optional getPreviousPageParam: GetPreviousPageParamFunction; +``` + +Defined in: [packages/query-core/src/types.ts:360](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L360) + +This function can be set to automatically get the previous cursor for infinite queries. +The result will also be used to determine the value of `hasPreviousPage`. + +*** + +### initialPageParam + +```ts +initialPageParam: TPageParam; +``` + +Defined in: [packages/query-core/src/types.ts:349](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L349) + +#### Inherited from + +[`InitialPageParam`](InitialPageParam.md).[`initialPageParam`](InitialPageParam.md#initialpageparam) diff --git a/docs/framework/angular/reference/interfaces/InitialPageParam.md b/docs/framework/angular/reference/interfaces/InitialPageParam.md new file mode 100644 index 00000000000..46d2b219ea4 --- /dev/null +++ b/docs/framework/angular/reference/interfaces/InitialPageParam.md @@ -0,0 +1,26 @@ +--- +id: InitialPageParam +title: InitialPageParam +--- + +Defined in: [packages/query-core/src/types.ts:348](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L348) + +## Extended by + +- [`InfiniteQueryPageParamsOptions`](InfiniteQueryPageParamsOptions.md) + +## Type Parameters + +### TPageParam + +`TPageParam` = `unknown` + +## Properties + +### initialPageParam + +```ts +initialPageParam: TPageParam; +``` + +Defined in: [packages/query-core/src/types.ts:349](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L349) diff --git a/docs/framework/angular/reference/interfaces/InjectInfiniteQueryOptions.md b/docs/framework/angular/reference/interfaces/InjectInfiniteQueryOptions.md index 0f1389379cc..a1f2d541d09 100644 --- a/docs/framework/angular/reference/interfaces/InjectInfiniteQueryOptions.md +++ b/docs/framework/angular/reference/interfaces/InjectInfiniteQueryOptions.md @@ -3,7 +3,7 @@ id: InjectInfiniteQueryOptions title: InjectInfiniteQueryOptions --- -Defined in: [inject-infinite-query.ts:25](https://github.com/TanStack/query/blob/main/packages/angular-query-experimental/src/inject-infinite-query.ts#L25) +Defined in: [packages/angular-query-experimental/src/inject-infinite-query.ts:25](https://github.com/TanStack/query/blob/main/packages/angular-query-experimental/src/inject-infinite-query.ts#L25) ## Properties @@ -13,7 +13,7 @@ Defined in: [inject-infinite-query.ts:25](https://github.com/TanStack/query/blob optional injector: Injector; ``` -Defined in: [inject-infinite-query.ts:31](https://github.com/TanStack/query/blob/main/packages/angular-query-experimental/src/inject-infinite-query.ts#L31) +Defined in: [packages/angular-query-experimental/src/inject-infinite-query.ts:31](https://github.com/TanStack/query/blob/main/packages/angular-query-experimental/src/inject-infinite-query.ts#L31) The `Injector` in which to create the infinite query. diff --git a/docs/framework/angular/reference/interfaces/InjectIsFetchingOptions.md b/docs/framework/angular/reference/interfaces/InjectIsFetchingOptions.md index 5fdd5353595..799b9a4498f 100644 --- a/docs/framework/angular/reference/interfaces/InjectIsFetchingOptions.md +++ b/docs/framework/angular/reference/interfaces/InjectIsFetchingOptions.md @@ -3,7 +3,7 @@ id: InjectIsFetchingOptions title: InjectIsFetchingOptions --- -Defined in: [inject-is-fetching.ts:13](https://github.com/TanStack/query/blob/main/packages/angular-query-experimental/src/inject-is-fetching.ts#L13) +Defined in: [packages/angular-query-experimental/src/inject-is-fetching.ts:13](https://github.com/TanStack/query/blob/main/packages/angular-query-experimental/src/inject-is-fetching.ts#L13) ## Properties @@ -13,7 +13,7 @@ Defined in: [inject-is-fetching.ts:13](https://github.com/TanStack/query/blob/ma optional injector: Injector; ``` -Defined in: [inject-is-fetching.ts:19](https://github.com/TanStack/query/blob/main/packages/angular-query-experimental/src/inject-is-fetching.ts#L19) +Defined in: [packages/angular-query-experimental/src/inject-is-fetching.ts:19](https://github.com/TanStack/query/blob/main/packages/angular-query-experimental/src/inject-is-fetching.ts#L19) The `Injector` in which to create the isFetching signal. diff --git a/docs/framework/angular/reference/interfaces/InjectIsMutatingOptions.md b/docs/framework/angular/reference/interfaces/InjectIsMutatingOptions.md index a76749f1724..344f84f0d9c 100644 --- a/docs/framework/angular/reference/interfaces/InjectIsMutatingOptions.md +++ b/docs/framework/angular/reference/interfaces/InjectIsMutatingOptions.md @@ -3,7 +3,7 @@ id: InjectIsMutatingOptions title: InjectIsMutatingOptions --- -Defined in: [inject-is-mutating.ts:13](https://github.com/TanStack/query/blob/main/packages/angular-query-experimental/src/inject-is-mutating.ts#L13) +Defined in: [packages/angular-query-experimental/src/inject-is-mutating.ts:13](https://github.com/TanStack/query/blob/main/packages/angular-query-experimental/src/inject-is-mutating.ts#L13) ## Properties @@ -13,7 +13,7 @@ Defined in: [inject-is-mutating.ts:13](https://github.com/TanStack/query/blob/ma optional injector: Injector; ``` -Defined in: [inject-is-mutating.ts:19](https://github.com/TanStack/query/blob/main/packages/angular-query-experimental/src/inject-is-mutating.ts#L19) +Defined in: [packages/angular-query-experimental/src/inject-is-mutating.ts:19](https://github.com/TanStack/query/blob/main/packages/angular-query-experimental/src/inject-is-mutating.ts#L19) The `Injector` in which to create the isMutating signal. diff --git a/docs/framework/angular/reference/interfaces/InjectMutationOptions.md b/docs/framework/angular/reference/interfaces/InjectMutationOptions.md index 893c8e0732f..8f012549d6c 100644 --- a/docs/framework/angular/reference/interfaces/InjectMutationOptions.md +++ b/docs/framework/angular/reference/interfaces/InjectMutationOptions.md @@ -3,7 +3,7 @@ id: InjectMutationOptions title: InjectMutationOptions --- -Defined in: [inject-mutation.ts:28](https://github.com/TanStack/query/blob/main/packages/angular-query-experimental/src/inject-mutation.ts#L28) +Defined in: [packages/angular-query-experimental/src/inject-mutation.ts:28](https://github.com/TanStack/query/blob/main/packages/angular-query-experimental/src/inject-mutation.ts#L28) ## Properties @@ -13,7 +13,7 @@ Defined in: [inject-mutation.ts:28](https://github.com/TanStack/query/blob/main/ optional injector: Injector; ``` -Defined in: [inject-mutation.ts:34](https://github.com/TanStack/query/blob/main/packages/angular-query-experimental/src/inject-mutation.ts#L34) +Defined in: [packages/angular-query-experimental/src/inject-mutation.ts:34](https://github.com/TanStack/query/blob/main/packages/angular-query-experimental/src/inject-mutation.ts#L34) The `Injector` in which to create the mutation. diff --git a/docs/framework/angular/reference/interfaces/InjectMutationStateOptions.md b/docs/framework/angular/reference/interfaces/InjectMutationStateOptions.md index 73b944e27da..8fe8ce53c0d 100644 --- a/docs/framework/angular/reference/interfaces/InjectMutationStateOptions.md +++ b/docs/framework/angular/reference/interfaces/InjectMutationStateOptions.md @@ -3,7 +3,7 @@ id: InjectMutationStateOptions title: InjectMutationStateOptions --- -Defined in: [inject-mutation-state.ts:40](https://github.com/TanStack/query/blob/main/packages/angular-query-experimental/src/inject-mutation-state.ts#L40) +Defined in: [packages/angular-query-experimental/src/inject-mutation-state.ts:40](https://github.com/TanStack/query/blob/main/packages/angular-query-experimental/src/inject-mutation-state.ts#L40) ## Properties @@ -13,7 +13,7 @@ Defined in: [inject-mutation-state.ts:40](https://github.com/TanStack/query/blob optional injector: Injector; ``` -Defined in: [inject-mutation-state.ts:46](https://github.com/TanStack/query/blob/main/packages/angular-query-experimental/src/inject-mutation-state.ts#L46) +Defined in: [packages/angular-query-experimental/src/inject-mutation-state.ts:46](https://github.com/TanStack/query/blob/main/packages/angular-query-experimental/src/inject-mutation-state.ts#L46) The `Injector` in which to create the mutation state signal. diff --git a/docs/framework/angular/reference/interfaces/InjectQueryOptions.md b/docs/framework/angular/reference/interfaces/InjectQueryOptions.md index c778d341dcc..418835acb0d 100644 --- a/docs/framework/angular/reference/interfaces/InjectQueryOptions.md +++ b/docs/framework/angular/reference/interfaces/InjectQueryOptions.md @@ -3,7 +3,7 @@ id: InjectQueryOptions title: InjectQueryOptions --- -Defined in: [inject-query.ts:20](https://github.com/TanStack/query/blob/main/packages/angular-query-experimental/src/inject-query.ts#L20) +Defined in: [packages/angular-query-experimental/src/inject-query.ts:20](https://github.com/TanStack/query/blob/main/packages/angular-query-experimental/src/inject-query.ts#L20) ## Properties @@ -13,7 +13,7 @@ Defined in: [inject-query.ts:20](https://github.com/TanStack/query/blob/main/pac optional injector: Injector; ``` -Defined in: [inject-query.ts:26](https://github.com/TanStack/query/blob/main/packages/angular-query-experimental/src/inject-query.ts#L26) +Defined in: [packages/angular-query-experimental/src/inject-query.ts:26](https://github.com/TanStack/query/blob/main/packages/angular-query-experimental/src/inject-query.ts#L26) The `Injector` in which to create the query. diff --git a/docs/framework/angular/reference/interfaces/InvalidateOptions.md b/docs/framework/angular/reference/interfaces/InvalidateOptions.md new file mode 100644 index 00000000000..8a81428b035 --- /dev/null +++ b/docs/framework/angular/reference/interfaces/InvalidateOptions.md @@ -0,0 +1,49 @@ +--- +id: InvalidateOptions +title: InvalidateOptions +--- + +Defined in: [packages/query-core/src/types.ts:734](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L734) + +## Extends + +- [`RefetchOptions`](RefetchOptions.md) + +## Properties + +### cancelRefetch? + +```ts +optional cancelRefetch: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:712](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L712) + +If set to `true`, a currently running request will be cancelled before a new request is made + +If set to `false`, no refetch will be made if there is already a request running. + +Defaults to `true`. + +#### Inherited from + +[`RefetchOptions`](RefetchOptions.md).[`cancelRefetch`](RefetchOptions.md#cancelrefetch) + +*** + +### throwOnError? + +```ts +optional throwOnError: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:701](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L701) + +If set to `true`, the method throws if any of the underlying query refetch tasks fail. + +Defaults to `false`, in which case failed refetches are swallowed and not surfaced to the +caller. + +#### Inherited from + +[`RefetchOptions`](RefetchOptions.md).[`throwOnError`](RefetchOptions.md#throwonerror) diff --git a/docs/framework/angular/reference/interfaces/InvalidateQueryFilters.md b/docs/framework/angular/reference/interfaces/InvalidateQueryFilters.md new file mode 100644 index 00000000000..569e42a4e1b --- /dev/null +++ b/docs/framework/angular/reference/interfaces/InvalidateQueryFilters.md @@ -0,0 +1,145 @@ +--- +id: InvalidateQueryFilters +title: InvalidateQueryFilters +--- + +Defined in: [packages/query-core/src/types.ts:715](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L715) + +Filters used to select queries, for example in `queryClient.getQueriesData` or `queryClient.invalidateQueries`. +All provided filters must match; filters that are left unspecified are ignored. + +## Extends + +- [`QueryFilters`](QueryFilters.md)\<`TQueryKey`\> + +## Type Parameters + +### TQueryKey + +`TQueryKey` *extends* [`QueryKey`](../type-aliases/QueryKey.md) = [`QueryKey`](../type-aliases/QueryKey.md) + +## Properties + +### exact? + +```ts +optional exact: boolean; +``` + +Defined in: [packages/query-core/src/utils.ts:41](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L41) + +Match query key exactly + +#### Inherited from + +[`QueryFilters`](QueryFilters.md).[`exact`](QueryFilters.md#exact) + +*** + +### fetchStatus? + +```ts +optional fetchStatus: FetchStatus; +``` + +Defined in: [packages/query-core/src/utils.ts:57](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L57) + +Include queries matching their fetchStatus + +#### Inherited from + +[`QueryFilters`](QueryFilters.md).[`fetchStatus`](QueryFilters.md#fetchstatus) + +*** + +### predicate()? + +```ts +optional predicate: (query) => boolean; +``` + +Defined in: [packages/query-core/src/utils.ts:45](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L45) + +Include queries matching this predicate function + +#### Parameters + +##### query + +[`Query`](../classes/Query.md) + +#### Returns + +`boolean` + +#### Inherited from + +[`QueryFilters`](QueryFilters.md).[`predicate`](QueryFilters.md#predicate) + +*** + +### queryKey? + +```ts +optional queryKey: TQueryKey | TuplePrefixes; +``` + +Defined in: [packages/query-core/src/utils.ts:49](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L49) + +Include queries matching this query key + +#### Inherited from + +[`QueryFilters`](QueryFilters.md).[`queryKey`](QueryFilters.md#querykey) + +*** + +### refetchType? + +```ts +optional refetchType: QueryTypeFilter | "none"; +``` + +Defined in: [packages/query-core/src/types.ts:727](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L727) + +Controls which of the matched (now-invalidated) queries are refetched in the background. + +Defaults to `'active'`. +- `'active'`: only queries with at least one active observer are refetched. +- `'inactive'`: only queries with no active observer are refetched. +- `'all'`: every matched query is refetched, active or not. +- `'none'`: no query is refetched; matched queries are only marked as invalidated. + +*** + +### stale? + +```ts +optional stale: boolean; +``` + +Defined in: [packages/query-core/src/utils.ts:53](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L53) + +Include or exclude stale queries + +#### Inherited from + +[`QueryFilters`](QueryFilters.md).[`stale`](QueryFilters.md#stale) + +*** + +### type? + +```ts +optional type: QueryTypeFilter; +``` + +Defined in: [packages/query-core/src/utils.ts:37](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L37) + +Filter to active queries, inactive queries or all queries + +Defaults to `'all'`. + +#### Inherited from + +[`QueryFilters`](QueryFilters.md).[`type`](QueryFilters.md#type) diff --git a/docs/framework/angular/reference/interfaces/MutateOptions.md b/docs/framework/angular/reference/interfaces/MutateOptions.md new file mode 100644 index 00000000000..34e2a4d4d7e --- /dev/null +++ b/docs/framework/angular/reference/interfaces/MutateOptions.md @@ -0,0 +1,124 @@ +--- +id: MutateOptions +title: MutateOptions +--- + +Defined in: [packages/query-core/src/types.ts:1284](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1284) + +## Type Parameters + +### TData + +`TData` = `unknown` + +### TError + +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) + +### TVariables + +`TVariables` = `void` + +### TOnMutateResult + +`TOnMutateResult` = `unknown` + +## Properties + +### onError()? + +```ts +optional onError: (error, variables, onMutateResult, context) => void; +``` + +Defined in: [packages/query-core/src/types.ts:1296](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1296) + +#### Parameters + +##### error + +`TError` + +##### variables + +`TVariables` + +##### onMutateResult + +`TOnMutateResult` | `undefined` + +##### context + +[`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md) + +#### Returns + +`void` + +*** + +### onSettled()? + +```ts +optional onSettled: (data, error, variables, onMutateResult, context) => void; +``` + +Defined in: [packages/query-core/src/types.ts:1302](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1302) + +#### Parameters + +##### data + +`TData` | `undefined` + +##### error + +`TError` | `null` + +##### variables + +`TVariables` + +##### onMutateResult + +`TOnMutateResult` | `undefined` + +##### context + +[`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md) + +#### Returns + +`void` + +*** + +### onSuccess()? + +```ts +optional onSuccess: (data, variables, onMutateResult, context) => void; +``` + +Defined in: [packages/query-core/src/types.ts:1290](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1290) + +#### Parameters + +##### data + +`TData` + +##### variables + +`TVariables` + +##### onMutateResult + +`TOnMutateResult` | `undefined` + +##### context + +[`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md) + +#### Returns + +`void` diff --git a/docs/framework/angular/reference/interfaces/MutationCacheConfig.md b/docs/framework/angular/reference/interfaces/MutationCacheConfig.md new file mode 100644 index 00000000000..c38d2dc26f4 --- /dev/null +++ b/docs/framework/angular/reference/interfaces/MutationCacheConfig.md @@ -0,0 +1,161 @@ +--- +id: MutationCacheConfig +title: MutationCacheConfig +--- + +Defined in: [packages/query-core/src/mutationCache.ts:26](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationCache.ts#L26) + +Global callbacks that fire for every mutation handled by a `MutationCache`, regardless of which +component or observer triggered it. They differ from the `defaultOptions` provided to a +`QueryClient` in two ways: `defaultOptions` can be overridden by each mutation, while these +callbacks are always called, and `onMutate` here does not allow returning a result. + +If a callback returns a promise, it will be awaited before the mutation continues. + +## Properties + +### onError()? + +```ts +optional onError: (error, variables, onMutateResult, mutation, context) => unknown; +``` + +Defined in: [packages/query-core/src/mutationCache.ts:28](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationCache.ts#L28) + +Called when any mutation in the cache encounters an error. + +#### Parameters + +##### error + +`Error` + +##### variables + +`unknown` + +##### onMutateResult + +`unknown` + +##### mutation + +[`Mutation`](../classes/Mutation.md)\<`unknown`, `unknown`, `unknown`\> + +##### context + +[`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md) + +#### Returns + +`unknown` + +*** + +### onMutate()? + +```ts +optional onMutate: (variables, mutation, context) => unknown; +``` + +Defined in: [packages/query-core/src/mutationCache.ts:44](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationCache.ts#L44) + +Called before any mutation in the cache executes. + +#### Parameters + +##### variables + +`unknown` + +##### mutation + +[`Mutation`](../classes/Mutation.md)\<`unknown`, `unknown`, `unknown`\> + +##### context + +[`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md) + +#### Returns + +`unknown` + +*** + +### onSettled()? + +```ts +optional onSettled: (data, error, variables, onMutateResult, mutation, context) => unknown; +``` + +Defined in: [packages/query-core/src/mutationCache.ts:50](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationCache.ts#L50) + +Called when any mutation in the cache is settled, either successfully or with an error. + +#### Parameters + +##### data + +`unknown` + +##### error + +`Error` | `null` + +##### variables + +`unknown` + +##### onMutateResult + +`unknown` + +##### mutation + +[`Mutation`](../classes/Mutation.md)\<`unknown`, `unknown`, `unknown`\> + +##### context + +[`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md) + +#### Returns + +`unknown` + +*** + +### onSuccess()? + +```ts +optional onSuccess: (data, variables, onMutateResult, mutation, context) => unknown; +``` + +Defined in: [packages/query-core/src/mutationCache.ts:36](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationCache.ts#L36) + +Called when any mutation in the cache is successful. + +#### Parameters + +##### data + +`unknown` + +##### variables + +`unknown` + +##### onMutateResult + +`unknown` + +##### mutation + +[`Mutation`](../classes/Mutation.md)\<`unknown`, `unknown`, `unknown`\> + +##### context + +[`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md) + +#### Returns + +`unknown` diff --git a/docs/framework/angular/reference/interfaces/MutationFilters.md b/docs/framework/angular/reference/interfaces/MutationFilters.md new file mode 100644 index 00000000000..fbc0208e8e1 --- /dev/null +++ b/docs/framework/angular/reference/interfaces/MutationFilters.md @@ -0,0 +1,85 @@ +--- +id: MutationFilters +title: MutationFilters +--- + +Defined in: [packages/query-core/src/utils.ts:64](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L64) + +Filters used to select mutations, for example in `mutationCache.findAll` or `queryClient.isMutating`. +All provided filters must match; filters that are left unspecified are ignored. + +## Type Parameters + +### TData + +`TData` = `unknown` + +### TError + +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) + +### TVariables + +`TVariables` = `unknown` + +### TOnMutateResult + +`TOnMutateResult` = `unknown` + +## Properties + +### exact? + +```ts +optional exact: boolean; +``` + +Defined in: [packages/query-core/src/utils.ts:73](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L73) + +Match mutation key exactly + +*** + +### mutationKey? + +```ts +optional mutationKey: readonly unknown[]; +``` + +Defined in: [packages/query-core/src/utils.ts:83](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L83) + +Include mutations matching this mutation key + +*** + +### predicate()? + +```ts +optional predicate: (mutation) => boolean; +``` + +Defined in: [packages/query-core/src/utils.ts:77](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L77) + +Include mutations matching this predicate function + +#### Parameters + +##### mutation + +[`Mutation`](../classes/Mutation.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\> + +#### Returns + +`boolean` + +*** + +### status? + +```ts +optional status: MutationStatus; +``` + +Defined in: [packages/query-core/src/utils.ts:87](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L87) + +Filter by mutation status diff --git a/docs/framework/angular/reference/interfaces/MutationObserverBaseResult.md b/docs/framework/angular/reference/interfaces/MutationObserverBaseResult.md new file mode 100644 index 00000000000..340a38cc9cc --- /dev/null +++ b/docs/framework/angular/reference/interfaces/MutationObserverBaseResult.md @@ -0,0 +1,291 @@ +--- +id: MutationObserverBaseResult +title: MutationObserverBaseResult +--- + +Defined in: [packages/query-core/src/types.ts:1335](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1335) + +The raw state stored on a `Mutation` instance. This is the underlying state +that observer results (e.g. `MutationObserverResult`) are derived from. + +## Extends + +- [`MutationState`](MutationState.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\> + +## Extended by + +- [`MutationObserverIdleResult`](MutationObserverIdleResult.md) +- [`MutationObserverLoadingResult`](MutationObserverLoadingResult.md) +- [`MutationObserverErrorResult`](MutationObserverErrorResult.md) +- [`MutationObserverSuccessResult`](MutationObserverSuccessResult.md) + +## Type Parameters + +### TData + +`TData` = `unknown` + +### TError + +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) + +### TVariables + +`TVariables` = `void` + +### TOnMutateResult + +`TOnMutateResult` = `unknown` + +## Properties + +### context + +```ts +context: TOnMutateResult | undefined; +``` + +Defined in: [packages/query-core/src/mutation.ts:40](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L40) + +The value returned by `onMutate`, if defined. Passed to `onSuccess`, +`onError` and `onSettled` as the mutation's context. + +#### Inherited from + +[`MutationState`](MutationState.md).[`context`](MutationState.md#context) + +*** + +### data + +```ts +data: TData | undefined; +``` + +Defined in: [packages/query-core/src/types.ts:1344](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1344) + +The last successfully resolved data for the mutation. + +#### Overrides + +[`MutationState`](MutationState.md).[`data`](MutationState.md#data) + +*** + +### error + +```ts +error: TError | null; +``` + +Defined in: [packages/query-core/src/types.ts:1353](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1353) + +The error object for the mutation, if an error was encountered. +- Defaults to `null`. + +#### Overrides + +[`MutationState`](MutationState.md).[`error`](MutationState.md#error) + +*** + +### failureCount + +```ts +failureCount: number; +``` + +Defined in: [packages/query-core/src/mutation.ts:53](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L53) + +The number of times the mutation function has failed for the current attempt. + +#### Inherited from + +[`MutationState`](MutationState.md).[`failureCount`](MutationState.md#failurecount) + +*** + +### failureReason + +```ts +failureReason: TError | null; +``` + +Defined in: [packages/query-core/src/mutation.ts:57](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L57) + +The reason the current attempt failed, as reported by the retryer. + +#### Inherited from + +[`MutationState`](MutationState.md).[`failureReason`](MutationState.md#failurereason) + +*** + +### isError + +```ts +isError: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1358](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1358) + +A boolean variable derived from `status`. +- `true` if the last mutation attempt resulted in an error. + +*** + +### isIdle + +```ts +isIdle: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1363](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1363) + +A boolean variable derived from `status`. +- `true` if the mutation is in its initial state prior to executing. + +*** + +### isPaused + +```ts +isPaused: boolean; +``` + +Defined in: [packages/query-core/src/mutation.ts:62](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L62) + +Whether the mutation is currently paused (see network mode), or is +waiting for another mutation with the same `scope` to finish. + +#### Inherited from + +[`MutationState`](MutationState.md).[`isPaused`](MutationState.md#ispaused) + +*** + +### isPending + +```ts +isPending: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1368](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1368) + +A boolean variable derived from `status`. +- `true` if the mutation is currently executing. + +*** + +### isSuccess + +```ts +isSuccess: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1373](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1373) + +A boolean variable derived from `status`. +- `true` if the last mutation attempt was successful. + +*** + +### mutate + +```ts +mutate: MutateFunction; +``` + +Defined in: [packages/query-core/src/types.ts:1393](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1393) + +The mutation function you can call with variables to trigger the mutation and optionally hooks on additional callback options. + +#### Param + +The variables object to pass to the `mutationFn`. + +#### Param + +This function will fire when the mutation is successful and will be passed the mutation's result. + +#### Param + +This function will fire if the mutation encounters an error and will be passed the error. + +#### Param + +This function will fire when the mutation is either successfully fetched or encounters an error and be passed either the data or error. + +#### Remarks + +- If you make multiple requests, `onSuccess` will fire only after the latest call you've made. +- All the callback functions (`onSuccess`, `onError`, `onSettled`) are void functions, and the returned value will be ignored. + +*** + +### reset() + +```ts +reset: () => void; +``` + +Defined in: [packages/query-core/src/types.ts:1397](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1397) + +A function to clean the mutation internal state (i.e., it resets the mutation to its initial state). + +#### Returns + +`void` + +*** + +### status + +```ts +status: MutationStatus; +``` + +Defined in: [packages/query-core/src/types.ts:1382](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1382) + +The status of the mutation. +- Will be: + - `idle` initial status prior to the mutation function executing. + - `pending` if the mutation is currently executing. + - `error` if the last mutation attempt resulted in an error. + - `success` if the last mutation attempt was successful. + +#### Overrides + +[`MutationState`](MutationState.md).[`status`](MutationState.md#status) + +*** + +### submittedAt + +```ts +submittedAt: number; +``` + +Defined in: [packages/query-core/src/mutation.ts:74](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L74) + +The timestamp for when the mutation was submitted. + +#### Inherited from + +[`MutationState`](MutationState.md).[`submittedAt`](MutationState.md#submittedat) + +*** + +### variables + +```ts +variables: TVariables | undefined; +``` + +Defined in: [packages/query-core/src/types.ts:1348](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1348) + +The variables object passed to the `mutationFn`. + +#### Overrides + +[`MutationState`](MutationState.md).[`variables`](MutationState.md#variables) diff --git a/docs/framework/angular/reference/interfaces/MutationObserverErrorResult.md b/docs/framework/angular/reference/interfaces/MutationObserverErrorResult.md new file mode 100644 index 00000000000..72e459a2e0b --- /dev/null +++ b/docs/framework/angular/reference/interfaces/MutationObserverErrorResult.md @@ -0,0 +1,308 @@ +--- +id: MutationObserverErrorResult +title: MutationObserverErrorResult +--- + +Defined in: [packages/query-core/src/types.ts:1442](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1442) + +The raw state stored on a `Mutation` instance. This is the underlying state +that observer results (e.g. `MutationObserverResult`) are derived from. + +## Extends + +- [`MutationObserverBaseResult`](MutationObserverBaseResult.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\> + +## Type Parameters + +### TData + +`TData` = `unknown` + +### TError + +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) + +### TVariables + +`TVariables` = `void` + +### TOnMutateResult + +`TOnMutateResult` = `unknown` + +## Properties + +### context + +```ts +context: TOnMutateResult | undefined; +``` + +Defined in: [packages/query-core/src/mutation.ts:40](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L40) + +The value returned by `onMutate`, if defined. Passed to `onSuccess`, +`onError` and `onSettled` as the mutation's context. + +#### Inherited from + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`context`](MutationObserverBaseResult.md#context) + +*** + +### data + +```ts +data: undefined; +``` + +Defined in: [packages/query-core/src/types.ts:1453](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1453) + +The last successfully resolved data for the mutation. + +#### Overrides + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`data`](MutationObserverBaseResult.md#data) + +*** + +### error + +```ts +error: TError; +``` + +Defined in: [packages/query-core/src/types.ts:1454](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1454) + +The error object for the mutation, if an error was encountered. +- Defaults to `null`. + +#### Overrides + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`error`](MutationObserverBaseResult.md#error) + +*** + +### failureCount + +```ts +failureCount: number; +``` + +Defined in: [packages/query-core/src/mutation.ts:53](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L53) + +The number of times the mutation function has failed for the current attempt. + +#### Inherited from + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`failureCount`](MutationObserverBaseResult.md#failurecount) + +*** + +### failureReason + +```ts +failureReason: TError | null; +``` + +Defined in: [packages/query-core/src/mutation.ts:57](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L57) + +The reason the current attempt failed, as reported by the retryer. + +#### Inherited from + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`failureReason`](MutationObserverBaseResult.md#failurereason) + +*** + +### isError + +```ts +isError: true; +``` + +Defined in: [packages/query-core/src/types.ts:1456](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1456) + +A boolean variable derived from `status`. +- `true` if the last mutation attempt resulted in an error. + +#### Overrides + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isError`](MutationObserverBaseResult.md#iserror) + +*** + +### isIdle + +```ts +isIdle: false; +``` + +Defined in: [packages/query-core/src/types.ts:1457](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1457) + +A boolean variable derived from `status`. +- `true` if the mutation is in its initial state prior to executing. + +#### Overrides + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isIdle`](MutationObserverBaseResult.md#isidle) + +*** + +### isPaused + +```ts +isPaused: boolean; +``` + +Defined in: [packages/query-core/src/mutation.ts:62](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L62) + +Whether the mutation is currently paused (see network mode), or is +waiting for another mutation with the same `scope` to finish. + +#### Inherited from + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isPaused`](MutationObserverBaseResult.md#ispaused) + +*** + +### isPending + +```ts +isPending: false; +``` + +Defined in: [packages/query-core/src/types.ts:1458](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1458) + +A boolean variable derived from `status`. +- `true` if the mutation is currently executing. + +#### Overrides + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isPending`](MutationObserverBaseResult.md#ispending) + +*** + +### isSuccess + +```ts +isSuccess: false; +``` + +Defined in: [packages/query-core/src/types.ts:1459](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1459) + +A boolean variable derived from `status`. +- `true` if the last mutation attempt was successful. + +#### Overrides + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isSuccess`](MutationObserverBaseResult.md#issuccess) + +*** + +### mutate + +```ts +mutate: MutateFunction; +``` + +Defined in: [packages/query-core/src/types.ts:1393](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1393) + +The mutation function you can call with variables to trigger the mutation and optionally hooks on additional callback options. + +#### Param + +The variables object to pass to the `mutationFn`. + +#### Param + +This function will fire when the mutation is successful and will be passed the mutation's result. + +#### Param + +This function will fire if the mutation encounters an error and will be passed the error. + +#### Param + +This function will fire when the mutation is either successfully fetched or encounters an error and be passed either the data or error. + +#### Remarks + +- If you make multiple requests, `onSuccess` will fire only after the latest call you've made. +- All the callback functions (`onSuccess`, `onError`, `onSettled`) are void functions, and the returned value will be ignored. + +#### Inherited from + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`mutate`](MutationObserverBaseResult.md#mutate) + +*** + +### reset() + +```ts +reset: () => void; +``` + +Defined in: [packages/query-core/src/types.ts:1397](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1397) + +A function to clean the mutation internal state (i.e., it resets the mutation to its initial state). + +#### Returns + +`void` + +#### Inherited from + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`reset`](MutationObserverBaseResult.md#reset) + +*** + +### status + +```ts +status: "error"; +``` + +Defined in: [packages/query-core/src/types.ts:1460](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1460) + +The status of the mutation. +- Will be: + - `idle` initial status prior to the mutation function executing. + - `pending` if the mutation is currently executing. + - `error` if the last mutation attempt resulted in an error. + - `success` if the last mutation attempt was successful. + +#### Overrides + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`status`](MutationObserverBaseResult.md#status) + +*** + +### submittedAt + +```ts +submittedAt: number; +``` + +Defined in: [packages/query-core/src/mutation.ts:74](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L74) + +The timestamp for when the mutation was submitted. + +#### Inherited from + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`submittedAt`](MutationObserverBaseResult.md#submittedat) + +*** + +### variables + +```ts +variables: TVariables; +``` + +Defined in: [packages/query-core/src/types.ts:1455](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1455) + +The variables object passed to the `mutationFn`. + +#### Overrides + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`variables`](MutationObserverBaseResult.md#variables) diff --git a/docs/framework/angular/reference/interfaces/MutationObserverIdleResult.md b/docs/framework/angular/reference/interfaces/MutationObserverIdleResult.md new file mode 100644 index 00000000000..cd8d6eb3130 --- /dev/null +++ b/docs/framework/angular/reference/interfaces/MutationObserverIdleResult.md @@ -0,0 +1,308 @@ +--- +id: MutationObserverIdleResult +title: MutationObserverIdleResult +--- + +Defined in: [packages/query-core/src/types.ts:1400](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1400) + +The raw state stored on a `Mutation` instance. This is the underlying state +that observer results (e.g. `MutationObserverResult`) are derived from. + +## Extends + +- [`MutationObserverBaseResult`](MutationObserverBaseResult.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\> + +## Type Parameters + +### TData + +`TData` = `unknown` + +### TError + +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) + +### TVariables + +`TVariables` = `void` + +### TOnMutateResult + +`TOnMutateResult` = `unknown` + +## Properties + +### context + +```ts +context: TOnMutateResult | undefined; +``` + +Defined in: [packages/query-core/src/mutation.ts:40](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L40) + +The value returned by `onMutate`, if defined. Passed to `onSuccess`, +`onError` and `onSettled` as the mutation's context. + +#### Inherited from + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`context`](MutationObserverBaseResult.md#context) + +*** + +### data + +```ts +data: undefined; +``` + +Defined in: [packages/query-core/src/types.ts:1411](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1411) + +The last successfully resolved data for the mutation. + +#### Overrides + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`data`](MutationObserverBaseResult.md#data) + +*** + +### error + +```ts +error: null; +``` + +Defined in: [packages/query-core/src/types.ts:1413](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1413) + +The error object for the mutation, if an error was encountered. +- Defaults to `null`. + +#### Overrides + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`error`](MutationObserverBaseResult.md#error) + +*** + +### failureCount + +```ts +failureCount: number; +``` + +Defined in: [packages/query-core/src/mutation.ts:53](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L53) + +The number of times the mutation function has failed for the current attempt. + +#### Inherited from + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`failureCount`](MutationObserverBaseResult.md#failurecount) + +*** + +### failureReason + +```ts +failureReason: TError | null; +``` + +Defined in: [packages/query-core/src/mutation.ts:57](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L57) + +The reason the current attempt failed, as reported by the retryer. + +#### Inherited from + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`failureReason`](MutationObserverBaseResult.md#failurereason) + +*** + +### isError + +```ts +isError: false; +``` + +Defined in: [packages/query-core/src/types.ts:1414](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1414) + +A boolean variable derived from `status`. +- `true` if the last mutation attempt resulted in an error. + +#### Overrides + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isError`](MutationObserverBaseResult.md#iserror) + +*** + +### isIdle + +```ts +isIdle: true; +``` + +Defined in: [packages/query-core/src/types.ts:1415](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1415) + +A boolean variable derived from `status`. +- `true` if the mutation is in its initial state prior to executing. + +#### Overrides + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isIdle`](MutationObserverBaseResult.md#isidle) + +*** + +### isPaused + +```ts +isPaused: boolean; +``` + +Defined in: [packages/query-core/src/mutation.ts:62](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L62) + +Whether the mutation is currently paused (see network mode), or is +waiting for another mutation with the same `scope` to finish. + +#### Inherited from + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isPaused`](MutationObserverBaseResult.md#ispaused) + +*** + +### isPending + +```ts +isPending: false; +``` + +Defined in: [packages/query-core/src/types.ts:1416](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1416) + +A boolean variable derived from `status`. +- `true` if the mutation is currently executing. + +#### Overrides + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isPending`](MutationObserverBaseResult.md#ispending) + +*** + +### isSuccess + +```ts +isSuccess: false; +``` + +Defined in: [packages/query-core/src/types.ts:1417](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1417) + +A boolean variable derived from `status`. +- `true` if the last mutation attempt was successful. + +#### Overrides + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isSuccess`](MutationObserverBaseResult.md#issuccess) + +*** + +### mutate + +```ts +mutate: MutateFunction; +``` + +Defined in: [packages/query-core/src/types.ts:1393](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1393) + +The mutation function you can call with variables to trigger the mutation and optionally hooks on additional callback options. + +#### Param + +The variables object to pass to the `mutationFn`. + +#### Param + +This function will fire when the mutation is successful and will be passed the mutation's result. + +#### Param + +This function will fire if the mutation encounters an error and will be passed the error. + +#### Param + +This function will fire when the mutation is either successfully fetched or encounters an error and be passed either the data or error. + +#### Remarks + +- If you make multiple requests, `onSuccess` will fire only after the latest call you've made. +- All the callback functions (`onSuccess`, `onError`, `onSettled`) are void functions, and the returned value will be ignored. + +#### Inherited from + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`mutate`](MutationObserverBaseResult.md#mutate) + +*** + +### reset() + +```ts +reset: () => void; +``` + +Defined in: [packages/query-core/src/types.ts:1397](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1397) + +A function to clean the mutation internal state (i.e., it resets the mutation to its initial state). + +#### Returns + +`void` + +#### Inherited from + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`reset`](MutationObserverBaseResult.md#reset) + +*** + +### status + +```ts +status: "idle"; +``` + +Defined in: [packages/query-core/src/types.ts:1418](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1418) + +The status of the mutation. +- Will be: + - `idle` initial status prior to the mutation function executing. + - `pending` if the mutation is currently executing. + - `error` if the last mutation attempt resulted in an error. + - `success` if the last mutation attempt was successful. + +#### Overrides + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`status`](MutationObserverBaseResult.md#status) + +*** + +### submittedAt + +```ts +submittedAt: number; +``` + +Defined in: [packages/query-core/src/mutation.ts:74](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L74) + +The timestamp for when the mutation was submitted. + +#### Inherited from + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`submittedAt`](MutationObserverBaseResult.md#submittedat) + +*** + +### variables + +```ts +variables: undefined; +``` + +Defined in: [packages/query-core/src/types.ts:1412](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1412) + +The variables object passed to the `mutationFn`. + +#### Overrides + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`variables`](MutationObserverBaseResult.md#variables) diff --git a/docs/framework/angular/reference/interfaces/MutationObserverLoadingResult.md b/docs/framework/angular/reference/interfaces/MutationObserverLoadingResult.md new file mode 100644 index 00000000000..9b70a8558e7 --- /dev/null +++ b/docs/framework/angular/reference/interfaces/MutationObserverLoadingResult.md @@ -0,0 +1,308 @@ +--- +id: MutationObserverLoadingResult +title: MutationObserverLoadingResult +--- + +Defined in: [packages/query-core/src/types.ts:1421](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1421) + +The raw state stored on a `Mutation` instance. This is the underlying state +that observer results (e.g. `MutationObserverResult`) are derived from. + +## Extends + +- [`MutationObserverBaseResult`](MutationObserverBaseResult.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\> + +## Type Parameters + +### TData + +`TData` = `unknown` + +### TError + +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) + +### TVariables + +`TVariables` = `void` + +### TOnMutateResult + +`TOnMutateResult` = `unknown` + +## Properties + +### context + +```ts +context: TOnMutateResult | undefined; +``` + +Defined in: [packages/query-core/src/mutation.ts:40](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L40) + +The value returned by `onMutate`, if defined. Passed to `onSuccess`, +`onError` and `onSettled` as the mutation's context. + +#### Inherited from + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`context`](MutationObserverBaseResult.md#context) + +*** + +### data + +```ts +data: undefined; +``` + +Defined in: [packages/query-core/src/types.ts:1432](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1432) + +The last successfully resolved data for the mutation. + +#### Overrides + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`data`](MutationObserverBaseResult.md#data) + +*** + +### error + +```ts +error: null; +``` + +Defined in: [packages/query-core/src/types.ts:1434](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1434) + +The error object for the mutation, if an error was encountered. +- Defaults to `null`. + +#### Overrides + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`error`](MutationObserverBaseResult.md#error) + +*** + +### failureCount + +```ts +failureCount: number; +``` + +Defined in: [packages/query-core/src/mutation.ts:53](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L53) + +The number of times the mutation function has failed for the current attempt. + +#### Inherited from + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`failureCount`](MutationObserverBaseResult.md#failurecount) + +*** + +### failureReason + +```ts +failureReason: TError | null; +``` + +Defined in: [packages/query-core/src/mutation.ts:57](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L57) + +The reason the current attempt failed, as reported by the retryer. + +#### Inherited from + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`failureReason`](MutationObserverBaseResult.md#failurereason) + +*** + +### isError + +```ts +isError: false; +``` + +Defined in: [packages/query-core/src/types.ts:1435](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1435) + +A boolean variable derived from `status`. +- `true` if the last mutation attempt resulted in an error. + +#### Overrides + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isError`](MutationObserverBaseResult.md#iserror) + +*** + +### isIdle + +```ts +isIdle: false; +``` + +Defined in: [packages/query-core/src/types.ts:1436](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1436) + +A boolean variable derived from `status`. +- `true` if the mutation is in its initial state prior to executing. + +#### Overrides + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isIdle`](MutationObserverBaseResult.md#isidle) + +*** + +### isPaused + +```ts +isPaused: boolean; +``` + +Defined in: [packages/query-core/src/mutation.ts:62](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L62) + +Whether the mutation is currently paused (see network mode), or is +waiting for another mutation with the same `scope` to finish. + +#### Inherited from + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isPaused`](MutationObserverBaseResult.md#ispaused) + +*** + +### isPending + +```ts +isPending: true; +``` + +Defined in: [packages/query-core/src/types.ts:1437](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1437) + +A boolean variable derived from `status`. +- `true` if the mutation is currently executing. + +#### Overrides + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isPending`](MutationObserverBaseResult.md#ispending) + +*** + +### isSuccess + +```ts +isSuccess: false; +``` + +Defined in: [packages/query-core/src/types.ts:1438](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1438) + +A boolean variable derived from `status`. +- `true` if the last mutation attempt was successful. + +#### Overrides + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isSuccess`](MutationObserverBaseResult.md#issuccess) + +*** + +### mutate + +```ts +mutate: MutateFunction; +``` + +Defined in: [packages/query-core/src/types.ts:1393](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1393) + +The mutation function you can call with variables to trigger the mutation and optionally hooks on additional callback options. + +#### Param + +The variables object to pass to the `mutationFn`. + +#### Param + +This function will fire when the mutation is successful and will be passed the mutation's result. + +#### Param + +This function will fire if the mutation encounters an error and will be passed the error. + +#### Param + +This function will fire when the mutation is either successfully fetched or encounters an error and be passed either the data or error. + +#### Remarks + +- If you make multiple requests, `onSuccess` will fire only after the latest call you've made. +- All the callback functions (`onSuccess`, `onError`, `onSettled`) are void functions, and the returned value will be ignored. + +#### Inherited from + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`mutate`](MutationObserverBaseResult.md#mutate) + +*** + +### reset() + +```ts +reset: () => void; +``` + +Defined in: [packages/query-core/src/types.ts:1397](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1397) + +A function to clean the mutation internal state (i.e., it resets the mutation to its initial state). + +#### Returns + +`void` + +#### Inherited from + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`reset`](MutationObserverBaseResult.md#reset) + +*** + +### status + +```ts +status: "pending"; +``` + +Defined in: [packages/query-core/src/types.ts:1439](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1439) + +The status of the mutation. +- Will be: + - `idle` initial status prior to the mutation function executing. + - `pending` if the mutation is currently executing. + - `error` if the last mutation attempt resulted in an error. + - `success` if the last mutation attempt was successful. + +#### Overrides + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`status`](MutationObserverBaseResult.md#status) + +*** + +### submittedAt + +```ts +submittedAt: number; +``` + +Defined in: [packages/query-core/src/mutation.ts:74](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L74) + +The timestamp for when the mutation was submitted. + +#### Inherited from + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`submittedAt`](MutationObserverBaseResult.md#submittedat) + +*** + +### variables + +```ts +variables: TVariables; +``` + +Defined in: [packages/query-core/src/types.ts:1433](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1433) + +The variables object passed to the `mutationFn`. + +#### Overrides + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`variables`](MutationObserverBaseResult.md#variables) diff --git a/docs/framework/angular/reference/interfaces/MutationObserverOptions.md b/docs/framework/angular/reference/interfaces/MutationObserverOptions.md new file mode 100644 index 00000000000..5bab2840a6d --- /dev/null +++ b/docs/framework/angular/reference/interfaces/MutationObserverOptions.md @@ -0,0 +1,322 @@ +--- +id: MutationObserverOptions +title: MutationObserverOptions +--- + +Defined in: [packages/query-core/src/types.ts:1267](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1267) + +## Extends + +- [`MutationOptions`](MutationOptions.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\> + +## Type Parameters + +### TData + +`TData` = `unknown` + +### TError + +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) + +### TVariables + +`TVariables` = `void` + +### TOnMutateResult + +`TOnMutateResult` = `unknown` + +## Properties + +### gcTime? + +```ts +optional gcTime: number; +``` + +Defined in: [packages/query-core/src/types.ts:1260](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1260) + +The time in milliseconds that an unused/inactive mutation remains in memory before it is +garbage collected. + +Defaults to `5 * 60 * 1000` (5 minutes), or `Infinity` during SSR. + +#### Inherited from + +[`MutationOptions`](MutationOptions.md).[`gcTime`](MutationOptions.md#gctime) + +*** + +### meta? + +```ts +optional meta: Record; +``` + +Defined in: [packages/query-core/src/types.ts:1263](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1263) + +#### Inherited from + +[`MutationOptions`](MutationOptions.md).[`meta`](MutationOptions.md#meta) + +*** + +### mutationFn? + +```ts +optional mutationFn: MutationFunction; +``` + +Defined in: [packages/query-core/src/types.ts:1206](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1206) + +#### Inherited from + +[`MutationOptions`](MutationOptions.md).[`mutationFn`](MutationOptions.md#mutationfn) + +*** + +### mutationKey? + +```ts +optional mutationKey: readonly unknown[]; +``` + +Defined in: [packages/query-core/src/types.ts:1207](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1207) + +#### Inherited from + +[`MutationOptions`](MutationOptions.md).[`mutationKey`](MutationOptions.md#mutationkey) + +*** + +### networkMode? + +```ts +optional networkMode: NetworkMode; +``` + +Defined in: [packages/query-core/src/types.ts:1253](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1253) + +Controls whether a mutation is allowed to run based on the current network connectivity. + +Defaults to `'online'`. + +#### See + +[Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. + +#### Inherited from + +[`MutationOptions`](MutationOptions.md).[`networkMode`](MutationOptions.md#networkmode) + +*** + +### onError()? + +```ts +optional onError: (error, variables, onMutateResult, context) => unknown; +``` + +Defined in: [packages/query-core/src/types.ts:1218](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1218) + +#### Parameters + +##### error + +`TError` + +##### variables + +`TVariables` + +##### onMutateResult + +`TOnMutateResult` | `undefined` + +##### context + +[`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md) + +#### Returns + +`unknown` + +#### Inherited from + +[`MutationOptions`](MutationOptions.md).[`onError`](MutationOptions.md#onerror) + +*** + +### onMutate()? + +```ts +optional onMutate: (variables, context) => TOnMutateResult | Promise; +``` + +Defined in: [packages/query-core/src/types.ts:1208](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1208) + +#### Parameters + +##### variables + +`TVariables` + +##### context + +[`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md) + +#### Returns + +`TOnMutateResult` \| `Promise`\<`TOnMutateResult`\> + +#### Inherited from + +[`MutationOptions`](MutationOptions.md).[`onMutate`](MutationOptions.md#onmutate) + +*** + +### onSettled()? + +```ts +optional onSettled: (data, error, variables, onMutateResult, context) => unknown; +``` + +Defined in: [packages/query-core/src/types.ts:1224](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1224) + +#### Parameters + +##### data + +`TData` | `undefined` + +##### error + +`TError` | `null` + +##### variables + +`TVariables` + +##### onMutateResult + +`TOnMutateResult` | `undefined` + +##### context + +[`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md) + +#### Returns + +`unknown` + +#### Inherited from + +[`MutationOptions`](MutationOptions.md).[`onSettled`](MutationOptions.md#onsettled) + +*** + +### onSuccess()? + +```ts +optional onSuccess: (data, variables, onMutateResult, context) => unknown; +``` + +Defined in: [packages/query-core/src/types.ts:1212](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1212) + +#### Parameters + +##### data + +`TData` + +##### variables + +`TVariables` + +##### onMutateResult + +`TOnMutateResult` + +##### context + +[`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md) + +#### Returns + +`unknown` + +#### Inherited from + +[`MutationOptions`](MutationOptions.md).[`onSuccess`](MutationOptions.md#onsuccess) + +*** + +### retry? + +```ts +optional retry: RetryValue; +``` + +Defined in: [packages/query-core/src/types.ts:1239](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1239) + +If `false`, failed mutations will not retry by default. +If `true`, failed mutations will retry infinitely. +If set to an integer number, e.g. 3, failed mutations will retry until the failed mutation count meets that number. +If set to a function `(failureCount, error) => boolean` failed mutations will retry until the function returns false. + +Defaults to `0`. + +#### Inherited from + +[`MutationOptions`](MutationOptions.md).[`retry`](MutationOptions.md#retry) + +*** + +### retryDelay? + +```ts +optional retryDelay: RetryDelayValue; +``` + +Defined in: [packages/query-core/src/types.ts:1246](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1246) + +This function receives a `retryAttempt` integer and the actual Error and returns the delay to apply before the +next attempt in milliseconds. + +Defaults to a function that applies exponential backoff, capped at 30 seconds. + +#### Inherited from + +[`MutationOptions`](MutationOptions.md).[`retryDelay`](MutationOptions.md#retrydelay) + +*** + +### scope? + +```ts +optional scope: MutationScope; +``` + +Defined in: [packages/query-core/src/types.ts:1264](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1264) + +#### Inherited from + +[`MutationOptions`](MutationOptions.md).[`scope`](MutationOptions.md#scope) + +*** + +### throwOnError? + +```ts +optional throwOnError: boolean | (error) => boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1281](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1281) + +Whether errors should be thrown instead of setting the `error` property. +If set to `true`, all errors will be thrown to the nearest error boundary. +If set to a function, it will be passed the error and should return a boolean indicating whether to throw the +error (`true`) or return it as state (`false`). + +Defaults to `false`. diff --git a/docs/framework/angular/reference/interfaces/MutationObserverSuccessResult.md b/docs/framework/angular/reference/interfaces/MutationObserverSuccessResult.md new file mode 100644 index 00000000000..e2e03642f82 --- /dev/null +++ b/docs/framework/angular/reference/interfaces/MutationObserverSuccessResult.md @@ -0,0 +1,308 @@ +--- +id: MutationObserverSuccessResult +title: MutationObserverSuccessResult +--- + +Defined in: [packages/query-core/src/types.ts:1463](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1463) + +The raw state stored on a `Mutation` instance. This is the underlying state +that observer results (e.g. `MutationObserverResult`) are derived from. + +## Extends + +- [`MutationObserverBaseResult`](MutationObserverBaseResult.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\> + +## Type Parameters + +### TData + +`TData` = `unknown` + +### TError + +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) + +### TVariables + +`TVariables` = `void` + +### TOnMutateResult + +`TOnMutateResult` = `unknown` + +## Properties + +### context + +```ts +context: TOnMutateResult | undefined; +``` + +Defined in: [packages/query-core/src/mutation.ts:40](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L40) + +The value returned by `onMutate`, if defined. Passed to `onSuccess`, +`onError` and `onSettled` as the mutation's context. + +#### Inherited from + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`context`](MutationObserverBaseResult.md#context) + +*** + +### data + +```ts +data: TData; +``` + +Defined in: [packages/query-core/src/types.ts:1474](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1474) + +The last successfully resolved data for the mutation. + +#### Overrides + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`data`](MutationObserverBaseResult.md#data) + +*** + +### error + +```ts +error: null; +``` + +Defined in: [packages/query-core/src/types.ts:1475](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1475) + +The error object for the mutation, if an error was encountered. +- Defaults to `null`. + +#### Overrides + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`error`](MutationObserverBaseResult.md#error) + +*** + +### failureCount + +```ts +failureCount: number; +``` + +Defined in: [packages/query-core/src/mutation.ts:53](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L53) + +The number of times the mutation function has failed for the current attempt. + +#### Inherited from + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`failureCount`](MutationObserverBaseResult.md#failurecount) + +*** + +### failureReason + +```ts +failureReason: TError | null; +``` + +Defined in: [packages/query-core/src/mutation.ts:57](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L57) + +The reason the current attempt failed, as reported by the retryer. + +#### Inherited from + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`failureReason`](MutationObserverBaseResult.md#failurereason) + +*** + +### isError + +```ts +isError: false; +``` + +Defined in: [packages/query-core/src/types.ts:1477](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1477) + +A boolean variable derived from `status`. +- `true` if the last mutation attempt resulted in an error. + +#### Overrides + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isError`](MutationObserverBaseResult.md#iserror) + +*** + +### isIdle + +```ts +isIdle: false; +``` + +Defined in: [packages/query-core/src/types.ts:1478](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1478) + +A boolean variable derived from `status`. +- `true` if the mutation is in its initial state prior to executing. + +#### Overrides + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isIdle`](MutationObserverBaseResult.md#isidle) + +*** + +### isPaused + +```ts +isPaused: boolean; +``` + +Defined in: [packages/query-core/src/mutation.ts:62](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L62) + +Whether the mutation is currently paused (see network mode), or is +waiting for another mutation with the same `scope` to finish. + +#### Inherited from + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isPaused`](MutationObserverBaseResult.md#ispaused) + +*** + +### isPending + +```ts +isPending: false; +``` + +Defined in: [packages/query-core/src/types.ts:1479](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1479) + +A boolean variable derived from `status`. +- `true` if the mutation is currently executing. + +#### Overrides + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isPending`](MutationObserverBaseResult.md#ispending) + +*** + +### isSuccess + +```ts +isSuccess: true; +``` + +Defined in: [packages/query-core/src/types.ts:1480](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1480) + +A boolean variable derived from `status`. +- `true` if the last mutation attempt was successful. + +#### Overrides + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isSuccess`](MutationObserverBaseResult.md#issuccess) + +*** + +### mutate + +```ts +mutate: MutateFunction; +``` + +Defined in: [packages/query-core/src/types.ts:1393](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1393) + +The mutation function you can call with variables to trigger the mutation and optionally hooks on additional callback options. + +#### Param + +The variables object to pass to the `mutationFn`. + +#### Param + +This function will fire when the mutation is successful and will be passed the mutation's result. + +#### Param + +This function will fire if the mutation encounters an error and will be passed the error. + +#### Param + +This function will fire when the mutation is either successfully fetched or encounters an error and be passed either the data or error. + +#### Remarks + +- If you make multiple requests, `onSuccess` will fire only after the latest call you've made. +- All the callback functions (`onSuccess`, `onError`, `onSettled`) are void functions, and the returned value will be ignored. + +#### Inherited from + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`mutate`](MutationObserverBaseResult.md#mutate) + +*** + +### reset() + +```ts +reset: () => void; +``` + +Defined in: [packages/query-core/src/types.ts:1397](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1397) + +A function to clean the mutation internal state (i.e., it resets the mutation to its initial state). + +#### Returns + +`void` + +#### Inherited from + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`reset`](MutationObserverBaseResult.md#reset) + +*** + +### status + +```ts +status: "success"; +``` + +Defined in: [packages/query-core/src/types.ts:1481](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1481) + +The status of the mutation. +- Will be: + - `idle` initial status prior to the mutation function executing. + - `pending` if the mutation is currently executing. + - `error` if the last mutation attempt resulted in an error. + - `success` if the last mutation attempt was successful. + +#### Overrides + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`status`](MutationObserverBaseResult.md#status) + +*** + +### submittedAt + +```ts +submittedAt: number; +``` + +Defined in: [packages/query-core/src/mutation.ts:74](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L74) + +The timestamp for when the mutation was submitted. + +#### Inherited from + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`submittedAt`](MutationObserverBaseResult.md#submittedat) + +*** + +### variables + +```ts +variables: TVariables; +``` + +Defined in: [packages/query-core/src/types.ts:1476](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1476) + +The variables object passed to the `mutationFn`. + +#### Overrides + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`variables`](MutationObserverBaseResult.md#variables) diff --git a/docs/framework/angular/reference/interfaces/MutationOptions.md b/docs/framework/angular/reference/interfaces/MutationOptions.md new file mode 100644 index 00000000000..5aabeeb0ca4 --- /dev/null +++ b/docs/framework/angular/reference/interfaces/MutationOptions.md @@ -0,0 +1,257 @@ +--- +id: MutationOptions +title: MutationOptions +--- + +Defined in: [packages/query-core/src/types.ts:1200](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1200) + +## Extended by + +- [`MutationObserverOptions`](MutationObserverOptions.md) + +## Type Parameters + +### TData + +`TData` = `unknown` + +### TError + +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) + +### TVariables + +`TVariables` = `void` + +### TOnMutateResult + +`TOnMutateResult` = `unknown` + +## Properties + +### gcTime? + +```ts +optional gcTime: number; +``` + +Defined in: [packages/query-core/src/types.ts:1260](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1260) + +The time in milliseconds that an unused/inactive mutation remains in memory before it is +garbage collected. + +Defaults to `5 * 60 * 1000` (5 minutes), or `Infinity` during SSR. + +*** + +### meta? + +```ts +optional meta: Record; +``` + +Defined in: [packages/query-core/src/types.ts:1263](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1263) + +*** + +### mutationFn? + +```ts +optional mutationFn: MutationFunction; +``` + +Defined in: [packages/query-core/src/types.ts:1206](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1206) + +*** + +### mutationKey? + +```ts +optional mutationKey: readonly unknown[]; +``` + +Defined in: [packages/query-core/src/types.ts:1207](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1207) + +*** + +### networkMode? + +```ts +optional networkMode: NetworkMode; +``` + +Defined in: [packages/query-core/src/types.ts:1253](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1253) + +Controls whether a mutation is allowed to run based on the current network connectivity. + +Defaults to `'online'`. + +#### See + +[Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. + +*** + +### onError()? + +```ts +optional onError: (error, variables, onMutateResult, context) => unknown; +``` + +Defined in: [packages/query-core/src/types.ts:1218](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1218) + +#### Parameters + +##### error + +`TError` + +##### variables + +`TVariables` + +##### onMutateResult + +`TOnMutateResult` | `undefined` + +##### context + +[`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md) + +#### Returns + +`unknown` + +*** + +### onMutate()? + +```ts +optional onMutate: (variables, context) => TOnMutateResult | Promise; +``` + +Defined in: [packages/query-core/src/types.ts:1208](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1208) + +#### Parameters + +##### variables + +`TVariables` + +##### context + +[`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md) + +#### Returns + +`TOnMutateResult` \| `Promise`\<`TOnMutateResult`\> + +*** + +### onSettled()? + +```ts +optional onSettled: (data, error, variables, onMutateResult, context) => unknown; +``` + +Defined in: [packages/query-core/src/types.ts:1224](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1224) + +#### Parameters + +##### data + +`TData` | `undefined` + +##### error + +`TError` | `null` + +##### variables + +`TVariables` + +##### onMutateResult + +`TOnMutateResult` | `undefined` + +##### context + +[`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md) + +#### Returns + +`unknown` + +*** + +### onSuccess()? + +```ts +optional onSuccess: (data, variables, onMutateResult, context) => unknown; +``` + +Defined in: [packages/query-core/src/types.ts:1212](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1212) + +#### Parameters + +##### data + +`TData` + +##### variables + +`TVariables` + +##### onMutateResult + +`TOnMutateResult` + +##### context + +[`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md) + +#### Returns + +`unknown` + +*** + +### retry? + +```ts +optional retry: RetryValue; +``` + +Defined in: [packages/query-core/src/types.ts:1239](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1239) + +If `false`, failed mutations will not retry by default. +If `true`, failed mutations will retry infinitely. +If set to an integer number, e.g. 3, failed mutations will retry until the failed mutation count meets that number. +If set to a function `(failureCount, error) => boolean` failed mutations will retry until the function returns false. + +Defaults to `0`. + +*** + +### retryDelay? + +```ts +optional retryDelay: RetryDelayValue; +``` + +Defined in: [packages/query-core/src/types.ts:1246](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1246) + +This function receives a `retryAttempt` integer and the actual Error and returns the delay to apply before the +next attempt in milliseconds. + +Defaults to a function that applies exponential backoff, capped at 30 seconds. + +*** + +### scope? + +```ts +optional scope: MutationScope; +``` + +Defined in: [packages/query-core/src/types.ts:1264](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1264) diff --git a/docs/framework/angular/reference/interfaces/MutationState.md b/docs/framework/angular/reference/interfaces/MutationState.md new file mode 100644 index 00000000000..bec050ec1d3 --- /dev/null +++ b/docs/framework/angular/reference/interfaces/MutationState.md @@ -0,0 +1,142 @@ +--- +id: MutationState +title: MutationState +--- + +Defined in: [packages/query-core/src/mutation.ts:30](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L30) + +The raw state stored on a `Mutation` instance. This is the underlying state +that observer results (e.g. `MutationObserverResult`) are derived from. + +## Extended by + +- [`MutationObserverBaseResult`](MutationObserverBaseResult.md) + +## Type Parameters + +### TData + +`TData` = `unknown` + +### TError + +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) + +### TVariables + +`TVariables` = `unknown` + +### TOnMutateResult + +`TOnMutateResult` = `unknown` + +## Properties + +### context + +```ts +context: TOnMutateResult | undefined; +``` + +Defined in: [packages/query-core/src/mutation.ts:40](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L40) + +The value returned by `onMutate`, if defined. Passed to `onSuccess`, +`onError` and `onSettled` as the mutation's context. + +*** + +### data + +```ts +data: TData | undefined; +``` + +Defined in: [packages/query-core/src/mutation.ts:44](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L44) + +The last successfully resolved data for the mutation. + +*** + +### error + +```ts +error: TError | null; +``` + +Defined in: [packages/query-core/src/mutation.ts:49](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L49) + +The error object for the mutation, if the last attempt resulted in an error. +- Defaults to `null`. + +*** + +### failureCount + +```ts +failureCount: number; +``` + +Defined in: [packages/query-core/src/mutation.ts:53](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L53) + +The number of times the mutation function has failed for the current attempt. + +*** + +### failureReason + +```ts +failureReason: TError | null; +``` + +Defined in: [packages/query-core/src/mutation.ts:57](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L57) + +The reason the current attempt failed, as reported by the retryer. + +*** + +### isPaused + +```ts +isPaused: boolean; +``` + +Defined in: [packages/query-core/src/mutation.ts:62](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L62) + +Whether the mutation is currently paused (see network mode), or is +waiting for another mutation with the same `scope` to finish. + +*** + +### status + +```ts +status: MutationStatus; +``` + +Defined in: [packages/query-core/src/mutation.ts:66](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L66) + +The status of the mutation. + +*** + +### submittedAt + +```ts +submittedAt: number; +``` + +Defined in: [packages/query-core/src/mutation.ts:74](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L74) + +The timestamp for when the mutation was submitted. + +*** + +### variables + +```ts +variables: TVariables | undefined; +``` + +Defined in: [packages/query-core/src/mutation.ts:70](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L70) + +The variables the mutation was last called with. diff --git a/docs/framework/angular/reference/interfaces/NotifyEvent.md b/docs/framework/angular/reference/interfaces/NotifyEvent.md new file mode 100644 index 00000000000..4f5b023f49a --- /dev/null +++ b/docs/framework/angular/reference/interfaces/NotifyEvent.md @@ -0,0 +1,16 @@ +--- +id: NotifyEvent +title: NotifyEvent +--- + +Defined in: [packages/query-core/src/types.ts:1539](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1539) + +## Properties + +### type + +```ts +type: NotifyEventType; +``` + +Defined in: [packages/query-core/src/types.ts:1540](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1540) diff --git a/docs/framework/angular/reference/interfaces/OnlineManager.md b/docs/framework/angular/reference/interfaces/OnlineManager.md new file mode 100644 index 00000000000..1a936c91ed9 --- /dev/null +++ b/docs/framework/angular/reference/interfaces/OnlineManager.md @@ -0,0 +1,214 @@ +--- +id: OnlineManager +title: OnlineManager +--- + +Defined in: [packages/query-core/src/onlineManager.ts:15](https://github.com/TanStack/query/blob/main/packages/query-core/src/onlineManager.ts#L15) + +The `OnlineManager` manages the online state within TanStack Query. It can +be used to change the default event listeners or to manually change the +online state. + +By default, the `onlineManager` assumes an active network connection, and +listens to the `online` and `offline` events on the `window` object to +detect changes. + +## Extends + +- `Subscribable`\<`Listener`\> + +## Properties + +### listeners + +```ts +protected listeners: Set; +``` + +Defined in: [packages/query-core/src/subscribable.ts:2](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L2) + +#### Inherited from + +```ts +Subscribable.listeners +``` + +## Methods + +### hasListeners() + +```ts +hasListeners(): boolean; +``` + +Defined in: [packages/query-core/src/subscribable.ts:19](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L19) + +#### Returns + +`boolean` + +#### Inherited from + +```ts +Subscribable.hasListeners +``` + +*** + +### isOnline() + +```ts +isOnline(): boolean; +``` + +Defined in: [packages/query-core/src/onlineManager.ts:109](https://github.com/TanStack/query/blob/main/packages/query-core/src/onlineManager.ts#L109) + +`isOnline` can be used to get the current online state. + +#### Returns + +`boolean` + +*** + +### onSubscribe() + +```ts +protected onSubscribe(): void; +``` + +Defined in: [packages/query-core/src/onlineManager.ts:44](https://github.com/TanStack/query/blob/main/packages/query-core/src/onlineManager.ts#L44) + +#### Returns + +`void` + +#### Overrides + +```ts +Subscribable.onSubscribe +``` + +*** + +### onUnsubscribe() + +```ts +protected onUnsubscribe(): void; +``` + +Defined in: [packages/query-core/src/onlineManager.ts:50](https://github.com/TanStack/query/blob/main/packages/query-core/src/onlineManager.ts#L50) + +#### Returns + +`void` + +#### Overrides + +```ts +Subscribable.onUnsubscribe +``` + +*** + +### setEventListener() + +```ts +setEventListener(setup): void; +``` + +Defined in: [packages/query-core/src/onlineManager.ts:75](https://github.com/TanStack/query/blob/main/packages/query-core/src/onlineManager.ts#L75) + +`setEventListener` can be used to set a custom event listener that will +be used to determine the online state. The provided `setup` function +receives a `setOnline` callback that should be called with a `boolean` +whenever the online state changes. + +#### Parameters + +##### setup + +`SetupFn` + +#### Returns + +`void` + +#### Example + +```ts +import NetInfo from '@react-native-community/netinfo' +import { onlineManager } from '@tanstack/query-core' + +onlineManager.setEventListener((setOnline) => { + return NetInfo.addEventListener((state) => { + setOnline(!!state.isConnected) + }) +}) +``` + +*** + +### setOnline() + +```ts +setOnline(online): void; +``` + +Defined in: [packages/query-core/src/onlineManager.ts:95](https://github.com/TanStack/query/blob/main/packages/query-core/src/onlineManager.ts#L95) + +`setOnline` can be used to manually set the online state. + +#### Parameters + +##### online + +`boolean` + +#### Returns + +`void` + +#### Example + +```ts +import { onlineManager } from '@tanstack/query-core' + +// Set to online +onlineManager.setOnline(true) + +// Set to offline +onlineManager.setOnline(false) +``` + +*** + +### subscribe() + +```ts +subscribe(listener): () => void; +``` + +Defined in: [packages/query-core/src/subscribable.ts:8](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L8) + +#### Parameters + +##### listener + +`Listener` + +#### Returns + +```ts +(): void; +``` + +##### Returns + +`void` + +#### Inherited from + +```ts +Subscribable.subscribe +``` diff --git a/docs/framework/angular/reference/interfaces/QueriesObserverOptions.md b/docs/framework/angular/reference/interfaces/QueriesObserverOptions.md new file mode 100644 index 00000000000..68e7913885d --- /dev/null +++ b/docs/framework/angular/reference/interfaces/QueriesObserverOptions.md @@ -0,0 +1,29 @@ +--- +id: QueriesObserverOptions +title: QueriesObserverOptions +--- + +Defined in: [packages/query-core/src/queriesObserver.ts:23](https://github.com/TanStack/query/blob/main/packages/query-core/src/queriesObserver.ts#L23) + +## Type Parameters + +### TCombinedResult + +`TCombinedResult` = [`QueryObserverResult`](../type-aliases/QueryObserverResult.md)[] + +## Properties + +### combine? + +```ts +optional combine: CombineFn; +``` + +Defined in: [packages/query-core/src/queriesObserver.ts:34](https://github.com/TanStack/query/blob/main/packages/query-core/src/queriesObserver.ts#L34) + +A function that combines the array of `QueryObserverResult`s (one per +observed query) into a single value. The combined value is memoized and +only recomputed when one of the underlying results, the query hashes, or +the `combine` function itself changes. + +Defaults to returning the array of `QueryObserverResult`s unchanged. diff --git a/docs/framework/angular/reference/interfaces/QueryCacheConfig.md b/docs/framework/angular/reference/interfaces/QueryCacheConfig.md new file mode 100644 index 00000000000..3c6aebe496f --- /dev/null +++ b/docs/framework/angular/reference/interfaces/QueryCacheConfig.md @@ -0,0 +1,93 @@ +--- +id: QueryCacheConfig +title: QueryCacheConfig +--- + +Defined in: [packages/query-core/src/queryCache.ts:25](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryCache.ts#L25) + +Global callbacks that fire for every query handled by a `QueryCache`, regardless of which +component or observer triggered it. Unlike `QueryClient`'s `defaultOptions`, which a query can +override, these callbacks are always called. Unlike `MutationCacheConfig`'s callbacks, these +are fire-and-forget: their return value is not awaited before the query settles. + +## Properties + +### onError()? + +```ts +optional onError: (error, query) => void; +``` + +Defined in: [packages/query-core/src/queryCache.ts:27](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryCache.ts#L27) + +Called when any query in the cache encounters an error. + +#### Parameters + +##### error + +`Error` + +##### query + +[`Query`](../classes/Query.md)\<`unknown`, `unknown`, `unknown`\> + +#### Returns + +`void` + +*** + +### onSettled()? + +```ts +optional onSettled: (data, error, query) => void; +``` + +Defined in: [packages/query-core/src/queryCache.ts:34](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryCache.ts#L34) + +Called when any query in the cache is settled, either successfully or with an error. + +#### Parameters + +##### data + +`unknown` + +##### error + +`Error` | `null` + +##### query + +[`Query`](../classes/Query.md)\<`unknown`, `unknown`, `unknown`\> + +#### Returns + +`void` + +*** + +### onSuccess()? + +```ts +optional onSuccess: (data, query) => void; +``` + +Defined in: [packages/query-core/src/queryCache.ts:32](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryCache.ts#L32) + +Called when any query in the cache is successful. + +#### Parameters + +##### data + +`unknown` + +##### query + +[`Query`](../classes/Query.md)\<`unknown`, `unknown`, `unknown`\> + +#### Returns + +`void` diff --git a/docs/framework/angular/reference/interfaces/QueryClientConfig.md b/docs/framework/angular/reference/interfaces/QueryClientConfig.md new file mode 100644 index 00000000000..070e249491f --- /dev/null +++ b/docs/framework/angular/reference/interfaces/QueryClientConfig.md @@ -0,0 +1,43 @@ +--- +id: QueryClientConfig +title: QueryClientConfig +--- + +Defined in: [packages/query-core/src/types.ts:1495](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1495) + +## Properties + +### defaultOptions? + +```ts +optional defaultOptions: DefaultOptions; +``` + +Defined in: [packages/query-core/src/types.ts:1504](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1504) + +Default options for all queries and mutations created through this client. + +*** + +### mutationCache? + +```ts +optional mutationCache: MutationCache; +``` + +Defined in: [packages/query-core/src/types.ts:1502](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1502) + +The mutation cache this client is connected to. A new `MutationCache` is created if not +provided. + +*** + +### queryCache? + +```ts +optional queryCache: QueryCache; +``` + +Defined in: [packages/query-core/src/types.ts:1497](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1497) + +The query cache this client is connected to. A new `QueryCache` is created if not provided. diff --git a/docs/framework/angular/reference/interfaces/QueryExecuteOptions.md b/docs/framework/angular/reference/interfaces/QueryExecuteOptions.md new file mode 100644 index 00000000000..23d272eb25f --- /dev/null +++ b/docs/framework/angular/reference/interfaces/QueryExecuteOptions.md @@ -0,0 +1,382 @@ +--- +id: QueryExecuteOptions +title: QueryExecuteOptions +--- + +Defined in: [packages/query-core/src/types.ts:574](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L574) + +## Extends + +- [`WithRequired`](../type-aliases/WithRequired.md)\<[`QueryOptions`](QueryOptions.md)\<`TQueryFnData`, `TError`, `TQueryData`, `TQueryKey`, `TPageParam`\>, `"queryKey"`\> + +## Type Parameters + +### TQueryFnData + +`TQueryFnData` = `unknown` + +### TError + +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) + +### TData + +`TData` = `TQueryFnData` + +### TQueryData + +`TQueryData` = `TQueryFnData` + +### TQueryKey + +`TQueryKey` *extends* [`QueryKey`](../type-aliases/QueryKey.md) = [`QueryKey`](../type-aliases/QueryKey.md) + +### TPageParam + +`TPageParam` = `never` + +## Properties + +### gcTime? + +```ts +optional gcTime: number; +``` + +Defined in: [packages/query-core/src/types.ts:277](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L277) + +The time in milliseconds that unused/inactive cache data remains in memory. +When a query's cache becomes unused or inactive, that cache data will be garbage collected after this duration. +When different garbage collection times are specified, the longest one will be used. +Setting it to `Infinity` will disable garbage collection. + +Defaults to `5 * 60 * 1000` (5 minutes), or `Infinity` during SSR. + +Note: the maximum allowed time is about 24 days, imposed by `setTimeout`'s 32-bit signed integer delay — see +`timeoutManager.setTimeoutProvider` for a workaround. + +#### Inherited from + +```ts +WithRequired.gcTime +``` + +*** + +### initialData? + +```ts +optional initialData: + | TQueryData +| InitialDataFunction; +``` + +Defined in: [packages/query-core/src/types.ts:317](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L317) + +If set, this value will be used as the initial data for the query cache (as long as the query hasn't been +created or cached yet). +If set to a function, the function will be called **once** during the shared/root query initialization, and be +expected to synchronously return the initial data. +Initial data is considered stale by default unless a `staleTime` has been set. +`initialData` **is persisted** to the cache. + +#### Inherited from + +```ts +WithRequired.initialData +``` + +*** + +### initialDataUpdatedAt? + +```ts +optional initialDataUpdatedAt: number | () => number | undefined; +``` + +Defined in: [packages/query-core/src/types.ts:321](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L321) + +If set, this value will be used as the time (in milliseconds) of when the `initialData` itself was last updated. + +#### Inherited from + +```ts +WithRequired.initialDataUpdatedAt +``` + +*** + +### initialPageParam? + +```ts +optional initialPageParam: undefined; +``` + +Defined in: [packages/query-core/src/types.ts:585](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L585) + +*** + +### maxPages? + +```ts +optional maxPages: number; +``` + +Defined in: [packages/query-core/src/types.ts:345](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L345) + +Maximum number of pages to store in the data of an infinite query. + +#### Inherited from + +```ts +WithRequired.maxPages +``` + +*** + +### meta? + +```ts +optional meta: Record; +``` + +Defined in: [packages/query-core/src/types.ts:341](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L341) + +Additional payload to be stored on each query. +Use this property to pass information that can be used in other places. + +#### Inherited from + +```ts +WithRequired.meta +``` + +*** + +### networkMode? + +```ts +optional networkMode: NetworkMode; +``` + +Defined in: [packages/query-core/src/types.ts:265](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L265) + +Controls whether a query is allowed to run based on the current network connectivity. + +Defaults to `'online'`. + +#### See + +[Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. + +#### Inherited from + +```ts +WithRequired.networkMode +``` + +*** + +### persister? + +```ts +optional persister: QueryPersister, TPageParam>; +``` + +Defined in: [packages/query-core/src/types.ts:290](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L290) + +This option can be used to persist the result of a query to an external storage, bypassing the need to actually +call the `queryFn`. Useful for persisting a query's data across e.g. server/client boundaries. + +#### Inherited from + +```ts +WithRequired.persister +``` + +*** + +### queryFn? + +```ts +optional queryFn: + | typeof skipToken +| QueryFunction; +``` + +Defined in: [packages/query-core/src/types.ts:285](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L285) + +The function that the query will use to request data. +Required, unless a default query function has been set via `queryClient.setQueryDefaults` or +`queryClient.setDefaultOptions`. +Receives a [QueryFunctionContext](../type-aliases/QueryFunctionContext.md). +Must return a promise that will either resolve data or throw an error. The data cannot be `undefined`. + +#### Inherited from + +```ts +WithRequired.queryFn +``` + +*** + +### queryHash? + +```ts +optional queryHash: string; +``` + +Defined in: [packages/query-core/src/types.ts:295](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L295) + +The hashed form of `queryKey`, computed with `queryKeyHashFn` (or the default hashing function otherwise). Used +as the actual cache key internally. + +#### Inherited from + +```ts +WithRequired.queryHash +``` + +*** + +### queryKey + +```ts +queryKey: TQueryKey & object; +``` + +Defined in: [packages/query-core/src/types.ts:304](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L304) + +The query key to use for this query. + +The query key will be hashed into a stable hash. See [Query Keys](https://tanstack.com/query/latest/docs/framework/react/guides/query-keys) +for more information. + +The query will automatically update when this key changes (as long as `enabled` is not set to `false`). + +#### Inherited from + +```ts +WithRequired.queryKey +``` + +*** + +### queryKeyHashFn? + +```ts +optional queryKeyHashFn: QueryKeyHashFunction; +``` + +Defined in: [packages/query-core/src/types.ts:308](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L308) + +If specified, this function is used to hash the `queryKey` to a string. + +#### Inherited from + +```ts +WithRequired.queryKeyHashFn +``` + +*** + +### retry? + +```ts +optional retry: RetryValue; +``` + +Defined in: [packages/query-core/src/types.ts:246](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L246) + +If `false`, failed queries will not retry by default. +If `true`, failed queries will retry infinitely. +If set to an integer number, e.g. 3, failed queries will retry until the failed query count meets that number. +If set to a function `(failureCount, error) => boolean` failed queries will retry until the function returns false. + +Defaults to `3` on the client and `0` on the server. + +#### Inherited from + +```ts +WithRequired.retry +``` + +*** + +### retryDelay? + +```ts +optional retryDelay: RetryDelayValue; +``` + +Defined in: [packages/query-core/src/types.ts:258](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L258) + +This function receives a `retryAttempt` integer and the actual Error and returns the delay to apply before the +next attempt in milliseconds. + +A function like `attempt => Math.min(attempt > 1 ? 2 ** attempt * 1000 : 1000, 30 * 1000)` applies exponential +backoff. + +A function like `attempt => attempt * 1000` applies linear backoff. + +Defaults to a function that applies exponential backoff, capped at 30 seconds. + +#### Inherited from + +```ts +WithRequired.retryDelay +``` + +*** + +### select()? + +```ts +optional select: (data) => TData; +``` + +Defined in: [packages/query-core/src/types.ts:586](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L586) + +#### Parameters + +##### data + +`TQueryData` + +#### Returns + +`TData` + +*** + +### staleTime? + +```ts +optional staleTime: StaleTimeFunction; +``` + +Defined in: [packages/query-core/src/types.ts:591](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L591) + +The time in milliseconds after data is considered stale. +If the data is fresh it will be returned from the cache. + +*** + +### structuralSharing? + +```ts +optional structuralSharing: boolean | (oldData, newData) => unknown; +``` + +Defined in: [packages/query-core/src/types.ts:330](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L330) + +Set this to `false` to disable structural sharing between query results. +Set this to a function which accepts the old and new data and returns resolved data of the same type to implement custom structural sharing logic. + +Defaults to `true`. + +#### Inherited from + +```ts +WithRequired.structuralSharing +``` diff --git a/docs/framework/angular/reference/interfaces/QueryFeature.md b/docs/framework/angular/reference/interfaces/QueryFeature.md index 916e0a4659d..11d0aaf6bb7 100644 --- a/docs/framework/angular/reference/interfaces/QueryFeature.md +++ b/docs/framework/angular/reference/interfaces/QueryFeature.md @@ -3,7 +3,7 @@ id: QueryFeature title: QueryFeature --- -Defined in: [providers.ts:132](https://github.com/TanStack/query/blob/main/packages/angular-query-experimental/src/providers.ts#L132) +Defined in: [packages/angular-query-experimental/src/providers.ts:132](https://github.com/TanStack/query/blob/main/packages/angular-query-experimental/src/providers.ts#L132) Helper type to represent a Query feature. @@ -21,7 +21,7 @@ Helper type to represent a Query feature. ɵkind: TFeatureKind; ``` -Defined in: [providers.ts:133](https://github.com/TanStack/query/blob/main/packages/angular-query-experimental/src/providers.ts#L133) +Defined in: [packages/angular-query-experimental/src/providers.ts:133](https://github.com/TanStack/query/blob/main/packages/angular-query-experimental/src/providers.ts#L133) *** @@ -31,4 +31,4 @@ Defined in: [providers.ts:133](https://github.com/TanStack/query/blob/main/packa ɵproviders: Provider[]; ``` -Defined in: [providers.ts:134](https://github.com/TanStack/query/blob/main/packages/angular-query-experimental/src/providers.ts#L134) +Defined in: [packages/angular-query-experimental/src/providers.ts:134](https://github.com/TanStack/query/blob/main/packages/angular-query-experimental/src/providers.ts#L134) diff --git a/docs/framework/angular/reference/interfaces/QueryFilters.md b/docs/framework/angular/reference/interfaces/QueryFilters.md new file mode 100644 index 00000000000..749e4283d0d --- /dev/null +++ b/docs/framework/angular/reference/interfaces/QueryFilters.md @@ -0,0 +1,104 @@ +--- +id: QueryFilters +title: QueryFilters +--- + +Defined in: [packages/query-core/src/utils.ts:31](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L31) + +Filters used to select queries, for example in `queryClient.getQueriesData` or `queryClient.invalidateQueries`. +All provided filters must match; filters that are left unspecified are ignored. + +## Extended by + +- [`InvalidateQueryFilters`](InvalidateQueryFilters.md) +- [`RefetchQueryFilters`](RefetchQueryFilters.md) + +## Type Parameters + +### TQueryKey + +`TQueryKey` *extends* [`QueryKey`](../type-aliases/QueryKey.md) = [`QueryKey`](../type-aliases/QueryKey.md) + +## Properties + +### exact? + +```ts +optional exact: boolean; +``` + +Defined in: [packages/query-core/src/utils.ts:41](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L41) + +Match query key exactly + +*** + +### fetchStatus? + +```ts +optional fetchStatus: FetchStatus; +``` + +Defined in: [packages/query-core/src/utils.ts:57](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L57) + +Include queries matching their fetchStatus + +*** + +### predicate()? + +```ts +optional predicate: (query) => boolean; +``` + +Defined in: [packages/query-core/src/utils.ts:45](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L45) + +Include queries matching this predicate function + +#### Parameters + +##### query + +[`Query`](../classes/Query.md) + +#### Returns + +`boolean` + +*** + +### queryKey? + +```ts +optional queryKey: TQueryKey | TuplePrefixes; +``` + +Defined in: [packages/query-core/src/utils.ts:49](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L49) + +Include queries matching this query key + +*** + +### stale? + +```ts +optional stale: boolean; +``` + +Defined in: [packages/query-core/src/utils.ts:53](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L53) + +Include or exclude stale queries + +*** + +### type? + +```ts +optional type: QueryTypeFilter; +``` + +Defined in: [packages/query-core/src/utils.ts:37](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L37) + +Filter to active queries, inactive queries or all queries + +Defaults to `'all'`. diff --git a/docs/framework/angular/reference/interfaces/QueryObserverBaseResult.md b/docs/framework/angular/reference/interfaces/QueryObserverBaseResult.md new file mode 100644 index 00000000000..ef5fe0ad757 --- /dev/null +++ b/docs/framework/angular/reference/interfaces/QueryObserverBaseResult.md @@ -0,0 +1,358 @@ +--- +id: QueryObserverBaseResult +title: QueryObserverBaseResult +--- + +Defined in: [packages/query-core/src/types.ts:764](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L764) + +## Extended by + +- [`QueryObserverPendingResult`](QueryObserverPendingResult.md) +- [`QueryObserverLoadingResult`](QueryObserverLoadingResult.md) +- [`QueryObserverLoadingErrorResult`](QueryObserverLoadingErrorResult.md) +- [`QueryObserverRefetchErrorResult`](QueryObserverRefetchErrorResult.md) +- [`QueryObserverSuccessResult`](QueryObserverSuccessResult.md) +- [`QueryObserverPlaceholderResult`](QueryObserverPlaceholderResult.md) +- [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md) + +## Type Parameters + +### TData + +`TData` = `unknown` + +### TError + +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) + +## Properties + +### data + +```ts +data: TData | undefined; +``` + +Defined in: [packages/query-core/src/types.ts:771](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L771) + +The last successfully resolved data for the query. + +*** + +### dataUpdatedAt + +```ts +dataUpdatedAt: number; +``` + +Defined in: [packages/query-core/src/types.ts:775](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L775) + +The timestamp for when the query most recently returned the `status` as `"success"`. + +*** + +### error + +```ts +error: TError | null; +``` + +Defined in: [packages/query-core/src/types.ts:780](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L780) + +The error object for the query, if an error was thrown. +- Defaults to `null`. + +*** + +### errorUpdateCount + +```ts +errorUpdateCount: number; +``` + +Defined in: [packages/query-core/src/types.ts:799](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L799) + +The sum of all errors. + +*** + +### errorUpdatedAt + +```ts +errorUpdatedAt: number; +``` + +Defined in: [packages/query-core/src/types.ts:784](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L784) + +The timestamp for when the query most recently returned the `status` as `"error"`. + +*** + +### failureCount + +```ts +failureCount: number; +``` + +Defined in: [packages/query-core/src/types.ts:790](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L790) + +The failure count for the query. +- Incremented every time the query fails. +- Reset to `0` when the query succeeds. + +*** + +### failureReason + +```ts +failureReason: TError | null; +``` + +Defined in: [packages/query-core/src/types.ts:795](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L795) + +The failure reason for the query retry. +- Reset to `null` when the query succeeds. + +*** + +### fetchStatus + +```ts +fetchStatus: FetchStatus; +``` + +Defined in: [packages/query-core/src/types.ts:889](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L889) + +The fetch status of the query. +- `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. +- `paused`: The query wanted to fetch, but has been `paused`. +- `idle`: The query is not fetching. +- See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. + +*** + +### isEnabled + +```ts +isEnabled: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:867](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L867) + +`true` if this observer is enabled, `false` otherwise. + +*** + +### isError + +```ts +isError: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:804](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L804) + +A derived boolean from the `status` variable, provided for convenience. +- `true` if the query attempt resulted in an error. + +*** + +### isFetched + +```ts +isFetched: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:808](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L808) + +Will be `true` if the query has been fetched. + +*** + +### isFetchedAfterMount + +```ts +isFetchedAfterMount: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:813](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L813) + +Will be `true` if the query has been fetched after the component mounted. +- This property can be used to not show any previously cached data. + +*** + +### isFetching + +```ts +isFetching: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:818](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L818) + +A derived boolean from the `fetchStatus` variable, provided for convenience. +- `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. + +*** + +### ~~isInitialLoading~~ + +```ts +isInitialLoading: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:836](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L836) + +#### Deprecated + +`isInitialLoading` is being deprecated in favor of `isLoading` +and will be removed in the next major version. + +*** + +### isLoading + +```ts +isLoading: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:823](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L823) + +Is `true` whenever the first fetch for a query is in-flight. +- Is the same as `isFetching && isPending`. + +*** + +### isLoadingError + +```ts +isLoadingError: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:831](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L831) + +Will be `true` if the query failed while fetching for the first time. + +*** + +### isPaused + +```ts +isPaused: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:841](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L841) + +A derived boolean from the `fetchStatus` variable, provided for convenience. +- The query wanted to fetch, but has been `paused`. + +*** + +### isPending + +```ts +isPending: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:827](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L827) + +Will be `pending` if there's no cached data and no query attempt was finished yet. + +*** + +### isPlaceholderData + +```ts +isPlaceholderData: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:845](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L845) + +Will be `true` if the data shown is the placeholder data. + +*** + +### isRefetchError + +```ts +isRefetchError: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:849](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L849) + +Will be `true` if the query failed while refetching. + +*** + +### isRefetching + +```ts +isRefetching: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:854](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L854) + +Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. +- Is the same as `isFetching && !isPending`. + +*** + +### isStale + +```ts +isStale: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:858](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L858) + +Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. + +*** + +### isSuccess + +```ts +isSuccess: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:863](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L863) + +A derived boolean from the `status` variable, provided for convenience. +- `true` if the query has received a response with no errors and is ready to display its data. + +*** + +### refetch() + +```ts +refetch: (options?) => Promise>; +``` + +Defined in: [packages/query-core/src/types.ts:871](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L871) + +A function to manually refetch the query. + +#### Parameters + +##### options? + +[`RefetchOptions`](RefetchOptions.md) + +#### Returns + +`Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> + +*** + +### status + +```ts +status: QueryStatus; +``` + +Defined in: [packages/query-core/src/types.ts:881](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L881) + +The status of the query. +- Will be: + - `pending` if there's no cached data and no query attempt was finished yet. + - `error` if the query attempt resulted in an error. + - `success` if the query has received a response with no errors and is ready to display its data. diff --git a/docs/framework/angular/reference/interfaces/QueryObserverLoadingErrorResult.md b/docs/framework/angular/reference/interfaces/QueryObserverLoadingErrorResult.md new file mode 100644 index 00000000000..21b39fbffe3 --- /dev/null +++ b/docs/framework/angular/reference/interfaces/QueryObserverLoadingErrorResult.md @@ -0,0 +1,452 @@ +--- +id: QueryObserverLoadingErrorResult +title: QueryObserverLoadingErrorResult +--- + +Defined in: [packages/query-core/src/types.ts:923](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L923) + +## Extends + +- [`QueryObserverBaseResult`](QueryObserverBaseResult.md)\<`TData`, `TError`\> + +## Type Parameters + +### TData + +`TData` = `unknown` + +### TError + +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) + +## Properties + +### data + +```ts +data: undefined; +``` + +Defined in: [packages/query-core/src/types.ts:927](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L927) + +The last successfully resolved data for the query. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`data`](QueryObserverBaseResult.md#data) + +*** + +### dataUpdatedAt + +```ts +dataUpdatedAt: number; +``` + +Defined in: [packages/query-core/src/types.ts:775](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L775) + +The timestamp for when the query most recently returned the `status` as `"success"`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`dataUpdatedAt`](QueryObserverBaseResult.md#dataupdatedat) + +*** + +### error + +```ts +error: TError; +``` + +Defined in: [packages/query-core/src/types.ts:928](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L928) + +The error object for the query, if an error was thrown. +- Defaults to `null`. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`error`](QueryObserverBaseResult.md#error) + +*** + +### errorUpdateCount + +```ts +errorUpdateCount: number; +``` + +Defined in: [packages/query-core/src/types.ts:799](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L799) + +The sum of all errors. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`errorUpdateCount`](QueryObserverBaseResult.md#errorupdatecount) + +*** + +### errorUpdatedAt + +```ts +errorUpdatedAt: number; +``` + +Defined in: [packages/query-core/src/types.ts:784](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L784) + +The timestamp for when the query most recently returned the `status` as `"error"`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`errorUpdatedAt`](QueryObserverBaseResult.md#errorupdatedat) + +*** + +### failureCount + +```ts +failureCount: number; +``` + +Defined in: [packages/query-core/src/types.ts:790](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L790) + +The failure count for the query. +- Incremented every time the query fails. +- Reset to `0` when the query succeeds. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`failureCount`](QueryObserverBaseResult.md#failurecount) + +*** + +### failureReason + +```ts +failureReason: TError | null; +``` + +Defined in: [packages/query-core/src/types.ts:795](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L795) + +The failure reason for the query retry. +- Reset to `null` when the query succeeds. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`failureReason`](QueryObserverBaseResult.md#failurereason) + +*** + +### fetchStatus + +```ts +fetchStatus: FetchStatus; +``` + +Defined in: [packages/query-core/src/types.ts:889](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L889) + +The fetch status of the query. +- `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. +- `paused`: The query wanted to fetch, but has been `paused`. +- `idle`: The query is not fetching. +- See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`fetchStatus`](QueryObserverBaseResult.md#fetchstatus) + +*** + +### isEnabled + +```ts +isEnabled: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:867](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L867) + +`true` if this observer is enabled, `false` otherwise. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isEnabled`](QueryObserverBaseResult.md#isenabled) + +*** + +### isError + +```ts +isError: true; +``` + +Defined in: [packages/query-core/src/types.ts:929](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L929) + +A derived boolean from the `status` variable, provided for convenience. +- `true` if the query attempt resulted in an error. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isError`](QueryObserverBaseResult.md#iserror) + +*** + +### isFetched + +```ts +isFetched: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:808](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L808) + +Will be `true` if the query has been fetched. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isFetched`](QueryObserverBaseResult.md#isfetched) + +*** + +### isFetchedAfterMount + +```ts +isFetchedAfterMount: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:813](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L813) + +Will be `true` if the query has been fetched after the component mounted. +- This property can be used to not show any previously cached data. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isFetchedAfterMount`](QueryObserverBaseResult.md#isfetchedaftermount) + +*** + +### isFetching + +```ts +isFetching: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:818](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L818) + +A derived boolean from the `fetchStatus` variable, provided for convenience. +- `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isFetching`](QueryObserverBaseResult.md#isfetching) + +*** + +### ~~isInitialLoading~~ + +```ts +isInitialLoading: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:836](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L836) + +#### Deprecated + +`isInitialLoading` is being deprecated in favor of `isLoading` +and will be removed in the next major version. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isInitialLoading`](QueryObserverBaseResult.md#isinitialloading) + +*** + +### isLoading + +```ts +isLoading: false; +``` + +Defined in: [packages/query-core/src/types.ts:931](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L931) + +Is `true` whenever the first fetch for a query is in-flight. +- Is the same as `isFetching && isPending`. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoading`](QueryObserverBaseResult.md#isloading) + +*** + +### isLoadingError + +```ts +isLoadingError: true; +``` + +Defined in: [packages/query-core/src/types.ts:932](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L932) + +Will be `true` if the query failed while fetching for the first time. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoadingError`](QueryObserverBaseResult.md#isloadingerror) + +*** + +### isPaused + +```ts +isPaused: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:841](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L841) + +A derived boolean from the `fetchStatus` variable, provided for convenience. +- The query wanted to fetch, but has been `paused`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPaused`](QueryObserverBaseResult.md#ispaused) + +*** + +### isPending + +```ts +isPending: false; +``` + +Defined in: [packages/query-core/src/types.ts:930](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L930) + +Will be `pending` if there's no cached data and no query attempt was finished yet. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPending`](QueryObserverBaseResult.md#ispending) + +*** + +### isPlaceholderData + +```ts +isPlaceholderData: false; +``` + +Defined in: [packages/query-core/src/types.ts:935](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L935) + +Will be `true` if the data shown is the placeholder data. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPlaceholderData`](QueryObserverBaseResult.md#isplaceholderdata) + +*** + +### isRefetchError + +```ts +isRefetchError: false; +``` + +Defined in: [packages/query-core/src/types.ts:933](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L933) + +Will be `true` if the query failed while refetching. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetchError`](QueryObserverBaseResult.md#isrefetcherror) + +*** + +### isRefetching + +```ts +isRefetching: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:854](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L854) + +Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. +- Is the same as `isFetching && !isPending`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetching`](QueryObserverBaseResult.md#isrefetching) + +*** + +### isStale + +```ts +isStale: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:858](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L858) + +Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isStale`](QueryObserverBaseResult.md#isstale) + +*** + +### isSuccess + +```ts +isSuccess: false; +``` + +Defined in: [packages/query-core/src/types.ts:934](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L934) + +A derived boolean from the `status` variable, provided for convenience. +- `true` if the query has received a response with no errors and is ready to display its data. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isSuccess`](QueryObserverBaseResult.md#issuccess) + +*** + +### refetch() + +```ts +refetch: (options?) => Promise>; +``` + +Defined in: [packages/query-core/src/types.ts:871](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L871) + +A function to manually refetch the query. + +#### Parameters + +##### options? + +[`RefetchOptions`](RefetchOptions.md) + +#### Returns + +`Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`refetch`](QueryObserverBaseResult.md#refetch) + +*** + +### status + +```ts +status: "error"; +``` + +Defined in: [packages/query-core/src/types.ts:936](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L936) + +The status of the query. +- Will be: + - `pending` if there's no cached data and no query attempt was finished yet. + - `error` if the query attempt resulted in an error. + - `success` if the query has received a response with no errors and is ready to display its data. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`status`](QueryObserverBaseResult.md#status) diff --git a/docs/framework/angular/reference/interfaces/QueryObserverLoadingResult.md b/docs/framework/angular/reference/interfaces/QueryObserverLoadingResult.md new file mode 100644 index 00000000000..4966390127f --- /dev/null +++ b/docs/framework/angular/reference/interfaces/QueryObserverLoadingResult.md @@ -0,0 +1,452 @@ +--- +id: QueryObserverLoadingResult +title: QueryObserverLoadingResult +--- + +Defined in: [packages/query-core/src/types.ts:907](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L907) + +## Extends + +- [`QueryObserverBaseResult`](QueryObserverBaseResult.md)\<`TData`, `TError`\> + +## Type Parameters + +### TData + +`TData` = `unknown` + +### TError + +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) + +## Properties + +### data + +```ts +data: undefined; +``` + +Defined in: [packages/query-core/src/types.ts:911](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L911) + +The last successfully resolved data for the query. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`data`](QueryObserverBaseResult.md#data) + +*** + +### dataUpdatedAt + +```ts +dataUpdatedAt: number; +``` + +Defined in: [packages/query-core/src/types.ts:775](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L775) + +The timestamp for when the query most recently returned the `status` as `"success"`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`dataUpdatedAt`](QueryObserverBaseResult.md#dataupdatedat) + +*** + +### error + +```ts +error: null; +``` + +Defined in: [packages/query-core/src/types.ts:912](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L912) + +The error object for the query, if an error was thrown. +- Defaults to `null`. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`error`](QueryObserverBaseResult.md#error) + +*** + +### errorUpdateCount + +```ts +errorUpdateCount: number; +``` + +Defined in: [packages/query-core/src/types.ts:799](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L799) + +The sum of all errors. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`errorUpdateCount`](QueryObserverBaseResult.md#errorupdatecount) + +*** + +### errorUpdatedAt + +```ts +errorUpdatedAt: number; +``` + +Defined in: [packages/query-core/src/types.ts:784](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L784) + +The timestamp for when the query most recently returned the `status` as `"error"`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`errorUpdatedAt`](QueryObserverBaseResult.md#errorupdatedat) + +*** + +### failureCount + +```ts +failureCount: number; +``` + +Defined in: [packages/query-core/src/types.ts:790](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L790) + +The failure count for the query. +- Incremented every time the query fails. +- Reset to `0` when the query succeeds. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`failureCount`](QueryObserverBaseResult.md#failurecount) + +*** + +### failureReason + +```ts +failureReason: TError | null; +``` + +Defined in: [packages/query-core/src/types.ts:795](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L795) + +The failure reason for the query retry. +- Reset to `null` when the query succeeds. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`failureReason`](QueryObserverBaseResult.md#failurereason) + +*** + +### fetchStatus + +```ts +fetchStatus: FetchStatus; +``` + +Defined in: [packages/query-core/src/types.ts:889](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L889) + +The fetch status of the query. +- `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. +- `paused`: The query wanted to fetch, but has been `paused`. +- `idle`: The query is not fetching. +- See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`fetchStatus`](QueryObserverBaseResult.md#fetchstatus) + +*** + +### isEnabled + +```ts +isEnabled: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:867](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L867) + +`true` if this observer is enabled, `false` otherwise. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isEnabled`](QueryObserverBaseResult.md#isenabled) + +*** + +### isError + +```ts +isError: false; +``` + +Defined in: [packages/query-core/src/types.ts:913](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L913) + +A derived boolean from the `status` variable, provided for convenience. +- `true` if the query attempt resulted in an error. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isError`](QueryObserverBaseResult.md#iserror) + +*** + +### isFetched + +```ts +isFetched: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:808](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L808) + +Will be `true` if the query has been fetched. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isFetched`](QueryObserverBaseResult.md#isfetched) + +*** + +### isFetchedAfterMount + +```ts +isFetchedAfterMount: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:813](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L813) + +Will be `true` if the query has been fetched after the component mounted. +- This property can be used to not show any previously cached data. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isFetchedAfterMount`](QueryObserverBaseResult.md#isfetchedaftermount) + +*** + +### isFetching + +```ts +isFetching: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:818](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L818) + +A derived boolean from the `fetchStatus` variable, provided for convenience. +- `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isFetching`](QueryObserverBaseResult.md#isfetching) + +*** + +### ~~isInitialLoading~~ + +```ts +isInitialLoading: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:836](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L836) + +#### Deprecated + +`isInitialLoading` is being deprecated in favor of `isLoading` +and will be removed in the next major version. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isInitialLoading`](QueryObserverBaseResult.md#isinitialloading) + +*** + +### isLoading + +```ts +isLoading: true; +``` + +Defined in: [packages/query-core/src/types.ts:915](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L915) + +Is `true` whenever the first fetch for a query is in-flight. +- Is the same as `isFetching && isPending`. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoading`](QueryObserverBaseResult.md#isloading) + +*** + +### isLoadingError + +```ts +isLoadingError: false; +``` + +Defined in: [packages/query-core/src/types.ts:916](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L916) + +Will be `true` if the query failed while fetching for the first time. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoadingError`](QueryObserverBaseResult.md#isloadingerror) + +*** + +### isPaused + +```ts +isPaused: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:841](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L841) + +A derived boolean from the `fetchStatus` variable, provided for convenience. +- The query wanted to fetch, but has been `paused`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPaused`](QueryObserverBaseResult.md#ispaused) + +*** + +### isPending + +```ts +isPending: true; +``` + +Defined in: [packages/query-core/src/types.ts:914](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L914) + +Will be `pending` if there's no cached data and no query attempt was finished yet. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPending`](QueryObserverBaseResult.md#ispending) + +*** + +### isPlaceholderData + +```ts +isPlaceholderData: false; +``` + +Defined in: [packages/query-core/src/types.ts:919](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L919) + +Will be `true` if the data shown is the placeholder data. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPlaceholderData`](QueryObserverBaseResult.md#isplaceholderdata) + +*** + +### isRefetchError + +```ts +isRefetchError: false; +``` + +Defined in: [packages/query-core/src/types.ts:917](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L917) + +Will be `true` if the query failed while refetching. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetchError`](QueryObserverBaseResult.md#isrefetcherror) + +*** + +### isRefetching + +```ts +isRefetching: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:854](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L854) + +Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. +- Is the same as `isFetching && !isPending`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetching`](QueryObserverBaseResult.md#isrefetching) + +*** + +### isStale + +```ts +isStale: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:858](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L858) + +Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isStale`](QueryObserverBaseResult.md#isstale) + +*** + +### isSuccess + +```ts +isSuccess: false; +``` + +Defined in: [packages/query-core/src/types.ts:918](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L918) + +A derived boolean from the `status` variable, provided for convenience. +- `true` if the query has received a response with no errors and is ready to display its data. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isSuccess`](QueryObserverBaseResult.md#issuccess) + +*** + +### refetch() + +```ts +refetch: (options?) => Promise>; +``` + +Defined in: [packages/query-core/src/types.ts:871](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L871) + +A function to manually refetch the query. + +#### Parameters + +##### options? + +[`RefetchOptions`](RefetchOptions.md) + +#### Returns + +`Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`refetch`](QueryObserverBaseResult.md#refetch) + +*** + +### status + +```ts +status: "pending"; +``` + +Defined in: [packages/query-core/src/types.ts:920](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L920) + +The status of the query. +- Will be: + - `pending` if there's no cached data and no query attempt was finished yet. + - `error` if the query attempt resulted in an error. + - `success` if the query has received a response with no errors and is ready to display its data. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`status`](QueryObserverBaseResult.md#status) diff --git a/docs/framework/angular/reference/interfaces/QueryObserverOptions.md b/docs/framework/angular/reference/interfaces/QueryObserverOptions.md new file mode 100644 index 00000000000..5e171652c26 --- /dev/null +++ b/docs/framework/angular/reference/interfaces/QueryObserverOptions.md @@ -0,0 +1,561 @@ +--- +id: QueryObserverOptions +title: QueryObserverOptions +--- + +Defined in: [packages/query-core/src/types.ts:380](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L380) + +## Extends + +- [`WithRequired`](../type-aliases/WithRequired.md)\<[`QueryOptions`](QueryOptions.md)\<`TQueryFnData`, `TError`, `TQueryData`, `TQueryKey`, `TPageParam`\>, `"queryKey"`\> + +## Extended by + +- [`InfiniteQueryObserverOptions`](InfiniteQueryObserverOptions.md) +- [`CreateBaseQueryOptions`](CreateBaseQueryOptions.md) + +## Type Parameters + +### TQueryFnData + +`TQueryFnData` = `unknown` + +### TError + +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) + +### TData + +`TData` = `TQueryFnData` + +### TQueryData + +`TQueryData` = `TQueryFnData` + +### TQueryKey + +`TQueryKey` *extends* [`QueryKey`](../type-aliases/QueryKey.md) = [`QueryKey`](../type-aliases/QueryKey.md) + +### TPageParam + +`TPageParam` = `never` + +## Properties + +### enabled? + +```ts +optional enabled: QueryBooleanOption; +``` + +Defined in: [packages/query-core/src/types.ts:398](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L398) + +Set this to `false` or a function that returns `false` to disable automatic refetching when the query mounts or changes query keys. +To refetch the query, use the `refetch` method returned from the `useQuery` instance. +Accepts a boolean or function that returns a boolean. + +Defaults to `true`. + +*** + +### gcTime? + +```ts +optional gcTime: number; +``` + +Defined in: [packages/query-core/src/types.ts:277](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L277) + +The time in milliseconds that unused/inactive cache data remains in memory. +When a query's cache becomes unused or inactive, that cache data will be garbage collected after this duration. +When different garbage collection times are specified, the longest one will be used. +Setting it to `Infinity` will disable garbage collection. + +Defaults to `5 * 60 * 1000` (5 minutes), or `Infinity` during SSR. + +Note: the maximum allowed time is about 24 days, imposed by `setTimeout`'s 32-bit signed integer delay — see +`timeoutManager.setTimeoutProvider` for a workaround. + +#### Inherited from + +```ts +WithRequired.gcTime +``` + +*** + +### initialData? + +```ts +optional initialData: + | TQueryData +| InitialDataFunction; +``` + +Defined in: [packages/query-core/src/types.ts:317](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L317) + +If set, this value will be used as the initial data for the query cache (as long as the query hasn't been +created or cached yet). +If set to a function, the function will be called **once** during the shared/root query initialization, and be +expected to synchronously return the initial data. +Initial data is considered stale by default unless a `staleTime` has been set. +`initialData` **is persisted** to the cache. + +#### Inherited from + +```ts +WithRequired.initialData +``` + +*** + +### initialDataUpdatedAt? + +```ts +optional initialDataUpdatedAt: number | () => number | undefined; +``` + +Defined in: [packages/query-core/src/types.ts:321](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L321) + +If set, this value will be used as the time (in milliseconds) of when the `initialData` itself was last updated. + +#### Inherited from + +```ts +WithRequired.initialDataUpdatedAt +``` + +*** + +### maxPages? + +```ts +optional maxPages: number; +``` + +Defined in: [packages/query-core/src/types.ts:345](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L345) + +Maximum number of pages to store in the data of an infinite query. + +#### Inherited from + +```ts +WithRequired.maxPages +``` + +*** + +### meta? + +```ts +optional meta: Record; +``` + +Defined in: [packages/query-core/src/types.ts:341](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L341) + +Additional payload to be stored on each query. +Use this property to pass information that can be used in other places. + +#### Inherited from + +```ts +WithRequired.meta +``` + +*** + +### networkMode? + +```ts +optional networkMode: NetworkMode; +``` + +Defined in: [packages/query-core/src/types.ts:265](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L265) + +Controls whether a query is allowed to run based on the current network connectivity. + +Defaults to `'online'`. + +#### See + +[Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. + +#### Inherited from + +```ts +WithRequired.networkMode +``` + +*** + +### notifyOnChangeProps? + +```ts +optional notifyOnChangeProps: NotifyOnChangeProps; +``` + +Defined in: [packages/query-core/src/types.ts:484](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L484) + +If set, the component will only re-render if any of the listed properties change. +When set to `['data', 'error']`, the component will only re-render when the `data` or `error` properties change. +When set to `'all'`, the component will re-render whenever a query is updated. +When set to a function, the function will be executed to compute the list of properties. + +Defaults to `undefined`, in which case property access is tracked automatically, and the +component only re-renders when one of the tracked properties changes. + +*** + +### persister? + +```ts +optional persister: QueryPersister, TPageParam>; +``` + +Defined in: [packages/query-core/src/types.ts:290](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L290) + +This option can be used to persist the result of a query to an external storage, bypassing the need to actually +call the `queryFn`. Useful for persisting a query's data across e.g. server/client boundaries. + +#### Inherited from + +```ts +WithRequired.persister +``` + +*** + +### placeholderData? + +```ts +optional placeholderData: + | NonFunctionGuard +| PlaceholderDataFunction, TError, NonFunctionGuard, TQueryKey>; +``` + +Defined in: [packages/query-core/src/types.ts:511](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L511) + +If set, this value will be used as the placeholder data for this particular query observer while the query is still in the `loading` data and no initialData has been provided. + +*** + +### queryFn? + +```ts +optional queryFn: + | typeof skipToken +| QueryFunction; +``` + +Defined in: [packages/query-core/src/types.ts:285](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L285) + +The function that the query will use to request data. +Required, unless a default query function has been set via `queryClient.setQueryDefaults` or +`queryClient.setDefaultOptions`. +Receives a [QueryFunctionContext](../type-aliases/QueryFunctionContext.md). +Must return a promise that will either resolve data or throw an error. The data cannot be `undefined`. + +#### Inherited from + +```ts +WithRequired.queryFn +``` + +*** + +### queryHash? + +```ts +optional queryHash: string; +``` + +Defined in: [packages/query-core/src/types.ts:295](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L295) + +The hashed form of `queryKey`, computed with `queryKeyHashFn` (or the default hashing function otherwise). Used +as the actual cache key internally. + +#### Inherited from + +```ts +WithRequired.queryHash +``` + +*** + +### queryKey + +```ts +queryKey: TQueryKey & object; +``` + +Defined in: [packages/query-core/src/types.ts:304](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L304) + +The query key to use for this query. + +The query key will be hashed into a stable hash. See [Query Keys](https://tanstack.com/query/latest/docs/framework/react/guides/query-keys) +for more information. + +The query will automatically update when this key changes (as long as `enabled` is not set to `false`). + +#### Inherited from + +```ts +WithRequired.queryKey +``` + +*** + +### queryKeyHashFn? + +```ts +optional queryKeyHashFn: QueryKeyHashFunction; +``` + +Defined in: [packages/query-core/src/types.ts:308](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L308) + +If specified, this function is used to hash the `queryKey` to a string. + +#### Inherited from + +```ts +WithRequired.queryKeyHashFn +``` + +*** + +### refetchInterval? + +```ts +optional refetchInterval: number | false | (query) => number | false | undefined; +``` + +Defined in: [packages/query-core/src/types.ts:414](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L414) + +If set to a number, the query will continuously refetch at this frequency in milliseconds. +If set to a function, the function will be executed with the latest data and query to compute a frequency + +Defaults to `false`. + +*** + +### refetchIntervalInBackground? + +```ts +optional refetchIntervalInBackground: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:425](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L425) + +If set to `true`, the query will continue to refetch while their tab/window is in the background. + +Defaults to `false`. + +*** + +### refetchOnMount? + +```ts +optional refetchOnMount: boolean | "always" | (query) => boolean | "always"; +``` + +Defined in: [packages/query-core/src/types.ts:462](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L462) + +If set to `true`, the query will refetch on mount if the data is stale. +If set to `false`, will disable additional instances of a query to trigger background refetch. +If set to `'always'`, the query will always refetch on mount (except when `staleTime: 'static'` is used). +If set to a function, the function will be executed with the latest data and query to compute the value + +Defaults to `true`. + +*** + +### refetchOnReconnect? + +```ts +optional refetchOnReconnect: boolean | "always" | (query) => boolean | "always"; +``` + +Defined in: [packages/query-core/src/types.ts:448](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L448) + +If set to `true`, the query will refetch on reconnect if the data is stale. +If set to `false`, the query will not refetch on reconnect. +If set to `'always'`, the query will always refetch on reconnect (except when `staleTime: 'static'` is used). +If set to a function, the function will be executed with the latest data and query to compute the value. + +Defaults to `true` unless `networkMode` is `'always'`. + +*** + +### refetchOnWindowFocus? + +```ts +optional refetchOnWindowFocus: boolean | "always" | (query) => boolean | "always"; +``` + +Defined in: [packages/query-core/src/types.ts:434](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L434) + +If set to `true`, the query will refetch on window focus if the data is stale. +If set to `false`, the query will not refetch on window focus. +If set to `'always'`, the query will always refetch on window focus (except when `staleTime: 'static'` is used). +If set to a function, the function will be executed with the latest data and query to compute the value. + +Defaults to `true`. + +*** + +### retry? + +```ts +optional retry: RetryValue; +``` + +Defined in: [packages/query-core/src/types.ts:246](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L246) + +If `false`, failed queries will not retry by default. +If `true`, failed queries will retry infinitely. +If set to an integer number, e.g. 3, failed queries will retry until the failed query count meets that number. +If set to a function `(failureCount, error) => boolean` failed queries will retry until the function returns false. + +Defaults to `3` on the client and `0` on the server. + +#### Inherited from + +```ts +WithRequired.retry +``` + +*** + +### retryDelay? + +```ts +optional retryDelay: RetryDelayValue; +``` + +Defined in: [packages/query-core/src/types.ts:258](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L258) + +This function receives a `retryAttempt` integer and the actual Error and returns the delay to apply before the +next attempt in milliseconds. + +A function like `attempt => Math.min(attempt > 1 ? 2 ** attempt * 1000 : 1000, 30 * 1000)` applies exponential +backoff. + +A function like `attempt => attempt * 1000` applies linear backoff. + +Defaults to a function that applies exponential backoff, capped at 30 seconds. + +#### Inherited from + +```ts +WithRequired.retryDelay +``` + +*** + +### retryOnMount? + +```ts +optional retryOnMount: QueryBooleanOption; +``` + +Defined in: [packages/query-core/src/types.ts:474](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L474) + +If set to `false`, the query will not be retried on mount if it contains an error. +If set to a function, the function will be executed with the query to compute the value. + +Defaults to `true`. + +*** + +### select()? + +```ts +optional select: (data) => TData; +``` + +Defined in: [packages/query-core/src/types.ts:500](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L500) + +This option can be used to transform or select a part of the data returned by the query function. It affects +the returned `data` value, but does not affect what gets stored in the query cache. +The `select` function will only run if `data` changed, or if the reference to the `select` function itself +changes. To optimize, memoize the function so its reference stays stable across calls. + +#### Parameters + +##### data + +`TQueryData` + +#### Returns + +`TData` + +*** + +### staleTime? + +```ts +optional staleTime: StaleTimeFunction; +``` + +Defined in: [packages/query-core/src/types.ts:407](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L407) + +The time in milliseconds after data is considered stale. +If set to `Infinity`, the data will never be considered stale. +If set to `'static'`, the data will never be considered stale. +If set to a function, the function will be executed with the query to compute a `staleTime`. + +Defaults to `0`. + +*** + +### structuralSharing? + +```ts +optional structuralSharing: boolean | (oldData, newData) => unknown; +``` + +Defined in: [packages/query-core/src/types.ts:330](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L330) + +Set this to `false` to disable structural sharing between query results. +Set this to a function which accepts the old and new data and returns resolved data of the same type to implement custom structural sharing logic. + +Defaults to `true`. + +#### Inherited from + +```ts +WithRequired.structuralSharing +``` + +*** + +### suspense? + +```ts +optional suspense: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:507](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L507) + +If set to `true`, the query will suspend when `status === 'pending'` +and throw errors when `status === 'error'`. + +Defaults to `false`. + +*** + +### throwOnError? + +```ts +optional throwOnError: ThrowOnError; +``` + +Defined in: [packages/query-core/src/types.ts:493](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L493) + +Whether errors should be thrown instead of setting the `error` property. +If set to `true` or `suspense` is `true`, all errors will be thrown to the error boundary. +If set to `false` and `suspense` is `false`, errors are returned as state. +If set to a function, it will be passed the error and the query, and it should return a boolean indicating whether to show the error in an error boundary (`true`) or return the error as state (`false`). + +Defaults to `false`. diff --git a/docs/framework/angular/reference/interfaces/QueryObserverPendingResult.md b/docs/framework/angular/reference/interfaces/QueryObserverPendingResult.md new file mode 100644 index 00000000000..8f00c426b64 --- /dev/null +++ b/docs/framework/angular/reference/interfaces/QueryObserverPendingResult.md @@ -0,0 +1,452 @@ +--- +id: QueryObserverPendingResult +title: QueryObserverPendingResult +--- + +Defined in: [packages/query-core/src/types.ts:892](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L892) + +## Extends + +- [`QueryObserverBaseResult`](QueryObserverBaseResult.md)\<`TData`, `TError`\> + +## Type Parameters + +### TData + +`TData` = `unknown` + +### TError + +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) + +## Properties + +### data + +```ts +data: undefined; +``` + +Defined in: [packages/query-core/src/types.ts:896](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L896) + +The last successfully resolved data for the query. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`data`](QueryObserverBaseResult.md#data) + +*** + +### dataUpdatedAt + +```ts +dataUpdatedAt: number; +``` + +Defined in: [packages/query-core/src/types.ts:775](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L775) + +The timestamp for when the query most recently returned the `status` as `"success"`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`dataUpdatedAt`](QueryObserverBaseResult.md#dataupdatedat) + +*** + +### error + +```ts +error: null; +``` + +Defined in: [packages/query-core/src/types.ts:897](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L897) + +The error object for the query, if an error was thrown. +- Defaults to `null`. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`error`](QueryObserverBaseResult.md#error) + +*** + +### errorUpdateCount + +```ts +errorUpdateCount: number; +``` + +Defined in: [packages/query-core/src/types.ts:799](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L799) + +The sum of all errors. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`errorUpdateCount`](QueryObserverBaseResult.md#errorupdatecount) + +*** + +### errorUpdatedAt + +```ts +errorUpdatedAt: number; +``` + +Defined in: [packages/query-core/src/types.ts:784](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L784) + +The timestamp for when the query most recently returned the `status` as `"error"`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`errorUpdatedAt`](QueryObserverBaseResult.md#errorupdatedat) + +*** + +### failureCount + +```ts +failureCount: number; +``` + +Defined in: [packages/query-core/src/types.ts:790](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L790) + +The failure count for the query. +- Incremented every time the query fails. +- Reset to `0` when the query succeeds. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`failureCount`](QueryObserverBaseResult.md#failurecount) + +*** + +### failureReason + +```ts +failureReason: TError | null; +``` + +Defined in: [packages/query-core/src/types.ts:795](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L795) + +The failure reason for the query retry. +- Reset to `null` when the query succeeds. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`failureReason`](QueryObserverBaseResult.md#failurereason) + +*** + +### fetchStatus + +```ts +fetchStatus: FetchStatus; +``` + +Defined in: [packages/query-core/src/types.ts:889](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L889) + +The fetch status of the query. +- `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. +- `paused`: The query wanted to fetch, but has been `paused`. +- `idle`: The query is not fetching. +- See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`fetchStatus`](QueryObserverBaseResult.md#fetchstatus) + +*** + +### isEnabled + +```ts +isEnabled: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:867](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L867) + +`true` if this observer is enabled, `false` otherwise. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isEnabled`](QueryObserverBaseResult.md#isenabled) + +*** + +### isError + +```ts +isError: false; +``` + +Defined in: [packages/query-core/src/types.ts:898](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L898) + +A derived boolean from the `status` variable, provided for convenience. +- `true` if the query attempt resulted in an error. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isError`](QueryObserverBaseResult.md#iserror) + +*** + +### isFetched + +```ts +isFetched: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:808](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L808) + +Will be `true` if the query has been fetched. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isFetched`](QueryObserverBaseResult.md#isfetched) + +*** + +### isFetchedAfterMount + +```ts +isFetchedAfterMount: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:813](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L813) + +Will be `true` if the query has been fetched after the component mounted. +- This property can be used to not show any previously cached data. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isFetchedAfterMount`](QueryObserverBaseResult.md#isfetchedaftermount) + +*** + +### isFetching + +```ts +isFetching: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:818](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L818) + +A derived boolean from the `fetchStatus` variable, provided for convenience. +- `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isFetching`](QueryObserverBaseResult.md#isfetching) + +*** + +### ~~isInitialLoading~~ + +```ts +isInitialLoading: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:836](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L836) + +#### Deprecated + +`isInitialLoading` is being deprecated in favor of `isLoading` +and will be removed in the next major version. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isInitialLoading`](QueryObserverBaseResult.md#isinitialloading) + +*** + +### isLoading + +```ts +isLoading: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:823](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L823) + +Is `true` whenever the first fetch for a query is in-flight. +- Is the same as `isFetching && isPending`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoading`](QueryObserverBaseResult.md#isloading) + +*** + +### isLoadingError + +```ts +isLoadingError: false; +``` + +Defined in: [packages/query-core/src/types.ts:900](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L900) + +Will be `true` if the query failed while fetching for the first time. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoadingError`](QueryObserverBaseResult.md#isloadingerror) + +*** + +### isPaused + +```ts +isPaused: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:841](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L841) + +A derived boolean from the `fetchStatus` variable, provided for convenience. +- The query wanted to fetch, but has been `paused`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPaused`](QueryObserverBaseResult.md#ispaused) + +*** + +### isPending + +```ts +isPending: true; +``` + +Defined in: [packages/query-core/src/types.ts:899](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L899) + +Will be `pending` if there's no cached data and no query attempt was finished yet. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPending`](QueryObserverBaseResult.md#ispending) + +*** + +### isPlaceholderData + +```ts +isPlaceholderData: false; +``` + +Defined in: [packages/query-core/src/types.ts:903](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L903) + +Will be `true` if the data shown is the placeholder data. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPlaceholderData`](QueryObserverBaseResult.md#isplaceholderdata) + +*** + +### isRefetchError + +```ts +isRefetchError: false; +``` + +Defined in: [packages/query-core/src/types.ts:901](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L901) + +Will be `true` if the query failed while refetching. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetchError`](QueryObserverBaseResult.md#isrefetcherror) + +*** + +### isRefetching + +```ts +isRefetching: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:854](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L854) + +Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. +- Is the same as `isFetching && !isPending`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetching`](QueryObserverBaseResult.md#isrefetching) + +*** + +### isStale + +```ts +isStale: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:858](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L858) + +Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isStale`](QueryObserverBaseResult.md#isstale) + +*** + +### isSuccess + +```ts +isSuccess: false; +``` + +Defined in: [packages/query-core/src/types.ts:902](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L902) + +A derived boolean from the `status` variable, provided for convenience. +- `true` if the query has received a response with no errors and is ready to display its data. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isSuccess`](QueryObserverBaseResult.md#issuccess) + +*** + +### refetch() + +```ts +refetch: (options?) => Promise>; +``` + +Defined in: [packages/query-core/src/types.ts:871](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L871) + +A function to manually refetch the query. + +#### Parameters + +##### options? + +[`RefetchOptions`](RefetchOptions.md) + +#### Returns + +`Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`refetch`](QueryObserverBaseResult.md#refetch) + +*** + +### status + +```ts +status: "pending"; +``` + +Defined in: [packages/query-core/src/types.ts:904](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L904) + +The status of the query. +- Will be: + - `pending` if there's no cached data and no query attempt was finished yet. + - `error` if the query attempt resulted in an error. + - `success` if the query has received a response with no errors and is ready to display its data. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`status`](QueryObserverBaseResult.md#status) diff --git a/docs/framework/angular/reference/interfaces/QueryObserverPlaceholderResult.md b/docs/framework/angular/reference/interfaces/QueryObserverPlaceholderResult.md new file mode 100644 index 00000000000..bbf3da387f9 --- /dev/null +++ b/docs/framework/angular/reference/interfaces/QueryObserverPlaceholderResult.md @@ -0,0 +1,452 @@ +--- +id: QueryObserverPlaceholderResult +title: QueryObserverPlaceholderResult +--- + +Defined in: [packages/query-core/src/types.ts:971](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L971) + +## Extends + +- [`QueryObserverBaseResult`](QueryObserverBaseResult.md)\<`TData`, `TError`\> + +## Type Parameters + +### TData + +`TData` = `unknown` + +### TError + +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) + +## Properties + +### data + +```ts +data: TData; +``` + +Defined in: [packages/query-core/src/types.ts:975](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L975) + +The last successfully resolved data for the query. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`data`](QueryObserverBaseResult.md#data) + +*** + +### dataUpdatedAt + +```ts +dataUpdatedAt: number; +``` + +Defined in: [packages/query-core/src/types.ts:775](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L775) + +The timestamp for when the query most recently returned the `status` as `"success"`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`dataUpdatedAt`](QueryObserverBaseResult.md#dataupdatedat) + +*** + +### error + +```ts +error: null; +``` + +Defined in: [packages/query-core/src/types.ts:977](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L977) + +The error object for the query, if an error was thrown. +- Defaults to `null`. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`error`](QueryObserverBaseResult.md#error) + +*** + +### errorUpdateCount + +```ts +errorUpdateCount: number; +``` + +Defined in: [packages/query-core/src/types.ts:799](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L799) + +The sum of all errors. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`errorUpdateCount`](QueryObserverBaseResult.md#errorupdatecount) + +*** + +### errorUpdatedAt + +```ts +errorUpdatedAt: number; +``` + +Defined in: [packages/query-core/src/types.ts:784](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L784) + +The timestamp for when the query most recently returned the `status` as `"error"`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`errorUpdatedAt`](QueryObserverBaseResult.md#errorupdatedat) + +*** + +### failureCount + +```ts +failureCount: number; +``` + +Defined in: [packages/query-core/src/types.ts:790](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L790) + +The failure count for the query. +- Incremented every time the query fails. +- Reset to `0` when the query succeeds. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`failureCount`](QueryObserverBaseResult.md#failurecount) + +*** + +### failureReason + +```ts +failureReason: TError | null; +``` + +Defined in: [packages/query-core/src/types.ts:795](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L795) + +The failure reason for the query retry. +- Reset to `null` when the query succeeds. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`failureReason`](QueryObserverBaseResult.md#failurereason) + +*** + +### fetchStatus + +```ts +fetchStatus: FetchStatus; +``` + +Defined in: [packages/query-core/src/types.ts:889](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L889) + +The fetch status of the query. +- `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. +- `paused`: The query wanted to fetch, but has been `paused`. +- `idle`: The query is not fetching. +- See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`fetchStatus`](QueryObserverBaseResult.md#fetchstatus) + +*** + +### isEnabled + +```ts +isEnabled: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:867](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L867) + +`true` if this observer is enabled, `false` otherwise. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isEnabled`](QueryObserverBaseResult.md#isenabled) + +*** + +### isError + +```ts +isError: false; +``` + +Defined in: [packages/query-core/src/types.ts:976](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L976) + +A derived boolean from the `status` variable, provided for convenience. +- `true` if the query attempt resulted in an error. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isError`](QueryObserverBaseResult.md#iserror) + +*** + +### isFetched + +```ts +isFetched: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:808](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L808) + +Will be `true` if the query has been fetched. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isFetched`](QueryObserverBaseResult.md#isfetched) + +*** + +### isFetchedAfterMount + +```ts +isFetchedAfterMount: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:813](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L813) + +Will be `true` if the query has been fetched after the component mounted. +- This property can be used to not show any previously cached data. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isFetchedAfterMount`](QueryObserverBaseResult.md#isfetchedaftermount) + +*** + +### isFetching + +```ts +isFetching: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:818](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L818) + +A derived boolean from the `fetchStatus` variable, provided for convenience. +- `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isFetching`](QueryObserverBaseResult.md#isfetching) + +*** + +### ~~isInitialLoading~~ + +```ts +isInitialLoading: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:836](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L836) + +#### Deprecated + +`isInitialLoading` is being deprecated in favor of `isLoading` +and will be removed in the next major version. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isInitialLoading`](QueryObserverBaseResult.md#isinitialloading) + +*** + +### isLoading + +```ts +isLoading: false; +``` + +Defined in: [packages/query-core/src/types.ts:979](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L979) + +Is `true` whenever the first fetch for a query is in-flight. +- Is the same as `isFetching && isPending`. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoading`](QueryObserverBaseResult.md#isloading) + +*** + +### isLoadingError + +```ts +isLoadingError: false; +``` + +Defined in: [packages/query-core/src/types.ts:980](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L980) + +Will be `true` if the query failed while fetching for the first time. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoadingError`](QueryObserverBaseResult.md#isloadingerror) + +*** + +### isPaused + +```ts +isPaused: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:841](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L841) + +A derived boolean from the `fetchStatus` variable, provided for convenience. +- The query wanted to fetch, but has been `paused`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPaused`](QueryObserverBaseResult.md#ispaused) + +*** + +### isPending + +```ts +isPending: false; +``` + +Defined in: [packages/query-core/src/types.ts:978](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L978) + +Will be `pending` if there's no cached data and no query attempt was finished yet. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPending`](QueryObserverBaseResult.md#ispending) + +*** + +### isPlaceholderData + +```ts +isPlaceholderData: true; +``` + +Defined in: [packages/query-core/src/types.ts:983](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L983) + +Will be `true` if the data shown is the placeholder data. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPlaceholderData`](QueryObserverBaseResult.md#isplaceholderdata) + +*** + +### isRefetchError + +```ts +isRefetchError: false; +``` + +Defined in: [packages/query-core/src/types.ts:981](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L981) + +Will be `true` if the query failed while refetching. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetchError`](QueryObserverBaseResult.md#isrefetcherror) + +*** + +### isRefetching + +```ts +isRefetching: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:854](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L854) + +Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. +- Is the same as `isFetching && !isPending`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetching`](QueryObserverBaseResult.md#isrefetching) + +*** + +### isStale + +```ts +isStale: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:858](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L858) + +Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isStale`](QueryObserverBaseResult.md#isstale) + +*** + +### isSuccess + +```ts +isSuccess: true; +``` + +Defined in: [packages/query-core/src/types.ts:982](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L982) + +A derived boolean from the `status` variable, provided for convenience. +- `true` if the query has received a response with no errors and is ready to display its data. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isSuccess`](QueryObserverBaseResult.md#issuccess) + +*** + +### refetch() + +```ts +refetch: (options?) => Promise>; +``` + +Defined in: [packages/query-core/src/types.ts:871](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L871) + +A function to manually refetch the query. + +#### Parameters + +##### options? + +[`RefetchOptions`](RefetchOptions.md) + +#### Returns + +`Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`refetch`](QueryObserverBaseResult.md#refetch) + +*** + +### status + +```ts +status: "success"; +``` + +Defined in: [packages/query-core/src/types.ts:984](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L984) + +The status of the query. +- Will be: + - `pending` if there's no cached data and no query attempt was finished yet. + - `error` if the query attempt resulted in an error. + - `success` if the query has received a response with no errors and is ready to display its data. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`status`](QueryObserverBaseResult.md#status) diff --git a/docs/framework/angular/reference/interfaces/QueryObserverRefetchErrorResult.md b/docs/framework/angular/reference/interfaces/QueryObserverRefetchErrorResult.md new file mode 100644 index 00000000000..345ecab35e1 --- /dev/null +++ b/docs/framework/angular/reference/interfaces/QueryObserverRefetchErrorResult.md @@ -0,0 +1,452 @@ +--- +id: QueryObserverRefetchErrorResult +title: QueryObserverRefetchErrorResult +--- + +Defined in: [packages/query-core/src/types.ts:939](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L939) + +## Extends + +- [`QueryObserverBaseResult`](QueryObserverBaseResult.md)\<`TData`, `TError`\> + +## Type Parameters + +### TData + +`TData` = `unknown` + +### TError + +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) + +## Properties + +### data + +```ts +data: TData; +``` + +Defined in: [packages/query-core/src/types.ts:943](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L943) + +The last successfully resolved data for the query. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`data`](QueryObserverBaseResult.md#data) + +*** + +### dataUpdatedAt + +```ts +dataUpdatedAt: number; +``` + +Defined in: [packages/query-core/src/types.ts:775](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L775) + +The timestamp for when the query most recently returned the `status` as `"success"`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`dataUpdatedAt`](QueryObserverBaseResult.md#dataupdatedat) + +*** + +### error + +```ts +error: TError; +``` + +Defined in: [packages/query-core/src/types.ts:944](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L944) + +The error object for the query, if an error was thrown. +- Defaults to `null`. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`error`](QueryObserverBaseResult.md#error) + +*** + +### errorUpdateCount + +```ts +errorUpdateCount: number; +``` + +Defined in: [packages/query-core/src/types.ts:799](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L799) + +The sum of all errors. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`errorUpdateCount`](QueryObserverBaseResult.md#errorupdatecount) + +*** + +### errorUpdatedAt + +```ts +errorUpdatedAt: number; +``` + +Defined in: [packages/query-core/src/types.ts:784](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L784) + +The timestamp for when the query most recently returned the `status` as `"error"`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`errorUpdatedAt`](QueryObserverBaseResult.md#errorupdatedat) + +*** + +### failureCount + +```ts +failureCount: number; +``` + +Defined in: [packages/query-core/src/types.ts:790](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L790) + +The failure count for the query. +- Incremented every time the query fails. +- Reset to `0` when the query succeeds. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`failureCount`](QueryObserverBaseResult.md#failurecount) + +*** + +### failureReason + +```ts +failureReason: TError | null; +``` + +Defined in: [packages/query-core/src/types.ts:795](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L795) + +The failure reason for the query retry. +- Reset to `null` when the query succeeds. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`failureReason`](QueryObserverBaseResult.md#failurereason) + +*** + +### fetchStatus + +```ts +fetchStatus: FetchStatus; +``` + +Defined in: [packages/query-core/src/types.ts:889](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L889) + +The fetch status of the query. +- `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. +- `paused`: The query wanted to fetch, but has been `paused`. +- `idle`: The query is not fetching. +- See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`fetchStatus`](QueryObserverBaseResult.md#fetchstatus) + +*** + +### isEnabled + +```ts +isEnabled: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:867](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L867) + +`true` if this observer is enabled, `false` otherwise. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isEnabled`](QueryObserverBaseResult.md#isenabled) + +*** + +### isError + +```ts +isError: true; +``` + +Defined in: [packages/query-core/src/types.ts:945](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L945) + +A derived boolean from the `status` variable, provided for convenience. +- `true` if the query attempt resulted in an error. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isError`](QueryObserverBaseResult.md#iserror) + +*** + +### isFetched + +```ts +isFetched: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:808](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L808) + +Will be `true` if the query has been fetched. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isFetched`](QueryObserverBaseResult.md#isfetched) + +*** + +### isFetchedAfterMount + +```ts +isFetchedAfterMount: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:813](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L813) + +Will be `true` if the query has been fetched after the component mounted. +- This property can be used to not show any previously cached data. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isFetchedAfterMount`](QueryObserverBaseResult.md#isfetchedaftermount) + +*** + +### isFetching + +```ts +isFetching: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:818](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L818) + +A derived boolean from the `fetchStatus` variable, provided for convenience. +- `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isFetching`](QueryObserverBaseResult.md#isfetching) + +*** + +### ~~isInitialLoading~~ + +```ts +isInitialLoading: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:836](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L836) + +#### Deprecated + +`isInitialLoading` is being deprecated in favor of `isLoading` +and will be removed in the next major version. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isInitialLoading`](QueryObserverBaseResult.md#isinitialloading) + +*** + +### isLoading + +```ts +isLoading: false; +``` + +Defined in: [packages/query-core/src/types.ts:947](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L947) + +Is `true` whenever the first fetch for a query is in-flight. +- Is the same as `isFetching && isPending`. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoading`](QueryObserverBaseResult.md#isloading) + +*** + +### isLoadingError + +```ts +isLoadingError: false; +``` + +Defined in: [packages/query-core/src/types.ts:948](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L948) + +Will be `true` if the query failed while fetching for the first time. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoadingError`](QueryObserverBaseResult.md#isloadingerror) + +*** + +### isPaused + +```ts +isPaused: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:841](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L841) + +A derived boolean from the `fetchStatus` variable, provided for convenience. +- The query wanted to fetch, but has been `paused`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPaused`](QueryObserverBaseResult.md#ispaused) + +*** + +### isPending + +```ts +isPending: false; +``` + +Defined in: [packages/query-core/src/types.ts:946](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L946) + +Will be `pending` if there's no cached data and no query attempt was finished yet. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPending`](QueryObserverBaseResult.md#ispending) + +*** + +### isPlaceholderData + +```ts +isPlaceholderData: false; +``` + +Defined in: [packages/query-core/src/types.ts:951](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L951) + +Will be `true` if the data shown is the placeholder data. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPlaceholderData`](QueryObserverBaseResult.md#isplaceholderdata) + +*** + +### isRefetchError + +```ts +isRefetchError: true; +``` + +Defined in: [packages/query-core/src/types.ts:949](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L949) + +Will be `true` if the query failed while refetching. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetchError`](QueryObserverBaseResult.md#isrefetcherror) + +*** + +### isRefetching + +```ts +isRefetching: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:854](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L854) + +Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. +- Is the same as `isFetching && !isPending`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetching`](QueryObserverBaseResult.md#isrefetching) + +*** + +### isStale + +```ts +isStale: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:858](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L858) + +Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isStale`](QueryObserverBaseResult.md#isstale) + +*** + +### isSuccess + +```ts +isSuccess: false; +``` + +Defined in: [packages/query-core/src/types.ts:950](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L950) + +A derived boolean from the `status` variable, provided for convenience. +- `true` if the query has received a response with no errors and is ready to display its data. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isSuccess`](QueryObserverBaseResult.md#issuccess) + +*** + +### refetch() + +```ts +refetch: (options?) => Promise>; +``` + +Defined in: [packages/query-core/src/types.ts:871](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L871) + +A function to manually refetch the query. + +#### Parameters + +##### options? + +[`RefetchOptions`](RefetchOptions.md) + +#### Returns + +`Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`refetch`](QueryObserverBaseResult.md#refetch) + +*** + +### status + +```ts +status: "error"; +``` + +Defined in: [packages/query-core/src/types.ts:952](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L952) + +The status of the query. +- Will be: + - `pending` if there's no cached data and no query attempt was finished yet. + - `error` if the query attempt resulted in an error. + - `success` if the query has received a response with no errors and is ready to display its data. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`status`](QueryObserverBaseResult.md#status) diff --git a/docs/framework/angular/reference/interfaces/QueryObserverSuccessResult.md b/docs/framework/angular/reference/interfaces/QueryObserverSuccessResult.md new file mode 100644 index 00000000000..3942655c627 --- /dev/null +++ b/docs/framework/angular/reference/interfaces/QueryObserverSuccessResult.md @@ -0,0 +1,452 @@ +--- +id: QueryObserverSuccessResult +title: QueryObserverSuccessResult +--- + +Defined in: [packages/query-core/src/types.ts:955](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L955) + +## Extends + +- [`QueryObserverBaseResult`](QueryObserverBaseResult.md)\<`TData`, `TError`\> + +## Type Parameters + +### TData + +`TData` = `unknown` + +### TError + +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) + +## Properties + +### data + +```ts +data: TData; +``` + +Defined in: [packages/query-core/src/types.ts:959](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L959) + +The last successfully resolved data for the query. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`data`](QueryObserverBaseResult.md#data) + +*** + +### dataUpdatedAt + +```ts +dataUpdatedAt: number; +``` + +Defined in: [packages/query-core/src/types.ts:775](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L775) + +The timestamp for when the query most recently returned the `status` as `"success"`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`dataUpdatedAt`](QueryObserverBaseResult.md#dataupdatedat) + +*** + +### error + +```ts +error: null; +``` + +Defined in: [packages/query-core/src/types.ts:960](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L960) + +The error object for the query, if an error was thrown. +- Defaults to `null`. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`error`](QueryObserverBaseResult.md#error) + +*** + +### errorUpdateCount + +```ts +errorUpdateCount: number; +``` + +Defined in: [packages/query-core/src/types.ts:799](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L799) + +The sum of all errors. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`errorUpdateCount`](QueryObserverBaseResult.md#errorupdatecount) + +*** + +### errorUpdatedAt + +```ts +errorUpdatedAt: number; +``` + +Defined in: [packages/query-core/src/types.ts:784](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L784) + +The timestamp for when the query most recently returned the `status` as `"error"`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`errorUpdatedAt`](QueryObserverBaseResult.md#errorupdatedat) + +*** + +### failureCount + +```ts +failureCount: number; +``` + +Defined in: [packages/query-core/src/types.ts:790](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L790) + +The failure count for the query. +- Incremented every time the query fails. +- Reset to `0` when the query succeeds. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`failureCount`](QueryObserverBaseResult.md#failurecount) + +*** + +### failureReason + +```ts +failureReason: TError | null; +``` + +Defined in: [packages/query-core/src/types.ts:795](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L795) + +The failure reason for the query retry. +- Reset to `null` when the query succeeds. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`failureReason`](QueryObserverBaseResult.md#failurereason) + +*** + +### fetchStatus + +```ts +fetchStatus: FetchStatus; +``` + +Defined in: [packages/query-core/src/types.ts:889](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L889) + +The fetch status of the query. +- `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. +- `paused`: The query wanted to fetch, but has been `paused`. +- `idle`: The query is not fetching. +- See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`fetchStatus`](QueryObserverBaseResult.md#fetchstatus) + +*** + +### isEnabled + +```ts +isEnabled: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:867](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L867) + +`true` if this observer is enabled, `false` otherwise. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isEnabled`](QueryObserverBaseResult.md#isenabled) + +*** + +### isError + +```ts +isError: false; +``` + +Defined in: [packages/query-core/src/types.ts:961](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L961) + +A derived boolean from the `status` variable, provided for convenience. +- `true` if the query attempt resulted in an error. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isError`](QueryObserverBaseResult.md#iserror) + +*** + +### isFetched + +```ts +isFetched: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:808](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L808) + +Will be `true` if the query has been fetched. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isFetched`](QueryObserverBaseResult.md#isfetched) + +*** + +### isFetchedAfterMount + +```ts +isFetchedAfterMount: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:813](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L813) + +Will be `true` if the query has been fetched after the component mounted. +- This property can be used to not show any previously cached data. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isFetchedAfterMount`](QueryObserverBaseResult.md#isfetchedaftermount) + +*** + +### isFetching + +```ts +isFetching: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:818](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L818) + +A derived boolean from the `fetchStatus` variable, provided for convenience. +- `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isFetching`](QueryObserverBaseResult.md#isfetching) + +*** + +### ~~isInitialLoading~~ + +```ts +isInitialLoading: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:836](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L836) + +#### Deprecated + +`isInitialLoading` is being deprecated in favor of `isLoading` +and will be removed in the next major version. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isInitialLoading`](QueryObserverBaseResult.md#isinitialloading) + +*** + +### isLoading + +```ts +isLoading: false; +``` + +Defined in: [packages/query-core/src/types.ts:963](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L963) + +Is `true` whenever the first fetch for a query is in-flight. +- Is the same as `isFetching && isPending`. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoading`](QueryObserverBaseResult.md#isloading) + +*** + +### isLoadingError + +```ts +isLoadingError: false; +``` + +Defined in: [packages/query-core/src/types.ts:964](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L964) + +Will be `true` if the query failed while fetching for the first time. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoadingError`](QueryObserverBaseResult.md#isloadingerror) + +*** + +### isPaused + +```ts +isPaused: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:841](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L841) + +A derived boolean from the `fetchStatus` variable, provided for convenience. +- The query wanted to fetch, but has been `paused`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPaused`](QueryObserverBaseResult.md#ispaused) + +*** + +### isPending + +```ts +isPending: false; +``` + +Defined in: [packages/query-core/src/types.ts:962](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L962) + +Will be `pending` if there's no cached data and no query attempt was finished yet. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPending`](QueryObserverBaseResult.md#ispending) + +*** + +### isPlaceholderData + +```ts +isPlaceholderData: false; +``` + +Defined in: [packages/query-core/src/types.ts:967](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L967) + +Will be `true` if the data shown is the placeholder data. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPlaceholderData`](QueryObserverBaseResult.md#isplaceholderdata) + +*** + +### isRefetchError + +```ts +isRefetchError: false; +``` + +Defined in: [packages/query-core/src/types.ts:965](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L965) + +Will be `true` if the query failed while refetching. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetchError`](QueryObserverBaseResult.md#isrefetcherror) + +*** + +### isRefetching + +```ts +isRefetching: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:854](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L854) + +Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. +- Is the same as `isFetching && !isPending`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetching`](QueryObserverBaseResult.md#isrefetching) + +*** + +### isStale + +```ts +isStale: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:858](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L858) + +Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isStale`](QueryObserverBaseResult.md#isstale) + +*** + +### isSuccess + +```ts +isSuccess: true; +``` + +Defined in: [packages/query-core/src/types.ts:966](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L966) + +A derived boolean from the `status` variable, provided for convenience. +- `true` if the query has received a response with no errors and is ready to display its data. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isSuccess`](QueryObserverBaseResult.md#issuccess) + +*** + +### refetch() + +```ts +refetch: (options?) => Promise>; +``` + +Defined in: [packages/query-core/src/types.ts:871](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L871) + +A function to manually refetch the query. + +#### Parameters + +##### options? + +[`RefetchOptions`](RefetchOptions.md) + +#### Returns + +`Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`refetch`](QueryObserverBaseResult.md#refetch) + +*** + +### status + +```ts +status: "success"; +``` + +Defined in: [packages/query-core/src/types.ts:968](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L968) + +The status of the query. +- Will be: + - `pending` if there's no cached data and no query attempt was finished yet. + - `error` if the query attempt resulted in an error. + - `success` if the query has received a response with no errors and is ready to display its data. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`status`](QueryObserverBaseResult.md#status) diff --git a/docs/framework/angular/reference/interfaces/QueryOptions.md b/docs/framework/angular/reference/interfaces/QueryOptions.md new file mode 100644 index 00000000000..7e059d3a1d6 --- /dev/null +++ b/docs/framework/angular/reference/interfaces/QueryOptions.md @@ -0,0 +1,247 @@ +--- +id: QueryOptions +title: QueryOptions +--- + +Defined in: [packages/query-core/src/types.ts:231](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L231) + +## Type Parameters + +### TQueryFnData + +`TQueryFnData` = `unknown` + +### TError + +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) + +### TData + +`TData` = `TQueryFnData` + +### TQueryKey + +`TQueryKey` *extends* [`QueryKey`](../type-aliases/QueryKey.md) = [`QueryKey`](../type-aliases/QueryKey.md) + +### TPageParam + +`TPageParam` = `never` + +## Properties + +### gcTime? + +```ts +optional gcTime: number; +``` + +Defined in: [packages/query-core/src/types.ts:277](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L277) + +The time in milliseconds that unused/inactive cache data remains in memory. +When a query's cache becomes unused or inactive, that cache data will be garbage collected after this duration. +When different garbage collection times are specified, the longest one will be used. +Setting it to `Infinity` will disable garbage collection. + +Defaults to `5 * 60 * 1000` (5 minutes), or `Infinity` during SSR. + +Note: the maximum allowed time is about 24 days, imposed by `setTimeout`'s 32-bit signed integer delay — see +`timeoutManager.setTimeoutProvider` for a workaround. + +*** + +### initialData? + +```ts +optional initialData: + | TData +| InitialDataFunction; +``` + +Defined in: [packages/query-core/src/types.ts:317](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L317) + +If set, this value will be used as the initial data for the query cache (as long as the query hasn't been +created or cached yet). +If set to a function, the function will be called **once** during the shared/root query initialization, and be +expected to synchronously return the initial data. +Initial data is considered stale by default unless a `staleTime` has been set. +`initialData` **is persisted** to the cache. + +*** + +### initialDataUpdatedAt? + +```ts +optional initialDataUpdatedAt: number | () => number | undefined; +``` + +Defined in: [packages/query-core/src/types.ts:321](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L321) + +If set, this value will be used as the time (in milliseconds) of when the `initialData` itself was last updated. + +*** + +### maxPages? + +```ts +optional maxPages: number; +``` + +Defined in: [packages/query-core/src/types.ts:345](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L345) + +Maximum number of pages to store in the data of an infinite query. + +*** + +### meta? + +```ts +optional meta: Record; +``` + +Defined in: [packages/query-core/src/types.ts:341](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L341) + +Additional payload to be stored on each query. +Use this property to pass information that can be used in other places. + +*** + +### networkMode? + +```ts +optional networkMode: NetworkMode; +``` + +Defined in: [packages/query-core/src/types.ts:265](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L265) + +Controls whether a query is allowed to run based on the current network connectivity. + +Defaults to `'online'`. + +#### See + +[Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. + +*** + +### persister? + +```ts +optional persister: QueryPersister, TPageParam>; +``` + +Defined in: [packages/query-core/src/types.ts:290](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L290) + +This option can be used to persist the result of a query to an external storage, bypassing the need to actually +call the `queryFn`. Useful for persisting a query's data across e.g. server/client boundaries. + +*** + +### queryFn? + +```ts +optional queryFn: + | QueryFunction + | typeof skipToken; +``` + +Defined in: [packages/query-core/src/types.ts:285](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L285) + +The function that the query will use to request data. +Required, unless a default query function has been set via `queryClient.setQueryDefaults` or +`queryClient.setDefaultOptions`. +Receives a [QueryFunctionContext](../type-aliases/QueryFunctionContext.md). +Must return a promise that will either resolve data or throw an error. The data cannot be `undefined`. + +*** + +### queryHash? + +```ts +optional queryHash: string; +``` + +Defined in: [packages/query-core/src/types.ts:295](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L295) + +The hashed form of `queryKey`, computed with `queryKeyHashFn` (or the default hashing function otherwise). Used +as the actual cache key internally. + +*** + +### queryKey? + +```ts +optional queryKey: TQueryKey; +``` + +Defined in: [packages/query-core/src/types.ts:304](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L304) + +The query key to use for this query. + +The query key will be hashed into a stable hash. See [Query Keys](https://tanstack.com/query/latest/docs/framework/react/guides/query-keys) +for more information. + +The query will automatically update when this key changes (as long as `enabled` is not set to `false`). + +*** + +### queryKeyHashFn? + +```ts +optional queryKeyHashFn: QueryKeyHashFunction; +``` + +Defined in: [packages/query-core/src/types.ts:308](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L308) + +If specified, this function is used to hash the `queryKey` to a string. + +*** + +### retry? + +```ts +optional retry: RetryValue; +``` + +Defined in: [packages/query-core/src/types.ts:246](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L246) + +If `false`, failed queries will not retry by default. +If `true`, failed queries will retry infinitely. +If set to an integer number, e.g. 3, failed queries will retry until the failed query count meets that number. +If set to a function `(failureCount, error) => boolean` failed queries will retry until the function returns false. + +Defaults to `3` on the client and `0` on the server. + +*** + +### retryDelay? + +```ts +optional retryDelay: RetryDelayValue; +``` + +Defined in: [packages/query-core/src/types.ts:258](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L258) + +This function receives a `retryAttempt` integer and the actual Error and returns the delay to apply before the +next attempt in milliseconds. + +A function like `attempt => Math.min(attempt > 1 ? 2 ** attempt * 1000 : 1000, 30 * 1000)` applies exponential +backoff. + +A function like `attempt => attempt * 1000` applies linear backoff. + +Defaults to a function that applies exponential backoff, capped at 30 seconds. + +*** + +### structuralSharing? + +```ts +optional structuralSharing: boolean | (oldData, newData) => unknown; +``` + +Defined in: [packages/query-core/src/types.ts:330](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L330) + +Set this to `false` to disable structural sharing between query results. +Set this to a function which accepts the old and new data and returns resolved data of the same type to implement custom structural sharing logic. + +Defaults to `true`. diff --git a/docs/framework/angular/reference/interfaces/QueryState.md b/docs/framework/angular/reference/interfaces/QueryState.md new file mode 100644 index 00000000000..7dce476d743 --- /dev/null +++ b/docs/framework/angular/reference/interfaces/QueryState.md @@ -0,0 +1,175 @@ +--- +id: QueryState +title: QueryState +--- + +Defined in: [packages/query-core/src/query.ts:52](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L52) + +The raw state stored on a `Query` instance. This is the underlying state +that observer results (e.g. `QueryObserverResult`) are derived from. + +## Type Parameters + +### TData + +`TData` = `unknown` + +### TError + +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) + +## Properties + +### data + +```ts +data: TData | undefined; +``` + +Defined in: [packages/query-core/src/query.ts:56](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L56) + +The last successfully resolved data for the query. + +*** + +### dataUpdateCount + +```ts +dataUpdateCount: number; +``` + +Defined in: [packages/query-core/src/query.ts:60](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L60) + +The number of times the query has successfully resolved. + +*** + +### dataUpdatedAt + +```ts +dataUpdatedAt: number; +``` + +Defined in: [packages/query-core/src/query.ts:64](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L64) + +The timestamp for when the query most recently returned the `status` as `"success"`. + +*** + +### error + +```ts +error: TError | null; +``` + +Defined in: [packages/query-core/src/query.ts:69](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L69) + +The error object for the query, if the last attempt resulted in an error. +- Defaults to `null`. + +*** + +### errorUpdateCount + +```ts +errorUpdateCount: number; +``` + +Defined in: [packages/query-core/src/query.ts:73](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L73) + +The sum of all errors, incremented every time the query resolves with an error. + +*** + +### errorUpdatedAt + +```ts +errorUpdatedAt: number; +``` + +Defined in: [packages/query-core/src/query.ts:77](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L77) + +The timestamp for when the query most recently returned the `status` as `"error"`. + +*** + +### fetchFailureCount + +```ts +fetchFailureCount: number; +``` + +Defined in: [packages/query-core/src/query.ts:83](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L83) + +The failure count for the current fetch. +- Incremented every time the fetch fails. +- Reset to `0` when the fetch succeeds. + +*** + +### fetchFailureReason + +```ts +fetchFailureReason: TError | null; +``` + +Defined in: [packages/query-core/src/query.ts:88](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L88) + +The reason the current fetch failed, as reported by the retryer. +- Reset to `null` when the fetch succeeds. + +*** + +### fetchMeta + +```ts +fetchMeta: FetchMeta | null; +``` + +Defined in: [packages/query-core/src/query.ts:93](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L93) + +Metadata passed to the currently in-flight (or most recent) fetch, e.g. the +`fetchMore` direction for infinite queries. + +*** + +### fetchStatus + +```ts +fetchStatus: FetchStatus; +``` + +Defined in: [packages/query-core/src/query.ts:112](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L112) + +The fetch status of the query. +- `fetching`: the `queryFn` is currently executing. +- `paused`: a fetch wanted to run but has been paused (see network mode). +- `idle`: the query is not fetching. + +*** + +### isInvalidated + +```ts +isInvalidated: boolean; +``` + +Defined in: [packages/query-core/src/query.ts:98](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L98) + +Whether the query has been marked as invalidated via `invalidate()`. +- Reset to `false` whenever the query resolves successfully. + +*** + +### status + +```ts +status: QueryStatus; +``` + +Defined in: [packages/query-core/src/query.ts:105](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L105) + +The status of the query. +- `pending` if there's no cached data and no attempt was finished yet. +- `error` if the last attempt resulted in an error. +- `success` if the query has data. diff --git a/docs/framework/angular/reference/interfaces/RefetchOptions.md b/docs/framework/angular/reference/interfaces/RefetchOptions.md new file mode 100644 index 00000000000..cfcc0498799 --- /dev/null +++ b/docs/framework/angular/reference/interfaces/RefetchOptions.md @@ -0,0 +1,50 @@ +--- +id: RefetchOptions +title: RefetchOptions +--- + +Defined in: [packages/query-core/src/types.ts:704](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L704) + +## Extends + +- [`ResultOptions`](ResultOptions.md) + +## Extended by + +- [`InvalidateOptions`](InvalidateOptions.md) +- [`ResetOptions`](ResetOptions.md) + +## Properties + +### cancelRefetch? + +```ts +optional cancelRefetch: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:712](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L712) + +If set to `true`, a currently running request will be cancelled before a new request is made + +If set to `false`, no refetch will be made if there is already a request running. + +Defaults to `true`. + +*** + +### throwOnError? + +```ts +optional throwOnError: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:701](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L701) + +If set to `true`, the method throws if any of the underlying query refetch tasks fail. + +Defaults to `false`, in which case failed refetches are swallowed and not surfaced to the +caller. + +#### Inherited from + +[`ResultOptions`](ResultOptions.md).[`throwOnError`](ResultOptions.md#throwonerror) diff --git a/docs/framework/angular/reference/interfaces/RefetchQueryFilters.md b/docs/framework/angular/reference/interfaces/RefetchQueryFilters.md new file mode 100644 index 00000000000..c45dfa953f1 --- /dev/null +++ b/docs/framework/angular/reference/interfaces/RefetchQueryFilters.md @@ -0,0 +1,127 @@ +--- +id: RefetchQueryFilters +title: RefetchQueryFilters +--- + +Defined in: [packages/query-core/src/types.ts:730](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L730) + +Filters used to select queries, for example in `queryClient.getQueriesData` or `queryClient.invalidateQueries`. +All provided filters must match; filters that are left unspecified are ignored. + +## Extends + +- [`QueryFilters`](QueryFilters.md)\<`TQueryKey`\> + +## Type Parameters + +### TQueryKey + +`TQueryKey` *extends* [`QueryKey`](../type-aliases/QueryKey.md) = [`QueryKey`](../type-aliases/QueryKey.md) + +## Properties + +### exact? + +```ts +optional exact: boolean; +``` + +Defined in: [packages/query-core/src/utils.ts:41](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L41) + +Match query key exactly + +#### Inherited from + +[`QueryFilters`](QueryFilters.md).[`exact`](QueryFilters.md#exact) + +*** + +### fetchStatus? + +```ts +optional fetchStatus: FetchStatus; +``` + +Defined in: [packages/query-core/src/utils.ts:57](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L57) + +Include queries matching their fetchStatus + +#### Inherited from + +[`QueryFilters`](QueryFilters.md).[`fetchStatus`](QueryFilters.md#fetchstatus) + +*** + +### predicate()? + +```ts +optional predicate: (query) => boolean; +``` + +Defined in: [packages/query-core/src/utils.ts:45](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L45) + +Include queries matching this predicate function + +#### Parameters + +##### query + +[`Query`](../classes/Query.md) + +#### Returns + +`boolean` + +#### Inherited from + +[`QueryFilters`](QueryFilters.md).[`predicate`](QueryFilters.md#predicate) + +*** + +### queryKey? + +```ts +optional queryKey: TQueryKey | TuplePrefixes; +``` + +Defined in: [packages/query-core/src/utils.ts:49](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L49) + +Include queries matching this query key + +#### Inherited from + +[`QueryFilters`](QueryFilters.md).[`queryKey`](QueryFilters.md#querykey) + +*** + +### stale? + +```ts +optional stale: boolean; +``` + +Defined in: [packages/query-core/src/utils.ts:53](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L53) + +Include or exclude stale queries + +#### Inherited from + +[`QueryFilters`](QueryFilters.md).[`stale`](QueryFilters.md#stale) + +*** + +### type? + +```ts +optional type: QueryTypeFilter; +``` + +Defined in: [packages/query-core/src/utils.ts:37](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L37) + +Filter to active queries, inactive queries or all queries + +Defaults to `'all'`. + +#### Inherited from + +[`QueryFilters`](QueryFilters.md).[`type`](QueryFilters.md#type) diff --git a/docs/framework/angular/reference/interfaces/Register.md b/docs/framework/angular/reference/interfaces/Register.md new file mode 100644 index 00000000000..4f442442b48 --- /dev/null +++ b/docs/framework/angular/reference/interfaces/Register.md @@ -0,0 +1,6 @@ +--- +id: Register +title: Register +--- + +Defined in: [packages/query-core/src/types.ts:37](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L37) diff --git a/docs/framework/angular/reference/interfaces/ResetOptions.md b/docs/framework/angular/reference/interfaces/ResetOptions.md new file mode 100644 index 00000000000..9f12324ba27 --- /dev/null +++ b/docs/framework/angular/reference/interfaces/ResetOptions.md @@ -0,0 +1,49 @@ +--- +id: ResetOptions +title: ResetOptions +--- + +Defined in: [packages/query-core/src/types.ts:735](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L735) + +## Extends + +- [`RefetchOptions`](RefetchOptions.md) + +## Properties + +### cancelRefetch? + +```ts +optional cancelRefetch: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:712](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L712) + +If set to `true`, a currently running request will be cancelled before a new request is made + +If set to `false`, no refetch will be made if there is already a request running. + +Defaults to `true`. + +#### Inherited from + +[`RefetchOptions`](RefetchOptions.md).[`cancelRefetch`](RefetchOptions.md#cancelrefetch) + +*** + +### throwOnError? + +```ts +optional throwOnError: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:701](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L701) + +If set to `true`, the method throws if any of the underlying query refetch tasks fail. + +Defaults to `false`, in which case failed refetches are swallowed and not surfaced to the +caller. + +#### Inherited from + +[`RefetchOptions`](RefetchOptions.md).[`throwOnError`](RefetchOptions.md#throwonerror) diff --git a/docs/framework/angular/reference/interfaces/ResultOptions.md b/docs/framework/angular/reference/interfaces/ResultOptions.md new file mode 100644 index 00000000000..42917f20bf0 --- /dev/null +++ b/docs/framework/angular/reference/interfaces/ResultOptions.md @@ -0,0 +1,27 @@ +--- +id: ResultOptions +title: ResultOptions +--- + +Defined in: [packages/query-core/src/types.ts:694](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L694) + +## Extended by + +- [`RefetchOptions`](RefetchOptions.md) +- [`FetchNextPageOptions`](FetchNextPageOptions.md) +- [`FetchPreviousPageOptions`](FetchPreviousPageOptions.md) + +## Properties + +### throwOnError? + +```ts +optional throwOnError: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:701](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L701) + +If set to `true`, the method throws if any of the underlying query refetch tasks fail. + +Defaults to `false`, in which case failed refetches are swallowed and not surfaced to the +caller. diff --git a/docs/framework/angular/reference/interfaces/SetDataOptions.md b/docs/framework/angular/reference/interfaces/SetDataOptions.md new file mode 100644 index 00000000000..bb668fbf162 --- /dev/null +++ b/docs/framework/angular/reference/interfaces/SetDataOptions.md @@ -0,0 +1,16 @@ +--- +id: SetDataOptions +title: SetDataOptions +--- + +Defined in: [packages/query-core/src/types.ts:1526](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1526) + +## Properties + +### updatedAt? + +```ts +optional updatedAt: number; +``` + +Defined in: [packages/query-core/src/types.ts:1527](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1527) diff --git a/docs/framework/angular/reference/interfaces/TimeoutManager.md b/docs/framework/angular/reference/interfaces/TimeoutManager.md new file mode 100644 index 00000000000..95ff07b2ccc --- /dev/null +++ b/docs/framework/angular/reference/interfaces/TimeoutManager.md @@ -0,0 +1,246 @@ +--- +id: TimeoutManager +title: TimeoutManager +--- + +Defined in: [packages/query-core/src/timeoutManager.ts:70](https://github.com/TanStack/query/blob/main/packages/query-core/src/timeoutManager.ts#L70) + +Allows customization of how timeouts are created. + +@tanstack/query-core makes liberal use of timeouts to implement `staleTime` +and `gcTime`. The default TimeoutManager provider uses the platform's global +`setTimeout` implementation, which is known to have scalability issues with +thousands of timeouts on the event loop. + +If you hit this limitation, consider providing a custom TimeoutProvider that +coalesces timeouts. + +## Implements + +- `Omit`\<[`TimeoutProvider`](../type-aliases/TimeoutProvider.md), `"name"`\> + +## Methods + +### clearInterval() + +```ts +clearInterval(intervalId): void; +``` + +Defined in: [packages/query-core/src/timeoutManager.ts:224](https://github.com/TanStack/query/blob/main/packages/query-core/src/timeoutManager.ts#L224) + +`clearInterval` can be used to cancel an interval, like the global +`clearInterval` function. It should be called with an interval ID +returned by `setInterval`. + +#### Parameters + +##### intervalId + +[`ManagedTimerId`](../type-aliases/ManagedTimerId.md) | `undefined` + +#### Returns + +`void` + +#### Example + +```ts +import { timeoutManager } from '@tanstack/query-core' + +const intervalId = timeoutManager.setInterval( + () => console.log('ran at:', new Date()), + 1000, +) + +timeoutManager.clearInterval(intervalId) +``` + +#### Implementation of + +[`TimeoutProvider`](../type-aliases/TimeoutProvider.md).[`clearInterval`](../type-aliases/TimeoutProvider.md#clearinterval) + +*** + +### clearTimeout() + +```ts +clearTimeout(timeoutId): void; +``` + +Defined in: [packages/query-core/src/timeoutManager.ts:179](https://github.com/TanStack/query/blob/main/packages/query-core/src/timeoutManager.ts#L179) + +`clearTimeout` cancels a timeout callback scheduled with `setTimeout`, +like the global `clearTimeout` function. It should be called with a +timer ID returned by `setTimeout`. + +#### Parameters + +##### timeoutId + +[`ManagedTimerId`](../type-aliases/ManagedTimerId.md) | `undefined` + +#### Returns + +`void` + +#### Example + +```ts +import { timeoutManager } from '@tanstack/query-core' + +const timeoutId = timeoutManager.setTimeout( + () => console.log('ran at:', new Date()), + 1000, +) + +timeoutManager.clearTimeout(timeoutId) +``` + +#### Implementation of + +[`TimeoutProvider`](../type-aliases/TimeoutProvider.md).[`clearTimeout`](../type-aliases/TimeoutProvider.md#cleartimeout) + +*** + +### setInterval() + +```ts +setInterval(callback, delay): ManagedTimerId; +``` + +Defined in: [packages/query-core/src/timeoutManager.ts:200](https://github.com/TanStack/query/blob/main/packages/query-core/src/timeoutManager.ts#L200) + +`setInterval` schedules a callback to be called approximately every +`delay` milliseconds, like the global `setInterval` function. + +Like `setTimeout`, it returns a timer ID, which may be a number or an +object that can be coerced to a number via `Symbol.toPrimitive`. + +#### Parameters + +##### callback + +[`TimeoutCallback`](../type-aliases/TimeoutCallback.md) + +##### delay + +`number` + +#### Returns + +[`ManagedTimerId`](../type-aliases/ManagedTimerId.md) + +#### Example + +```ts +import { timeoutManager } from '@tanstack/query-core' + +const intervalId = timeoutManager.setInterval( + () => console.log('ran at:', new Date()), + 1000, +) +``` + +#### Implementation of + +[`TimeoutProvider`](../type-aliases/TimeoutProvider.md).[`setInterval`](../type-aliases/TimeoutProvider.md#setinterval) + +*** + +### setTimeout() + +```ts +setTimeout(callback, delay): ManagedTimerId; +``` + +Defined in: [packages/query-core/src/timeoutManager.ts:155](https://github.com/TanStack/query/blob/main/packages/query-core/src/timeoutManager.ts#L155) + +`setTimeout` schedules a callback to run after approximately `delay` +milliseconds, like the global `setTimeout` function. The callback can be +canceled with `clearTimeout`. + +It returns a timer ID, which may be a number or an object that can be +coerced to a number via `Symbol.toPrimitive`. + +#### Parameters + +##### callback + +[`TimeoutCallback`](../type-aliases/TimeoutCallback.md) + +##### delay + +`number` + +#### Returns + +[`ManagedTimerId`](../type-aliases/ManagedTimerId.md) + +#### Example + +```ts +import { timeoutManager } from '@tanstack/query-core' + +const timeoutId = timeoutManager.setTimeout( + () => console.log('ran at:', new Date()), + 1000, +) + +const timeoutIdNumber: number = Number(timeoutId) +``` + +#### Implementation of + +[`TimeoutProvider`](../type-aliases/TimeoutProvider.md).[`setTimeout`](../type-aliases/TimeoutProvider.md#settimeout) + +*** + +### setTimeoutProvider() + +```ts +setTimeoutProvider(provider): void; +``` + +Defined in: [packages/query-core/src/timeoutManager.ts:106](https://github.com/TanStack/query/blob/main/packages/query-core/src/timeoutManager.ts#L106) + +`setTimeoutProvider` can be used to set a custom implementation of the +`setTimeout`, `clearTimeout`, `setInterval`, `clearInterval` functions, +called a `TimeoutProvider`. + +This may be useful if you notice event loop performance issues with +thousands of queries. A custom TimeoutProvider could also support timer +delays longer than the global `setTimeout` maximum delay value of about +24 days. + +It is important to call `setTimeoutProvider` before creating a +QueryClient or queries, so that the same provider is used consistently +for all timers in the application, since different TimeoutProviders +cannot cancel each others' timers. + +#### Type Parameters + +##### TTimerId + +`TTimerId` *extends* [`ManagedTimerId`](../type-aliases/ManagedTimerId.md) + +#### Parameters + +##### provider + +[`TimeoutProvider`](../type-aliases/TimeoutProvider.md)\<`TTimerId`\> + +#### Returns + +`void` + +#### Example + +```ts +import { timeoutManager, QueryClient } from '@tanstack/query-core' +import { CustomTimeoutProvider } from './CustomTimeoutProvider' + +timeoutManager.setTimeoutProvider(new CustomTimeoutProvider()) + +export const queryClient = new QueryClient() +``` diff --git a/docs/framework/angular/reference/type-aliases/AnyDataTag.md b/docs/framework/angular/reference/type-aliases/AnyDataTag.md new file mode 100644 index 00000000000..d3d5e33bb3e --- /dev/null +++ b/docs/framework/angular/reference/type-aliases/AnyDataTag.md @@ -0,0 +1,30 @@ +--- +id: AnyDataTag +title: AnyDataTag +--- + +```ts +type AnyDataTag = object; +``` + +Defined in: [packages/query-core/src/types.ts:67](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L67) + +## Properties + +### \[dataTagErrorSymbol\] + +```ts +[dataTagErrorSymbol]: any; +``` + +Defined in: [packages/query-core/src/types.ts:69](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L69) + +*** + +### \[dataTagSymbol\] + +```ts +[dataTagSymbol]: any; +``` + +Defined in: [packages/query-core/src/types.ts:68](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L68) diff --git a/docs/framework/angular/reference/type-aliases/CreateBaseMutationResult.md b/docs/framework/angular/reference/type-aliases/CreateBaseMutationResult.md index f593d6ce62d..30408338654 100644 --- a/docs/framework/angular/reference/type-aliases/CreateBaseMutationResult.md +++ b/docs/framework/angular/reference/type-aliases/CreateBaseMutationResult.md @@ -9,10 +9,10 @@ type CreateBaseMutationResult = Over }> & object; ``` -Defined in: [types.ts:284](https://github.com/TanStack/query/blob/main/packages/angular-query-experimental/src/types.ts#L284) +Defined in: [packages/angular-query-experimental/src/types.ts:284](https://github.com/TanStack/query/blob/main/packages/angular-query-experimental/src/types.ts#L284) The pre-`Signal` shape [CreateMutationResult](CreateMutationResult.md) is built from — not what `injectMutation` actually -returns. Same as MutationObserverResult from `@tanstack/query-core`, with `mutate` narrowed to the +returns. Same as [MutationObserverResult](MutationObserverResult.md) from `@tanstack/query-core`, with `mutate` narrowed to the fire-and-forget [CreateMutateFunction](CreateMutateFunction.md) signature, plus the added `mutateAsync`. ## Type Declaration @@ -35,7 +35,7 @@ The type your mutation function resolves to. ### TError -`TError` = `DefaultError` +`TError` = [`DefaultError`](DefaultError.md) The type of errors your mutation function may throw. diff --git a/docs/framework/angular/reference/type-aliases/CreateBaseQueryResult.md b/docs/framework/angular/reference/type-aliases/CreateBaseQueryResult.md index 988a2074f36..f632a3e04a7 100644 --- a/docs/framework/angular/reference/type-aliases/CreateBaseQueryResult.md +++ b/docs/framework/angular/reference/type-aliases/CreateBaseQueryResult.md @@ -7,10 +7,10 @@ title: CreateBaseQueryResult type CreateBaseQueryResult = BaseQueryNarrowing & MapToSignals>; ``` -Defined in: [types.ts:149](https://github.com/TanStack/query/blob/main/packages/angular-query-experimental/src/types.ts#L149) +Defined in: [packages/angular-query-experimental/src/types.ts:149](https://github.com/TanStack/query/blob/main/packages/angular-query-experimental/src/types.ts#L149) The result of `injectQuery` when `initialData` isn't set — `data` may be `undefined` while the query is -`pending`. Same shape as QueryObserverResult from `@tanstack/query-core`, but value fields (like +`pending`. Same shape as [QueryObserverResult](QueryObserverResult.md) from `@tanstack/query-core`, but value fields (like `data`, `error`, `status`) are exposed as a `Signal` — read them with `query.data()`, not `query.data` — while function fields (like `refetch`) are called directly, unchanged. `isSuccess`/`isError`/`isPending` are [BaseQueryNarrowing](../interfaces/BaseQueryNarrowing.md) type-guard methods rather than plain booleans. @@ -26,10 +26,10 @@ The type `data` ends up as after `select` runs. ### TError -`TError` = `DefaultError` +`TError` = [`DefaultError`](DefaultError.md) The type of errors your `queryFn` may throw. ### TState -`TState` = `QueryObserverResult`\<`TData`, `TError`\> +`TState` = [`QueryObserverResult`](QueryObserverResult.md)\<`TData`, `TError`\> diff --git a/docs/framework/angular/reference/type-aliases/CreateInfiniteQueryResult.md b/docs/framework/angular/reference/type-aliases/CreateInfiniteQueryResult.md index b5d12e1b9d3..e0b6a6981f4 100644 --- a/docs/framework/angular/reference/type-aliases/CreateInfiniteQueryResult.md +++ b/docs/framework/angular/reference/type-aliases/CreateInfiniteQueryResult.md @@ -7,10 +7,10 @@ title: CreateInfiniteQueryResult type CreateInfiniteQueryResult = BaseQueryNarrowing & MapToSignals>; ``` -Defined in: [types.ts:191](https://github.com/TanStack/query/blob/main/packages/angular-query-experimental/src/types.ts#L191) +Defined in: [packages/angular-query-experimental/src/types.ts:191](https://github.com/TanStack/query/blob/main/packages/angular-query-experimental/src/types.ts#L191) The result of `injectInfiniteQuery` when `initialData` isn't set — `data` may be `undefined` while the -query is `pending`. Same shape as InfiniteQueryObserverResult from `@tanstack/query-core`, but +query is `pending`. Same shape as [InfiniteQueryObserverResult](InfiniteQueryObserverResult.md) from `@tanstack/query-core`, but value fields are exposed as a `Signal` while function fields (like `fetchNextPage`) are called directly, unchanged. @@ -24,6 +24,6 @@ The type `data` ends up as after `select` runs. ### TError -`TError` = `DefaultError` +`TError` = [`DefaultError`](DefaultError.md) The type of errors your `queryFn` may throw. diff --git a/docs/framework/angular/reference/type-aliases/CreateMutateAsyncFunction.md b/docs/framework/angular/reference/type-aliases/CreateMutateAsyncFunction.md index af507a45388..fe72322f8cd 100644 --- a/docs/framework/angular/reference/type-aliases/CreateMutateAsyncFunction.md +++ b/docs/framework/angular/reference/type-aliases/CreateMutateAsyncFunction.md @@ -7,7 +7,7 @@ title: CreateMutateAsyncFunction type CreateMutateAsyncFunction = MutateFunction; ``` -Defined in: [types.ts:266](https://github.com/TanStack/query/blob/main/packages/angular-query-experimental/src/types.ts#L266) +Defined in: [packages/angular-query-experimental/src/types.ts:266](https://github.com/TanStack/query/blob/main/packages/angular-query-experimental/src/types.ts#L266) The type of `mutateAsync`, as returned by `injectMutation`. Similar to [CreateMutateFunction](CreateMutateFunction.md), but returns a promise which can be awaited. @@ -22,7 +22,7 @@ The type your mutation function resolves to. ### TError -`TError` = `DefaultError` +`TError` = [`DefaultError`](DefaultError.md) The type of errors your mutation function may throw. diff --git a/docs/framework/angular/reference/type-aliases/CreateMutateFunction.md b/docs/framework/angular/reference/type-aliases/CreateMutateFunction.md index 62ffebc6351..9960203a068 100644 --- a/docs/framework/angular/reference/type-aliases/CreateMutateFunction.md +++ b/docs/framework/angular/reference/type-aliases/CreateMutateFunction.md @@ -7,7 +7,7 @@ title: CreateMutateFunction type CreateMutateFunction = (...args) => void; ``` -Defined in: [types.ts:245](https://github.com/TanStack/query/blob/main/packages/angular-query-experimental/src/types.ts#L245) +Defined in: [packages/angular-query-experimental/src/types.ts:245](https://github.com/TanStack/query/blob/main/packages/angular-query-experimental/src/types.ts#L245) The type of `mutate`, as returned by `injectMutation`. Forwards the variables (and an optional per-call `onSuccess`/`onError`/`onSettled`) to the underlying `mutate` call. Fire-and-forget — errors are surfaced @@ -23,7 +23,7 @@ The type your mutation function resolves to. ### TError -`TError` = `DefaultError` +`TError` = [`DefaultError`](DefaultError.md) The type of errors your mutation function may throw. @@ -44,7 +44,7 @@ their `onMutateResult` parameter — useful for optimistic-update rollback data. ### args -...`Parameters`\<`MutateFunction`\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\>\> +...`Parameters`\<[`MutateFunction`](MutateFunction.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\>\> ## Returns diff --git a/docs/framework/angular/reference/type-aliases/CreateMutationResult.md b/docs/framework/angular/reference/type-aliases/CreateMutationResult.md index a355e7a1eca..7a167bee22c 100644 --- a/docs/framework/angular/reference/type-aliases/CreateMutationResult.md +++ b/docs/framework/angular/reference/type-aliases/CreateMutationResult.md @@ -7,7 +7,7 @@ title: CreateMutationResult type CreateMutationResult = BaseMutationNarrowing & MapToSignals>; ``` -Defined in: [types.ts:416](https://github.com/TanStack/query/blob/main/packages/angular-query-experimental/src/types.ts#L416) +Defined in: [packages/angular-query-experimental/src/types.ts:416](https://github.com/TanStack/query/blob/main/packages/angular-query-experimental/src/types.ts#L416) The result of `injectMutation`. Based on [CreateBaseMutationResult](CreateBaseMutationResult.md), but value fields are exposed as a `Signal` — read them with `mutation.data()`, not `mutation.data` — while function fields (`mutate`, @@ -24,7 +24,7 @@ The type your mutation function resolves to. ### TError -`TError` = `DefaultError` +`TError` = [`DefaultError`](DefaultError.md) The type of errors your mutation function may throw. diff --git a/docs/framework/angular/reference/type-aliases/CreateQueryResult.md b/docs/framework/angular/reference/type-aliases/CreateQueryResult.md index c1a4fb1bc5d..2e57945064b 100644 --- a/docs/framework/angular/reference/type-aliases/CreateQueryResult.md +++ b/docs/framework/angular/reference/type-aliases/CreateQueryResult.md @@ -7,7 +7,7 @@ title: CreateQueryResult type CreateQueryResult = CreateBaseQueryResult; ``` -Defined in: [types.ts:162](https://github.com/TanStack/query/blob/main/packages/angular-query-experimental/src/types.ts#L162) +Defined in: [packages/angular-query-experimental/src/types.ts:162](https://github.com/TanStack/query/blob/main/packages/angular-query-experimental/src/types.ts#L162) The result of `injectQuery`. Same as [CreateBaseQueryResult](CreateBaseQueryResult.md). @@ -21,6 +21,6 @@ The type `data` ends up as after `select` runs. ### TError -`TError` = `DefaultError` +`TError` = [`DefaultError`](DefaultError.md) The type of errors your `queryFn` may throw. diff --git a/docs/framework/angular/reference/type-aliases/DataTag.md b/docs/framework/angular/reference/type-aliases/DataTag.md new file mode 100644 index 00000000000..904ca124464 --- /dev/null +++ b/docs/framework/angular/reference/type-aliases/DataTag.md @@ -0,0 +1,24 @@ +--- +id: DataTag +title: DataTag +--- + +```ts +type DataTag = TType extends AnyDataTag ? TType : TType & object; +``` + +Defined in: [packages/query-core/src/types.ts:71](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L71) + +## Type Parameters + +### TType + +`TType` + +### TValue + +`TValue` + +### TError + +`TError` = [`UnsetMarker`](UnsetMarker.md) diff --git a/docs/framework/angular/reference/type-aliases/DefaultError.md b/docs/framework/angular/reference/type-aliases/DefaultError.md new file mode 100644 index 00000000000..da9f615482f --- /dev/null +++ b/docs/framework/angular/reference/type-aliases/DefaultError.md @@ -0,0 +1,10 @@ +--- +id: DefaultError +title: DefaultError +--- + +```ts +type DefaultError = Register extends object ? TError : Error; +``` + +Defined in: [packages/query-core/src/types.ts:45](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L45) diff --git a/docs/framework/angular/reference/type-aliases/DefaultedInfiniteQueryObserverOptions.md b/docs/framework/angular/reference/type-aliases/DefaultedInfiniteQueryObserverOptions.md new file mode 100644 index 00000000000..82c7ddbb886 --- /dev/null +++ b/docs/framework/angular/reference/type-aliases/DefaultedInfiniteQueryObserverOptions.md @@ -0,0 +1,32 @@ +--- +id: DefaultedInfiniteQueryObserverOptions +title: DefaultedInfiniteQueryObserverOptions +--- + +```ts +type DefaultedInfiniteQueryObserverOptions = WithRequired, "throwOnError" | "refetchOnReconnect" | "queryHash">; +``` + +Defined in: [packages/query-core/src/types.ts:557](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L557) + +## Type Parameters + +### TQueryFnData + +`TQueryFnData` = `unknown` + +### TError + +`TError` = [`DefaultError`](DefaultError.md) + +### TData + +`TData` = `TQueryFnData` + +### TQueryKey + +`TQueryKey` *extends* [`QueryKey`](QueryKey.md) = [`QueryKey`](QueryKey.md) + +### TPageParam + +`TPageParam` = `unknown` diff --git a/docs/framework/angular/reference/type-aliases/DefaultedQueryObserverOptions.md b/docs/framework/angular/reference/type-aliases/DefaultedQueryObserverOptions.md new file mode 100644 index 00000000000..7687d8c24f6 --- /dev/null +++ b/docs/framework/angular/reference/type-aliases/DefaultedQueryObserverOptions.md @@ -0,0 +1,32 @@ +--- +id: DefaultedQueryObserverOptions +title: DefaultedQueryObserverOptions +--- + +```ts +type DefaultedQueryObserverOptions = WithRequired, "throwOnError" | "refetchOnReconnect" | "queryHash">; +``` + +Defined in: [packages/query-core/src/types.ts:528](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L528) + +## Type Parameters + +### TQueryFnData + +`TQueryFnData` = `unknown` + +### TError + +`TError` = [`DefaultError`](DefaultError.md) + +### TData + +`TData` = `TQueryFnData` + +### TQueryData + +`TQueryData` = `TQueryFnData` + +### TQueryKey + +`TQueryKey` *extends* [`QueryKey`](QueryKey.md) = [`QueryKey`](QueryKey.md) diff --git a/docs/framework/angular/reference/type-aliases/DefinedCreateInfiniteQueryResult.md b/docs/framework/angular/reference/type-aliases/DefinedCreateInfiniteQueryResult.md index 4b56723f9ab..382b86bdbd1 100644 --- a/docs/framework/angular/reference/type-aliases/DefinedCreateInfiniteQueryResult.md +++ b/docs/framework/angular/reference/type-aliases/DefinedCreateInfiniteQueryResult.md @@ -7,10 +7,10 @@ title: DefinedCreateInfiniteQueryResult type DefinedCreateInfiniteQueryResult = MapToSignals; ``` -Defined in: [types.ts:205](https://github.com/TanStack/query/blob/main/packages/angular-query-experimental/src/types.ts#L205) +Defined in: [packages/angular-query-experimental/src/types.ts:205](https://github.com/TanStack/query/blob/main/packages/angular-query-experimental/src/types.ts#L205) The result of `injectInfiniteQuery` when `initialData` is set — `data` is never `undefined`. Same shape as -DefinedInfiniteQueryObserverResult from `@tanstack/query-core`, but value fields are exposed as a +[DefinedInfiniteQueryObserverResult](DefinedInfiniteQueryObserverResult.md) from `@tanstack/query-core`, but value fields are exposed as a `Signal` while function fields are called directly, unchanged. ## Type Parameters @@ -23,10 +23,10 @@ The type `data` ends up as after `select` runs. ### TError -`TError` = `DefaultError` +`TError` = [`DefaultError`](DefaultError.md) The type of errors your `queryFn` may throw. ### TDefinedInfiniteQueryObserver -`TDefinedInfiniteQueryObserver` = `DefinedInfiniteQueryObserverResult`\<`TData`, `TError`\> +`TDefinedInfiniteQueryObserver` = [`DefinedInfiniteQueryObserverResult`](DefinedInfiniteQueryObserverResult.md)\<`TData`, `TError`\> diff --git a/docs/framework/angular/reference/type-aliases/DefinedCreateQueryResult.md b/docs/framework/angular/reference/type-aliases/DefinedCreateQueryResult.md index 36e9b1de9de..934f51485d1 100644 --- a/docs/framework/angular/reference/type-aliases/DefinedCreateQueryResult.md +++ b/docs/framework/angular/reference/type-aliases/DefinedCreateQueryResult.md @@ -7,10 +7,10 @@ title: DefinedCreateQueryResult type DefinedCreateQueryResult = BaseQueryNarrowing & MapToSignals>; ``` -Defined in: [types.ts:175](https://github.com/TanStack/query/blob/main/packages/angular-query-experimental/src/types.ts#L175) +Defined in: [packages/angular-query-experimental/src/types.ts:175](https://github.com/TanStack/query/blob/main/packages/angular-query-experimental/src/types.ts#L175) The result of `injectQuery` when `initialData` is set — `data` is never `undefined`. Same shape as -DefinedQueryObserverResult from `@tanstack/query-core`, but value fields are exposed as a +[DefinedQueryObserverResult](DefinedQueryObserverResult.md) from `@tanstack/query-core`, but value fields are exposed as a `Signal` while function fields are called directly, unchanged. ## Type Parameters @@ -23,10 +23,10 @@ The type `data` ends up as after `select` runs. ### TError -`TError` = `DefaultError` +`TError` = [`DefaultError`](DefaultError.md) The type of errors your `queryFn` may throw. ### TState -`TState` = `DefinedQueryObserverResult`\<`TData`, `TError`\> +`TState` = [`DefinedQueryObserverResult`](DefinedQueryObserverResult.md)\<`TData`, `TError`\> diff --git a/docs/framework/angular/reference/type-aliases/DefinedInfiniteQueryObserverResult.md b/docs/framework/angular/reference/type-aliases/DefinedInfiniteQueryObserverResult.md new file mode 100644 index 00000000000..38dac7cfe2b --- /dev/null +++ b/docs/framework/angular/reference/type-aliases/DefinedInfiniteQueryObserverResult.md @@ -0,0 +1,22 @@ +--- +id: DefinedInfiniteQueryObserverResult +title: DefinedInfiniteQueryObserverResult +--- + +```ts +type DefinedInfiniteQueryObserverResult = + | InfiniteQueryObserverRefetchErrorResult +| InfiniteQueryObserverSuccessResult; +``` + +Defined in: [packages/query-core/src/types.ts:1148](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1148) + +## Type Parameters + +### TData + +`TData` = `unknown` + +### TError + +`TError` = [`DefaultError`](DefaultError.md) diff --git a/docs/framework/angular/reference/type-aliases/DefinedInitialDataInfiniteOptions.md b/docs/framework/angular/reference/type-aliases/DefinedInitialDataInfiniteOptions.md index b0cef845357..d4b42457136 100644 --- a/docs/framework/angular/reference/type-aliases/DefinedInitialDataInfiniteOptions.md +++ b/docs/framework/angular/reference/type-aliases/DefinedInitialDataInfiniteOptions.md @@ -7,7 +7,7 @@ title: DefinedInitialDataInfiniteOptions type DefinedInitialDataInfiniteOptions = CreateInfiniteQueryOptions & object; ``` -Defined in: [infinite-query-options.ts:109](https://github.com/TanStack/query/blob/main/packages/angular-query-experimental/src/infinite-query-options.ts#L109) +Defined in: [packages/angular-query-experimental/src/infinite-query-options.ts:109](https://github.com/TanStack/query/blob/main/packages/angular-query-experimental/src/infinite-query-options.ts#L109) The options accepted by the `infiniteQueryOptions` overload selected when `initialData` is set — `data` is never `undefined` (unless a `select` changes `TData` to include `undefined`). @@ -39,20 +39,20 @@ The type of a single page, as your `queryFn` resolves it. ### TError -`TError` = `DefaultError` +`TError` = [`DefaultError`](DefaultError.md) The type of errors your `queryFn` may throw. ### TData -`TData` = `InfiniteData`\<`TQueryFnData`\> +`TData` = [`InfiniteData`](../interfaces/InfiniteData.md)\<`TQueryFnData`\> The type `data` ends up as after `select` runs — defaults to `InfiniteData`, the shape of all fetched pages plus their page params. ### TQueryKey -`TQueryKey` *extends* `QueryKey` = `QueryKey` +`TQueryKey` *extends* [`QueryKey`](QueryKey.md) = [`QueryKey`](QueryKey.md) The type of your `queryKey`. diff --git a/docs/framework/angular/reference/type-aliases/DefinedInitialDataOptions.md b/docs/framework/angular/reference/type-aliases/DefinedInitialDataOptions.md index 36e867b0423..e37476fa74d 100644 --- a/docs/framework/angular/reference/type-aliases/DefinedInitialDataOptions.md +++ b/docs/framework/angular/reference/type-aliases/DefinedInitialDataOptions.md @@ -7,7 +7,7 @@ title: DefinedInitialDataOptions type DefinedInitialDataOptions = Omit, "queryFn"> & object; ``` -Defined in: [query-options.ts:80](https://github.com/TanStack/query/blob/main/packages/angular-query-experimental/src/query-options.ts#L80) +Defined in: [packages/angular-query-experimental/src/query-options.ts:80](https://github.com/TanStack/query/blob/main/packages/angular-query-experimental/src/query-options.ts#L80) The options accepted by the `queryOptions` overload selected when `initialData` is set — `data` is never `undefined` (unless a `select` changes `TData` to include `undefined`). @@ -48,7 +48,7 @@ The type your `queryFn` resolves to. ### TError -`TError` = `DefaultError` +`TError` = [`DefaultError`](DefaultError.md) The type of errors your `queryFn` may throw. @@ -60,6 +60,6 @@ The type `data` ends up as after `select` runs. ### TQueryKey -`TQueryKey` *extends* `QueryKey` = `QueryKey` +`TQueryKey` *extends* [`QueryKey`](QueryKey.md) = [`QueryKey`](QueryKey.md) The type of your `queryKey`. diff --git a/docs/framework/angular/reference/type-aliases/DefinedQueryObserverResult.md b/docs/framework/angular/reference/type-aliases/DefinedQueryObserverResult.md new file mode 100644 index 00000000000..ae77ddcc22d --- /dev/null +++ b/docs/framework/angular/reference/type-aliases/DefinedQueryObserverResult.md @@ -0,0 +1,22 @@ +--- +id: DefinedQueryObserverResult +title: DefinedQueryObserverResult +--- + +```ts +type DefinedQueryObserverResult = + | QueryObserverRefetchErrorResult +| QueryObserverSuccessResult; +``` + +Defined in: [packages/query-core/src/types.ts:987](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L987) + +## Type Parameters + +### TData + +`TData` = `unknown` + +### TError + +`TError` = [`DefaultError`](DefaultError.md) diff --git a/docs/framework/angular/reference/type-aliases/DevtoolsFeature.md b/docs/framework/angular/reference/type-aliases/DevtoolsFeature.md index 2ec2614ef8b..2db12a400ab 100644 --- a/docs/framework/angular/reference/type-aliases/DevtoolsFeature.md +++ b/docs/framework/angular/reference/type-aliases/DevtoolsFeature.md @@ -7,7 +7,7 @@ title: DevtoolsFeature type DevtoolsFeature = QueryFeature<"Devtools">; ``` -Defined in: [providers.ts:155](https://github.com/TanStack/query/blob/main/packages/angular-query-experimental/src/providers.ts#L155) +Defined in: [packages/angular-query-experimental/src/providers.ts:155](https://github.com/TanStack/query/blob/main/packages/angular-query-experimental/src/providers.ts#L155) A type alias that represents a feature which enables developer tools. The type is used to describe the return value of the `withDevtools` function. diff --git a/docs/framework/angular/reference/type-aliases/DistributiveOmit.md b/docs/framework/angular/reference/type-aliases/DistributiveOmit.md new file mode 100644 index 00000000000..33b87a5cd6e --- /dev/null +++ b/docs/framework/angular/reference/type-aliases/DistributiveOmit.md @@ -0,0 +1,20 @@ +--- +id: DistributiveOmit +title: DistributiveOmit +--- + +```ts +type DistributiveOmit = TObject extends any ? Omit : never; +``` + +Defined in: [packages/query-core/src/types.ts:14](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L14) + +## Type Parameters + +### TObject + +`TObject` + +### TKey + +`TKey` *extends* keyof `TObject` diff --git a/docs/framework/angular/reference/type-aliases/EnsureInfiniteQueryDataOptions.md b/docs/framework/angular/reference/type-aliases/EnsureInfiniteQueryDataOptions.md new file mode 100644 index 00000000000..7648331fca2 --- /dev/null +++ b/docs/framework/angular/reference/type-aliases/EnsureInfiniteQueryDataOptions.md @@ -0,0 +1,42 @@ +--- +id: EnsureInfiniteQueryDataOptions +title: EnsureInfiniteQueryDataOptions +--- + +```ts +type EnsureInfiniteQueryDataOptions = FetchInfiniteQueryOptions & object; +``` + +Defined in: [packages/query-core/src/types.ts:631](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L631) + +## Type Declaration + +### ~~revalidateIfStale?~~ + +```ts +optional revalidateIfStale: boolean; +``` + +## Type Parameters + +### TQueryFnData + +`TQueryFnData` = `unknown` + +### TError + +`TError` = [`DefaultError`](DefaultError.md) + +### TData + +`TData` = `TQueryFnData` + +### TQueryKey + +`TQueryKey` *extends* [`QueryKey`](QueryKey.md) = [`QueryKey`](QueryKey.md) + +### TPageParam + +`TPageParam` = `unknown` + +## Deprecated diff --git a/docs/framework/angular/reference/type-aliases/FetchInfiniteQueryOptions.md b/docs/framework/angular/reference/type-aliases/FetchInfiniteQueryOptions.md new file mode 100644 index 00000000000..d00a2455889 --- /dev/null +++ b/docs/framework/angular/reference/type-aliases/FetchInfiniteQueryOptions.md @@ -0,0 +1,34 @@ +--- +id: FetchInfiniteQueryOptions +title: FetchInfiniteQueryOptions +--- + +```ts +type FetchInfiniteQueryOptions = Omit, TQueryKey, TPageParam>, "initialPageParam"> & InitialPageParam & InfiniteQueryPages; +``` + +Defined in: [packages/query-core/src/types.ts:675](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L675) + +## Type Parameters + +### TQueryFnData + +`TQueryFnData` = `unknown` + +### TError + +`TError` = [`DefaultError`](DefaultError.md) + +### TData + +`TData` = `TQueryFnData` + +### TQueryKey + +`TQueryKey` *extends* [`QueryKey`](QueryKey.md) = [`QueryKey`](QueryKey.md) + +### TPageParam + +`TPageParam` = `unknown` + +## Deprecated diff --git a/docs/framework/angular/reference/type-aliases/FetchStatus.md b/docs/framework/angular/reference/type-aliases/FetchStatus.md new file mode 100644 index 00000000000..d50002355ca --- /dev/null +++ b/docs/framework/angular/reference/type-aliases/FetchStatus.md @@ -0,0 +1,10 @@ +--- +id: FetchStatus +title: FetchStatus +--- + +```ts +type FetchStatus = "fetching" | "paused" | "idle"; +``` + +Defined in: [packages/query-core/src/types.ts:762](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L762) diff --git a/docs/framework/angular/reference/type-aliases/GetNextPageParamFunction.md b/docs/framework/angular/reference/type-aliases/GetNextPageParamFunction.md new file mode 100644 index 00000000000..81d1a1544ab --- /dev/null +++ b/docs/framework/angular/reference/type-aliases/GetNextPageParamFunction.md @@ -0,0 +1,42 @@ +--- +id: GetNextPageParamFunction +title: GetNextPageParamFunction +--- + +```ts +type GetNextPageParamFunction = (lastPage, allPages, lastPageParam, allPageParams) => TPageParam | undefined | null; +``` + +Defined in: [packages/query-core/src/types.ts:203](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L203) + +## Type Parameters + +### TPageParam + +`TPageParam` + +### TQueryFnData + +`TQueryFnData` = `unknown` + +## Parameters + +### lastPage + +`TQueryFnData` + +### allPages + +`TQueryFnData`[] + +### lastPageParam + +`TPageParam` + +### allPageParams + +`TPageParam`[] + +## Returns + +`TPageParam` \| `undefined` \| `null` diff --git a/docs/framework/angular/reference/type-aliases/GetPreviousPageParamFunction.md b/docs/framework/angular/reference/type-aliases/GetPreviousPageParamFunction.md new file mode 100644 index 00000000000..5a6d9b93d7e --- /dev/null +++ b/docs/framework/angular/reference/type-aliases/GetPreviousPageParamFunction.md @@ -0,0 +1,42 @@ +--- +id: GetPreviousPageParamFunction +title: GetPreviousPageParamFunction +--- + +```ts +type GetPreviousPageParamFunction = (firstPage, allPages, firstPageParam, allPageParams) => TPageParam | undefined | null; +``` + +Defined in: [packages/query-core/src/types.ts:196](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L196) + +## Type Parameters + +### TPageParam + +`TPageParam` + +### TQueryFnData + +`TQueryFnData` = `unknown` + +## Parameters + +### firstPage + +`TQueryFnData` + +### allPages + +`TQueryFnData`[] + +### firstPageParam + +`TPageParam` + +### allPageParams + +`TPageParam`[] + +## Returns + +`TPageParam` \| `undefined` \| `null` diff --git a/docs/framework/angular/reference/type-aliases/InferDataFromTag.md b/docs/framework/angular/reference/type-aliases/InferDataFromTag.md new file mode 100644 index 00000000000..09a15ca4b1c --- /dev/null +++ b/docs/framework/angular/reference/type-aliases/InferDataFromTag.md @@ -0,0 +1,20 @@ +--- +id: InferDataFromTag +title: InferDataFromTag +--- + +```ts +type InferDataFromTag = TTaggedQueryKey extends DataTag ? TaggedValue : TQueryFnData; +``` + +Defined in: [packages/query-core/src/types.ts:90](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L90) + +## Type Parameters + +### TQueryFnData + +`TQueryFnData` + +### TTaggedQueryKey + +`TTaggedQueryKey` *extends* [`QueryKey`](QueryKey.md) diff --git a/docs/framework/angular/reference/type-aliases/InferErrorFromTag.md b/docs/framework/angular/reference/type-aliases/InferErrorFromTag.md new file mode 100644 index 00000000000..cd94e4b5c3f --- /dev/null +++ b/docs/framework/angular/reference/type-aliases/InferErrorFromTag.md @@ -0,0 +1,20 @@ +--- +id: InferErrorFromTag +title: InferErrorFromTag +--- + +```ts +type InferErrorFromTag = TTaggedQueryKey extends DataTag ? TaggedError extends UnsetMarker ? TError : TaggedError : TError; +``` + +Defined in: [packages/query-core/src/types.ts:95](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L95) + +## Type Parameters + +### TError + +`TError` + +### TTaggedQueryKey + +`TTaggedQueryKey` *extends* [`QueryKey`](QueryKey.md) diff --git a/docs/framework/angular/reference/type-aliases/InfiniteQueryExecuteOptions.md b/docs/framework/angular/reference/type-aliases/InfiniteQueryExecuteOptions.md new file mode 100644 index 00000000000..259c97c96bb --- /dev/null +++ b/docs/framework/angular/reference/type-aliases/InfiniteQueryExecuteOptions.md @@ -0,0 +1,32 @@ +--- +id: InfiniteQueryExecuteOptions +title: InfiniteQueryExecuteOptions +--- + +```ts +type InfiniteQueryExecuteOptions = Omit, TQueryKey, TPageParam>, "initialPageParam"> & InitialPageParam & InfiniteQueryPages; +``` + +Defined in: [packages/query-core/src/types.ts:654](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L654) + +## Type Parameters + +### TQueryFnData + +`TQueryFnData` = `unknown` + +### TError + +`TError` = [`DefaultError`](DefaultError.md) + +### TData + +`TData` = [`InfiniteData`](../interfaces/InfiniteData.md)\<`TQueryFnData`\> + +### TQueryKey + +`TQueryKey` *extends* [`QueryKey`](QueryKey.md) = [`QueryKey`](QueryKey.md) + +### TPageParam + +`TPageParam` = `unknown` diff --git a/docs/framework/angular/reference/type-aliases/InfiniteQueryObserverResult.md b/docs/framework/angular/reference/type-aliases/InfiniteQueryObserverResult.md new file mode 100644 index 00000000000..aa27563b9cd --- /dev/null +++ b/docs/framework/angular/reference/type-aliases/InfiniteQueryObserverResult.md @@ -0,0 +1,25 @@ +--- +id: InfiniteQueryObserverResult +title: InfiniteQueryObserverResult +--- + +```ts +type InfiniteQueryObserverResult = + | DefinedInfiniteQueryObserverResult + | InfiniteQueryObserverLoadingErrorResult + | InfiniteQueryObserverLoadingResult + | InfiniteQueryObserverPendingResult +| InfiniteQueryObserverPlaceholderResult; +``` + +Defined in: [packages/query-core/src/types.ts:1155](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1155) + +## Type Parameters + +### TData + +`TData` = `unknown` + +### TError + +`TError` = [`DefaultError`](DefaultError.md) diff --git a/docs/framework/angular/reference/type-aliases/InitialDataFunction.md b/docs/framework/angular/reference/type-aliases/InitialDataFunction.md new file mode 100644 index 00000000000..6ba4aaabe61 --- /dev/null +++ b/docs/framework/angular/reference/type-aliases/InitialDataFunction.md @@ -0,0 +1,20 @@ +--- +id: InitialDataFunction +title: InitialDataFunction +--- + +```ts +type InitialDataFunction = () => T | undefined; +``` + +Defined in: [packages/query-core/src/types.ts:173](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L173) + +## Type Parameters + +### T + +`T` + +## Returns + +`T` \| `undefined` diff --git a/docs/framework/angular/reference/type-aliases/ManagedTimerId.md b/docs/framework/angular/reference/type-aliases/ManagedTimerId.md new file mode 100644 index 00000000000..d7833e3e4f0 --- /dev/null +++ b/docs/framework/angular/reference/type-aliases/ManagedTimerId.md @@ -0,0 +1,19 @@ +--- +id: ManagedTimerId +title: ManagedTimerId +--- + +```ts +type ManagedTimerId = + | number + | { + [toPrimitive]: () => number; +}; +``` + +Defined in: [packages/query-core/src/timeoutManager.ts:17](https://github.com/TanStack/query/blob/main/packages/query-core/src/timeoutManager.ts#L17) + +Wrapping `setTimeout` is awkward from a typing perspective because platform +typings may extend the return type of `setTimeout`. For example, NodeJS +typings add `NodeJS.Timeout`; but a non-default `timeoutManager` may not be +able to return such a type. diff --git a/docs/framework/angular/reference/type-aliases/MutateFunction.md b/docs/framework/angular/reference/type-aliases/MutateFunction.md new file mode 100644 index 00000000000..e12b7a80291 --- /dev/null +++ b/docs/framework/angular/reference/type-aliases/MutateFunction.md @@ -0,0 +1,38 @@ +--- +id: MutateFunction +title: MutateFunction +--- + +```ts +type MutateFunction = (...rest) => Promise; +``` + +Defined in: [packages/query-core/src/types.ts:1326](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1326) + +## Type Parameters + +### TData + +`TData` = `unknown` + +### TError + +`TError` = [`DefaultError`](DefaultError.md) + +### TVariables + +`TVariables` = `void` + +### TOnMutateResult + +`TOnMutateResult` = `unknown` + +## Parameters + +### rest + +...[`MutateFunctionRest`](MutateFunctionRest.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\> + +## Returns + +`Promise`\<`TData`\> diff --git a/docs/framework/angular/reference/type-aliases/MutateFunctionRest.md b/docs/framework/angular/reference/type-aliases/MutateFunctionRest.md new file mode 100644 index 00000000000..3902f1082f9 --- /dev/null +++ b/docs/framework/angular/reference/type-aliases/MutateFunctionRest.md @@ -0,0 +1,28 @@ +--- +id: MutateFunctionRest +title: MutateFunctionRest +--- + +```ts +type MutateFunctionRest = undefined extends TVariables ? [TVariables, MutateOptions] : [TVariables, MutateOptions]; +``` + +Defined in: [packages/query-core/src/types.ts:1311](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1311) + +## Type Parameters + +### TData + +`TData` = `unknown` + +### TError + +`TError` = [`DefaultError`](DefaultError.md) + +### TVariables + +`TVariables` = `void` + +### TOnMutateResult + +`TOnMutateResult` = `unknown` diff --git a/docs/framework/angular/reference/type-aliases/MutationCacheNotifyEvent.md b/docs/framework/angular/reference/type-aliases/MutationCacheNotifyEvent.md new file mode 100644 index 00000000000..aa5e196bc72 --- /dev/null +++ b/docs/framework/angular/reference/type-aliases/MutationCacheNotifyEvent.md @@ -0,0 +1,20 @@ +--- +id: MutationCacheNotifyEvent +title: MutationCacheNotifyEvent +--- + +```ts +type MutationCacheNotifyEvent = + | NotifyEventMutationAdded + | NotifyEventMutationRemoved + | NotifyEventMutationObserverAdded + | NotifyEventMutationObserverRemoved + | NotifyEventMutationObserverOptionsUpdated + | NotifyEventMutationUpdated; +``` + +Defined in: [packages/query-core/src/mutationCache.ts:98](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationCache.ts#L98) + +The event passed to a `MutationCache` subscriber. Fired whenever a mutation is added or removed +from the cache, its state is updated, or one of its observers is added, removed, or has its +options updated. diff --git a/docs/framework/angular/reference/type-aliases/MutationFunction.md b/docs/framework/angular/reference/type-aliases/MutationFunction.md new file mode 100644 index 00000000000..9bafb3db56b --- /dev/null +++ b/docs/framework/angular/reference/type-aliases/MutationFunction.md @@ -0,0 +1,34 @@ +--- +id: MutationFunction +title: MutationFunction +--- + +```ts +type MutationFunction = (variables, context) => Promise; +``` + +Defined in: [packages/query-core/src/types.ts:1195](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1195) + +## Type Parameters + +### TData + +`TData` = `unknown` + +### TVariables + +`TVariables` = `unknown` + +## Parameters + +### variables + +`TVariables` + +### context + +[`MutationFunctionContext`](MutationFunctionContext.md) + +## Returns + +`Promise`\<`TData`\> diff --git a/docs/framework/angular/reference/type-aliases/MutationFunctionContext.md b/docs/framework/angular/reference/type-aliases/MutationFunctionContext.md new file mode 100644 index 00000000000..0207256c702 --- /dev/null +++ b/docs/framework/angular/reference/type-aliases/MutationFunctionContext.md @@ -0,0 +1,40 @@ +--- +id: MutationFunctionContext +title: MutationFunctionContext +--- + +```ts +type MutationFunctionContext = object; +``` + +Defined in: [packages/query-core/src/types.ts:1189](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1189) + +## Properties + +### client + +```ts +client: QueryClient; +``` + +Defined in: [packages/query-core/src/types.ts:1190](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1190) + +*** + +### meta + +```ts +meta: MutationMeta | undefined; +``` + +Defined in: [packages/query-core/src/types.ts:1191](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1191) + +*** + +### mutationKey? + +```ts +optional mutationKey: MutationKey; +``` + +Defined in: [packages/query-core/src/types.ts:1192](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1192) diff --git a/docs/framework/angular/reference/type-aliases/MutationKey.md b/docs/framework/angular/reference/type-aliases/MutationKey.md new file mode 100644 index 00000000000..9d1d7f0f77b --- /dev/null +++ b/docs/framework/angular/reference/type-aliases/MutationKey.md @@ -0,0 +1,10 @@ +--- +id: MutationKey +title: MutationKey +--- + +```ts +type MutationKey = Register extends object ? TMutationKey extends ReadonlyArray ? TMutationKey : TMutationKey extends unknown[] ? TMutationKey : ReadonlyArray : ReadonlyArray; +``` + +Defined in: [packages/query-core/src/types.ts:1165](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1165) diff --git a/docs/framework/angular/reference/type-aliases/MutationMeta.md b/docs/framework/angular/reference/type-aliases/MutationMeta.md new file mode 100644 index 00000000000..ff1f9b4bf94 --- /dev/null +++ b/docs/framework/angular/reference/type-aliases/MutationMeta.md @@ -0,0 +1,10 @@ +--- +id: MutationMeta +title: MutationMeta +--- + +```ts +type MutationMeta = Register extends object ? TMutationMeta extends Record ? TMutationMeta : Record : Record; +``` + +Defined in: [packages/query-core/src/types.ts:1181](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1181) diff --git a/docs/framework/angular/reference/type-aliases/MutationObserverResult.md b/docs/framework/angular/reference/type-aliases/MutationObserverResult.md new file mode 100644 index 00000000000..c21fc3ac591 --- /dev/null +++ b/docs/framework/angular/reference/type-aliases/MutationObserverResult.md @@ -0,0 +1,32 @@ +--- +id: MutationObserverResult +title: MutationObserverResult +--- + +```ts +type MutationObserverResult = + | MutationObserverIdleResult + | MutationObserverLoadingResult + | MutationObserverErrorResult +| MutationObserverSuccessResult; +``` + +Defined in: [packages/query-core/src/types.ts:1484](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1484) + +## Type Parameters + +### TData + +`TData` = `unknown` + +### TError + +`TError` = [`DefaultError`](DefaultError.md) + +### TVariables + +`TVariables` = `void` + +### TOnMutateResult + +`TOnMutateResult` = `unknown` diff --git a/docs/framework/angular/reference/type-aliases/MutationScope.md b/docs/framework/angular/reference/type-aliases/MutationScope.md new file mode 100644 index 00000000000..1d6a91bd434 --- /dev/null +++ b/docs/framework/angular/reference/type-aliases/MutationScope.md @@ -0,0 +1,20 @@ +--- +id: MutationScope +title: MutationScope +--- + +```ts +type MutationScope = object; +``` + +Defined in: [packages/query-core/src/types.ts:1177](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1177) + +## Properties + +### id + +```ts +id: string; +``` + +Defined in: [packages/query-core/src/types.ts:1178](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1178) diff --git a/docs/framework/angular/reference/type-aliases/MutationStatus.md b/docs/framework/angular/reference/type-aliases/MutationStatus.md new file mode 100644 index 00000000000..cf12d3d3ee3 --- /dev/null +++ b/docs/framework/angular/reference/type-aliases/MutationStatus.md @@ -0,0 +1,10 @@ +--- +id: MutationStatus +title: MutationStatus +--- + +```ts +type MutationStatus = "idle" | "pending" | "success" | "error"; +``` + +Defined in: [packages/query-core/src/types.ts:1175](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1175) diff --git a/docs/framework/angular/reference/type-aliases/NetworkMode.md b/docs/framework/angular/reference/type-aliases/NetworkMode.md new file mode 100644 index 00000000000..94ae0ba76ed --- /dev/null +++ b/docs/framework/angular/reference/type-aliases/NetworkMode.md @@ -0,0 +1,10 @@ +--- +id: NetworkMode +title: NetworkMode +--- + +```ts +type NetworkMode = "online" | "always" | "offlineFirst"; +``` + +Defined in: [packages/query-core/src/types.ts:223](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L223) diff --git a/docs/framework/angular/reference/type-aliases/NonUndefinedGuard.md b/docs/framework/angular/reference/type-aliases/NonUndefinedGuard.md new file mode 100644 index 00000000000..4aaf208013b --- /dev/null +++ b/docs/framework/angular/reference/type-aliases/NonUndefinedGuard.md @@ -0,0 +1,16 @@ +--- +id: NonUndefinedGuard +title: NonUndefinedGuard +--- + +```ts +type NonUndefinedGuard = T extends undefined ? never : T; +``` + +Defined in: [packages/query-core/src/types.ts:12](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L12) + +## Type Parameters + +### T + +`T` diff --git a/docs/framework/angular/reference/type-aliases/NotifyEventType.md b/docs/framework/angular/reference/type-aliases/NotifyEventType.md new file mode 100644 index 00000000000..ffa60b016e3 --- /dev/null +++ b/docs/framework/angular/reference/type-aliases/NotifyEventType.md @@ -0,0 +1,17 @@ +--- +id: NotifyEventType +title: NotifyEventType +--- + +```ts +type NotifyEventType = + | "added" + | "removed" + | "updated" + | "observerAdded" + | "observerRemoved" + | "observerResultsUpdated" + | "observerOptionsUpdated"; +``` + +Defined in: [packages/query-core/src/types.ts:1530](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1530) diff --git a/docs/framework/angular/reference/type-aliases/NotifyOnChangeProps.md b/docs/framework/angular/reference/type-aliases/NotifyOnChangeProps.md new file mode 100644 index 00000000000..7de194fa10b --- /dev/null +++ b/docs/framework/angular/reference/type-aliases/NotifyOnChangeProps.md @@ -0,0 +1,17 @@ +--- +id: NotifyOnChangeProps +title: NotifyOnChangeProps +--- + +```ts +type NotifyOnChangeProps = + | keyof InfiniteQueryObserverResult[] + | "all" + | undefined + | () => + | keyof InfiniteQueryObserverResult[] + | "all" + | undefined; +``` + +Defined in: [packages/query-core/src/types.ts:225](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L225) diff --git a/docs/framework/angular/reference/type-aliases/OmitKeyof.md b/docs/framework/angular/reference/type-aliases/OmitKeyof.md new file mode 100644 index 00000000000..690a7b0a5d2 --- /dev/null +++ b/docs/framework/angular/reference/type-aliases/OmitKeyof.md @@ -0,0 +1,28 @@ +--- +id: OmitKeyof +title: OmitKeyof +--- + +```ts +type OmitKeyof = Omit; +``` + +Defined in: [packages/query-core/src/types.ts:19](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L19) + +## Type Parameters + +### TObject + +`TObject` + +### TKey + +`TKey` *extends* `TStrictly` *extends* `"safely"` ? + \| keyof `TObject` + \| `string` & `Record`\<`never`, `never`\> + \| `number` & `Record`\<`never`, `never`\> + \| `symbol` & `Record`\<`never`, `never`\> : keyof `TObject` + +### TStrictly + +`TStrictly` *extends* `"strictly"` \| `"safely"` = `"strictly"` diff --git a/docs/framework/angular/reference/type-aliases/Override.md b/docs/framework/angular/reference/type-aliases/Override.md new file mode 100644 index 00000000000..8abcecd1e1b --- /dev/null +++ b/docs/framework/angular/reference/type-aliases/Override.md @@ -0,0 +1,20 @@ +--- +id: Override +title: Override +--- + +```ts +type Override = { [AKey in keyof TTargetA]: AKey extends keyof TTargetB ? TTargetB[AKey] : TTargetA[AKey] }; +``` + +Defined in: [packages/query-core/src/types.ts:31](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L31) + +## Type Parameters + +### TTargetA + +`TTargetA` + +### TTargetB + +`TTargetB` diff --git a/docs/framework/angular/reference/type-aliases/PersistQueryClientFeature.md b/docs/framework/angular/reference/type-aliases/PersistQueryClientFeature.md index cb5f2440ccc..e094e32a970 100644 --- a/docs/framework/angular/reference/type-aliases/PersistQueryClientFeature.md +++ b/docs/framework/angular/reference/type-aliases/PersistQueryClientFeature.md @@ -7,7 +7,7 @@ title: PersistQueryClientFeature type PersistQueryClientFeature = QueryFeature<"PersistQueryClient">; ``` -Defined in: [providers.ts:161](https://github.com/TanStack/query/blob/main/packages/angular-query-experimental/src/providers.ts#L161) +Defined in: [packages/angular-query-experimental/src/providers.ts:161](https://github.com/TanStack/query/blob/main/packages/angular-query-experimental/src/providers.ts#L161) A type alias that represents a feature which enables persistence. The type is used to describe the return value of the `withPersistQueryClient` function. diff --git a/docs/framework/angular/reference/type-aliases/PlaceholderDataFunction.md b/docs/framework/angular/reference/type-aliases/PlaceholderDataFunction.md new file mode 100644 index 00000000000..cd40f28b41e --- /dev/null +++ b/docs/framework/angular/reference/type-aliases/PlaceholderDataFunction.md @@ -0,0 +1,42 @@ +--- +id: PlaceholderDataFunction +title: PlaceholderDataFunction +--- + +```ts +type PlaceholderDataFunction = (previousData, previousQuery) => TQueryData | undefined; +``` + +Defined in: [packages/query-core/src/types.ts:177](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L177) + +## Type Parameters + +### TQueryFnData + +`TQueryFnData` = `unknown` + +### TError + +`TError` = [`DefaultError`](DefaultError.md) + +### TQueryData + +`TQueryData` = `TQueryFnData` + +### TQueryKey + +`TQueryKey` *extends* [`QueryKey`](QueryKey.md) = [`QueryKey`](QueryKey.md) + +## Parameters + +### previousData + +`TQueryData` | `undefined` + +### previousQuery + +[`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryData`, `TQueryKey`\> | `undefined` + +## Returns + +`TQueryData` \| `undefined` diff --git a/docs/framework/angular/reference/type-aliases/QueriesOptions.md b/docs/framework/angular/reference/type-aliases/QueriesOptions.md index 02313675d29..a0f51826b76 100644 --- a/docs/framework/angular/reference/type-aliases/QueriesOptions.md +++ b/docs/framework/angular/reference/type-aliases/QueriesOptions.md @@ -7,7 +7,7 @@ title: QueriesOptions type QueriesOptions = TDepth["length"] extends MAXIMUM_DEPTH ? QueryObserverOptionsForCreateQueries[] : T extends [] ? [] : T extends [infer Head] ? [...TResults, GetCreateQueryOptionsForCreateQueries] : T extends [infer Head, ...(infer Tails)] ? QueriesOptions<[...Tails], [...TResults, GetCreateQueryOptionsForCreateQueries], [...TDepth, 1]> : ReadonlyArray extends T ? T : T extends QueryObserverOptionsForCreateQueries[] ? QueryObserverOptionsForCreateQueries[] : QueryObserverOptionsForCreateQueries[]; ``` -Defined in: [inject-queries.ts:154](https://github.com/TanStack/query/blob/main/packages/angular-query-experimental/src/inject-queries.ts#L154) +Defined in: [packages/angular-query-experimental/src/inject-queries.ts:154](https://github.com/TanStack/query/blob/main/packages/angular-query-experimental/src/inject-queries.ts#L154) The `queries` array accepted by `injectQueries`. Recursively unwraps each tuple element so every entry's `queryFn`/`select`/`throwOnError` are inferred individually, up to 20 elements — past that, tuple diff --git a/docs/framework/angular/reference/type-aliases/QueriesPlaceholderDataFunction.md b/docs/framework/angular/reference/type-aliases/QueriesPlaceholderDataFunction.md new file mode 100644 index 00000000000..5d3fca8c9e0 --- /dev/null +++ b/docs/framework/angular/reference/type-aliases/QueriesPlaceholderDataFunction.md @@ -0,0 +1,30 @@ +--- +id: QueriesPlaceholderDataFunction +title: QueriesPlaceholderDataFunction +--- + +```ts +type QueriesPlaceholderDataFunction = (previousData, previousQuery) => TQueryData | undefined; +``` + +Defined in: [packages/query-core/src/types.ts:187](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L187) + +## Type Parameters + +### TQueryData + +`TQueryData` + +## Parameters + +### previousData + +`undefined` + +### previousQuery + +`undefined` + +## Returns + +`TQueryData` \| `undefined` diff --git a/docs/framework/angular/reference/type-aliases/QueriesResults.md b/docs/framework/angular/reference/type-aliases/QueriesResults.md index b44ac22ee82..e31cb61caef 100644 --- a/docs/framework/angular/reference/type-aliases/QueriesResults.md +++ b/docs/framework/angular/reference/type-aliases/QueriesResults.md @@ -7,7 +7,7 @@ title: QueriesResults type QueriesResults = TDepth["length"] extends MAXIMUM_DEPTH ? CreateQueryResult[] : T extends [] ? [] : T extends [infer Head] ? [...TResults, GetCreateQueryResult] : T extends [infer Head, ...(infer Tails)] ? QueriesResults<[...Tails], [...TResults, GetCreateQueryResult], [...TDepth, 1]> : { [K in keyof T]: GetCreateQueryResult }; ``` -Defined in: [inject-queries.ts:205](https://github.com/TanStack/query/blob/main/packages/angular-query-experimental/src/inject-queries.ts#L205) +Defined in: [packages/angular-query-experimental/src/inject-queries.ts:205](https://github.com/TanStack/query/blob/main/packages/angular-query-experimental/src/inject-queries.ts#L205) The result type returned by `injectQueries`, when no `combine` is provided. Mirrors [QueriesOptions](QueriesOptions.md): each tuple element's result type is inferred individually, up to 20 elements — past that, tuple recursion diff --git a/docs/framework/angular/reference/type-aliases/QueryBooleanOption.md b/docs/framework/angular/reference/type-aliases/QueryBooleanOption.md new file mode 100644 index 00000000000..9759e3ddb42 --- /dev/null +++ b/docs/framework/angular/reference/type-aliases/QueryBooleanOption.md @@ -0,0 +1,28 @@ +--- +id: QueryBooleanOption +title: QueryBooleanOption +--- + +```ts +type QueryBooleanOption = boolean | (query) => boolean; +``` + +Defined in: [packages/query-core/src/types.ts:119](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L119) + +## Type Parameters + +### TQueryFnData + +`TQueryFnData` = `unknown` + +### TError + +`TError` = [`DefaultError`](DefaultError.md) + +### TData + +`TData` = `TQueryFnData` + +### TQueryKey + +`TQueryKey` *extends* [`QueryKey`](QueryKey.md) = [`QueryKey`](QueryKey.md) diff --git a/docs/framework/angular/reference/type-aliases/QueryCacheNotifyEvent.md b/docs/framework/angular/reference/type-aliases/QueryCacheNotifyEvent.md new file mode 100644 index 00000000000..b92c76fb826 --- /dev/null +++ b/docs/framework/angular/reference/type-aliases/QueryCacheNotifyEvent.md @@ -0,0 +1,21 @@ +--- +id: QueryCacheNotifyEvent +title: QueryCacheNotifyEvent +--- + +```ts +type QueryCacheNotifyEvent = + | NotifyEventQueryAdded + | NotifyEventQueryRemoved + | NotifyEventQueryUpdated + | NotifyEventQueryObserverAdded + | NotifyEventQueryObserverRemoved + | NotifyEventQueryObserverResultsUpdated + | NotifyEventQueryObserverOptionsUpdated; +``` + +Defined in: [packages/query-core/src/queryCache.ts:85](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryCache.ts#L85) + +The event passed to a `QueryCache` subscriber. Fired whenever a query is added or removed from +the cache, its state is updated (e.g. via `query.setState` or `queryClient.removeQueries`), or +one of its observers is added, removed, or has its results or options updated. diff --git a/docs/framework/angular/reference/type-aliases/QueryFeatures.md b/docs/framework/angular/reference/type-aliases/QueryFeatures.md index ca829d2faf2..ea04f398ffc 100644 --- a/docs/framework/angular/reference/type-aliases/QueryFeatures.md +++ b/docs/framework/angular/reference/type-aliases/QueryFeatures.md @@ -9,7 +9,7 @@ type QueryFeatures = | PersistQueryClientFeature; ``` -Defined in: [providers.ts:170](https://github.com/TanStack/query/blob/main/packages/angular-query-experimental/src/providers.ts#L170) +Defined in: [packages/angular-query-experimental/src/providers.ts:170](https://github.com/TanStack/query/blob/main/packages/angular-query-experimental/src/providers.ts#L170) A type alias that represents all Query features available for use with `provideTanStackQuery`. Features can be enabled by adding special functions to the `provideTanStackQuery` call. diff --git a/docs/framework/angular/reference/type-aliases/QueryFunction.md b/docs/framework/angular/reference/type-aliases/QueryFunction.md new file mode 100644 index 00000000000..306367388a1 --- /dev/null +++ b/docs/framework/angular/reference/type-aliases/QueryFunction.md @@ -0,0 +1,34 @@ +--- +id: QueryFunction +title: QueryFunction +--- + +```ts +type QueryFunction = (context) => T | Promise; +``` + +Defined in: [packages/query-core/src/types.ts:102](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L102) + +## Type Parameters + +### T + +`T` = `unknown` + +### TQueryKey + +`TQueryKey` *extends* [`QueryKey`](QueryKey.md) = [`QueryKey`](QueryKey.md) + +### TPageParam + +`TPageParam` = `never` + +## Parameters + +### context + +[`QueryFunctionContext`](QueryFunctionContext.md)\<`TQueryKey`, `TPageParam`\> + +## Returns + +`T` \| `Promise`\<`T`\> diff --git a/docs/framework/angular/reference/type-aliases/QueryFunctionContext.md b/docs/framework/angular/reference/type-aliases/QueryFunctionContext.md new file mode 100644 index 00000000000..d2c9fe3e2b2 --- /dev/null +++ b/docs/framework/angular/reference/type-aliases/QueryFunctionContext.md @@ -0,0 +1,20 @@ +--- +id: QueryFunctionContext +title: QueryFunctionContext +--- + +```ts +type QueryFunctionContext = [TPageParam] extends [never] ? object : object; +``` + +Defined in: [packages/query-core/src/types.ts:144](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L144) + +## Type Parameters + +### TQueryKey + +`TQueryKey` *extends* [`QueryKey`](QueryKey.md) = [`QueryKey`](QueryKey.md) + +### TPageParam + +`TPageParam` = `never` diff --git a/docs/framework/angular/reference/type-aliases/QueryKey.md b/docs/framework/angular/reference/type-aliases/QueryKey.md new file mode 100644 index 00000000000..1a3f34cde18 --- /dev/null +++ b/docs/framework/angular/reference/type-aliases/QueryKey.md @@ -0,0 +1,10 @@ +--- +id: QueryKey +title: QueryKey +--- + +```ts +type QueryKey = Register extends object ? TQueryKey extends ReadonlyArray ? TQueryKey : TQueryKey extends unknown[] ? TQueryKey : ReadonlyArray : ReadonlyArray; +``` + +Defined in: [packages/query-core/src/types.ts:51](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L51) diff --git a/docs/framework/angular/reference/type-aliases/QueryKeyHashFunction.md b/docs/framework/angular/reference/type-aliases/QueryKeyHashFunction.md new file mode 100644 index 00000000000..feda96373cc --- /dev/null +++ b/docs/framework/angular/reference/type-aliases/QueryKeyHashFunction.md @@ -0,0 +1,26 @@ +--- +id: QueryKeyHashFunction +title: QueryKeyHashFunction +--- + +```ts +type QueryKeyHashFunction = (queryKey) => string; +``` + +Defined in: [packages/query-core/src/types.ts:192](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L192) + +## Type Parameters + +### TQueryKey + +`TQueryKey` *extends* [`QueryKey`](QueryKey.md) + +## Parameters + +### queryKey + +`TQueryKey` + +## Returns + +`string` diff --git a/docs/framework/angular/reference/type-aliases/QueryKeyWithDataTag.md b/docs/framework/angular/reference/type-aliases/QueryKeyWithDataTag.md new file mode 100644 index 00000000000..6613f74be9e --- /dev/null +++ b/docs/framework/angular/reference/type-aliases/QueryKeyWithDataTag.md @@ -0,0 +1,34 @@ +--- +id: QueryKeyWithDataTag +title: QueryKeyWithDataTag +--- + +```ts +type QueryKeyWithDataTag = object; +``` + +Defined in: [packages/query-core/src/types.ts:82](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L82) + +## Type Parameters + +### TQueryKey + +`TQueryKey` *extends* [`QueryKey`](QueryKey.md) = [`QueryKey`](QueryKey.md) + +### TQueryFnData + +`TQueryFnData` = `unknown` + +### TError + +`TError` = [`DefaultError`](DefaultError.md) + +## Properties + +### queryKey + +```ts +queryKey: DataTag; +``` + +Defined in: [packages/query-core/src/types.ts:87](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L87) diff --git a/docs/framework/angular/reference/type-aliases/QueryMeta.md b/docs/framework/angular/reference/type-aliases/QueryMeta.md new file mode 100644 index 00000000000..c12917b2cce --- /dev/null +++ b/docs/framework/angular/reference/type-aliases/QueryMeta.md @@ -0,0 +1,10 @@ +--- +id: QueryMeta +title: QueryMeta +--- + +```ts +type QueryMeta = Register extends object ? TQueryMeta extends Record ? TQueryMeta : Record : Record; +``` + +Defined in: [packages/query-core/src/types.ts:215](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L215) diff --git a/docs/framework/angular/reference/type-aliases/QueryObserverResult.md b/docs/framework/angular/reference/type-aliases/QueryObserverResult.md new file mode 100644 index 00000000000..5138b635f2c --- /dev/null +++ b/docs/framework/angular/reference/type-aliases/QueryObserverResult.md @@ -0,0 +1,25 @@ +--- +id: QueryObserverResult +title: QueryObserverResult +--- + +```ts +type QueryObserverResult = + | DefinedQueryObserverResult + | QueryObserverLoadingErrorResult + | QueryObserverLoadingResult + | QueryObserverPendingResult +| QueryObserverPlaceholderResult; +``` + +Defined in: [packages/query-core/src/types.ts:994](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L994) + +## Type Parameters + +### TData + +`TData` = `unknown` + +### TError + +`TError` = [`DefaultError`](DefaultError.md) diff --git a/docs/framework/angular/reference/type-aliases/QueryPersister.md b/docs/framework/angular/reference/type-aliases/QueryPersister.md new file mode 100644 index 00000000000..72e80165b0d --- /dev/null +++ b/docs/framework/angular/reference/type-aliases/QueryPersister.md @@ -0,0 +1,24 @@ +--- +id: QueryPersister +title: QueryPersister +--- + +```ts +type QueryPersister = [TPageParam] extends [never] ? (queryFn, context, query) => T | Promise : (queryFn, context, query) => T | Promise; +``` + +Defined in: [packages/query-core/src/types.ts:128](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L128) + +## Type Parameters + +### T + +`T` = `unknown` + +### TQueryKey + +`TQueryKey` *extends* [`QueryKey`](QueryKey.md) = [`QueryKey`](QueryKey.md) + +### TPageParam + +`TPageParam` = `never` diff --git a/docs/framework/angular/reference/type-aliases/QueryStatus.md b/docs/framework/angular/reference/type-aliases/QueryStatus.md new file mode 100644 index 00000000000..bab00f6f423 --- /dev/null +++ b/docs/framework/angular/reference/type-aliases/QueryStatus.md @@ -0,0 +1,10 @@ +--- +id: QueryStatus +title: QueryStatus +--- + +```ts +type QueryStatus = "pending" | "error" | "success"; +``` + +Defined in: [packages/query-core/src/types.ts:761](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L761) diff --git a/docs/framework/angular/reference/type-aliases/SkipToken.md b/docs/framework/angular/reference/type-aliases/SkipToken.md new file mode 100644 index 00000000000..3a5791b982e --- /dev/null +++ b/docs/framework/angular/reference/type-aliases/SkipToken.md @@ -0,0 +1,12 @@ +--- +id: SkipToken +title: SkipToken +--- + +```ts +type SkipToken = typeof skipToken; +``` + +Defined in: [packages/query-core/src/utils.ts:526](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L526) + +The type of the [skipToken](../variables/skipToken.md) sentinel value. diff --git a/docs/framework/angular/reference/type-aliases/StaleTime.md b/docs/framework/angular/reference/type-aliases/StaleTime.md new file mode 100644 index 00000000000..3e7e21608be --- /dev/null +++ b/docs/framework/angular/reference/type-aliases/StaleTime.md @@ -0,0 +1,10 @@ +--- +id: StaleTime +title: StaleTime +--- + +```ts +type StaleTime = number | "static"; +``` + +Defined in: [packages/query-core/src/types.ts:108](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L108) diff --git a/docs/framework/angular/reference/type-aliases/StaleTimeFunction.md b/docs/framework/angular/reference/type-aliases/StaleTimeFunction.md new file mode 100644 index 00000000000..b1c541fa64e --- /dev/null +++ b/docs/framework/angular/reference/type-aliases/StaleTimeFunction.md @@ -0,0 +1,28 @@ +--- +id: StaleTimeFunction +title: StaleTimeFunction +--- + +```ts +type StaleTimeFunction = StaleTime | (query) => StaleTime; +``` + +Defined in: [packages/query-core/src/types.ts:110](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L110) + +## Type Parameters + +### TQueryFnData + +`TQueryFnData` = `unknown` + +### TError + +`TError` = [`DefaultError`](DefaultError.md) + +### TData + +`TData` = `TQueryFnData` + +### TQueryKey + +`TQueryKey` *extends* [`QueryKey`](QueryKey.md) = [`QueryKey`](QueryKey.md) diff --git a/docs/framework/angular/reference/type-aliases/ThrowOnError.md b/docs/framework/angular/reference/type-aliases/ThrowOnError.md new file mode 100644 index 00000000000..134683388ef --- /dev/null +++ b/docs/framework/angular/reference/type-aliases/ThrowOnError.md @@ -0,0 +1,28 @@ +--- +id: ThrowOnError +title: ThrowOnError +--- + +```ts +type ThrowOnError = boolean | (error, query) => boolean; +``` + +Defined in: [packages/query-core/src/types.ts:368](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L368) + +## Type Parameters + +### TQueryFnData + +`TQueryFnData` + +### TError + +`TError` + +### TQueryData + +`TQueryData` + +### TQueryKey + +`TQueryKey` *extends* [`QueryKey`](QueryKey.md) diff --git a/docs/framework/angular/reference/type-aliases/TimeoutCallback.md b/docs/framework/angular/reference/type-aliases/TimeoutCallback.md new file mode 100644 index 00000000000..773b5fdaeb9 --- /dev/null +++ b/docs/framework/angular/reference/type-aliases/TimeoutCallback.md @@ -0,0 +1,27 @@ +--- +id: TimeoutCallback +title: TimeoutCallback +--- + +```ts +type TimeoutCallback = (_) => void; +``` + +Defined in: [packages/query-core/src/timeoutManager.ts:9](https://github.com/TanStack/query/blob/main/packages/query-core/src/timeoutManager.ts#L9) + +[TimeoutManager](../interfaces/TimeoutManager.md) does not support passing arguments to the callback. + +`(_: void)` is the argument type inferred by TypeScript's default typings for +`setTimeout(cb, number)`. +If we don't accept a single void argument, then +`new Promise(resolve => timeoutManager.setTimeout(resolve, N))` is a type error. + +## Parameters + +### \_ + +`void` + +## Returns + +`void` diff --git a/docs/framework/angular/reference/type-aliases/TimeoutProvider.md b/docs/framework/angular/reference/type-aliases/TimeoutProvider.md new file mode 100644 index 00000000000..3509105bcd1 --- /dev/null +++ b/docs/framework/angular/reference/type-aliases/TimeoutProvider.md @@ -0,0 +1,112 @@ +--- +id: TimeoutProvider +title: TimeoutProvider +--- + +```ts +type TimeoutProvider = object; +``` + +Defined in: [packages/query-core/src/timeoutManager.ts:28](https://github.com/TanStack/query/blob/main/packages/query-core/src/timeoutManager.ts#L28) + +Backend for timer functions. + +Timers are performance-sensitive: short-lived timers (delays under a few seconds) tend to be +latency-sensitive, while long-lived ones may benefit more from coalescing — batching timers +with similar deadlines together — which the default provider (backed by the platform's global +`setTimeout`/`setInterval`) does not do. A custom provider can implement coalescing, and can +also support delays longer than the ~24-day maximum of the global `setTimeout`. + +## Type Parameters + +### TTimerId + +`TTimerId` *extends* [`ManagedTimerId`](ManagedTimerId.md) = [`ManagedTimerId`](ManagedTimerId.md) + +## Properties + +### clearInterval() + +```ts +readonly clearInterval: (intervalId) => void; +``` + +Defined in: [packages/query-core/src/timeoutManager.ts:34](https://github.com/TanStack/query/blob/main/packages/query-core/src/timeoutManager.ts#L34) + +#### Parameters + +##### intervalId + +`TTimerId` | `undefined` + +#### Returns + +`void` + +*** + +### clearTimeout() + +```ts +readonly clearTimeout: (timeoutId) => void; +``` + +Defined in: [packages/query-core/src/timeoutManager.ts:31](https://github.com/TanStack/query/blob/main/packages/query-core/src/timeoutManager.ts#L31) + +#### Parameters + +##### timeoutId + +`TTimerId` | `undefined` + +#### Returns + +`void` + +*** + +### setInterval() + +```ts +readonly setInterval: (callback, delay) => TTimerId; +``` + +Defined in: [packages/query-core/src/timeoutManager.ts:33](https://github.com/TanStack/query/blob/main/packages/query-core/src/timeoutManager.ts#L33) + +#### Parameters + +##### callback + +[`TimeoutCallback`](TimeoutCallback.md) + +##### delay + +`number` + +#### Returns + +`TTimerId` + +*** + +### setTimeout() + +```ts +readonly setTimeout: (callback, delay) => TTimerId; +``` + +Defined in: [packages/query-core/src/timeoutManager.ts:30](https://github.com/TanStack/query/blob/main/packages/query-core/src/timeoutManager.ts#L30) + +#### Parameters + +##### callback + +[`TimeoutCallback`](TimeoutCallback.md) + +##### delay + +`number` + +#### Returns + +`TTimerId` diff --git a/docs/framework/angular/reference/type-aliases/UndefinedInitialDataInfiniteOptions.md b/docs/framework/angular/reference/type-aliases/UndefinedInitialDataInfiniteOptions.md index ea99866a0f0..e657351693d 100644 --- a/docs/framework/angular/reference/type-aliases/UndefinedInitialDataInfiniteOptions.md +++ b/docs/framework/angular/reference/type-aliases/UndefinedInitialDataInfiniteOptions.md @@ -7,7 +7,7 @@ title: UndefinedInitialDataInfiniteOptions type UndefinedInitialDataInfiniteOptions = CreateInfiniteQueryOptions & object; ``` -Defined in: [infinite-query-options.ts:24](https://github.com/TanStack/query/blob/main/packages/angular-query-experimental/src/infinite-query-options.ts#L24) +Defined in: [packages/angular-query-experimental/src/infinite-query-options.ts:24](https://github.com/TanStack/query/blob/main/packages/angular-query-experimental/src/infinite-query-options.ts#L24) The options accepted by the `infiniteQueryOptions` overload selected when no `initialData` is set — `data` may be `undefined` while the query is `pending`. @@ -38,20 +38,20 @@ The type of a single page, as your `queryFn` resolves it. ### TError -`TError` = `DefaultError` +`TError` = [`DefaultError`](DefaultError.md) The type of errors your `queryFn` may throw. ### TData -`TData` = `InfiniteData`\<`TQueryFnData`\> +`TData` = [`InfiniteData`](../interfaces/InfiniteData.md)\<`TQueryFnData`\> The type `data` ends up as after `select` runs — defaults to `InfiniteData`, the shape of all fetched pages plus their page params. ### TQueryKey -`TQueryKey` *extends* `QueryKey` = `QueryKey` +`TQueryKey` *extends* [`QueryKey`](QueryKey.md) = [`QueryKey`](QueryKey.md) The type of your `queryKey`. diff --git a/docs/framework/angular/reference/type-aliases/UndefinedInitialDataOptions.md b/docs/framework/angular/reference/type-aliases/UndefinedInitialDataOptions.md index 28e2b4d2fbb..3814e441388 100644 --- a/docs/framework/angular/reference/type-aliases/UndefinedInitialDataOptions.md +++ b/docs/framework/angular/reference/type-aliases/UndefinedInitialDataOptions.md @@ -7,7 +7,7 @@ title: UndefinedInitialDataOptions type UndefinedInitialDataOptions = CreateQueryOptions & object; ``` -Defined in: [query-options.ts:22](https://github.com/TanStack/query/blob/main/packages/angular-query-experimental/src/query-options.ts#L22) +Defined in: [packages/angular-query-experimental/src/query-options.ts:22](https://github.com/TanStack/query/blob/main/packages/angular-query-experimental/src/query-options.ts#L22) The options accepted by the `queryOptions` overload selected when no `initialData` is set — `data` may be `undefined` while the query is `pending`. @@ -38,7 +38,7 @@ The type your `queryFn` resolves to. ### TError -`TError` = `DefaultError` +`TError` = [`DefaultError`](DefaultError.md) The type of errors your `queryFn` may throw. @@ -50,6 +50,6 @@ The type `data` ends up as after `select` runs. ### TQueryKey -`TQueryKey` *extends* `QueryKey` = `QueryKey` +`TQueryKey` *extends* [`QueryKey`](QueryKey.md) = [`QueryKey`](QueryKey.md) The type of your `queryKey`. diff --git a/docs/framework/angular/reference/type-aliases/UnsetMarker.md b/docs/framework/angular/reference/type-aliases/UnsetMarker.md new file mode 100644 index 00000000000..8b9c14e1907 --- /dev/null +++ b/docs/framework/angular/reference/type-aliases/UnsetMarker.md @@ -0,0 +1,10 @@ +--- +id: UnsetMarker +title: UnsetMarker +--- + +```ts +type UnsetMarker = typeof unsetMarker; +``` + +Defined in: [packages/query-core/src/types.ts:66](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L66) diff --git a/docs/framework/angular/reference/type-aliases/UnusedSkipTokenInfiniteOptions.md b/docs/framework/angular/reference/type-aliases/UnusedSkipTokenInfiniteOptions.md index 499287c4f00..ec9ab5c61dd 100644 --- a/docs/framework/angular/reference/type-aliases/UnusedSkipTokenInfiniteOptions.md +++ b/docs/framework/angular/reference/type-aliases/UnusedSkipTokenInfiniteOptions.md @@ -7,7 +7,7 @@ title: UnusedSkipTokenInfiniteOptions type UnusedSkipTokenInfiniteOptions = OmitKeyof, "queryFn"> & object; ``` -Defined in: [infinite-query-options.ts:64](https://github.com/TanStack/query/blob/main/packages/angular-query-experimental/src/infinite-query-options.ts#L64) +Defined in: [packages/angular-query-experimental/src/infinite-query-options.ts:64](https://github.com/TanStack/query/blob/main/packages/angular-query-experimental/src/infinite-query-options.ts#L64) The options accepted by the `infiniteQueryOptions` overload selected when no `initialData` is set and `queryFn` is not `skipToken` — same as [UndefinedInitialDataInfiniteOptions](UndefinedInitialDataInfiniteOptions.md), but `queryFn` may not be @@ -36,20 +36,20 @@ The type of a single page, as your `queryFn` resolves it. ### TError -`TError` = `DefaultError` +`TError` = [`DefaultError`](DefaultError.md) The type of errors your `queryFn` may throw. ### TData -`TData` = `InfiniteData`\<`TQueryFnData`\> +`TData` = [`InfiniteData`](../interfaces/InfiniteData.md)\<`TQueryFnData`\> The type `data` ends up as after `select` runs — defaults to `InfiniteData`, the shape of all fetched pages plus their page params. ### TQueryKey -`TQueryKey` *extends* `QueryKey` = `QueryKey` +`TQueryKey` *extends* [`QueryKey`](QueryKey.md) = [`QueryKey`](QueryKey.md) The type of your `queryKey`. diff --git a/docs/framework/angular/reference/type-aliases/UnusedSkipTokenOptions.md b/docs/framework/angular/reference/type-aliases/UnusedSkipTokenOptions.md index dc85f4f9732..854d773b68e 100644 --- a/docs/framework/angular/reference/type-aliases/UnusedSkipTokenOptions.md +++ b/docs/framework/angular/reference/type-aliases/UnusedSkipTokenOptions.md @@ -7,7 +7,7 @@ title: UnusedSkipTokenOptions type UnusedSkipTokenOptions = OmitKeyof, "queryFn"> & object; ``` -Defined in: [query-options.ts:50](https://github.com/TanStack/query/blob/main/packages/angular-query-experimental/src/query-options.ts#L50) +Defined in: [packages/angular-query-experimental/src/query-options.ts:50](https://github.com/TanStack/query/blob/main/packages/angular-query-experimental/src/query-options.ts#L50) The options accepted by the `queryOptions` overload selected when no `initialData` is set and `queryFn` is not `skipToken` — same as [UndefinedInitialDataOptions](UndefinedInitialDataOptions.md), but `queryFn` may not be `skipToken`. @@ -35,7 +35,7 @@ The type your `queryFn` resolves to. ### TError -`TError` = `DefaultError` +`TError` = [`DefaultError`](DefaultError.md) The type of errors your `queryFn` may throw. @@ -47,6 +47,6 @@ The type `data` ends up as after `select` runs. ### TQueryKey -`TQueryKey` *extends* `QueryKey` = `QueryKey` +`TQueryKey` *extends* [`QueryKey`](QueryKey.md) = [`QueryKey`](QueryKey.md) The type of your `queryKey`. diff --git a/docs/framework/angular/reference/type-aliases/Updater.md b/docs/framework/angular/reference/type-aliases/Updater.md new file mode 100644 index 00000000000..7a0c2f30503 --- /dev/null +++ b/docs/framework/angular/reference/type-aliases/Updater.md @@ -0,0 +1,35 @@ +--- +id: Updater +title: Updater +--- + +```ts +type Updater = TOutput | (input) => TOutput; +``` + +Defined in: [packages/query-core/src/utils.ts:105](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L105) + +Either a plain value of type `TOutput`, or a function that receives `TInput` and returns `TOutput`. +Used for example by `setQueryData`-style updaters, which accept either the new data directly or a +function that computes it from the previous data. See functionalUpdate. + +## Type Parameters + +### TInput + +`TInput` + +### TOutput + +`TOutput` + +## Example + +```ts +queryClient.setQueryData(['posts'], newPosts) + +// Or, using an updater function that receives the current data: +queryClient.setQueryData(['posts'], (oldPosts) => + oldPosts ? [...oldPosts, newPost] : oldPosts, +) +``` diff --git a/docs/framework/angular/reference/type-aliases/WithRequired.md b/docs/framework/angular/reference/type-aliases/WithRequired.md new file mode 100644 index 00000000000..a40a48c865b --- /dev/null +++ b/docs/framework/angular/reference/type-aliases/WithRequired.md @@ -0,0 +1,20 @@ +--- +id: WithRequired +title: WithRequired +--- + +```ts +type WithRequired = TTarget & { [_ in TKey]: {} }; +``` + +Defined in: [packages/query-core/src/types.ts:524](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L524) + +## Type Parameters + +### TTarget + +`TTarget` + +### TKey + +`TKey` *extends* keyof `TTarget` diff --git a/docs/framework/angular/reference/type-aliases/dataTagErrorSymbol.md b/docs/framework/angular/reference/type-aliases/dataTagErrorSymbol.md new file mode 100644 index 00000000000..26148a94d6e --- /dev/null +++ b/docs/framework/angular/reference/type-aliases/dataTagErrorSymbol.md @@ -0,0 +1,10 @@ +--- +id: dataTagErrorSymbol +title: dataTagErrorSymbol +--- + +```ts +type dataTagErrorSymbol = typeof dataTagErrorSymbol; +``` + +Defined in: [packages/query-core/src/types.ts:63](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L63) diff --git a/docs/framework/angular/reference/type-aliases/dataTagSymbol.md b/docs/framework/angular/reference/type-aliases/dataTagSymbol.md new file mode 100644 index 00000000000..0012c108cc5 --- /dev/null +++ b/docs/framework/angular/reference/type-aliases/dataTagSymbol.md @@ -0,0 +1,10 @@ +--- +id: dataTagSymbol +title: dataTagSymbol +--- + +```ts +type dataTagSymbol = typeof dataTagSymbol; +``` + +Defined in: [packages/query-core/src/types.ts:61](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L61) diff --git a/docs/framework/angular/reference/variables/dataTagErrorSymbol.md b/docs/framework/angular/reference/variables/dataTagErrorSymbol.md new file mode 100644 index 00000000000..20bab62fb01 --- /dev/null +++ b/docs/framework/angular/reference/variables/dataTagErrorSymbol.md @@ -0,0 +1,10 @@ +--- +id: dataTagErrorSymbol +title: dataTagErrorSymbol +--- + +```ts +const dataTagErrorSymbol: typeof dataTagErrorSymbol; +``` + +Defined in: [packages/query-core/src/types.ts:63](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L63) diff --git a/docs/framework/angular/reference/variables/dataTagSymbol.md b/docs/framework/angular/reference/variables/dataTagSymbol.md new file mode 100644 index 00000000000..83dd68a56e9 --- /dev/null +++ b/docs/framework/angular/reference/variables/dataTagSymbol.md @@ -0,0 +1,10 @@ +--- +id: dataTagSymbol +title: dataTagSymbol +--- + +```ts +const dataTagSymbol: typeof dataTagSymbol; +``` + +Defined in: [packages/query-core/src/types.ts:61](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L61) diff --git a/docs/framework/angular/reference/variables/defaultScheduler.md b/docs/framework/angular/reference/variables/defaultScheduler.md new file mode 100644 index 00000000000..70e14d3f846 --- /dev/null +++ b/docs/framework/angular/reference/variables/defaultScheduler.md @@ -0,0 +1,13 @@ +--- +id: defaultScheduler +title: defaultScheduler +--- + +```ts +const defaultScheduler: ScheduleFunction = systemSetTimeoutZero; +``` + +Defined in: [packages/query-core/src/notifyManager.ts:19](https://github.com/TanStack/query/blob/main/packages/query-core/src/notifyManager.ts#L19) + +Default scheduling function used by the notify manager. +Schedules the callback with the system's `setTimeout(callback, 0)`. diff --git a/docs/framework/angular/reference/variables/environmentManager.md b/docs/framework/angular/reference/variables/environmentManager.md new file mode 100644 index 00000000000..ed333b8747b --- /dev/null +++ b/docs/framework/angular/reference/variables/environmentManager.md @@ -0,0 +1,59 @@ +--- +id: environmentManager +title: environmentManager +--- + +```ts +const environmentManager: object; +``` + +Defined in: [packages/query-core/src/environmentManager.ts:29](https://github.com/TanStack/query/blob/main/packages/query-core/src/environmentManager.ts#L29) + +Manages how TanStack Query detects whether the current runtime should be treated as +server-side, which disables scheduling refetch timers and changes the default `retry` count +and `gcTime`. By default, the detection treats a missing `window` (or the presence of a +`Deno` global) as server. + +Override this for runtimes where that default detection would give the wrong answer — for +example, a Service Worker, where `window` is undefined even though the environment should +behave like a client. + +## Type Declaration + +### isServer() + +```ts +isServer: () => boolean; +``` + +Returns whether the current runtime should be treated as a server environment. + +#### Returns + +`boolean` + +### setIsServer() + +```ts +setIsServer(isServerValue): void; +``` + +Overrides the server check globally. + +#### Parameters + +##### isServerValue + +`IsServerValue` + +#### Returns + +`void` + +## Example + +```ts +import { environmentManager } from '@tanstack/query-core' + +environmentManager.setIsServer(() => false) +``` diff --git a/docs/framework/angular/reference/variables/focusManager.md b/docs/framework/angular/reference/variables/focusManager.md new file mode 100644 index 00000000000..86477849e06 --- /dev/null +++ b/docs/framework/angular/reference/variables/focusManager.md @@ -0,0 +1,12 @@ +--- +id: focusManager +title: focusManager +--- + +```ts +const focusManager: FocusManager; +``` + +Defined in: [packages/query-core/src/focusManager.ts:142](https://github.com/TanStack/query/blob/main/packages/query-core/src/focusManager.ts#L142) + +Singleton instance of [FocusManager](../interfaces/FocusManager.md), used to manage and observe the focus state within TanStack Query. diff --git a/docs/framework/angular/reference/variables/isServer.md b/docs/framework/angular/reference/variables/isServer.md new file mode 100644 index 00000000000..16aa39d1244 --- /dev/null +++ b/docs/framework/angular/reference/variables/isServer.md @@ -0,0 +1,14 @@ +--- +id: isServer +title: isServer +--- + +```ts +const isServer: boolean; +``` + +Defined in: [packages/query-core/src/utils.ts:114](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L114) + +## Deprecated + +use `environmentManager.isServer()` instead. diff --git a/docs/framework/angular/reference/variables/notifyManager.md b/docs/framework/angular/reference/variables/notifyManager.md new file mode 100644 index 00000000000..4bdf3478be0 --- /dev/null +++ b/docs/framework/angular/reference/variables/notifyManager.md @@ -0,0 +1,166 @@ +--- +id: notifyManager +title: notifyManager +--- + +```ts +const notifyManager: object; +``` + +Defined in: [packages/query-core/src/notifyManager.ts:144](https://github.com/TanStack/query/blob/main/packages/query-core/src/notifyManager.ts#L144) + +Handles scheduling and batching callbacks in TanStack Query. + +## Type Declaration + +### batch() + +```ts +readonly batch: (callback) => T; +``` + +Batches all updates scheduled inside the passed callback. +This is mainly used internally to optimize query client updating. +Batches can be nested; the queue is only flushed once the outermost `batch` call finishes. +The return value of `callback` is passed through. + +#### Type Parameters + +##### T + +`T` + +#### Parameters + +##### callback + +() => `T` + +#### Returns + +`T` + +### batchCalls() + +```ts +readonly batchCalls: (callback) => BatchCallsCallback; +``` + +All calls to the wrapped function will be batched. + +#### Type Parameters + +##### T + +`T` *extends* `unknown`[] + +#### Parameters + +##### callback + +`BatchCallsCallback`\<`T`\> + +#### Returns + +`BatchCallsCallback`\<`T`\> + +### schedule() + +```ts +schedule: (callback) => void; +``` + +Schedules a function to be run on the next batch. +By default, the batch is run with a `setTimeout`, but this can be configured via `setScheduler`. + +#### Parameters + +##### callback + +`NotifyCallback` + +#### Returns + +`void` + +### setBatchNotifyFunction() + +```ts +readonly setBatchNotifyFunction: (fn) => void; +``` + +Use this method to set a custom function to batch notifications together into a single tick. +Framework adapters use this to plug in their own batching primitive, so that a single query +update only triggers one re-render instead of one per subscriber. + +#### Parameters + +##### fn + +`BatchNotifyFunction` + +#### Returns + +`void` + +#### Example + +```ts +import { notifyManager } from '@tanstack/query-core' +import { batch } from 'solid-js' + +notifyManager.setBatchNotifyFunction(batch) +``` + +### setNotifyFunction() + +```ts +readonly setNotifyFunction: (fn) => void; +``` + +Use this method to set a custom notify function. +This can be used to for example wrap notifications with `React.act` while running tests. + +#### Parameters + +##### fn + +`NotifyFunction` + +#### Returns + +`void` + +### setScheduler() + +```ts +readonly setScheduler: (fn) => void; +``` + +Configures a custom callback that schedules when the next batch runs. +The default behavior is `setTimeout(callback, 0)`. + +#### Parameters + +##### fn + +`ScheduleFunction` + +#### Returns + +`void` + +#### Example + +```ts +import { notifyManager } from '@tanstack/query-core' + +// Schedule batches in the next microtask +notifyManager.setScheduler(queueMicrotask) + +// Schedule batches before the next frame is rendered +notifyManager.setScheduler(requestAnimationFrame) + +// Schedule batches some time in the future +notifyManager.setScheduler((cb) => setTimeout(cb, 10)) +``` diff --git a/docs/framework/angular/reference/variables/onlineManager.md b/docs/framework/angular/reference/variables/onlineManager.md new file mode 100644 index 00000000000..2eeec5385d8 --- /dev/null +++ b/docs/framework/angular/reference/variables/onlineManager.md @@ -0,0 +1,12 @@ +--- +id: onlineManager +title: onlineManager +--- + +```ts +const onlineManager: OnlineManager; +``` + +Defined in: [packages/query-core/src/onlineManager.ts:117](https://github.com/TanStack/query/blob/main/packages/query-core/src/onlineManager.ts#L117) + +Singleton instance of [OnlineManager](../interfaces/OnlineManager.md), used to manage and observe the online state within TanStack Query. diff --git a/docs/framework/angular/reference/variables/skipToken.md b/docs/framework/angular/reference/variables/skipToken.md new file mode 100644 index 00000000000..a390d0b7b66 --- /dev/null +++ b/docs/framework/angular/reference/variables/skipToken.md @@ -0,0 +1,23 @@ +--- +id: skipToken +title: skipToken +--- + +```ts +const skipToken: typeof skipToken; +``` + +Defined in: [packages/query-core/src/utils.ts:522](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L522) + +Sentinel value that can be passed as a query's `queryFn` to conditionally disable the query (equivalent +to `enabled: false`) while preserving full type inference for the query's data. Unlike `enabled: false`, +a query disabled via `skipToken` cannot be triggered with `refetch`. + +## Example + +```ts +new QueryObserver(queryClient, { + queryKey: ['post', postId], + queryFn: postId != null ? () => fetchPost(postId) : skipToken, +}) +``` diff --git a/docs/framework/angular/reference/variables/timeoutManager.md b/docs/framework/angular/reference/variables/timeoutManager.md new file mode 100644 index 00000000000..1eca1a5f343 --- /dev/null +++ b/docs/framework/angular/reference/variables/timeoutManager.md @@ -0,0 +1,12 @@ +--- +id: timeoutManager +title: timeoutManager +--- + +```ts +const timeoutManager: TimeoutManager; +``` + +Defined in: [packages/query-core/src/timeoutManager.ts:232](https://github.com/TanStack/query/blob/main/packages/query-core/src/timeoutManager.ts#L232) + +Singleton instance of [TimeoutManager](../interfaces/TimeoutManager.md), used throughout TanStack Query to schedule and cancel timers. diff --git a/docs/framework/angular/reference/variables/unsetMarker.md b/docs/framework/angular/reference/variables/unsetMarker.md new file mode 100644 index 00000000000..d19ee65b38e --- /dev/null +++ b/docs/framework/angular/reference/variables/unsetMarker.md @@ -0,0 +1,10 @@ +--- +id: unsetMarker +title: unsetMarker +--- + +```ts +const unsetMarker: typeof unsetMarker; +``` + +Defined in: [packages/query-core/src/types.ts:65](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L65) diff --git a/docs/framework/lit/reference/classes/CancelledError.md b/docs/framework/lit/reference/classes/CancelledError.md new file mode 100644 index 00000000000..dd8b31d2c24 --- /dev/null +++ b/docs/framework/lit/reference/classes/CancelledError.md @@ -0,0 +1,75 @@ +--- +id: CancelledError +title: CancelledError +--- + +Defined in: [packages/query-core/src/retryer.ts:77](https://github.com/TanStack/query/blob/main/packages/query-core/src/retryer.ts#L77) + +The error thrown by a `Retryer` (and surfaced to `query.promise`/`mutation`) when a fetch is cancelled, e.g. via +`query.cancel()`. `revert`, if `true`, tells the caller to restore the state the query was in before the fetch +started instead of surfacing the error. `silent`, if `true`, tells the caller to suppress this error and instead +resolve with the promise of the fetch that triggered the cancellation. + +## Example + +```ts +query.cancel() + +try { + await query.promise +} catch (error) { + if (error instanceof CancelledError) { + // the fetch was cancelled, e.g. via `query.cancel()` + } +} +``` + +## Extends + +- `Error` + +## Constructors + +### Constructor + +```ts +new CancelledError(options?): CancelledError; +``` + +Defined in: [packages/query-core/src/retryer.ts:80](https://github.com/TanStack/query/blob/main/packages/query-core/src/retryer.ts#L80) + +#### Parameters + +##### options? + +[`CancelOptions`](../interfaces/CancelOptions.md) + +#### Returns + +`CancelledError` + +#### Overrides + +```ts +Error.constructor +``` + +## Properties + +### revert? + +```ts +optional revert: boolean; +``` + +Defined in: [packages/query-core/src/retryer.ts:78](https://github.com/TanStack/query/blob/main/packages/query-core/src/retryer.ts#L78) + +*** + +### silent? + +```ts +optional silent: boolean; +``` + +Defined in: [packages/query-core/src/retryer.ts:79](https://github.com/TanStack/query/blob/main/packages/query-core/src/retryer.ts#L79) diff --git a/docs/framework/lit/reference/classes/InfiniteQueryObserver.md b/docs/framework/lit/reference/classes/InfiniteQueryObserver.md new file mode 100644 index 00000000000..af43087a3ad --- /dev/null +++ b/docs/framework/lit/reference/classes/InfiniteQueryObserver.md @@ -0,0 +1,665 @@ +--- +id: InfiniteQueryObserver +title: InfiniteQueryObserver +--- + +Defined in: [packages/query-core/src/infiniteQueryObserver.ts:41](https://github.com/TanStack/query/blob/main/packages/query-core/src/infiniteQueryObserver.ts#L41) + +An `InfiniteQueryObserver` extends `QueryObserver` to observe and switch +between infinite queries. It augments the base `QueryObserverResult` with +infinite-query-specific fields and methods, such as `hasNextPage` and +`fetchNextPage`, and is the primitive that framework adapters (e.g. +`useInfiniteQuery`) build their hooks on top of. + +## Example + +```ts +const observer = new InfiniteQueryObserver(queryClient, { + queryKey: ['projects'], + queryFn: ({ pageParam }) => fetchProjects(pageParam), + initialPageParam: 0, + getNextPageParam: (lastPage) => lastPage.nextCursor, +}) + +const unsubscribe = observer.subscribe((result) => console.log(result)) +``` + +## Extends + +- [`QueryObserver`](QueryObserver.md)\<`TQueryFnData`, `TError`, `TData`, [`InfiniteData`](../interfaces/InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\> + +## Type Parameters + +### TQueryFnData + +`TQueryFnData` = `unknown` + +### TError + +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) + +### TData + +`TData` = [`InfiniteData`](../interfaces/InfiniteData.md)\<`TQueryFnData`\> + +### TQueryKey + +`TQueryKey` *extends* [`QueryKey`](../type-aliases/QueryKey.md) = [`QueryKey`](../type-aliases/QueryKey.md) + +### TPageParam + +`TPageParam` = `unknown` + +## Constructors + +### Constructor + +```ts +new InfiniteQueryObserver(client, options): InfiniteQueryObserver; +``` + +Defined in: [packages/query-core/src/infiniteQueryObserver.ts:83](https://github.com/TanStack/query/blob/main/packages/query-core/src/infiniteQueryObserver.ts#L83) + +#### Parameters + +##### client + +[`QueryClient`](QueryClient.md) + +##### options + +[`InfiniteQueryObserverOptions`](../interfaces/InfiniteQueryObserverOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`, `TPageParam`\> + +#### Returns + +`InfiniteQueryObserver`\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`, `TPageParam`\> + +#### Overrides + +[`QueryObserver`](QueryObserver.md).[`constructor`](QueryObserver.md#constructor) + +## Properties + +### fetch + +```ts +protected fetch: ReplaceReturnType<(fetchOptions) => Promise>, Promise>>; +``` + +Defined in: [packages/query-core/src/infiniteQueryObserver.ts:72](https://github.com/TanStack/query/blob/main/packages/query-core/src/infiniteQueryObserver.ts#L72) + +#### Overrides + +```ts +QueryObserver.fetch +``` + +*** + +### getCurrentResult + +```ts +getCurrentResult: ReplaceReturnType<() => QueryObserverResult, InfiniteQueryObserverResult>; +``` + +Defined in: [packages/query-core/src/infiniteQueryObserver.ts:60](https://github.com/TanStack/query/blob/main/packages/query-core/src/infiniteQueryObserver.ts#L60) + +Returns the most recently computed `QueryObserverResult` for the +observed query. This is a point-in-time read; to be notified of updates +as they happen, subscribe to the observer instead (its inherited +`subscribe` method). + +#### Example + +```ts +const result = observer.getCurrentResult() +console.log(result.status, result.data) +``` + +#### Overrides + +```ts +QueryObserver.getCurrentResult +``` + +*** + +### listeners + +```ts +protected listeners: Set>; +``` + +Defined in: [packages/query-core/src/subscribable.ts:2](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L2) + +#### Inherited from + +[`QueryObserver`](QueryObserver.md).[`listeners`](QueryObserver.md#listeners) + +*** + +### options + +```ts +options: QueryObserverOptions, TQueryKey>; +``` + +Defined in: [packages/query-core/src/queryObserver.ts:89](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L89) + +#### Inherited from + +[`QueryObserver`](QueryObserver.md).[`options`](QueryObserver.md#options) + +*** + +### subscribe() + +```ts +subscribe: (listener) => () => void; +``` + +Defined in: [packages/query-core/src/infiniteQueryObserver.ts:55](https://github.com/TanStack/query/blob/main/packages/query-core/src/infiniteQueryObserver.ts#L55) + +#### Parameters + +##### listener + +`InfiniteQueryObserverListener` + +#### Returns + +```ts +(): void; +``` + +##### Returns + +`void` + +#### Overrides + +```ts +QueryObserver.subscribe +``` + +## Methods + +### bindMethods() + +```ts +protected bindMethods(): void; +``` + +Defined in: [packages/query-core/src/infiniteQueryObserver.ts:96](https://github.com/TanStack/query/blob/main/packages/query-core/src/infiniteQueryObserver.ts#L96) + +#### Returns + +`void` + +#### Overrides + +[`QueryObserver`](QueryObserver.md).[`bindMethods`](QueryObserver.md#bindmethods) + +*** + +### createResult() + +```ts +protected createResult(query, options): InfiniteQueryObserverResult; +``` + +Defined in: [packages/query-core/src/infiniteQueryObserver.ts:201](https://github.com/TanStack/query/blob/main/packages/query-core/src/infiniteQueryObserver.ts#L201) + +#### Parameters + +##### query + +[`Query`](Query.md)\<`TQueryFnData`, `TError`, [`InfiniteData`](../interfaces/InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\> + +##### options + +[`InfiniteQueryObserverOptions`](../interfaces/InfiniteQueryObserverOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`, `TPageParam`\> + +#### Returns + +[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\> + +#### Overrides + +[`QueryObserver`](QueryObserver.md).[`createResult`](QueryObserver.md#createresult) + +*** + +### destroy() + +```ts +destroy(): void; +``` + +Defined in: [packages/query-core/src/queryObserver.ts:161](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L161) + +Stops observing the current query: clears all listeners, cancels the +stale and refetch-interval timers, and removes this observer from the +query it was observing. + +#### Returns + +`void` + +#### Inherited from + +[`QueryObserver`](QueryObserver.md).[`destroy`](QueryObserver.md#destroy) + +*** + +### fetchNextPage() + +```ts +fetchNextPage(options?): Promise>; +``` + +Defined in: [packages/query-core/src/infiniteQueryObserver.ts:161](https://github.com/TanStack/query/blob/main/packages/query-core/src/infiniteQueryObserver.ts#L161) + +Fetches the next page of the infinite query and returns a promise that +resolves with the resulting `InfiniteQueryObserverResult`. The page +param used for the fetch is determined by `getNextPageParam`, which +receives the current pages/page params and whose result also determines +`hasNextPage`. + +#### Parameters + +##### options? + +[`FetchNextPageOptions`](../interfaces/FetchNextPageOptions.md) + +#### Returns + +`Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> + +#### Example + +```ts +const { hasNextPage } = observer.getCurrentResult() + +if (hasNextPage) { + await observer.fetchNextPage() +} +``` + +#### See + +[InfiniteQueryObserver#fetchPreviousPage](#fetchpreviouspage) + +*** + +### fetchOptimistic() + +```ts +fetchOptimistic(options): Promise>; +``` + +Defined in: [packages/query-core/src/queryObserver.ts:395](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L395) + +Fetches a query defined by the given options without affecting this +observer's own tracked query or result, and returns a promise that +resolves with the `QueryObserverResult` for that fetch. This is useful +for prefetching data that another observer (e.g. a query about to be +navigated to) will need, ahead of time. + +#### Parameters + +##### options + +[`QueryObserverOptions`](../interfaces/QueryObserverOptions.md)\<`TQueryFnData`, `TError`, `TData`, [`InfiniteData`](../interfaces/InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\> + +#### Returns + +`Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> + +#### Example + +```ts +const result = await observer.fetchOptimistic({ + queryKey: ['posts', 2], + queryFn: () => fetchPost(2), +}) +console.log(result.data) +``` + +#### Inherited from + +[`QueryObserver`](QueryObserver.md).[`fetchOptimistic`](QueryObserver.md#fetchoptimistic) + +*** + +### fetchPreviousPage() + +```ts +fetchPreviousPage(options?): Promise>; +``` + +Defined in: [packages/query-core/src/infiniteQueryObserver.ts:190](https://github.com/TanStack/query/blob/main/packages/query-core/src/infiniteQueryObserver.ts#L190) + +Fetches the previous page of the infinite query and returns a promise +that resolves with the resulting `InfiniteQueryObserverResult`. The page +param used for the fetch is determined by `getPreviousPageParam`, which +receives the current pages/page params and whose result also determines +`hasPreviousPage`. + +#### Parameters + +##### options? + +[`FetchPreviousPageOptions`](../interfaces/FetchPreviousPageOptions.md) + +#### Returns + +`Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> + +#### Example + +```ts +const { hasPreviousPage } = observer.getCurrentResult() + +if (hasPreviousPage) { + await observer.fetchPreviousPage() +} +``` + +#### See + +[InfiniteQueryObserver#fetchNextPage](#fetchnextpage) + +*** + +### getCurrentQuery() + +```ts +getCurrentQuery(): Query, TQueryKey>; +``` + +Defined in: [packages/query-core/src/queryObserver.ts:357](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L357) + +Returns the `Query` instance this observer is currently observing. + +#### Returns + +[`Query`](Query.md)\<`TQueryFnData`, `TError`, [`InfiniteData`](../interfaces/InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\> + +#### Inherited from + +[`QueryObserver`](QueryObserver.md).[`getCurrentQuery`](QueryObserver.md#getcurrentquery) + +*** + +### getOptimisticResult() + +```ts +getOptimisticResult(options): InfiniteQueryObserverResult; +``` + +Defined in: [packages/query-core/src/infiniteQueryObserver.ts:127](https://github.com/TanStack/query/blob/main/packages/query-core/src/infiniteQueryObserver.ts#L127) + +The infinite-query counterpart of [QueryObserver#getOptimisticResult](QueryObserver.md#getoptimisticresult), marking the +options as an infinite query before delegating to it. Called by framework adapters (e.g. +`useInfiniteQuery`) ahead of subscribing, to compute the current `InfiniteQueryObserverResult` +synchronously. + +#### Parameters + +##### options + +[`DefaultedInfiniteQueryObserverOptions`](../type-aliases/DefaultedInfiniteQueryObserverOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`, `TPageParam`\> + +#### Returns + +[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\> + +#### Overrides + +[`QueryObserver`](QueryObserver.md).[`getOptimisticResult`](QueryObserver.md#getoptimisticresult) + +*** + +### hasListeners() + +```ts +hasListeners(): boolean; +``` + +Defined in: [packages/query-core/src/subscribable.ts:19](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L19) + +#### Returns + +`boolean` + +#### Inherited from + +[`QueryObserver`](QueryObserver.md).[`hasListeners`](QueryObserver.md#haslisteners) + +*** + +### onSubscribe() + +```ts +protected onSubscribe(): void; +``` + +Defined in: [packages/query-core/src/queryObserver.ts:110](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L110) + +#### Returns + +`void` + +#### Inherited from + +[`QueryObserver`](QueryObserver.md).[`onSubscribe`](QueryObserver.md#onsubscribe) + +*** + +### onUnsubscribe() + +```ts +protected onUnsubscribe(): void; +``` + +Defined in: [packages/query-core/src/queryObserver.ts:124](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L124) + +#### Returns + +`void` + +#### Inherited from + +[`QueryObserver`](QueryObserver.md).[`onUnsubscribe`](QueryObserver.md#onunsubscribe) + +*** + +### refetch() + +```ts +refetch(__namedParameters): Promise>; +``` + +Defined in: [packages/query-core/src/queryObserver.ts:371](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L371) + +Refetches the observed query and returns a promise that resolves with +the resulting `QueryObserverResult`. + +#### Parameters + +##### \_\_namedParameters + +[`RefetchOptions`](../interfaces/RefetchOptions.md) = `{}` + +#### Returns + +`Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> + +#### Example + +```ts +const result = await observer.refetch({ cancelRefetch: false }) +console.log(result.data) +``` + +#### Inherited from + +[`QueryObserver`](QueryObserver.md).[`refetch`](QueryObserver.md#refetch) + +*** + +### setOptions() + +```ts +setOptions(options): void; +``` + +Defined in: [packages/query-core/src/infiniteQueryObserver.ts:108](https://github.com/TanStack/query/blob/main/packages/query-core/src/infiniteQueryObserver.ts#L108) + +Updates the observer's options. Behaves the same as +`QueryObserver.setOptions`, additionally marking the options as +belonging to an infinite query before delegating to the base +implementation. + +#### Parameters + +##### options + +[`InfiniteQueryObserverOptions`](../interfaces/InfiniteQueryObserverOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`, `TPageParam`\> + +#### Returns + +`void` + +#### Overrides + +[`QueryObserver`](QueryObserver.md).[`setOptions`](QueryObserver.md#setoptions) + +*** + +### shouldFetchOnReconnect() + +```ts +shouldFetchOnReconnect(): boolean; +``` + +Defined in: [packages/query-core/src/queryObserver.ts:135](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L135) + +Returns whether the observed query is currently stale and configured +(via the `refetchOnReconnect` option) to refetch when the network +reconnects. + +#### Returns + +`boolean` + +#### Inherited from + +[`QueryObserver`](QueryObserver.md).[`shouldFetchOnReconnect`](QueryObserver.md#shouldfetchonreconnect) + +*** + +### shouldFetchOnWindowFocus() + +```ts +shouldFetchOnWindowFocus(): boolean; +``` + +Defined in: [packages/query-core/src/queryObserver.ts:148](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L148) + +Returns whether the observed query is currently stale and configured +(via the `refetchOnWindowFocus` option) to refetch when the window +regains focus. + +#### Returns + +`boolean` + +#### Inherited from + +[`QueryObserver`](QueryObserver.md).[`shouldFetchOnWindowFocus`](QueryObserver.md#shouldfetchonwindowfocus) + +*** + +### trackProp() + +```ts +trackProp(key): void; +``` + +Defined in: [packages/query-core/src/queryObserver.ts:350](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L350) + +Records that the given `QueryObserverResult` property was read, so a subsequent update only +notifies this observer if a tracked property actually changed. Normally called indirectly via +[QueryObserver#trackResult](QueryObserver.md#trackresult)'s proxy; exposed directly for adapters that track property +access themselves (e.g. through their own reactivity system) instead of via the proxy. + +#### Parameters + +##### key + +`"error"` | `"data"` | `"isError"` | `"isPending"` | `"isLoading"` | `"isLoadingError"` | `"isRefetchError"` | `"isSuccess"` | `"isPlaceholderData"` | `"status"` | `"dataUpdatedAt"` | `"errorUpdatedAt"` | `"failureCount"` | `"failureReason"` | `"errorUpdateCount"` | `"isFetched"` | `"isFetchedAfterMount"` | `"isFetching"` | `"isInitialLoading"` | `"isPaused"` | `"isRefetching"` | `"isStale"` | `"isEnabled"` | `"refetch"` | `"fetchStatus"` + +#### Returns + +`void` + +#### Inherited from + +[`QueryObserver`](QueryObserver.md).[`trackProp`](QueryObserver.md#trackprop) + +*** + +### trackResult() + +```ts +trackResult(result, onPropTracked?): QueryObserverResult; +``` + +Defined in: [packages/query-core/src/queryObserver.ts:331](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L331) + +Wraps a `QueryObserverResult` in a `Proxy` that records which properties are read, via +[QueryObserver#trackProp](QueryObserver.md#trackprop) (and an optional `onPropTracked` callback). Used by framework +adapters when `notifyOnChangeProps` is not set, to implement its default "only re-render on +properties you actually read" behavior. + +#### Parameters + +##### result + +[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\> + +##### onPropTracked? + +(`key`) => `void` + +#### Returns + +[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\> + +#### Inherited from + +[`QueryObserver`](QueryObserver.md).[`trackResult`](QueryObserver.md#trackresult) + +*** + +### updateResult() + +```ts +updateResult(): void; +``` + +Defined in: [packages/query-core/src/queryObserver.ts:735](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L735) + +Recomputes and stores the current result from the current query/options, notifying listeners +if it changed. Framework adapters call this right after subscribing to make sure no query +update was missed in the gap between creating the observer and subscribing to it. + +#### Returns + +`void` + +#### Inherited from + +[`QueryObserver`](QueryObserver.md).[`updateResult`](QueryObserver.md#updateresult) diff --git a/docs/framework/lit/reference/classes/Mutation.md b/docs/framework/lit/reference/classes/Mutation.md new file mode 100644 index 00000000000..e038a9cd394 --- /dev/null +++ b/docs/framework/lit/reference/classes/Mutation.md @@ -0,0 +1,330 @@ +--- +id: Mutation +title: Mutation +--- + +Defined in: [packages/query-core/src/mutation.ts:135](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L135) + +Represents a single mutation attempt. A `Mutation` holds the mutation's +options, state (data/error/status), and the `MutationObserver`s currently +subscribed to it. + +Instances are created and managed internally by `MutationCache`; application +code typically interacts with mutations indirectly through `QueryClient` or +a framework hook like `useMutation`. Direct access to a `Mutation` instance +is possible via `mutationCache.find()`/`getAll()` for inspecting cache state. + +## Example + +```ts +const mutationCache = queryClient.getMutationCache() + +const mutation = mutationCache.find({ mutationKey: ['addPost'] }) +``` + +## Extends + +- `Removable` + +## Type Parameters + +### TData + +`TData` = `unknown` + +### TError + +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) + +### TVariables + +`TVariables` = `unknown` + +### TOnMutateResult + +`TOnMutateResult` = `unknown` + +## Constructors + +### Constructor + +```ts +new Mutation(config): Mutation; +``` + +Defined in: [packages/query-core/src/mutation.ts:152](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L152) + +#### Parameters + +##### config + +`MutationConfig`\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\> + +#### Returns + +`Mutation`\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\> + +#### Overrides + +```ts +Removable.constructor +``` + +## Properties + +### gcTime + +```ts +gcTime: number; +``` + +Defined in: [packages/query-core/src/removable.ts:7](https://github.com/TanStack/query/blob/main/packages/query-core/src/removable.ts#L7) + +#### Inherited from + +```ts +Removable.gcTime +``` + +*** + +### mutationId + +```ts +readonly mutationId: number; +``` + +Defined in: [packages/query-core/src/mutation.ts:143](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L143) + +*** + +### options + +```ts +options: MutationOptions; +``` + +Defined in: [packages/query-core/src/mutation.ts:142](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L142) + +*** + +### state + +```ts +state: MutationState; +``` + +Defined in: [packages/query-core/src/mutation.ts:141](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L141) + +## Accessors + +### meta + +#### Get Signature + +```ts +get meta(): Record | undefined; +``` + +Defined in: [packages/query-core/src/mutation.ts:179](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L179) + +The `meta` object passed in the mutation's options, if any. + +##### Returns + +`Record`\<`string`, `unknown`\> \| `undefined` + +## Methods + +### clearGcTimeout() + +```ts +protected clearGcTimeout(): void; +``` + +Defined in: [packages/query-core/src/removable.ts:32](https://github.com/TanStack/query/blob/main/packages/query-core/src/removable.ts#L32) + +#### Returns + +`void` + +#### Inherited from + +```ts +Removable.clearGcTimeout +``` + +*** + +### continue() + +```ts +continue(): Promise; +``` + +Defined in: [packages/query-core/src/mutation.ts:243](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L243) + +Resumes a mutation that is currently paused or was restored from a +dehydrated, still-`pending` state. + +- If this mutation has an active retryer (it paused mid-attempt, e.g. due + to the network mode or scope-based queuing), its retryer is resumed. +- Otherwise, if the mutation's status is still `pending` (e.g. it was + dehydrated while an attempt was in flight and never got a retryer in + this instance), `execute` is called again with the last known variables. +- Otherwise the mutation has already settled and this resolves immediately + without running anything again. + +#### Returns + +`Promise`\<`unknown`\> + +#### Example + +```ts +// typically driven by reconnect handling, e.g. queryClient.resumePausedMutations() +const mutation = mutationCache.find({ mutationKey: ['addPost'] }) +await mutation?.continue() +``` + +#### See + +[Mutation#execute](#execute) + +*** + +### destroy() + +```ts +destroy(): void; +``` + +Defined in: [packages/query-core/src/removable.ts:10](https://github.com/TanStack/query/blob/main/packages/query-core/src/removable.ts#L10) + +#### Returns + +`void` + +#### Inherited from + +```ts +Removable.destroy +``` + +*** + +### execute() + +```ts +execute(variables): Promise; +``` + +Defined in: [packages/query-core/src/mutation.ts:284](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L284) + +Runs the mutation function for the given variables through a retryer, and +drives the mutation's state and lifecycle callbacks through to settlement. + +If this mutation's state is already `pending` when `execute` is called +(i.e. it was restored, still in-flight, from a dehydrated state), the +`onMutate` step is skipped and a `continue` action is dispatched to +unpause it; otherwise a `pending` action is dispatched first, then the +mutation cache's `onMutate` and the mutation's own `onMutate` option are +awaited in that order, and the resulting context is stored. + +The mutation function is then run (subject to `retry`/`retryDelay`/ +`networkMode`, and to the mutation cache's scope-based serialization). +On success, the cache's `onSuccess`/`onSettled` callbacks run before the +mutation's own `onSuccess`/`onSettled` options, a `success` action is +dispatched, and the resolved data is returned. On failure, the same +cache-then-option ordering is used for `onError`/`onSettled`, but each of +those four callbacks is individually caught so that a throwing callback +cannot mask the original error; an `error` action is then dispatched and +the original error is re-thrown. + +#### Parameters + +##### variables + +`TVariables` + +#### Returns + +`Promise`\<`TData`\> + +#### Example + +```ts +// Called internally by `MutationObserver.mutate` and `Mutation.continue` — +// applications normally trigger mutations through those, not this method. +const data = await mutation.execute(variables) +``` + +#### See + +[Mutation#continue](#continue) + +*** + +### optionalRemove() + +```ts +protected optionalRemove(): void; +``` + +Defined in: [packages/query-core/src/mutation.ts:212](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L212) + +#### Returns + +`void` + +#### Overrides + +```ts +Removable.optionalRemove +``` + +*** + +### scheduleGc() + +```ts +protected scheduleGc(): void; +``` + +Defined in: [packages/query-core/src/removable.ts:14](https://github.com/TanStack/query/blob/main/packages/query-core/src/removable.ts#L14) + +#### Returns + +`void` + +#### Inherited from + +```ts +Removable.scheduleGc +``` + +*** + +### updateGcTime() + +```ts +protected updateGcTime(newGcTime): void; +``` + +Defined in: [packages/query-core/src/removable.ts:24](https://github.com/TanStack/query/blob/main/packages/query-core/src/removable.ts#L24) + +#### Parameters + +##### newGcTime + +`number` | `undefined` + +#### Returns + +`void` + +#### Inherited from + +```ts +Removable.updateGcTime +``` diff --git a/docs/framework/lit/reference/classes/MutationCache.md b/docs/framework/lit/reference/classes/MutationCache.md new file mode 100644 index 00000000000..067363d312b --- /dev/null +++ b/docs/framework/lit/reference/classes/MutationCache.md @@ -0,0 +1,316 @@ +--- +id: MutationCache +title: MutationCache +--- + +Defined in: [packages/query-core/src/mutationCache.ts:124](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationCache.ts#L124) + +The `MutationCache` is the storage for mutations. + +Normally, you will not interact with the `MutationCache` directly and instead use a +`QueryClient`. You can subscribe to it (inherited from `Subscribable`) to be informed of +safe/known updates to the cache, such as mutations being added, removed, or updated. + +## Example + +```ts +const unsubscribe = mutationCache.subscribe((event) => { + console.log(event.type, event.mutation) +}) +``` + +## Extends + +- `Subscribable`\<`MutationCacheListener`\> + +## Constructors + +### Constructor + +```ts +new MutationCache(config): MutationCache; +``` + +Defined in: [packages/query-core/src/mutationCache.ts:129](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationCache.ts#L129) + +#### Parameters + +##### config + +[`MutationCacheConfig`](../interfaces/MutationCacheConfig.md) = `{}` + +#### Returns + +`MutationCache` + +#### Overrides + +```ts +Subscribable.constructor +``` + +## Properties + +### config + +```ts +config: MutationCacheConfig = {}; +``` + +Defined in: [packages/query-core/src/mutationCache.ts:129](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationCache.ts#L129) + +*** + +### listeners + +```ts +protected listeners: Set; +``` + +Defined in: [packages/query-core/src/subscribable.ts:2](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L2) + +#### Inherited from + +```ts +Subscribable.listeners +``` + +## Methods + +### clear() + +```ts +clear(): void; +``` + +Defined in: [packages/query-core/src/mutationCache.ts:236](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationCache.ts#L236) + +Removes all mutations from the cache. + +#### Returns + +`void` + +#### Example + +```ts +const mutationCache = queryClient.getMutationCache() + +mutationCache.clear() +``` + +*** + +### find() + +```ts +find(filters): + | Mutation + | undefined; +``` + +Defined in: [packages/query-core/src/mutationCache.ts:278](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationCache.ts#L278) + +A slightly more advanced method that can be used to get an existing mutation instance from +the cache. If the mutation does not exist, `undefined` is returned. + +This is not typically needed for most applications, but can come in handy when needing more +information about a mutation in rare scenarios. + +#### Type Parameters + +##### TData + +`TData` = `unknown` + +##### TError + +`TError` = `Error` + +##### TVariables + +`TVariables` = `any` + +##### TOnMutateResult + +`TOnMutateResult` = `unknown` + +#### Parameters + +##### filters + +[`MutationFilters`](../interfaces/MutationFilters.md) + +#### Returns + + \| [`Mutation`](Mutation.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\> + \| `undefined` + +#### See + +[MutationCache#findAll](#findall) + +#### Example + +```ts +const mutationCache = queryClient.getMutationCache() + +const mutation = mutationCache.find({ mutationKey: ['addPost'] }) +``` + +*** + +### findAll() + +```ts +findAll(filters): Mutation[]; +``` + +Defined in: [packages/query-core/src/mutationCache.ts:308](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationCache.ts#L308) + +An even more advanced method that can be used to get existing mutation instances from the +cache that match the given filters. If no mutations match, an empty array is returned. + +This is not typically needed for most applications, but can come in handy when needing more +information about mutations in rare scenarios. + +#### Parameters + +##### filters + +[`MutationFilters`](../interfaces/MutationFilters.md) = `{}` + +#### Returns + +[`Mutation`](Mutation.md)\<`unknown`, `Error`, `unknown`, `unknown`\>[] + +#### See + +[MutationCache#find](#find) + +#### Example + +```ts +const mutationCache = queryClient.getMutationCache() + +const mutations = mutationCache.findAll({ mutationKey: ['addPost'] }) +``` + +*** + +### getAll() + +```ts +getAll(): Mutation[]; +``` + +Defined in: [packages/query-core/src/mutationCache.ts:259](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationCache.ts#L259) + +Returns all mutations within the cache. + +This is not typically needed for most applications, but can come in handy when needing more +information about a mutation in rare scenarios. + +#### Returns + +[`Mutation`](Mutation.md)\<`unknown`, `Error`, `unknown`, `unknown`\>[] + +#### Example + +```ts +const mutationCache = queryClient.getMutationCache() + +const mutations = mutationCache.getAll() +``` + +*** + +### hasListeners() + +```ts +hasListeners(): boolean; +``` + +Defined in: [packages/query-core/src/subscribable.ts:19](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L19) + +#### Returns + +`boolean` + +#### Inherited from + +```ts +Subscribable.hasListeners +``` + +*** + +### onSubscribe() + +```ts +protected onSubscribe(): void; +``` + +Defined in: [packages/query-core/src/subscribable.ts:23](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L23) + +#### Returns + +`void` + +#### Inherited from + +```ts +Subscribable.onSubscribe +``` + +*** + +### onUnsubscribe() + +```ts +protected onUnsubscribe(): void; +``` + +Defined in: [packages/query-core/src/subscribable.ts:27](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L27) + +#### Returns + +`void` + +#### Inherited from + +```ts +Subscribable.onUnsubscribe +``` + +*** + +### subscribe() + +```ts +subscribe(listener): () => void; +``` + +Defined in: [packages/query-core/src/subscribable.ts:8](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L8) + +#### Parameters + +##### listener + +`MutationCacheListener` + +#### Returns + +```ts +(): void; +``` + +##### Returns + +`void` + +#### Inherited from + +```ts +Subscribable.subscribe +``` diff --git a/docs/framework/lit/reference/classes/MutationObserver.md b/docs/framework/lit/reference/classes/MutationObserver.md new file mode 100644 index 00000000000..a121c67b0e8 --- /dev/null +++ b/docs/framework/lit/reference/classes/MutationObserver.md @@ -0,0 +1,335 @@ +--- +id: MutationObserver +title: MutationObserver +--- + +Defined in: [packages/query-core/src/mutationObserver.ts:38](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationObserver.ts#L38) + +Observes a single mutation and derives a `MutationObserverResult` from it. +A framework hook like `useMutation` creates one `MutationObserver` per hook +call, keeps it stable across re-renders, calls `setOptions` when the options +passed to the hook change, subscribes to it to re-render on updates, and +reads `getCurrentResult()` for the value to return. Calling `mutate()` +builds a new underlying `Mutation` in the `MutationCache` and executes it. + +## Example + +```ts +const observer = new MutationObserver(queryClient, { + mutationFn: (variables: { title: string }) => addPost(variables), +}) +``` + +## Extends + +- `Subscribable`\<`MutationObserverListener`\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\>\> + +## Type Parameters + +### TData + +`TData` = `unknown` + +### TError + +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) + +### TVariables + +`TVariables` = `void` + +### TOnMutateResult + +`TOnMutateResult` = `unknown` + +## Constructors + +### Constructor + +```ts +new MutationObserver(client, options): MutationObserver; +``` + +Defined in: [packages/query-core/src/mutationObserver.ts:58](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationObserver.ts#L58) + +#### Parameters + +##### client + +[`QueryClient`](QueryClient.md) + +##### options + +[`MutationObserverOptions`](../interfaces/MutationObserverOptions.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\> + +#### Returns + +`MutationObserver`\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\> + +#### Overrides + +```ts +Subscribable< + MutationObserverListener +>.constructor +``` + +## Properties + +### listeners + +```ts +protected listeners: Set>; +``` + +Defined in: [packages/query-core/src/subscribable.ts:2](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L2) + +#### Inherited from + +```ts +Subscribable.listeners +``` + +*** + +### options + +```ts +options: MutationObserverOptions; +``` + +Defined in: [packages/query-core/src/mutationObserver.ts:46](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationObserver.ts#L46) + +## Methods + +### bindMethods() + +```ts +protected bindMethods(): void; +``` + +Defined in: [packages/query-core/src/mutationObserver.ts:75](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationObserver.ts#L75) + +#### Returns + +`void` + +*** + +### getCurrentResult() + +```ts +getCurrentResult(): MutationObserverResult; +``` + +Defined in: [packages/query-core/src/mutationObserver.ts:155](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationObserver.ts#L155) + +Returns the observer's current result, derived from the observed +mutation's state (or the default, `idle` state if no mutation has been +built yet, e.g. before the first `mutate()` call or after `reset()`). + +#### Returns + +[`MutationObserverResult`](../type-aliases/MutationObserverResult.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\> + +*** + +### hasListeners() + +```ts +hasListeners(): boolean; +``` + +Defined in: [packages/query-core/src/subscribable.ts:19](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L19) + +#### Returns + +`boolean` + +#### Inherited from + +```ts +Subscribable.hasListeners +``` + +*** + +### mutate() + +```ts +mutate(variables, options?): Promise; +``` + +Defined in: [packages/query-core/src/mutationObserver.ts:207](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationObserver.ts#L207) + +Builds a new `Mutation` in the `MutationCache` using the observer's +current options, detaches this observer from any previously observed +mutation, attaches it to the new one, and executes it with the given +variables. + +The optional per-call `options` (`onSuccess`/`onError`/`onSettled`) are +invoked once the mutation settles, in addition to any callbacks defined +on the observer's own options. + +#### Parameters + +##### variables + +`TVariables` + +##### options? + +[`MutateOptions`](../interfaces/MutateOptions.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\> + +#### Returns + +`Promise`\<`TData`\> + +#### Example + +```ts +await observer.mutate( + { title: 'New post' }, + { onSuccess: (data) => console.log(data) }, +) +``` + +*** + +### onSubscribe() + +```ts +protected onSubscribe(): void; +``` + +Defined in: [packages/query-core/src/mutationObserver.ts:127](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationObserver.ts#L127) + +#### Returns + +`void` + +#### Overrides + +```ts +Subscribable.onSubscribe +``` + +*** + +### onUnsubscribe() + +```ts +protected onUnsubscribe(): void; +``` + +Defined in: [packages/query-core/src/mutationObserver.ts:135](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationObserver.ts#L135) + +#### Returns + +`void` + +#### Overrides + +```ts +Subscribable.onUnsubscribe +``` + +*** + +### reset() + +```ts +reset(): void; +``` + +Defined in: [packages/query-core/src/mutationObserver.ts:180](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationObserver.ts#L180) + +Detaches the observer from the mutation it is currently observing (if +any) and resets the observed result back to its default, `idle` state. + +This does not cancel an in-flight mutation; the mutation itself keeps +running to completion and its own callbacks still fire, but this +observer stops reflecting its state and a subsequent `mutate()` call +will build a brand new mutation. + +#### Returns + +`void` + +#### Example + +```ts +observer.reset() +``` + +#### See + +[MutationObserver#mutate](#mutate) + +*** + +### setOptions() + +```ts +setOptions(options): void; +``` + +Defined in: [packages/query-core/src/mutationObserver.ts:96](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationObserver.ts#L96) + +Updates the observer's options. + +If the new `mutationKey` differs from the previous one (and both were +defined), the observer is reset, detaching it from the mutation it was +observing. Otherwise, if the currently observed mutation is still +`pending`, its options are updated in place as well. + +#### Parameters + +##### options + +[`MutationObserverOptions`](../interfaces/MutationObserverOptions.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\> + +#### Returns + +`void` + +#### Example + +```ts +observer.setOptions({ + mutationFn: (variables: { title: string }) => addPost(variables), + onSuccess: (data) => console.log(data), +}) +``` + +*** + +### subscribe() + +```ts +subscribe(listener): () => void; +``` + +Defined in: [packages/query-core/src/subscribable.ts:8](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L8) + +#### Parameters + +##### listener + +`MutationObserverListener` + +#### Returns + +```ts +(): void; +``` + +##### Returns + +`void` + +#### Inherited from + +```ts +Subscribable.subscribe +``` diff --git a/docs/framework/lit/reference/classes/QueriesObserver.md b/docs/framework/lit/reference/classes/QueriesObserver.md new file mode 100644 index 00000000000..a64a0fa56f7 --- /dev/null +++ b/docs/framework/lit/reference/classes/QueriesObserver.md @@ -0,0 +1,325 @@ +--- +id: QueriesObserver +title: QueriesObserver +--- + +Defined in: [packages/query-core/src/queriesObserver.ts:56](https://github.com/TanStack/query/blob/main/packages/query-core/src/queriesObserver.ts#L56) + +A `QueriesObserver` watches an array of queries at once, exposing them as +a single array of `QueryObserverResult`s (or, when a `combine` option is +given, as a combined value derived from that array). It manages one +internal `QueryObserver` per query, and is the primitive that framework +adapters (e.g. `useQueries`) build their hooks on top of. + +## Example + +```ts +const observer = new QueriesObserver(queryClient, [ + { queryKey: ['post', 1], queryFn: fetchPost }, + { queryKey: ['post', 2], queryFn: fetchPost }, +]) + +const unsubscribe = observer.subscribe((result) => { + console.log(result) +}) +``` + +## Extends + +- `Subscribable`\<`QueriesObserverListener`\> + +## Type Parameters + +### TCombinedResult + +`TCombinedResult` = [`QueryObserverResult`](../type-aliases/QueryObserverResult.md)[] + +## Constructors + +### Constructor + +```ts +new QueriesObserver( + client, + queries, +options?): QueriesObserver; +``` + +Defined in: [packages/query-core/src/queriesObserver.ts:70](https://github.com/TanStack/query/blob/main/packages/query-core/src/queriesObserver.ts#L70) + +#### Parameters + +##### client + +[`QueryClient`](QueryClient.md) + +##### queries + +[`QueryObserverOptions`](../interfaces/QueryObserverOptions.md)\<`any`, `any`, `any`, `any`, `any`, `never`\>[] + +##### options? + +[`QueriesObserverOptions`](../interfaces/QueriesObserverOptions.md)\<`TCombinedResult`\> + +#### Returns + +`QueriesObserver`\<`TCombinedResult`\> + +#### Overrides + +```ts +Subscribable.constructor +``` + +## Properties + +### listeners + +```ts +protected listeners: Set; +``` + +Defined in: [packages/query-core/src/subscribable.ts:2](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L2) + +#### Inherited from + +```ts +Subscribable.listeners +``` + +## Methods + +### destroy() + +```ts +destroy(): void; +``` + +Defined in: [packages/query-core/src/queriesObserver.ts:106](https://github.com/TanStack/query/blob/main/packages/query-core/src/queriesObserver.ts#L106) + +Stops observing all queries: clears all listeners and destroys every +underlying `QueryObserver` this observer manages. + +#### Returns + +`void` + +*** + +### getCurrentResult() + +```ts +getCurrentResult(): QueryObserverResult[]; +``` + +Defined in: [packages/query-core/src/queriesObserver.ts:210](https://github.com/TanStack/query/blob/main/packages/query-core/src/queriesObserver.ts#L210) + +Returns the most recently computed array of `QueryObserverResult`s, one +per observed query, in the same order as the queries passed to the +constructor or `setQueries`. + +#### Returns + +[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)[] + +#### Example + +```ts +const results = observer.getCurrentResult() +const data = results.map((result) => result.data) +``` + +*** + +### getObservers() + +```ts +getObservers(): QueryObserver[]; +``` + +Defined in: [packages/query-core/src/queriesObserver.ts:227](https://github.com/TanStack/query/blob/main/packages/query-core/src/queriesObserver.ts#L227) + +Returns the underlying `QueryObserver` instances this observer manages, +in the same order as the queries passed to the constructor or +`setQueries`. + +#### Returns + +[`QueryObserver`](QueryObserver.md)\<`unknown`, `Error`, `unknown`, `unknown`, readonly `unknown`[]\>[] + +*** + +### getOptimisticResult() + +```ts +getOptimisticResult(queries, combine): [QueryObserverResult[], (r?) => TCombinedResult, () => QueryObserverResult[]]; +``` + +Defined in: [packages/query-core/src/queriesObserver.ts:238](https://github.com/TanStack/query/blob/main/packages/query-core/src/queriesObserver.ts#L238) + +The `QueriesObserver` counterpart of [QueryObserver#getOptimisticResult](QueryObserver.md#getoptimisticresult) — computes +the result for the given (already-defaulted) queries right now, synchronously. Called by +framework adapters (e.g. `useQueries`) ahead of subscribing, returning a tuple of the raw +per-query results, a function to compute the combined result from them, and a function to +wrap the results for property-access tracking. + +#### Parameters + +##### queries + +[`QueryObserverOptions`](../interfaces/QueryObserverOptions.md)\<`unknown`, `Error`, `unknown`, `unknown`, readonly `unknown`[], `never`\>[] + +##### combine + +`CombineFn`\<`TCombinedResult`\> | `undefined` + +#### Returns + +\[[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)[], (`r?`) => `TCombinedResult`, () => [`QueryObserverResult`](../type-aliases/QueryObserverResult.md)[]\] + +*** + +### getQueries() + +```ts +getQueries(): Query[]; +``` + +Defined in: [packages/query-core/src/queriesObserver.ts:218](https://github.com/TanStack/query/blob/main/packages/query-core/src/queriesObserver.ts#L218) + +Returns the underlying `Query` instances currently being observed, in +the same order as the queries passed to the constructor or `setQueries`. + +#### Returns + +[`Query`](Query.md)\<`unknown`, `Error`, `unknown`, readonly `unknown`[]\>[] + +*** + +### hasListeners() + +```ts +hasListeners(): boolean; +``` + +Defined in: [packages/query-core/src/subscribable.ts:19](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L19) + +#### Returns + +`boolean` + +#### Inherited from + +```ts +Subscribable.hasListeners +``` + +*** + +### onSubscribe() + +```ts +protected onSubscribe(): void; +``` + +Defined in: [packages/query-core/src/queriesObserver.ts:86](https://github.com/TanStack/query/blob/main/packages/query-core/src/queriesObserver.ts#L86) + +#### Returns + +`void` + +#### Overrides + +```ts +Subscribable.onSubscribe +``` + +*** + +### onUnsubscribe() + +```ts +protected onUnsubscribe(): void; +``` + +Defined in: [packages/query-core/src/queriesObserver.ts:96](https://github.com/TanStack/query/blob/main/packages/query-core/src/queriesObserver.ts#L96) + +#### Returns + +`void` + +#### Overrides + +```ts +Subscribable.onUnsubscribe +``` + +*** + +### setQueries() + +```ts +setQueries(queries, options?): void; +``` + +Defined in: [packages/query-core/src/queriesObserver.ts:127](https://github.com/TanStack/query/blob/main/packages/query-core/src/queriesObserver.ts#L127) + +Replaces the set of queries being observed. Existing `QueryObserver`s +are reused for queries that match an already-observed query hash; +observers for queries that are no longer present are destroyed, and new +observers are created and subscribed to for newly added queries. + +#### Parameters + +##### queries + +[`QueryObserverOptions`](../interfaces/QueryObserverOptions.md)\<`unknown`, `Error`, `unknown`, `unknown`, readonly `unknown`[], `never`\>[] + +##### options? + +[`QueriesObserverOptions`](../interfaces/QueriesObserverOptions.md)\<`TCombinedResult`\> + +#### Returns + +`void` + +#### Example + +```ts +observer.setQueries([ + { queryKey: ['post', 1], queryFn: fetchPost }, + { queryKey: ['post', 3], queryFn: fetchPost }, +]) +``` + +*** + +### subscribe() + +```ts +subscribe(listener): () => void; +``` + +Defined in: [packages/query-core/src/subscribable.ts:8](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L8) + +#### Parameters + +##### listener + +`QueriesObserverListener` + +#### Returns + +```ts +(): void; +``` + +##### Returns + +`void` + +#### Inherited from + +```ts +Subscribable.subscribe +``` diff --git a/docs/framework/lit/reference/classes/Query.md b/docs/framework/lit/reference/classes/Query.md new file mode 100644 index 00000000000..bc15461e541 --- /dev/null +++ b/docs/framework/lit/reference/classes/Query.md @@ -0,0 +1,585 @@ +--- +id: Query +title: Query +--- + +Defined in: [packages/query-core/src/query.ts:225](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L225) + +Represents a single cached query. A `Query` holds the query's key, options, +state (data/error/status), and the observers currently subscribed to it. + +Instances are created and managed internally by `QueryCache`; application +code typically interacts with queries indirectly through `QueryClient` or +a framework hook like `useQuery`. Direct access to a `Query` instance is +possible via `queryCache.find()`/`findAll()` for inspecting cache state. + +## Example + +```ts +const queryCache = queryClient.getQueryCache() +const query = queryCache.find({ queryKey: ['posts'] }) + +if (query) { + console.log(query.state.dataUpdatedAt) +} +``` + +## Extends + +- `Removable` + +## Type Parameters + +### TQueryFnData + +`TQueryFnData` = `unknown` + +### TError + +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) + +### TData + +`TData` = `TQueryFnData` + +### TQueryKey + +`TQueryKey` *extends* [`QueryKey`](../type-aliases/QueryKey.md) = [`QueryKey`](../type-aliases/QueryKey.md) + +## Constructors + +### Constructor + +```ts +new Query(config): Query; +``` + +Defined in: [packages/query-core/src/query.ts:246](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L246) + +#### Parameters + +##### config + +`QueryConfig`\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`\> + +#### Returns + +`Query`\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`\> + +#### Overrides + +```ts +Removable.constructor +``` + +## Properties + +### gcTime + +```ts +gcTime: number; +``` + +Defined in: [packages/query-core/src/removable.ts:7](https://github.com/TanStack/query/blob/main/packages/query-core/src/removable.ts#L7) + +#### Inherited from + +```ts +Removable.gcTime +``` + +*** + +### observers + +```ts +observers: QueryObserver[]; +``` + +Defined in: [packages/query-core/src/query.ts:242](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L242) + +*** + +### options + +```ts +options: QueryOptions; +``` + +Defined in: [packages/query-core/src/query.ts:233](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L233) + +*** + +### queryHash + +```ts +queryHash: string; +``` + +Defined in: [packages/query-core/src/query.ts:232](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L232) + +*** + +### queryKey + +```ts +queryKey: TQueryKey; +``` + +Defined in: [packages/query-core/src/query.ts:231](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L231) + +*** + +### state + +```ts +state: QueryState; +``` + +Defined in: [packages/query-core/src/query.ts:234](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L234) + +## Accessors + +### meta + +#### Get Signature + +```ts +get meta(): Record | undefined; +``` + +Defined in: [packages/query-core/src/query.ts:264](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L264) + +The `meta` object passed in the query's options, if any. + +##### Returns + +`Record`\<`string`, `unknown`\> \| `undefined` + +*** + +### promise + +#### Get Signature + +```ts +get promise(): Promise | undefined; +``` + +Defined in: [packages/query-core/src/query.ts:277](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L277) + +The promise for the currently in-flight fetch, if the query is fetching. +`undefined` when the query is not fetching. + +##### Returns + +`Promise`\<`TData`\> \| `undefined` + +## Methods + +### cancel() + +```ts +cancel(options?): Promise; +``` + +Defined in: [packages/query-core/src/query.ts:348](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L348) + +Cancels the query's currently in-flight fetch, if any. +- Returns a promise that resolves once the cancellation has settled. +- If no fetch is in progress, resolves immediately. + +#### Parameters + +##### options? + +[`CancelOptions`](../interfaces/CancelOptions.md) + +#### Returns + +`Promise`\<`void`\> + +#### Example + +```ts +await query.cancel() +``` + +*** + +### clearGcTimeout() + +```ts +protected clearGcTimeout(): void; +``` + +Defined in: [packages/query-core/src/removable.ts:32](https://github.com/TanStack/query/blob/main/packages/query-core/src/removable.ts#L32) + +#### Returns + +`void` + +#### Inherited from + +```ts +Removable.clearGcTimeout +``` + +*** + +### destroy() + +```ts +destroy(): void; +``` + +Defined in: [packages/query-core/src/query.ts:361](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L361) + +Clears the query's garbage collection timeout and silently cancels any +in-flight fetch. Called by `QueryCache` when the query is removed from +the cache. + +#### Returns + +`void` + +#### See + +[Query#cancel](#cancel) + +#### Overrides + +```ts +Removable.destroy +``` + +*** + +### fetch() + +```ts +fetch(options?, fetchOptions?): Promise; +``` + +Defined in: [packages/query-core/src/query.ts:590](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L590) + +Fetches the query, i.e. runs its `queryFn` (through any configured +retryer/behavior) and updates the query's state with the result. +- If a fetch is already in flight, returns its promise instead of + starting a new one, unless `fetchOptions.cancelRefetch` is set and the + query already has data, in which case the current fetch is silently + cancelled first. +- If `options` is passed, it replaces the query's current options + before fetching. + +#### Parameters + +##### options? + +[`QueryOptions`](../interfaces/QueryOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`, `never`\> + +##### fetchOptions? + +`FetchOptions`\<`TQueryFnData`\> + +#### Returns + +`Promise`\<`TData`\> + +*** + +### getObserversCount() + +```ts +getObserversCount(): number; +``` + +Defined in: [packages/query-core/src/query.ts:560](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L560) + +Returns the number of observers currently subscribed to this query. + +#### Returns + +`number` + +#### Example + +```ts +if (query.getObserversCount() === 0) { + // no component is currently watching this query +} +``` + +*** + +### invalidate() + +```ts +invalidate(): void; +``` + +Defined in: [packages/query-core/src/query.ts:574](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L574) + +Marks the query as invalidated, unless it is already invalidated. This +updates `state.isInvalidated` and notifies observers, but does not by +itself trigger a refetch. + +#### Returns + +`void` + +#### Example + +```ts +query.invalidate() +``` + +*** + +### isActive() + +```ts +isActive(): boolean; +``` + +Defined in: [packages/query-core/src/query.ts:386](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L386) + +Returns `true` if the query has at least one observer for which `enabled` +does not resolve to `false`. + +#### Returns + +`boolean` + +*** + +### isDisabled() + +```ts +isDisabled(): boolean; +``` + +Defined in: [packages/query-core/src/query.ts:400](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L400) + +Returns `true` if the query is disabled, meaning it will not fetch +automatically. +- If the query has observers, it is disabled when none of them are active + (see `isActive`). +- If the query has no observers, it is disabled when its `queryFn` is + `skipToken` or it has never been fetched. + +#### Returns + +`boolean` + +*** + +### isFetched() + +```ts +isFetched(): boolean; +``` + +Defined in: [packages/query-core/src/query.ts:412](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L412) + +Returns `true` if the query has been fetched, i.e. it has resolved with +either data or an error at least once. + +#### Returns + +`boolean` + +*** + +### isStale() + +```ts +isStale(): boolean; +``` + +Defined in: [packages/query-core/src/query.ts:447](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L447) + +Returns `true` if the query is stale. +- If the query has observers, defers to whether any observer's current + result reports `isStale` (which accounts for each observer's own + `staleTime` and `enabled` state). +- If the query has no observers, it is considered stale when it has no + data or has been invalidated. + +#### Returns + +`boolean` + +#### See + +[Query#isStaleByTime](#isstalebytime) + +#### Example + +```ts +if (query.isStale()) { + // refetch or otherwise treat the cached data as outdated +} +``` + +*** + +### isStaleByTime() + +```ts +isStaleByTime(staleTime): boolean; +``` + +Defined in: [packages/query-core/src/query.ts:473](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L473) + +Returns `true` if the query's data is stale relative to the given +`staleTime` (defaults to `0`). +- A query with no data is always stale. +- `staleTime: 'static'` is never stale. +- An invalidated query is always stale. +- Otherwise, staleness is based on elapsed time since `dataUpdatedAt`. + +#### Parameters + +##### staleTime + +[`StaleTime`](../type-aliases/StaleTime.md) = `0` + +#### Returns + +`boolean` + +#### See + +[Query#isStale](#isstale) + +#### Example + +```ts +const isStale = query.isStaleByTime(1000 * 60) +``` + +*** + +### isStatic() + +```ts +isStatic(): boolean; +``` + +Defined in: [packages/query-core/src/query.ts:420](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L420) + +Returns `true` if the query has at least one observer configured with +`staleTime: 'static'`, meaning it is treated as never stale. + +#### Returns + +`boolean` + +*** + +### optionalRemove() + +```ts +protected optionalRemove(): void; +``` + +Defined in: [packages/query-core/src/query.ts:305](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L305) + +#### Returns + +`void` + +#### Overrides + +```ts +Removable.optionalRemove +``` + +*** + +### reset() + +```ts +reset(): void; +``` + +Defined in: [packages/query-core/src/query.ts:377](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L377) + +Resets the query back to its initial state (the state it had when it was +first created, e.g. any `initialData`), destroying it first to cancel any +in-flight fetch. + +#### Returns + +`void` + +*** + +### scheduleGc() + +```ts +protected scheduleGc(): void; +``` + +Defined in: [packages/query-core/src/removable.ts:14](https://github.com/TanStack/query/blob/main/packages/query-core/src/removable.ts#L14) + +#### Returns + +`void` + +#### Inherited from + +```ts +Removable.scheduleGc +``` + +*** + +### setState() + +```ts +setState(state): void; +``` + +Defined in: [packages/query-core/src/query.ts:334](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L334) + +Merges the given partial state directly into this query's state, notifying observers. Used +by persistence and broadcast plugins to restore a state snapshot, and by devtools to let a +user manually trigger a loading/error state or edit the cached data. + +#### Parameters + +##### state + +`Partial`\<[`QueryState`](../interfaces/QueryState.md)\<`TData`, `TError`\>\> + +#### Returns + +`void` + +*** + +### updateGcTime() + +```ts +protected updateGcTime(newGcTime): void; +``` + +Defined in: [packages/query-core/src/removable.ts:24](https://github.com/TanStack/query/blob/main/packages/query-core/src/removable.ts#L24) + +#### Parameters + +##### newGcTime + +`number` | `undefined` + +#### Returns + +`void` + +#### Inherited from + +```ts +Removable.updateGcTime +``` diff --git a/docs/framework/lit/reference/classes/QueryCache.md b/docs/framework/lit/reference/classes/QueryCache.md new file mode 100644 index 00000000000..b3ebf24e6fc --- /dev/null +++ b/docs/framework/lit/reference/classes/QueryCache.md @@ -0,0 +1,471 @@ +--- +id: QueryCache +title: QueryCache +--- + +Defined in: [packages/query-core/src/queryCache.ts:123](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryCache.ts#L123) + +The `QueryCache` is the storage mechanism for TanStack Query. It stores all the data, meta +information, and state of the queries it contains. + +Normally, you will not interact with the `QueryCache` directly and instead use a `QueryClient` +for a specific cache. You can subscribe to it (inherited from `Subscribable`) to be informed of +safe/known updates to the cache, such as queries being added, removed, or updated — updates made +outside of the cache's own tracked mechanisms (e.g. mutating a query's state object directly) do +not notify subscribers. + +## Example + +```ts +const unsubscribe = queryCache.subscribe((event) => { + console.log(event.type, event.query) +}) +``` + +## Extends + +- `Subscribable`\<`QueryCacheListener`\> + +## Constructors + +### Constructor + +```ts +new QueryCache(config): QueryCache; +``` + +Defined in: [packages/query-core/src/queryCache.ts:126](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryCache.ts#L126) + +#### Parameters + +##### config + +[`QueryCacheConfig`](../interfaces/QueryCacheConfig.md) = `{}` + +#### Returns + +`QueryCache` + +#### Overrides + +```ts +Subscribable.constructor +``` + +## Properties + +### config + +```ts +config: QueryCacheConfig = {}; +``` + +Defined in: [packages/query-core/src/queryCache.ts:126](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryCache.ts#L126) + +*** + +### listeners + +```ts +protected listeners: Set; +``` + +Defined in: [packages/query-core/src/subscribable.ts:2](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L2) + +#### Inherited from + +```ts +Subscribable.listeners +``` + +## Methods + +### build() + +```ts +build( + client, + options, +state?): Query; +``` + +Defined in: [packages/query-core/src/queryCache.ts:147](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryCache.ts#L147) + +Returns the existing `Query` instance for the given options' `queryKey`/`queryHash`, or +builds and adds a new one to the cache if none exists yet. Used by framework adapters and +plugins (e.g. broadcast/persistence) that need to get-or-create a `Query` directly, bypassing +the reactive `QueryObserver` machinery. + +#### Type Parameters + +##### TQueryFnData + +`TQueryFnData` = `unknown` + +##### TError + +`TError` = `Error` + +##### TData + +`TData` = `TQueryFnData` + +##### TQueryKey + +`TQueryKey` *extends* readonly `unknown`[] = readonly `unknown`[] + +#### Parameters + +##### client + +[`QueryClient`](QueryClient.md) + +##### options + +[`WithRequired`](../type-aliases/WithRequired.md)\<[`QueryOptions`](../interfaces/QueryOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`, `never`\>, `"queryKey"`\> + +##### state? + +[`QueryState`](../interfaces/QueryState.md)\<`TData`, `TError`\> + +#### Returns + +[`Query`](Query.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`\> + +#### Example + +```ts +const queryCache = queryClient.getQueryCache() + +const query = queryCache.build(queryClient, { + queryKey: ['posts'], + queryFn: fetchPosts, +}) +``` + +*** + +### clear() + +```ts +clear(): void; +``` + +Defined in: [packages/query-core/src/queryCache.ts:232](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryCache.ts#L232) + +Removes all queries from the cache. + +#### Returns + +`void` + +#### Example + +```ts +const queryCache = queryClient.getQueryCache() + +queryCache.clear() +``` + +*** + +### find() + +```ts +find(filters): + | Query + | undefined; +``` + +Defined in: [packages/query-core/src/queryCache.ts:299](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryCache.ts#L299) + +A slightly more advanced method that can be used to get an existing query instance from the +cache. This instance not only contains all the state for the query, but all of the instances, +and underlying guts of the query as well. If the query does not exist, `undefined` is +returned. + +This is not typically needed for most applications, but can come in handy when needing more +information about a query in rare scenarios (e.g. looking at `query.state.dataUpdatedAt` to +decide whether a query is fresh enough to be used as an initial value). + +#### Type Parameters + +##### TQueryFnData + +`TQueryFnData` = `unknown` + +##### TError + +`TError` = `Error` + +##### TData + +`TData` = `TQueryFnData` + +#### Parameters + +##### filters + +[`WithRequired`](../type-aliases/WithRequired.md)\<[`QueryFilters`](../interfaces/QueryFilters.md)\, `"queryKey"`\> + +#### Returns + + \| [`Query`](Query.md)\<`TQueryFnData`, `TError`, `TData`, readonly `unknown`[]\> + \| `undefined` + +#### See + +[QueryCache#findAll](#findall) + +#### Example + +```ts +const queryCache = queryClient.getQueryCache() + +const query = queryCache.find({ queryKey: ['posts'] }) +``` + +*** + +### findAll() + +```ts +findAll(filters): Query[]; +``` + +Defined in: [packages/query-core/src/queryCache.ts:324](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryCache.ts#L324) + +An even more advanced method that can be used to get existing query instances from the cache +that partially match a query key. If no queries match, an empty array is returned. + +This is not typically needed for most applications, but can come in handy when needing more +information about queries in rare scenarios. + +#### Parameters + +##### filters + +[`QueryFilters`](../interfaces/QueryFilters.md)\<`any`\> = `{}` + +#### Returns + +[`Query`](Query.md)\<`unknown`, `Error`, `unknown`, readonly `unknown`[]\>[] + +#### See + +[QueryCache#find](#find) + +#### Example + +```ts +const queryCache = queryClient.getQueryCache() + +const queries = queryCache.findAll({ queryKey: ['posts'] }) +``` + +*** + +### get() + +```ts +get(queryHash): + | Query + | undefined; +``` + +Defined in: [packages/query-core/src/queryCache.ts:254](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryCache.ts#L254) + +Returns the `Query` instance stored under the given `queryHash`, or `undefined` if none +exists. Unlike [QueryCache#find](#find), this looks up by the already-computed hash rather +than by `QueryFilters`. Used by plugins (e.g. broadcast/hydration) that already have a hash +to look up directly. + +#### Type Parameters + +##### TQueryFnData + +`TQueryFnData` = `unknown` + +##### TError + +`TError` = `Error` + +##### TData + +`TData` = `TQueryFnData` + +##### TQueryKey + +`TQueryKey` *extends* readonly `unknown`[] = readonly `unknown`[] + +#### Parameters + +##### queryHash + +`string` + +#### Returns + + \| [`Query`](Query.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`\> + \| `undefined` + +#### Example + +```ts +const queryCache = queryClient.getQueryCache() +const queryHash = hashKey(['posts']) + +const query = queryCache.get(queryHash) +``` + +*** + +### getAll() + +```ts +getAll(): Query[]; +``` + +Defined in: [packages/query-core/src/queryCache.ts:277](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryCache.ts#L277) + +Returns all queries within the cache. + +#### Returns + +[`Query`](Query.md)\<`unknown`, `Error`, `unknown`, readonly `unknown`[]\>[] + +#### Example + +```ts +const queryCache = queryClient.getQueryCache() + +const queries = queryCache.getAll() +``` + +*** + +### hasListeners() + +```ts +hasListeners(): boolean; +``` + +Defined in: [packages/query-core/src/subscribable.ts:19](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L19) + +#### Returns + +`boolean` + +#### Inherited from + +```ts +Subscribable.hasListeners +``` + +*** + +### onSubscribe() + +```ts +protected onSubscribe(): void; +``` + +Defined in: [packages/query-core/src/subscribable.ts:23](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L23) + +#### Returns + +`void` + +#### Inherited from + +```ts +Subscribable.onSubscribe +``` + +*** + +### onUnsubscribe() + +```ts +protected onUnsubscribe(): void; +``` + +Defined in: [packages/query-core/src/subscribable.ts:27](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L27) + +#### Returns + +`void` + +#### Inherited from + +```ts +Subscribable.onUnsubscribe +``` + +*** + +### remove() + +```ts +remove(query): void; +``` + +Defined in: [packages/query-core/src/queryCache.ts:208](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryCache.ts#L208) + +Destroys the given `Query` and removes it from the cache, notifying subscribers with a +`'removed'` event. A no-op if the query is no longer the one currently stored under its hash +(e.g. it was already replaced). Used by plugins (e.g. the broadcast client) that mirror +removals across `QueryCache` instances. + +#### Parameters + +##### query + +[`Query`](Query.md)\<`any`, `any`, `any`, `any`\> + +#### Returns + +`void` + +#### Example + +```ts +const queryCache = queryClient.getQueryCache() +const query = queryCache.find({ queryKey: ['posts'] }) + +if (query) { + queryCache.remove(query) +} +``` + +*** + +### subscribe() + +```ts +subscribe(listener): () => void; +``` + +Defined in: [packages/query-core/src/subscribable.ts:8](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L8) + +#### Parameters + +##### listener + +`QueryCacheListener` + +#### Returns + +```ts +(): void; +``` + +##### Returns + +`void` + +#### Inherited from + +```ts +Subscribable.subscribe +``` diff --git a/docs/framework/lit/reference/classes/QueryClient.md b/docs/framework/lit/reference/classes/QueryClient.md new file mode 100644 index 00000000000..2b0254ffb05 --- /dev/null +++ b/docs/framework/lit/reference/classes/QueryClient.md @@ -0,0 +1,1466 @@ +--- +id: QueryClient +title: QueryClient +--- + +Defined in: [packages/query-core/src/queryClient.ts:79](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L79) + +`QueryClient` is used to interact with a cache of queries and mutations. It owns a +`QueryCache` and a `MutationCache` (creating default ones if none are passed in) and holds +the default options that are applied to queries and mutations created through it. + +## Example + +```ts +const queryClient = new QueryClient({ + defaultOptions: { + queries: { + staleTime: Infinity, + }, + }, +}) + +await queryClient.query({ queryKey: ['posts'], queryFn: fetchPosts }) +``` + +## Constructors + +### Constructor + +```ts +new QueryClient(config): QueryClient; +``` + +Defined in: [packages/query-core/src/queryClient.ts:89](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L89) + +#### Parameters + +##### config + +[`QueryClientConfig`](../interfaces/QueryClientConfig.md) = `{}` + +#### Returns + +`QueryClient` + +## Methods + +### cancelQueries() + +```ts +cancelQueries(filters?, cancelOptions?): Promise; +``` + +Defined in: [packages/query-core/src/queryClient.ts:432](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L432) + +Cancels outgoing fetches for queries matching the given filters. Most useful when performing +optimistic updates, since any outgoing refetch that resolves afterwards would otherwise +overwrite the optimistic update. By default (`revert: true`), a cancelled query's data is +reverted to its state before the outgoing fetch started. + +The returned promise never rejects, even if individual cancellations fail. + +#### Type Parameters + +##### TTaggedQueryKey + +`TTaggedQueryKey` *extends* readonly `unknown`[] = readonly `unknown`[] + +#### Parameters + +##### filters? + +[`QueryFilters`](../interfaces/QueryFilters.md)\<`TTaggedQueryKey`\> + +##### cancelOptions? + +[`CancelOptions`](../interfaces/CancelOptions.md) = `{}` + +#### Returns + +`Promise`\<`void`\> + +#### Example + +```ts +await queryClient.cancelQueries({ queryKey: ['posts'], exact: true }) +``` + +*** + +### clear() + +```ts +clear(): void; +``` + +Defined in: [packages/query-core/src/queryClient.ts:1083](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L1083) + +Clears both the query cache and the mutation cache this client is connected to. + +#### Returns + +`void` + +#### Example + +```ts +import { QueryClient } from '@tanstack/query-core' + +const queryClient = new QueryClient() +queryClient.clear() +``` + +*** + +### defaultMutationOptions() + +```ts +defaultMutationOptions(options?): T; +``` + +Defined in: [packages/query-core/src/queryClient.ts:1057](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L1057) + +The mutation counterpart of [QueryClient#defaultQueryOptions](#defaultqueryoptions). Called by framework +adapters (e.g. inside `useMutation`) to merge `queryClient.setMutationDefaults` for the +given `mutationKey`, then the client's `defaultOptions.mutations`, then the caller's options +on top. A no-op if the options are already defaulted (`_defaulted: true`). + +#### Type Parameters + +##### T + +`T` *extends* [`MutationOptions`](../interfaces/MutationOptions.md)\<`any`, `any`, `any`, `any`\> + +#### Parameters + +##### options? + +`T` + +#### Returns + +`T` + +*** + +### defaultQueryOptions() + +```ts +defaultQueryOptions(options): DefaultedQueryObserverOptions; +``` + +Defined in: [packages/query-core/src/queryClient.ts:970](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L970) + +Called by framework adapters (e.g. inside `useQuery`) to resolve the options passed by the +caller into their final, defaulted form: merging `queryClient.setQueryDefaults` for the +given `queryKey`, then the client's own `defaultOptions.queries`, then the caller's options +on top. A no-op if the options are already defaulted (`_defaulted: true`). + +#### Type Parameters + +##### TQueryFnData + +`TQueryFnData` = `unknown` + +##### TError + +`TError` = `Error` + +##### TData + +`TData` = `TQueryFnData` + +##### TQueryData + +`TQueryData` = `TQueryFnData` + +##### TQueryKey + +`TQueryKey` *extends* readonly `unknown`[] = readonly `unknown`[] + +##### TPageParam + +`TPageParam` = `never` + +#### Parameters + +##### options + +[`QueryObserverOptions`](../interfaces/QueryObserverOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryData`, `TQueryKey`, `TPageParam`\> | [`DefaultedQueryObserverOptions`](../type-aliases/DefaultedQueryObserverOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryData`, `TQueryKey`\> + +#### Returns + +[`DefaultedQueryObserverOptions`](../type-aliases/DefaultedQueryObserverOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryData`, `TQueryKey`\> + +*** + +### ~~ensureInfiniteQueryData()~~ + +```ts +ensureInfiniteQueryData(options): Promise>; +``` + +Defined in: [packages/query-core/src/queryClient.ts:735](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L735) + +#### Type Parameters + +##### TQueryFnData + +`TQueryFnData` + +##### TError + +`TError` = `Error` + +##### TData + +`TData` = `TQueryFnData` + +##### TQueryKey + +`TQueryKey` *extends* readonly `unknown`[] = readonly `unknown`[] + +##### TPageParam + +`TPageParam` = `unknown` + +#### Parameters + +##### options + +[`EnsureInfiniteQueryDataOptions`](../type-aliases/EnsureInfiniteQueryDataOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`, `TPageParam`\> + +#### Returns + +`Promise`\<[`InfiniteData`](../interfaces/InfiniteData.md)\<`TData`, `TPageParam`\>\> + +#### Deprecated + +Use queryClient.infiniteQuery({ ...options, staleTime: 'static' }) instead. This method will be removed in the next major version. + +*** + +### ~~ensureQueryData()~~ + +```ts +ensureQueryData(options): Promise; +``` + +Defined in: [packages/query-core/src/queryClient.ts:197](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L197) + +#### Type Parameters + +##### TQueryFnData + +`TQueryFnData` + +##### TError + +`TError` = `Error` + +##### TData + +`TData` = `TQueryFnData` + +##### TQueryKey + +`TQueryKey` *extends* readonly `unknown`[] = readonly `unknown`[] + +#### Parameters + +##### options + +[`EnsureQueryDataOptions`](../interfaces/EnsureQueryDataOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`\> + +#### Returns + +`Promise`\<`TData`\> + +#### Deprecated + +Use queryClient.query({ ...options, staleTime: 'static' }) instead. This method will be removed in the next major version. + +*** + +### ~~fetchInfiniteQuery()~~ + +```ts +fetchInfiniteQuery(options): Promise>; +``` + +Defined in: [packages/query-core/src/queryClient.ts:692](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L692) + +#### Type Parameters + +##### TQueryFnData + +`TQueryFnData` + +##### TError + +`TError` = `Error` + +##### TData + +`TData` = `TQueryFnData` + +##### TQueryKey + +`TQueryKey` *extends* readonly `unknown`[] = readonly `unknown`[] + +##### TPageParam + +`TPageParam` = `unknown` + +#### Parameters + +##### options + +[`FetchInfiniteQueryOptions`](../type-aliases/FetchInfiniteQueryOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`, `TPageParam`\> + +#### Returns + +`Promise`\<[`InfiniteData`](../interfaces/InfiniteData.md)\<`TData`, `TPageParam`\>\> + +#### Deprecated + +Use queryClient.infiniteQuery(options) instead. This method will be removed in the next major version. + +*** + +### ~~fetchQuery()~~ + +```ts +fetchQuery(options): Promise; +``` + +Defined in: [packages/query-core/src/queryClient.ts:600](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L600) + +#### Type Parameters + +##### TQueryFnData + +`TQueryFnData` + +##### TError + +`TError` = `Error` + +##### TData + +`TData` = `TQueryFnData` + +##### TQueryKey + +`TQueryKey` *extends* readonly `unknown`[] = readonly `unknown`[] + +##### TPageParam + +`TPageParam` = `never` + +#### Parameters + +##### options + +[`FetchQueryOptions`](../interfaces/FetchQueryOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`, `TPageParam`\> + +#### Returns + +`Promise`\<`TData`\> + +#### Deprecated + +Use queryClient.query(options) instead. This method will be removed in the next major version. + +*** + +### getDefaultOptions() + +```ts +getDefaultOptions(): DefaultOptions; +``` + +Defined in: [packages/query-core/src/queryClient.ts:818](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L818) + +Returns the default options that were set when creating the client, or via +[QueryClient#setDefaultOptions](#setdefaultoptions). + +#### Returns + +[`DefaultOptions`](../interfaces/DefaultOptions.md) + +#### Example + +```ts +import { QueryClient } from '@tanstack/query-core' + +const queryClient = new QueryClient() +const defaultOptions = queryClient.getDefaultOptions() +``` + +*** + +### getMutationCache() + +```ts +getMutationCache(): MutationCache; +``` + +Defined in: [packages/query-core/src/queryClient.ts:802](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L802) + +Returns the mutation cache this client is connected to. + +#### Returns + +[`MutationCache`](MutationCache.md) + +#### Example + +```ts +import { QueryClient } from '@tanstack/query-core' + +const queryClient = new QueryClient() +const mutationCache = queryClient.getMutationCache() +const mutations = mutationCache.findAll({ status: 'pending' }) +``` + +*** + +### getMutationDefaults() + +```ts +getMutationDefaults(mutationKey): OmitKeyof, "mutationKey">; +``` + +Defined in: [packages/query-core/src/queryClient.ts:945](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L945) + +Returns the default options registered for mutations whose mutation key partially matches +the given `mutationKey`, via [QueryClient#setMutationDefaults](#setmutationdefaults). If multiple registered +defaults match, they are merged together in registration order. + +#### Parameters + +##### mutationKey + +readonly `unknown`[] + +#### Returns + +[`OmitKeyof`](../type-aliases/OmitKeyof.md)\<[`MutationObserverOptions`](../interfaces/MutationObserverOptions.md)\<`any`, `any`, `any`, `any`\>, `"mutationKey"`\> + +#### Example + +```ts +const defaultOptions = queryClient.getMutationDefaults(['addPost']) +``` + +*** + +### getQueriesData() + +```ts +getQueriesData(filters): [readonly unknown[], TQueryFnData | undefined][]; +``` + +Defined in: [packages/query-core/src/queryClient.ts:240](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L240) + +Imperative (non-reactive) way to retrieve the cached data of multiple queries at once. +Only queries matching the given filters are returned; if none match, an empty array is +returned. + +Because the matched queries can hold data of different shapes (e.g. a broad filter can match +queries with unrelated data types), the `TQueryFnData` generic defaults to `unknown` rather +than being inferred. Passing a more specific type is a convenience for call sites that know +every matched query holds the same shape — it is not checked against the actual cache +contents. + +#### Type Parameters + +##### TQueryFnData + +`TQueryFnData` = `unknown` + +##### TQueryFilters + +`TQueryFilters` *extends* [`QueryFilters`](../interfaces/QueryFilters.md)\<`any`\> = [`QueryFilters`](../interfaces/QueryFilters.md)\ + +#### Parameters + +##### filters + +`TQueryFilters` + +#### Returns + +\[readonly `unknown`[], `TQueryFnData` \| `undefined`\][] + +#### See + +[QueryClient#getQueryData](#getquerydata) + +#### Example + +```ts +const data = queryClient.getQueriesData({ queryKey: ['posts'] }) +``` + +*** + +### getQueryCache() + +```ts +getQueryCache(): QueryCache; +``` + +Defined in: [packages/query-core/src/queryClient.ts:786](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L786) + +Returns the query cache this client is connected to. + +#### Returns + +[`QueryCache`](QueryCache.md) + +#### Example + +```ts +import { QueryClient } from '@tanstack/query-core' + +const queryClient = new QueryClient() +const queryCache = queryClient.getQueryCache() +const queries = queryCache.findAll({ queryKey: ['posts'] }) +``` + +*** + +### getQueryData() + +```ts +getQueryData(queryKey): TInferredQueryFnData | undefined; +``` + +Defined in: [packages/query-core/src/queryClient.ts:183](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L183) + +Imperative (non-reactive) way to retrieve data for a QueryKey. +Should only be used in callbacks or functions where reading the latest data is necessary, e.g. for optimistic updates. + +Hint: Do not use this function inside a component, because it won't receive updates. +Use `useQuery` to create a `QueryObserver` that subscribes to changes. + +#### Type Parameters + +##### TQueryFnData + +`TQueryFnData` = `unknown` + +##### TTaggedQueryKey + +`TTaggedQueryKey` *extends* readonly `unknown`[] = readonly `unknown`[] + +##### TInferredQueryFnData + +`TInferredQueryFnData` = [`InferDataFromTag`](../type-aliases/InferDataFromTag.md)\<`TQueryFnData`, `TTaggedQueryKey`\> + +#### Parameters + +##### queryKey + +`TTaggedQueryKey` + +#### Returns + +`TInferredQueryFnData` \| `undefined` + +#### See + +[QueryClient#getQueriesData](#getqueriesdata) + +*** + +### getQueryDefaults() + +```ts +getQueryDefaults(queryKey): OmitKeyof, "queryKey">; +``` + +Defined in: [packages/query-core/src/queryClient.ts:888](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L888) + +Returns the default options registered for queries whose query key partially matches the +given `queryKey`, via [QueryClient#setQueryDefaults](#setquerydefaults). If multiple registered defaults +match, they are merged together in registration order. + +#### Parameters + +##### queryKey + +readonly `unknown`[] + +#### Returns + +[`OmitKeyof`](../type-aliases/OmitKeyof.md)\<[`QueryObserverOptions`](../interfaces/QueryObserverOptions.md)\<`any`, `any`, `any`, `any`, `any`\>, `"queryKey"`\> + +#### Example + +```ts +const defaultOptions = queryClient.getQueryDefaults(['posts']) +``` + +*** + +### getQueryState() + +```ts +getQueryState(queryKey): + | QueryState + | undefined; +``` + +Defined in: [packages/query-core/src/queryClient.ts:350](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L350) + +Imperative (non-reactive) way to retrieve an existing query's state. If the query does not +exist, `undefined` is returned. + +#### Type Parameters + +##### TQueryFnData + +`TQueryFnData` = `unknown` + +##### TError + +`TError` = `Error` + +##### TTaggedQueryKey + +`TTaggedQueryKey` *extends* readonly `unknown`[] = readonly `unknown`[] + +##### TInferredQueryFnData + +`TInferredQueryFnData` = [`InferDataFromTag`](../type-aliases/InferDataFromTag.md)\<`TQueryFnData`, `TTaggedQueryKey`\> + +##### TInferredError + +`TInferredError` = [`InferErrorFromTag`](../type-aliases/InferErrorFromTag.md)\<`TError`, `TTaggedQueryKey`\> + +#### Parameters + +##### queryKey + +`TTaggedQueryKey` + +#### Returns + + \| [`QueryState`](../interfaces/QueryState.md)\<`TInferredQueryFnData`, `TInferredError`\> + \| `undefined` + +#### Example + +```ts +const state = queryClient.getQueryState(['posts']) +console.log(state?.dataUpdatedAt) +``` + +*** + +### infiniteQuery() + +```ts +infiniteQuery(options): Promise[] ? InfiniteData : TData>; +``` + +Defined in: [packages/query-core/src/queryClient.ts:666](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L666) + +Asynchronous method to fetch and cache an infinite query, resolving with an +[InfiniteData](../interfaces/InfiniteData.md) object or throwing with the error. + +Behaves like [QueryClient#query](#query), accepting the same options (minus +`initialPageParam`), plus the required `initialPageParam`, and an optional `pages` / +`getNextPageParam` pair used to refetch a fixed number of pages from the start. + +This method replaces the deprecated `fetchInfiniteQuery`, and — combined with +`{ staleTime: 'static' }` — the deprecated `ensureInfiniteQueryData`. + +#### Type Parameters + +##### TQueryFnData + +`TQueryFnData` + +##### TError + +`TError` = `Error` + +##### TData + +`TData` = [`InfiniteData`](../interfaces/InfiniteData.md)\<`TQueryFnData`, `unknown`\> + +##### TQueryKey + +`TQueryKey` *extends* readonly `unknown`[] = readonly `unknown`[] + +##### TPageParam + +`TPageParam` = `unknown` + +#### Parameters + +##### options + +[`InfiniteQueryExecuteOptions`](../type-aliases/InfiniteQueryExecuteOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`, `TPageParam`\> + +#### Returns + +`Promise`\<`TData`[] *extends* [`InfiniteData`](../interfaces/InfiniteData.md)\<`TQueryFnData`, `unknown`\>[] ? [`InfiniteData`](../interfaces/InfiniteData.md)\<`TQueryFnData`, `TPageParam`\> : `TData`\> + +#### Example + +```ts +try { + const data = await queryClient.infiniteQuery({ queryKey, queryFn, initialPageParam: 0 }) + console.log(data.pages) +} catch (error) { + console.log(error) +} +``` + +*** + +### invalidateQueries() + +```ts +invalidateQueries(filters?, options?): Promise; +``` + +Defined in: [packages/query-core/src/queryClient.ts:460](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L460) + +Marks queries matching the given filters as invalidated. Unlike +[QueryClient#removeQueries](#removequeries), invalidated queries stay in the cache. + +Unless `filters.refetchType` is `'none'`, matching queries are then refetched via +[QueryClient#refetchQueries](#refetchqueries), using `filters.refetchType` if set, otherwise +`filters.type`, otherwise `'active'`. + +#### Type Parameters + +##### TTaggedQueryKey + +`TTaggedQueryKey` *extends* readonly `unknown`[] = readonly `unknown`[] + +#### Parameters + +##### filters? + +[`InvalidateQueryFilters`](../interfaces/InvalidateQueryFilters.md)\<`TTaggedQueryKey`\> + +##### options? + +[`InvalidateOptions`](../interfaces/InvalidateOptions.md) = `{}` + +#### Returns + +`Promise`\<`void`\> + +#### Example + +```ts +await queryClient.invalidateQueries({ queryKey: ['posts'], refetchType: 'active' }) +``` + +*** + +### isFetching() + +```ts +isFetching(filters?): number; +``` + +Defined in: [packages/query-core/src/queryClient.ts:150](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L150) + +Returns the number of queries in the cache that are currently fetching, optionally +matching a set of filters. This includes background-fetching, loading new pages, and +loading more infinite query results. + +#### Type Parameters + +##### TQueryFilters + +`TQueryFilters` *extends* [`QueryFilters`](../interfaces/QueryFilters.md)\<`any`\> = [`QueryFilters`](../interfaces/QueryFilters.md)\ + +#### Parameters + +##### filters? + +`TQueryFilters` + +#### Returns + +`number` + +#### Example + +```ts +if (queryClient.isFetching()) { + console.log('At least one query is fetching!') +} +``` + +*** + +### isMutating() + +```ts +isMutating(filters?): number; +``` + +Defined in: [packages/query-core/src/queryClient.ts:168](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L168) + +Returns the number of mutations in the cache that are currently pending, optionally +matching a set of filters. + +#### Type Parameters + +##### TMutationFilters + +`TMutationFilters` *extends* [`MutationFilters`](../interfaces/MutationFilters.md)\<`any`, `any`, `unknown`, `unknown`\> = [`MutationFilters`](../interfaces/MutationFilters.md)\<`unknown`, `Error`, `unknown`, `unknown`\> + +#### Parameters + +##### filters? + +`TMutationFilters` + +#### Returns + +`number` + +#### Example + +```ts +if (queryClient.isMutating()) { + console.log('At least one mutation is pending!') +} +``` + +*** + +### mount() + +```ts +mount(): void; +``` + +Defined in: [packages/query-core/src/queryClient.ts:104](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L104) + +Called by a framework adapter's `QueryClientProvider`-equivalent when it mounts, to start +listening for focus/online events and resume paused mutations. Ref-counted via an internal +mount count, so nested or multiple providers sharing the same `QueryClient` don't tear down +the shared listeners until the last one unmounts. + +#### Returns + +`void` + +*** + +### ~~prefetchInfiniteQuery()~~ + +```ts +prefetchInfiniteQuery(options): Promise; +``` + +Defined in: [packages/query-core/src/queryClient.ts:714](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L714) + +#### Type Parameters + +##### TQueryFnData + +`TQueryFnData` + +##### TError + +`TError` = `Error` + +##### TData + +`TData` = `TQueryFnData` + +##### TQueryKey + +`TQueryKey` *extends* readonly `unknown`[] = readonly `unknown`[] + +##### TPageParam + +`TPageParam` = `unknown` + +#### Parameters + +##### options + +[`FetchInfiniteQueryOptions`](../type-aliases/FetchInfiniteQueryOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`, `TPageParam`\> + +#### Returns + +`Promise`\<`void`\> + +#### Deprecated + +Use queryClient.infiniteQuery(options) instead. You can swallow errors with `.catch(noop)`. This method will be removed in the next major version. + +*** + +### ~~prefetchQuery()~~ + +```ts +prefetchQuery(options): Promise; +``` + +Defined in: [packages/query-core/src/queryClient.ts:634](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L634) + +#### Type Parameters + +##### TQueryFnData + +`TQueryFnData` = `unknown` + +##### TError + +`TError` = `Error` + +##### TData + +`TData` = `TQueryFnData` + +##### TQueryKey + +`TQueryKey` *extends* readonly `unknown`[] = readonly `unknown`[] + +#### Parameters + +##### options + +[`FetchQueryOptions`](../interfaces/FetchQueryOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`\> + +#### Returns + +`Promise`\<`void`\> + +#### Deprecated + +Use queryClient.query(options) instead. You can swallow errors with `.catch(noop)`. This method will be removed in the next major version. + +*** + +### query() + +```ts +query(options): Promise; +``` + +Defined in: [packages/query-core/src/queryClient.ts:554](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L554) + +Asynchronous method to fetch and cache a query, resolving with the data or throwing with +the error. + +If the query already exists in the cache and its data is not stale (per the given +`staleTime`), the cached data is returned without fetching. Otherwise, the query is fetched +and the promise resolves once the fetch settles. If a `select` function is provided, it is +applied to the data in both cases (cached or freshly fetched) before it is returned. + +Unlike a reactive observer, retries are disabled by default here (`retry: false`) unless +explicitly configured, since there is no component to catch a thrown error and retry through +re-render. + +The accepted options are `QueryObserverOptions` minus the fields that only make sense for a +reactive observer — `enabled`, `refetchInterval`, `refetchIntervalInBackground`, +`refetchOnWindowFocus`, `refetchOnReconnect`, `refetchOnMount`, `retryOnMount`, +`notifyOnChangeProps`, `throwOnError`, `suspense`, and `placeholderData` are not part of this +method's options. + +This method replaces the deprecated `fetchQuery`, and — combined with +`{ staleTime: 'static' }` — the deprecated `ensureQueryData`. + +#### Type Parameters + +##### TQueryFnData + +`TQueryFnData` + +##### TError + +`TError` = `Error` + +##### TData + +`TData` = `TQueryFnData` + +##### TQueryData + +`TQueryData` = `TQueryFnData` + +##### TQueryKey + +`TQueryKey` *extends* readonly `unknown`[] = readonly `unknown`[] + +##### TPageParam + +`TPageParam` = `never` + +#### Parameters + +##### options + +[`QueryExecuteOptions`](../interfaces/QueryExecuteOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryData`, `TQueryKey`, `TPageParam`\> + +#### Returns + +`Promise`\<`TData`\> + +#### Example + +```ts +try { + const data = await queryClient.query({ queryKey, queryFn, staleTime: 10000 }) +} catch (error) { + console.log(error) +} +``` + +*** + +### refetchQueries() + +```ts +refetchQueries(filters?, options?): Promise; +``` + +Defined in: [packages/query-core/src/queryClient.ts:497](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L497) + +Refetches queries matching the given filters, regardless of whether they are stale. Without +filters, every query in the cache is refetched. Queries that are disabled, or static (only +have observers with a static `staleTime`), are never refetched. + +By default (`cancelRefetch: true`), a currently running fetch is cancelled before the new +one starts. The returned promise resolves once all matching queries have settled; it does +not reject on individual query failures unless `throwOnError` is set. + +#### Type Parameters + +##### TTaggedQueryKey + +`TTaggedQueryKey` *extends* readonly `unknown`[] = readonly `unknown`[] + +#### Parameters + +##### filters? + +[`RefetchQueryFilters`](../interfaces/RefetchQueryFilters.md)\<`TTaggedQueryKey`\> + +##### options? + +[`RefetchOptions`](../interfaces/RefetchOptions.md) = `{}` + +#### Returns + +`Promise`\<`void`\> + +#### Example + +```ts +// refetch all active queries partially matching a query key: +await queryClient.refetchQueries({ queryKey: ['posts'], type: 'active' }) +``` + +*** + +### removeQueries() + +```ts +removeQueries(filters?): void; +``` + +Defined in: [packages/query-core/src/queryClient.ts:376](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L376) + +Removes queries from the cache that match the given filters. Unlike +[QueryClient#invalidateQueries](#invalidatequeries) or [QueryClient#refetchQueries](#refetchqueries), this removes +matching queries from the cache instead of refetching them. Without filters, every query in +the cache is removed. + +#### Type Parameters + +##### TTaggedQueryKey + +`TTaggedQueryKey` *extends* readonly `unknown`[] = readonly `unknown`[] + +#### Parameters + +##### filters? + +[`QueryFilters`](../interfaces/QueryFilters.md)\<`TTaggedQueryKey`\> + +#### Returns + +`void` + +#### Example + +```ts +queryClient.removeQueries({ queryKey: ['posts'], exact: true }) +``` + +*** + +### resetQueries() + +```ts +resetQueries(filters?, options?): Promise; +``` + +Defined in: [packages/query-core/src/queryClient.ts:397](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L397) + +Resets queries matching the given filters back to their initial state (e.g. any +`initialData`), notifying subscribers rather than removing them. Active queries among the +matched set are then refetched, and the returned promise resolves once that refetch settles. + +#### Type Parameters + +##### TTaggedQueryKey + +`TTaggedQueryKey` *extends* readonly `unknown`[] = readonly `unknown`[] + +#### Parameters + +##### filters? + +[`QueryFilters`](../interfaces/QueryFilters.md)\<`TTaggedQueryKey`\> + +##### options? + +[`ResetOptions`](../interfaces/ResetOptions.md) + +#### Returns + +`Promise`\<`void`\> + +#### Example + +```ts +await queryClient.resetQueries({ queryKey: ['posts'], exact: true }) +``` + +*** + +### resumePausedMutations() + +```ts +resumePausedMutations(): Promise; +``` + +Defined in: [packages/query-core/src/queryClient.ts:767](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L767) + +Resumes mutations that were paused because there was no network connection. Does nothing +(resolving immediately) if the client is currently offline. + +#### Returns + +`Promise`\<`unknown`\> + +#### Example + +```ts +import { QueryClient } from '@tanstack/query-core' + +const queryClient = new QueryClient() +await queryClient.resumePausedMutations() +``` + +*** + +### setDefaultOptions() + +```ts +setDefaultOptions(options): void; +``` + +Defined in: [packages/query-core/src/queryClient.ts:839](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L839) + +Dynamically sets the default options for this client, overwriting any previously defined +default options. + +#### Parameters + +##### options + +[`DefaultOptions`](../interfaces/DefaultOptions.md) + +#### Returns + +`void` + +#### See + +[QueryClient#getDefaultOptions](#getdefaultoptions) + +#### Example + +```ts +import { QueryClient } from '@tanstack/query-core' + +const queryClient = new QueryClient() +queryClient.setDefaultOptions({ + queries: { + staleTime: Infinity, + }, +}) +``` + +*** + +### setMutationDefaults() + +```ts +setMutationDefaults(mutationKey, options): void; +``` + +Defined in: [packages/query-core/src/queryClient.ts:917](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L917) + +Sets default options for mutations whose mutation key partially matches the given +`mutationKey`. As with [QueryClient#setQueryDefaults](#setquerydefaults), the order of registration +matters when several registered defaults match the same mutation key. + +#### Type Parameters + +##### TData + +`TData` = `unknown` + +##### TError + +`TError` = `Error` + +##### TVariables + +`TVariables` = `void` + +##### TOnMutateResult + +`TOnMutateResult` = `unknown` + +#### Parameters + +##### mutationKey + +readonly `unknown`[] + +##### options + +[`OmitKeyof`](../type-aliases/OmitKeyof.md)\<[`MutationObserverOptions`](../interfaces/MutationObserverOptions.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\>, `"mutationKey"`\> + +#### Returns + +`void` + +#### See + +[QueryClient#getMutationDefaults](#getmutationdefaults) + +#### Example + +```ts +queryClient.setMutationDefaults(['addPost'], { mutationFn: addPost }) +``` + +*** + +### setQueriesData() + +```ts +setQueriesData( + filters, + updater, + options?): [readonly unknown[], TQueryFnData | undefined][]; +``` + +Defined in: [packages/query-core/src/queryClient.ts:319](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L319) + +Synchronous way to immediately update the cached data of multiple queries at once, using +filters or partial query key matching. Only queries that already exist and match the given +filters are updated; no new cache entries are created. Internally this calls +[QueryClient#setQueryData](#setquerydata) for each matching query. + +#### Type Parameters + +##### TQueryFnData + +`TQueryFnData` + +##### TQueryFilters + +`TQueryFilters` *extends* [`QueryFilters`](../interfaces/QueryFilters.md)\<`any`\> = [`QueryFilters`](../interfaces/QueryFilters.md)\ + +#### Parameters + +##### filters + +`TQueryFilters` + +##### updater + +[`Updater`](../type-aliases/Updater.md)\<`NoInfer`\<`TQueryFnData`\> \| `undefined`, `NoInfer`\<`TQueryFnData`\> \| `undefined`\> + +##### options? + +[`SetDataOptions`](../interfaces/SetDataOptions.md) + +#### Returns + +\[readonly `unknown`[], `TQueryFnData` \| `undefined`\][] + +#### Example + +```ts +queryClient.setQueriesData({ queryKey: ['posts'] }, (oldPosts) => + oldPosts ? oldPosts.filter((post) => post.id !== deletedId) : oldPosts, +) +``` + +*** + +### setQueryData() + +```ts +setQueryData( + queryKey, + updater, + options?): NoInfer | undefined; +``` + +Defined in: [packages/query-core/src/queryClient.ts:271](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L271) + +Synchronous way to immediately update a query's cached data. If the updater (or the value +passed) resolves to `undefined`, the cache is left untouched and no query is created; +otherwise, if the query does not exist yet, it will be created. To update multiple queries +at once by partially matching query keys, use [QueryClient#setQueriesData](#setqueriesdata) instead. + +Updates must be performed immutably: do not mutate `oldData`, or data previously retrieved +via [QueryClient#getQueryData](#getquerydata), in place. + +#### Type Parameters + +##### TQueryFnData + +`TQueryFnData` = `unknown` + +##### TTaggedQueryKey + +`TTaggedQueryKey` *extends* readonly `unknown`[] = readonly `unknown`[] + +##### TInferredQueryFnData + +`TInferredQueryFnData` = [`InferDataFromTag`](../type-aliases/InferDataFromTag.md)\<`TQueryFnData`, `TTaggedQueryKey`\> + +#### Parameters + +##### queryKey + +`TTaggedQueryKey` + +The query key to set data for. + +##### updater + +[`Updater`](../type-aliases/Updater.md)\<`NoInfer`\<`TInferredQueryFnData`\> \| `undefined`, `NoInfer`\<`TInferredQueryFnData`\> \| `undefined`\> + +Either the new data, or a function that receives the current data (which +may be `undefined`) and returns the new data. + +##### options? + +[`SetDataOptions`](../interfaces/SetDataOptions.md) + +#### Returns + +`NoInfer`\<`TInferredQueryFnData`\> \| `undefined` + +#### Example + +```ts +queryClient.setQueryData(['posts'], newPosts) + +// Or, using an updater function that receives the current data: +queryClient.setQueryData(['posts'], (oldPosts) => [...oldPosts, newPost]) +``` + +*** + +### setQueryDefaults() + +```ts +setQueryDefaults(queryKey, options): void; +``` + +Defined in: [packages/query-core/src/queryClient.ts:858](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L858) + +Sets default options for queries whose query key partially matches the given `queryKey`. + +If several registered query defaults match a given query key, they are merged together in +registration order by [QueryClient#getQueryDefaults](#getquerydefaults), so register defaults from the +most generic key to the least generic one — more specific defaults should be registered +after more generic ones so they take precedence. + +#### Type Parameters + +##### TQueryFnData + +`TQueryFnData` = `unknown` + +##### TError + +`TError` = `Error` + +##### TData + +`TData` = `TQueryFnData` + +##### TQueryData + +`TQueryData` = `TQueryFnData` + +#### Parameters + +##### queryKey + +readonly `unknown`[] + +##### options + +`Partial`\<[`OmitKeyof`](../type-aliases/OmitKeyof.md)\<[`QueryObserverOptions`](../interfaces/QueryObserverOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryData`\>, `"queryKey"`\>\> + +#### Returns + +`void` + +#### Example + +```ts +queryClient.setQueryDefaults(['posts'], { queryFn: fetchPosts }) + +await queryClient.query({ queryKey: ['posts'] }) +``` + +*** + +### unmount() + +```ts +unmount(): void; +``` + +Defined in: [packages/query-core/src/queryClient.ts:127](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L127) + +The inverse of [QueryClient#mount](#mount) — called by a framework adapter's +`QueryClientProvider`-equivalent when it unmounts. Only tears down the focus/online +listeners once the mount count returns to `0`. + +#### Returns + +`void` diff --git a/docs/framework/lit/reference/classes/QueryObserver.md b/docs/framework/lit/reference/classes/QueryObserver.md new file mode 100644 index 00000000000..51ff16910df --- /dev/null +++ b/docs/framework/lit/reference/classes/QueryObserver.md @@ -0,0 +1,555 @@ +--- +id: QueryObserver +title: QueryObserver +--- + +Defined in: [packages/query-core/src/queryObserver.ts:57](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L57) + +A `QueryObserver` watches a single query in the `QueryCache` and computes a +`QueryObserverResult` from its state, recomputing and notifying subscribers +whenever the underlying query (or the observer's options) changes. It is +the primitive that framework adapters (e.g. `useQuery`) build their hooks +on top of, but it can also be used directly to observe and switch between +queries outside of any framework. + +## Example + +```ts +const observer = new QueryObserver(queryClient, { + queryKey: ['posts'], + queryFn: fetchPosts, +}) + +const unsubscribe = observer.subscribe((result) => { + console.log(result.data) +}) +``` + +## Extends + +- `Subscribable`\<`QueryObserverListener`\<`TData`, `TError`\>\> + +## Extended by + +- [`InfiniteQueryObserver`](InfiniteQueryObserver.md) + +## Type Parameters + +### TQueryFnData + +`TQueryFnData` = `unknown` + +### TError + +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) + +### TData + +`TData` = `TQueryFnData` + +### TQueryData + +`TQueryData` = `TQueryFnData` + +### TQueryKey + +`TQueryKey` *extends* [`QueryKey`](../type-aliases/QueryKey.md) = [`QueryKey`](../type-aliases/QueryKey.md) + +## Constructors + +### Constructor + +```ts +new QueryObserver(client, options): QueryObserver; +``` + +Defined in: [packages/query-core/src/queryObserver.ts:87](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L87) + +#### Parameters + +##### client + +[`QueryClient`](QueryClient.md) + +##### options + +[`QueryObserverOptions`](../interfaces/QueryObserverOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryData`, `TQueryKey`\> + +#### Returns + +`QueryObserver`\<`TQueryFnData`, `TError`, `TData`, `TQueryData`, `TQueryKey`\> + +#### Overrides + +```ts +Subscribable>.constructor +``` + +## Properties + +### listeners + +```ts +protected listeners: Set>; +``` + +Defined in: [packages/query-core/src/subscribable.ts:2](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L2) + +#### Inherited from + +```ts +Subscribable.listeners +``` + +*** + +### options + +```ts +options: QueryObserverOptions; +``` + +Defined in: [packages/query-core/src/queryObserver.ts:89](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L89) + +## Methods + +### bindMethods() + +```ts +protected bindMethods(): void; +``` + +Defined in: [packages/query-core/src/queryObserver.ts:106](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L106) + +#### Returns + +`void` + +*** + +### createResult() + +```ts +protected createResult(query, options): QueryObserverResult; +``` + +Defined in: [packages/query-core/src/queryObserver.ts:559](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L559) + +#### Parameters + +##### query + +[`Query`](Query.md)\<`TQueryFnData`, `TError`, `TQueryData`, `TQueryKey`\> + +##### options + +[`QueryObserverOptions`](../interfaces/QueryObserverOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryData`, `TQueryKey`\> + +#### Returns + +[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\> + +*** + +### destroy() + +```ts +destroy(): void; +``` + +Defined in: [packages/query-core/src/queryObserver.ts:161](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L161) + +Stops observing the current query: clears all listeners, cancels the +stale and refetch-interval timers, and removes this observer from the +query it was observing. + +#### Returns + +`void` + +*** + +### fetch() + +```ts +protected fetch(fetchOptions): Promise>; +``` + +Defined in: [packages/query-core/src/queryObserver.ts:448](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L448) + +#### Parameters + +##### fetchOptions + +`ObserverFetchOptions` + +#### Returns + +`Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> + +*** + +### fetchOptimistic() + +```ts +fetchOptimistic(options): Promise>; +``` + +Defined in: [packages/query-core/src/queryObserver.ts:395](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L395) + +Fetches a query defined by the given options without affecting this +observer's own tracked query or result, and returns a promise that +resolves with the `QueryObserverResult` for that fetch. This is useful +for prefetching data that another observer (e.g. a query about to be +navigated to) will need, ahead of time. + +#### Parameters + +##### options + +[`QueryObserverOptions`](../interfaces/QueryObserverOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryData`, `TQueryKey`\> + +#### Returns + +`Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> + +#### Example + +```ts +const result = await observer.fetchOptimistic({ + queryKey: ['posts', 2], + queryFn: () => fetchPost(2), +}) +console.log(result.data) +``` + +*** + +### getCurrentQuery() + +```ts +getCurrentQuery(): Query; +``` + +Defined in: [packages/query-core/src/queryObserver.ts:357](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L357) + +Returns the `Query` instance this observer is currently observing. + +#### Returns + +[`Query`](Query.md)\<`TQueryFnData`, `TError`, `TQueryData`, `TQueryKey`\> + +*** + +### getCurrentResult() + +```ts +getCurrentResult(): QueryObserverResult; +``` + +Defined in: [packages/query-core/src/queryObserver.ts:321](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L321) + +Returns the most recently computed `QueryObserverResult` for the +observed query. This is a point-in-time read; to be notified of updates +as they happen, subscribe to the observer instead (its inherited +`subscribe` method). + +#### Returns + +[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\> + +#### Example + +```ts +const result = observer.getCurrentResult() +console.log(result.status, result.data) +``` + +*** + +### getOptimisticResult() + +```ts +getOptimisticResult(options): QueryObserverResult; +``` + +Defined in: [packages/query-core/src/queryObserver.ts:272](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L272) + +Computes the result the observer would produce for the given (already-defaulted) options +right now, building the underlying `Query` if it doesn't exist yet, without waiting for a +subscription callback. Called by framework adapters on every render (e.g. `useQuery`) so the +returned value is available synchronously, ahead of `setOptions` triggering an actual fetch. + +#### Parameters + +##### options + +[`DefaultedQueryObserverOptions`](../type-aliases/DefaultedQueryObserverOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryData`, `TQueryKey`\> + +#### Returns + +[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\> + +*** + +### hasListeners() + +```ts +hasListeners(): boolean; +``` + +Defined in: [packages/query-core/src/subscribable.ts:19](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L19) + +#### Returns + +`boolean` + +#### Inherited from + +```ts +Subscribable.hasListeners +``` + +*** + +### onSubscribe() + +```ts +protected onSubscribe(): void; +``` + +Defined in: [packages/query-core/src/queryObserver.ts:110](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L110) + +#### Returns + +`void` + +#### Overrides + +```ts +Subscribable.onSubscribe +``` + +*** + +### onUnsubscribe() + +```ts +protected onUnsubscribe(): void; +``` + +Defined in: [packages/query-core/src/queryObserver.ts:124](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L124) + +#### Returns + +`void` + +#### Overrides + +```ts +Subscribable.onUnsubscribe +``` + +*** + +### refetch() + +```ts +refetch(__namedParameters): Promise>; +``` + +Defined in: [packages/query-core/src/queryObserver.ts:371](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L371) + +Refetches the observed query and returns a promise that resolves with +the resulting `QueryObserverResult`. + +#### Parameters + +##### \_\_namedParameters + +[`RefetchOptions`](../interfaces/RefetchOptions.md) = `{}` + +#### Returns + +`Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> + +#### Example + +```ts +const result = await observer.refetch({ cancelRefetch: false }) +console.log(result.data) +``` + +*** + +### setOptions() + +```ts +setOptions(options): void; +``` + +Defined in: [packages/query-core/src/queryObserver.ts:182](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L182) + +Updates the observer's options. This will re-resolve the query being +observed (switching to a different query if the `queryKey` changed), +trigger a fetch if the new options require one and the observer has +subscribers, recompute the current result, and reschedule the stale and +refetch-interval timers as needed. + +#### Parameters + +##### options + +[`QueryObserverOptions`](../interfaces/QueryObserverOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryData`, `TQueryKey`\> + +#### Returns + +`void` + +#### Example + +```ts +observer.setOptions({ queryKey: ['posts', 1], queryFn: () => fetchPost(1) }) +// later: switch to a different query, reusing the same observer +observer.setOptions({ queryKey: ['posts', 2], queryFn: () => fetchPost(2) }) +``` + +*** + +### shouldFetchOnReconnect() + +```ts +shouldFetchOnReconnect(): boolean; +``` + +Defined in: [packages/query-core/src/queryObserver.ts:135](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L135) + +Returns whether the observed query is currently stale and configured +(via the `refetchOnReconnect` option) to refetch when the network +reconnects. + +#### Returns + +`boolean` + +*** + +### shouldFetchOnWindowFocus() + +```ts +shouldFetchOnWindowFocus(): boolean; +``` + +Defined in: [packages/query-core/src/queryObserver.ts:148](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L148) + +Returns whether the observed query is currently stale and configured +(via the `refetchOnWindowFocus` option) to refetch when the window +regains focus. + +#### Returns + +`boolean` + +*** + +### subscribe() + +```ts +subscribe(listener): () => void; +``` + +Defined in: [packages/query-core/src/subscribable.ts:8](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L8) + +#### Parameters + +##### listener + +`QueryObserverListener` + +#### Returns + +```ts +(): void; +``` + +##### Returns + +`void` + +#### Inherited from + +```ts +Subscribable.subscribe +``` + +*** + +### trackProp() + +```ts +trackProp(key): void; +``` + +Defined in: [packages/query-core/src/queryObserver.ts:350](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L350) + +Records that the given `QueryObserverResult` property was read, so a subsequent update only +notifies this observer if a tracked property actually changed. Normally called indirectly via +[QueryObserver#trackResult](#trackresult)'s proxy; exposed directly for adapters that track property +access themselves (e.g. through their own reactivity system) instead of via the proxy. + +#### Parameters + +##### key + +`"error"` | `"data"` | `"isError"` | `"isPending"` | `"isLoading"` | `"isLoadingError"` | `"isRefetchError"` | `"isSuccess"` | `"isPlaceholderData"` | `"status"` | `"dataUpdatedAt"` | `"errorUpdatedAt"` | `"failureCount"` | `"failureReason"` | `"errorUpdateCount"` | `"isFetched"` | `"isFetchedAfterMount"` | `"isFetching"` | `"isInitialLoading"` | `"isPaused"` | `"isRefetching"` | `"isStale"` | `"isEnabled"` | `"refetch"` | `"fetchStatus"` + +#### Returns + +`void` + +*** + +### trackResult() + +```ts +trackResult(result, onPropTracked?): QueryObserverResult; +``` + +Defined in: [packages/query-core/src/queryObserver.ts:331](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L331) + +Wraps a `QueryObserverResult` in a `Proxy` that records which properties are read, via +[QueryObserver#trackProp](#trackprop) (and an optional `onPropTracked` callback). Used by framework +adapters when `notifyOnChangeProps` is not set, to implement its default "only re-render on +properties you actually read" behavior. + +#### Parameters + +##### result + +[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\> + +##### onPropTracked? + +(`key`) => `void` + +#### Returns + +[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\> + +*** + +### updateResult() + +```ts +updateResult(): void; +``` + +Defined in: [packages/query-core/src/queryObserver.ts:735](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L735) + +Recomputes and stores the current result from the current query/options, notifying listeners +if it changed. Framework adapters call this right after subscribing to make sure no query +update was missed in the gap between creating the observer and subscribing to it. + +#### Returns + +`void` diff --git a/docs/framework/lit/reference/functions/createInfiniteQueryController.md b/docs/framework/lit/reference/functions/createInfiniteQueryController.md index 3974efa3af6..a9b6930a17c 100644 --- a/docs/framework/lit/reference/functions/createInfiniteQueryController.md +++ b/docs/framework/lit/reference/functions/createInfiniteQueryController.md @@ -35,7 +35,7 @@ nearest connected `QueryClientProvider`. ### TData -`TData` = `InfiniteData`\<`TQueryFnData`, `unknown`\> +`TData` = [`InfiniteData`](../interfaces/InfiniteData.md)\<`TQueryFnData`, `unknown`\> ### TQueryKey @@ -63,7 +63,7 @@ options. ### queryClient? -`QueryClient` +[`QueryClient`](../classes/QueryClient.md) Optional explicit query client. Provide this for controllers that should not resolve a client from Lit context. diff --git a/docs/framework/lit/reference/functions/createMutationController.md b/docs/framework/lit/reference/functions/createMutationController.md index 4ea9b122bda..dfed592d8c2 100644 --- a/docs/framework/lit/reference/functions/createMutationController.md +++ b/docs/framework/lit/reference/functions/createMutationController.md @@ -57,7 +57,7 @@ Mutation observer options, or a getter that returns options. ### queryClient? -`QueryClient` +[`QueryClient`](../classes/QueryClient.md) Optional explicit query client. Provide this for controllers that should not resolve a client from Lit context. diff --git a/docs/framework/lit/reference/functions/createQueriesController.md b/docs/framework/lit/reference/functions/createQueriesController.md index 0c632c3ec8a..c82411887dc 100644 --- a/docs/framework/lit/reference/functions/createQueriesController.md +++ b/docs/framework/lit/reference/functions/createQueriesController.md @@ -49,7 +49,7 @@ Queries controller options, or a getter that returns options. ### queryClient? -`QueryClient` +[`QueryClient`](../classes/QueryClient.md) Optional explicit query client. Provide this for controllers that should not resolve a client from Lit context. diff --git a/docs/framework/lit/reference/functions/createQueryController.md b/docs/framework/lit/reference/functions/createQueryController.md index caa4641736a..ae9523703d1 100644 --- a/docs/framework/lit/reference/functions/createQueryController.md +++ b/docs/framework/lit/reference/functions/createQueryController.md @@ -60,7 +60,7 @@ Query observer options, or a getter that returns options. ### queryClient? -`QueryClient` +[`QueryClient`](../classes/QueryClient.md) Optional explicit query client. Provide this for controllers that should not resolve a client from Lit context. diff --git a/docs/framework/lit/reference/functions/defaultShouldDehydrateMutation.md b/docs/framework/lit/reference/functions/defaultShouldDehydrateMutation.md new file mode 100644 index 00000000000..940f8745a5d --- /dev/null +++ b/docs/framework/lit/reference/functions/defaultShouldDehydrateMutation.md @@ -0,0 +1,23 @@ +--- +id: defaultShouldDehydrateMutation +title: defaultShouldDehydrateMutation +--- + +```ts +function defaultShouldDehydrateMutation(mutation): boolean; +``` + +Defined in: [packages/query-core/src/hydration.ts:177](https://github.com/TanStack/query/blob/main/packages/query-core/src/hydration.ts#L177) + +The default `shouldDehydrateMutation` predicate used by `dehydrate`. Only dehydrates mutations that are +currently paused (e.g. paused by `networkMode` while offline). + +## Parameters + +### mutation + +[`Mutation`](../classes/Mutation.md) + +## Returns + +`boolean` diff --git a/docs/framework/lit/reference/functions/defaultShouldDehydrateQuery.md b/docs/framework/lit/reference/functions/defaultShouldDehydrateQuery.md new file mode 100644 index 00000000000..abf19439d8a --- /dev/null +++ b/docs/framework/lit/reference/functions/defaultShouldDehydrateQuery.md @@ -0,0 +1,23 @@ +--- +id: defaultShouldDehydrateQuery +title: defaultShouldDehydrateQuery +--- + +```ts +function defaultShouldDehydrateQuery(query): boolean; +``` + +Defined in: [packages/query-core/src/hydration.ts:185](https://github.com/TanStack/query/blob/main/packages/query-core/src/hydration.ts#L185) + +The default `shouldDehydrateQuery` predicate used by `dehydrate`. Only dehydrates queries whose status is +`'success'`. + +## Parameters + +### query + +[`Query`](../classes/Query.md) + +## Returns + +`boolean` diff --git a/docs/framework/lit/reference/functions/dehydrate.md b/docs/framework/lit/reference/functions/dehydrate.md new file mode 100644 index 00000000000..33cdcd3940d --- /dev/null +++ b/docs/framework/lit/reference/functions/dehydrate.md @@ -0,0 +1,43 @@ +--- +id: dehydrate +title: dehydrate +--- + +```ts +function dehydrate(client, options): DehydratedState; +``` + +Defined in: [packages/query-core/src/hydration.ts:207](https://github.com/TanStack/query/blob/main/packages/query-core/src/hydration.ts#L207) + +Dehydrates a `QueryClient`'s cache (queries and mutations) into a plain, serializable `DehydratedState`, +typically to embed in server-rendered markup and later restore into a client-side `QueryClient` via `hydrate`. +Which queries/mutations are included, and how their data/errors are transformed, is controlled by `options`, +falling back to the client's `dehydrate` default options, and finally to `defaultShouldDehydrateQuery` / +`defaultShouldDehydrateMutation`. + +## Parameters + +### client + +[`QueryClient`](../classes/QueryClient.md) + +### options + +[`DehydrateOptions`](../interfaces/DehydrateOptions.md) = `{}` + +## Returns + +[`DehydratedState`](../interfaces/DehydratedState.md) + +## Example + +```ts +const queryClient = new QueryClient() + +await queryClient.prefetchQuery({ + queryKey: ['posts'], + queryFn: getPosts, +}) + +const dehydratedState = dehydrate(queryClient) +``` diff --git a/docs/framework/lit/reference/functions/dehydrateQuery.md b/docs/framework/lit/reference/functions/dehydrateQuery.md new file mode 100644 index 00000000000..ae991427eb1 --- /dev/null +++ b/docs/framework/lit/reference/functions/dehydrateQuery.md @@ -0,0 +1,43 @@ +--- +id: dehydrateQuery +title: dehydrateQuery +--- + +```ts +function dehydrateQuery( + query, + serializeData?, + shouldRedactErrors?): DehydratedQuery; +``` + +Defined in: [packages/query-core/src/hydration.ts:148](https://github.com/TanStack/query/blob/main/packages/query-core/src/hydration.ts#L148) + +Dehydrates a single `Query` into a serializable `DehydratedQuery` snapshot. Note that most query config (e.g. +`queryFn`, `staleTime`) is not dehydrated but instead meant to be configured again when consuming the +de/rehydrated data, typically with `useQuery` on the client. If the query is still `pending`, its in-flight +promise is dehydrated too so it can be resumed on the other side instead of re-fetched. + +## Parameters + +### query + +[`Query`](../classes/Query.md) + +The query to dehydrate. + +### serializeData? + +`TransformerFn` + +Optional transform applied to `query.state.data` before it is included in the snapshot. + +### shouldRedactErrors? + +(`error`) => `boolean` + +Optional predicate; if it returns `false` for the promise's rejection error, that +error is kept as-is instead of being redacted. + +## Returns + +`DehydratedQuery` diff --git a/docs/framework/lit/reference/functions/experimental_streamedQuery.md b/docs/framework/lit/reference/functions/experimental_streamedQuery.md new file mode 100644 index 00000000000..4c490322d60 --- /dev/null +++ b/docs/framework/lit/reference/functions/experimental_streamedQuery.md @@ -0,0 +1,52 @@ +--- +id: experimental_streamedQuery +title: experimental_streamedQuery +--- + +```ts +function experimental_streamedQuery(streamFn): QueryFunction; +``` + +Defined in: [packages/query-core/src/streamedQuery.ts:75](https://github.com/TanStack/query/blob/main/packages/query-core/src/streamedQuery.ts#L75) + +This is a helper function to create a query function that streams data from an AsyncIterable. +Data will be an Array of all the chunks received. +The query will be in a 'pending' state until the first chunk of data is received, but will go to 'success' after that. +The query will stay in fetchStatus 'fetching' until the stream ends. + +## Type Parameters + +### TQueryFnData + +`TQueryFnData` = `unknown` + +### TData + +`TData` = `TQueryFnData`[] + +### TQueryKey + +`TQueryKey` *extends* readonly `unknown`[] = readonly `unknown`[] + +## Parameters + +### streamFn + +`StreamedQueryParams`\<`TQueryFnData`, `TData`, `TQueryKey`\> + +The function that returns an AsyncIterable to stream data from. + +## Returns + +[`QueryFunction`](../type-aliases/QueryFunction.md)\<`TData`, `TQueryKey`\> + +## Example + +```ts +await queryClient.query({ + queryKey: ['data'], + queryFn: streamedQuery({ + streamFn: fetchDataInChunks, + }), +}) +``` diff --git a/docs/framework/lit/reference/functions/getDefaultQueryClient.md b/docs/framework/lit/reference/functions/getDefaultQueryClient.md index 0f1959c3fcc..07371741212 100644 --- a/docs/framework/lit/reference/functions/getDefaultQueryClient.md +++ b/docs/framework/lit/reference/functions/getDefaultQueryClient.md @@ -14,7 +14,7 @@ available. ## Returns -`QueryClient` \| `undefined` +[`QueryClient`](../classes/QueryClient.md) \| `undefined` The default query client, or `undefined` when there is no registered client or more than one registered client. diff --git a/docs/framework/lit/reference/functions/hashKey.md b/docs/framework/lit/reference/functions/hashKey.md new file mode 100644 index 00000000000..dc774c032ce --- /dev/null +++ b/docs/framework/lit/reference/functions/hashKey.md @@ -0,0 +1,30 @@ +--- +id: hashKey +title: hashKey +--- + +```ts +function hashKey(queryKey): string; +``` + +Defined in: [packages/query-core/src/utils.ts:284](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L284) + +Default query & mutation keys hash function. +Hashes the value into a stable hash. + +## Parameters + +### queryKey + +readonly `unknown`[] + +## Returns + +`string` + +## Example + +```ts +// Object keys are sorted, so key order doesn't affect the hash: +hashKey(['todos', { page: 1, filter: 'done' }]) // === '["todos",{"filter":"done","page":1}]' +``` diff --git a/docs/framework/lit/reference/functions/hydrate.md b/docs/framework/lit/reference/functions/hydrate.md new file mode 100644 index 00000000000..3a9e6b1ace2 --- /dev/null +++ b/docs/framework/lit/reference/functions/hydrate.md @@ -0,0 +1,49 @@ +--- +id: hydrate +title: hydrate +--- + +```ts +function hydrate( + client, + dehydratedState, + options?): void; +``` + +Defined in: [packages/query-core/src/hydration.ts:264](https://github.com/TanStack/query/blob/main/packages/query-core/src/hydration.ts#L264) + +Restores a `DehydratedState` (as produced by `dehydrate`) into a `QueryClient`'s cache, typically to seed the +client with data already fetched on the server. `mutations` and `queries` are each optional on `dehydratedState`. +Queries not yet in the cache are built from the dehydrated snapshot; queries that already exist are only updated +when the dehydrated data is newer than what's already cached. Newly built queries have their `fetchStatus` reset +to `'idle'` so they don't hydrate stuck in a fetching state. If a dehydrated query still had an in-flight +promise, it is resumed via `query.fetch()` (reusing that promise as `initialPromise`) rather than re-invoking +`queryFn`. + +## Parameters + +### client + +[`QueryClient`](../classes/QueryClient.md) + +### dehydratedState + +`Partial`\<[`DehydratedState`](../interfaces/DehydratedState.md)\> + +### options? + +[`HydrateOptions`](../interfaces/HydrateOptions.md) + +## Returns + +`void` + +## Example + +```ts +// dehydratedState was produced by `dehydrate` on the server +// and sent to the client, e.g. embedded in server-rendered markup. +const queryClient = new QueryClient() + +hydrate(queryClient, dehydratedState) +``` diff --git a/docs/framework/lit/reference/functions/infiniteQueryOptions.md b/docs/framework/lit/reference/functions/infiniteQueryOptions.md index 184528cc0ee..0e6d602e875 100644 --- a/docs/framework/lit/reference/functions/infiniteQueryOptions.md +++ b/docs/framework/lit/reference/functions/infiniteQueryOptions.md @@ -24,7 +24,7 @@ data and error types across TanStack Query APIs. ### TData -`TData` = `InfiniteData`\<`TQueryFnData`, `unknown`\> +`TData` = [`InfiniteData`](../interfaces/InfiniteData.md)\<`TQueryFnData`, `unknown`\> ### TQueryKey @@ -38,13 +38,13 @@ data and error types across TanStack Query APIs. ### options -`InfiniteQueryObserverOptions`\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`, `TPageParam`\> +[`InfiniteQueryObserverOptions`](../interfaces/InfiniteQueryObserverOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`, `TPageParam`\> Infinite query options to preserve and brand. ## Returns -`InfiniteQueryObserverOptions`\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`, `TPageParam`\> & `object` +[`InfiniteQueryObserverOptions`](../interfaces/InfiniteQueryObserverOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`, `TPageParam`\> & `object` The same options object with a typed `queryKey`. diff --git a/docs/framework/lit/reference/functions/isCancelledError.md b/docs/framework/lit/reference/functions/isCancelledError.md new file mode 100644 index 00000000000..c8f57c4b94d --- /dev/null +++ b/docs/framework/lit/reference/functions/isCancelledError.md @@ -0,0 +1,24 @@ +--- +id: isCancelledError +title: isCancelledError +--- + +```ts +function isCancelledError(value): value is CancelledError; +``` + +Defined in: [packages/query-core/src/retryer.ts:90](https://github.com/TanStack/query/blob/main/packages/query-core/src/retryer.ts#L90) + +## Parameters + +### value + +`any` + +## Returns + +`value is CancelledError` + +## Deprecated + +Use instanceof `CancelledError` instead. diff --git a/docs/framework/lit/reference/functions/keepPreviousData.md b/docs/framework/lit/reference/functions/keepPreviousData.md new file mode 100644 index 00000000000..6a84f4c5970 --- /dev/null +++ b/docs/framework/lit/reference/functions/keepPreviousData.md @@ -0,0 +1,40 @@ +--- +id: keepPreviousData +title: keepPreviousData +--- + +```ts +function keepPreviousData(previousData): T | undefined; +``` + +Defined in: [packages/query-core/src/utils.ts:493](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L493) + +Intended to be passed as a query's `placeholderData` option, for example +`placeholderData: keepPreviousData`. Instead of resetting the query's data to `undefined` while a new +query key is fetching, it keeps displaying the previously fetched data until the new data arrives. + +## Type Parameters + +### T + +`T` + +## Parameters + +### previousData + +`T` | `undefined` + +## Returns + +`T` \| `undefined` + +## Example + +```ts +new QueryObserver(queryClient, { + queryKey: ['posts', page], + queryFn: () => fetchPosts(page), + placeholderData: keepPreviousData, +}) +``` diff --git a/docs/framework/lit/reference/functions/matchMutation.md b/docs/framework/lit/reference/functions/matchMutation.md new file mode 100644 index 00000000000..40210da4cf1 --- /dev/null +++ b/docs/framework/lit/reference/functions/matchMutation.md @@ -0,0 +1,38 @@ +--- +id: matchMutation +title: matchMutation +--- + +```ts +function matchMutation(filters, mutation): boolean; +``` + +Defined in: [packages/query-core/src/utils.ts:237](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L237) + +Checks whether a mutation matches the given [MutationFilters](../interfaces/MutationFilters.md). +Every filter that is specified must match; filters that are left unspecified are ignored. +If a `mutationKey` filter is provided but the mutation has no `mutationKey` of its own, it does not match. + +## Parameters + +### filters + +[`MutationFilters`](../interfaces/MutationFilters.md) + +### mutation + +[`Mutation`](../classes/Mutation.md)\<`any`, `any`\> + +## Returns + +`boolean` + +## Example + +```ts +const mutationCache = queryClient.getMutationCache() + +const matchingMutations = mutationCache + .getAll() + .filter((mutation) => matchMutation({ mutationKey: ['addPost'] }, mutation)) +``` diff --git a/docs/framework/lit/reference/functions/matchQuery.md b/docs/framework/lit/reference/functions/matchQuery.md new file mode 100644 index 00000000000..4c54b2df995 --- /dev/null +++ b/docs/framework/lit/reference/functions/matchQuery.md @@ -0,0 +1,37 @@ +--- +id: matchQuery +title: matchQuery +--- + +```ts +function matchQuery(filters, query): boolean; +``` + +Defined in: [packages/query-core/src/utils.ts:175](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L175) + +Checks whether a query matches the given [QueryFilters](../interfaces/QueryFilters.md). +Every filter that is specified must match; filters that are left unspecified are ignored. + +## Parameters + +### filters + +[`QueryFilters`](../interfaces/QueryFilters.md) + +### query + +[`Query`](../classes/Query.md)\<`any`, `any`, `any`, `any`\> + +## Returns + +`boolean` + +## Example + +```ts +const queryCache = queryClient.getQueryCache() + +const matchingQueries = queryCache + .getAll() + .filter((query) => matchQuery({ queryKey: ['posts'] }, query)) +``` diff --git a/docs/framework/lit/reference/functions/mutationOptions.md b/docs/framework/lit/reference/functions/mutationOptions.md index 151ac414cf2..0413a4f78df 100644 --- a/docs/framework/lit/reference/functions/mutationOptions.md +++ b/docs/framework/lit/reference/functions/mutationOptions.md @@ -33,13 +33,13 @@ Preserves and types mutation options for reuse across Lit Query APIs. ### options -`MutationObserverOptions`\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\> +[`MutationObserverOptions`](../interfaces/MutationObserverOptions.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\> Mutation options to preserve. ## Returns -`MutationObserverOptions`\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\> +[`MutationObserverOptions`](../interfaces/MutationObserverOptions.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\> The same options object. diff --git a/docs/framework/lit/reference/functions/noop.md b/docs/framework/lit/reference/functions/noop.md new file mode 100644 index 00000000000..01fb409f4e9 --- /dev/null +++ b/docs/framework/lit/reference/functions/noop.md @@ -0,0 +1,32 @@ +--- +id: noop +title: noop +--- + +## Call Signature + +```ts +function noop(): void; +``` + +Defined in: [packages/query-core/src/utils.ts:119](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L119) + +A function that does nothing. + +### Returns + +`void` + +## Call Signature + +```ts +function noop(): undefined; +``` + +Defined in: [packages/query-core/src/utils.ts:120](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L120) + +A function that does nothing. + +### Returns + +`undefined` diff --git a/docs/framework/lit/reference/functions/partialMatchKey.md b/docs/framework/lit/reference/functions/partialMatchKey.md new file mode 100644 index 00000000000..4db67323e9b --- /dev/null +++ b/docs/framework/lit/reference/functions/partialMatchKey.md @@ -0,0 +1,26 @@ +--- +id: partialMatchKey +title: partialMatchKey +--- + +```ts +function partialMatchKey(a, b): boolean; +``` + +Defined in: [packages/query-core/src/utils.ts:300](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L300) + +Checks if key `b` partially matches with key `a`. + +## Parameters + +### a + +readonly `unknown`[] + +### b + +readonly `unknown`[] + +## Returns + +`boolean` diff --git a/docs/framework/lit/reference/functions/queryOptions.md b/docs/framework/lit/reference/functions/queryOptions.md index f6e4524f8db..ef522eb17c7 100644 --- a/docs/framework/lit/reference/functions/queryOptions.md +++ b/docs/framework/lit/reference/functions/queryOptions.md @@ -42,7 +42,7 @@ Query options to preserve and brand. ### Returns -`Omit`\<`QueryObserverOptions`\<`TQueryFnData`, `TError`, `TData`, `TQueryFnData`, `TQueryKey`, `never`\>, `"queryFn"`\> & `object` & `object` +`Omit`\<[`QueryObserverOptions`](../interfaces/QueryObserverOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryFnData`, `TQueryKey`, `never`\>, `"queryFn"`\> & `object` & `object` The same options object with a typed `queryKey`. @@ -97,7 +97,7 @@ Query options to preserve and brand. ### Returns -`OmitKeyof`\<`QueryObserverOptions`\<`TQueryFnData`, `TError`, `TData`, `TQueryFnData`, `TQueryKey`, `never`\>, `"queryFn"`\> & `object` & `object` +[`OmitKeyof`](../type-aliases/OmitKeyof.md)\<[`QueryObserverOptions`](../interfaces/QueryObserverOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryFnData`, `TQueryKey`, `never`\>, `"queryFn"`\> & `object` & `object` The same options object with a typed `queryKey`. @@ -140,6 +140,6 @@ Query options to preserve and brand. ### Returns -`QueryObserverOptions`\<`TQueryFnData`, `TError`, `TData`, `TQueryFnData`, `TQueryKey`, `never`\> & `object` & `object` +[`QueryObserverOptions`](../interfaces/QueryObserverOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryFnData`, `TQueryKey`, `never`\> & `object` & `object` The same options object with a typed `queryKey`. diff --git a/docs/framework/lit/reference/functions/registerDefaultQueryClient.md b/docs/framework/lit/reference/functions/registerDefaultQueryClient.md index 8d1b0711cda..42e9954cead 100644 --- a/docs/framework/lit/reference/functions/registerDefaultQueryClient.md +++ b/docs/framework/lit/reference/functions/registerDefaultQueryClient.md @@ -19,7 +19,7 @@ passing an explicit client or rendering under a provider when possible. ### client -`QueryClient` +[`QueryClient`](../classes/QueryClient.md) The query client to register as the current default. diff --git a/docs/framework/lit/reference/functions/replaceEqualDeep.md b/docs/framework/lit/reference/functions/replaceEqualDeep.md new file mode 100644 index 00000000000..dfd23c33115 --- /dev/null +++ b/docs/framework/lit/reference/functions/replaceEqualDeep.md @@ -0,0 +1,41 @@ +--- +id: replaceEqualDeep +title: replaceEqualDeep +--- + +```ts +function replaceEqualDeep( + a, + b, + depth?): T; +``` + +Defined in: [packages/query-core/src/utils.ts:339](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L339) + +This function returns `a` if `b` is deeply equal. +If not, it will replace any deeply equal children of `b` with those of `a`. +This can be used for structural sharing between JSON values for example. + +## Type Parameters + +### T + +`T` + +## Parameters + +### a + +`unknown` + +### b + +`T` + +### depth? + +`number` + +## Returns + +`T` diff --git a/docs/framework/lit/reference/functions/resolveQueryClient.md b/docs/framework/lit/reference/functions/resolveQueryClient.md index f06bc53018d..fee291e978d 100644 --- a/docs/framework/lit/reference/functions/resolveQueryClient.md +++ b/docs/framework/lit/reference/functions/resolveQueryClient.md @@ -15,13 +15,13 @@ Resolves an explicit `QueryClient` or falls back to `useQueryClient`. ### explicit? -`QueryClient` +[`QueryClient`](../classes/QueryClient.md) Optional client supplied by the caller. ## Returns -`QueryClient` +[`QueryClient`](../classes/QueryClient.md) The explicit client when provided, otherwise the current default client. diff --git a/docs/framework/lit/reference/functions/shouldThrowError.md b/docs/framework/lit/reference/functions/shouldThrowError.md new file mode 100644 index 00000000000..1f1e62a8d0e --- /dev/null +++ b/docs/framework/lit/reference/functions/shouldThrowError.md @@ -0,0 +1,45 @@ +--- +id: shouldThrowError +title: shouldThrowError +--- + +```ts +function shouldThrowError(throwOnError, params): boolean; +``` + +Defined in: [packages/query-core/src/utils.ts:576](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L576) + +Resolves a `throwOnError` option to a boolean. +If `throwOnError` is a function, it is called with `params` (e.g. the error and, depending on the caller, +additional context such as the query or mutation) and its result is returned, allowing the throwing +behavior to be decided per error. Otherwise, `throwOnError` itself is coerced to a boolean (`undefined` +resolves to `false`). + +## Type Parameters + +### T + +`T` *extends* (...`args`) => `boolean` + +## Parameters + +### throwOnError + +`boolean` | `T` | `undefined` + +### params + +`Parameters`\<`T`\> + +## Returns + +`boolean` + +## Example + +```ts +const throwOnError = + query.state.error && typeof options.throwOnError === 'function' + ? shouldThrowError(options.throwOnError, [query.state.error, query]) + : options.throwOnError +``` diff --git a/docs/framework/lit/reference/functions/unregisterDefaultQueryClient.md b/docs/framework/lit/reference/functions/unregisterDefaultQueryClient.md index 6f0a5bd8056..e164e2013cb 100644 --- a/docs/framework/lit/reference/functions/unregisterDefaultQueryClient.md +++ b/docs/framework/lit/reference/functions/unregisterDefaultQueryClient.md @@ -18,7 +18,7 @@ Unregisters a client previously registered with ### client -`QueryClient` +[`QueryClient`](../classes/QueryClient.md) The query client registration to release. diff --git a/docs/framework/lit/reference/functions/useIsFetching.md b/docs/framework/lit/reference/functions/useIsFetching.md index a4887fbea3d..b7017bee5b0 100644 --- a/docs/framework/lit/reference/functions/useIsFetching.md +++ b/docs/framework/lit/reference/functions/useIsFetching.md @@ -30,13 +30,13 @@ subscription. ### filters -[`Accessor`](../type-aliases/Accessor.md)\<`QueryFilters`\\> = `{}` +[`Accessor`](../type-aliases/Accessor.md)\<[`QueryFilters`](../interfaces/QueryFilters.md)\\> = `{}` Query filters, or a getter that returns query filters. ### queryClient? -`QueryClient` +[`QueryClient`](../classes/QueryClient.md) Optional explicit query client. Provide this for controllers that should not resolve a client from Lit context. diff --git a/docs/framework/lit/reference/functions/useIsMutating.md b/docs/framework/lit/reference/functions/useIsMutating.md index f89df7ff3a1..44cdd98978a 100644 --- a/docs/framework/lit/reference/functions/useIsMutating.md +++ b/docs/framework/lit/reference/functions/useIsMutating.md @@ -30,13 +30,13 @@ subscription. ### filters -[`Accessor`](../type-aliases/Accessor.md)\<`MutationFilters`\<`unknown`, `Error`, `unknown`, `unknown`\>\> = `{}` +[`Accessor`](../type-aliases/Accessor.md)\<[`MutationFilters`](../interfaces/MutationFilters.md)\<`unknown`, `Error`, `unknown`, `unknown`\>\> = `{}` Mutation filters, or a getter that returns mutation filters. ### queryClient? -`QueryClient` +[`QueryClient`](../classes/QueryClient.md) Optional explicit query client. Provide this for controllers that should not resolve a client from Lit context. diff --git a/docs/framework/lit/reference/functions/useMutationState.md b/docs/framework/lit/reference/functions/useMutationState.md index 688f1af61e2..c207ae27a55 100644 --- a/docs/framework/lit/reference/functions/useMutationState.md +++ b/docs/framework/lit/reference/functions/useMutationState.md @@ -24,7 +24,7 @@ the controller resolves the client from the nearest connected ### TResult -`TResult` = `MutationState`\<`unknown`, `unknown`, `unknown`, `unknown`\> +`TResult` = [`MutationState`](../interfaces/MutationState.md)\<`unknown`, `unknown`, `unknown`, `unknown`\> ## Parameters @@ -43,7 +43,7 @@ Mutation state filters and optional selector. ### queryClient? -`QueryClient` +[`QueryClient`](../classes/QueryClient.md) Optional explicit query client. Provide this for controllers that should not resolve a client from Lit context. diff --git a/docs/framework/lit/reference/functions/useQueryClient.md b/docs/framework/lit/reference/functions/useQueryClient.md index 8128dc9ede3..3cce315ce13 100644 --- a/docs/framework/lit/reference/functions/useQueryClient.md +++ b/docs/framework/lit/reference/functions/useQueryClient.md @@ -18,6 +18,6 @@ clients are mounted and the default would be ambiguous. ## Returns -`QueryClient` +[`QueryClient`](../classes/QueryClient.md) The single registered query client. diff --git a/docs/framework/lit/reference/index.md b/docs/framework/lit/reference/index.md index c47f6a79a88..cd93d99b440 100644 --- a/docs/framework/lit/reference/index.md +++ b/docs/framework/lit/reference/index.md @@ -5,38 +5,179 @@ title: "@tanstack/lit-query" ## Classes +- [CancelledError](classes/CancelledError.md) +- [InfiniteQueryObserver](classes/InfiniteQueryObserver.md) +- [Mutation](classes/Mutation.md) +- [MutationCache](classes/MutationCache.md) +- [MutationObserver](classes/MutationObserver.md) +- [QueriesObserver](classes/QueriesObserver.md) +- [Query](classes/Query.md) +- [QueryCache](classes/QueryCache.md) +- [QueryClient](classes/QueryClient.md) - [QueryClientProvider](classes/QueryClientProvider.md) +- [QueryObserver](classes/QueryObserver.md) + +## Interfaces + +- [CancelOptions](interfaces/CancelOptions.md) +- [DefaultOptions](interfaces/DefaultOptions.md) +- [DehydratedState](interfaces/DehydratedState.md) +- [DehydrateOptions](interfaces/DehydrateOptions.md) +- [~~EnsureQueryDataOptions~~](interfaces/EnsureQueryDataOptions.md) +- [FetchNextPageOptions](interfaces/FetchNextPageOptions.md) +- [FetchPreviousPageOptions](interfaces/FetchPreviousPageOptions.md) +- [~~FetchQueryOptions~~](interfaces/FetchQueryOptions.md) +- [FocusManager](interfaces/FocusManager.md) +- [HydrateOptions](interfaces/HydrateOptions.md) +- [InfiniteData](interfaces/InfiniteData.md) +- [InfiniteQueryObserverBaseResult](interfaces/InfiniteQueryObserverBaseResult.md) +- [InfiniteQueryObserverLoadingErrorResult](interfaces/InfiniteQueryObserverLoadingErrorResult.md) +- [InfiniteQueryObserverLoadingResult](interfaces/InfiniteQueryObserverLoadingResult.md) +- [InfiniteQueryObserverOptions](interfaces/InfiniteQueryObserverOptions.md) +- [InfiniteQueryObserverPendingResult](interfaces/InfiniteQueryObserverPendingResult.md) +- [InfiniteQueryObserverPlaceholderResult](interfaces/InfiniteQueryObserverPlaceholderResult.md) +- [InfiniteQueryObserverRefetchErrorResult](interfaces/InfiniteQueryObserverRefetchErrorResult.md) +- [InfiniteQueryObserverSuccessResult](interfaces/InfiniteQueryObserverSuccessResult.md) +- [InfiniteQueryPageParamsOptions](interfaces/InfiniteQueryPageParamsOptions.md) +- [InitialPageParam](interfaces/InitialPageParam.md) +- [InvalidateOptions](interfaces/InvalidateOptions.md) +- [InvalidateQueryFilters](interfaces/InvalidateQueryFilters.md) +- [MutateOptions](interfaces/MutateOptions.md) +- [MutationCacheConfig](interfaces/MutationCacheConfig.md) +- [MutationFilters](interfaces/MutationFilters.md) +- [MutationObserverBaseResult](interfaces/MutationObserverBaseResult.md) +- [MutationObserverErrorResult](interfaces/MutationObserverErrorResult.md) +- [MutationObserverIdleResult](interfaces/MutationObserverIdleResult.md) +- [MutationObserverLoadingResult](interfaces/MutationObserverLoadingResult.md) +- [MutationObserverOptions](interfaces/MutationObserverOptions.md) +- [MutationObserverSuccessResult](interfaces/MutationObserverSuccessResult.md) +- [MutationOptions](interfaces/MutationOptions.md) +- [MutationState](interfaces/MutationState.md) +- [NotifyEvent](interfaces/NotifyEvent.md) +- [OnlineManager](interfaces/OnlineManager.md) +- [QueriesObserverOptions](interfaces/QueriesObserverOptions.md) +- [QueryCacheConfig](interfaces/QueryCacheConfig.md) +- [QueryClientConfig](interfaces/QueryClientConfig.md) +- [QueryExecuteOptions](interfaces/QueryExecuteOptions.md) +- [QueryFilters](interfaces/QueryFilters.md) +- [QueryObserverBaseResult](interfaces/QueryObserverBaseResult.md) +- [QueryObserverLoadingErrorResult](interfaces/QueryObserverLoadingErrorResult.md) +- [QueryObserverLoadingResult](interfaces/QueryObserverLoadingResult.md) +- [QueryObserverOptions](interfaces/QueryObserverOptions.md) +- [QueryObserverPendingResult](interfaces/QueryObserverPendingResult.md) +- [QueryObserverPlaceholderResult](interfaces/QueryObserverPlaceholderResult.md) +- [QueryObserverRefetchErrorResult](interfaces/QueryObserverRefetchErrorResult.md) +- [QueryObserverSuccessResult](interfaces/QueryObserverSuccessResult.md) +- [QueryOptions](interfaces/QueryOptions.md) +- [QueryState](interfaces/QueryState.md) +- [RefetchOptions](interfaces/RefetchOptions.md) +- [RefetchQueryFilters](interfaces/RefetchQueryFilters.md) +- [Register](interfaces/Register.md) +- [ResetOptions](interfaces/ResetOptions.md) +- [ResultOptions](interfaces/ResultOptions.md) +- [SetDataOptions](interfaces/SetDataOptions.md) +- [TimeoutManager](interfaces/TimeoutManager.md) ## Type Aliases - [Accessor](type-aliases/Accessor.md) +- [AnyDataTag](type-aliases/AnyDataTag.md) - [CreateInfiniteQueryOptions](type-aliases/CreateInfiniteQueryOptions.md) - [CreateMutationOptions](type-aliases/CreateMutationOptions.md) - [CreateQueriesControllerOptions](type-aliases/CreateQueriesControllerOptions.md) - [CreateQueriesInput](type-aliases/CreateQueriesInput.md) - [CreateQueryOptions](type-aliases/CreateQueryOptions.md) +- [DataTag](type-aliases/DataTag.md) +- [dataTagErrorSymbol](type-aliases/dataTagErrorSymbol.md) +- [dataTagSymbol](type-aliases/dataTagSymbol.md) +- [DefaultedInfiniteQueryObserverOptions](type-aliases/DefaultedInfiniteQueryObserverOptions.md) +- [DefaultedQueryObserverOptions](type-aliases/DefaultedQueryObserverOptions.md) +- [DefaultError](type-aliases/DefaultError.md) +- [DefinedInfiniteQueryObserverResult](type-aliases/DefinedInfiniteQueryObserverResult.md) - [DefinedInitialDataOptions](type-aliases/DefinedInitialDataOptions.md) +- [DefinedQueryObserverResult](type-aliases/DefinedQueryObserverResult.md) +- [DistributiveOmit](type-aliases/DistributiveOmit.md) +- [~~EnsureInfiniteQueryDataOptions~~](type-aliases/EnsureInfiniteQueryDataOptions.md) +- [~~FetchInfiniteQueryOptions~~](type-aliases/FetchInfiniteQueryOptions.md) +- [FetchStatus](type-aliases/FetchStatus.md) +- [GetNextPageParamFunction](type-aliases/GetNextPageParamFunction.md) +- [GetPreviousPageParamFunction](type-aliases/GetPreviousPageParamFunction.md) +- [InferDataFromTag](type-aliases/InferDataFromTag.md) +- [InferErrorFromTag](type-aliases/InferErrorFromTag.md) - [InfiniteQueryControllerOptions](type-aliases/InfiniteQueryControllerOptions.md) +- [InfiniteQueryExecuteOptions](type-aliases/InfiniteQueryExecuteOptions.md) +- [InfiniteQueryObserverResult](type-aliases/InfiniteQueryObserverResult.md) - [InfiniteQueryResultAccessor](type-aliases/InfiniteQueryResultAccessor.md) +- [InitialDataFunction](type-aliases/InitialDataFunction.md) - [IsFetchingAccessor](type-aliases/IsFetchingAccessor.md) - [IsMutatingAccessor](type-aliases/IsMutatingAccessor.md) +- [ManagedTimerId](type-aliases/ManagedTimerId.md) +- [MutateFunction](type-aliases/MutateFunction.md) +- [MutateFunctionRest](type-aliases/MutateFunctionRest.md) +- [MutationCacheNotifyEvent](type-aliases/MutationCacheNotifyEvent.md) - [MutationControllerOptions](type-aliases/MutationControllerOptions.md) - [MutationControllerResult](type-aliases/MutationControllerResult.md) +- [MutationFunction](type-aliases/MutationFunction.md) +- [MutationFunctionContext](type-aliases/MutationFunctionContext.md) +- [MutationKey](type-aliases/MutationKey.md) +- [MutationMeta](type-aliases/MutationMeta.md) +- [MutationObserverResult](type-aliases/MutationObserverResult.md) - [MutationResultAccessor](type-aliases/MutationResultAccessor.md) +- [MutationScope](type-aliases/MutationScope.md) - [MutationStateAccessor](type-aliases/MutationStateAccessor.md) - [MutationStateOptions](type-aliases/MutationStateOptions.md) +- [MutationStatus](type-aliases/MutationStatus.md) +- [NetworkMode](type-aliases/NetworkMode.md) +- [NonUndefinedGuard](type-aliases/NonUndefinedGuard.md) +- [NotifyEventType](type-aliases/NotifyEventType.md) +- [NotifyOnChangeProps](type-aliases/NotifyOnChangeProps.md) +- [OmitKeyof](type-aliases/OmitKeyof.md) +- [Override](type-aliases/Override.md) +- [PlaceholderDataFunction](type-aliases/PlaceholderDataFunction.md) - [QueriesControllerOptions](type-aliases/QueriesControllerOptions.md) +- [QueriesPlaceholderDataFunction](type-aliases/QueriesPlaceholderDataFunction.md) - [QueriesResultAccessor](type-aliases/QueriesResultAccessor.md) +- [QueryBooleanOption](type-aliases/QueryBooleanOption.md) +- [QueryCacheNotifyEvent](type-aliases/QueryCacheNotifyEvent.md) - [QueryControllerOptions](type-aliases/QueryControllerOptions.md) - [QueryControllerResult](type-aliases/QueryControllerResult.md) +- [QueryFunction](type-aliases/QueryFunction.md) +- [QueryFunctionContext](type-aliases/QueryFunctionContext.md) +- [QueryKey](type-aliases/QueryKey.md) +- [QueryKeyHashFunction](type-aliases/QueryKeyHashFunction.md) +- [QueryKeyWithDataTag](type-aliases/QueryKeyWithDataTag.md) +- [QueryMeta](type-aliases/QueryMeta.md) +- [QueryObserverResult](type-aliases/QueryObserverResult.md) +- [QueryPersister](type-aliases/QueryPersister.md) - [QueryResultAccessor](type-aliases/QueryResultAccessor.md) +- [QueryStatus](type-aliases/QueryStatus.md) +- [SkipToken](type-aliases/SkipToken.md) +- [StaleTime](type-aliases/StaleTime.md) +- [StaleTimeFunction](type-aliases/StaleTimeFunction.md) +- [ThrowOnError](type-aliases/ThrowOnError.md) +- [TimeoutCallback](type-aliases/TimeoutCallback.md) +- [TimeoutProvider](type-aliases/TimeoutProvider.md) - [UndefinedInitialDataOptions](type-aliases/UndefinedInitialDataOptions.md) +- [UnsetMarker](type-aliases/UnsetMarker.md) - [UnusedSkipTokenOptions](type-aliases/UnusedSkipTokenOptions.md) +- [Updater](type-aliases/Updater.md) - [ValueAccessor](type-aliases/ValueAccessor.md) +- [WithRequired](type-aliases/WithRequired.md) ## Variables +- [dataTagErrorSymbol](variables/dataTagErrorSymbol.md) +- [dataTagSymbol](variables/dataTagSymbol.md) +- [defaultScheduler](variables/defaultScheduler.md) +- [environmentManager](variables/environmentManager.md) +- [focusManager](variables/focusManager.md) +- [~~isServer~~](variables/isServer.md) +- [notifyManager](variables/notifyManager.md) +- [onlineManager](variables/onlineManager.md) - [queryClientContext](variables/queryClientContext.md) +- [skipToken](variables/skipToken.md) +- [timeoutManager](variables/timeoutManager.md) +- [unsetMarker](variables/unsetMarker.md) ## Functions @@ -44,12 +185,27 @@ title: "@tanstack/lit-query" - [createMutationController](functions/createMutationController.md) - [createQueriesController](functions/createQueriesController.md) - [createQueryController](functions/createQueryController.md) +- [defaultShouldDehydrateMutation](functions/defaultShouldDehydrateMutation.md) +- [defaultShouldDehydrateQuery](functions/defaultShouldDehydrateQuery.md) +- [dehydrate](functions/dehydrate.md) +- [dehydrateQuery](functions/dehydrateQuery.md) +- [experimental\_streamedQuery](functions/experimental_streamedQuery.md) - [getDefaultQueryClient](functions/getDefaultQueryClient.md) +- [hashKey](functions/hashKey.md) +- [hydrate](functions/hydrate.md) - [infiniteQueryOptions](functions/infiniteQueryOptions.md) +- [~~isCancelledError~~](functions/isCancelledError.md) +- [keepPreviousData](functions/keepPreviousData.md) +- [matchMutation](functions/matchMutation.md) +- [matchQuery](functions/matchQuery.md) - [mutationOptions](functions/mutationOptions.md) +- [noop](functions/noop.md) +- [partialMatchKey](functions/partialMatchKey.md) - [queryOptions](functions/queryOptions.md) - [registerDefaultQueryClient](functions/registerDefaultQueryClient.md) +- [replaceEqualDeep](functions/replaceEqualDeep.md) - [resolveQueryClient](functions/resolveQueryClient.md) +- [shouldThrowError](functions/shouldThrowError.md) - [unregisterDefaultQueryClient](functions/unregisterDefaultQueryClient.md) - [useIsFetching](functions/useIsFetching.md) - [useIsMutating](functions/useIsMutating.md) diff --git a/docs/framework/lit/reference/interfaces/CancelOptions.md b/docs/framework/lit/reference/interfaces/CancelOptions.md new file mode 100644 index 00000000000..b7464c48e50 --- /dev/null +++ b/docs/framework/lit/reference/interfaces/CancelOptions.md @@ -0,0 +1,26 @@ +--- +id: CancelOptions +title: CancelOptions +--- + +Defined in: [packages/query-core/src/types.ts:1521](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1521) + +## Properties + +### revert? + +```ts +optional revert: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1522](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1522) + +*** + +### silent? + +```ts +optional silent: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1523](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1523) diff --git a/docs/framework/lit/reference/interfaces/DefaultOptions.md b/docs/framework/lit/reference/interfaces/DefaultOptions.md new file mode 100644 index 00000000000..e45a56f075f --- /dev/null +++ b/docs/framework/lit/reference/interfaces/DefaultOptions.md @@ -0,0 +1,84 @@ +--- +id: DefaultOptions +title: DefaultOptions +--- + +Defined in: [packages/query-core/src/types.ts:1507](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1507) + +## Type Parameters + +### TError + +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) + +## Properties + +### dehydrate? + +```ts +optional dehydrate: DehydrateOptions; +``` + +Defined in: [packages/query-core/src/types.ts:1518](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1518) + +Default options used when dehydrating the client's caches; see [DehydrateOptions](DehydrateOptions.md). + +*** + +### hydrate? + +```ts +optional hydrate: object; +``` + +Defined in: [packages/query-core/src/types.ts:1516](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1516) + +Default options used when hydrating queries; see [HydrateOptions](HydrateOptions.md). + +#### deserializeData? + +```ts +optional deserializeData: TransformerFn; +``` + +Transforms a query's `data` after it is read from the dehydrated state, reversing `serializeData`. + +#### mutations? + +```ts +optional mutations: MutationOptions; +``` + +Default options merged into every mutation restored from the dehydrated state. + +#### queries? + +```ts +optional queries: QueryOptions; +``` + +Default options merged into every query restored from the dehydrated state. + +*** + +### mutations? + +```ts +optional mutations: MutationObserverOptions; +``` + +Defined in: [packages/query-core/src/types.ts:1514](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1514) + +Default options applied to every mutation, unless overridden per-mutation. + +*** + +### queries? + +```ts +optional queries: OmitKeyof, "queryKey" | "suspense", "strictly">; +``` + +Defined in: [packages/query-core/src/types.ts:1509](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1509) + +Default options applied to every query, unless overridden per-query. diff --git a/docs/framework/lit/reference/interfaces/DehydrateOptions.md b/docs/framework/lit/reference/interfaces/DehydrateOptions.md new file mode 100644 index 00000000000..e862ae88b43 --- /dev/null +++ b/docs/framework/lit/reference/interfaces/DehydrateOptions.md @@ -0,0 +1,89 @@ +--- +id: DehydrateOptions +title: DehydrateOptions +--- + +Defined in: [packages/query-core/src/hydration.ts:42](https://github.com/TanStack/query/blob/main/packages/query-core/src/hydration.ts#L42) + +Options for `dehydrate`, controlling which queries/mutations are included in the resulting `DehydratedState` and +how their data/errors are transformed before being serialized (e.g. for embedding in server-rendered markup). + +## Properties + +### serializeData? + +```ts +optional serializeData: TransformerFn; +``` + +Defined in: [packages/query-core/src/hydration.ts:44](https://github.com/TanStack/query/blob/main/packages/query-core/src/hydration.ts#L44) + +Transforms a query's `data` before it is dehydrated. Useful for non-JSON-serializable data. + +*** + +### shouldDehydrateMutation()? + +```ts +optional shouldDehydrateMutation: (mutation) => boolean; +``` + +Defined in: [packages/query-core/src/hydration.ts:46](https://github.com/TanStack/query/blob/main/packages/query-core/src/hydration.ts#L46) + +Predicate to decide whether a given `Mutation` should be dehydrated. Defaults to `defaultShouldDehydrateMutation`. + +#### Parameters + +##### mutation + +[`Mutation`](../classes/Mutation.md) + +#### Returns + +`boolean` + +*** + +### shouldDehydrateQuery()? + +```ts +optional shouldDehydrateQuery: (query) => boolean; +``` + +Defined in: [packages/query-core/src/hydration.ts:48](https://github.com/TanStack/query/blob/main/packages/query-core/src/hydration.ts#L48) + +Predicate to decide whether a given `Query` should be dehydrated. Defaults to `defaultShouldDehydrateQuery`. + +#### Parameters + +##### query + +[`Query`](../classes/Query.md) + +#### Returns + +`boolean` + +*** + +### shouldRedactErrors()? + +```ts +optional shouldRedactErrors: (error) => boolean; +``` + +Defined in: [packages/query-core/src/hydration.ts:54](https://github.com/TanStack/query/blob/main/packages/query-core/src/hydration.ts#L54) + +Predicate to decide whether a query's error should be redacted before dehydration. Errors are redacted +(replaced with a generic `Error('redacted')`) unless this function is provided and returns `false` for the +given error, in which case the original error is kept. + +#### Parameters + +##### error + +`unknown` + +#### Returns + +`boolean` diff --git a/docs/framework/lit/reference/interfaces/DehydratedState.md b/docs/framework/lit/reference/interfaces/DehydratedState.md new file mode 100644 index 00000000000..be034c9e8fd --- /dev/null +++ b/docs/framework/lit/reference/interfaces/DehydratedState.md @@ -0,0 +1,30 @@ +--- +id: DehydratedState +title: DehydratedState +--- + +Defined in: [packages/query-core/src/hydration.ts:94](https://github.com/TanStack/query/blob/main/packages/query-core/src/hydration.ts#L94) + +A serializable snapshot of a `QueryClient`'s cache, as produced by `dehydrate` and consumed by `hydrate`. Typically +transported from server to client (e.g. embedded in server-rendered markup) to seed the client's cache with data +that has already been fetched, avoiding a redundant fetch on the client. + +## Properties + +### mutations + +```ts +mutations: DehydratedMutation[]; +``` + +Defined in: [packages/query-core/src/hydration.ts:95](https://github.com/TanStack/query/blob/main/packages/query-core/src/hydration.ts#L95) + +*** + +### queries + +```ts +queries: DehydratedQuery[]; +``` + +Defined in: [packages/query-core/src/hydration.ts:96](https://github.com/TanStack/query/blob/main/packages/query-core/src/hydration.ts#L96) diff --git a/docs/framework/lit/reference/interfaces/EnsureQueryDataOptions.md b/docs/framework/lit/reference/interfaces/EnsureQueryDataOptions.md new file mode 100644 index 00000000000..f6d78f3f882 --- /dev/null +++ b/docs/framework/lit/reference/interfaces/EnsureQueryDataOptions.md @@ -0,0 +1,350 @@ +--- +id: EnsureQueryDataOptions +title: EnsureQueryDataOptions +--- + +Defined in: [packages/query-core/src/types.ts:614](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L614) + +## Deprecated + +## Extends + +- [`FetchQueryOptions`](FetchQueryOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`, `TPageParam`\> + +## Type Parameters + +### TQueryFnData + +`TQueryFnData` = `unknown` + +### TError + +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) + +### TData + +`TData` = `TQueryFnData` + +### TQueryKey + +`TQueryKey` *extends* [`QueryKey`](../type-aliases/QueryKey.md) = [`QueryKey`](../type-aliases/QueryKey.md) + +### TPageParam + +`TPageParam` = `never` + +## Properties + +### ~~gcTime?~~ + +```ts +optional gcTime: number; +``` + +Defined in: [packages/query-core/src/types.ts:277](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L277) + +The time in milliseconds that unused/inactive cache data remains in memory. +When a query's cache becomes unused or inactive, that cache data will be garbage collected after this duration. +When different garbage collection times are specified, the longest one will be used. +Setting it to `Infinity` will disable garbage collection. + +Defaults to `5 * 60 * 1000` (5 minutes), or `Infinity` during SSR. + +Note: the maximum allowed time is about 24 days, imposed by `setTimeout`'s 32-bit signed integer delay — see +`timeoutManager.setTimeoutProvider` for a workaround. + +#### Inherited from + +[`FetchQueryOptions`](FetchQueryOptions.md).[`gcTime`](FetchQueryOptions.md#gctime) + +*** + +### ~~initialData?~~ + +```ts +optional initialData: + | TData +| InitialDataFunction; +``` + +Defined in: [packages/query-core/src/types.ts:317](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L317) + +If set, this value will be used as the initial data for the query cache (as long as the query hasn't been +created or cached yet). +If set to a function, the function will be called **once** during the shared/root query initialization, and be +expected to synchronously return the initial data. +Initial data is considered stale by default unless a `staleTime` has been set. +`initialData` **is persisted** to the cache. + +#### Inherited from + +[`FetchQueryOptions`](FetchQueryOptions.md).[`initialData`](FetchQueryOptions.md#initialdata) + +*** + +### ~~initialDataUpdatedAt?~~ + +```ts +optional initialDataUpdatedAt: number | () => number | undefined; +``` + +Defined in: [packages/query-core/src/types.ts:321](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L321) + +If set, this value will be used as the time (in milliseconds) of when the `initialData` itself was last updated. + +#### Inherited from + +[`FetchQueryOptions`](FetchQueryOptions.md).[`initialDataUpdatedAt`](FetchQueryOptions.md#initialdataupdatedat) + +*** + +### ~~initialPageParam?~~ + +```ts +optional initialPageParam: undefined; +``` + +Defined in: [packages/query-core/src/types.ts:605](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L605) + +#### Inherited from + +[`FetchQueryOptions`](FetchQueryOptions.md).[`initialPageParam`](FetchQueryOptions.md#initialpageparam) + +*** + +### ~~maxPages?~~ + +```ts +optional maxPages: number; +``` + +Defined in: [packages/query-core/src/types.ts:345](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L345) + +Maximum number of pages to store in the data of an infinite query. + +#### Inherited from + +[`FetchQueryOptions`](FetchQueryOptions.md).[`maxPages`](FetchQueryOptions.md#maxpages) + +*** + +### ~~meta?~~ + +```ts +optional meta: Record; +``` + +Defined in: [packages/query-core/src/types.ts:341](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L341) + +Additional payload to be stored on each query. +Use this property to pass information that can be used in other places. + +#### Inherited from + +[`FetchQueryOptions`](FetchQueryOptions.md).[`meta`](FetchQueryOptions.md#meta) + +*** + +### ~~networkMode?~~ + +```ts +optional networkMode: NetworkMode; +``` + +Defined in: [packages/query-core/src/types.ts:265](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L265) + +Controls whether a query is allowed to run based on the current network connectivity. + +Defaults to `'online'`. + +#### See + +[Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. + +#### Inherited from + +[`FetchQueryOptions`](FetchQueryOptions.md).[`networkMode`](FetchQueryOptions.md#networkmode) + +*** + +### ~~persister?~~ + +```ts +optional persister: QueryPersister, TPageParam>; +``` + +Defined in: [packages/query-core/src/types.ts:290](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L290) + +This option can be used to persist the result of a query to an external storage, bypassing the need to actually +call the `queryFn`. Useful for persisting a query's data across e.g. server/client boundaries. + +#### Inherited from + +[`FetchQueryOptions`](FetchQueryOptions.md).[`persister`](FetchQueryOptions.md#persister) + +*** + +### ~~queryFn?~~ + +```ts +optional queryFn: + | typeof skipToken +| QueryFunction; +``` + +Defined in: [packages/query-core/src/types.ts:285](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L285) + +The function that the query will use to request data. +Required, unless a default query function has been set via `queryClient.setQueryDefaults` or +`queryClient.setDefaultOptions`. +Receives a [QueryFunctionContext](../type-aliases/QueryFunctionContext.md). +Must return a promise that will either resolve data or throw an error. The data cannot be `undefined`. + +#### Inherited from + +[`FetchQueryOptions`](FetchQueryOptions.md).[`queryFn`](FetchQueryOptions.md#queryfn) + +*** + +### ~~queryHash?~~ + +```ts +optional queryHash: string; +``` + +Defined in: [packages/query-core/src/types.ts:295](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L295) + +The hashed form of `queryKey`, computed with `queryKeyHashFn` (or the default hashing function otherwise). Used +as the actual cache key internally. + +#### Inherited from + +[`FetchQueryOptions`](FetchQueryOptions.md).[`queryHash`](FetchQueryOptions.md#queryhash) + +*** + +### ~~queryKey~~ + +```ts +queryKey: TQueryKey & object; +``` + +Defined in: [packages/query-core/src/types.ts:304](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L304) + +The query key to use for this query. + +The query key will be hashed into a stable hash. See [Query Keys](https://tanstack.com/query/latest/docs/framework/react/guides/query-keys) +for more information. + +The query will automatically update when this key changes (as long as `enabled` is not set to `false`). + +#### Inherited from + +[`FetchQueryOptions`](FetchQueryOptions.md).[`queryKey`](FetchQueryOptions.md#querykey) + +*** + +### ~~queryKeyHashFn?~~ + +```ts +optional queryKeyHashFn: QueryKeyHashFunction; +``` + +Defined in: [packages/query-core/src/types.ts:308](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L308) + +If specified, this function is used to hash the `queryKey` to a string. + +#### Inherited from + +[`FetchQueryOptions`](FetchQueryOptions.md).[`queryKeyHashFn`](FetchQueryOptions.md#querykeyhashfn) + +*** + +### ~~retry?~~ + +```ts +optional retry: RetryValue; +``` + +Defined in: [packages/query-core/src/types.ts:246](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L246) + +If `false`, failed queries will not retry by default. +If `true`, failed queries will retry infinitely. +If set to an integer number, e.g. 3, failed queries will retry until the failed query count meets that number. +If set to a function `(failureCount, error) => boolean` failed queries will retry until the function returns false. + +Defaults to `3` on the client and `0` on the server. + +#### Inherited from + +[`FetchQueryOptions`](FetchQueryOptions.md).[`retry`](FetchQueryOptions.md#retry) + +*** + +### ~~retryDelay?~~ + +```ts +optional retryDelay: RetryDelayValue; +``` + +Defined in: [packages/query-core/src/types.ts:258](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L258) + +This function receives a `retryAttempt` integer and the actual Error and returns the delay to apply before the +next attempt in milliseconds. + +A function like `attempt => Math.min(attempt > 1 ? 2 ** attempt * 1000 : 1000, 30 * 1000)` applies exponential +backoff. + +A function like `attempt => attempt * 1000` applies linear backoff. + +Defaults to a function that applies exponential backoff, capped at 30 seconds. + +#### Inherited from + +[`FetchQueryOptions`](FetchQueryOptions.md).[`retryDelay`](FetchQueryOptions.md#retrydelay) + +*** + +### ~~revalidateIfStale?~~ + +```ts +optional revalidateIfStale: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:627](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L627) + +*** + +### ~~staleTime?~~ + +```ts +optional staleTime: StaleTimeFunction; +``` + +Defined in: [packages/query-core/src/types.ts:610](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L610) + +The time in milliseconds after data is considered stale. +If the data is fresh it will be returned from the cache. + +#### Inherited from + +[`FetchQueryOptions`](FetchQueryOptions.md).[`staleTime`](FetchQueryOptions.md#staletime) + +*** + +### ~~structuralSharing?~~ + +```ts +optional structuralSharing: boolean | (oldData, newData) => unknown; +``` + +Defined in: [packages/query-core/src/types.ts:330](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L330) + +Set this to `false` to disable structural sharing between query results. +Set this to a function which accepts the old and new data and returns resolved data of the same type to implement custom structural sharing logic. + +Defaults to `true`. + +#### Inherited from + +[`FetchQueryOptions`](FetchQueryOptions.md).[`structuralSharing`](FetchQueryOptions.md#structuralsharing) diff --git a/docs/framework/lit/reference/interfaces/FetchNextPageOptions.md b/docs/framework/lit/reference/interfaces/FetchNextPageOptions.md new file mode 100644 index 00000000000..b79cdbe19b3 --- /dev/null +++ b/docs/framework/lit/reference/interfaces/FetchNextPageOptions.md @@ -0,0 +1,46 @@ +--- +id: FetchNextPageOptions +title: FetchNextPageOptions +--- + +Defined in: [packages/query-core/src/types.ts:737](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L737) + +## Extends + +- [`ResultOptions`](ResultOptions.md) + +## Properties + +### cancelRefetch? + +```ts +optional cancelRefetch: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:746](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L746) + +If set to `true`, calling `fetchNextPage` repeatedly will invoke `queryFn` every time, +whether the previous invocation has resolved or not. Also, the result from previous invocations will be ignored. + +If set to `false`, calling `fetchNextPage` repeatedly won't have any effect until the first invocation has resolved. + +Defaults to `true`. + +*** + +### throwOnError? + +```ts +optional throwOnError: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:701](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L701) + +If set to `true`, the method throws if any of the underlying query refetch tasks fail. + +Defaults to `false`, in which case failed refetches are swallowed and not surfaced to the +caller. + +#### Inherited from + +[`ResultOptions`](ResultOptions.md).[`throwOnError`](ResultOptions.md#throwonerror) diff --git a/docs/framework/lit/reference/interfaces/FetchPreviousPageOptions.md b/docs/framework/lit/reference/interfaces/FetchPreviousPageOptions.md new file mode 100644 index 00000000000..fd5a08767b6 --- /dev/null +++ b/docs/framework/lit/reference/interfaces/FetchPreviousPageOptions.md @@ -0,0 +1,46 @@ +--- +id: FetchPreviousPageOptions +title: FetchPreviousPageOptions +--- + +Defined in: [packages/query-core/src/types.ts:749](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L749) + +## Extends + +- [`ResultOptions`](ResultOptions.md) + +## Properties + +### cancelRefetch? + +```ts +optional cancelRefetch: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:758](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L758) + +If set to `true`, calling `fetchPreviousPage` repeatedly will invoke `queryFn` every time, +whether the previous invocation has resolved or not. Also, the result from previous invocations will be ignored. + +If set to `false`, calling `fetchPreviousPage` repeatedly won't have any effect until the first invocation has resolved. + +Defaults to `true`. + +*** + +### throwOnError? + +```ts +optional throwOnError: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:701](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L701) + +If set to `true`, the method throws if any of the underlying query refetch tasks fail. + +Defaults to `false`, in which case failed refetches are swallowed and not surfaced to the +caller. + +#### Inherited from + +[`ResultOptions`](ResultOptions.md).[`throwOnError`](ResultOptions.md#throwonerror) diff --git a/docs/framework/lit/reference/interfaces/FetchQueryOptions.md b/docs/framework/lit/reference/interfaces/FetchQueryOptions.md new file mode 100644 index 00000000000..561b68de853 --- /dev/null +++ b/docs/framework/lit/reference/interfaces/FetchQueryOptions.md @@ -0,0 +1,364 @@ +--- +id: FetchQueryOptions +title: FetchQueryOptions +--- + +Defined in: [packages/query-core/src/types.ts:595](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L595) + +## Deprecated + +## Extends + +- [`WithRequired`](../type-aliases/WithRequired.md)\<[`QueryOptions`](QueryOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`, `TPageParam`\>, `"queryKey"`\> + +## Extended by + +- [`EnsureQueryDataOptions`](EnsureQueryDataOptions.md) + +## Type Parameters + +### TQueryFnData + +`TQueryFnData` = `unknown` + +### TError + +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) + +### TData + +`TData` = `TQueryFnData` + +### TQueryKey + +`TQueryKey` *extends* [`QueryKey`](../type-aliases/QueryKey.md) = [`QueryKey`](../type-aliases/QueryKey.md) + +### TPageParam + +`TPageParam` = `never` + +## Properties + +### ~~gcTime?~~ + +```ts +optional gcTime: number; +``` + +Defined in: [packages/query-core/src/types.ts:277](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L277) + +The time in milliseconds that unused/inactive cache data remains in memory. +When a query's cache becomes unused or inactive, that cache data will be garbage collected after this duration. +When different garbage collection times are specified, the longest one will be used. +Setting it to `Infinity` will disable garbage collection. + +Defaults to `5 * 60 * 1000` (5 minutes), or `Infinity` during SSR. + +Note: the maximum allowed time is about 24 days, imposed by `setTimeout`'s 32-bit signed integer delay — see +`timeoutManager.setTimeoutProvider` for a workaround. + +#### Inherited from + +```ts +WithRequired.gcTime +``` + +*** + +### ~~initialData?~~ + +```ts +optional initialData: + | TData +| InitialDataFunction; +``` + +Defined in: [packages/query-core/src/types.ts:317](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L317) + +If set, this value will be used as the initial data for the query cache (as long as the query hasn't been +created or cached yet). +If set to a function, the function will be called **once** during the shared/root query initialization, and be +expected to synchronously return the initial data. +Initial data is considered stale by default unless a `staleTime` has been set. +`initialData` **is persisted** to the cache. + +#### Inherited from + +```ts +WithRequired.initialData +``` + +*** + +### ~~initialDataUpdatedAt?~~ + +```ts +optional initialDataUpdatedAt: number | () => number | undefined; +``` + +Defined in: [packages/query-core/src/types.ts:321](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L321) + +If set, this value will be used as the time (in milliseconds) of when the `initialData` itself was last updated. + +#### Inherited from + +```ts +WithRequired.initialDataUpdatedAt +``` + +*** + +### ~~initialPageParam?~~ + +```ts +optional initialPageParam: undefined; +``` + +Defined in: [packages/query-core/src/types.ts:605](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L605) + +*** + +### ~~maxPages?~~ + +```ts +optional maxPages: number; +``` + +Defined in: [packages/query-core/src/types.ts:345](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L345) + +Maximum number of pages to store in the data of an infinite query. + +#### Inherited from + +```ts +WithRequired.maxPages +``` + +*** + +### ~~meta?~~ + +```ts +optional meta: Record; +``` + +Defined in: [packages/query-core/src/types.ts:341](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L341) + +Additional payload to be stored on each query. +Use this property to pass information that can be used in other places. + +#### Inherited from + +```ts +WithRequired.meta +``` + +*** + +### ~~networkMode?~~ + +```ts +optional networkMode: NetworkMode; +``` + +Defined in: [packages/query-core/src/types.ts:265](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L265) + +Controls whether a query is allowed to run based on the current network connectivity. + +Defaults to `'online'`. + +#### See + +[Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. + +#### Inherited from + +```ts +WithRequired.networkMode +``` + +*** + +### ~~persister?~~ + +```ts +optional persister: QueryPersister, TPageParam>; +``` + +Defined in: [packages/query-core/src/types.ts:290](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L290) + +This option can be used to persist the result of a query to an external storage, bypassing the need to actually +call the `queryFn`. Useful for persisting a query's data across e.g. server/client boundaries. + +#### Inherited from + +```ts +WithRequired.persister +``` + +*** + +### ~~queryFn?~~ + +```ts +optional queryFn: + | typeof skipToken +| QueryFunction; +``` + +Defined in: [packages/query-core/src/types.ts:285](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L285) + +The function that the query will use to request data. +Required, unless a default query function has been set via `queryClient.setQueryDefaults` or +`queryClient.setDefaultOptions`. +Receives a [QueryFunctionContext](../type-aliases/QueryFunctionContext.md). +Must return a promise that will either resolve data or throw an error. The data cannot be `undefined`. + +#### Inherited from + +```ts +WithRequired.queryFn +``` + +*** + +### ~~queryHash?~~ + +```ts +optional queryHash: string; +``` + +Defined in: [packages/query-core/src/types.ts:295](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L295) + +The hashed form of `queryKey`, computed with `queryKeyHashFn` (or the default hashing function otherwise). Used +as the actual cache key internally. + +#### Inherited from + +```ts +WithRequired.queryHash +``` + +*** + +### ~~queryKey~~ + +```ts +queryKey: TQueryKey & object; +``` + +Defined in: [packages/query-core/src/types.ts:304](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L304) + +The query key to use for this query. + +The query key will be hashed into a stable hash. See [Query Keys](https://tanstack.com/query/latest/docs/framework/react/guides/query-keys) +for more information. + +The query will automatically update when this key changes (as long as `enabled` is not set to `false`). + +#### Inherited from + +```ts +WithRequired.queryKey +``` + +*** + +### ~~queryKeyHashFn?~~ + +```ts +optional queryKeyHashFn: QueryKeyHashFunction; +``` + +Defined in: [packages/query-core/src/types.ts:308](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L308) + +If specified, this function is used to hash the `queryKey` to a string. + +#### Inherited from + +```ts +WithRequired.queryKeyHashFn +``` + +*** + +### ~~retry?~~ + +```ts +optional retry: RetryValue; +``` + +Defined in: [packages/query-core/src/types.ts:246](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L246) + +If `false`, failed queries will not retry by default. +If `true`, failed queries will retry infinitely. +If set to an integer number, e.g. 3, failed queries will retry until the failed query count meets that number. +If set to a function `(failureCount, error) => boolean` failed queries will retry until the function returns false. + +Defaults to `3` on the client and `0` on the server. + +#### Inherited from + +```ts +WithRequired.retry +``` + +*** + +### ~~retryDelay?~~ + +```ts +optional retryDelay: RetryDelayValue; +``` + +Defined in: [packages/query-core/src/types.ts:258](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L258) + +This function receives a `retryAttempt` integer and the actual Error and returns the delay to apply before the +next attempt in milliseconds. + +A function like `attempt => Math.min(attempt > 1 ? 2 ** attempt * 1000 : 1000, 30 * 1000)` applies exponential +backoff. + +A function like `attempt => attempt * 1000` applies linear backoff. + +Defaults to a function that applies exponential backoff, capped at 30 seconds. + +#### Inherited from + +```ts +WithRequired.retryDelay +``` + +*** + +### ~~staleTime?~~ + +```ts +optional staleTime: StaleTimeFunction; +``` + +Defined in: [packages/query-core/src/types.ts:610](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L610) + +The time in milliseconds after data is considered stale. +If the data is fresh it will be returned from the cache. + +*** + +### ~~structuralSharing?~~ + +```ts +optional structuralSharing: boolean | (oldData, newData) => unknown; +``` + +Defined in: [packages/query-core/src/types.ts:330](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L330) + +Set this to `false` to disable structural sharing between query results. +Set this to a function which accepts the old and new data and returns resolved data of the same type to implement custom structural sharing logic. + +Defaults to `true`. + +#### Inherited from + +```ts +WithRequired.structuralSharing +``` diff --git a/docs/framework/lit/reference/interfaces/FocusManager.md b/docs/framework/lit/reference/interfaces/FocusManager.md new file mode 100644 index 00000000000..1ab81dc6357 --- /dev/null +++ b/docs/framework/lit/reference/interfaces/FocusManager.md @@ -0,0 +1,237 @@ +--- +id: FocusManager +title: FocusManager +--- + +Defined in: [packages/query-core/src/focusManager.ts:14](https://github.com/TanStack/query/blob/main/packages/query-core/src/focusManager.ts#L14) + +The `FocusManager` manages the focus state within TanStack Query. + +It can be used to change the default event listeners or to manually change the focus state. + +## Extends + +- `Subscribable`\<`Listener`\> + +## Properties + +### listeners + +```ts +protected listeners: Set; +``` + +Defined in: [packages/query-core/src/subscribable.ts:2](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L2) + +#### Inherited from + +```ts +Subscribable.listeners +``` + +## Methods + +### hasListeners() + +```ts +hasListeners(): boolean; +``` + +Defined in: [packages/query-core/src/subscribable.ts:19](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L19) + +#### Returns + +`boolean` + +#### Inherited from + +```ts +Subscribable.hasListeners +``` + +*** + +### isFocused() + +```ts +isFocused(): boolean; +``` + +Defined in: [packages/query-core/src/focusManager.ts:128](https://github.com/TanStack/query/blob/main/packages/query-core/src/focusManager.ts#L128) + +`isFocused` can be used to get the current focus state. + +#### Returns + +`boolean` + +*** + +### onFocus() + +```ts +onFocus(): void; +``` + +Defined in: [packages/query-core/src/focusManager.ts:118](https://github.com/TanStack/query/blob/main/packages/query-core/src/focusManager.ts#L118) + +`onFocus` notifies all subscribed listeners with the current focus state. + +#### Returns + +`void` + +*** + +### onSubscribe() + +```ts +protected onSubscribe(): void; +``` + +Defined in: [packages/query-core/src/focusManager.ts:39](https://github.com/TanStack/query/blob/main/packages/query-core/src/focusManager.ts#L39) + +#### Returns + +`void` + +#### Overrides + +```ts +Subscribable.onSubscribe +``` + +*** + +### onUnsubscribe() + +```ts +protected onUnsubscribe(): void; +``` + +Defined in: [packages/query-core/src/focusManager.ts:45](https://github.com/TanStack/query/blob/main/packages/query-core/src/focusManager.ts#L45) + +#### Returns + +`void` + +#### Overrides + +```ts +Subscribable.onUnsubscribe +``` + +*** + +### setEventListener() + +```ts +setEventListener(setup): void; +``` + +Defined in: [packages/query-core/src/focusManager.ts:77](https://github.com/TanStack/query/blob/main/packages/query-core/src/focusManager.ts#L77) + +`setEventListener` can be used to set a custom event listener that will +be used to determine the focus state. The provided `setup` function +receives a `setFocused` callback: call it with a `boolean` to manually +set the focus state, or with no arguments to re-evaluate the current +focus state and notify subscribers. + +#### Parameters + +##### setup + +`SetupFn` + +#### Returns + +`void` + +#### Example + +```ts +import { focusManager } from '@tanstack/query-core' + +focusManager.setEventListener((handleFocus) => { + const listener = () => handleFocus() + // Listen to visibilitychange + if (typeof window !== 'undefined' && window.addEventListener) { + window.addEventListener('visibilitychange', listener, false) + } + + return () => { + // Be sure to unsubscribe if a new handler is set + window.removeEventListener('visibilitychange', listener) + } +}) +``` + +*** + +### setFocused() + +```ts +setFocused(focused?): void; +``` + +Defined in: [packages/query-core/src/focusManager.ts:107](https://github.com/TanStack/query/blob/main/packages/query-core/src/focusManager.ts#L107) + +`setFocused` can be used to manually set the focus state. Set `undefined` +to fall back to the default focus check. + +#### Parameters + +##### focused? + +`boolean` + +#### Returns + +`void` + +#### Example + +```ts +import { focusManager } from '@tanstack/query-core' + +// Set focused +focusManager.setFocused(true) + +// Set unfocused +focusManager.setFocused(false) + +// Fallback to the default focus check +focusManager.setFocused(undefined) +``` + +*** + +### subscribe() + +```ts +subscribe(listener): () => void; +``` + +Defined in: [packages/query-core/src/subscribable.ts:8](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L8) + +#### Parameters + +##### listener + +`Listener` + +#### Returns + +```ts +(): void; +``` + +##### Returns + +`void` + +#### Inherited from + +```ts +Subscribable.subscribe +``` diff --git a/docs/framework/lit/reference/interfaces/HydrateOptions.md b/docs/framework/lit/reference/interfaces/HydrateOptions.md new file mode 100644 index 00000000000..fe8b92317e3 --- /dev/null +++ b/docs/framework/lit/reference/interfaces/HydrateOptions.md @@ -0,0 +1,43 @@ +--- +id: HydrateOptions +title: HydrateOptions +--- + +Defined in: [packages/query-core/src/hydration.ts:61](https://github.com/TanStack/query/blob/main/packages/query-core/src/hydration.ts#L61) + +Options for `hydrate`, controlling the default options applied to queries/mutations restored from a +`DehydratedState`, and how to reverse any transformation applied by `DehydrateOptions.serializeData`. + +## Properties + +### defaultOptions? + +```ts +optional defaultOptions: object; +``` + +Defined in: [packages/query-core/src/hydration.ts:62](https://github.com/TanStack/query/blob/main/packages/query-core/src/hydration.ts#L62) + +#### deserializeData? + +```ts +optional deserializeData: TransformerFn; +``` + +Transforms a query's `data` after it is read from the dehydrated state, reversing `serializeData`. + +#### mutations? + +```ts +optional mutations: MutationOptions; +``` + +Default options merged into every mutation restored from the dehydrated state. + +#### queries? + +```ts +optional queries: QueryOptions; +``` + +Default options merged into every query restored from the dehydrated state. diff --git a/docs/framework/lit/reference/interfaces/InfiniteData.md b/docs/framework/lit/reference/interfaces/InfiniteData.md new file mode 100644 index 00000000000..4d7ad595c2d --- /dev/null +++ b/docs/framework/lit/reference/interfaces/InfiniteData.md @@ -0,0 +1,36 @@ +--- +id: InfiniteData +title: InfiniteData +--- + +Defined in: [packages/query-core/src/types.ts:210](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L210) + +## Type Parameters + +### TData + +`TData` + +### TPageParam + +`TPageParam` = `unknown` + +## Properties + +### pageParams + +```ts +pageParams: TPageParam[]; +``` + +Defined in: [packages/query-core/src/types.ts:212](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L212) + +*** + +### pages + +```ts +pages: TData[]; +``` + +Defined in: [packages/query-core/src/types.ts:211](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L211) diff --git a/docs/framework/lit/reference/interfaces/InfiniteQueryObserverBaseResult.md b/docs/framework/lit/reference/interfaces/InfiniteQueryObserverBaseResult.md new file mode 100644 index 00000000000..0aa01962aa5 --- /dev/null +++ b/docs/framework/lit/reference/interfaces/InfiniteQueryObserverBaseResult.md @@ -0,0 +1,577 @@ +--- +id: InfiniteQueryObserverBaseResult +title: InfiniteQueryObserverBaseResult +--- + +Defined in: [packages/query-core/src/types.ts:1001](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1001) + +## Extends + +- [`QueryObserverBaseResult`](QueryObserverBaseResult.md)\<`TData`, `TError`\> + +## Extended by + +- [`InfiniteQueryObserverPendingResult`](InfiniteQueryObserverPendingResult.md) +- [`InfiniteQueryObserverLoadingResult`](InfiniteQueryObserverLoadingResult.md) +- [`InfiniteQueryObserverLoadingErrorResult`](InfiniteQueryObserverLoadingErrorResult.md) +- [`InfiniteQueryObserverRefetchErrorResult`](InfiniteQueryObserverRefetchErrorResult.md) +- [`InfiniteQueryObserverSuccessResult`](InfiniteQueryObserverSuccessResult.md) +- [`InfiniteQueryObserverPlaceholderResult`](InfiniteQueryObserverPlaceholderResult.md) + +## Type Parameters + +### TData + +`TData` = `unknown` + +### TError + +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) + +## Properties + +### data + +```ts +data: TData | undefined; +``` + +Defined in: [packages/query-core/src/types.ts:771](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L771) + +The last successfully resolved data for the query. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`data`](QueryObserverBaseResult.md#data) + +*** + +### dataUpdatedAt + +```ts +dataUpdatedAt: number; +``` + +Defined in: [packages/query-core/src/types.ts:775](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L775) + +The timestamp for when the query most recently returned the `status` as `"success"`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`dataUpdatedAt`](QueryObserverBaseResult.md#dataupdatedat) + +*** + +### error + +```ts +error: TError | null; +``` + +Defined in: [packages/query-core/src/types.ts:780](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L780) + +The error object for the query, if an error was thrown. +- Defaults to `null`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`error`](QueryObserverBaseResult.md#error) + +*** + +### errorUpdateCount + +```ts +errorUpdateCount: number; +``` + +Defined in: [packages/query-core/src/types.ts:799](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L799) + +The sum of all errors. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`errorUpdateCount`](QueryObserverBaseResult.md#errorupdatecount) + +*** + +### errorUpdatedAt + +```ts +errorUpdatedAt: number; +``` + +Defined in: [packages/query-core/src/types.ts:784](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L784) + +The timestamp for when the query most recently returned the `status` as `"error"`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`errorUpdatedAt`](QueryObserverBaseResult.md#errorupdatedat) + +*** + +### failureCount + +```ts +failureCount: number; +``` + +Defined in: [packages/query-core/src/types.ts:790](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L790) + +The failure count for the query. +- Incremented every time the query fails. +- Reset to `0` when the query succeeds. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`failureCount`](QueryObserverBaseResult.md#failurecount) + +*** + +### failureReason + +```ts +failureReason: TError | null; +``` + +Defined in: [packages/query-core/src/types.ts:795](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L795) + +The failure reason for the query retry. +- Reset to `null` when the query succeeds. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`failureReason`](QueryObserverBaseResult.md#failurereason) + +*** + +### fetchNextPage() + +```ts +fetchNextPage: (options?) => Promise>; +``` + +Defined in: [packages/query-core/src/types.ts:1008](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1008) + +This function allows you to fetch the next "page" of results. + +#### Parameters + +##### options? + +[`FetchNextPageOptions`](FetchNextPageOptions.md) + +#### Returns + +`Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> + +*** + +### fetchPreviousPage() + +```ts +fetchPreviousPage: (options?) => Promise>; +``` + +Defined in: [packages/query-core/src/types.ts:1014](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1014) + +This function allows you to fetch the previous "page" of results. + +#### Parameters + +##### options? + +[`FetchPreviousPageOptions`](FetchPreviousPageOptions.md) + +#### Returns + +`Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> + +*** + +### fetchStatus + +```ts +fetchStatus: FetchStatus; +``` + +Defined in: [packages/query-core/src/types.ts:889](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L889) + +The fetch status of the query. +- `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. +- `paused`: The query wanted to fetch, but has been `paused`. +- `idle`: The query is not fetching. +- See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`fetchStatus`](QueryObserverBaseResult.md#fetchstatus) + +*** + +### hasNextPage + +```ts +hasNextPage: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1020](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1020) + +Will be `true` if there is a next page to be fetched (known via the `getNextPageParam` option). + +*** + +### hasPreviousPage + +```ts +hasPreviousPage: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1024](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1024) + +Will be `true` if there is a previous page to be fetched (known via the `getPreviousPageParam` option). + +*** + +### isEnabled + +```ts +isEnabled: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:867](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L867) + +`true` if this observer is enabled, `false` otherwise. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isEnabled`](QueryObserverBaseResult.md#isenabled) + +*** + +### isError + +```ts +isError: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:804](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L804) + +A derived boolean from the `status` variable, provided for convenience. +- `true` if the query attempt resulted in an error. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isError`](QueryObserverBaseResult.md#iserror) + +*** + +### isFetched + +```ts +isFetched: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:808](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L808) + +Will be `true` if the query has been fetched. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isFetched`](QueryObserverBaseResult.md#isfetched) + +*** + +### isFetchedAfterMount + +```ts +isFetchedAfterMount: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:813](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L813) + +Will be `true` if the query has been fetched after the component mounted. +- This property can be used to not show any previously cached data. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isFetchedAfterMount`](QueryObserverBaseResult.md#isfetchedaftermount) + +*** + +### isFetching + +```ts +isFetching: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:818](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L818) + +A derived boolean from the `fetchStatus` variable, provided for convenience. +- `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isFetching`](QueryObserverBaseResult.md#isfetching) + +*** + +### isFetchingNextPage + +```ts +isFetchingNextPage: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1032](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1032) + +Will be `true` while fetching the next page with `fetchNextPage`. + +*** + +### isFetchingPreviousPage + +```ts +isFetchingPreviousPage: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1040](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1040) + +Will be `true` while fetching the previous page with `fetchPreviousPage`. + +*** + +### isFetchNextPageError + +```ts +isFetchNextPageError: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1028](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1028) + +Will be `true` if the query failed while fetching the next page. + +*** + +### isFetchPreviousPageError + +```ts +isFetchPreviousPageError: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1036](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1036) + +Will be `true` if the query failed while fetching the previous page. + +*** + +### ~~isInitialLoading~~ + +```ts +isInitialLoading: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:836](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L836) + +#### Deprecated + +`isInitialLoading` is being deprecated in favor of `isLoading` +and will be removed in the next major version. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isInitialLoading`](QueryObserverBaseResult.md#isinitialloading) + +*** + +### isLoading + +```ts +isLoading: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:823](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L823) + +Is `true` whenever the first fetch for a query is in-flight. +- Is the same as `isFetching && isPending`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoading`](QueryObserverBaseResult.md#isloading) + +*** + +### isLoadingError + +```ts +isLoadingError: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:831](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L831) + +Will be `true` if the query failed while fetching for the first time. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoadingError`](QueryObserverBaseResult.md#isloadingerror) + +*** + +### isPaused + +```ts +isPaused: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:841](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L841) + +A derived boolean from the `fetchStatus` variable, provided for convenience. +- The query wanted to fetch, but has been `paused`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPaused`](QueryObserverBaseResult.md#ispaused) + +*** + +### isPending + +```ts +isPending: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:827](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L827) + +Will be `pending` if there's no cached data and no query attempt was finished yet. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPending`](QueryObserverBaseResult.md#ispending) + +*** + +### isPlaceholderData + +```ts +isPlaceholderData: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:845](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L845) + +Will be `true` if the data shown is the placeholder data. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPlaceholderData`](QueryObserverBaseResult.md#isplaceholderdata) + +*** + +### isRefetchError + +```ts +isRefetchError: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:849](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L849) + +Will be `true` if the query failed while refetching. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetchError`](QueryObserverBaseResult.md#isrefetcherror) + +*** + +### isRefetching + +```ts +isRefetching: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:854](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L854) + +Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. +- Is the same as `isFetching && !isPending`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetching`](QueryObserverBaseResult.md#isrefetching) + +*** + +### isStale + +```ts +isStale: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:858](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L858) + +Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isStale`](QueryObserverBaseResult.md#isstale) + +*** + +### isSuccess + +```ts +isSuccess: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:863](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L863) + +A derived boolean from the `status` variable, provided for convenience. +- `true` if the query has received a response with no errors and is ready to display its data. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isSuccess`](QueryObserverBaseResult.md#issuccess) + +*** + +### refetch() + +```ts +refetch: (options?) => Promise>; +``` + +Defined in: [packages/query-core/src/types.ts:871](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L871) + +A function to manually refetch the query. + +#### Parameters + +##### options? + +[`RefetchOptions`](RefetchOptions.md) + +#### Returns + +`Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`refetch`](QueryObserverBaseResult.md#refetch) + +*** + +### status + +```ts +status: QueryStatus; +``` + +Defined in: [packages/query-core/src/types.ts:881](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L881) + +The status of the query. +- Will be: + - `pending` if there's no cached data and no query attempt was finished yet. + - `error` if the query attempt resulted in an error. + - `success` if the query has received a response with no errors and is ready to display its data. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`status`](QueryObserverBaseResult.md#status) diff --git a/docs/framework/lit/reference/interfaces/InfiniteQueryObserverLoadingErrorResult.md b/docs/framework/lit/reference/interfaces/InfiniteQueryObserverLoadingErrorResult.md new file mode 100644 index 00000000000..f5e3352f27c --- /dev/null +++ b/docs/framework/lit/reference/interfaces/InfiniteQueryObserverLoadingErrorResult.md @@ -0,0 +1,600 @@ +--- +id: InfiniteQueryObserverLoadingErrorResult +title: InfiniteQueryObserverLoadingErrorResult +--- + +Defined in: [packages/query-core/src/types.ts:1078](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1078) + +## Extends + +- [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md)\<`TData`, `TError`\> + +## Type Parameters + +### TData + +`TData` = `unknown` + +### TError + +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) + +## Properties + +### data + +```ts +data: undefined; +``` + +Defined in: [packages/query-core/src/types.ts:1082](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1082) + +The last successfully resolved data for the query. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`data`](InfiniteQueryObserverBaseResult.md#data) + +*** + +### dataUpdatedAt + +```ts +dataUpdatedAt: number; +``` + +Defined in: [packages/query-core/src/types.ts:775](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L775) + +The timestamp for when the query most recently returned the `status` as `"success"`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`dataUpdatedAt`](InfiniteQueryObserverBaseResult.md#dataupdatedat) + +*** + +### error + +```ts +error: TError; +``` + +Defined in: [packages/query-core/src/types.ts:1083](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1083) + +The error object for the query, if an error was thrown. +- Defaults to `null`. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`error`](InfiniteQueryObserverBaseResult.md#error) + +*** + +### errorUpdateCount + +```ts +errorUpdateCount: number; +``` + +Defined in: [packages/query-core/src/types.ts:799](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L799) + +The sum of all errors. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`errorUpdateCount`](InfiniteQueryObserverBaseResult.md#errorupdatecount) + +*** + +### errorUpdatedAt + +```ts +errorUpdatedAt: number; +``` + +Defined in: [packages/query-core/src/types.ts:784](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L784) + +The timestamp for when the query most recently returned the `status` as `"error"`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`errorUpdatedAt`](InfiniteQueryObserverBaseResult.md#errorupdatedat) + +*** + +### failureCount + +```ts +failureCount: number; +``` + +Defined in: [packages/query-core/src/types.ts:790](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L790) + +The failure count for the query. +- Incremented every time the query fails. +- Reset to `0` when the query succeeds. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`failureCount`](InfiniteQueryObserverBaseResult.md#failurecount) + +*** + +### failureReason + +```ts +failureReason: TError | null; +``` + +Defined in: [packages/query-core/src/types.ts:795](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L795) + +The failure reason for the query retry. +- Reset to `null` when the query succeeds. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`failureReason`](InfiniteQueryObserverBaseResult.md#failurereason) + +*** + +### fetchNextPage() + +```ts +fetchNextPage: (options?) => Promise>; +``` + +Defined in: [packages/query-core/src/types.ts:1008](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1008) + +This function allows you to fetch the next "page" of results. + +#### Parameters + +##### options? + +[`FetchNextPageOptions`](FetchNextPageOptions.md) + +#### Returns + +`Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`fetchNextPage`](InfiniteQueryObserverBaseResult.md#fetchnextpage) + +*** + +### fetchPreviousPage() + +```ts +fetchPreviousPage: (options?) => Promise>; +``` + +Defined in: [packages/query-core/src/types.ts:1014](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1014) + +This function allows you to fetch the previous "page" of results. + +#### Parameters + +##### options? + +[`FetchPreviousPageOptions`](FetchPreviousPageOptions.md) + +#### Returns + +`Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`fetchPreviousPage`](InfiniteQueryObserverBaseResult.md#fetchpreviouspage) + +*** + +### fetchStatus + +```ts +fetchStatus: FetchStatus; +``` + +Defined in: [packages/query-core/src/types.ts:889](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L889) + +The fetch status of the query. +- `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. +- `paused`: The query wanted to fetch, but has been `paused`. +- `idle`: The query is not fetching. +- See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`fetchStatus`](InfiniteQueryObserverBaseResult.md#fetchstatus) + +*** + +### hasNextPage + +```ts +hasNextPage: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1020](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1020) + +Will be `true` if there is a next page to be fetched (known via the `getNextPageParam` option). + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`hasNextPage`](InfiniteQueryObserverBaseResult.md#hasnextpage) + +*** + +### hasPreviousPage + +```ts +hasPreviousPage: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1024](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1024) + +Will be `true` if there is a previous page to be fetched (known via the `getPreviousPageParam` option). + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`hasPreviousPage`](InfiniteQueryObserverBaseResult.md#haspreviouspage) + +*** + +### isEnabled + +```ts +isEnabled: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:867](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L867) + +`true` if this observer is enabled, `false` otherwise. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isEnabled`](InfiniteQueryObserverBaseResult.md#isenabled) + +*** + +### isError + +```ts +isError: true; +``` + +Defined in: [packages/query-core/src/types.ts:1084](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1084) + +A derived boolean from the `status` variable, provided for convenience. +- `true` if the query attempt resulted in an error. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isError`](InfiniteQueryObserverBaseResult.md#iserror) + +*** + +### isFetched + +```ts +isFetched: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:808](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L808) + +Will be `true` if the query has been fetched. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetched`](InfiniteQueryObserverBaseResult.md#isfetched) + +*** + +### isFetchedAfterMount + +```ts +isFetchedAfterMount: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:813](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L813) + +Will be `true` if the query has been fetched after the component mounted. +- This property can be used to not show any previously cached data. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchedAfterMount`](InfiniteQueryObserverBaseResult.md#isfetchedaftermount) + +*** + +### isFetching + +```ts +isFetching: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:818](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L818) + +A derived boolean from the `fetchStatus` variable, provided for convenience. +- `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetching`](InfiniteQueryObserverBaseResult.md#isfetching) + +*** + +### isFetchingNextPage + +```ts +isFetchingNextPage: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1032](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1032) + +Will be `true` while fetching the next page with `fetchNextPage`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchingNextPage`](InfiniteQueryObserverBaseResult.md#isfetchingnextpage) + +*** + +### isFetchingPreviousPage + +```ts +isFetchingPreviousPage: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1040](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1040) + +Will be `true` while fetching the previous page with `fetchPreviousPage`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchingPreviousPage`](InfiniteQueryObserverBaseResult.md#isfetchingpreviouspage) + +*** + +### isFetchNextPageError + +```ts +isFetchNextPageError: false; +``` + +Defined in: [packages/query-core/src/types.ts:1089](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1089) + +Will be `true` if the query failed while fetching the next page. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchNextPageError`](InfiniteQueryObserverBaseResult.md#isfetchnextpageerror) + +*** + +### isFetchPreviousPageError + +```ts +isFetchPreviousPageError: false; +``` + +Defined in: [packages/query-core/src/types.ts:1090](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1090) + +Will be `true` if the query failed while fetching the previous page. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchPreviousPageError`](InfiniteQueryObserverBaseResult.md#isfetchpreviouspageerror) + +*** + +### ~~isInitialLoading~~ + +```ts +isInitialLoading: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:836](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L836) + +#### Deprecated + +`isInitialLoading` is being deprecated in favor of `isLoading` +and will be removed in the next major version. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isInitialLoading`](InfiniteQueryObserverBaseResult.md#isinitialloading) + +*** + +### isLoading + +```ts +isLoading: false; +``` + +Defined in: [packages/query-core/src/types.ts:1086](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1086) + +Is `true` whenever the first fetch for a query is in-flight. +- Is the same as `isFetching && isPending`. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoading`](InfiniteQueryObserverBaseResult.md#isloading) + +*** + +### isLoadingError + +```ts +isLoadingError: true; +``` + +Defined in: [packages/query-core/src/types.ts:1087](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1087) + +Will be `true` if the query failed while fetching for the first time. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoadingError`](InfiniteQueryObserverBaseResult.md#isloadingerror) + +*** + +### isPaused + +```ts +isPaused: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:841](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L841) + +A derived boolean from the `fetchStatus` variable, provided for convenience. +- The query wanted to fetch, but has been `paused`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPaused`](InfiniteQueryObserverBaseResult.md#ispaused) + +*** + +### isPending + +```ts +isPending: false; +``` + +Defined in: [packages/query-core/src/types.ts:1085](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1085) + +Will be `pending` if there's no cached data and no query attempt was finished yet. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPending`](InfiniteQueryObserverBaseResult.md#ispending) + +*** + +### isPlaceholderData + +```ts +isPlaceholderData: false; +``` + +Defined in: [packages/query-core/src/types.ts:1092](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1092) + +Will be `true` if the data shown is the placeholder data. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPlaceholderData`](InfiniteQueryObserverBaseResult.md#isplaceholderdata) + +*** + +### isRefetchError + +```ts +isRefetchError: false; +``` + +Defined in: [packages/query-core/src/types.ts:1088](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1088) + +Will be `true` if the query failed while refetching. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isRefetchError`](InfiniteQueryObserverBaseResult.md#isrefetcherror) + +*** + +### isRefetching + +```ts +isRefetching: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:854](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L854) + +Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. +- Is the same as `isFetching && !isPending`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isRefetching`](InfiniteQueryObserverBaseResult.md#isrefetching) + +*** + +### isStale + +```ts +isStale: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:858](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L858) + +Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isStale`](InfiniteQueryObserverBaseResult.md#isstale) + +*** + +### isSuccess + +```ts +isSuccess: false; +``` + +Defined in: [packages/query-core/src/types.ts:1091](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1091) + +A derived boolean from the `status` variable, provided for convenience. +- `true` if the query has received a response with no errors and is ready to display its data. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isSuccess`](InfiniteQueryObserverBaseResult.md#issuccess) + +*** + +### refetch() + +```ts +refetch: (options?) => Promise>; +``` + +Defined in: [packages/query-core/src/types.ts:871](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L871) + +A function to manually refetch the query. + +#### Parameters + +##### options? + +[`RefetchOptions`](RefetchOptions.md) + +#### Returns + +`Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`refetch`](InfiniteQueryObserverBaseResult.md#refetch) + +*** + +### status + +```ts +status: "error"; +``` + +Defined in: [packages/query-core/src/types.ts:1093](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1093) + +The status of the query. +- Will be: + - `pending` if there's no cached data and no query attempt was finished yet. + - `error` if the query attempt resulted in an error. + - `success` if the query has received a response with no errors and is ready to display its data. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`status`](InfiniteQueryObserverBaseResult.md#status) diff --git a/docs/framework/lit/reference/interfaces/InfiniteQueryObserverLoadingResult.md b/docs/framework/lit/reference/interfaces/InfiniteQueryObserverLoadingResult.md new file mode 100644 index 00000000000..b7aa67744c0 --- /dev/null +++ b/docs/framework/lit/reference/interfaces/InfiniteQueryObserverLoadingResult.md @@ -0,0 +1,600 @@ +--- +id: InfiniteQueryObserverLoadingResult +title: InfiniteQueryObserverLoadingResult +--- + +Defined in: [packages/query-core/src/types.ts:1060](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1060) + +## Extends + +- [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md)\<`TData`, `TError`\> + +## Type Parameters + +### TData + +`TData` = `unknown` + +### TError + +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) + +## Properties + +### data + +```ts +data: undefined; +``` + +Defined in: [packages/query-core/src/types.ts:1064](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1064) + +The last successfully resolved data for the query. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`data`](InfiniteQueryObserverBaseResult.md#data) + +*** + +### dataUpdatedAt + +```ts +dataUpdatedAt: number; +``` + +Defined in: [packages/query-core/src/types.ts:775](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L775) + +The timestamp for when the query most recently returned the `status` as `"success"`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`dataUpdatedAt`](InfiniteQueryObserverBaseResult.md#dataupdatedat) + +*** + +### error + +```ts +error: null; +``` + +Defined in: [packages/query-core/src/types.ts:1065](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1065) + +The error object for the query, if an error was thrown. +- Defaults to `null`. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`error`](InfiniteQueryObserverBaseResult.md#error) + +*** + +### errorUpdateCount + +```ts +errorUpdateCount: number; +``` + +Defined in: [packages/query-core/src/types.ts:799](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L799) + +The sum of all errors. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`errorUpdateCount`](InfiniteQueryObserverBaseResult.md#errorupdatecount) + +*** + +### errorUpdatedAt + +```ts +errorUpdatedAt: number; +``` + +Defined in: [packages/query-core/src/types.ts:784](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L784) + +The timestamp for when the query most recently returned the `status` as `"error"`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`errorUpdatedAt`](InfiniteQueryObserverBaseResult.md#errorupdatedat) + +*** + +### failureCount + +```ts +failureCount: number; +``` + +Defined in: [packages/query-core/src/types.ts:790](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L790) + +The failure count for the query. +- Incremented every time the query fails. +- Reset to `0` when the query succeeds. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`failureCount`](InfiniteQueryObserverBaseResult.md#failurecount) + +*** + +### failureReason + +```ts +failureReason: TError | null; +``` + +Defined in: [packages/query-core/src/types.ts:795](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L795) + +The failure reason for the query retry. +- Reset to `null` when the query succeeds. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`failureReason`](InfiniteQueryObserverBaseResult.md#failurereason) + +*** + +### fetchNextPage() + +```ts +fetchNextPage: (options?) => Promise>; +``` + +Defined in: [packages/query-core/src/types.ts:1008](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1008) + +This function allows you to fetch the next "page" of results. + +#### Parameters + +##### options? + +[`FetchNextPageOptions`](FetchNextPageOptions.md) + +#### Returns + +`Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`fetchNextPage`](InfiniteQueryObserverBaseResult.md#fetchnextpage) + +*** + +### fetchPreviousPage() + +```ts +fetchPreviousPage: (options?) => Promise>; +``` + +Defined in: [packages/query-core/src/types.ts:1014](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1014) + +This function allows you to fetch the previous "page" of results. + +#### Parameters + +##### options? + +[`FetchPreviousPageOptions`](FetchPreviousPageOptions.md) + +#### Returns + +`Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`fetchPreviousPage`](InfiniteQueryObserverBaseResult.md#fetchpreviouspage) + +*** + +### fetchStatus + +```ts +fetchStatus: FetchStatus; +``` + +Defined in: [packages/query-core/src/types.ts:889](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L889) + +The fetch status of the query. +- `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. +- `paused`: The query wanted to fetch, but has been `paused`. +- `idle`: The query is not fetching. +- See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`fetchStatus`](InfiniteQueryObserverBaseResult.md#fetchstatus) + +*** + +### hasNextPage + +```ts +hasNextPage: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1020](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1020) + +Will be `true` if there is a next page to be fetched (known via the `getNextPageParam` option). + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`hasNextPage`](InfiniteQueryObserverBaseResult.md#hasnextpage) + +*** + +### hasPreviousPage + +```ts +hasPreviousPage: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1024](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1024) + +Will be `true` if there is a previous page to be fetched (known via the `getPreviousPageParam` option). + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`hasPreviousPage`](InfiniteQueryObserverBaseResult.md#haspreviouspage) + +*** + +### isEnabled + +```ts +isEnabled: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:867](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L867) + +`true` if this observer is enabled, `false` otherwise. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isEnabled`](InfiniteQueryObserverBaseResult.md#isenabled) + +*** + +### isError + +```ts +isError: false; +``` + +Defined in: [packages/query-core/src/types.ts:1066](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1066) + +A derived boolean from the `status` variable, provided for convenience. +- `true` if the query attempt resulted in an error. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isError`](InfiniteQueryObserverBaseResult.md#iserror) + +*** + +### isFetched + +```ts +isFetched: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:808](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L808) + +Will be `true` if the query has been fetched. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetched`](InfiniteQueryObserverBaseResult.md#isfetched) + +*** + +### isFetchedAfterMount + +```ts +isFetchedAfterMount: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:813](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L813) + +Will be `true` if the query has been fetched after the component mounted. +- This property can be used to not show any previously cached data. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchedAfterMount`](InfiniteQueryObserverBaseResult.md#isfetchedaftermount) + +*** + +### isFetching + +```ts +isFetching: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:818](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L818) + +A derived boolean from the `fetchStatus` variable, provided for convenience. +- `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetching`](InfiniteQueryObserverBaseResult.md#isfetching) + +*** + +### isFetchingNextPage + +```ts +isFetchingNextPage: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1032](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1032) + +Will be `true` while fetching the next page with `fetchNextPage`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchingNextPage`](InfiniteQueryObserverBaseResult.md#isfetchingnextpage) + +*** + +### isFetchingPreviousPage + +```ts +isFetchingPreviousPage: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1040](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1040) + +Will be `true` while fetching the previous page with `fetchPreviousPage`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchingPreviousPage`](InfiniteQueryObserverBaseResult.md#isfetchingpreviouspage) + +*** + +### isFetchNextPageError + +```ts +isFetchNextPageError: false; +``` + +Defined in: [packages/query-core/src/types.ts:1071](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1071) + +Will be `true` if the query failed while fetching the next page. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchNextPageError`](InfiniteQueryObserverBaseResult.md#isfetchnextpageerror) + +*** + +### isFetchPreviousPageError + +```ts +isFetchPreviousPageError: false; +``` + +Defined in: [packages/query-core/src/types.ts:1072](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1072) + +Will be `true` if the query failed while fetching the previous page. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchPreviousPageError`](InfiniteQueryObserverBaseResult.md#isfetchpreviouspageerror) + +*** + +### ~~isInitialLoading~~ + +```ts +isInitialLoading: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:836](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L836) + +#### Deprecated + +`isInitialLoading` is being deprecated in favor of `isLoading` +and will be removed in the next major version. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isInitialLoading`](InfiniteQueryObserverBaseResult.md#isinitialloading) + +*** + +### isLoading + +```ts +isLoading: true; +``` + +Defined in: [packages/query-core/src/types.ts:1068](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1068) + +Is `true` whenever the first fetch for a query is in-flight. +- Is the same as `isFetching && isPending`. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoading`](InfiniteQueryObserverBaseResult.md#isloading) + +*** + +### isLoadingError + +```ts +isLoadingError: false; +``` + +Defined in: [packages/query-core/src/types.ts:1069](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1069) + +Will be `true` if the query failed while fetching for the first time. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoadingError`](InfiniteQueryObserverBaseResult.md#isloadingerror) + +*** + +### isPaused + +```ts +isPaused: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:841](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L841) + +A derived boolean from the `fetchStatus` variable, provided for convenience. +- The query wanted to fetch, but has been `paused`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPaused`](InfiniteQueryObserverBaseResult.md#ispaused) + +*** + +### isPending + +```ts +isPending: true; +``` + +Defined in: [packages/query-core/src/types.ts:1067](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1067) + +Will be `pending` if there's no cached data and no query attempt was finished yet. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPending`](InfiniteQueryObserverBaseResult.md#ispending) + +*** + +### isPlaceholderData + +```ts +isPlaceholderData: false; +``` + +Defined in: [packages/query-core/src/types.ts:1074](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1074) + +Will be `true` if the data shown is the placeholder data. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPlaceholderData`](InfiniteQueryObserverBaseResult.md#isplaceholderdata) + +*** + +### isRefetchError + +```ts +isRefetchError: false; +``` + +Defined in: [packages/query-core/src/types.ts:1070](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1070) + +Will be `true` if the query failed while refetching. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isRefetchError`](InfiniteQueryObserverBaseResult.md#isrefetcherror) + +*** + +### isRefetching + +```ts +isRefetching: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:854](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L854) + +Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. +- Is the same as `isFetching && !isPending`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isRefetching`](InfiniteQueryObserverBaseResult.md#isrefetching) + +*** + +### isStale + +```ts +isStale: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:858](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L858) + +Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isStale`](InfiniteQueryObserverBaseResult.md#isstale) + +*** + +### isSuccess + +```ts +isSuccess: false; +``` + +Defined in: [packages/query-core/src/types.ts:1073](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1073) + +A derived boolean from the `status` variable, provided for convenience. +- `true` if the query has received a response with no errors and is ready to display its data. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isSuccess`](InfiniteQueryObserverBaseResult.md#issuccess) + +*** + +### refetch() + +```ts +refetch: (options?) => Promise>; +``` + +Defined in: [packages/query-core/src/types.ts:871](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L871) + +A function to manually refetch the query. + +#### Parameters + +##### options? + +[`RefetchOptions`](RefetchOptions.md) + +#### Returns + +`Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`refetch`](InfiniteQueryObserverBaseResult.md#refetch) + +*** + +### status + +```ts +status: "pending"; +``` + +Defined in: [packages/query-core/src/types.ts:1075](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1075) + +The status of the query. +- Will be: + - `pending` if there's no cached data and no query attempt was finished yet. + - `error` if the query attempt resulted in an error. + - `success` if the query has received a response with no errors and is ready to display its data. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`status`](InfiniteQueryObserverBaseResult.md#status) diff --git a/docs/framework/lit/reference/interfaces/InfiniteQueryObserverOptions.md b/docs/framework/lit/reference/interfaces/InfiniteQueryObserverOptions.md new file mode 100644 index 00000000000..404c8e34519 --- /dev/null +++ b/docs/framework/lit/reference/interfaces/InfiniteQueryObserverOptions.md @@ -0,0 +1,624 @@ +--- +id: InfiniteQueryObserverOptions +title: InfiniteQueryObserverOptions +--- + +Defined in: [packages/query-core/src/types.ts:539](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L539) + +## Extends + +- [`QueryObserverOptions`](QueryObserverOptions.md)\<`TQueryFnData`, `TError`, `TData`, [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`, `TPageParam`\>.[`InfiniteQueryPageParamsOptions`](InfiniteQueryPageParamsOptions.md)\<`TQueryFnData`, `TPageParam`\> + +## Type Parameters + +### TQueryFnData + +`TQueryFnData` = `unknown` + +### TError + +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) + +### TData + +`TData` = `TQueryFnData` + +### TQueryKey + +`TQueryKey` *extends* [`QueryKey`](../type-aliases/QueryKey.md) = [`QueryKey`](../type-aliases/QueryKey.md) + +### TPageParam + +`TPageParam` = `unknown` + +## Properties + +### enabled? + +```ts +optional enabled: QueryBooleanOption, TQueryKey>; +``` + +Defined in: [packages/query-core/src/types.ts:398](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L398) + +Set this to `false` or a function that returns `false` to disable automatic refetching when the query mounts or changes query keys. +To refetch the query, use the `refetch` method returned from the `useQuery` instance. +Accepts a boolean or function that returns a boolean. + +Defaults to `true`. + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`enabled`](QueryObserverOptions.md#enabled) + +*** + +### gcTime? + +```ts +optional gcTime: number; +``` + +Defined in: [packages/query-core/src/types.ts:277](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L277) + +The time in milliseconds that unused/inactive cache data remains in memory. +When a query's cache becomes unused or inactive, that cache data will be garbage collected after this duration. +When different garbage collection times are specified, the longest one will be used. +Setting it to `Infinity` will disable garbage collection. + +Defaults to `5 * 60 * 1000` (5 minutes), or `Infinity` during SSR. + +Note: the maximum allowed time is about 24 days, imposed by `setTimeout`'s 32-bit signed integer delay — see +`timeoutManager.setTimeoutProvider` for a workaround. + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`gcTime`](QueryObserverOptions.md#gctime) + +*** + +### getNextPageParam + +```ts +getNextPageParam: GetNextPageParamFunction; +``` + +Defined in: [packages/query-core/src/types.ts:365](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L365) + +This function can be set to automatically get the next cursor for infinite queries. +The result will also be used to determine the value of `hasNextPage`. + +#### Inherited from + +[`InfiniteQueryPageParamsOptions`](InfiniteQueryPageParamsOptions.md).[`getNextPageParam`](InfiniteQueryPageParamsOptions.md#getnextpageparam) + +*** + +### getPreviousPageParam? + +```ts +optional getPreviousPageParam: GetPreviousPageParamFunction; +``` + +Defined in: [packages/query-core/src/types.ts:360](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L360) + +This function can be set to automatically get the previous cursor for infinite queries. +The result will also be used to determine the value of `hasPreviousPage`. + +#### Inherited from + +[`InfiniteQueryPageParamsOptions`](InfiniteQueryPageParamsOptions.md).[`getPreviousPageParam`](InfiniteQueryPageParamsOptions.md#getpreviouspageparam) + +*** + +### initialData? + +```ts +optional initialData: + | InfiniteData +| InitialDataFunction>; +``` + +Defined in: [packages/query-core/src/types.ts:317](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L317) + +If set, this value will be used as the initial data for the query cache (as long as the query hasn't been +created or cached yet). +If set to a function, the function will be called **once** during the shared/root query initialization, and be +expected to synchronously return the initial data. +Initial data is considered stale by default unless a `staleTime` has been set. +`initialData` **is persisted** to the cache. + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`initialData`](QueryObserverOptions.md#initialdata) + +*** + +### initialDataUpdatedAt? + +```ts +optional initialDataUpdatedAt: number | () => number | undefined; +``` + +Defined in: [packages/query-core/src/types.ts:321](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L321) + +If set, this value will be used as the time (in milliseconds) of when the `initialData` itself was last updated. + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`initialDataUpdatedAt`](QueryObserverOptions.md#initialdataupdatedat) + +*** + +### initialPageParam + +```ts +initialPageParam: TPageParam; +``` + +Defined in: [packages/query-core/src/types.ts:349](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L349) + +#### Inherited from + +[`InfiniteQueryPageParamsOptions`](InfiniteQueryPageParamsOptions.md).[`initialPageParam`](InfiniteQueryPageParamsOptions.md#initialpageparam) + +*** + +### maxPages? + +```ts +optional maxPages: number; +``` + +Defined in: [packages/query-core/src/types.ts:345](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L345) + +Maximum number of pages to store in the data of an infinite query. + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`maxPages`](QueryObserverOptions.md#maxpages) + +*** + +### meta? + +```ts +optional meta: Record; +``` + +Defined in: [packages/query-core/src/types.ts:341](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L341) + +Additional payload to be stored on each query. +Use this property to pass information that can be used in other places. + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`meta`](QueryObserverOptions.md#meta) + +*** + +### networkMode? + +```ts +optional networkMode: NetworkMode; +``` + +Defined in: [packages/query-core/src/types.ts:265](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L265) + +Controls whether a query is allowed to run based on the current network connectivity. + +Defaults to `'online'`. + +#### See + +[Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`networkMode`](QueryObserverOptions.md#networkmode) + +*** + +### notifyOnChangeProps? + +```ts +optional notifyOnChangeProps: NotifyOnChangeProps; +``` + +Defined in: [packages/query-core/src/types.ts:484](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L484) + +If set, the component will only re-render if any of the listed properties change. +When set to `['data', 'error']`, the component will only re-render when the `data` or `error` properties change. +When set to `'all'`, the component will re-render whenever a query is updated. +When set to a function, the function will be executed to compute the list of properties. + +Defaults to `undefined`, in which case property access is tracked automatically, and the +component only re-renders when one of the tracked properties changes. + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`notifyOnChangeProps`](QueryObserverOptions.md#notifyonchangeprops) + +*** + +### persister? + +```ts +optional persister: QueryPersister, TPageParam>; +``` + +Defined in: [packages/query-core/src/types.ts:290](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L290) + +This option can be used to persist the result of a query to an external storage, bypassing the need to actually +call the `queryFn`. Useful for persisting a query's data across e.g. server/client boundaries. + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`persister`](QueryObserverOptions.md#persister) + +*** + +### placeholderData? + +```ts +optional placeholderData: + | InfiniteData +| PlaceholderDataFunction, TError, InfiniteData, TQueryKey>; +``` + +Defined in: [packages/query-core/src/types.ts:511](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L511) + +If set, this value will be used as the placeholder data for this particular query observer while the query is still in the `loading` data and no initialData has been provided. + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`placeholderData`](QueryObserverOptions.md#placeholderdata) + +*** + +### queryFn? + +```ts +optional queryFn: + | typeof skipToken +| QueryFunction; +``` + +Defined in: [packages/query-core/src/types.ts:285](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L285) + +The function that the query will use to request data. +Required, unless a default query function has been set via `queryClient.setQueryDefaults` or +`queryClient.setDefaultOptions`. +Receives a [QueryFunctionContext](../type-aliases/QueryFunctionContext.md). +Must return a promise that will either resolve data or throw an error. The data cannot be `undefined`. + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`queryFn`](QueryObserverOptions.md#queryfn) + +*** + +### queryHash? + +```ts +optional queryHash: string; +``` + +Defined in: [packages/query-core/src/types.ts:295](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L295) + +The hashed form of `queryKey`, computed with `queryKeyHashFn` (or the default hashing function otherwise). Used +as the actual cache key internally. + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`queryHash`](QueryObserverOptions.md#queryhash) + +*** + +### queryKey + +```ts +queryKey: TQueryKey & object; +``` + +Defined in: [packages/query-core/src/types.ts:304](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L304) + +The query key to use for this query. + +The query key will be hashed into a stable hash. See [Query Keys](https://tanstack.com/query/latest/docs/framework/react/guides/query-keys) +for more information. + +The query will automatically update when this key changes (as long as `enabled` is not set to `false`). + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`queryKey`](QueryObserverOptions.md#querykey) + +*** + +### queryKeyHashFn? + +```ts +optional queryKeyHashFn: QueryKeyHashFunction; +``` + +Defined in: [packages/query-core/src/types.ts:308](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L308) + +If specified, this function is used to hash the `queryKey` to a string. + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`queryKeyHashFn`](QueryObserverOptions.md#querykeyhashfn) + +*** + +### refetchInterval? + +```ts +optional refetchInterval: number | false | (query) => number | false | undefined; +``` + +Defined in: [packages/query-core/src/types.ts:414](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L414) + +If set to a number, the query will continuously refetch at this frequency in milliseconds. +If set to a function, the function will be executed with the latest data and query to compute a frequency + +Defaults to `false`. + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`refetchInterval`](QueryObserverOptions.md#refetchinterval) + +*** + +### refetchIntervalInBackground? + +```ts +optional refetchIntervalInBackground: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:425](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L425) + +If set to `true`, the query will continue to refetch while their tab/window is in the background. + +Defaults to `false`. + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`refetchIntervalInBackground`](QueryObserverOptions.md#refetchintervalinbackground) + +*** + +### refetchOnMount? + +```ts +optional refetchOnMount: boolean | "always" | (query) => boolean | "always"; +``` + +Defined in: [packages/query-core/src/types.ts:462](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L462) + +If set to `true`, the query will refetch on mount if the data is stale. +If set to `false`, will disable additional instances of a query to trigger background refetch. +If set to `'always'`, the query will always refetch on mount (except when `staleTime: 'static'` is used). +If set to a function, the function will be executed with the latest data and query to compute the value + +Defaults to `true`. + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`refetchOnMount`](QueryObserverOptions.md#refetchonmount) + +*** + +### refetchOnReconnect? + +```ts +optional refetchOnReconnect: boolean | "always" | (query) => boolean | "always"; +``` + +Defined in: [packages/query-core/src/types.ts:448](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L448) + +If set to `true`, the query will refetch on reconnect if the data is stale. +If set to `false`, the query will not refetch on reconnect. +If set to `'always'`, the query will always refetch on reconnect (except when `staleTime: 'static'` is used). +If set to a function, the function will be executed with the latest data and query to compute the value. + +Defaults to `true` unless `networkMode` is `'always'`. + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`refetchOnReconnect`](QueryObserverOptions.md#refetchonreconnect) + +*** + +### refetchOnWindowFocus? + +```ts +optional refetchOnWindowFocus: boolean | "always" | (query) => boolean | "always"; +``` + +Defined in: [packages/query-core/src/types.ts:434](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L434) + +If set to `true`, the query will refetch on window focus if the data is stale. +If set to `false`, the query will not refetch on window focus. +If set to `'always'`, the query will always refetch on window focus (except when `staleTime: 'static'` is used). +If set to a function, the function will be executed with the latest data and query to compute the value. + +Defaults to `true`. + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`refetchOnWindowFocus`](QueryObserverOptions.md#refetchonwindowfocus) + +*** + +### retry? + +```ts +optional retry: RetryValue; +``` + +Defined in: [packages/query-core/src/types.ts:246](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L246) + +If `false`, failed queries will not retry by default. +If `true`, failed queries will retry infinitely. +If set to an integer number, e.g. 3, failed queries will retry until the failed query count meets that number. +If set to a function `(failureCount, error) => boolean` failed queries will retry until the function returns false. + +Defaults to `3` on the client and `0` on the server. + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`retry`](QueryObserverOptions.md#retry) + +*** + +### retryDelay? + +```ts +optional retryDelay: RetryDelayValue; +``` + +Defined in: [packages/query-core/src/types.ts:258](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L258) + +This function receives a `retryAttempt` integer and the actual Error and returns the delay to apply before the +next attempt in milliseconds. + +A function like `attempt => Math.min(attempt > 1 ? 2 ** attempt * 1000 : 1000, 30 * 1000)` applies exponential +backoff. + +A function like `attempt => attempt * 1000` applies linear backoff. + +Defaults to a function that applies exponential backoff, capped at 30 seconds. + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`retryDelay`](QueryObserverOptions.md#retrydelay) + +*** + +### retryOnMount? + +```ts +optional retryOnMount: QueryBooleanOption, TQueryKey>; +``` + +Defined in: [packages/query-core/src/types.ts:474](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L474) + +If set to `false`, the query will not be retried on mount if it contains an error. +If set to a function, the function will be executed with the query to compute the value. + +Defaults to `true`. + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`retryOnMount`](QueryObserverOptions.md#retryonmount) + +*** + +### select()? + +```ts +optional select: (data) => TData; +``` + +Defined in: [packages/query-core/src/types.ts:500](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L500) + +This option can be used to transform or select a part of the data returned by the query function. It affects +the returned `data` value, but does not affect what gets stored in the query cache. +The `select` function will only run if `data` changed, or if the reference to the `select` function itself +changes. To optimize, memoize the function so its reference stays stable across calls. + +#### Parameters + +##### data + +[`InfiniteData`](InfiniteData.md) + +#### Returns + +`TData` + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`select`](QueryObserverOptions.md#select) + +*** + +### staleTime? + +```ts +optional staleTime: StaleTimeFunction, TQueryKey>; +``` + +Defined in: [packages/query-core/src/types.ts:407](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L407) + +The time in milliseconds after data is considered stale. +If set to `Infinity`, the data will never be considered stale. +If set to `'static'`, the data will never be considered stale. +If set to a function, the function will be executed with the query to compute a `staleTime`. + +Defaults to `0`. + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`staleTime`](QueryObserverOptions.md#staletime) + +*** + +### structuralSharing? + +```ts +optional structuralSharing: boolean | (oldData, newData) => unknown; +``` + +Defined in: [packages/query-core/src/types.ts:330](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L330) + +Set this to `false` to disable structural sharing between query results. +Set this to a function which accepts the old and new data and returns resolved data of the same type to implement custom structural sharing logic. + +Defaults to `true`. + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`structuralSharing`](QueryObserverOptions.md#structuralsharing) + +*** + +### suspense? + +```ts +optional suspense: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:507](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L507) + +If set to `true`, the query will suspend when `status === 'pending'` +and throw errors when `status === 'error'`. + +Defaults to `false`. + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`suspense`](QueryObserverOptions.md#suspense) + +*** + +### throwOnError? + +```ts +optional throwOnError: ThrowOnError, TQueryKey>; +``` + +Defined in: [packages/query-core/src/types.ts:493](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L493) + +Whether errors should be thrown instead of setting the `error` property. +If set to `true` or `suspense` is `true`, all errors will be thrown to the error boundary. +If set to `false` and `suspense` is `false`, errors are returned as state. +If set to a function, it will be passed the error and the query, and it should return a boolean indicating whether to show the error in an error boundary (`true`) or return the error as state (`false`). + +Defaults to `false`. + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`throwOnError`](QueryObserverOptions.md#throwonerror) diff --git a/docs/framework/lit/reference/interfaces/InfiniteQueryObserverPendingResult.md b/docs/framework/lit/reference/interfaces/InfiniteQueryObserverPendingResult.md new file mode 100644 index 00000000000..a09301ab6c4 --- /dev/null +++ b/docs/framework/lit/reference/interfaces/InfiniteQueryObserverPendingResult.md @@ -0,0 +1,600 @@ +--- +id: InfiniteQueryObserverPendingResult +title: InfiniteQueryObserverPendingResult +--- + +Defined in: [packages/query-core/src/types.ts:1043](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1043) + +## Extends + +- [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md)\<`TData`, `TError`\> + +## Type Parameters + +### TData + +`TData` = `unknown` + +### TError + +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) + +## Properties + +### data + +```ts +data: undefined; +``` + +Defined in: [packages/query-core/src/types.ts:1047](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1047) + +The last successfully resolved data for the query. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`data`](InfiniteQueryObserverBaseResult.md#data) + +*** + +### dataUpdatedAt + +```ts +dataUpdatedAt: number; +``` + +Defined in: [packages/query-core/src/types.ts:775](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L775) + +The timestamp for when the query most recently returned the `status` as `"success"`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`dataUpdatedAt`](InfiniteQueryObserverBaseResult.md#dataupdatedat) + +*** + +### error + +```ts +error: null; +``` + +Defined in: [packages/query-core/src/types.ts:1048](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1048) + +The error object for the query, if an error was thrown. +- Defaults to `null`. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`error`](InfiniteQueryObserverBaseResult.md#error) + +*** + +### errorUpdateCount + +```ts +errorUpdateCount: number; +``` + +Defined in: [packages/query-core/src/types.ts:799](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L799) + +The sum of all errors. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`errorUpdateCount`](InfiniteQueryObserverBaseResult.md#errorupdatecount) + +*** + +### errorUpdatedAt + +```ts +errorUpdatedAt: number; +``` + +Defined in: [packages/query-core/src/types.ts:784](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L784) + +The timestamp for when the query most recently returned the `status` as `"error"`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`errorUpdatedAt`](InfiniteQueryObserverBaseResult.md#errorupdatedat) + +*** + +### failureCount + +```ts +failureCount: number; +``` + +Defined in: [packages/query-core/src/types.ts:790](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L790) + +The failure count for the query. +- Incremented every time the query fails. +- Reset to `0` when the query succeeds. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`failureCount`](InfiniteQueryObserverBaseResult.md#failurecount) + +*** + +### failureReason + +```ts +failureReason: TError | null; +``` + +Defined in: [packages/query-core/src/types.ts:795](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L795) + +The failure reason for the query retry. +- Reset to `null` when the query succeeds. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`failureReason`](InfiniteQueryObserverBaseResult.md#failurereason) + +*** + +### fetchNextPage() + +```ts +fetchNextPage: (options?) => Promise>; +``` + +Defined in: [packages/query-core/src/types.ts:1008](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1008) + +This function allows you to fetch the next "page" of results. + +#### Parameters + +##### options? + +[`FetchNextPageOptions`](FetchNextPageOptions.md) + +#### Returns + +`Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`fetchNextPage`](InfiniteQueryObserverBaseResult.md#fetchnextpage) + +*** + +### fetchPreviousPage() + +```ts +fetchPreviousPage: (options?) => Promise>; +``` + +Defined in: [packages/query-core/src/types.ts:1014](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1014) + +This function allows you to fetch the previous "page" of results. + +#### Parameters + +##### options? + +[`FetchPreviousPageOptions`](FetchPreviousPageOptions.md) + +#### Returns + +`Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`fetchPreviousPage`](InfiniteQueryObserverBaseResult.md#fetchpreviouspage) + +*** + +### fetchStatus + +```ts +fetchStatus: FetchStatus; +``` + +Defined in: [packages/query-core/src/types.ts:889](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L889) + +The fetch status of the query. +- `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. +- `paused`: The query wanted to fetch, but has been `paused`. +- `idle`: The query is not fetching. +- See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`fetchStatus`](InfiniteQueryObserverBaseResult.md#fetchstatus) + +*** + +### hasNextPage + +```ts +hasNextPage: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1020](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1020) + +Will be `true` if there is a next page to be fetched (known via the `getNextPageParam` option). + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`hasNextPage`](InfiniteQueryObserverBaseResult.md#hasnextpage) + +*** + +### hasPreviousPage + +```ts +hasPreviousPage: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1024](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1024) + +Will be `true` if there is a previous page to be fetched (known via the `getPreviousPageParam` option). + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`hasPreviousPage`](InfiniteQueryObserverBaseResult.md#haspreviouspage) + +*** + +### isEnabled + +```ts +isEnabled: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:867](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L867) + +`true` if this observer is enabled, `false` otherwise. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isEnabled`](InfiniteQueryObserverBaseResult.md#isenabled) + +*** + +### isError + +```ts +isError: false; +``` + +Defined in: [packages/query-core/src/types.ts:1049](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1049) + +A derived boolean from the `status` variable, provided for convenience. +- `true` if the query attempt resulted in an error. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isError`](InfiniteQueryObserverBaseResult.md#iserror) + +*** + +### isFetched + +```ts +isFetched: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:808](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L808) + +Will be `true` if the query has been fetched. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetched`](InfiniteQueryObserverBaseResult.md#isfetched) + +*** + +### isFetchedAfterMount + +```ts +isFetchedAfterMount: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:813](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L813) + +Will be `true` if the query has been fetched after the component mounted. +- This property can be used to not show any previously cached data. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchedAfterMount`](InfiniteQueryObserverBaseResult.md#isfetchedaftermount) + +*** + +### isFetching + +```ts +isFetching: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:818](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L818) + +A derived boolean from the `fetchStatus` variable, provided for convenience. +- `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetching`](InfiniteQueryObserverBaseResult.md#isfetching) + +*** + +### isFetchingNextPage + +```ts +isFetchingNextPage: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1032](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1032) + +Will be `true` while fetching the next page with `fetchNextPage`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchingNextPage`](InfiniteQueryObserverBaseResult.md#isfetchingnextpage) + +*** + +### isFetchingPreviousPage + +```ts +isFetchingPreviousPage: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1040](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1040) + +Will be `true` while fetching the previous page with `fetchPreviousPage`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchingPreviousPage`](InfiniteQueryObserverBaseResult.md#isfetchingpreviouspage) + +*** + +### isFetchNextPageError + +```ts +isFetchNextPageError: false; +``` + +Defined in: [packages/query-core/src/types.ts:1053](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1053) + +Will be `true` if the query failed while fetching the next page. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchNextPageError`](InfiniteQueryObserverBaseResult.md#isfetchnextpageerror) + +*** + +### isFetchPreviousPageError + +```ts +isFetchPreviousPageError: false; +``` + +Defined in: [packages/query-core/src/types.ts:1054](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1054) + +Will be `true` if the query failed while fetching the previous page. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchPreviousPageError`](InfiniteQueryObserverBaseResult.md#isfetchpreviouspageerror) + +*** + +### ~~isInitialLoading~~ + +```ts +isInitialLoading: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:836](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L836) + +#### Deprecated + +`isInitialLoading` is being deprecated in favor of `isLoading` +and will be removed in the next major version. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isInitialLoading`](InfiniteQueryObserverBaseResult.md#isinitialloading) + +*** + +### isLoading + +```ts +isLoading: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:823](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L823) + +Is `true` whenever the first fetch for a query is in-flight. +- Is the same as `isFetching && isPending`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoading`](InfiniteQueryObserverBaseResult.md#isloading) + +*** + +### isLoadingError + +```ts +isLoadingError: false; +``` + +Defined in: [packages/query-core/src/types.ts:1051](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1051) + +Will be `true` if the query failed while fetching for the first time. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoadingError`](InfiniteQueryObserverBaseResult.md#isloadingerror) + +*** + +### isPaused + +```ts +isPaused: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:841](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L841) + +A derived boolean from the `fetchStatus` variable, provided for convenience. +- The query wanted to fetch, but has been `paused`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPaused`](InfiniteQueryObserverBaseResult.md#ispaused) + +*** + +### isPending + +```ts +isPending: true; +``` + +Defined in: [packages/query-core/src/types.ts:1050](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1050) + +Will be `pending` if there's no cached data and no query attempt was finished yet. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPending`](InfiniteQueryObserverBaseResult.md#ispending) + +*** + +### isPlaceholderData + +```ts +isPlaceholderData: false; +``` + +Defined in: [packages/query-core/src/types.ts:1056](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1056) + +Will be `true` if the data shown is the placeholder data. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPlaceholderData`](InfiniteQueryObserverBaseResult.md#isplaceholderdata) + +*** + +### isRefetchError + +```ts +isRefetchError: false; +``` + +Defined in: [packages/query-core/src/types.ts:1052](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1052) + +Will be `true` if the query failed while refetching. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isRefetchError`](InfiniteQueryObserverBaseResult.md#isrefetcherror) + +*** + +### isRefetching + +```ts +isRefetching: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:854](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L854) + +Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. +- Is the same as `isFetching && !isPending`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isRefetching`](InfiniteQueryObserverBaseResult.md#isrefetching) + +*** + +### isStale + +```ts +isStale: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:858](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L858) + +Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isStale`](InfiniteQueryObserverBaseResult.md#isstale) + +*** + +### isSuccess + +```ts +isSuccess: false; +``` + +Defined in: [packages/query-core/src/types.ts:1055](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1055) + +A derived boolean from the `status` variable, provided for convenience. +- `true` if the query has received a response with no errors and is ready to display its data. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isSuccess`](InfiniteQueryObserverBaseResult.md#issuccess) + +*** + +### refetch() + +```ts +refetch: (options?) => Promise>; +``` + +Defined in: [packages/query-core/src/types.ts:871](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L871) + +A function to manually refetch the query. + +#### Parameters + +##### options? + +[`RefetchOptions`](RefetchOptions.md) + +#### Returns + +`Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`refetch`](InfiniteQueryObserverBaseResult.md#refetch) + +*** + +### status + +```ts +status: "pending"; +``` + +Defined in: [packages/query-core/src/types.ts:1057](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1057) + +The status of the query. +- Will be: + - `pending` if there's no cached data and no query attempt was finished yet. + - `error` if the query attempt resulted in an error. + - `success` if the query has received a response with no errors and is ready to display its data. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`status`](InfiniteQueryObserverBaseResult.md#status) diff --git a/docs/framework/lit/reference/interfaces/InfiniteQueryObserverPlaceholderResult.md b/docs/framework/lit/reference/interfaces/InfiniteQueryObserverPlaceholderResult.md new file mode 100644 index 00000000000..58193a987d1 --- /dev/null +++ b/docs/framework/lit/reference/interfaces/InfiniteQueryObserverPlaceholderResult.md @@ -0,0 +1,600 @@ +--- +id: InfiniteQueryObserverPlaceholderResult +title: InfiniteQueryObserverPlaceholderResult +--- + +Defined in: [packages/query-core/src/types.ts:1130](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1130) + +## Extends + +- [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md)\<`TData`, `TError`\> + +## Type Parameters + +### TData + +`TData` = `unknown` + +### TError + +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) + +## Properties + +### data + +```ts +data: TData; +``` + +Defined in: [packages/query-core/src/types.ts:1134](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1134) + +The last successfully resolved data for the query. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`data`](InfiniteQueryObserverBaseResult.md#data) + +*** + +### dataUpdatedAt + +```ts +dataUpdatedAt: number; +``` + +Defined in: [packages/query-core/src/types.ts:775](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L775) + +The timestamp for when the query most recently returned the `status` as `"success"`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`dataUpdatedAt`](InfiniteQueryObserverBaseResult.md#dataupdatedat) + +*** + +### error + +```ts +error: null; +``` + +Defined in: [packages/query-core/src/types.ts:1136](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1136) + +The error object for the query, if an error was thrown. +- Defaults to `null`. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`error`](InfiniteQueryObserverBaseResult.md#error) + +*** + +### errorUpdateCount + +```ts +errorUpdateCount: number; +``` + +Defined in: [packages/query-core/src/types.ts:799](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L799) + +The sum of all errors. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`errorUpdateCount`](InfiniteQueryObserverBaseResult.md#errorupdatecount) + +*** + +### errorUpdatedAt + +```ts +errorUpdatedAt: number; +``` + +Defined in: [packages/query-core/src/types.ts:784](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L784) + +The timestamp for when the query most recently returned the `status` as `"error"`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`errorUpdatedAt`](InfiniteQueryObserverBaseResult.md#errorupdatedat) + +*** + +### failureCount + +```ts +failureCount: number; +``` + +Defined in: [packages/query-core/src/types.ts:790](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L790) + +The failure count for the query. +- Incremented every time the query fails. +- Reset to `0` when the query succeeds. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`failureCount`](InfiniteQueryObserverBaseResult.md#failurecount) + +*** + +### failureReason + +```ts +failureReason: TError | null; +``` + +Defined in: [packages/query-core/src/types.ts:795](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L795) + +The failure reason for the query retry. +- Reset to `null` when the query succeeds. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`failureReason`](InfiniteQueryObserverBaseResult.md#failurereason) + +*** + +### fetchNextPage() + +```ts +fetchNextPage: (options?) => Promise>; +``` + +Defined in: [packages/query-core/src/types.ts:1008](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1008) + +This function allows you to fetch the next "page" of results. + +#### Parameters + +##### options? + +[`FetchNextPageOptions`](FetchNextPageOptions.md) + +#### Returns + +`Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`fetchNextPage`](InfiniteQueryObserverBaseResult.md#fetchnextpage) + +*** + +### fetchPreviousPage() + +```ts +fetchPreviousPage: (options?) => Promise>; +``` + +Defined in: [packages/query-core/src/types.ts:1014](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1014) + +This function allows you to fetch the previous "page" of results. + +#### Parameters + +##### options? + +[`FetchPreviousPageOptions`](FetchPreviousPageOptions.md) + +#### Returns + +`Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`fetchPreviousPage`](InfiniteQueryObserverBaseResult.md#fetchpreviouspage) + +*** + +### fetchStatus + +```ts +fetchStatus: FetchStatus; +``` + +Defined in: [packages/query-core/src/types.ts:889](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L889) + +The fetch status of the query. +- `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. +- `paused`: The query wanted to fetch, but has been `paused`. +- `idle`: The query is not fetching. +- See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`fetchStatus`](InfiniteQueryObserverBaseResult.md#fetchstatus) + +*** + +### hasNextPage + +```ts +hasNextPage: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1020](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1020) + +Will be `true` if there is a next page to be fetched (known via the `getNextPageParam` option). + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`hasNextPage`](InfiniteQueryObserverBaseResult.md#hasnextpage) + +*** + +### hasPreviousPage + +```ts +hasPreviousPage: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1024](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1024) + +Will be `true` if there is a previous page to be fetched (known via the `getPreviousPageParam` option). + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`hasPreviousPage`](InfiniteQueryObserverBaseResult.md#haspreviouspage) + +*** + +### isEnabled + +```ts +isEnabled: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:867](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L867) + +`true` if this observer is enabled, `false` otherwise. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isEnabled`](InfiniteQueryObserverBaseResult.md#isenabled) + +*** + +### isError + +```ts +isError: false; +``` + +Defined in: [packages/query-core/src/types.ts:1135](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1135) + +A derived boolean from the `status` variable, provided for convenience. +- `true` if the query attempt resulted in an error. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isError`](InfiniteQueryObserverBaseResult.md#iserror) + +*** + +### isFetched + +```ts +isFetched: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:808](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L808) + +Will be `true` if the query has been fetched. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetched`](InfiniteQueryObserverBaseResult.md#isfetched) + +*** + +### isFetchedAfterMount + +```ts +isFetchedAfterMount: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:813](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L813) + +Will be `true` if the query has been fetched after the component mounted. +- This property can be used to not show any previously cached data. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchedAfterMount`](InfiniteQueryObserverBaseResult.md#isfetchedaftermount) + +*** + +### isFetching + +```ts +isFetching: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:818](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L818) + +A derived boolean from the `fetchStatus` variable, provided for convenience. +- `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetching`](InfiniteQueryObserverBaseResult.md#isfetching) + +*** + +### isFetchingNextPage + +```ts +isFetchingNextPage: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1032](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1032) + +Will be `true` while fetching the next page with `fetchNextPage`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchingNextPage`](InfiniteQueryObserverBaseResult.md#isfetchingnextpage) + +*** + +### isFetchingPreviousPage + +```ts +isFetchingPreviousPage: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1040](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1040) + +Will be `true` while fetching the previous page with `fetchPreviousPage`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchingPreviousPage`](InfiniteQueryObserverBaseResult.md#isfetchingpreviouspage) + +*** + +### isFetchNextPageError + +```ts +isFetchNextPageError: false; +``` + +Defined in: [packages/query-core/src/types.ts:1143](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1143) + +Will be `true` if the query failed while fetching the next page. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchNextPageError`](InfiniteQueryObserverBaseResult.md#isfetchnextpageerror) + +*** + +### isFetchPreviousPageError + +```ts +isFetchPreviousPageError: false; +``` + +Defined in: [packages/query-core/src/types.ts:1144](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1144) + +Will be `true` if the query failed while fetching the previous page. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchPreviousPageError`](InfiniteQueryObserverBaseResult.md#isfetchpreviouspageerror) + +*** + +### ~~isInitialLoading~~ + +```ts +isInitialLoading: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:836](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L836) + +#### Deprecated + +`isInitialLoading` is being deprecated in favor of `isLoading` +and will be removed in the next major version. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isInitialLoading`](InfiniteQueryObserverBaseResult.md#isinitialloading) + +*** + +### isLoading + +```ts +isLoading: false; +``` + +Defined in: [packages/query-core/src/types.ts:1138](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1138) + +Is `true` whenever the first fetch for a query is in-flight. +- Is the same as `isFetching && isPending`. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoading`](InfiniteQueryObserverBaseResult.md#isloading) + +*** + +### isLoadingError + +```ts +isLoadingError: false; +``` + +Defined in: [packages/query-core/src/types.ts:1139](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1139) + +Will be `true` if the query failed while fetching for the first time. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoadingError`](InfiniteQueryObserverBaseResult.md#isloadingerror) + +*** + +### isPaused + +```ts +isPaused: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:841](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L841) + +A derived boolean from the `fetchStatus` variable, provided for convenience. +- The query wanted to fetch, but has been `paused`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPaused`](InfiniteQueryObserverBaseResult.md#ispaused) + +*** + +### isPending + +```ts +isPending: false; +``` + +Defined in: [packages/query-core/src/types.ts:1137](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1137) + +Will be `pending` if there's no cached data and no query attempt was finished yet. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPending`](InfiniteQueryObserverBaseResult.md#ispending) + +*** + +### isPlaceholderData + +```ts +isPlaceholderData: true; +``` + +Defined in: [packages/query-core/src/types.ts:1142](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1142) + +Will be `true` if the data shown is the placeholder data. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPlaceholderData`](InfiniteQueryObserverBaseResult.md#isplaceholderdata) + +*** + +### isRefetchError + +```ts +isRefetchError: false; +``` + +Defined in: [packages/query-core/src/types.ts:1140](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1140) + +Will be `true` if the query failed while refetching. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isRefetchError`](InfiniteQueryObserverBaseResult.md#isrefetcherror) + +*** + +### isRefetching + +```ts +isRefetching: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:854](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L854) + +Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. +- Is the same as `isFetching && !isPending`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isRefetching`](InfiniteQueryObserverBaseResult.md#isrefetching) + +*** + +### isStale + +```ts +isStale: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:858](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L858) + +Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isStale`](InfiniteQueryObserverBaseResult.md#isstale) + +*** + +### isSuccess + +```ts +isSuccess: true; +``` + +Defined in: [packages/query-core/src/types.ts:1141](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1141) + +A derived boolean from the `status` variable, provided for convenience. +- `true` if the query has received a response with no errors and is ready to display its data. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isSuccess`](InfiniteQueryObserverBaseResult.md#issuccess) + +*** + +### refetch() + +```ts +refetch: (options?) => Promise>; +``` + +Defined in: [packages/query-core/src/types.ts:871](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L871) + +A function to manually refetch the query. + +#### Parameters + +##### options? + +[`RefetchOptions`](RefetchOptions.md) + +#### Returns + +`Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`refetch`](InfiniteQueryObserverBaseResult.md#refetch) + +*** + +### status + +```ts +status: "success"; +``` + +Defined in: [packages/query-core/src/types.ts:1145](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1145) + +The status of the query. +- Will be: + - `pending` if there's no cached data and no query attempt was finished yet. + - `error` if the query attempt resulted in an error. + - `success` if the query has received a response with no errors and is ready to display its data. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`status`](InfiniteQueryObserverBaseResult.md#status) diff --git a/docs/framework/lit/reference/interfaces/InfiniteQueryObserverRefetchErrorResult.md b/docs/framework/lit/reference/interfaces/InfiniteQueryObserverRefetchErrorResult.md new file mode 100644 index 00000000000..4ce469bceed --- /dev/null +++ b/docs/framework/lit/reference/interfaces/InfiniteQueryObserverRefetchErrorResult.md @@ -0,0 +1,600 @@ +--- +id: InfiniteQueryObserverRefetchErrorResult +title: InfiniteQueryObserverRefetchErrorResult +--- + +Defined in: [packages/query-core/src/types.ts:1096](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1096) + +## Extends + +- [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md)\<`TData`, `TError`\> + +## Type Parameters + +### TData + +`TData` = `unknown` + +### TError + +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) + +## Properties + +### data + +```ts +data: TData; +``` + +Defined in: [packages/query-core/src/types.ts:1100](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1100) + +The last successfully resolved data for the query. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`data`](InfiniteQueryObserverBaseResult.md#data) + +*** + +### dataUpdatedAt + +```ts +dataUpdatedAt: number; +``` + +Defined in: [packages/query-core/src/types.ts:775](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L775) + +The timestamp for when the query most recently returned the `status` as `"success"`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`dataUpdatedAt`](InfiniteQueryObserverBaseResult.md#dataupdatedat) + +*** + +### error + +```ts +error: TError; +``` + +Defined in: [packages/query-core/src/types.ts:1101](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1101) + +The error object for the query, if an error was thrown. +- Defaults to `null`. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`error`](InfiniteQueryObserverBaseResult.md#error) + +*** + +### errorUpdateCount + +```ts +errorUpdateCount: number; +``` + +Defined in: [packages/query-core/src/types.ts:799](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L799) + +The sum of all errors. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`errorUpdateCount`](InfiniteQueryObserverBaseResult.md#errorupdatecount) + +*** + +### errorUpdatedAt + +```ts +errorUpdatedAt: number; +``` + +Defined in: [packages/query-core/src/types.ts:784](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L784) + +The timestamp for when the query most recently returned the `status` as `"error"`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`errorUpdatedAt`](InfiniteQueryObserverBaseResult.md#errorupdatedat) + +*** + +### failureCount + +```ts +failureCount: number; +``` + +Defined in: [packages/query-core/src/types.ts:790](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L790) + +The failure count for the query. +- Incremented every time the query fails. +- Reset to `0` when the query succeeds. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`failureCount`](InfiniteQueryObserverBaseResult.md#failurecount) + +*** + +### failureReason + +```ts +failureReason: TError | null; +``` + +Defined in: [packages/query-core/src/types.ts:795](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L795) + +The failure reason for the query retry. +- Reset to `null` when the query succeeds. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`failureReason`](InfiniteQueryObserverBaseResult.md#failurereason) + +*** + +### fetchNextPage() + +```ts +fetchNextPage: (options?) => Promise>; +``` + +Defined in: [packages/query-core/src/types.ts:1008](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1008) + +This function allows you to fetch the next "page" of results. + +#### Parameters + +##### options? + +[`FetchNextPageOptions`](FetchNextPageOptions.md) + +#### Returns + +`Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`fetchNextPage`](InfiniteQueryObserverBaseResult.md#fetchnextpage) + +*** + +### fetchPreviousPage() + +```ts +fetchPreviousPage: (options?) => Promise>; +``` + +Defined in: [packages/query-core/src/types.ts:1014](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1014) + +This function allows you to fetch the previous "page" of results. + +#### Parameters + +##### options? + +[`FetchPreviousPageOptions`](FetchPreviousPageOptions.md) + +#### Returns + +`Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`fetchPreviousPage`](InfiniteQueryObserverBaseResult.md#fetchpreviouspage) + +*** + +### fetchStatus + +```ts +fetchStatus: FetchStatus; +``` + +Defined in: [packages/query-core/src/types.ts:889](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L889) + +The fetch status of the query. +- `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. +- `paused`: The query wanted to fetch, but has been `paused`. +- `idle`: The query is not fetching. +- See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`fetchStatus`](InfiniteQueryObserverBaseResult.md#fetchstatus) + +*** + +### hasNextPage + +```ts +hasNextPage: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1020](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1020) + +Will be `true` if there is a next page to be fetched (known via the `getNextPageParam` option). + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`hasNextPage`](InfiniteQueryObserverBaseResult.md#hasnextpage) + +*** + +### hasPreviousPage + +```ts +hasPreviousPage: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1024](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1024) + +Will be `true` if there is a previous page to be fetched (known via the `getPreviousPageParam` option). + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`hasPreviousPage`](InfiniteQueryObserverBaseResult.md#haspreviouspage) + +*** + +### isEnabled + +```ts +isEnabled: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:867](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L867) + +`true` if this observer is enabled, `false` otherwise. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isEnabled`](InfiniteQueryObserverBaseResult.md#isenabled) + +*** + +### isError + +```ts +isError: true; +``` + +Defined in: [packages/query-core/src/types.ts:1102](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1102) + +A derived boolean from the `status` variable, provided for convenience. +- `true` if the query attempt resulted in an error. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isError`](InfiniteQueryObserverBaseResult.md#iserror) + +*** + +### isFetched + +```ts +isFetched: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:808](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L808) + +Will be `true` if the query has been fetched. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetched`](InfiniteQueryObserverBaseResult.md#isfetched) + +*** + +### isFetchedAfterMount + +```ts +isFetchedAfterMount: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:813](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L813) + +Will be `true` if the query has been fetched after the component mounted. +- This property can be used to not show any previously cached data. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchedAfterMount`](InfiniteQueryObserverBaseResult.md#isfetchedaftermount) + +*** + +### isFetching + +```ts +isFetching: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:818](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L818) + +A derived boolean from the `fetchStatus` variable, provided for convenience. +- `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetching`](InfiniteQueryObserverBaseResult.md#isfetching) + +*** + +### isFetchingNextPage + +```ts +isFetchingNextPage: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1032](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1032) + +Will be `true` while fetching the next page with `fetchNextPage`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchingNextPage`](InfiniteQueryObserverBaseResult.md#isfetchingnextpage) + +*** + +### isFetchingPreviousPage + +```ts +isFetchingPreviousPage: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1040](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1040) + +Will be `true` while fetching the previous page with `fetchPreviousPage`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchingPreviousPage`](InfiniteQueryObserverBaseResult.md#isfetchingpreviouspage) + +*** + +### isFetchNextPageError + +```ts +isFetchNextPageError: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1028](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1028) + +Will be `true` if the query failed while fetching the next page. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchNextPageError`](InfiniteQueryObserverBaseResult.md#isfetchnextpageerror) + +*** + +### isFetchPreviousPageError + +```ts +isFetchPreviousPageError: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1036](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1036) + +Will be `true` if the query failed while fetching the previous page. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchPreviousPageError`](InfiniteQueryObserverBaseResult.md#isfetchpreviouspageerror) + +*** + +### ~~isInitialLoading~~ + +```ts +isInitialLoading: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:836](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L836) + +#### Deprecated + +`isInitialLoading` is being deprecated in favor of `isLoading` +and will be removed in the next major version. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isInitialLoading`](InfiniteQueryObserverBaseResult.md#isinitialloading) + +*** + +### isLoading + +```ts +isLoading: false; +``` + +Defined in: [packages/query-core/src/types.ts:1104](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1104) + +Is `true` whenever the first fetch for a query is in-flight. +- Is the same as `isFetching && isPending`. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoading`](InfiniteQueryObserverBaseResult.md#isloading) + +*** + +### isLoadingError + +```ts +isLoadingError: false; +``` + +Defined in: [packages/query-core/src/types.ts:1105](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1105) + +Will be `true` if the query failed while fetching for the first time. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoadingError`](InfiniteQueryObserverBaseResult.md#isloadingerror) + +*** + +### isPaused + +```ts +isPaused: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:841](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L841) + +A derived boolean from the `fetchStatus` variable, provided for convenience. +- The query wanted to fetch, but has been `paused`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPaused`](InfiniteQueryObserverBaseResult.md#ispaused) + +*** + +### isPending + +```ts +isPending: false; +``` + +Defined in: [packages/query-core/src/types.ts:1103](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1103) + +Will be `pending` if there's no cached data and no query attempt was finished yet. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPending`](InfiniteQueryObserverBaseResult.md#ispending) + +*** + +### isPlaceholderData + +```ts +isPlaceholderData: false; +``` + +Defined in: [packages/query-core/src/types.ts:1108](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1108) + +Will be `true` if the data shown is the placeholder data. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPlaceholderData`](InfiniteQueryObserverBaseResult.md#isplaceholderdata) + +*** + +### isRefetchError + +```ts +isRefetchError: true; +``` + +Defined in: [packages/query-core/src/types.ts:1106](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1106) + +Will be `true` if the query failed while refetching. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isRefetchError`](InfiniteQueryObserverBaseResult.md#isrefetcherror) + +*** + +### isRefetching + +```ts +isRefetching: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:854](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L854) + +Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. +- Is the same as `isFetching && !isPending`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isRefetching`](InfiniteQueryObserverBaseResult.md#isrefetching) + +*** + +### isStale + +```ts +isStale: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:858](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L858) + +Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isStale`](InfiniteQueryObserverBaseResult.md#isstale) + +*** + +### isSuccess + +```ts +isSuccess: false; +``` + +Defined in: [packages/query-core/src/types.ts:1107](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1107) + +A derived boolean from the `status` variable, provided for convenience. +- `true` if the query has received a response with no errors and is ready to display its data. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isSuccess`](InfiniteQueryObserverBaseResult.md#issuccess) + +*** + +### refetch() + +```ts +refetch: (options?) => Promise>; +``` + +Defined in: [packages/query-core/src/types.ts:871](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L871) + +A function to manually refetch the query. + +#### Parameters + +##### options? + +[`RefetchOptions`](RefetchOptions.md) + +#### Returns + +`Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`refetch`](InfiniteQueryObserverBaseResult.md#refetch) + +*** + +### status + +```ts +status: "error"; +``` + +Defined in: [packages/query-core/src/types.ts:1109](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1109) + +The status of the query. +- Will be: + - `pending` if there's no cached data and no query attempt was finished yet. + - `error` if the query attempt resulted in an error. + - `success` if the query has received a response with no errors and is ready to display its data. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`status`](InfiniteQueryObserverBaseResult.md#status) diff --git a/docs/framework/lit/reference/interfaces/InfiniteQueryObserverSuccessResult.md b/docs/framework/lit/reference/interfaces/InfiniteQueryObserverSuccessResult.md new file mode 100644 index 00000000000..131f6d01ae7 --- /dev/null +++ b/docs/framework/lit/reference/interfaces/InfiniteQueryObserverSuccessResult.md @@ -0,0 +1,600 @@ +--- +id: InfiniteQueryObserverSuccessResult +title: InfiniteQueryObserverSuccessResult +--- + +Defined in: [packages/query-core/src/types.ts:1112](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1112) + +## Extends + +- [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md)\<`TData`, `TError`\> + +## Type Parameters + +### TData + +`TData` = `unknown` + +### TError + +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) + +## Properties + +### data + +```ts +data: TData; +``` + +Defined in: [packages/query-core/src/types.ts:1116](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1116) + +The last successfully resolved data for the query. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`data`](InfiniteQueryObserverBaseResult.md#data) + +*** + +### dataUpdatedAt + +```ts +dataUpdatedAt: number; +``` + +Defined in: [packages/query-core/src/types.ts:775](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L775) + +The timestamp for when the query most recently returned the `status` as `"success"`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`dataUpdatedAt`](InfiniteQueryObserverBaseResult.md#dataupdatedat) + +*** + +### error + +```ts +error: null; +``` + +Defined in: [packages/query-core/src/types.ts:1117](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1117) + +The error object for the query, if an error was thrown. +- Defaults to `null`. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`error`](InfiniteQueryObserverBaseResult.md#error) + +*** + +### errorUpdateCount + +```ts +errorUpdateCount: number; +``` + +Defined in: [packages/query-core/src/types.ts:799](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L799) + +The sum of all errors. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`errorUpdateCount`](InfiniteQueryObserverBaseResult.md#errorupdatecount) + +*** + +### errorUpdatedAt + +```ts +errorUpdatedAt: number; +``` + +Defined in: [packages/query-core/src/types.ts:784](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L784) + +The timestamp for when the query most recently returned the `status` as `"error"`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`errorUpdatedAt`](InfiniteQueryObserverBaseResult.md#errorupdatedat) + +*** + +### failureCount + +```ts +failureCount: number; +``` + +Defined in: [packages/query-core/src/types.ts:790](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L790) + +The failure count for the query. +- Incremented every time the query fails. +- Reset to `0` when the query succeeds. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`failureCount`](InfiniteQueryObserverBaseResult.md#failurecount) + +*** + +### failureReason + +```ts +failureReason: TError | null; +``` + +Defined in: [packages/query-core/src/types.ts:795](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L795) + +The failure reason for the query retry. +- Reset to `null` when the query succeeds. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`failureReason`](InfiniteQueryObserverBaseResult.md#failurereason) + +*** + +### fetchNextPage() + +```ts +fetchNextPage: (options?) => Promise>; +``` + +Defined in: [packages/query-core/src/types.ts:1008](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1008) + +This function allows you to fetch the next "page" of results. + +#### Parameters + +##### options? + +[`FetchNextPageOptions`](FetchNextPageOptions.md) + +#### Returns + +`Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`fetchNextPage`](InfiniteQueryObserverBaseResult.md#fetchnextpage) + +*** + +### fetchPreviousPage() + +```ts +fetchPreviousPage: (options?) => Promise>; +``` + +Defined in: [packages/query-core/src/types.ts:1014](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1014) + +This function allows you to fetch the previous "page" of results. + +#### Parameters + +##### options? + +[`FetchPreviousPageOptions`](FetchPreviousPageOptions.md) + +#### Returns + +`Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`fetchPreviousPage`](InfiniteQueryObserverBaseResult.md#fetchpreviouspage) + +*** + +### fetchStatus + +```ts +fetchStatus: FetchStatus; +``` + +Defined in: [packages/query-core/src/types.ts:889](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L889) + +The fetch status of the query. +- `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. +- `paused`: The query wanted to fetch, but has been `paused`. +- `idle`: The query is not fetching. +- See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`fetchStatus`](InfiniteQueryObserverBaseResult.md#fetchstatus) + +*** + +### hasNextPage + +```ts +hasNextPage: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1020](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1020) + +Will be `true` if there is a next page to be fetched (known via the `getNextPageParam` option). + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`hasNextPage`](InfiniteQueryObserverBaseResult.md#hasnextpage) + +*** + +### hasPreviousPage + +```ts +hasPreviousPage: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1024](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1024) + +Will be `true` if there is a previous page to be fetched (known via the `getPreviousPageParam` option). + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`hasPreviousPage`](InfiniteQueryObserverBaseResult.md#haspreviouspage) + +*** + +### isEnabled + +```ts +isEnabled: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:867](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L867) + +`true` if this observer is enabled, `false` otherwise. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isEnabled`](InfiniteQueryObserverBaseResult.md#isenabled) + +*** + +### isError + +```ts +isError: false; +``` + +Defined in: [packages/query-core/src/types.ts:1118](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1118) + +A derived boolean from the `status` variable, provided for convenience. +- `true` if the query attempt resulted in an error. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isError`](InfiniteQueryObserverBaseResult.md#iserror) + +*** + +### isFetched + +```ts +isFetched: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:808](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L808) + +Will be `true` if the query has been fetched. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetched`](InfiniteQueryObserverBaseResult.md#isfetched) + +*** + +### isFetchedAfterMount + +```ts +isFetchedAfterMount: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:813](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L813) + +Will be `true` if the query has been fetched after the component mounted. +- This property can be used to not show any previously cached data. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchedAfterMount`](InfiniteQueryObserverBaseResult.md#isfetchedaftermount) + +*** + +### isFetching + +```ts +isFetching: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:818](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L818) + +A derived boolean from the `fetchStatus` variable, provided for convenience. +- `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetching`](InfiniteQueryObserverBaseResult.md#isfetching) + +*** + +### isFetchingNextPage + +```ts +isFetchingNextPage: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1032](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1032) + +Will be `true` while fetching the next page with `fetchNextPage`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchingNextPage`](InfiniteQueryObserverBaseResult.md#isfetchingnextpage) + +*** + +### isFetchingPreviousPage + +```ts +isFetchingPreviousPage: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1040](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1040) + +Will be `true` while fetching the previous page with `fetchPreviousPage`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchingPreviousPage`](InfiniteQueryObserverBaseResult.md#isfetchingpreviouspage) + +*** + +### isFetchNextPageError + +```ts +isFetchNextPageError: false; +``` + +Defined in: [packages/query-core/src/types.ts:1123](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1123) + +Will be `true` if the query failed while fetching the next page. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchNextPageError`](InfiniteQueryObserverBaseResult.md#isfetchnextpageerror) + +*** + +### isFetchPreviousPageError + +```ts +isFetchPreviousPageError: false; +``` + +Defined in: [packages/query-core/src/types.ts:1124](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1124) + +Will be `true` if the query failed while fetching the previous page. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchPreviousPageError`](InfiniteQueryObserverBaseResult.md#isfetchpreviouspageerror) + +*** + +### ~~isInitialLoading~~ + +```ts +isInitialLoading: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:836](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L836) + +#### Deprecated + +`isInitialLoading` is being deprecated in favor of `isLoading` +and will be removed in the next major version. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isInitialLoading`](InfiniteQueryObserverBaseResult.md#isinitialloading) + +*** + +### isLoading + +```ts +isLoading: false; +``` + +Defined in: [packages/query-core/src/types.ts:1120](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1120) + +Is `true` whenever the first fetch for a query is in-flight. +- Is the same as `isFetching && isPending`. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoading`](InfiniteQueryObserverBaseResult.md#isloading) + +*** + +### isLoadingError + +```ts +isLoadingError: false; +``` + +Defined in: [packages/query-core/src/types.ts:1121](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1121) + +Will be `true` if the query failed while fetching for the first time. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoadingError`](InfiniteQueryObserverBaseResult.md#isloadingerror) + +*** + +### isPaused + +```ts +isPaused: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:841](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L841) + +A derived boolean from the `fetchStatus` variable, provided for convenience. +- The query wanted to fetch, but has been `paused`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPaused`](InfiniteQueryObserverBaseResult.md#ispaused) + +*** + +### isPending + +```ts +isPending: false; +``` + +Defined in: [packages/query-core/src/types.ts:1119](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1119) + +Will be `pending` if there's no cached data and no query attempt was finished yet. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPending`](InfiniteQueryObserverBaseResult.md#ispending) + +*** + +### isPlaceholderData + +```ts +isPlaceholderData: false; +``` + +Defined in: [packages/query-core/src/types.ts:1126](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1126) + +Will be `true` if the data shown is the placeholder data. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPlaceholderData`](InfiniteQueryObserverBaseResult.md#isplaceholderdata) + +*** + +### isRefetchError + +```ts +isRefetchError: false; +``` + +Defined in: [packages/query-core/src/types.ts:1122](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1122) + +Will be `true` if the query failed while refetching. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isRefetchError`](InfiniteQueryObserverBaseResult.md#isrefetcherror) + +*** + +### isRefetching + +```ts +isRefetching: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:854](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L854) + +Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. +- Is the same as `isFetching && !isPending`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isRefetching`](InfiniteQueryObserverBaseResult.md#isrefetching) + +*** + +### isStale + +```ts +isStale: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:858](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L858) + +Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isStale`](InfiniteQueryObserverBaseResult.md#isstale) + +*** + +### isSuccess + +```ts +isSuccess: true; +``` + +Defined in: [packages/query-core/src/types.ts:1125](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1125) + +A derived boolean from the `status` variable, provided for convenience. +- `true` if the query has received a response with no errors and is ready to display its data. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isSuccess`](InfiniteQueryObserverBaseResult.md#issuccess) + +*** + +### refetch() + +```ts +refetch: (options?) => Promise>; +``` + +Defined in: [packages/query-core/src/types.ts:871](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L871) + +A function to manually refetch the query. + +#### Parameters + +##### options? + +[`RefetchOptions`](RefetchOptions.md) + +#### Returns + +`Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`refetch`](InfiniteQueryObserverBaseResult.md#refetch) + +*** + +### status + +```ts +status: "success"; +``` + +Defined in: [packages/query-core/src/types.ts:1127](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1127) + +The status of the query. +- Will be: + - `pending` if there's no cached data and no query attempt was finished yet. + - `error` if the query attempt resulted in an error. + - `success` if the query has received a response with no errors and is ready to display its data. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`status`](InfiniteQueryObserverBaseResult.md#status) diff --git a/docs/framework/lit/reference/interfaces/InfiniteQueryPageParamsOptions.md b/docs/framework/lit/reference/interfaces/InfiniteQueryPageParamsOptions.md new file mode 100644 index 00000000000..c091cc15456 --- /dev/null +++ b/docs/framework/lit/reference/interfaces/InfiniteQueryPageParamsOptions.md @@ -0,0 +1,64 @@ +--- +id: InfiniteQueryPageParamsOptions +title: InfiniteQueryPageParamsOptions +--- + +Defined in: [packages/query-core/src/types.ts:352](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L352) + +## Extends + +- [`InitialPageParam`](InitialPageParam.md)\<`TPageParam`\> + +## Extended by + +- [`InfiniteQueryObserverOptions`](InfiniteQueryObserverOptions.md) + +## Type Parameters + +### TQueryFnData + +`TQueryFnData` = `unknown` + +### TPageParam + +`TPageParam` = `unknown` + +## Properties + +### getNextPageParam + +```ts +getNextPageParam: GetNextPageParamFunction; +``` + +Defined in: [packages/query-core/src/types.ts:365](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L365) + +This function can be set to automatically get the next cursor for infinite queries. +The result will also be used to determine the value of `hasNextPage`. + +*** + +### getPreviousPageParam? + +```ts +optional getPreviousPageParam: GetPreviousPageParamFunction; +``` + +Defined in: [packages/query-core/src/types.ts:360](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L360) + +This function can be set to automatically get the previous cursor for infinite queries. +The result will also be used to determine the value of `hasPreviousPage`. + +*** + +### initialPageParam + +```ts +initialPageParam: TPageParam; +``` + +Defined in: [packages/query-core/src/types.ts:349](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L349) + +#### Inherited from + +[`InitialPageParam`](InitialPageParam.md).[`initialPageParam`](InitialPageParam.md#initialpageparam) diff --git a/docs/framework/lit/reference/interfaces/InitialPageParam.md b/docs/framework/lit/reference/interfaces/InitialPageParam.md new file mode 100644 index 00000000000..46d2b219ea4 --- /dev/null +++ b/docs/framework/lit/reference/interfaces/InitialPageParam.md @@ -0,0 +1,26 @@ +--- +id: InitialPageParam +title: InitialPageParam +--- + +Defined in: [packages/query-core/src/types.ts:348](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L348) + +## Extended by + +- [`InfiniteQueryPageParamsOptions`](InfiniteQueryPageParamsOptions.md) + +## Type Parameters + +### TPageParam + +`TPageParam` = `unknown` + +## Properties + +### initialPageParam + +```ts +initialPageParam: TPageParam; +``` + +Defined in: [packages/query-core/src/types.ts:349](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L349) diff --git a/docs/framework/lit/reference/interfaces/InvalidateOptions.md b/docs/framework/lit/reference/interfaces/InvalidateOptions.md new file mode 100644 index 00000000000..8a81428b035 --- /dev/null +++ b/docs/framework/lit/reference/interfaces/InvalidateOptions.md @@ -0,0 +1,49 @@ +--- +id: InvalidateOptions +title: InvalidateOptions +--- + +Defined in: [packages/query-core/src/types.ts:734](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L734) + +## Extends + +- [`RefetchOptions`](RefetchOptions.md) + +## Properties + +### cancelRefetch? + +```ts +optional cancelRefetch: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:712](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L712) + +If set to `true`, a currently running request will be cancelled before a new request is made + +If set to `false`, no refetch will be made if there is already a request running. + +Defaults to `true`. + +#### Inherited from + +[`RefetchOptions`](RefetchOptions.md).[`cancelRefetch`](RefetchOptions.md#cancelrefetch) + +*** + +### throwOnError? + +```ts +optional throwOnError: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:701](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L701) + +If set to `true`, the method throws if any of the underlying query refetch tasks fail. + +Defaults to `false`, in which case failed refetches are swallowed and not surfaced to the +caller. + +#### Inherited from + +[`RefetchOptions`](RefetchOptions.md).[`throwOnError`](RefetchOptions.md#throwonerror) diff --git a/docs/framework/lit/reference/interfaces/InvalidateQueryFilters.md b/docs/framework/lit/reference/interfaces/InvalidateQueryFilters.md new file mode 100644 index 00000000000..569e42a4e1b --- /dev/null +++ b/docs/framework/lit/reference/interfaces/InvalidateQueryFilters.md @@ -0,0 +1,145 @@ +--- +id: InvalidateQueryFilters +title: InvalidateQueryFilters +--- + +Defined in: [packages/query-core/src/types.ts:715](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L715) + +Filters used to select queries, for example in `queryClient.getQueriesData` or `queryClient.invalidateQueries`. +All provided filters must match; filters that are left unspecified are ignored. + +## Extends + +- [`QueryFilters`](QueryFilters.md)\<`TQueryKey`\> + +## Type Parameters + +### TQueryKey + +`TQueryKey` *extends* [`QueryKey`](../type-aliases/QueryKey.md) = [`QueryKey`](../type-aliases/QueryKey.md) + +## Properties + +### exact? + +```ts +optional exact: boolean; +``` + +Defined in: [packages/query-core/src/utils.ts:41](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L41) + +Match query key exactly + +#### Inherited from + +[`QueryFilters`](QueryFilters.md).[`exact`](QueryFilters.md#exact) + +*** + +### fetchStatus? + +```ts +optional fetchStatus: FetchStatus; +``` + +Defined in: [packages/query-core/src/utils.ts:57](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L57) + +Include queries matching their fetchStatus + +#### Inherited from + +[`QueryFilters`](QueryFilters.md).[`fetchStatus`](QueryFilters.md#fetchstatus) + +*** + +### predicate()? + +```ts +optional predicate: (query) => boolean; +``` + +Defined in: [packages/query-core/src/utils.ts:45](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L45) + +Include queries matching this predicate function + +#### Parameters + +##### query + +[`Query`](../classes/Query.md) + +#### Returns + +`boolean` + +#### Inherited from + +[`QueryFilters`](QueryFilters.md).[`predicate`](QueryFilters.md#predicate) + +*** + +### queryKey? + +```ts +optional queryKey: TQueryKey | TuplePrefixes; +``` + +Defined in: [packages/query-core/src/utils.ts:49](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L49) + +Include queries matching this query key + +#### Inherited from + +[`QueryFilters`](QueryFilters.md).[`queryKey`](QueryFilters.md#querykey) + +*** + +### refetchType? + +```ts +optional refetchType: QueryTypeFilter | "none"; +``` + +Defined in: [packages/query-core/src/types.ts:727](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L727) + +Controls which of the matched (now-invalidated) queries are refetched in the background. + +Defaults to `'active'`. +- `'active'`: only queries with at least one active observer are refetched. +- `'inactive'`: only queries with no active observer are refetched. +- `'all'`: every matched query is refetched, active or not. +- `'none'`: no query is refetched; matched queries are only marked as invalidated. + +*** + +### stale? + +```ts +optional stale: boolean; +``` + +Defined in: [packages/query-core/src/utils.ts:53](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L53) + +Include or exclude stale queries + +#### Inherited from + +[`QueryFilters`](QueryFilters.md).[`stale`](QueryFilters.md#stale) + +*** + +### type? + +```ts +optional type: QueryTypeFilter; +``` + +Defined in: [packages/query-core/src/utils.ts:37](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L37) + +Filter to active queries, inactive queries or all queries + +Defaults to `'all'`. + +#### Inherited from + +[`QueryFilters`](QueryFilters.md).[`type`](QueryFilters.md#type) diff --git a/docs/framework/lit/reference/interfaces/MutateOptions.md b/docs/framework/lit/reference/interfaces/MutateOptions.md new file mode 100644 index 00000000000..34e2a4d4d7e --- /dev/null +++ b/docs/framework/lit/reference/interfaces/MutateOptions.md @@ -0,0 +1,124 @@ +--- +id: MutateOptions +title: MutateOptions +--- + +Defined in: [packages/query-core/src/types.ts:1284](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1284) + +## Type Parameters + +### TData + +`TData` = `unknown` + +### TError + +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) + +### TVariables + +`TVariables` = `void` + +### TOnMutateResult + +`TOnMutateResult` = `unknown` + +## Properties + +### onError()? + +```ts +optional onError: (error, variables, onMutateResult, context) => void; +``` + +Defined in: [packages/query-core/src/types.ts:1296](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1296) + +#### Parameters + +##### error + +`TError` + +##### variables + +`TVariables` + +##### onMutateResult + +`TOnMutateResult` | `undefined` + +##### context + +[`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md) + +#### Returns + +`void` + +*** + +### onSettled()? + +```ts +optional onSettled: (data, error, variables, onMutateResult, context) => void; +``` + +Defined in: [packages/query-core/src/types.ts:1302](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1302) + +#### Parameters + +##### data + +`TData` | `undefined` + +##### error + +`TError` | `null` + +##### variables + +`TVariables` + +##### onMutateResult + +`TOnMutateResult` | `undefined` + +##### context + +[`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md) + +#### Returns + +`void` + +*** + +### onSuccess()? + +```ts +optional onSuccess: (data, variables, onMutateResult, context) => void; +``` + +Defined in: [packages/query-core/src/types.ts:1290](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1290) + +#### Parameters + +##### data + +`TData` + +##### variables + +`TVariables` + +##### onMutateResult + +`TOnMutateResult` | `undefined` + +##### context + +[`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md) + +#### Returns + +`void` diff --git a/docs/framework/lit/reference/interfaces/MutationCacheConfig.md b/docs/framework/lit/reference/interfaces/MutationCacheConfig.md new file mode 100644 index 00000000000..c38d2dc26f4 --- /dev/null +++ b/docs/framework/lit/reference/interfaces/MutationCacheConfig.md @@ -0,0 +1,161 @@ +--- +id: MutationCacheConfig +title: MutationCacheConfig +--- + +Defined in: [packages/query-core/src/mutationCache.ts:26](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationCache.ts#L26) + +Global callbacks that fire for every mutation handled by a `MutationCache`, regardless of which +component or observer triggered it. They differ from the `defaultOptions` provided to a +`QueryClient` in two ways: `defaultOptions` can be overridden by each mutation, while these +callbacks are always called, and `onMutate` here does not allow returning a result. + +If a callback returns a promise, it will be awaited before the mutation continues. + +## Properties + +### onError()? + +```ts +optional onError: (error, variables, onMutateResult, mutation, context) => unknown; +``` + +Defined in: [packages/query-core/src/mutationCache.ts:28](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationCache.ts#L28) + +Called when any mutation in the cache encounters an error. + +#### Parameters + +##### error + +`Error` + +##### variables + +`unknown` + +##### onMutateResult + +`unknown` + +##### mutation + +[`Mutation`](../classes/Mutation.md)\<`unknown`, `unknown`, `unknown`\> + +##### context + +[`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md) + +#### Returns + +`unknown` + +*** + +### onMutate()? + +```ts +optional onMutate: (variables, mutation, context) => unknown; +``` + +Defined in: [packages/query-core/src/mutationCache.ts:44](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationCache.ts#L44) + +Called before any mutation in the cache executes. + +#### Parameters + +##### variables + +`unknown` + +##### mutation + +[`Mutation`](../classes/Mutation.md)\<`unknown`, `unknown`, `unknown`\> + +##### context + +[`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md) + +#### Returns + +`unknown` + +*** + +### onSettled()? + +```ts +optional onSettled: (data, error, variables, onMutateResult, mutation, context) => unknown; +``` + +Defined in: [packages/query-core/src/mutationCache.ts:50](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationCache.ts#L50) + +Called when any mutation in the cache is settled, either successfully or with an error. + +#### Parameters + +##### data + +`unknown` + +##### error + +`Error` | `null` + +##### variables + +`unknown` + +##### onMutateResult + +`unknown` + +##### mutation + +[`Mutation`](../classes/Mutation.md)\<`unknown`, `unknown`, `unknown`\> + +##### context + +[`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md) + +#### Returns + +`unknown` + +*** + +### onSuccess()? + +```ts +optional onSuccess: (data, variables, onMutateResult, mutation, context) => unknown; +``` + +Defined in: [packages/query-core/src/mutationCache.ts:36](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationCache.ts#L36) + +Called when any mutation in the cache is successful. + +#### Parameters + +##### data + +`unknown` + +##### variables + +`unknown` + +##### onMutateResult + +`unknown` + +##### mutation + +[`Mutation`](../classes/Mutation.md)\<`unknown`, `unknown`, `unknown`\> + +##### context + +[`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md) + +#### Returns + +`unknown` diff --git a/docs/framework/lit/reference/interfaces/MutationFilters.md b/docs/framework/lit/reference/interfaces/MutationFilters.md new file mode 100644 index 00000000000..fbc0208e8e1 --- /dev/null +++ b/docs/framework/lit/reference/interfaces/MutationFilters.md @@ -0,0 +1,85 @@ +--- +id: MutationFilters +title: MutationFilters +--- + +Defined in: [packages/query-core/src/utils.ts:64](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L64) + +Filters used to select mutations, for example in `mutationCache.findAll` or `queryClient.isMutating`. +All provided filters must match; filters that are left unspecified are ignored. + +## Type Parameters + +### TData + +`TData` = `unknown` + +### TError + +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) + +### TVariables + +`TVariables` = `unknown` + +### TOnMutateResult + +`TOnMutateResult` = `unknown` + +## Properties + +### exact? + +```ts +optional exact: boolean; +``` + +Defined in: [packages/query-core/src/utils.ts:73](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L73) + +Match mutation key exactly + +*** + +### mutationKey? + +```ts +optional mutationKey: readonly unknown[]; +``` + +Defined in: [packages/query-core/src/utils.ts:83](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L83) + +Include mutations matching this mutation key + +*** + +### predicate()? + +```ts +optional predicate: (mutation) => boolean; +``` + +Defined in: [packages/query-core/src/utils.ts:77](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L77) + +Include mutations matching this predicate function + +#### Parameters + +##### mutation + +[`Mutation`](../classes/Mutation.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\> + +#### Returns + +`boolean` + +*** + +### status? + +```ts +optional status: MutationStatus; +``` + +Defined in: [packages/query-core/src/utils.ts:87](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L87) + +Filter by mutation status diff --git a/docs/framework/lit/reference/interfaces/MutationObserverBaseResult.md b/docs/framework/lit/reference/interfaces/MutationObserverBaseResult.md new file mode 100644 index 00000000000..340a38cc9cc --- /dev/null +++ b/docs/framework/lit/reference/interfaces/MutationObserverBaseResult.md @@ -0,0 +1,291 @@ +--- +id: MutationObserverBaseResult +title: MutationObserverBaseResult +--- + +Defined in: [packages/query-core/src/types.ts:1335](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1335) + +The raw state stored on a `Mutation` instance. This is the underlying state +that observer results (e.g. `MutationObserverResult`) are derived from. + +## Extends + +- [`MutationState`](MutationState.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\> + +## Extended by + +- [`MutationObserverIdleResult`](MutationObserverIdleResult.md) +- [`MutationObserverLoadingResult`](MutationObserverLoadingResult.md) +- [`MutationObserverErrorResult`](MutationObserverErrorResult.md) +- [`MutationObserverSuccessResult`](MutationObserverSuccessResult.md) + +## Type Parameters + +### TData + +`TData` = `unknown` + +### TError + +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) + +### TVariables + +`TVariables` = `void` + +### TOnMutateResult + +`TOnMutateResult` = `unknown` + +## Properties + +### context + +```ts +context: TOnMutateResult | undefined; +``` + +Defined in: [packages/query-core/src/mutation.ts:40](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L40) + +The value returned by `onMutate`, if defined. Passed to `onSuccess`, +`onError` and `onSettled` as the mutation's context. + +#### Inherited from + +[`MutationState`](MutationState.md).[`context`](MutationState.md#context) + +*** + +### data + +```ts +data: TData | undefined; +``` + +Defined in: [packages/query-core/src/types.ts:1344](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1344) + +The last successfully resolved data for the mutation. + +#### Overrides + +[`MutationState`](MutationState.md).[`data`](MutationState.md#data) + +*** + +### error + +```ts +error: TError | null; +``` + +Defined in: [packages/query-core/src/types.ts:1353](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1353) + +The error object for the mutation, if an error was encountered. +- Defaults to `null`. + +#### Overrides + +[`MutationState`](MutationState.md).[`error`](MutationState.md#error) + +*** + +### failureCount + +```ts +failureCount: number; +``` + +Defined in: [packages/query-core/src/mutation.ts:53](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L53) + +The number of times the mutation function has failed for the current attempt. + +#### Inherited from + +[`MutationState`](MutationState.md).[`failureCount`](MutationState.md#failurecount) + +*** + +### failureReason + +```ts +failureReason: TError | null; +``` + +Defined in: [packages/query-core/src/mutation.ts:57](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L57) + +The reason the current attempt failed, as reported by the retryer. + +#### Inherited from + +[`MutationState`](MutationState.md).[`failureReason`](MutationState.md#failurereason) + +*** + +### isError + +```ts +isError: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1358](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1358) + +A boolean variable derived from `status`. +- `true` if the last mutation attempt resulted in an error. + +*** + +### isIdle + +```ts +isIdle: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1363](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1363) + +A boolean variable derived from `status`. +- `true` if the mutation is in its initial state prior to executing. + +*** + +### isPaused + +```ts +isPaused: boolean; +``` + +Defined in: [packages/query-core/src/mutation.ts:62](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L62) + +Whether the mutation is currently paused (see network mode), or is +waiting for another mutation with the same `scope` to finish. + +#### Inherited from + +[`MutationState`](MutationState.md).[`isPaused`](MutationState.md#ispaused) + +*** + +### isPending + +```ts +isPending: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1368](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1368) + +A boolean variable derived from `status`. +- `true` if the mutation is currently executing. + +*** + +### isSuccess + +```ts +isSuccess: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1373](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1373) + +A boolean variable derived from `status`. +- `true` if the last mutation attempt was successful. + +*** + +### mutate + +```ts +mutate: MutateFunction; +``` + +Defined in: [packages/query-core/src/types.ts:1393](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1393) + +The mutation function you can call with variables to trigger the mutation and optionally hooks on additional callback options. + +#### Param + +The variables object to pass to the `mutationFn`. + +#### Param + +This function will fire when the mutation is successful and will be passed the mutation's result. + +#### Param + +This function will fire if the mutation encounters an error and will be passed the error. + +#### Param + +This function will fire when the mutation is either successfully fetched or encounters an error and be passed either the data or error. + +#### Remarks + +- If you make multiple requests, `onSuccess` will fire only after the latest call you've made. +- All the callback functions (`onSuccess`, `onError`, `onSettled`) are void functions, and the returned value will be ignored. + +*** + +### reset() + +```ts +reset: () => void; +``` + +Defined in: [packages/query-core/src/types.ts:1397](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1397) + +A function to clean the mutation internal state (i.e., it resets the mutation to its initial state). + +#### Returns + +`void` + +*** + +### status + +```ts +status: MutationStatus; +``` + +Defined in: [packages/query-core/src/types.ts:1382](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1382) + +The status of the mutation. +- Will be: + - `idle` initial status prior to the mutation function executing. + - `pending` if the mutation is currently executing. + - `error` if the last mutation attempt resulted in an error. + - `success` if the last mutation attempt was successful. + +#### Overrides + +[`MutationState`](MutationState.md).[`status`](MutationState.md#status) + +*** + +### submittedAt + +```ts +submittedAt: number; +``` + +Defined in: [packages/query-core/src/mutation.ts:74](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L74) + +The timestamp for when the mutation was submitted. + +#### Inherited from + +[`MutationState`](MutationState.md).[`submittedAt`](MutationState.md#submittedat) + +*** + +### variables + +```ts +variables: TVariables | undefined; +``` + +Defined in: [packages/query-core/src/types.ts:1348](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1348) + +The variables object passed to the `mutationFn`. + +#### Overrides + +[`MutationState`](MutationState.md).[`variables`](MutationState.md#variables) diff --git a/docs/framework/lit/reference/interfaces/MutationObserverErrorResult.md b/docs/framework/lit/reference/interfaces/MutationObserverErrorResult.md new file mode 100644 index 00000000000..72e459a2e0b --- /dev/null +++ b/docs/framework/lit/reference/interfaces/MutationObserverErrorResult.md @@ -0,0 +1,308 @@ +--- +id: MutationObserverErrorResult +title: MutationObserverErrorResult +--- + +Defined in: [packages/query-core/src/types.ts:1442](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1442) + +The raw state stored on a `Mutation` instance. This is the underlying state +that observer results (e.g. `MutationObserverResult`) are derived from. + +## Extends + +- [`MutationObserverBaseResult`](MutationObserverBaseResult.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\> + +## Type Parameters + +### TData + +`TData` = `unknown` + +### TError + +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) + +### TVariables + +`TVariables` = `void` + +### TOnMutateResult + +`TOnMutateResult` = `unknown` + +## Properties + +### context + +```ts +context: TOnMutateResult | undefined; +``` + +Defined in: [packages/query-core/src/mutation.ts:40](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L40) + +The value returned by `onMutate`, if defined. Passed to `onSuccess`, +`onError` and `onSettled` as the mutation's context. + +#### Inherited from + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`context`](MutationObserverBaseResult.md#context) + +*** + +### data + +```ts +data: undefined; +``` + +Defined in: [packages/query-core/src/types.ts:1453](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1453) + +The last successfully resolved data for the mutation. + +#### Overrides + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`data`](MutationObserverBaseResult.md#data) + +*** + +### error + +```ts +error: TError; +``` + +Defined in: [packages/query-core/src/types.ts:1454](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1454) + +The error object for the mutation, if an error was encountered. +- Defaults to `null`. + +#### Overrides + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`error`](MutationObserverBaseResult.md#error) + +*** + +### failureCount + +```ts +failureCount: number; +``` + +Defined in: [packages/query-core/src/mutation.ts:53](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L53) + +The number of times the mutation function has failed for the current attempt. + +#### Inherited from + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`failureCount`](MutationObserverBaseResult.md#failurecount) + +*** + +### failureReason + +```ts +failureReason: TError | null; +``` + +Defined in: [packages/query-core/src/mutation.ts:57](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L57) + +The reason the current attempt failed, as reported by the retryer. + +#### Inherited from + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`failureReason`](MutationObserverBaseResult.md#failurereason) + +*** + +### isError + +```ts +isError: true; +``` + +Defined in: [packages/query-core/src/types.ts:1456](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1456) + +A boolean variable derived from `status`. +- `true` if the last mutation attempt resulted in an error. + +#### Overrides + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isError`](MutationObserverBaseResult.md#iserror) + +*** + +### isIdle + +```ts +isIdle: false; +``` + +Defined in: [packages/query-core/src/types.ts:1457](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1457) + +A boolean variable derived from `status`. +- `true` if the mutation is in its initial state prior to executing. + +#### Overrides + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isIdle`](MutationObserverBaseResult.md#isidle) + +*** + +### isPaused + +```ts +isPaused: boolean; +``` + +Defined in: [packages/query-core/src/mutation.ts:62](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L62) + +Whether the mutation is currently paused (see network mode), or is +waiting for another mutation with the same `scope` to finish. + +#### Inherited from + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isPaused`](MutationObserverBaseResult.md#ispaused) + +*** + +### isPending + +```ts +isPending: false; +``` + +Defined in: [packages/query-core/src/types.ts:1458](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1458) + +A boolean variable derived from `status`. +- `true` if the mutation is currently executing. + +#### Overrides + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isPending`](MutationObserverBaseResult.md#ispending) + +*** + +### isSuccess + +```ts +isSuccess: false; +``` + +Defined in: [packages/query-core/src/types.ts:1459](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1459) + +A boolean variable derived from `status`. +- `true` if the last mutation attempt was successful. + +#### Overrides + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isSuccess`](MutationObserverBaseResult.md#issuccess) + +*** + +### mutate + +```ts +mutate: MutateFunction; +``` + +Defined in: [packages/query-core/src/types.ts:1393](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1393) + +The mutation function you can call with variables to trigger the mutation and optionally hooks on additional callback options. + +#### Param + +The variables object to pass to the `mutationFn`. + +#### Param + +This function will fire when the mutation is successful and will be passed the mutation's result. + +#### Param + +This function will fire if the mutation encounters an error and will be passed the error. + +#### Param + +This function will fire when the mutation is either successfully fetched or encounters an error and be passed either the data or error. + +#### Remarks + +- If you make multiple requests, `onSuccess` will fire only after the latest call you've made. +- All the callback functions (`onSuccess`, `onError`, `onSettled`) are void functions, and the returned value will be ignored. + +#### Inherited from + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`mutate`](MutationObserverBaseResult.md#mutate) + +*** + +### reset() + +```ts +reset: () => void; +``` + +Defined in: [packages/query-core/src/types.ts:1397](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1397) + +A function to clean the mutation internal state (i.e., it resets the mutation to its initial state). + +#### Returns + +`void` + +#### Inherited from + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`reset`](MutationObserverBaseResult.md#reset) + +*** + +### status + +```ts +status: "error"; +``` + +Defined in: [packages/query-core/src/types.ts:1460](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1460) + +The status of the mutation. +- Will be: + - `idle` initial status prior to the mutation function executing. + - `pending` if the mutation is currently executing. + - `error` if the last mutation attempt resulted in an error. + - `success` if the last mutation attempt was successful. + +#### Overrides + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`status`](MutationObserverBaseResult.md#status) + +*** + +### submittedAt + +```ts +submittedAt: number; +``` + +Defined in: [packages/query-core/src/mutation.ts:74](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L74) + +The timestamp for when the mutation was submitted. + +#### Inherited from + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`submittedAt`](MutationObserverBaseResult.md#submittedat) + +*** + +### variables + +```ts +variables: TVariables; +``` + +Defined in: [packages/query-core/src/types.ts:1455](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1455) + +The variables object passed to the `mutationFn`. + +#### Overrides + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`variables`](MutationObserverBaseResult.md#variables) diff --git a/docs/framework/lit/reference/interfaces/MutationObserverIdleResult.md b/docs/framework/lit/reference/interfaces/MutationObserverIdleResult.md new file mode 100644 index 00000000000..cd8d6eb3130 --- /dev/null +++ b/docs/framework/lit/reference/interfaces/MutationObserverIdleResult.md @@ -0,0 +1,308 @@ +--- +id: MutationObserverIdleResult +title: MutationObserverIdleResult +--- + +Defined in: [packages/query-core/src/types.ts:1400](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1400) + +The raw state stored on a `Mutation` instance. This is the underlying state +that observer results (e.g. `MutationObserverResult`) are derived from. + +## Extends + +- [`MutationObserverBaseResult`](MutationObserverBaseResult.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\> + +## Type Parameters + +### TData + +`TData` = `unknown` + +### TError + +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) + +### TVariables + +`TVariables` = `void` + +### TOnMutateResult + +`TOnMutateResult` = `unknown` + +## Properties + +### context + +```ts +context: TOnMutateResult | undefined; +``` + +Defined in: [packages/query-core/src/mutation.ts:40](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L40) + +The value returned by `onMutate`, if defined. Passed to `onSuccess`, +`onError` and `onSettled` as the mutation's context. + +#### Inherited from + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`context`](MutationObserverBaseResult.md#context) + +*** + +### data + +```ts +data: undefined; +``` + +Defined in: [packages/query-core/src/types.ts:1411](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1411) + +The last successfully resolved data for the mutation. + +#### Overrides + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`data`](MutationObserverBaseResult.md#data) + +*** + +### error + +```ts +error: null; +``` + +Defined in: [packages/query-core/src/types.ts:1413](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1413) + +The error object for the mutation, if an error was encountered. +- Defaults to `null`. + +#### Overrides + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`error`](MutationObserverBaseResult.md#error) + +*** + +### failureCount + +```ts +failureCount: number; +``` + +Defined in: [packages/query-core/src/mutation.ts:53](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L53) + +The number of times the mutation function has failed for the current attempt. + +#### Inherited from + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`failureCount`](MutationObserverBaseResult.md#failurecount) + +*** + +### failureReason + +```ts +failureReason: TError | null; +``` + +Defined in: [packages/query-core/src/mutation.ts:57](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L57) + +The reason the current attempt failed, as reported by the retryer. + +#### Inherited from + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`failureReason`](MutationObserverBaseResult.md#failurereason) + +*** + +### isError + +```ts +isError: false; +``` + +Defined in: [packages/query-core/src/types.ts:1414](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1414) + +A boolean variable derived from `status`. +- `true` if the last mutation attempt resulted in an error. + +#### Overrides + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isError`](MutationObserverBaseResult.md#iserror) + +*** + +### isIdle + +```ts +isIdle: true; +``` + +Defined in: [packages/query-core/src/types.ts:1415](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1415) + +A boolean variable derived from `status`. +- `true` if the mutation is in its initial state prior to executing. + +#### Overrides + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isIdle`](MutationObserverBaseResult.md#isidle) + +*** + +### isPaused + +```ts +isPaused: boolean; +``` + +Defined in: [packages/query-core/src/mutation.ts:62](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L62) + +Whether the mutation is currently paused (see network mode), or is +waiting for another mutation with the same `scope` to finish. + +#### Inherited from + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isPaused`](MutationObserverBaseResult.md#ispaused) + +*** + +### isPending + +```ts +isPending: false; +``` + +Defined in: [packages/query-core/src/types.ts:1416](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1416) + +A boolean variable derived from `status`. +- `true` if the mutation is currently executing. + +#### Overrides + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isPending`](MutationObserverBaseResult.md#ispending) + +*** + +### isSuccess + +```ts +isSuccess: false; +``` + +Defined in: [packages/query-core/src/types.ts:1417](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1417) + +A boolean variable derived from `status`. +- `true` if the last mutation attempt was successful. + +#### Overrides + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isSuccess`](MutationObserverBaseResult.md#issuccess) + +*** + +### mutate + +```ts +mutate: MutateFunction; +``` + +Defined in: [packages/query-core/src/types.ts:1393](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1393) + +The mutation function you can call with variables to trigger the mutation and optionally hooks on additional callback options. + +#### Param + +The variables object to pass to the `mutationFn`. + +#### Param + +This function will fire when the mutation is successful and will be passed the mutation's result. + +#### Param + +This function will fire if the mutation encounters an error and will be passed the error. + +#### Param + +This function will fire when the mutation is either successfully fetched or encounters an error and be passed either the data or error. + +#### Remarks + +- If you make multiple requests, `onSuccess` will fire only after the latest call you've made. +- All the callback functions (`onSuccess`, `onError`, `onSettled`) are void functions, and the returned value will be ignored. + +#### Inherited from + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`mutate`](MutationObserverBaseResult.md#mutate) + +*** + +### reset() + +```ts +reset: () => void; +``` + +Defined in: [packages/query-core/src/types.ts:1397](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1397) + +A function to clean the mutation internal state (i.e., it resets the mutation to its initial state). + +#### Returns + +`void` + +#### Inherited from + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`reset`](MutationObserverBaseResult.md#reset) + +*** + +### status + +```ts +status: "idle"; +``` + +Defined in: [packages/query-core/src/types.ts:1418](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1418) + +The status of the mutation. +- Will be: + - `idle` initial status prior to the mutation function executing. + - `pending` if the mutation is currently executing. + - `error` if the last mutation attempt resulted in an error. + - `success` if the last mutation attempt was successful. + +#### Overrides + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`status`](MutationObserverBaseResult.md#status) + +*** + +### submittedAt + +```ts +submittedAt: number; +``` + +Defined in: [packages/query-core/src/mutation.ts:74](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L74) + +The timestamp for when the mutation was submitted. + +#### Inherited from + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`submittedAt`](MutationObserverBaseResult.md#submittedat) + +*** + +### variables + +```ts +variables: undefined; +``` + +Defined in: [packages/query-core/src/types.ts:1412](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1412) + +The variables object passed to the `mutationFn`. + +#### Overrides + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`variables`](MutationObserverBaseResult.md#variables) diff --git a/docs/framework/lit/reference/interfaces/MutationObserverLoadingResult.md b/docs/framework/lit/reference/interfaces/MutationObserverLoadingResult.md new file mode 100644 index 00000000000..9b70a8558e7 --- /dev/null +++ b/docs/framework/lit/reference/interfaces/MutationObserverLoadingResult.md @@ -0,0 +1,308 @@ +--- +id: MutationObserverLoadingResult +title: MutationObserverLoadingResult +--- + +Defined in: [packages/query-core/src/types.ts:1421](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1421) + +The raw state stored on a `Mutation` instance. This is the underlying state +that observer results (e.g. `MutationObserverResult`) are derived from. + +## Extends + +- [`MutationObserverBaseResult`](MutationObserverBaseResult.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\> + +## Type Parameters + +### TData + +`TData` = `unknown` + +### TError + +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) + +### TVariables + +`TVariables` = `void` + +### TOnMutateResult + +`TOnMutateResult` = `unknown` + +## Properties + +### context + +```ts +context: TOnMutateResult | undefined; +``` + +Defined in: [packages/query-core/src/mutation.ts:40](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L40) + +The value returned by `onMutate`, if defined. Passed to `onSuccess`, +`onError` and `onSettled` as the mutation's context. + +#### Inherited from + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`context`](MutationObserverBaseResult.md#context) + +*** + +### data + +```ts +data: undefined; +``` + +Defined in: [packages/query-core/src/types.ts:1432](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1432) + +The last successfully resolved data for the mutation. + +#### Overrides + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`data`](MutationObserverBaseResult.md#data) + +*** + +### error + +```ts +error: null; +``` + +Defined in: [packages/query-core/src/types.ts:1434](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1434) + +The error object for the mutation, if an error was encountered. +- Defaults to `null`. + +#### Overrides + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`error`](MutationObserverBaseResult.md#error) + +*** + +### failureCount + +```ts +failureCount: number; +``` + +Defined in: [packages/query-core/src/mutation.ts:53](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L53) + +The number of times the mutation function has failed for the current attempt. + +#### Inherited from + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`failureCount`](MutationObserverBaseResult.md#failurecount) + +*** + +### failureReason + +```ts +failureReason: TError | null; +``` + +Defined in: [packages/query-core/src/mutation.ts:57](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L57) + +The reason the current attempt failed, as reported by the retryer. + +#### Inherited from + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`failureReason`](MutationObserverBaseResult.md#failurereason) + +*** + +### isError + +```ts +isError: false; +``` + +Defined in: [packages/query-core/src/types.ts:1435](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1435) + +A boolean variable derived from `status`. +- `true` if the last mutation attempt resulted in an error. + +#### Overrides + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isError`](MutationObserverBaseResult.md#iserror) + +*** + +### isIdle + +```ts +isIdle: false; +``` + +Defined in: [packages/query-core/src/types.ts:1436](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1436) + +A boolean variable derived from `status`. +- `true` if the mutation is in its initial state prior to executing. + +#### Overrides + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isIdle`](MutationObserverBaseResult.md#isidle) + +*** + +### isPaused + +```ts +isPaused: boolean; +``` + +Defined in: [packages/query-core/src/mutation.ts:62](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L62) + +Whether the mutation is currently paused (see network mode), or is +waiting for another mutation with the same `scope` to finish. + +#### Inherited from + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isPaused`](MutationObserverBaseResult.md#ispaused) + +*** + +### isPending + +```ts +isPending: true; +``` + +Defined in: [packages/query-core/src/types.ts:1437](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1437) + +A boolean variable derived from `status`. +- `true` if the mutation is currently executing. + +#### Overrides + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isPending`](MutationObserverBaseResult.md#ispending) + +*** + +### isSuccess + +```ts +isSuccess: false; +``` + +Defined in: [packages/query-core/src/types.ts:1438](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1438) + +A boolean variable derived from `status`. +- `true` if the last mutation attempt was successful. + +#### Overrides + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isSuccess`](MutationObserverBaseResult.md#issuccess) + +*** + +### mutate + +```ts +mutate: MutateFunction; +``` + +Defined in: [packages/query-core/src/types.ts:1393](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1393) + +The mutation function you can call with variables to trigger the mutation and optionally hooks on additional callback options. + +#### Param + +The variables object to pass to the `mutationFn`. + +#### Param + +This function will fire when the mutation is successful and will be passed the mutation's result. + +#### Param + +This function will fire if the mutation encounters an error and will be passed the error. + +#### Param + +This function will fire when the mutation is either successfully fetched or encounters an error and be passed either the data or error. + +#### Remarks + +- If you make multiple requests, `onSuccess` will fire only after the latest call you've made. +- All the callback functions (`onSuccess`, `onError`, `onSettled`) are void functions, and the returned value will be ignored. + +#### Inherited from + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`mutate`](MutationObserverBaseResult.md#mutate) + +*** + +### reset() + +```ts +reset: () => void; +``` + +Defined in: [packages/query-core/src/types.ts:1397](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1397) + +A function to clean the mutation internal state (i.e., it resets the mutation to its initial state). + +#### Returns + +`void` + +#### Inherited from + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`reset`](MutationObserverBaseResult.md#reset) + +*** + +### status + +```ts +status: "pending"; +``` + +Defined in: [packages/query-core/src/types.ts:1439](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1439) + +The status of the mutation. +- Will be: + - `idle` initial status prior to the mutation function executing. + - `pending` if the mutation is currently executing. + - `error` if the last mutation attempt resulted in an error. + - `success` if the last mutation attempt was successful. + +#### Overrides + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`status`](MutationObserverBaseResult.md#status) + +*** + +### submittedAt + +```ts +submittedAt: number; +``` + +Defined in: [packages/query-core/src/mutation.ts:74](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L74) + +The timestamp for when the mutation was submitted. + +#### Inherited from + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`submittedAt`](MutationObserverBaseResult.md#submittedat) + +*** + +### variables + +```ts +variables: TVariables; +``` + +Defined in: [packages/query-core/src/types.ts:1433](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1433) + +The variables object passed to the `mutationFn`. + +#### Overrides + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`variables`](MutationObserverBaseResult.md#variables) diff --git a/docs/framework/lit/reference/interfaces/MutationObserverOptions.md b/docs/framework/lit/reference/interfaces/MutationObserverOptions.md new file mode 100644 index 00000000000..5bab2840a6d --- /dev/null +++ b/docs/framework/lit/reference/interfaces/MutationObserverOptions.md @@ -0,0 +1,322 @@ +--- +id: MutationObserverOptions +title: MutationObserverOptions +--- + +Defined in: [packages/query-core/src/types.ts:1267](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1267) + +## Extends + +- [`MutationOptions`](MutationOptions.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\> + +## Type Parameters + +### TData + +`TData` = `unknown` + +### TError + +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) + +### TVariables + +`TVariables` = `void` + +### TOnMutateResult + +`TOnMutateResult` = `unknown` + +## Properties + +### gcTime? + +```ts +optional gcTime: number; +``` + +Defined in: [packages/query-core/src/types.ts:1260](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1260) + +The time in milliseconds that an unused/inactive mutation remains in memory before it is +garbage collected. + +Defaults to `5 * 60 * 1000` (5 minutes), or `Infinity` during SSR. + +#### Inherited from + +[`MutationOptions`](MutationOptions.md).[`gcTime`](MutationOptions.md#gctime) + +*** + +### meta? + +```ts +optional meta: Record; +``` + +Defined in: [packages/query-core/src/types.ts:1263](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1263) + +#### Inherited from + +[`MutationOptions`](MutationOptions.md).[`meta`](MutationOptions.md#meta) + +*** + +### mutationFn? + +```ts +optional mutationFn: MutationFunction; +``` + +Defined in: [packages/query-core/src/types.ts:1206](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1206) + +#### Inherited from + +[`MutationOptions`](MutationOptions.md).[`mutationFn`](MutationOptions.md#mutationfn) + +*** + +### mutationKey? + +```ts +optional mutationKey: readonly unknown[]; +``` + +Defined in: [packages/query-core/src/types.ts:1207](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1207) + +#### Inherited from + +[`MutationOptions`](MutationOptions.md).[`mutationKey`](MutationOptions.md#mutationkey) + +*** + +### networkMode? + +```ts +optional networkMode: NetworkMode; +``` + +Defined in: [packages/query-core/src/types.ts:1253](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1253) + +Controls whether a mutation is allowed to run based on the current network connectivity. + +Defaults to `'online'`. + +#### See + +[Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. + +#### Inherited from + +[`MutationOptions`](MutationOptions.md).[`networkMode`](MutationOptions.md#networkmode) + +*** + +### onError()? + +```ts +optional onError: (error, variables, onMutateResult, context) => unknown; +``` + +Defined in: [packages/query-core/src/types.ts:1218](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1218) + +#### Parameters + +##### error + +`TError` + +##### variables + +`TVariables` + +##### onMutateResult + +`TOnMutateResult` | `undefined` + +##### context + +[`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md) + +#### Returns + +`unknown` + +#### Inherited from + +[`MutationOptions`](MutationOptions.md).[`onError`](MutationOptions.md#onerror) + +*** + +### onMutate()? + +```ts +optional onMutate: (variables, context) => TOnMutateResult | Promise; +``` + +Defined in: [packages/query-core/src/types.ts:1208](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1208) + +#### Parameters + +##### variables + +`TVariables` + +##### context + +[`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md) + +#### Returns + +`TOnMutateResult` \| `Promise`\<`TOnMutateResult`\> + +#### Inherited from + +[`MutationOptions`](MutationOptions.md).[`onMutate`](MutationOptions.md#onmutate) + +*** + +### onSettled()? + +```ts +optional onSettled: (data, error, variables, onMutateResult, context) => unknown; +``` + +Defined in: [packages/query-core/src/types.ts:1224](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1224) + +#### Parameters + +##### data + +`TData` | `undefined` + +##### error + +`TError` | `null` + +##### variables + +`TVariables` + +##### onMutateResult + +`TOnMutateResult` | `undefined` + +##### context + +[`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md) + +#### Returns + +`unknown` + +#### Inherited from + +[`MutationOptions`](MutationOptions.md).[`onSettled`](MutationOptions.md#onsettled) + +*** + +### onSuccess()? + +```ts +optional onSuccess: (data, variables, onMutateResult, context) => unknown; +``` + +Defined in: [packages/query-core/src/types.ts:1212](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1212) + +#### Parameters + +##### data + +`TData` + +##### variables + +`TVariables` + +##### onMutateResult + +`TOnMutateResult` + +##### context + +[`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md) + +#### Returns + +`unknown` + +#### Inherited from + +[`MutationOptions`](MutationOptions.md).[`onSuccess`](MutationOptions.md#onsuccess) + +*** + +### retry? + +```ts +optional retry: RetryValue; +``` + +Defined in: [packages/query-core/src/types.ts:1239](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1239) + +If `false`, failed mutations will not retry by default. +If `true`, failed mutations will retry infinitely. +If set to an integer number, e.g. 3, failed mutations will retry until the failed mutation count meets that number. +If set to a function `(failureCount, error) => boolean` failed mutations will retry until the function returns false. + +Defaults to `0`. + +#### Inherited from + +[`MutationOptions`](MutationOptions.md).[`retry`](MutationOptions.md#retry) + +*** + +### retryDelay? + +```ts +optional retryDelay: RetryDelayValue; +``` + +Defined in: [packages/query-core/src/types.ts:1246](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1246) + +This function receives a `retryAttempt` integer and the actual Error and returns the delay to apply before the +next attempt in milliseconds. + +Defaults to a function that applies exponential backoff, capped at 30 seconds. + +#### Inherited from + +[`MutationOptions`](MutationOptions.md).[`retryDelay`](MutationOptions.md#retrydelay) + +*** + +### scope? + +```ts +optional scope: MutationScope; +``` + +Defined in: [packages/query-core/src/types.ts:1264](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1264) + +#### Inherited from + +[`MutationOptions`](MutationOptions.md).[`scope`](MutationOptions.md#scope) + +*** + +### throwOnError? + +```ts +optional throwOnError: boolean | (error) => boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1281](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1281) + +Whether errors should be thrown instead of setting the `error` property. +If set to `true`, all errors will be thrown to the nearest error boundary. +If set to a function, it will be passed the error and should return a boolean indicating whether to throw the +error (`true`) or return it as state (`false`). + +Defaults to `false`. diff --git a/docs/framework/lit/reference/interfaces/MutationObserverSuccessResult.md b/docs/framework/lit/reference/interfaces/MutationObserverSuccessResult.md new file mode 100644 index 00000000000..e2e03642f82 --- /dev/null +++ b/docs/framework/lit/reference/interfaces/MutationObserverSuccessResult.md @@ -0,0 +1,308 @@ +--- +id: MutationObserverSuccessResult +title: MutationObserverSuccessResult +--- + +Defined in: [packages/query-core/src/types.ts:1463](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1463) + +The raw state stored on a `Mutation` instance. This is the underlying state +that observer results (e.g. `MutationObserverResult`) are derived from. + +## Extends + +- [`MutationObserverBaseResult`](MutationObserverBaseResult.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\> + +## Type Parameters + +### TData + +`TData` = `unknown` + +### TError + +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) + +### TVariables + +`TVariables` = `void` + +### TOnMutateResult + +`TOnMutateResult` = `unknown` + +## Properties + +### context + +```ts +context: TOnMutateResult | undefined; +``` + +Defined in: [packages/query-core/src/mutation.ts:40](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L40) + +The value returned by `onMutate`, if defined. Passed to `onSuccess`, +`onError` and `onSettled` as the mutation's context. + +#### Inherited from + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`context`](MutationObserverBaseResult.md#context) + +*** + +### data + +```ts +data: TData; +``` + +Defined in: [packages/query-core/src/types.ts:1474](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1474) + +The last successfully resolved data for the mutation. + +#### Overrides + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`data`](MutationObserverBaseResult.md#data) + +*** + +### error + +```ts +error: null; +``` + +Defined in: [packages/query-core/src/types.ts:1475](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1475) + +The error object for the mutation, if an error was encountered. +- Defaults to `null`. + +#### Overrides + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`error`](MutationObserverBaseResult.md#error) + +*** + +### failureCount + +```ts +failureCount: number; +``` + +Defined in: [packages/query-core/src/mutation.ts:53](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L53) + +The number of times the mutation function has failed for the current attempt. + +#### Inherited from + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`failureCount`](MutationObserverBaseResult.md#failurecount) + +*** + +### failureReason + +```ts +failureReason: TError | null; +``` + +Defined in: [packages/query-core/src/mutation.ts:57](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L57) + +The reason the current attempt failed, as reported by the retryer. + +#### Inherited from + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`failureReason`](MutationObserverBaseResult.md#failurereason) + +*** + +### isError + +```ts +isError: false; +``` + +Defined in: [packages/query-core/src/types.ts:1477](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1477) + +A boolean variable derived from `status`. +- `true` if the last mutation attempt resulted in an error. + +#### Overrides + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isError`](MutationObserverBaseResult.md#iserror) + +*** + +### isIdle + +```ts +isIdle: false; +``` + +Defined in: [packages/query-core/src/types.ts:1478](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1478) + +A boolean variable derived from `status`. +- `true` if the mutation is in its initial state prior to executing. + +#### Overrides + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isIdle`](MutationObserverBaseResult.md#isidle) + +*** + +### isPaused + +```ts +isPaused: boolean; +``` + +Defined in: [packages/query-core/src/mutation.ts:62](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L62) + +Whether the mutation is currently paused (see network mode), or is +waiting for another mutation with the same `scope` to finish. + +#### Inherited from + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isPaused`](MutationObserverBaseResult.md#ispaused) + +*** + +### isPending + +```ts +isPending: false; +``` + +Defined in: [packages/query-core/src/types.ts:1479](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1479) + +A boolean variable derived from `status`. +- `true` if the mutation is currently executing. + +#### Overrides + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isPending`](MutationObserverBaseResult.md#ispending) + +*** + +### isSuccess + +```ts +isSuccess: true; +``` + +Defined in: [packages/query-core/src/types.ts:1480](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1480) + +A boolean variable derived from `status`. +- `true` if the last mutation attempt was successful. + +#### Overrides + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isSuccess`](MutationObserverBaseResult.md#issuccess) + +*** + +### mutate + +```ts +mutate: MutateFunction; +``` + +Defined in: [packages/query-core/src/types.ts:1393](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1393) + +The mutation function you can call with variables to trigger the mutation and optionally hooks on additional callback options. + +#### Param + +The variables object to pass to the `mutationFn`. + +#### Param + +This function will fire when the mutation is successful and will be passed the mutation's result. + +#### Param + +This function will fire if the mutation encounters an error and will be passed the error. + +#### Param + +This function will fire when the mutation is either successfully fetched or encounters an error and be passed either the data or error. + +#### Remarks + +- If you make multiple requests, `onSuccess` will fire only after the latest call you've made. +- All the callback functions (`onSuccess`, `onError`, `onSettled`) are void functions, and the returned value will be ignored. + +#### Inherited from + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`mutate`](MutationObserverBaseResult.md#mutate) + +*** + +### reset() + +```ts +reset: () => void; +``` + +Defined in: [packages/query-core/src/types.ts:1397](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1397) + +A function to clean the mutation internal state (i.e., it resets the mutation to its initial state). + +#### Returns + +`void` + +#### Inherited from + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`reset`](MutationObserverBaseResult.md#reset) + +*** + +### status + +```ts +status: "success"; +``` + +Defined in: [packages/query-core/src/types.ts:1481](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1481) + +The status of the mutation. +- Will be: + - `idle` initial status prior to the mutation function executing. + - `pending` if the mutation is currently executing. + - `error` if the last mutation attempt resulted in an error. + - `success` if the last mutation attempt was successful. + +#### Overrides + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`status`](MutationObserverBaseResult.md#status) + +*** + +### submittedAt + +```ts +submittedAt: number; +``` + +Defined in: [packages/query-core/src/mutation.ts:74](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L74) + +The timestamp for when the mutation was submitted. + +#### Inherited from + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`submittedAt`](MutationObserverBaseResult.md#submittedat) + +*** + +### variables + +```ts +variables: TVariables; +``` + +Defined in: [packages/query-core/src/types.ts:1476](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1476) + +The variables object passed to the `mutationFn`. + +#### Overrides + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`variables`](MutationObserverBaseResult.md#variables) diff --git a/docs/framework/lit/reference/interfaces/MutationOptions.md b/docs/framework/lit/reference/interfaces/MutationOptions.md new file mode 100644 index 00000000000..5aabeeb0ca4 --- /dev/null +++ b/docs/framework/lit/reference/interfaces/MutationOptions.md @@ -0,0 +1,257 @@ +--- +id: MutationOptions +title: MutationOptions +--- + +Defined in: [packages/query-core/src/types.ts:1200](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1200) + +## Extended by + +- [`MutationObserverOptions`](MutationObserverOptions.md) + +## Type Parameters + +### TData + +`TData` = `unknown` + +### TError + +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) + +### TVariables + +`TVariables` = `void` + +### TOnMutateResult + +`TOnMutateResult` = `unknown` + +## Properties + +### gcTime? + +```ts +optional gcTime: number; +``` + +Defined in: [packages/query-core/src/types.ts:1260](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1260) + +The time in milliseconds that an unused/inactive mutation remains in memory before it is +garbage collected. + +Defaults to `5 * 60 * 1000` (5 minutes), or `Infinity` during SSR. + +*** + +### meta? + +```ts +optional meta: Record; +``` + +Defined in: [packages/query-core/src/types.ts:1263](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1263) + +*** + +### mutationFn? + +```ts +optional mutationFn: MutationFunction; +``` + +Defined in: [packages/query-core/src/types.ts:1206](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1206) + +*** + +### mutationKey? + +```ts +optional mutationKey: readonly unknown[]; +``` + +Defined in: [packages/query-core/src/types.ts:1207](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1207) + +*** + +### networkMode? + +```ts +optional networkMode: NetworkMode; +``` + +Defined in: [packages/query-core/src/types.ts:1253](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1253) + +Controls whether a mutation is allowed to run based on the current network connectivity. + +Defaults to `'online'`. + +#### See + +[Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. + +*** + +### onError()? + +```ts +optional onError: (error, variables, onMutateResult, context) => unknown; +``` + +Defined in: [packages/query-core/src/types.ts:1218](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1218) + +#### Parameters + +##### error + +`TError` + +##### variables + +`TVariables` + +##### onMutateResult + +`TOnMutateResult` | `undefined` + +##### context + +[`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md) + +#### Returns + +`unknown` + +*** + +### onMutate()? + +```ts +optional onMutate: (variables, context) => TOnMutateResult | Promise; +``` + +Defined in: [packages/query-core/src/types.ts:1208](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1208) + +#### Parameters + +##### variables + +`TVariables` + +##### context + +[`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md) + +#### Returns + +`TOnMutateResult` \| `Promise`\<`TOnMutateResult`\> + +*** + +### onSettled()? + +```ts +optional onSettled: (data, error, variables, onMutateResult, context) => unknown; +``` + +Defined in: [packages/query-core/src/types.ts:1224](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1224) + +#### Parameters + +##### data + +`TData` | `undefined` + +##### error + +`TError` | `null` + +##### variables + +`TVariables` + +##### onMutateResult + +`TOnMutateResult` | `undefined` + +##### context + +[`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md) + +#### Returns + +`unknown` + +*** + +### onSuccess()? + +```ts +optional onSuccess: (data, variables, onMutateResult, context) => unknown; +``` + +Defined in: [packages/query-core/src/types.ts:1212](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1212) + +#### Parameters + +##### data + +`TData` + +##### variables + +`TVariables` + +##### onMutateResult + +`TOnMutateResult` + +##### context + +[`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md) + +#### Returns + +`unknown` + +*** + +### retry? + +```ts +optional retry: RetryValue; +``` + +Defined in: [packages/query-core/src/types.ts:1239](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1239) + +If `false`, failed mutations will not retry by default. +If `true`, failed mutations will retry infinitely. +If set to an integer number, e.g. 3, failed mutations will retry until the failed mutation count meets that number. +If set to a function `(failureCount, error) => boolean` failed mutations will retry until the function returns false. + +Defaults to `0`. + +*** + +### retryDelay? + +```ts +optional retryDelay: RetryDelayValue; +``` + +Defined in: [packages/query-core/src/types.ts:1246](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1246) + +This function receives a `retryAttempt` integer and the actual Error and returns the delay to apply before the +next attempt in milliseconds. + +Defaults to a function that applies exponential backoff, capped at 30 seconds. + +*** + +### scope? + +```ts +optional scope: MutationScope; +``` + +Defined in: [packages/query-core/src/types.ts:1264](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1264) diff --git a/docs/framework/lit/reference/interfaces/MutationState.md b/docs/framework/lit/reference/interfaces/MutationState.md new file mode 100644 index 00000000000..bec050ec1d3 --- /dev/null +++ b/docs/framework/lit/reference/interfaces/MutationState.md @@ -0,0 +1,142 @@ +--- +id: MutationState +title: MutationState +--- + +Defined in: [packages/query-core/src/mutation.ts:30](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L30) + +The raw state stored on a `Mutation` instance. This is the underlying state +that observer results (e.g. `MutationObserverResult`) are derived from. + +## Extended by + +- [`MutationObserverBaseResult`](MutationObserverBaseResult.md) + +## Type Parameters + +### TData + +`TData` = `unknown` + +### TError + +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) + +### TVariables + +`TVariables` = `unknown` + +### TOnMutateResult + +`TOnMutateResult` = `unknown` + +## Properties + +### context + +```ts +context: TOnMutateResult | undefined; +``` + +Defined in: [packages/query-core/src/mutation.ts:40](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L40) + +The value returned by `onMutate`, if defined. Passed to `onSuccess`, +`onError` and `onSettled` as the mutation's context. + +*** + +### data + +```ts +data: TData | undefined; +``` + +Defined in: [packages/query-core/src/mutation.ts:44](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L44) + +The last successfully resolved data for the mutation. + +*** + +### error + +```ts +error: TError | null; +``` + +Defined in: [packages/query-core/src/mutation.ts:49](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L49) + +The error object for the mutation, if the last attempt resulted in an error. +- Defaults to `null`. + +*** + +### failureCount + +```ts +failureCount: number; +``` + +Defined in: [packages/query-core/src/mutation.ts:53](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L53) + +The number of times the mutation function has failed for the current attempt. + +*** + +### failureReason + +```ts +failureReason: TError | null; +``` + +Defined in: [packages/query-core/src/mutation.ts:57](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L57) + +The reason the current attempt failed, as reported by the retryer. + +*** + +### isPaused + +```ts +isPaused: boolean; +``` + +Defined in: [packages/query-core/src/mutation.ts:62](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L62) + +Whether the mutation is currently paused (see network mode), or is +waiting for another mutation with the same `scope` to finish. + +*** + +### status + +```ts +status: MutationStatus; +``` + +Defined in: [packages/query-core/src/mutation.ts:66](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L66) + +The status of the mutation. + +*** + +### submittedAt + +```ts +submittedAt: number; +``` + +Defined in: [packages/query-core/src/mutation.ts:74](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L74) + +The timestamp for when the mutation was submitted. + +*** + +### variables + +```ts +variables: TVariables | undefined; +``` + +Defined in: [packages/query-core/src/mutation.ts:70](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L70) + +The variables the mutation was last called with. diff --git a/docs/framework/lit/reference/interfaces/NotifyEvent.md b/docs/framework/lit/reference/interfaces/NotifyEvent.md new file mode 100644 index 00000000000..4f5b023f49a --- /dev/null +++ b/docs/framework/lit/reference/interfaces/NotifyEvent.md @@ -0,0 +1,16 @@ +--- +id: NotifyEvent +title: NotifyEvent +--- + +Defined in: [packages/query-core/src/types.ts:1539](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1539) + +## Properties + +### type + +```ts +type: NotifyEventType; +``` + +Defined in: [packages/query-core/src/types.ts:1540](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1540) diff --git a/docs/framework/lit/reference/interfaces/OnlineManager.md b/docs/framework/lit/reference/interfaces/OnlineManager.md new file mode 100644 index 00000000000..1a936c91ed9 --- /dev/null +++ b/docs/framework/lit/reference/interfaces/OnlineManager.md @@ -0,0 +1,214 @@ +--- +id: OnlineManager +title: OnlineManager +--- + +Defined in: [packages/query-core/src/onlineManager.ts:15](https://github.com/TanStack/query/blob/main/packages/query-core/src/onlineManager.ts#L15) + +The `OnlineManager` manages the online state within TanStack Query. It can +be used to change the default event listeners or to manually change the +online state. + +By default, the `onlineManager` assumes an active network connection, and +listens to the `online` and `offline` events on the `window` object to +detect changes. + +## Extends + +- `Subscribable`\<`Listener`\> + +## Properties + +### listeners + +```ts +protected listeners: Set; +``` + +Defined in: [packages/query-core/src/subscribable.ts:2](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L2) + +#### Inherited from + +```ts +Subscribable.listeners +``` + +## Methods + +### hasListeners() + +```ts +hasListeners(): boolean; +``` + +Defined in: [packages/query-core/src/subscribable.ts:19](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L19) + +#### Returns + +`boolean` + +#### Inherited from + +```ts +Subscribable.hasListeners +``` + +*** + +### isOnline() + +```ts +isOnline(): boolean; +``` + +Defined in: [packages/query-core/src/onlineManager.ts:109](https://github.com/TanStack/query/blob/main/packages/query-core/src/onlineManager.ts#L109) + +`isOnline` can be used to get the current online state. + +#### Returns + +`boolean` + +*** + +### onSubscribe() + +```ts +protected onSubscribe(): void; +``` + +Defined in: [packages/query-core/src/onlineManager.ts:44](https://github.com/TanStack/query/blob/main/packages/query-core/src/onlineManager.ts#L44) + +#### Returns + +`void` + +#### Overrides + +```ts +Subscribable.onSubscribe +``` + +*** + +### onUnsubscribe() + +```ts +protected onUnsubscribe(): void; +``` + +Defined in: [packages/query-core/src/onlineManager.ts:50](https://github.com/TanStack/query/blob/main/packages/query-core/src/onlineManager.ts#L50) + +#### Returns + +`void` + +#### Overrides + +```ts +Subscribable.onUnsubscribe +``` + +*** + +### setEventListener() + +```ts +setEventListener(setup): void; +``` + +Defined in: [packages/query-core/src/onlineManager.ts:75](https://github.com/TanStack/query/blob/main/packages/query-core/src/onlineManager.ts#L75) + +`setEventListener` can be used to set a custom event listener that will +be used to determine the online state. The provided `setup` function +receives a `setOnline` callback that should be called with a `boolean` +whenever the online state changes. + +#### Parameters + +##### setup + +`SetupFn` + +#### Returns + +`void` + +#### Example + +```ts +import NetInfo from '@react-native-community/netinfo' +import { onlineManager } from '@tanstack/query-core' + +onlineManager.setEventListener((setOnline) => { + return NetInfo.addEventListener((state) => { + setOnline(!!state.isConnected) + }) +}) +``` + +*** + +### setOnline() + +```ts +setOnline(online): void; +``` + +Defined in: [packages/query-core/src/onlineManager.ts:95](https://github.com/TanStack/query/blob/main/packages/query-core/src/onlineManager.ts#L95) + +`setOnline` can be used to manually set the online state. + +#### Parameters + +##### online + +`boolean` + +#### Returns + +`void` + +#### Example + +```ts +import { onlineManager } from '@tanstack/query-core' + +// Set to online +onlineManager.setOnline(true) + +// Set to offline +onlineManager.setOnline(false) +``` + +*** + +### subscribe() + +```ts +subscribe(listener): () => void; +``` + +Defined in: [packages/query-core/src/subscribable.ts:8](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L8) + +#### Parameters + +##### listener + +`Listener` + +#### Returns + +```ts +(): void; +``` + +##### Returns + +`void` + +#### Inherited from + +```ts +Subscribable.subscribe +``` diff --git a/docs/framework/lit/reference/interfaces/QueriesObserverOptions.md b/docs/framework/lit/reference/interfaces/QueriesObserverOptions.md new file mode 100644 index 00000000000..68e7913885d --- /dev/null +++ b/docs/framework/lit/reference/interfaces/QueriesObserverOptions.md @@ -0,0 +1,29 @@ +--- +id: QueriesObserverOptions +title: QueriesObserverOptions +--- + +Defined in: [packages/query-core/src/queriesObserver.ts:23](https://github.com/TanStack/query/blob/main/packages/query-core/src/queriesObserver.ts#L23) + +## Type Parameters + +### TCombinedResult + +`TCombinedResult` = [`QueryObserverResult`](../type-aliases/QueryObserverResult.md)[] + +## Properties + +### combine? + +```ts +optional combine: CombineFn; +``` + +Defined in: [packages/query-core/src/queriesObserver.ts:34](https://github.com/TanStack/query/blob/main/packages/query-core/src/queriesObserver.ts#L34) + +A function that combines the array of `QueryObserverResult`s (one per +observed query) into a single value. The combined value is memoized and +only recomputed when one of the underlying results, the query hashes, or +the `combine` function itself changes. + +Defaults to returning the array of `QueryObserverResult`s unchanged. diff --git a/docs/framework/lit/reference/interfaces/QueryCacheConfig.md b/docs/framework/lit/reference/interfaces/QueryCacheConfig.md new file mode 100644 index 00000000000..3c6aebe496f --- /dev/null +++ b/docs/framework/lit/reference/interfaces/QueryCacheConfig.md @@ -0,0 +1,93 @@ +--- +id: QueryCacheConfig +title: QueryCacheConfig +--- + +Defined in: [packages/query-core/src/queryCache.ts:25](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryCache.ts#L25) + +Global callbacks that fire for every query handled by a `QueryCache`, regardless of which +component or observer triggered it. Unlike `QueryClient`'s `defaultOptions`, which a query can +override, these callbacks are always called. Unlike `MutationCacheConfig`'s callbacks, these +are fire-and-forget: their return value is not awaited before the query settles. + +## Properties + +### onError()? + +```ts +optional onError: (error, query) => void; +``` + +Defined in: [packages/query-core/src/queryCache.ts:27](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryCache.ts#L27) + +Called when any query in the cache encounters an error. + +#### Parameters + +##### error + +`Error` + +##### query + +[`Query`](../classes/Query.md)\<`unknown`, `unknown`, `unknown`\> + +#### Returns + +`void` + +*** + +### onSettled()? + +```ts +optional onSettled: (data, error, query) => void; +``` + +Defined in: [packages/query-core/src/queryCache.ts:34](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryCache.ts#L34) + +Called when any query in the cache is settled, either successfully or with an error. + +#### Parameters + +##### data + +`unknown` + +##### error + +`Error` | `null` + +##### query + +[`Query`](../classes/Query.md)\<`unknown`, `unknown`, `unknown`\> + +#### Returns + +`void` + +*** + +### onSuccess()? + +```ts +optional onSuccess: (data, query) => void; +``` + +Defined in: [packages/query-core/src/queryCache.ts:32](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryCache.ts#L32) + +Called when any query in the cache is successful. + +#### Parameters + +##### data + +`unknown` + +##### query + +[`Query`](../classes/Query.md)\<`unknown`, `unknown`, `unknown`\> + +#### Returns + +`void` diff --git a/docs/framework/lit/reference/interfaces/QueryClientConfig.md b/docs/framework/lit/reference/interfaces/QueryClientConfig.md new file mode 100644 index 00000000000..070e249491f --- /dev/null +++ b/docs/framework/lit/reference/interfaces/QueryClientConfig.md @@ -0,0 +1,43 @@ +--- +id: QueryClientConfig +title: QueryClientConfig +--- + +Defined in: [packages/query-core/src/types.ts:1495](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1495) + +## Properties + +### defaultOptions? + +```ts +optional defaultOptions: DefaultOptions; +``` + +Defined in: [packages/query-core/src/types.ts:1504](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1504) + +Default options for all queries and mutations created through this client. + +*** + +### mutationCache? + +```ts +optional mutationCache: MutationCache; +``` + +Defined in: [packages/query-core/src/types.ts:1502](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1502) + +The mutation cache this client is connected to. A new `MutationCache` is created if not +provided. + +*** + +### queryCache? + +```ts +optional queryCache: QueryCache; +``` + +Defined in: [packages/query-core/src/types.ts:1497](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1497) + +The query cache this client is connected to. A new `QueryCache` is created if not provided. diff --git a/docs/framework/lit/reference/interfaces/QueryExecuteOptions.md b/docs/framework/lit/reference/interfaces/QueryExecuteOptions.md new file mode 100644 index 00000000000..0b20b761718 --- /dev/null +++ b/docs/framework/lit/reference/interfaces/QueryExecuteOptions.md @@ -0,0 +1,382 @@ +--- +id: QueryExecuteOptions +title: QueryExecuteOptions +--- + +Defined in: [packages/query-core/src/types.ts:574](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L574) + +## Extends + +- [`WithRequired`](../type-aliases/WithRequired.md)\<[`QueryOptions`](QueryOptions.md)\<`TQueryFnData`, `TError`, `TQueryData`, `TQueryKey`, `TPageParam`\>, `"queryKey"`\> + +## Type Parameters + +### TQueryFnData + +`TQueryFnData` = `unknown` + +### TError + +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) + +### TData + +`TData` = `TQueryFnData` + +### TQueryData + +`TQueryData` = `TQueryFnData` + +### TQueryKey + +`TQueryKey` *extends* [`QueryKey`](../type-aliases/QueryKey.md) = [`QueryKey`](../type-aliases/QueryKey.md) + +### TPageParam + +`TPageParam` = `never` + +## Properties + +### gcTime? + +```ts +optional gcTime: number; +``` + +Defined in: [packages/query-core/src/types.ts:277](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L277) + +The time in milliseconds that unused/inactive cache data remains in memory. +When a query's cache becomes unused or inactive, that cache data will be garbage collected after this duration. +When different garbage collection times are specified, the longest one will be used. +Setting it to `Infinity` will disable garbage collection. + +Defaults to `5 * 60 * 1000` (5 minutes), or `Infinity` during SSR. + +Note: the maximum allowed time is about 24 days, imposed by `setTimeout`'s 32-bit signed integer delay — see +`timeoutManager.setTimeoutProvider` for a workaround. + +#### Inherited from + +```ts +WithRequired.gcTime +``` + +*** + +### initialData? + +```ts +optional initialData: + | TQueryData +| InitialDataFunction; +``` + +Defined in: [packages/query-core/src/types.ts:317](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L317) + +If set, this value will be used as the initial data for the query cache (as long as the query hasn't been +created or cached yet). +If set to a function, the function will be called **once** during the shared/root query initialization, and be +expected to synchronously return the initial data. +Initial data is considered stale by default unless a `staleTime` has been set. +`initialData` **is persisted** to the cache. + +#### Inherited from + +```ts +WithRequired.initialData +``` + +*** + +### initialDataUpdatedAt? + +```ts +optional initialDataUpdatedAt: number | () => number | undefined; +``` + +Defined in: [packages/query-core/src/types.ts:321](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L321) + +If set, this value will be used as the time (in milliseconds) of when the `initialData` itself was last updated. + +#### Inherited from + +```ts +WithRequired.initialDataUpdatedAt +``` + +*** + +### initialPageParam? + +```ts +optional initialPageParam: undefined; +``` + +Defined in: [packages/query-core/src/types.ts:585](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L585) + +*** + +### maxPages? + +```ts +optional maxPages: number; +``` + +Defined in: [packages/query-core/src/types.ts:345](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L345) + +Maximum number of pages to store in the data of an infinite query. + +#### Inherited from + +```ts +WithRequired.maxPages +``` + +*** + +### meta? + +```ts +optional meta: Record; +``` + +Defined in: [packages/query-core/src/types.ts:341](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L341) + +Additional payload to be stored on each query. +Use this property to pass information that can be used in other places. + +#### Inherited from + +```ts +WithRequired.meta +``` + +*** + +### networkMode? + +```ts +optional networkMode: NetworkMode; +``` + +Defined in: [packages/query-core/src/types.ts:265](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L265) + +Controls whether a query is allowed to run based on the current network connectivity. + +Defaults to `'online'`. + +#### See + +[Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. + +#### Inherited from + +```ts +WithRequired.networkMode +``` + +*** + +### persister? + +```ts +optional persister: QueryPersister, TPageParam>; +``` + +Defined in: [packages/query-core/src/types.ts:290](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L290) + +This option can be used to persist the result of a query to an external storage, bypassing the need to actually +call the `queryFn`. Useful for persisting a query's data across e.g. server/client boundaries. + +#### Inherited from + +```ts +WithRequired.persister +``` + +*** + +### queryFn? + +```ts +optional queryFn: + | typeof skipToken +| QueryFunction; +``` + +Defined in: [packages/query-core/src/types.ts:285](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L285) + +The function that the query will use to request data. +Required, unless a default query function has been set via `queryClient.setQueryDefaults` or +`queryClient.setDefaultOptions`. +Receives a [QueryFunctionContext](../type-aliases/QueryFunctionContext.md). +Must return a promise that will either resolve data or throw an error. The data cannot be `undefined`. + +#### Inherited from + +```ts +WithRequired.queryFn +``` + +*** + +### queryHash? + +```ts +optional queryHash: string; +``` + +Defined in: [packages/query-core/src/types.ts:295](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L295) + +The hashed form of `queryKey`, computed with `queryKeyHashFn` (or the default hashing function otherwise). Used +as the actual cache key internally. + +#### Inherited from + +```ts +WithRequired.queryHash +``` + +*** + +### queryKey + +```ts +queryKey: TQueryKey & object; +``` + +Defined in: [packages/query-core/src/types.ts:304](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L304) + +The query key to use for this query. + +The query key will be hashed into a stable hash. See [Query Keys](https://tanstack.com/query/latest/docs/framework/react/guides/query-keys) +for more information. + +The query will automatically update when this key changes (as long as `enabled` is not set to `false`). + +#### Inherited from + +```ts +WithRequired.queryKey +``` + +*** + +### queryKeyHashFn? + +```ts +optional queryKeyHashFn: QueryKeyHashFunction; +``` + +Defined in: [packages/query-core/src/types.ts:308](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L308) + +If specified, this function is used to hash the `queryKey` to a string. + +#### Inherited from + +```ts +WithRequired.queryKeyHashFn +``` + +*** + +### retry? + +```ts +optional retry: RetryValue; +``` + +Defined in: [packages/query-core/src/types.ts:246](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L246) + +If `false`, failed queries will not retry by default. +If `true`, failed queries will retry infinitely. +If set to an integer number, e.g. 3, failed queries will retry until the failed query count meets that number. +If set to a function `(failureCount, error) => boolean` failed queries will retry until the function returns false. + +Defaults to `3` on the client and `0` on the server. + +#### Inherited from + +```ts +WithRequired.retry +``` + +*** + +### retryDelay? + +```ts +optional retryDelay: RetryDelayValue; +``` + +Defined in: [packages/query-core/src/types.ts:258](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L258) + +This function receives a `retryAttempt` integer and the actual Error and returns the delay to apply before the +next attempt in milliseconds. + +A function like `attempt => Math.min(attempt > 1 ? 2 ** attempt * 1000 : 1000, 30 * 1000)` applies exponential +backoff. + +A function like `attempt => attempt * 1000` applies linear backoff. + +Defaults to a function that applies exponential backoff, capped at 30 seconds. + +#### Inherited from + +```ts +WithRequired.retryDelay +``` + +*** + +### select()? + +```ts +optional select: (data) => TData; +``` + +Defined in: [packages/query-core/src/types.ts:586](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L586) + +#### Parameters + +##### data + +`TQueryData` + +#### Returns + +`TData` + +*** + +### staleTime? + +```ts +optional staleTime: StaleTimeFunction; +``` + +Defined in: [packages/query-core/src/types.ts:591](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L591) + +The time in milliseconds after data is considered stale. +If the data is fresh it will be returned from the cache. + +*** + +### structuralSharing? + +```ts +optional structuralSharing: boolean | (oldData, newData) => unknown; +``` + +Defined in: [packages/query-core/src/types.ts:330](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L330) + +Set this to `false` to disable structural sharing between query results. +Set this to a function which accepts the old and new data and returns resolved data of the same type to implement custom structural sharing logic. + +Defaults to `true`. + +#### Inherited from + +```ts +WithRequired.structuralSharing +``` diff --git a/docs/framework/lit/reference/interfaces/QueryFilters.md b/docs/framework/lit/reference/interfaces/QueryFilters.md new file mode 100644 index 00000000000..749e4283d0d --- /dev/null +++ b/docs/framework/lit/reference/interfaces/QueryFilters.md @@ -0,0 +1,104 @@ +--- +id: QueryFilters +title: QueryFilters +--- + +Defined in: [packages/query-core/src/utils.ts:31](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L31) + +Filters used to select queries, for example in `queryClient.getQueriesData` or `queryClient.invalidateQueries`. +All provided filters must match; filters that are left unspecified are ignored. + +## Extended by + +- [`InvalidateQueryFilters`](InvalidateQueryFilters.md) +- [`RefetchQueryFilters`](RefetchQueryFilters.md) + +## Type Parameters + +### TQueryKey + +`TQueryKey` *extends* [`QueryKey`](../type-aliases/QueryKey.md) = [`QueryKey`](../type-aliases/QueryKey.md) + +## Properties + +### exact? + +```ts +optional exact: boolean; +``` + +Defined in: [packages/query-core/src/utils.ts:41](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L41) + +Match query key exactly + +*** + +### fetchStatus? + +```ts +optional fetchStatus: FetchStatus; +``` + +Defined in: [packages/query-core/src/utils.ts:57](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L57) + +Include queries matching their fetchStatus + +*** + +### predicate()? + +```ts +optional predicate: (query) => boolean; +``` + +Defined in: [packages/query-core/src/utils.ts:45](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L45) + +Include queries matching this predicate function + +#### Parameters + +##### query + +[`Query`](../classes/Query.md) + +#### Returns + +`boolean` + +*** + +### queryKey? + +```ts +optional queryKey: TQueryKey | TuplePrefixes; +``` + +Defined in: [packages/query-core/src/utils.ts:49](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L49) + +Include queries matching this query key + +*** + +### stale? + +```ts +optional stale: boolean; +``` + +Defined in: [packages/query-core/src/utils.ts:53](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L53) + +Include or exclude stale queries + +*** + +### type? + +```ts +optional type: QueryTypeFilter; +``` + +Defined in: [packages/query-core/src/utils.ts:37](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L37) + +Filter to active queries, inactive queries or all queries + +Defaults to `'all'`. diff --git a/docs/framework/lit/reference/interfaces/QueryObserverBaseResult.md b/docs/framework/lit/reference/interfaces/QueryObserverBaseResult.md new file mode 100644 index 00000000000..ef5fe0ad757 --- /dev/null +++ b/docs/framework/lit/reference/interfaces/QueryObserverBaseResult.md @@ -0,0 +1,358 @@ +--- +id: QueryObserverBaseResult +title: QueryObserverBaseResult +--- + +Defined in: [packages/query-core/src/types.ts:764](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L764) + +## Extended by + +- [`QueryObserverPendingResult`](QueryObserverPendingResult.md) +- [`QueryObserverLoadingResult`](QueryObserverLoadingResult.md) +- [`QueryObserverLoadingErrorResult`](QueryObserverLoadingErrorResult.md) +- [`QueryObserverRefetchErrorResult`](QueryObserverRefetchErrorResult.md) +- [`QueryObserverSuccessResult`](QueryObserverSuccessResult.md) +- [`QueryObserverPlaceholderResult`](QueryObserverPlaceholderResult.md) +- [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md) + +## Type Parameters + +### TData + +`TData` = `unknown` + +### TError + +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) + +## Properties + +### data + +```ts +data: TData | undefined; +``` + +Defined in: [packages/query-core/src/types.ts:771](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L771) + +The last successfully resolved data for the query. + +*** + +### dataUpdatedAt + +```ts +dataUpdatedAt: number; +``` + +Defined in: [packages/query-core/src/types.ts:775](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L775) + +The timestamp for when the query most recently returned the `status` as `"success"`. + +*** + +### error + +```ts +error: TError | null; +``` + +Defined in: [packages/query-core/src/types.ts:780](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L780) + +The error object for the query, if an error was thrown. +- Defaults to `null`. + +*** + +### errorUpdateCount + +```ts +errorUpdateCount: number; +``` + +Defined in: [packages/query-core/src/types.ts:799](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L799) + +The sum of all errors. + +*** + +### errorUpdatedAt + +```ts +errorUpdatedAt: number; +``` + +Defined in: [packages/query-core/src/types.ts:784](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L784) + +The timestamp for when the query most recently returned the `status` as `"error"`. + +*** + +### failureCount + +```ts +failureCount: number; +``` + +Defined in: [packages/query-core/src/types.ts:790](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L790) + +The failure count for the query. +- Incremented every time the query fails. +- Reset to `0` when the query succeeds. + +*** + +### failureReason + +```ts +failureReason: TError | null; +``` + +Defined in: [packages/query-core/src/types.ts:795](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L795) + +The failure reason for the query retry. +- Reset to `null` when the query succeeds. + +*** + +### fetchStatus + +```ts +fetchStatus: FetchStatus; +``` + +Defined in: [packages/query-core/src/types.ts:889](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L889) + +The fetch status of the query. +- `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. +- `paused`: The query wanted to fetch, but has been `paused`. +- `idle`: The query is not fetching. +- See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. + +*** + +### isEnabled + +```ts +isEnabled: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:867](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L867) + +`true` if this observer is enabled, `false` otherwise. + +*** + +### isError + +```ts +isError: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:804](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L804) + +A derived boolean from the `status` variable, provided for convenience. +- `true` if the query attempt resulted in an error. + +*** + +### isFetched + +```ts +isFetched: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:808](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L808) + +Will be `true` if the query has been fetched. + +*** + +### isFetchedAfterMount + +```ts +isFetchedAfterMount: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:813](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L813) + +Will be `true` if the query has been fetched after the component mounted. +- This property can be used to not show any previously cached data. + +*** + +### isFetching + +```ts +isFetching: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:818](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L818) + +A derived boolean from the `fetchStatus` variable, provided for convenience. +- `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. + +*** + +### ~~isInitialLoading~~ + +```ts +isInitialLoading: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:836](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L836) + +#### Deprecated + +`isInitialLoading` is being deprecated in favor of `isLoading` +and will be removed in the next major version. + +*** + +### isLoading + +```ts +isLoading: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:823](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L823) + +Is `true` whenever the first fetch for a query is in-flight. +- Is the same as `isFetching && isPending`. + +*** + +### isLoadingError + +```ts +isLoadingError: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:831](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L831) + +Will be `true` if the query failed while fetching for the first time. + +*** + +### isPaused + +```ts +isPaused: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:841](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L841) + +A derived boolean from the `fetchStatus` variable, provided for convenience. +- The query wanted to fetch, but has been `paused`. + +*** + +### isPending + +```ts +isPending: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:827](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L827) + +Will be `pending` if there's no cached data and no query attempt was finished yet. + +*** + +### isPlaceholderData + +```ts +isPlaceholderData: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:845](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L845) + +Will be `true` if the data shown is the placeholder data. + +*** + +### isRefetchError + +```ts +isRefetchError: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:849](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L849) + +Will be `true` if the query failed while refetching. + +*** + +### isRefetching + +```ts +isRefetching: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:854](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L854) + +Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. +- Is the same as `isFetching && !isPending`. + +*** + +### isStale + +```ts +isStale: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:858](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L858) + +Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. + +*** + +### isSuccess + +```ts +isSuccess: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:863](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L863) + +A derived boolean from the `status` variable, provided for convenience. +- `true` if the query has received a response with no errors and is ready to display its data. + +*** + +### refetch() + +```ts +refetch: (options?) => Promise>; +``` + +Defined in: [packages/query-core/src/types.ts:871](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L871) + +A function to manually refetch the query. + +#### Parameters + +##### options? + +[`RefetchOptions`](RefetchOptions.md) + +#### Returns + +`Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> + +*** + +### status + +```ts +status: QueryStatus; +``` + +Defined in: [packages/query-core/src/types.ts:881](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L881) + +The status of the query. +- Will be: + - `pending` if there's no cached data and no query attempt was finished yet. + - `error` if the query attempt resulted in an error. + - `success` if the query has received a response with no errors and is ready to display its data. diff --git a/docs/framework/lit/reference/interfaces/QueryObserverLoadingErrorResult.md b/docs/framework/lit/reference/interfaces/QueryObserverLoadingErrorResult.md new file mode 100644 index 00000000000..21b39fbffe3 --- /dev/null +++ b/docs/framework/lit/reference/interfaces/QueryObserverLoadingErrorResult.md @@ -0,0 +1,452 @@ +--- +id: QueryObserverLoadingErrorResult +title: QueryObserverLoadingErrorResult +--- + +Defined in: [packages/query-core/src/types.ts:923](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L923) + +## Extends + +- [`QueryObserverBaseResult`](QueryObserverBaseResult.md)\<`TData`, `TError`\> + +## Type Parameters + +### TData + +`TData` = `unknown` + +### TError + +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) + +## Properties + +### data + +```ts +data: undefined; +``` + +Defined in: [packages/query-core/src/types.ts:927](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L927) + +The last successfully resolved data for the query. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`data`](QueryObserverBaseResult.md#data) + +*** + +### dataUpdatedAt + +```ts +dataUpdatedAt: number; +``` + +Defined in: [packages/query-core/src/types.ts:775](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L775) + +The timestamp for when the query most recently returned the `status` as `"success"`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`dataUpdatedAt`](QueryObserverBaseResult.md#dataupdatedat) + +*** + +### error + +```ts +error: TError; +``` + +Defined in: [packages/query-core/src/types.ts:928](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L928) + +The error object for the query, if an error was thrown. +- Defaults to `null`. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`error`](QueryObserverBaseResult.md#error) + +*** + +### errorUpdateCount + +```ts +errorUpdateCount: number; +``` + +Defined in: [packages/query-core/src/types.ts:799](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L799) + +The sum of all errors. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`errorUpdateCount`](QueryObserverBaseResult.md#errorupdatecount) + +*** + +### errorUpdatedAt + +```ts +errorUpdatedAt: number; +``` + +Defined in: [packages/query-core/src/types.ts:784](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L784) + +The timestamp for when the query most recently returned the `status` as `"error"`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`errorUpdatedAt`](QueryObserverBaseResult.md#errorupdatedat) + +*** + +### failureCount + +```ts +failureCount: number; +``` + +Defined in: [packages/query-core/src/types.ts:790](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L790) + +The failure count for the query. +- Incremented every time the query fails. +- Reset to `0` when the query succeeds. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`failureCount`](QueryObserverBaseResult.md#failurecount) + +*** + +### failureReason + +```ts +failureReason: TError | null; +``` + +Defined in: [packages/query-core/src/types.ts:795](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L795) + +The failure reason for the query retry. +- Reset to `null` when the query succeeds. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`failureReason`](QueryObserverBaseResult.md#failurereason) + +*** + +### fetchStatus + +```ts +fetchStatus: FetchStatus; +``` + +Defined in: [packages/query-core/src/types.ts:889](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L889) + +The fetch status of the query. +- `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. +- `paused`: The query wanted to fetch, but has been `paused`. +- `idle`: The query is not fetching. +- See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`fetchStatus`](QueryObserverBaseResult.md#fetchstatus) + +*** + +### isEnabled + +```ts +isEnabled: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:867](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L867) + +`true` if this observer is enabled, `false` otherwise. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isEnabled`](QueryObserverBaseResult.md#isenabled) + +*** + +### isError + +```ts +isError: true; +``` + +Defined in: [packages/query-core/src/types.ts:929](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L929) + +A derived boolean from the `status` variable, provided for convenience. +- `true` if the query attempt resulted in an error. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isError`](QueryObserverBaseResult.md#iserror) + +*** + +### isFetched + +```ts +isFetched: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:808](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L808) + +Will be `true` if the query has been fetched. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isFetched`](QueryObserverBaseResult.md#isfetched) + +*** + +### isFetchedAfterMount + +```ts +isFetchedAfterMount: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:813](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L813) + +Will be `true` if the query has been fetched after the component mounted. +- This property can be used to not show any previously cached data. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isFetchedAfterMount`](QueryObserverBaseResult.md#isfetchedaftermount) + +*** + +### isFetching + +```ts +isFetching: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:818](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L818) + +A derived boolean from the `fetchStatus` variable, provided for convenience. +- `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isFetching`](QueryObserverBaseResult.md#isfetching) + +*** + +### ~~isInitialLoading~~ + +```ts +isInitialLoading: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:836](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L836) + +#### Deprecated + +`isInitialLoading` is being deprecated in favor of `isLoading` +and will be removed in the next major version. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isInitialLoading`](QueryObserverBaseResult.md#isinitialloading) + +*** + +### isLoading + +```ts +isLoading: false; +``` + +Defined in: [packages/query-core/src/types.ts:931](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L931) + +Is `true` whenever the first fetch for a query is in-flight. +- Is the same as `isFetching && isPending`. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoading`](QueryObserverBaseResult.md#isloading) + +*** + +### isLoadingError + +```ts +isLoadingError: true; +``` + +Defined in: [packages/query-core/src/types.ts:932](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L932) + +Will be `true` if the query failed while fetching for the first time. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoadingError`](QueryObserverBaseResult.md#isloadingerror) + +*** + +### isPaused + +```ts +isPaused: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:841](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L841) + +A derived boolean from the `fetchStatus` variable, provided for convenience. +- The query wanted to fetch, but has been `paused`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPaused`](QueryObserverBaseResult.md#ispaused) + +*** + +### isPending + +```ts +isPending: false; +``` + +Defined in: [packages/query-core/src/types.ts:930](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L930) + +Will be `pending` if there's no cached data and no query attempt was finished yet. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPending`](QueryObserverBaseResult.md#ispending) + +*** + +### isPlaceholderData + +```ts +isPlaceholderData: false; +``` + +Defined in: [packages/query-core/src/types.ts:935](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L935) + +Will be `true` if the data shown is the placeholder data. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPlaceholderData`](QueryObserverBaseResult.md#isplaceholderdata) + +*** + +### isRefetchError + +```ts +isRefetchError: false; +``` + +Defined in: [packages/query-core/src/types.ts:933](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L933) + +Will be `true` if the query failed while refetching. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetchError`](QueryObserverBaseResult.md#isrefetcherror) + +*** + +### isRefetching + +```ts +isRefetching: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:854](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L854) + +Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. +- Is the same as `isFetching && !isPending`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetching`](QueryObserverBaseResult.md#isrefetching) + +*** + +### isStale + +```ts +isStale: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:858](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L858) + +Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isStale`](QueryObserverBaseResult.md#isstale) + +*** + +### isSuccess + +```ts +isSuccess: false; +``` + +Defined in: [packages/query-core/src/types.ts:934](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L934) + +A derived boolean from the `status` variable, provided for convenience. +- `true` if the query has received a response with no errors and is ready to display its data. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isSuccess`](QueryObserverBaseResult.md#issuccess) + +*** + +### refetch() + +```ts +refetch: (options?) => Promise>; +``` + +Defined in: [packages/query-core/src/types.ts:871](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L871) + +A function to manually refetch the query. + +#### Parameters + +##### options? + +[`RefetchOptions`](RefetchOptions.md) + +#### Returns + +`Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`refetch`](QueryObserverBaseResult.md#refetch) + +*** + +### status + +```ts +status: "error"; +``` + +Defined in: [packages/query-core/src/types.ts:936](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L936) + +The status of the query. +- Will be: + - `pending` if there's no cached data and no query attempt was finished yet. + - `error` if the query attempt resulted in an error. + - `success` if the query has received a response with no errors and is ready to display its data. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`status`](QueryObserverBaseResult.md#status) diff --git a/docs/framework/lit/reference/interfaces/QueryObserverLoadingResult.md b/docs/framework/lit/reference/interfaces/QueryObserverLoadingResult.md new file mode 100644 index 00000000000..4966390127f --- /dev/null +++ b/docs/framework/lit/reference/interfaces/QueryObserverLoadingResult.md @@ -0,0 +1,452 @@ +--- +id: QueryObserverLoadingResult +title: QueryObserverLoadingResult +--- + +Defined in: [packages/query-core/src/types.ts:907](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L907) + +## Extends + +- [`QueryObserverBaseResult`](QueryObserverBaseResult.md)\<`TData`, `TError`\> + +## Type Parameters + +### TData + +`TData` = `unknown` + +### TError + +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) + +## Properties + +### data + +```ts +data: undefined; +``` + +Defined in: [packages/query-core/src/types.ts:911](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L911) + +The last successfully resolved data for the query. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`data`](QueryObserverBaseResult.md#data) + +*** + +### dataUpdatedAt + +```ts +dataUpdatedAt: number; +``` + +Defined in: [packages/query-core/src/types.ts:775](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L775) + +The timestamp for when the query most recently returned the `status` as `"success"`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`dataUpdatedAt`](QueryObserverBaseResult.md#dataupdatedat) + +*** + +### error + +```ts +error: null; +``` + +Defined in: [packages/query-core/src/types.ts:912](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L912) + +The error object for the query, if an error was thrown. +- Defaults to `null`. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`error`](QueryObserverBaseResult.md#error) + +*** + +### errorUpdateCount + +```ts +errorUpdateCount: number; +``` + +Defined in: [packages/query-core/src/types.ts:799](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L799) + +The sum of all errors. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`errorUpdateCount`](QueryObserverBaseResult.md#errorupdatecount) + +*** + +### errorUpdatedAt + +```ts +errorUpdatedAt: number; +``` + +Defined in: [packages/query-core/src/types.ts:784](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L784) + +The timestamp for when the query most recently returned the `status` as `"error"`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`errorUpdatedAt`](QueryObserverBaseResult.md#errorupdatedat) + +*** + +### failureCount + +```ts +failureCount: number; +``` + +Defined in: [packages/query-core/src/types.ts:790](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L790) + +The failure count for the query. +- Incremented every time the query fails. +- Reset to `0` when the query succeeds. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`failureCount`](QueryObserverBaseResult.md#failurecount) + +*** + +### failureReason + +```ts +failureReason: TError | null; +``` + +Defined in: [packages/query-core/src/types.ts:795](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L795) + +The failure reason for the query retry. +- Reset to `null` when the query succeeds. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`failureReason`](QueryObserverBaseResult.md#failurereason) + +*** + +### fetchStatus + +```ts +fetchStatus: FetchStatus; +``` + +Defined in: [packages/query-core/src/types.ts:889](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L889) + +The fetch status of the query. +- `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. +- `paused`: The query wanted to fetch, but has been `paused`. +- `idle`: The query is not fetching. +- See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`fetchStatus`](QueryObserverBaseResult.md#fetchstatus) + +*** + +### isEnabled + +```ts +isEnabled: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:867](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L867) + +`true` if this observer is enabled, `false` otherwise. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isEnabled`](QueryObserverBaseResult.md#isenabled) + +*** + +### isError + +```ts +isError: false; +``` + +Defined in: [packages/query-core/src/types.ts:913](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L913) + +A derived boolean from the `status` variable, provided for convenience. +- `true` if the query attempt resulted in an error. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isError`](QueryObserverBaseResult.md#iserror) + +*** + +### isFetched + +```ts +isFetched: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:808](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L808) + +Will be `true` if the query has been fetched. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isFetched`](QueryObserverBaseResult.md#isfetched) + +*** + +### isFetchedAfterMount + +```ts +isFetchedAfterMount: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:813](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L813) + +Will be `true` if the query has been fetched after the component mounted. +- This property can be used to not show any previously cached data. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isFetchedAfterMount`](QueryObserverBaseResult.md#isfetchedaftermount) + +*** + +### isFetching + +```ts +isFetching: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:818](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L818) + +A derived boolean from the `fetchStatus` variable, provided for convenience. +- `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isFetching`](QueryObserverBaseResult.md#isfetching) + +*** + +### ~~isInitialLoading~~ + +```ts +isInitialLoading: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:836](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L836) + +#### Deprecated + +`isInitialLoading` is being deprecated in favor of `isLoading` +and will be removed in the next major version. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isInitialLoading`](QueryObserverBaseResult.md#isinitialloading) + +*** + +### isLoading + +```ts +isLoading: true; +``` + +Defined in: [packages/query-core/src/types.ts:915](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L915) + +Is `true` whenever the first fetch for a query is in-flight. +- Is the same as `isFetching && isPending`. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoading`](QueryObserverBaseResult.md#isloading) + +*** + +### isLoadingError + +```ts +isLoadingError: false; +``` + +Defined in: [packages/query-core/src/types.ts:916](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L916) + +Will be `true` if the query failed while fetching for the first time. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoadingError`](QueryObserverBaseResult.md#isloadingerror) + +*** + +### isPaused + +```ts +isPaused: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:841](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L841) + +A derived boolean from the `fetchStatus` variable, provided for convenience. +- The query wanted to fetch, but has been `paused`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPaused`](QueryObserverBaseResult.md#ispaused) + +*** + +### isPending + +```ts +isPending: true; +``` + +Defined in: [packages/query-core/src/types.ts:914](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L914) + +Will be `pending` if there's no cached data and no query attempt was finished yet. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPending`](QueryObserverBaseResult.md#ispending) + +*** + +### isPlaceholderData + +```ts +isPlaceholderData: false; +``` + +Defined in: [packages/query-core/src/types.ts:919](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L919) + +Will be `true` if the data shown is the placeholder data. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPlaceholderData`](QueryObserverBaseResult.md#isplaceholderdata) + +*** + +### isRefetchError + +```ts +isRefetchError: false; +``` + +Defined in: [packages/query-core/src/types.ts:917](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L917) + +Will be `true` if the query failed while refetching. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetchError`](QueryObserverBaseResult.md#isrefetcherror) + +*** + +### isRefetching + +```ts +isRefetching: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:854](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L854) + +Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. +- Is the same as `isFetching && !isPending`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetching`](QueryObserverBaseResult.md#isrefetching) + +*** + +### isStale + +```ts +isStale: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:858](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L858) + +Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isStale`](QueryObserverBaseResult.md#isstale) + +*** + +### isSuccess + +```ts +isSuccess: false; +``` + +Defined in: [packages/query-core/src/types.ts:918](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L918) + +A derived boolean from the `status` variable, provided for convenience. +- `true` if the query has received a response with no errors and is ready to display its data. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isSuccess`](QueryObserverBaseResult.md#issuccess) + +*** + +### refetch() + +```ts +refetch: (options?) => Promise>; +``` + +Defined in: [packages/query-core/src/types.ts:871](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L871) + +A function to manually refetch the query. + +#### Parameters + +##### options? + +[`RefetchOptions`](RefetchOptions.md) + +#### Returns + +`Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`refetch`](QueryObserverBaseResult.md#refetch) + +*** + +### status + +```ts +status: "pending"; +``` + +Defined in: [packages/query-core/src/types.ts:920](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L920) + +The status of the query. +- Will be: + - `pending` if there's no cached data and no query attempt was finished yet. + - `error` if the query attempt resulted in an error. + - `success` if the query has received a response with no errors and is ready to display its data. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`status`](QueryObserverBaseResult.md#status) diff --git a/docs/framework/lit/reference/interfaces/QueryObserverOptions.md b/docs/framework/lit/reference/interfaces/QueryObserverOptions.md new file mode 100644 index 00000000000..3d6dc9c42ce --- /dev/null +++ b/docs/framework/lit/reference/interfaces/QueryObserverOptions.md @@ -0,0 +1,560 @@ +--- +id: QueryObserverOptions +title: QueryObserverOptions +--- + +Defined in: [packages/query-core/src/types.ts:380](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L380) + +## Extends + +- [`WithRequired`](../type-aliases/WithRequired.md)\<[`QueryOptions`](QueryOptions.md)\<`TQueryFnData`, `TError`, `TQueryData`, `TQueryKey`, `TPageParam`\>, `"queryKey"`\> + +## Extended by + +- [`InfiniteQueryObserverOptions`](InfiniteQueryObserverOptions.md) + +## Type Parameters + +### TQueryFnData + +`TQueryFnData` = `unknown` + +### TError + +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) + +### TData + +`TData` = `TQueryFnData` + +### TQueryData + +`TQueryData` = `TQueryFnData` + +### TQueryKey + +`TQueryKey` *extends* [`QueryKey`](../type-aliases/QueryKey.md) = [`QueryKey`](../type-aliases/QueryKey.md) + +### TPageParam + +`TPageParam` = `never` + +## Properties + +### enabled? + +```ts +optional enabled: QueryBooleanOption; +``` + +Defined in: [packages/query-core/src/types.ts:398](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L398) + +Set this to `false` or a function that returns `false` to disable automatic refetching when the query mounts or changes query keys. +To refetch the query, use the `refetch` method returned from the `useQuery` instance. +Accepts a boolean or function that returns a boolean. + +Defaults to `true`. + +*** + +### gcTime? + +```ts +optional gcTime: number; +``` + +Defined in: [packages/query-core/src/types.ts:277](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L277) + +The time in milliseconds that unused/inactive cache data remains in memory. +When a query's cache becomes unused or inactive, that cache data will be garbage collected after this duration. +When different garbage collection times are specified, the longest one will be used. +Setting it to `Infinity` will disable garbage collection. + +Defaults to `5 * 60 * 1000` (5 minutes), or `Infinity` during SSR. + +Note: the maximum allowed time is about 24 days, imposed by `setTimeout`'s 32-bit signed integer delay — see +`timeoutManager.setTimeoutProvider` for a workaround. + +#### Inherited from + +```ts +WithRequired.gcTime +``` + +*** + +### initialData? + +```ts +optional initialData: + | TQueryData +| InitialDataFunction; +``` + +Defined in: [packages/query-core/src/types.ts:317](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L317) + +If set, this value will be used as the initial data for the query cache (as long as the query hasn't been +created or cached yet). +If set to a function, the function will be called **once** during the shared/root query initialization, and be +expected to synchronously return the initial data. +Initial data is considered stale by default unless a `staleTime` has been set. +`initialData` **is persisted** to the cache. + +#### Inherited from + +```ts +WithRequired.initialData +``` + +*** + +### initialDataUpdatedAt? + +```ts +optional initialDataUpdatedAt: number | () => number | undefined; +``` + +Defined in: [packages/query-core/src/types.ts:321](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L321) + +If set, this value will be used as the time (in milliseconds) of when the `initialData` itself was last updated. + +#### Inherited from + +```ts +WithRequired.initialDataUpdatedAt +``` + +*** + +### maxPages? + +```ts +optional maxPages: number; +``` + +Defined in: [packages/query-core/src/types.ts:345](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L345) + +Maximum number of pages to store in the data of an infinite query. + +#### Inherited from + +```ts +WithRequired.maxPages +``` + +*** + +### meta? + +```ts +optional meta: Record; +``` + +Defined in: [packages/query-core/src/types.ts:341](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L341) + +Additional payload to be stored on each query. +Use this property to pass information that can be used in other places. + +#### Inherited from + +```ts +WithRequired.meta +``` + +*** + +### networkMode? + +```ts +optional networkMode: NetworkMode; +``` + +Defined in: [packages/query-core/src/types.ts:265](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L265) + +Controls whether a query is allowed to run based on the current network connectivity. + +Defaults to `'online'`. + +#### See + +[Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. + +#### Inherited from + +```ts +WithRequired.networkMode +``` + +*** + +### notifyOnChangeProps? + +```ts +optional notifyOnChangeProps: NotifyOnChangeProps; +``` + +Defined in: [packages/query-core/src/types.ts:484](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L484) + +If set, the component will only re-render if any of the listed properties change. +When set to `['data', 'error']`, the component will only re-render when the `data` or `error` properties change. +When set to `'all'`, the component will re-render whenever a query is updated. +When set to a function, the function will be executed to compute the list of properties. + +Defaults to `undefined`, in which case property access is tracked automatically, and the +component only re-renders when one of the tracked properties changes. + +*** + +### persister? + +```ts +optional persister: QueryPersister, TPageParam>; +``` + +Defined in: [packages/query-core/src/types.ts:290](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L290) + +This option can be used to persist the result of a query to an external storage, bypassing the need to actually +call the `queryFn`. Useful for persisting a query's data across e.g. server/client boundaries. + +#### Inherited from + +```ts +WithRequired.persister +``` + +*** + +### placeholderData? + +```ts +optional placeholderData: + | NonFunctionGuard +| PlaceholderDataFunction, TError, NonFunctionGuard, TQueryKey>; +``` + +Defined in: [packages/query-core/src/types.ts:511](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L511) + +If set, this value will be used as the placeholder data for this particular query observer while the query is still in the `loading` data and no initialData has been provided. + +*** + +### queryFn? + +```ts +optional queryFn: + | typeof skipToken +| QueryFunction; +``` + +Defined in: [packages/query-core/src/types.ts:285](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L285) + +The function that the query will use to request data. +Required, unless a default query function has been set via `queryClient.setQueryDefaults` or +`queryClient.setDefaultOptions`. +Receives a [QueryFunctionContext](../type-aliases/QueryFunctionContext.md). +Must return a promise that will either resolve data or throw an error. The data cannot be `undefined`. + +#### Inherited from + +```ts +WithRequired.queryFn +``` + +*** + +### queryHash? + +```ts +optional queryHash: string; +``` + +Defined in: [packages/query-core/src/types.ts:295](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L295) + +The hashed form of `queryKey`, computed with `queryKeyHashFn` (or the default hashing function otherwise). Used +as the actual cache key internally. + +#### Inherited from + +```ts +WithRequired.queryHash +``` + +*** + +### queryKey + +```ts +queryKey: TQueryKey & object; +``` + +Defined in: [packages/query-core/src/types.ts:304](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L304) + +The query key to use for this query. + +The query key will be hashed into a stable hash. See [Query Keys](https://tanstack.com/query/latest/docs/framework/react/guides/query-keys) +for more information. + +The query will automatically update when this key changes (as long as `enabled` is not set to `false`). + +#### Inherited from + +```ts +WithRequired.queryKey +``` + +*** + +### queryKeyHashFn? + +```ts +optional queryKeyHashFn: QueryKeyHashFunction; +``` + +Defined in: [packages/query-core/src/types.ts:308](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L308) + +If specified, this function is used to hash the `queryKey` to a string. + +#### Inherited from + +```ts +WithRequired.queryKeyHashFn +``` + +*** + +### refetchInterval? + +```ts +optional refetchInterval: number | false | (query) => number | false | undefined; +``` + +Defined in: [packages/query-core/src/types.ts:414](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L414) + +If set to a number, the query will continuously refetch at this frequency in milliseconds. +If set to a function, the function will be executed with the latest data and query to compute a frequency + +Defaults to `false`. + +*** + +### refetchIntervalInBackground? + +```ts +optional refetchIntervalInBackground: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:425](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L425) + +If set to `true`, the query will continue to refetch while their tab/window is in the background. + +Defaults to `false`. + +*** + +### refetchOnMount? + +```ts +optional refetchOnMount: boolean | "always" | (query) => boolean | "always"; +``` + +Defined in: [packages/query-core/src/types.ts:462](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L462) + +If set to `true`, the query will refetch on mount if the data is stale. +If set to `false`, will disable additional instances of a query to trigger background refetch. +If set to `'always'`, the query will always refetch on mount (except when `staleTime: 'static'` is used). +If set to a function, the function will be executed with the latest data and query to compute the value + +Defaults to `true`. + +*** + +### refetchOnReconnect? + +```ts +optional refetchOnReconnect: boolean | "always" | (query) => boolean | "always"; +``` + +Defined in: [packages/query-core/src/types.ts:448](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L448) + +If set to `true`, the query will refetch on reconnect if the data is stale. +If set to `false`, the query will not refetch on reconnect. +If set to `'always'`, the query will always refetch on reconnect (except when `staleTime: 'static'` is used). +If set to a function, the function will be executed with the latest data and query to compute the value. + +Defaults to `true` unless `networkMode` is `'always'`. + +*** + +### refetchOnWindowFocus? + +```ts +optional refetchOnWindowFocus: boolean | "always" | (query) => boolean | "always"; +``` + +Defined in: [packages/query-core/src/types.ts:434](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L434) + +If set to `true`, the query will refetch on window focus if the data is stale. +If set to `false`, the query will not refetch on window focus. +If set to `'always'`, the query will always refetch on window focus (except when `staleTime: 'static'` is used). +If set to a function, the function will be executed with the latest data and query to compute the value. + +Defaults to `true`. + +*** + +### retry? + +```ts +optional retry: RetryValue; +``` + +Defined in: [packages/query-core/src/types.ts:246](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L246) + +If `false`, failed queries will not retry by default. +If `true`, failed queries will retry infinitely. +If set to an integer number, e.g. 3, failed queries will retry until the failed query count meets that number. +If set to a function `(failureCount, error) => boolean` failed queries will retry until the function returns false. + +Defaults to `3` on the client and `0` on the server. + +#### Inherited from + +```ts +WithRequired.retry +``` + +*** + +### retryDelay? + +```ts +optional retryDelay: RetryDelayValue; +``` + +Defined in: [packages/query-core/src/types.ts:258](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L258) + +This function receives a `retryAttempt` integer and the actual Error and returns the delay to apply before the +next attempt in milliseconds. + +A function like `attempt => Math.min(attempt > 1 ? 2 ** attempt * 1000 : 1000, 30 * 1000)` applies exponential +backoff. + +A function like `attempt => attempt * 1000` applies linear backoff. + +Defaults to a function that applies exponential backoff, capped at 30 seconds. + +#### Inherited from + +```ts +WithRequired.retryDelay +``` + +*** + +### retryOnMount? + +```ts +optional retryOnMount: QueryBooleanOption; +``` + +Defined in: [packages/query-core/src/types.ts:474](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L474) + +If set to `false`, the query will not be retried on mount if it contains an error. +If set to a function, the function will be executed with the query to compute the value. + +Defaults to `true`. + +*** + +### select()? + +```ts +optional select: (data) => TData; +``` + +Defined in: [packages/query-core/src/types.ts:500](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L500) + +This option can be used to transform or select a part of the data returned by the query function. It affects +the returned `data` value, but does not affect what gets stored in the query cache. +The `select` function will only run if `data` changed, or if the reference to the `select` function itself +changes. To optimize, memoize the function so its reference stays stable across calls. + +#### Parameters + +##### data + +`TQueryData` + +#### Returns + +`TData` + +*** + +### staleTime? + +```ts +optional staleTime: StaleTimeFunction; +``` + +Defined in: [packages/query-core/src/types.ts:407](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L407) + +The time in milliseconds after data is considered stale. +If set to `Infinity`, the data will never be considered stale. +If set to `'static'`, the data will never be considered stale. +If set to a function, the function will be executed with the query to compute a `staleTime`. + +Defaults to `0`. + +*** + +### structuralSharing? + +```ts +optional structuralSharing: boolean | (oldData, newData) => unknown; +``` + +Defined in: [packages/query-core/src/types.ts:330](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L330) + +Set this to `false` to disable structural sharing between query results. +Set this to a function which accepts the old and new data and returns resolved data of the same type to implement custom structural sharing logic. + +Defaults to `true`. + +#### Inherited from + +```ts +WithRequired.structuralSharing +``` + +*** + +### suspense? + +```ts +optional suspense: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:507](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L507) + +If set to `true`, the query will suspend when `status === 'pending'` +and throw errors when `status === 'error'`. + +Defaults to `false`. + +*** + +### throwOnError? + +```ts +optional throwOnError: ThrowOnError; +``` + +Defined in: [packages/query-core/src/types.ts:493](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L493) + +Whether errors should be thrown instead of setting the `error` property. +If set to `true` or `suspense` is `true`, all errors will be thrown to the error boundary. +If set to `false` and `suspense` is `false`, errors are returned as state. +If set to a function, it will be passed the error and the query, and it should return a boolean indicating whether to show the error in an error boundary (`true`) or return the error as state (`false`). + +Defaults to `false`. diff --git a/docs/framework/lit/reference/interfaces/QueryObserverPendingResult.md b/docs/framework/lit/reference/interfaces/QueryObserverPendingResult.md new file mode 100644 index 00000000000..8f00c426b64 --- /dev/null +++ b/docs/framework/lit/reference/interfaces/QueryObserverPendingResult.md @@ -0,0 +1,452 @@ +--- +id: QueryObserverPendingResult +title: QueryObserverPendingResult +--- + +Defined in: [packages/query-core/src/types.ts:892](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L892) + +## Extends + +- [`QueryObserverBaseResult`](QueryObserverBaseResult.md)\<`TData`, `TError`\> + +## Type Parameters + +### TData + +`TData` = `unknown` + +### TError + +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) + +## Properties + +### data + +```ts +data: undefined; +``` + +Defined in: [packages/query-core/src/types.ts:896](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L896) + +The last successfully resolved data for the query. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`data`](QueryObserverBaseResult.md#data) + +*** + +### dataUpdatedAt + +```ts +dataUpdatedAt: number; +``` + +Defined in: [packages/query-core/src/types.ts:775](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L775) + +The timestamp for when the query most recently returned the `status` as `"success"`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`dataUpdatedAt`](QueryObserverBaseResult.md#dataupdatedat) + +*** + +### error + +```ts +error: null; +``` + +Defined in: [packages/query-core/src/types.ts:897](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L897) + +The error object for the query, if an error was thrown. +- Defaults to `null`. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`error`](QueryObserverBaseResult.md#error) + +*** + +### errorUpdateCount + +```ts +errorUpdateCount: number; +``` + +Defined in: [packages/query-core/src/types.ts:799](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L799) + +The sum of all errors. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`errorUpdateCount`](QueryObserverBaseResult.md#errorupdatecount) + +*** + +### errorUpdatedAt + +```ts +errorUpdatedAt: number; +``` + +Defined in: [packages/query-core/src/types.ts:784](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L784) + +The timestamp for when the query most recently returned the `status` as `"error"`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`errorUpdatedAt`](QueryObserverBaseResult.md#errorupdatedat) + +*** + +### failureCount + +```ts +failureCount: number; +``` + +Defined in: [packages/query-core/src/types.ts:790](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L790) + +The failure count for the query. +- Incremented every time the query fails. +- Reset to `0` when the query succeeds. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`failureCount`](QueryObserverBaseResult.md#failurecount) + +*** + +### failureReason + +```ts +failureReason: TError | null; +``` + +Defined in: [packages/query-core/src/types.ts:795](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L795) + +The failure reason for the query retry. +- Reset to `null` when the query succeeds. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`failureReason`](QueryObserverBaseResult.md#failurereason) + +*** + +### fetchStatus + +```ts +fetchStatus: FetchStatus; +``` + +Defined in: [packages/query-core/src/types.ts:889](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L889) + +The fetch status of the query. +- `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. +- `paused`: The query wanted to fetch, but has been `paused`. +- `idle`: The query is not fetching. +- See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`fetchStatus`](QueryObserverBaseResult.md#fetchstatus) + +*** + +### isEnabled + +```ts +isEnabled: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:867](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L867) + +`true` if this observer is enabled, `false` otherwise. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isEnabled`](QueryObserverBaseResult.md#isenabled) + +*** + +### isError + +```ts +isError: false; +``` + +Defined in: [packages/query-core/src/types.ts:898](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L898) + +A derived boolean from the `status` variable, provided for convenience. +- `true` if the query attempt resulted in an error. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isError`](QueryObserverBaseResult.md#iserror) + +*** + +### isFetched + +```ts +isFetched: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:808](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L808) + +Will be `true` if the query has been fetched. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isFetched`](QueryObserverBaseResult.md#isfetched) + +*** + +### isFetchedAfterMount + +```ts +isFetchedAfterMount: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:813](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L813) + +Will be `true` if the query has been fetched after the component mounted. +- This property can be used to not show any previously cached data. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isFetchedAfterMount`](QueryObserverBaseResult.md#isfetchedaftermount) + +*** + +### isFetching + +```ts +isFetching: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:818](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L818) + +A derived boolean from the `fetchStatus` variable, provided for convenience. +- `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isFetching`](QueryObserverBaseResult.md#isfetching) + +*** + +### ~~isInitialLoading~~ + +```ts +isInitialLoading: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:836](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L836) + +#### Deprecated + +`isInitialLoading` is being deprecated in favor of `isLoading` +and will be removed in the next major version. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isInitialLoading`](QueryObserverBaseResult.md#isinitialloading) + +*** + +### isLoading + +```ts +isLoading: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:823](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L823) + +Is `true` whenever the first fetch for a query is in-flight. +- Is the same as `isFetching && isPending`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoading`](QueryObserverBaseResult.md#isloading) + +*** + +### isLoadingError + +```ts +isLoadingError: false; +``` + +Defined in: [packages/query-core/src/types.ts:900](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L900) + +Will be `true` if the query failed while fetching for the first time. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoadingError`](QueryObserverBaseResult.md#isloadingerror) + +*** + +### isPaused + +```ts +isPaused: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:841](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L841) + +A derived boolean from the `fetchStatus` variable, provided for convenience. +- The query wanted to fetch, but has been `paused`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPaused`](QueryObserverBaseResult.md#ispaused) + +*** + +### isPending + +```ts +isPending: true; +``` + +Defined in: [packages/query-core/src/types.ts:899](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L899) + +Will be `pending` if there's no cached data and no query attempt was finished yet. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPending`](QueryObserverBaseResult.md#ispending) + +*** + +### isPlaceholderData + +```ts +isPlaceholderData: false; +``` + +Defined in: [packages/query-core/src/types.ts:903](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L903) + +Will be `true` if the data shown is the placeholder data. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPlaceholderData`](QueryObserverBaseResult.md#isplaceholderdata) + +*** + +### isRefetchError + +```ts +isRefetchError: false; +``` + +Defined in: [packages/query-core/src/types.ts:901](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L901) + +Will be `true` if the query failed while refetching. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetchError`](QueryObserverBaseResult.md#isrefetcherror) + +*** + +### isRefetching + +```ts +isRefetching: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:854](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L854) + +Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. +- Is the same as `isFetching && !isPending`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetching`](QueryObserverBaseResult.md#isrefetching) + +*** + +### isStale + +```ts +isStale: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:858](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L858) + +Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isStale`](QueryObserverBaseResult.md#isstale) + +*** + +### isSuccess + +```ts +isSuccess: false; +``` + +Defined in: [packages/query-core/src/types.ts:902](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L902) + +A derived boolean from the `status` variable, provided for convenience. +- `true` if the query has received a response with no errors and is ready to display its data. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isSuccess`](QueryObserverBaseResult.md#issuccess) + +*** + +### refetch() + +```ts +refetch: (options?) => Promise>; +``` + +Defined in: [packages/query-core/src/types.ts:871](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L871) + +A function to manually refetch the query. + +#### Parameters + +##### options? + +[`RefetchOptions`](RefetchOptions.md) + +#### Returns + +`Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`refetch`](QueryObserverBaseResult.md#refetch) + +*** + +### status + +```ts +status: "pending"; +``` + +Defined in: [packages/query-core/src/types.ts:904](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L904) + +The status of the query. +- Will be: + - `pending` if there's no cached data and no query attempt was finished yet. + - `error` if the query attempt resulted in an error. + - `success` if the query has received a response with no errors and is ready to display its data. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`status`](QueryObserverBaseResult.md#status) diff --git a/docs/framework/lit/reference/interfaces/QueryObserverPlaceholderResult.md b/docs/framework/lit/reference/interfaces/QueryObserverPlaceholderResult.md new file mode 100644 index 00000000000..bbf3da387f9 --- /dev/null +++ b/docs/framework/lit/reference/interfaces/QueryObserverPlaceholderResult.md @@ -0,0 +1,452 @@ +--- +id: QueryObserverPlaceholderResult +title: QueryObserverPlaceholderResult +--- + +Defined in: [packages/query-core/src/types.ts:971](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L971) + +## Extends + +- [`QueryObserverBaseResult`](QueryObserverBaseResult.md)\<`TData`, `TError`\> + +## Type Parameters + +### TData + +`TData` = `unknown` + +### TError + +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) + +## Properties + +### data + +```ts +data: TData; +``` + +Defined in: [packages/query-core/src/types.ts:975](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L975) + +The last successfully resolved data for the query. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`data`](QueryObserverBaseResult.md#data) + +*** + +### dataUpdatedAt + +```ts +dataUpdatedAt: number; +``` + +Defined in: [packages/query-core/src/types.ts:775](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L775) + +The timestamp for when the query most recently returned the `status` as `"success"`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`dataUpdatedAt`](QueryObserverBaseResult.md#dataupdatedat) + +*** + +### error + +```ts +error: null; +``` + +Defined in: [packages/query-core/src/types.ts:977](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L977) + +The error object for the query, if an error was thrown. +- Defaults to `null`. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`error`](QueryObserverBaseResult.md#error) + +*** + +### errorUpdateCount + +```ts +errorUpdateCount: number; +``` + +Defined in: [packages/query-core/src/types.ts:799](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L799) + +The sum of all errors. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`errorUpdateCount`](QueryObserverBaseResult.md#errorupdatecount) + +*** + +### errorUpdatedAt + +```ts +errorUpdatedAt: number; +``` + +Defined in: [packages/query-core/src/types.ts:784](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L784) + +The timestamp for when the query most recently returned the `status` as `"error"`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`errorUpdatedAt`](QueryObserverBaseResult.md#errorupdatedat) + +*** + +### failureCount + +```ts +failureCount: number; +``` + +Defined in: [packages/query-core/src/types.ts:790](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L790) + +The failure count for the query. +- Incremented every time the query fails. +- Reset to `0` when the query succeeds. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`failureCount`](QueryObserverBaseResult.md#failurecount) + +*** + +### failureReason + +```ts +failureReason: TError | null; +``` + +Defined in: [packages/query-core/src/types.ts:795](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L795) + +The failure reason for the query retry. +- Reset to `null` when the query succeeds. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`failureReason`](QueryObserverBaseResult.md#failurereason) + +*** + +### fetchStatus + +```ts +fetchStatus: FetchStatus; +``` + +Defined in: [packages/query-core/src/types.ts:889](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L889) + +The fetch status of the query. +- `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. +- `paused`: The query wanted to fetch, but has been `paused`. +- `idle`: The query is not fetching. +- See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`fetchStatus`](QueryObserverBaseResult.md#fetchstatus) + +*** + +### isEnabled + +```ts +isEnabled: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:867](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L867) + +`true` if this observer is enabled, `false` otherwise. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isEnabled`](QueryObserverBaseResult.md#isenabled) + +*** + +### isError + +```ts +isError: false; +``` + +Defined in: [packages/query-core/src/types.ts:976](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L976) + +A derived boolean from the `status` variable, provided for convenience. +- `true` if the query attempt resulted in an error. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isError`](QueryObserverBaseResult.md#iserror) + +*** + +### isFetched + +```ts +isFetched: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:808](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L808) + +Will be `true` if the query has been fetched. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isFetched`](QueryObserverBaseResult.md#isfetched) + +*** + +### isFetchedAfterMount + +```ts +isFetchedAfterMount: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:813](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L813) + +Will be `true` if the query has been fetched after the component mounted. +- This property can be used to not show any previously cached data. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isFetchedAfterMount`](QueryObserverBaseResult.md#isfetchedaftermount) + +*** + +### isFetching + +```ts +isFetching: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:818](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L818) + +A derived boolean from the `fetchStatus` variable, provided for convenience. +- `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isFetching`](QueryObserverBaseResult.md#isfetching) + +*** + +### ~~isInitialLoading~~ + +```ts +isInitialLoading: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:836](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L836) + +#### Deprecated + +`isInitialLoading` is being deprecated in favor of `isLoading` +and will be removed in the next major version. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isInitialLoading`](QueryObserverBaseResult.md#isinitialloading) + +*** + +### isLoading + +```ts +isLoading: false; +``` + +Defined in: [packages/query-core/src/types.ts:979](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L979) + +Is `true` whenever the first fetch for a query is in-flight. +- Is the same as `isFetching && isPending`. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoading`](QueryObserverBaseResult.md#isloading) + +*** + +### isLoadingError + +```ts +isLoadingError: false; +``` + +Defined in: [packages/query-core/src/types.ts:980](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L980) + +Will be `true` if the query failed while fetching for the first time. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoadingError`](QueryObserverBaseResult.md#isloadingerror) + +*** + +### isPaused + +```ts +isPaused: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:841](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L841) + +A derived boolean from the `fetchStatus` variable, provided for convenience. +- The query wanted to fetch, but has been `paused`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPaused`](QueryObserverBaseResult.md#ispaused) + +*** + +### isPending + +```ts +isPending: false; +``` + +Defined in: [packages/query-core/src/types.ts:978](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L978) + +Will be `pending` if there's no cached data and no query attempt was finished yet. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPending`](QueryObserverBaseResult.md#ispending) + +*** + +### isPlaceholderData + +```ts +isPlaceholderData: true; +``` + +Defined in: [packages/query-core/src/types.ts:983](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L983) + +Will be `true` if the data shown is the placeholder data. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPlaceholderData`](QueryObserverBaseResult.md#isplaceholderdata) + +*** + +### isRefetchError + +```ts +isRefetchError: false; +``` + +Defined in: [packages/query-core/src/types.ts:981](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L981) + +Will be `true` if the query failed while refetching. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetchError`](QueryObserverBaseResult.md#isrefetcherror) + +*** + +### isRefetching + +```ts +isRefetching: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:854](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L854) + +Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. +- Is the same as `isFetching && !isPending`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetching`](QueryObserverBaseResult.md#isrefetching) + +*** + +### isStale + +```ts +isStale: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:858](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L858) + +Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isStale`](QueryObserverBaseResult.md#isstale) + +*** + +### isSuccess + +```ts +isSuccess: true; +``` + +Defined in: [packages/query-core/src/types.ts:982](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L982) + +A derived boolean from the `status` variable, provided for convenience. +- `true` if the query has received a response with no errors and is ready to display its data. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isSuccess`](QueryObserverBaseResult.md#issuccess) + +*** + +### refetch() + +```ts +refetch: (options?) => Promise>; +``` + +Defined in: [packages/query-core/src/types.ts:871](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L871) + +A function to manually refetch the query. + +#### Parameters + +##### options? + +[`RefetchOptions`](RefetchOptions.md) + +#### Returns + +`Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`refetch`](QueryObserverBaseResult.md#refetch) + +*** + +### status + +```ts +status: "success"; +``` + +Defined in: [packages/query-core/src/types.ts:984](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L984) + +The status of the query. +- Will be: + - `pending` if there's no cached data and no query attempt was finished yet. + - `error` if the query attempt resulted in an error. + - `success` if the query has received a response with no errors and is ready to display its data. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`status`](QueryObserverBaseResult.md#status) diff --git a/docs/framework/lit/reference/interfaces/QueryObserverRefetchErrorResult.md b/docs/framework/lit/reference/interfaces/QueryObserverRefetchErrorResult.md new file mode 100644 index 00000000000..345ecab35e1 --- /dev/null +++ b/docs/framework/lit/reference/interfaces/QueryObserverRefetchErrorResult.md @@ -0,0 +1,452 @@ +--- +id: QueryObserverRefetchErrorResult +title: QueryObserverRefetchErrorResult +--- + +Defined in: [packages/query-core/src/types.ts:939](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L939) + +## Extends + +- [`QueryObserverBaseResult`](QueryObserverBaseResult.md)\<`TData`, `TError`\> + +## Type Parameters + +### TData + +`TData` = `unknown` + +### TError + +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) + +## Properties + +### data + +```ts +data: TData; +``` + +Defined in: [packages/query-core/src/types.ts:943](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L943) + +The last successfully resolved data for the query. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`data`](QueryObserverBaseResult.md#data) + +*** + +### dataUpdatedAt + +```ts +dataUpdatedAt: number; +``` + +Defined in: [packages/query-core/src/types.ts:775](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L775) + +The timestamp for when the query most recently returned the `status` as `"success"`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`dataUpdatedAt`](QueryObserverBaseResult.md#dataupdatedat) + +*** + +### error + +```ts +error: TError; +``` + +Defined in: [packages/query-core/src/types.ts:944](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L944) + +The error object for the query, if an error was thrown. +- Defaults to `null`. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`error`](QueryObserverBaseResult.md#error) + +*** + +### errorUpdateCount + +```ts +errorUpdateCount: number; +``` + +Defined in: [packages/query-core/src/types.ts:799](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L799) + +The sum of all errors. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`errorUpdateCount`](QueryObserverBaseResult.md#errorupdatecount) + +*** + +### errorUpdatedAt + +```ts +errorUpdatedAt: number; +``` + +Defined in: [packages/query-core/src/types.ts:784](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L784) + +The timestamp for when the query most recently returned the `status` as `"error"`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`errorUpdatedAt`](QueryObserverBaseResult.md#errorupdatedat) + +*** + +### failureCount + +```ts +failureCount: number; +``` + +Defined in: [packages/query-core/src/types.ts:790](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L790) + +The failure count for the query. +- Incremented every time the query fails. +- Reset to `0` when the query succeeds. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`failureCount`](QueryObserverBaseResult.md#failurecount) + +*** + +### failureReason + +```ts +failureReason: TError | null; +``` + +Defined in: [packages/query-core/src/types.ts:795](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L795) + +The failure reason for the query retry. +- Reset to `null` when the query succeeds. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`failureReason`](QueryObserverBaseResult.md#failurereason) + +*** + +### fetchStatus + +```ts +fetchStatus: FetchStatus; +``` + +Defined in: [packages/query-core/src/types.ts:889](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L889) + +The fetch status of the query. +- `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. +- `paused`: The query wanted to fetch, but has been `paused`. +- `idle`: The query is not fetching. +- See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`fetchStatus`](QueryObserverBaseResult.md#fetchstatus) + +*** + +### isEnabled + +```ts +isEnabled: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:867](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L867) + +`true` if this observer is enabled, `false` otherwise. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isEnabled`](QueryObserverBaseResult.md#isenabled) + +*** + +### isError + +```ts +isError: true; +``` + +Defined in: [packages/query-core/src/types.ts:945](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L945) + +A derived boolean from the `status` variable, provided for convenience. +- `true` if the query attempt resulted in an error. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isError`](QueryObserverBaseResult.md#iserror) + +*** + +### isFetched + +```ts +isFetched: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:808](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L808) + +Will be `true` if the query has been fetched. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isFetched`](QueryObserverBaseResult.md#isfetched) + +*** + +### isFetchedAfterMount + +```ts +isFetchedAfterMount: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:813](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L813) + +Will be `true` if the query has been fetched after the component mounted. +- This property can be used to not show any previously cached data. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isFetchedAfterMount`](QueryObserverBaseResult.md#isfetchedaftermount) + +*** + +### isFetching + +```ts +isFetching: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:818](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L818) + +A derived boolean from the `fetchStatus` variable, provided for convenience. +- `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isFetching`](QueryObserverBaseResult.md#isfetching) + +*** + +### ~~isInitialLoading~~ + +```ts +isInitialLoading: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:836](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L836) + +#### Deprecated + +`isInitialLoading` is being deprecated in favor of `isLoading` +and will be removed in the next major version. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isInitialLoading`](QueryObserverBaseResult.md#isinitialloading) + +*** + +### isLoading + +```ts +isLoading: false; +``` + +Defined in: [packages/query-core/src/types.ts:947](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L947) + +Is `true` whenever the first fetch for a query is in-flight. +- Is the same as `isFetching && isPending`. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoading`](QueryObserverBaseResult.md#isloading) + +*** + +### isLoadingError + +```ts +isLoadingError: false; +``` + +Defined in: [packages/query-core/src/types.ts:948](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L948) + +Will be `true` if the query failed while fetching for the first time. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoadingError`](QueryObserverBaseResult.md#isloadingerror) + +*** + +### isPaused + +```ts +isPaused: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:841](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L841) + +A derived boolean from the `fetchStatus` variable, provided for convenience. +- The query wanted to fetch, but has been `paused`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPaused`](QueryObserverBaseResult.md#ispaused) + +*** + +### isPending + +```ts +isPending: false; +``` + +Defined in: [packages/query-core/src/types.ts:946](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L946) + +Will be `pending` if there's no cached data and no query attempt was finished yet. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPending`](QueryObserverBaseResult.md#ispending) + +*** + +### isPlaceholderData + +```ts +isPlaceholderData: false; +``` + +Defined in: [packages/query-core/src/types.ts:951](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L951) + +Will be `true` if the data shown is the placeholder data. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPlaceholderData`](QueryObserverBaseResult.md#isplaceholderdata) + +*** + +### isRefetchError + +```ts +isRefetchError: true; +``` + +Defined in: [packages/query-core/src/types.ts:949](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L949) + +Will be `true` if the query failed while refetching. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetchError`](QueryObserverBaseResult.md#isrefetcherror) + +*** + +### isRefetching + +```ts +isRefetching: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:854](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L854) + +Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. +- Is the same as `isFetching && !isPending`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetching`](QueryObserverBaseResult.md#isrefetching) + +*** + +### isStale + +```ts +isStale: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:858](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L858) + +Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isStale`](QueryObserverBaseResult.md#isstale) + +*** + +### isSuccess + +```ts +isSuccess: false; +``` + +Defined in: [packages/query-core/src/types.ts:950](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L950) + +A derived boolean from the `status` variable, provided for convenience. +- `true` if the query has received a response with no errors and is ready to display its data. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isSuccess`](QueryObserverBaseResult.md#issuccess) + +*** + +### refetch() + +```ts +refetch: (options?) => Promise>; +``` + +Defined in: [packages/query-core/src/types.ts:871](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L871) + +A function to manually refetch the query. + +#### Parameters + +##### options? + +[`RefetchOptions`](RefetchOptions.md) + +#### Returns + +`Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`refetch`](QueryObserverBaseResult.md#refetch) + +*** + +### status + +```ts +status: "error"; +``` + +Defined in: [packages/query-core/src/types.ts:952](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L952) + +The status of the query. +- Will be: + - `pending` if there's no cached data and no query attempt was finished yet. + - `error` if the query attempt resulted in an error. + - `success` if the query has received a response with no errors and is ready to display its data. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`status`](QueryObserverBaseResult.md#status) diff --git a/docs/framework/lit/reference/interfaces/QueryObserverSuccessResult.md b/docs/framework/lit/reference/interfaces/QueryObserverSuccessResult.md new file mode 100644 index 00000000000..3942655c627 --- /dev/null +++ b/docs/framework/lit/reference/interfaces/QueryObserverSuccessResult.md @@ -0,0 +1,452 @@ +--- +id: QueryObserverSuccessResult +title: QueryObserverSuccessResult +--- + +Defined in: [packages/query-core/src/types.ts:955](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L955) + +## Extends + +- [`QueryObserverBaseResult`](QueryObserverBaseResult.md)\<`TData`, `TError`\> + +## Type Parameters + +### TData + +`TData` = `unknown` + +### TError + +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) + +## Properties + +### data + +```ts +data: TData; +``` + +Defined in: [packages/query-core/src/types.ts:959](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L959) + +The last successfully resolved data for the query. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`data`](QueryObserverBaseResult.md#data) + +*** + +### dataUpdatedAt + +```ts +dataUpdatedAt: number; +``` + +Defined in: [packages/query-core/src/types.ts:775](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L775) + +The timestamp for when the query most recently returned the `status` as `"success"`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`dataUpdatedAt`](QueryObserverBaseResult.md#dataupdatedat) + +*** + +### error + +```ts +error: null; +``` + +Defined in: [packages/query-core/src/types.ts:960](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L960) + +The error object for the query, if an error was thrown. +- Defaults to `null`. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`error`](QueryObserverBaseResult.md#error) + +*** + +### errorUpdateCount + +```ts +errorUpdateCount: number; +``` + +Defined in: [packages/query-core/src/types.ts:799](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L799) + +The sum of all errors. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`errorUpdateCount`](QueryObserverBaseResult.md#errorupdatecount) + +*** + +### errorUpdatedAt + +```ts +errorUpdatedAt: number; +``` + +Defined in: [packages/query-core/src/types.ts:784](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L784) + +The timestamp for when the query most recently returned the `status` as `"error"`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`errorUpdatedAt`](QueryObserverBaseResult.md#errorupdatedat) + +*** + +### failureCount + +```ts +failureCount: number; +``` + +Defined in: [packages/query-core/src/types.ts:790](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L790) + +The failure count for the query. +- Incremented every time the query fails. +- Reset to `0` when the query succeeds. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`failureCount`](QueryObserverBaseResult.md#failurecount) + +*** + +### failureReason + +```ts +failureReason: TError | null; +``` + +Defined in: [packages/query-core/src/types.ts:795](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L795) + +The failure reason for the query retry. +- Reset to `null` when the query succeeds. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`failureReason`](QueryObserverBaseResult.md#failurereason) + +*** + +### fetchStatus + +```ts +fetchStatus: FetchStatus; +``` + +Defined in: [packages/query-core/src/types.ts:889](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L889) + +The fetch status of the query. +- `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. +- `paused`: The query wanted to fetch, but has been `paused`. +- `idle`: The query is not fetching. +- See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`fetchStatus`](QueryObserverBaseResult.md#fetchstatus) + +*** + +### isEnabled + +```ts +isEnabled: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:867](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L867) + +`true` if this observer is enabled, `false` otherwise. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isEnabled`](QueryObserverBaseResult.md#isenabled) + +*** + +### isError + +```ts +isError: false; +``` + +Defined in: [packages/query-core/src/types.ts:961](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L961) + +A derived boolean from the `status` variable, provided for convenience. +- `true` if the query attempt resulted in an error. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isError`](QueryObserverBaseResult.md#iserror) + +*** + +### isFetched + +```ts +isFetched: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:808](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L808) + +Will be `true` if the query has been fetched. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isFetched`](QueryObserverBaseResult.md#isfetched) + +*** + +### isFetchedAfterMount + +```ts +isFetchedAfterMount: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:813](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L813) + +Will be `true` if the query has been fetched after the component mounted. +- This property can be used to not show any previously cached data. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isFetchedAfterMount`](QueryObserverBaseResult.md#isfetchedaftermount) + +*** + +### isFetching + +```ts +isFetching: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:818](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L818) + +A derived boolean from the `fetchStatus` variable, provided for convenience. +- `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isFetching`](QueryObserverBaseResult.md#isfetching) + +*** + +### ~~isInitialLoading~~ + +```ts +isInitialLoading: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:836](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L836) + +#### Deprecated + +`isInitialLoading` is being deprecated in favor of `isLoading` +and will be removed in the next major version. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isInitialLoading`](QueryObserverBaseResult.md#isinitialloading) + +*** + +### isLoading + +```ts +isLoading: false; +``` + +Defined in: [packages/query-core/src/types.ts:963](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L963) + +Is `true` whenever the first fetch for a query is in-flight. +- Is the same as `isFetching && isPending`. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoading`](QueryObserverBaseResult.md#isloading) + +*** + +### isLoadingError + +```ts +isLoadingError: false; +``` + +Defined in: [packages/query-core/src/types.ts:964](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L964) + +Will be `true` if the query failed while fetching for the first time. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoadingError`](QueryObserverBaseResult.md#isloadingerror) + +*** + +### isPaused + +```ts +isPaused: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:841](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L841) + +A derived boolean from the `fetchStatus` variable, provided for convenience. +- The query wanted to fetch, but has been `paused`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPaused`](QueryObserverBaseResult.md#ispaused) + +*** + +### isPending + +```ts +isPending: false; +``` + +Defined in: [packages/query-core/src/types.ts:962](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L962) + +Will be `pending` if there's no cached data and no query attempt was finished yet. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPending`](QueryObserverBaseResult.md#ispending) + +*** + +### isPlaceholderData + +```ts +isPlaceholderData: false; +``` + +Defined in: [packages/query-core/src/types.ts:967](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L967) + +Will be `true` if the data shown is the placeholder data. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPlaceholderData`](QueryObserverBaseResult.md#isplaceholderdata) + +*** + +### isRefetchError + +```ts +isRefetchError: false; +``` + +Defined in: [packages/query-core/src/types.ts:965](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L965) + +Will be `true` if the query failed while refetching. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetchError`](QueryObserverBaseResult.md#isrefetcherror) + +*** + +### isRefetching + +```ts +isRefetching: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:854](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L854) + +Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. +- Is the same as `isFetching && !isPending`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetching`](QueryObserverBaseResult.md#isrefetching) + +*** + +### isStale + +```ts +isStale: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:858](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L858) + +Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isStale`](QueryObserverBaseResult.md#isstale) + +*** + +### isSuccess + +```ts +isSuccess: true; +``` + +Defined in: [packages/query-core/src/types.ts:966](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L966) + +A derived boolean from the `status` variable, provided for convenience. +- `true` if the query has received a response with no errors and is ready to display its data. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isSuccess`](QueryObserverBaseResult.md#issuccess) + +*** + +### refetch() + +```ts +refetch: (options?) => Promise>; +``` + +Defined in: [packages/query-core/src/types.ts:871](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L871) + +A function to manually refetch the query. + +#### Parameters + +##### options? + +[`RefetchOptions`](RefetchOptions.md) + +#### Returns + +`Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`refetch`](QueryObserverBaseResult.md#refetch) + +*** + +### status + +```ts +status: "success"; +``` + +Defined in: [packages/query-core/src/types.ts:968](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L968) + +The status of the query. +- Will be: + - `pending` if there's no cached data and no query attempt was finished yet. + - `error` if the query attempt resulted in an error. + - `success` if the query has received a response with no errors and is ready to display its data. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`status`](QueryObserverBaseResult.md#status) diff --git a/docs/framework/lit/reference/interfaces/QueryOptions.md b/docs/framework/lit/reference/interfaces/QueryOptions.md new file mode 100644 index 00000000000..8d6124d5688 --- /dev/null +++ b/docs/framework/lit/reference/interfaces/QueryOptions.md @@ -0,0 +1,247 @@ +--- +id: QueryOptions +title: QueryOptions +--- + +Defined in: [packages/query-core/src/types.ts:231](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L231) + +## Type Parameters + +### TQueryFnData + +`TQueryFnData` = `unknown` + +### TError + +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) + +### TData + +`TData` = `TQueryFnData` + +### TQueryKey + +`TQueryKey` *extends* [`QueryKey`](../type-aliases/QueryKey.md) = [`QueryKey`](../type-aliases/QueryKey.md) + +### TPageParam + +`TPageParam` = `never` + +## Properties + +### gcTime? + +```ts +optional gcTime: number; +``` + +Defined in: [packages/query-core/src/types.ts:277](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L277) + +The time in milliseconds that unused/inactive cache data remains in memory. +When a query's cache becomes unused or inactive, that cache data will be garbage collected after this duration. +When different garbage collection times are specified, the longest one will be used. +Setting it to `Infinity` will disable garbage collection. + +Defaults to `5 * 60 * 1000` (5 minutes), or `Infinity` during SSR. + +Note: the maximum allowed time is about 24 days, imposed by `setTimeout`'s 32-bit signed integer delay — see +`timeoutManager.setTimeoutProvider` for a workaround. + +*** + +### initialData? + +```ts +optional initialData: + | TData +| InitialDataFunction; +``` + +Defined in: [packages/query-core/src/types.ts:317](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L317) + +If set, this value will be used as the initial data for the query cache (as long as the query hasn't been +created or cached yet). +If set to a function, the function will be called **once** during the shared/root query initialization, and be +expected to synchronously return the initial data. +Initial data is considered stale by default unless a `staleTime` has been set. +`initialData` **is persisted** to the cache. + +*** + +### initialDataUpdatedAt? + +```ts +optional initialDataUpdatedAt: number | () => number | undefined; +``` + +Defined in: [packages/query-core/src/types.ts:321](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L321) + +If set, this value will be used as the time (in milliseconds) of when the `initialData` itself was last updated. + +*** + +### maxPages? + +```ts +optional maxPages: number; +``` + +Defined in: [packages/query-core/src/types.ts:345](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L345) + +Maximum number of pages to store in the data of an infinite query. + +*** + +### meta? + +```ts +optional meta: Record; +``` + +Defined in: [packages/query-core/src/types.ts:341](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L341) + +Additional payload to be stored on each query. +Use this property to pass information that can be used in other places. + +*** + +### networkMode? + +```ts +optional networkMode: NetworkMode; +``` + +Defined in: [packages/query-core/src/types.ts:265](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L265) + +Controls whether a query is allowed to run based on the current network connectivity. + +Defaults to `'online'`. + +#### See + +[Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. + +*** + +### persister? + +```ts +optional persister: QueryPersister, TPageParam>; +``` + +Defined in: [packages/query-core/src/types.ts:290](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L290) + +This option can be used to persist the result of a query to an external storage, bypassing the need to actually +call the `queryFn`. Useful for persisting a query's data across e.g. server/client boundaries. + +*** + +### queryFn? + +```ts +optional queryFn: + | QueryFunction + | typeof skipToken; +``` + +Defined in: [packages/query-core/src/types.ts:285](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L285) + +The function that the query will use to request data. +Required, unless a default query function has been set via `queryClient.setQueryDefaults` or +`queryClient.setDefaultOptions`. +Receives a [QueryFunctionContext](../type-aliases/QueryFunctionContext.md). +Must return a promise that will either resolve data or throw an error. The data cannot be `undefined`. + +*** + +### queryHash? + +```ts +optional queryHash: string; +``` + +Defined in: [packages/query-core/src/types.ts:295](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L295) + +The hashed form of `queryKey`, computed with `queryKeyHashFn` (or the default hashing function otherwise). Used +as the actual cache key internally. + +*** + +### queryKey? + +```ts +optional queryKey: TQueryKey; +``` + +Defined in: [packages/query-core/src/types.ts:304](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L304) + +The query key to use for this query. + +The query key will be hashed into a stable hash. See [Query Keys](https://tanstack.com/query/latest/docs/framework/react/guides/query-keys) +for more information. + +The query will automatically update when this key changes (as long as `enabled` is not set to `false`). + +*** + +### queryKeyHashFn? + +```ts +optional queryKeyHashFn: QueryKeyHashFunction; +``` + +Defined in: [packages/query-core/src/types.ts:308](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L308) + +If specified, this function is used to hash the `queryKey` to a string. + +*** + +### retry? + +```ts +optional retry: RetryValue; +``` + +Defined in: [packages/query-core/src/types.ts:246](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L246) + +If `false`, failed queries will not retry by default. +If `true`, failed queries will retry infinitely. +If set to an integer number, e.g. 3, failed queries will retry until the failed query count meets that number. +If set to a function `(failureCount, error) => boolean` failed queries will retry until the function returns false. + +Defaults to `3` on the client and `0` on the server. + +*** + +### retryDelay? + +```ts +optional retryDelay: RetryDelayValue; +``` + +Defined in: [packages/query-core/src/types.ts:258](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L258) + +This function receives a `retryAttempt` integer and the actual Error and returns the delay to apply before the +next attempt in milliseconds. + +A function like `attempt => Math.min(attempt > 1 ? 2 ** attempt * 1000 : 1000, 30 * 1000)` applies exponential +backoff. + +A function like `attempt => attempt * 1000` applies linear backoff. + +Defaults to a function that applies exponential backoff, capped at 30 seconds. + +*** + +### structuralSharing? + +```ts +optional structuralSharing: boolean | (oldData, newData) => unknown; +``` + +Defined in: [packages/query-core/src/types.ts:330](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L330) + +Set this to `false` to disable structural sharing between query results. +Set this to a function which accepts the old and new data and returns resolved data of the same type to implement custom structural sharing logic. + +Defaults to `true`. diff --git a/docs/framework/lit/reference/interfaces/QueryState.md b/docs/framework/lit/reference/interfaces/QueryState.md new file mode 100644 index 00000000000..7dce476d743 --- /dev/null +++ b/docs/framework/lit/reference/interfaces/QueryState.md @@ -0,0 +1,175 @@ +--- +id: QueryState +title: QueryState +--- + +Defined in: [packages/query-core/src/query.ts:52](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L52) + +The raw state stored on a `Query` instance. This is the underlying state +that observer results (e.g. `QueryObserverResult`) are derived from. + +## Type Parameters + +### TData + +`TData` = `unknown` + +### TError + +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) + +## Properties + +### data + +```ts +data: TData | undefined; +``` + +Defined in: [packages/query-core/src/query.ts:56](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L56) + +The last successfully resolved data for the query. + +*** + +### dataUpdateCount + +```ts +dataUpdateCount: number; +``` + +Defined in: [packages/query-core/src/query.ts:60](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L60) + +The number of times the query has successfully resolved. + +*** + +### dataUpdatedAt + +```ts +dataUpdatedAt: number; +``` + +Defined in: [packages/query-core/src/query.ts:64](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L64) + +The timestamp for when the query most recently returned the `status` as `"success"`. + +*** + +### error + +```ts +error: TError | null; +``` + +Defined in: [packages/query-core/src/query.ts:69](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L69) + +The error object for the query, if the last attempt resulted in an error. +- Defaults to `null`. + +*** + +### errorUpdateCount + +```ts +errorUpdateCount: number; +``` + +Defined in: [packages/query-core/src/query.ts:73](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L73) + +The sum of all errors, incremented every time the query resolves with an error. + +*** + +### errorUpdatedAt + +```ts +errorUpdatedAt: number; +``` + +Defined in: [packages/query-core/src/query.ts:77](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L77) + +The timestamp for when the query most recently returned the `status` as `"error"`. + +*** + +### fetchFailureCount + +```ts +fetchFailureCount: number; +``` + +Defined in: [packages/query-core/src/query.ts:83](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L83) + +The failure count for the current fetch. +- Incremented every time the fetch fails. +- Reset to `0` when the fetch succeeds. + +*** + +### fetchFailureReason + +```ts +fetchFailureReason: TError | null; +``` + +Defined in: [packages/query-core/src/query.ts:88](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L88) + +The reason the current fetch failed, as reported by the retryer. +- Reset to `null` when the fetch succeeds. + +*** + +### fetchMeta + +```ts +fetchMeta: FetchMeta | null; +``` + +Defined in: [packages/query-core/src/query.ts:93](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L93) + +Metadata passed to the currently in-flight (or most recent) fetch, e.g. the +`fetchMore` direction for infinite queries. + +*** + +### fetchStatus + +```ts +fetchStatus: FetchStatus; +``` + +Defined in: [packages/query-core/src/query.ts:112](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L112) + +The fetch status of the query. +- `fetching`: the `queryFn` is currently executing. +- `paused`: a fetch wanted to run but has been paused (see network mode). +- `idle`: the query is not fetching. + +*** + +### isInvalidated + +```ts +isInvalidated: boolean; +``` + +Defined in: [packages/query-core/src/query.ts:98](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L98) + +Whether the query has been marked as invalidated via `invalidate()`. +- Reset to `false` whenever the query resolves successfully. + +*** + +### status + +```ts +status: QueryStatus; +``` + +Defined in: [packages/query-core/src/query.ts:105](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L105) + +The status of the query. +- `pending` if there's no cached data and no attempt was finished yet. +- `error` if the last attempt resulted in an error. +- `success` if the query has data. diff --git a/docs/framework/lit/reference/interfaces/RefetchOptions.md b/docs/framework/lit/reference/interfaces/RefetchOptions.md new file mode 100644 index 00000000000..cfcc0498799 --- /dev/null +++ b/docs/framework/lit/reference/interfaces/RefetchOptions.md @@ -0,0 +1,50 @@ +--- +id: RefetchOptions +title: RefetchOptions +--- + +Defined in: [packages/query-core/src/types.ts:704](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L704) + +## Extends + +- [`ResultOptions`](ResultOptions.md) + +## Extended by + +- [`InvalidateOptions`](InvalidateOptions.md) +- [`ResetOptions`](ResetOptions.md) + +## Properties + +### cancelRefetch? + +```ts +optional cancelRefetch: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:712](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L712) + +If set to `true`, a currently running request will be cancelled before a new request is made + +If set to `false`, no refetch will be made if there is already a request running. + +Defaults to `true`. + +*** + +### throwOnError? + +```ts +optional throwOnError: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:701](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L701) + +If set to `true`, the method throws if any of the underlying query refetch tasks fail. + +Defaults to `false`, in which case failed refetches are swallowed and not surfaced to the +caller. + +#### Inherited from + +[`ResultOptions`](ResultOptions.md).[`throwOnError`](ResultOptions.md#throwonerror) diff --git a/docs/framework/lit/reference/interfaces/RefetchQueryFilters.md b/docs/framework/lit/reference/interfaces/RefetchQueryFilters.md new file mode 100644 index 00000000000..c45dfa953f1 --- /dev/null +++ b/docs/framework/lit/reference/interfaces/RefetchQueryFilters.md @@ -0,0 +1,127 @@ +--- +id: RefetchQueryFilters +title: RefetchQueryFilters +--- + +Defined in: [packages/query-core/src/types.ts:730](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L730) + +Filters used to select queries, for example in `queryClient.getQueriesData` or `queryClient.invalidateQueries`. +All provided filters must match; filters that are left unspecified are ignored. + +## Extends + +- [`QueryFilters`](QueryFilters.md)\<`TQueryKey`\> + +## Type Parameters + +### TQueryKey + +`TQueryKey` *extends* [`QueryKey`](../type-aliases/QueryKey.md) = [`QueryKey`](../type-aliases/QueryKey.md) + +## Properties + +### exact? + +```ts +optional exact: boolean; +``` + +Defined in: [packages/query-core/src/utils.ts:41](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L41) + +Match query key exactly + +#### Inherited from + +[`QueryFilters`](QueryFilters.md).[`exact`](QueryFilters.md#exact) + +*** + +### fetchStatus? + +```ts +optional fetchStatus: FetchStatus; +``` + +Defined in: [packages/query-core/src/utils.ts:57](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L57) + +Include queries matching their fetchStatus + +#### Inherited from + +[`QueryFilters`](QueryFilters.md).[`fetchStatus`](QueryFilters.md#fetchstatus) + +*** + +### predicate()? + +```ts +optional predicate: (query) => boolean; +``` + +Defined in: [packages/query-core/src/utils.ts:45](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L45) + +Include queries matching this predicate function + +#### Parameters + +##### query + +[`Query`](../classes/Query.md) + +#### Returns + +`boolean` + +#### Inherited from + +[`QueryFilters`](QueryFilters.md).[`predicate`](QueryFilters.md#predicate) + +*** + +### queryKey? + +```ts +optional queryKey: TQueryKey | TuplePrefixes; +``` + +Defined in: [packages/query-core/src/utils.ts:49](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L49) + +Include queries matching this query key + +#### Inherited from + +[`QueryFilters`](QueryFilters.md).[`queryKey`](QueryFilters.md#querykey) + +*** + +### stale? + +```ts +optional stale: boolean; +``` + +Defined in: [packages/query-core/src/utils.ts:53](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L53) + +Include or exclude stale queries + +#### Inherited from + +[`QueryFilters`](QueryFilters.md).[`stale`](QueryFilters.md#stale) + +*** + +### type? + +```ts +optional type: QueryTypeFilter; +``` + +Defined in: [packages/query-core/src/utils.ts:37](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L37) + +Filter to active queries, inactive queries or all queries + +Defaults to `'all'`. + +#### Inherited from + +[`QueryFilters`](QueryFilters.md).[`type`](QueryFilters.md#type) diff --git a/docs/framework/lit/reference/interfaces/Register.md b/docs/framework/lit/reference/interfaces/Register.md new file mode 100644 index 00000000000..4f442442b48 --- /dev/null +++ b/docs/framework/lit/reference/interfaces/Register.md @@ -0,0 +1,6 @@ +--- +id: Register +title: Register +--- + +Defined in: [packages/query-core/src/types.ts:37](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L37) diff --git a/docs/framework/lit/reference/interfaces/ResetOptions.md b/docs/framework/lit/reference/interfaces/ResetOptions.md new file mode 100644 index 00000000000..9f12324ba27 --- /dev/null +++ b/docs/framework/lit/reference/interfaces/ResetOptions.md @@ -0,0 +1,49 @@ +--- +id: ResetOptions +title: ResetOptions +--- + +Defined in: [packages/query-core/src/types.ts:735](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L735) + +## Extends + +- [`RefetchOptions`](RefetchOptions.md) + +## Properties + +### cancelRefetch? + +```ts +optional cancelRefetch: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:712](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L712) + +If set to `true`, a currently running request will be cancelled before a new request is made + +If set to `false`, no refetch will be made if there is already a request running. + +Defaults to `true`. + +#### Inherited from + +[`RefetchOptions`](RefetchOptions.md).[`cancelRefetch`](RefetchOptions.md#cancelrefetch) + +*** + +### throwOnError? + +```ts +optional throwOnError: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:701](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L701) + +If set to `true`, the method throws if any of the underlying query refetch tasks fail. + +Defaults to `false`, in which case failed refetches are swallowed and not surfaced to the +caller. + +#### Inherited from + +[`RefetchOptions`](RefetchOptions.md).[`throwOnError`](RefetchOptions.md#throwonerror) diff --git a/docs/framework/lit/reference/interfaces/ResultOptions.md b/docs/framework/lit/reference/interfaces/ResultOptions.md new file mode 100644 index 00000000000..42917f20bf0 --- /dev/null +++ b/docs/framework/lit/reference/interfaces/ResultOptions.md @@ -0,0 +1,27 @@ +--- +id: ResultOptions +title: ResultOptions +--- + +Defined in: [packages/query-core/src/types.ts:694](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L694) + +## Extended by + +- [`RefetchOptions`](RefetchOptions.md) +- [`FetchNextPageOptions`](FetchNextPageOptions.md) +- [`FetchPreviousPageOptions`](FetchPreviousPageOptions.md) + +## Properties + +### throwOnError? + +```ts +optional throwOnError: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:701](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L701) + +If set to `true`, the method throws if any of the underlying query refetch tasks fail. + +Defaults to `false`, in which case failed refetches are swallowed and not surfaced to the +caller. diff --git a/docs/framework/lit/reference/interfaces/SetDataOptions.md b/docs/framework/lit/reference/interfaces/SetDataOptions.md new file mode 100644 index 00000000000..bb668fbf162 --- /dev/null +++ b/docs/framework/lit/reference/interfaces/SetDataOptions.md @@ -0,0 +1,16 @@ +--- +id: SetDataOptions +title: SetDataOptions +--- + +Defined in: [packages/query-core/src/types.ts:1526](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1526) + +## Properties + +### updatedAt? + +```ts +optional updatedAt: number; +``` + +Defined in: [packages/query-core/src/types.ts:1527](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1527) diff --git a/docs/framework/lit/reference/interfaces/TimeoutManager.md b/docs/framework/lit/reference/interfaces/TimeoutManager.md new file mode 100644 index 00000000000..95ff07b2ccc --- /dev/null +++ b/docs/framework/lit/reference/interfaces/TimeoutManager.md @@ -0,0 +1,246 @@ +--- +id: TimeoutManager +title: TimeoutManager +--- + +Defined in: [packages/query-core/src/timeoutManager.ts:70](https://github.com/TanStack/query/blob/main/packages/query-core/src/timeoutManager.ts#L70) + +Allows customization of how timeouts are created. + +@tanstack/query-core makes liberal use of timeouts to implement `staleTime` +and `gcTime`. The default TimeoutManager provider uses the platform's global +`setTimeout` implementation, which is known to have scalability issues with +thousands of timeouts on the event loop. + +If you hit this limitation, consider providing a custom TimeoutProvider that +coalesces timeouts. + +## Implements + +- `Omit`\<[`TimeoutProvider`](../type-aliases/TimeoutProvider.md), `"name"`\> + +## Methods + +### clearInterval() + +```ts +clearInterval(intervalId): void; +``` + +Defined in: [packages/query-core/src/timeoutManager.ts:224](https://github.com/TanStack/query/blob/main/packages/query-core/src/timeoutManager.ts#L224) + +`clearInterval` can be used to cancel an interval, like the global +`clearInterval` function. It should be called with an interval ID +returned by `setInterval`. + +#### Parameters + +##### intervalId + +[`ManagedTimerId`](../type-aliases/ManagedTimerId.md) | `undefined` + +#### Returns + +`void` + +#### Example + +```ts +import { timeoutManager } from '@tanstack/query-core' + +const intervalId = timeoutManager.setInterval( + () => console.log('ran at:', new Date()), + 1000, +) + +timeoutManager.clearInterval(intervalId) +``` + +#### Implementation of + +[`TimeoutProvider`](../type-aliases/TimeoutProvider.md).[`clearInterval`](../type-aliases/TimeoutProvider.md#clearinterval) + +*** + +### clearTimeout() + +```ts +clearTimeout(timeoutId): void; +``` + +Defined in: [packages/query-core/src/timeoutManager.ts:179](https://github.com/TanStack/query/blob/main/packages/query-core/src/timeoutManager.ts#L179) + +`clearTimeout` cancels a timeout callback scheduled with `setTimeout`, +like the global `clearTimeout` function. It should be called with a +timer ID returned by `setTimeout`. + +#### Parameters + +##### timeoutId + +[`ManagedTimerId`](../type-aliases/ManagedTimerId.md) | `undefined` + +#### Returns + +`void` + +#### Example + +```ts +import { timeoutManager } from '@tanstack/query-core' + +const timeoutId = timeoutManager.setTimeout( + () => console.log('ran at:', new Date()), + 1000, +) + +timeoutManager.clearTimeout(timeoutId) +``` + +#### Implementation of + +[`TimeoutProvider`](../type-aliases/TimeoutProvider.md).[`clearTimeout`](../type-aliases/TimeoutProvider.md#cleartimeout) + +*** + +### setInterval() + +```ts +setInterval(callback, delay): ManagedTimerId; +``` + +Defined in: [packages/query-core/src/timeoutManager.ts:200](https://github.com/TanStack/query/blob/main/packages/query-core/src/timeoutManager.ts#L200) + +`setInterval` schedules a callback to be called approximately every +`delay` milliseconds, like the global `setInterval` function. + +Like `setTimeout`, it returns a timer ID, which may be a number or an +object that can be coerced to a number via `Symbol.toPrimitive`. + +#### Parameters + +##### callback + +[`TimeoutCallback`](../type-aliases/TimeoutCallback.md) + +##### delay + +`number` + +#### Returns + +[`ManagedTimerId`](../type-aliases/ManagedTimerId.md) + +#### Example + +```ts +import { timeoutManager } from '@tanstack/query-core' + +const intervalId = timeoutManager.setInterval( + () => console.log('ran at:', new Date()), + 1000, +) +``` + +#### Implementation of + +[`TimeoutProvider`](../type-aliases/TimeoutProvider.md).[`setInterval`](../type-aliases/TimeoutProvider.md#setinterval) + +*** + +### setTimeout() + +```ts +setTimeout(callback, delay): ManagedTimerId; +``` + +Defined in: [packages/query-core/src/timeoutManager.ts:155](https://github.com/TanStack/query/blob/main/packages/query-core/src/timeoutManager.ts#L155) + +`setTimeout` schedules a callback to run after approximately `delay` +milliseconds, like the global `setTimeout` function. The callback can be +canceled with `clearTimeout`. + +It returns a timer ID, which may be a number or an object that can be +coerced to a number via `Symbol.toPrimitive`. + +#### Parameters + +##### callback + +[`TimeoutCallback`](../type-aliases/TimeoutCallback.md) + +##### delay + +`number` + +#### Returns + +[`ManagedTimerId`](../type-aliases/ManagedTimerId.md) + +#### Example + +```ts +import { timeoutManager } from '@tanstack/query-core' + +const timeoutId = timeoutManager.setTimeout( + () => console.log('ran at:', new Date()), + 1000, +) + +const timeoutIdNumber: number = Number(timeoutId) +``` + +#### Implementation of + +[`TimeoutProvider`](../type-aliases/TimeoutProvider.md).[`setTimeout`](../type-aliases/TimeoutProvider.md#settimeout) + +*** + +### setTimeoutProvider() + +```ts +setTimeoutProvider(provider): void; +``` + +Defined in: [packages/query-core/src/timeoutManager.ts:106](https://github.com/TanStack/query/blob/main/packages/query-core/src/timeoutManager.ts#L106) + +`setTimeoutProvider` can be used to set a custom implementation of the +`setTimeout`, `clearTimeout`, `setInterval`, `clearInterval` functions, +called a `TimeoutProvider`. + +This may be useful if you notice event loop performance issues with +thousands of queries. A custom TimeoutProvider could also support timer +delays longer than the global `setTimeout` maximum delay value of about +24 days. + +It is important to call `setTimeoutProvider` before creating a +QueryClient or queries, so that the same provider is used consistently +for all timers in the application, since different TimeoutProviders +cannot cancel each others' timers. + +#### Type Parameters + +##### TTimerId + +`TTimerId` *extends* [`ManagedTimerId`](../type-aliases/ManagedTimerId.md) + +#### Parameters + +##### provider + +[`TimeoutProvider`](../type-aliases/TimeoutProvider.md)\<`TTimerId`\> + +#### Returns + +`void` + +#### Example + +```ts +import { timeoutManager, QueryClient } from '@tanstack/query-core' +import { CustomTimeoutProvider } from './CustomTimeoutProvider' + +timeoutManager.setTimeoutProvider(new CustomTimeoutProvider()) + +export const queryClient = new QueryClient() +``` diff --git a/docs/framework/lit/reference/type-aliases/AnyDataTag.md b/docs/framework/lit/reference/type-aliases/AnyDataTag.md new file mode 100644 index 00000000000..d3d5e33bb3e --- /dev/null +++ b/docs/framework/lit/reference/type-aliases/AnyDataTag.md @@ -0,0 +1,30 @@ +--- +id: AnyDataTag +title: AnyDataTag +--- + +```ts +type AnyDataTag = object; +``` + +Defined in: [packages/query-core/src/types.ts:67](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L67) + +## Properties + +### \[dataTagErrorSymbol\] + +```ts +[dataTagErrorSymbol]: any; +``` + +Defined in: [packages/query-core/src/types.ts:69](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L69) + +*** + +### \[dataTagSymbol\] + +```ts +[dataTagSymbol]: any; +``` + +Defined in: [packages/query-core/src/types.ts:68](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L68) diff --git a/docs/framework/lit/reference/type-aliases/CreateInfiniteQueryOptions.md b/docs/framework/lit/reference/type-aliases/CreateInfiniteQueryOptions.md index 0c0ea871be5..559a092fd7e 100644 --- a/docs/framework/lit/reference/type-aliases/CreateInfiniteQueryOptions.md +++ b/docs/framework/lit/reference/type-aliases/CreateInfiniteQueryOptions.md @@ -22,15 +22,15 @@ directly or through an `Accessor` when the options depend on Lit host state. ### TError -`TError` = `DefaultError` +`TError` = [`DefaultError`](DefaultError.md) ### TData -`TData` = `InfiniteData`\<`TQueryFnData`\> +`TData` = [`InfiniteData`](../interfaces/InfiniteData.md)\<`TQueryFnData`\> ### TQueryKey -`TQueryKey` *extends* `QueryKey` = `QueryKey` +`TQueryKey` *extends* [`QueryKey`](QueryKey.md) = [`QueryKey`](QueryKey.md) ### TPageParam diff --git a/docs/framework/lit/reference/type-aliases/CreateMutationOptions.md b/docs/framework/lit/reference/type-aliases/CreateMutationOptions.md index cc70eefe405..e240c803930 100644 --- a/docs/framework/lit/reference/type-aliases/CreateMutationOptions.md +++ b/docs/framework/lit/reference/type-aliases/CreateMutationOptions.md @@ -22,7 +22,7 @@ or through an `Accessor` when the options depend on Lit host state. ### TError -`TError` = `DefaultError` +`TError` = [`DefaultError`](DefaultError.md) ### TVariables diff --git a/docs/framework/lit/reference/type-aliases/CreateQueriesInput.md b/docs/framework/lit/reference/type-aliases/CreateQueriesInput.md index 75c47d1435f..4083ef175ff 100644 --- a/docs/framework/lit/reference/type-aliases/CreateQueriesInput.md +++ b/docs/framework/lit/reference/type-aliases/CreateQueriesInput.md @@ -22,7 +22,7 @@ maps each input query to its corresponding result. ### TError -`TError` = `DefaultError` +`TError` = [`DefaultError`](DefaultError.md) ### TData @@ -30,4 +30,4 @@ maps each input query to its corresponding result. ### TQueryKey -`TQueryKey` *extends* `QueryKey` = `QueryKey` +`TQueryKey` *extends* [`QueryKey`](QueryKey.md) = [`QueryKey`](QueryKey.md) diff --git a/docs/framework/lit/reference/type-aliases/CreateQueryOptions.md b/docs/framework/lit/reference/type-aliases/CreateQueryOptions.md index 9f911a32744..95f19e25e8f 100644 --- a/docs/framework/lit/reference/type-aliases/CreateQueryOptions.md +++ b/docs/framework/lit/reference/type-aliases/CreateQueryOptions.md @@ -23,7 +23,7 @@ options depend on Lit host state. ### TError -`TError` = `DefaultError` +`TError` = [`DefaultError`](DefaultError.md) ### TData @@ -35,4 +35,4 @@ options depend on Lit host state. ### TQueryKey -`TQueryKey` *extends* `QueryKey` = `QueryKey` +`TQueryKey` *extends* [`QueryKey`](QueryKey.md) = [`QueryKey`](QueryKey.md) diff --git a/docs/framework/lit/reference/type-aliases/DataTag.md b/docs/framework/lit/reference/type-aliases/DataTag.md new file mode 100644 index 00000000000..904ca124464 --- /dev/null +++ b/docs/framework/lit/reference/type-aliases/DataTag.md @@ -0,0 +1,24 @@ +--- +id: DataTag +title: DataTag +--- + +```ts +type DataTag = TType extends AnyDataTag ? TType : TType & object; +``` + +Defined in: [packages/query-core/src/types.ts:71](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L71) + +## Type Parameters + +### TType + +`TType` + +### TValue + +`TValue` + +### TError + +`TError` = [`UnsetMarker`](UnsetMarker.md) diff --git a/docs/framework/lit/reference/type-aliases/DefaultError.md b/docs/framework/lit/reference/type-aliases/DefaultError.md new file mode 100644 index 00000000000..da9f615482f --- /dev/null +++ b/docs/framework/lit/reference/type-aliases/DefaultError.md @@ -0,0 +1,10 @@ +--- +id: DefaultError +title: DefaultError +--- + +```ts +type DefaultError = Register extends object ? TError : Error; +``` + +Defined in: [packages/query-core/src/types.ts:45](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L45) diff --git a/docs/framework/lit/reference/type-aliases/DefaultedInfiniteQueryObserverOptions.md b/docs/framework/lit/reference/type-aliases/DefaultedInfiniteQueryObserverOptions.md new file mode 100644 index 00000000000..82c7ddbb886 --- /dev/null +++ b/docs/framework/lit/reference/type-aliases/DefaultedInfiniteQueryObserverOptions.md @@ -0,0 +1,32 @@ +--- +id: DefaultedInfiniteQueryObserverOptions +title: DefaultedInfiniteQueryObserverOptions +--- + +```ts +type DefaultedInfiniteQueryObserverOptions = WithRequired, "throwOnError" | "refetchOnReconnect" | "queryHash">; +``` + +Defined in: [packages/query-core/src/types.ts:557](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L557) + +## Type Parameters + +### TQueryFnData + +`TQueryFnData` = `unknown` + +### TError + +`TError` = [`DefaultError`](DefaultError.md) + +### TData + +`TData` = `TQueryFnData` + +### TQueryKey + +`TQueryKey` *extends* [`QueryKey`](QueryKey.md) = [`QueryKey`](QueryKey.md) + +### TPageParam + +`TPageParam` = `unknown` diff --git a/docs/framework/lit/reference/type-aliases/DefaultedQueryObserverOptions.md b/docs/framework/lit/reference/type-aliases/DefaultedQueryObserverOptions.md new file mode 100644 index 00000000000..7687d8c24f6 --- /dev/null +++ b/docs/framework/lit/reference/type-aliases/DefaultedQueryObserverOptions.md @@ -0,0 +1,32 @@ +--- +id: DefaultedQueryObserverOptions +title: DefaultedQueryObserverOptions +--- + +```ts +type DefaultedQueryObserverOptions = WithRequired, "throwOnError" | "refetchOnReconnect" | "queryHash">; +``` + +Defined in: [packages/query-core/src/types.ts:528](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L528) + +## Type Parameters + +### TQueryFnData + +`TQueryFnData` = `unknown` + +### TError + +`TError` = [`DefaultError`](DefaultError.md) + +### TData + +`TData` = `TQueryFnData` + +### TQueryData + +`TQueryData` = `TQueryFnData` + +### TQueryKey + +`TQueryKey` *extends* [`QueryKey`](QueryKey.md) = [`QueryKey`](QueryKey.md) diff --git a/docs/framework/lit/reference/type-aliases/DefinedInfiniteQueryObserverResult.md b/docs/framework/lit/reference/type-aliases/DefinedInfiniteQueryObserverResult.md new file mode 100644 index 00000000000..605bf55cec2 --- /dev/null +++ b/docs/framework/lit/reference/type-aliases/DefinedInfiniteQueryObserverResult.md @@ -0,0 +1,22 @@ +--- +id: DefinedInfiniteQueryObserverResult +title: DefinedInfiniteQueryObserverResult +--- + +```ts +type DefinedInfiniteQueryObserverResult = + | InfiniteQueryObserverRefetchErrorResult +| InfiniteQueryObserverSuccessResult; +``` + +Defined in: [packages/query-core/src/types.ts:1148](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1148) + +## Type Parameters + +### TData + +`TData` = `unknown` + +### TError + +`TError` = [`DefaultError`](DefaultError.md) diff --git a/docs/framework/lit/reference/type-aliases/DefinedInitialDataOptions.md b/docs/framework/lit/reference/type-aliases/DefinedInitialDataOptions.md index a263fa6afe8..f2be44efd8a 100644 --- a/docs/framework/lit/reference/type-aliases/DefinedInitialDataOptions.md +++ b/docs/framework/lit/reference/type-aliases/DefinedInitialDataOptions.md @@ -35,7 +35,7 @@ optional queryFn: QueryFunction; ### TError -`TError` = `DefaultError` +`TError` = [`DefaultError`](DefaultError.md) ### TData @@ -43,4 +43,4 @@ optional queryFn: QueryFunction; ### TQueryKey -`TQueryKey` *extends* `QueryKey` = `QueryKey` +`TQueryKey` *extends* [`QueryKey`](QueryKey.md) = [`QueryKey`](QueryKey.md) diff --git a/docs/framework/lit/reference/type-aliases/DefinedQueryObserverResult.md b/docs/framework/lit/reference/type-aliases/DefinedQueryObserverResult.md new file mode 100644 index 00000000000..f863eaa925e --- /dev/null +++ b/docs/framework/lit/reference/type-aliases/DefinedQueryObserverResult.md @@ -0,0 +1,22 @@ +--- +id: DefinedQueryObserverResult +title: DefinedQueryObserverResult +--- + +```ts +type DefinedQueryObserverResult = + | QueryObserverRefetchErrorResult +| QueryObserverSuccessResult; +``` + +Defined in: [packages/query-core/src/types.ts:987](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L987) + +## Type Parameters + +### TData + +`TData` = `unknown` + +### TError + +`TError` = [`DefaultError`](DefaultError.md) diff --git a/docs/framework/lit/reference/type-aliases/DistributiveOmit.md b/docs/framework/lit/reference/type-aliases/DistributiveOmit.md new file mode 100644 index 00000000000..33b87a5cd6e --- /dev/null +++ b/docs/framework/lit/reference/type-aliases/DistributiveOmit.md @@ -0,0 +1,20 @@ +--- +id: DistributiveOmit +title: DistributiveOmit +--- + +```ts +type DistributiveOmit = TObject extends any ? Omit : never; +``` + +Defined in: [packages/query-core/src/types.ts:14](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L14) + +## Type Parameters + +### TObject + +`TObject` + +### TKey + +`TKey` *extends* keyof `TObject` diff --git a/docs/framework/lit/reference/type-aliases/EnsureInfiniteQueryDataOptions.md b/docs/framework/lit/reference/type-aliases/EnsureInfiniteQueryDataOptions.md new file mode 100644 index 00000000000..7648331fca2 --- /dev/null +++ b/docs/framework/lit/reference/type-aliases/EnsureInfiniteQueryDataOptions.md @@ -0,0 +1,42 @@ +--- +id: EnsureInfiniteQueryDataOptions +title: EnsureInfiniteQueryDataOptions +--- + +```ts +type EnsureInfiniteQueryDataOptions = FetchInfiniteQueryOptions & object; +``` + +Defined in: [packages/query-core/src/types.ts:631](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L631) + +## Type Declaration + +### ~~revalidateIfStale?~~ + +```ts +optional revalidateIfStale: boolean; +``` + +## Type Parameters + +### TQueryFnData + +`TQueryFnData` = `unknown` + +### TError + +`TError` = [`DefaultError`](DefaultError.md) + +### TData + +`TData` = `TQueryFnData` + +### TQueryKey + +`TQueryKey` *extends* [`QueryKey`](QueryKey.md) = [`QueryKey`](QueryKey.md) + +### TPageParam + +`TPageParam` = `unknown` + +## Deprecated diff --git a/docs/framework/lit/reference/type-aliases/FetchInfiniteQueryOptions.md b/docs/framework/lit/reference/type-aliases/FetchInfiniteQueryOptions.md new file mode 100644 index 00000000000..d00a2455889 --- /dev/null +++ b/docs/framework/lit/reference/type-aliases/FetchInfiniteQueryOptions.md @@ -0,0 +1,34 @@ +--- +id: FetchInfiniteQueryOptions +title: FetchInfiniteQueryOptions +--- + +```ts +type FetchInfiniteQueryOptions = Omit, TQueryKey, TPageParam>, "initialPageParam"> & InitialPageParam & InfiniteQueryPages; +``` + +Defined in: [packages/query-core/src/types.ts:675](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L675) + +## Type Parameters + +### TQueryFnData + +`TQueryFnData` = `unknown` + +### TError + +`TError` = [`DefaultError`](DefaultError.md) + +### TData + +`TData` = `TQueryFnData` + +### TQueryKey + +`TQueryKey` *extends* [`QueryKey`](QueryKey.md) = [`QueryKey`](QueryKey.md) + +### TPageParam + +`TPageParam` = `unknown` + +## Deprecated diff --git a/docs/framework/lit/reference/type-aliases/FetchStatus.md b/docs/framework/lit/reference/type-aliases/FetchStatus.md new file mode 100644 index 00000000000..d50002355ca --- /dev/null +++ b/docs/framework/lit/reference/type-aliases/FetchStatus.md @@ -0,0 +1,10 @@ +--- +id: FetchStatus +title: FetchStatus +--- + +```ts +type FetchStatus = "fetching" | "paused" | "idle"; +``` + +Defined in: [packages/query-core/src/types.ts:762](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L762) diff --git a/docs/framework/lit/reference/type-aliases/GetNextPageParamFunction.md b/docs/framework/lit/reference/type-aliases/GetNextPageParamFunction.md new file mode 100644 index 00000000000..81d1a1544ab --- /dev/null +++ b/docs/framework/lit/reference/type-aliases/GetNextPageParamFunction.md @@ -0,0 +1,42 @@ +--- +id: GetNextPageParamFunction +title: GetNextPageParamFunction +--- + +```ts +type GetNextPageParamFunction = (lastPage, allPages, lastPageParam, allPageParams) => TPageParam | undefined | null; +``` + +Defined in: [packages/query-core/src/types.ts:203](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L203) + +## Type Parameters + +### TPageParam + +`TPageParam` + +### TQueryFnData + +`TQueryFnData` = `unknown` + +## Parameters + +### lastPage + +`TQueryFnData` + +### allPages + +`TQueryFnData`[] + +### lastPageParam + +`TPageParam` + +### allPageParams + +`TPageParam`[] + +## Returns + +`TPageParam` \| `undefined` \| `null` diff --git a/docs/framework/lit/reference/type-aliases/GetPreviousPageParamFunction.md b/docs/framework/lit/reference/type-aliases/GetPreviousPageParamFunction.md new file mode 100644 index 00000000000..5a6d9b93d7e --- /dev/null +++ b/docs/framework/lit/reference/type-aliases/GetPreviousPageParamFunction.md @@ -0,0 +1,42 @@ +--- +id: GetPreviousPageParamFunction +title: GetPreviousPageParamFunction +--- + +```ts +type GetPreviousPageParamFunction = (firstPage, allPages, firstPageParam, allPageParams) => TPageParam | undefined | null; +``` + +Defined in: [packages/query-core/src/types.ts:196](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L196) + +## Type Parameters + +### TPageParam + +`TPageParam` + +### TQueryFnData + +`TQueryFnData` = `unknown` + +## Parameters + +### firstPage + +`TQueryFnData` + +### allPages + +`TQueryFnData`[] + +### firstPageParam + +`TPageParam` + +### allPageParams + +`TPageParam`[] + +## Returns + +`TPageParam` \| `undefined` \| `null` diff --git a/docs/framework/lit/reference/type-aliases/InferDataFromTag.md b/docs/framework/lit/reference/type-aliases/InferDataFromTag.md new file mode 100644 index 00000000000..09a15ca4b1c --- /dev/null +++ b/docs/framework/lit/reference/type-aliases/InferDataFromTag.md @@ -0,0 +1,20 @@ +--- +id: InferDataFromTag +title: InferDataFromTag +--- + +```ts +type InferDataFromTag = TTaggedQueryKey extends DataTag ? TaggedValue : TQueryFnData; +``` + +Defined in: [packages/query-core/src/types.ts:90](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L90) + +## Type Parameters + +### TQueryFnData + +`TQueryFnData` + +### TTaggedQueryKey + +`TTaggedQueryKey` *extends* [`QueryKey`](QueryKey.md) diff --git a/docs/framework/lit/reference/type-aliases/InferErrorFromTag.md b/docs/framework/lit/reference/type-aliases/InferErrorFromTag.md new file mode 100644 index 00000000000..cd94e4b5c3f --- /dev/null +++ b/docs/framework/lit/reference/type-aliases/InferErrorFromTag.md @@ -0,0 +1,20 @@ +--- +id: InferErrorFromTag +title: InferErrorFromTag +--- + +```ts +type InferErrorFromTag = TTaggedQueryKey extends DataTag ? TaggedError extends UnsetMarker ? TError : TaggedError : TError; +``` + +Defined in: [packages/query-core/src/types.ts:95](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L95) + +## Type Parameters + +### TError + +`TError` + +### TTaggedQueryKey + +`TTaggedQueryKey` *extends* [`QueryKey`](QueryKey.md) diff --git a/docs/framework/lit/reference/type-aliases/InfiniteQueryControllerOptions.md b/docs/framework/lit/reference/type-aliases/InfiniteQueryControllerOptions.md index 0bd1447d181..a952ddd5bde 100644 --- a/docs/framework/lit/reference/type-aliases/InfiniteQueryControllerOptions.md +++ b/docs/framework/lit/reference/type-aliases/InfiniteQueryControllerOptions.md @@ -19,15 +19,15 @@ Accessor-wrapped options accepted by `createInfiniteQueryController`. ### TError -`TError` = `DefaultError` +`TError` = [`DefaultError`](DefaultError.md) ### TData -`TData` = `InfiniteData`\<`TQueryFnData`\> +`TData` = [`InfiniteData`](../interfaces/InfiniteData.md)\<`TQueryFnData`\> ### TQueryKey -`TQueryKey` *extends* `QueryKey` = `QueryKey` +`TQueryKey` *extends* [`QueryKey`](QueryKey.md) = [`QueryKey`](QueryKey.md) ### TPageParam diff --git a/docs/framework/lit/reference/type-aliases/InfiniteQueryExecuteOptions.md b/docs/framework/lit/reference/type-aliases/InfiniteQueryExecuteOptions.md new file mode 100644 index 00000000000..259c97c96bb --- /dev/null +++ b/docs/framework/lit/reference/type-aliases/InfiniteQueryExecuteOptions.md @@ -0,0 +1,32 @@ +--- +id: InfiniteQueryExecuteOptions +title: InfiniteQueryExecuteOptions +--- + +```ts +type InfiniteQueryExecuteOptions = Omit, TQueryKey, TPageParam>, "initialPageParam"> & InitialPageParam & InfiniteQueryPages; +``` + +Defined in: [packages/query-core/src/types.ts:654](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L654) + +## Type Parameters + +### TQueryFnData + +`TQueryFnData` = `unknown` + +### TError + +`TError` = [`DefaultError`](DefaultError.md) + +### TData + +`TData` = [`InfiniteData`](../interfaces/InfiniteData.md)\<`TQueryFnData`\> + +### TQueryKey + +`TQueryKey` *extends* [`QueryKey`](QueryKey.md) = [`QueryKey`](QueryKey.md) + +### TPageParam + +`TPageParam` = `unknown` diff --git a/docs/framework/lit/reference/type-aliases/InfiniteQueryObserverResult.md b/docs/framework/lit/reference/type-aliases/InfiniteQueryObserverResult.md new file mode 100644 index 00000000000..bf5e086a190 --- /dev/null +++ b/docs/framework/lit/reference/type-aliases/InfiniteQueryObserverResult.md @@ -0,0 +1,25 @@ +--- +id: InfiniteQueryObserverResult +title: InfiniteQueryObserverResult +--- + +```ts +type InfiniteQueryObserverResult = + | DefinedInfiniteQueryObserverResult + | InfiniteQueryObserverLoadingErrorResult + | InfiniteQueryObserverLoadingResult + | InfiniteQueryObserverPendingResult +| InfiniteQueryObserverPlaceholderResult; +``` + +Defined in: [packages/query-core/src/types.ts:1155](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1155) + +## Type Parameters + +### TData + +`TData` = `unknown` + +### TError + +`TError` = [`DefaultError`](DefaultError.md) diff --git a/docs/framework/lit/reference/type-aliases/InitialDataFunction.md b/docs/framework/lit/reference/type-aliases/InitialDataFunction.md new file mode 100644 index 00000000000..6ba4aaabe61 --- /dev/null +++ b/docs/framework/lit/reference/type-aliases/InitialDataFunction.md @@ -0,0 +1,20 @@ +--- +id: InitialDataFunction +title: InitialDataFunction +--- + +```ts +type InitialDataFunction = () => T | undefined; +``` + +Defined in: [packages/query-core/src/types.ts:173](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L173) + +## Type Parameters + +### T + +`T` + +## Returns + +`T` \| `undefined` diff --git a/docs/framework/lit/reference/type-aliases/ManagedTimerId.md b/docs/framework/lit/reference/type-aliases/ManagedTimerId.md new file mode 100644 index 00000000000..2492d8b1ec7 --- /dev/null +++ b/docs/framework/lit/reference/type-aliases/ManagedTimerId.md @@ -0,0 +1,19 @@ +--- +id: ManagedTimerId +title: ManagedTimerId +--- + +```ts +type ManagedTimerId = + | number + | { + [toPrimitive]: () => number; +}; +``` + +Defined in: [packages/query-core/src/timeoutManager.ts:17](https://github.com/TanStack/query/blob/main/packages/query-core/src/timeoutManager.ts#L17) + +Wrapping `setTimeout` is awkward from a typing perspective because platform +typings may extend the return type of `setTimeout`. For example, NodeJS +typings add `NodeJS.Timeout`; but a non-default `timeoutManager` may not be +able to return such a type. diff --git a/docs/framework/lit/reference/type-aliases/MutateFunction.md b/docs/framework/lit/reference/type-aliases/MutateFunction.md new file mode 100644 index 00000000000..e12b7a80291 --- /dev/null +++ b/docs/framework/lit/reference/type-aliases/MutateFunction.md @@ -0,0 +1,38 @@ +--- +id: MutateFunction +title: MutateFunction +--- + +```ts +type MutateFunction = (...rest) => Promise; +``` + +Defined in: [packages/query-core/src/types.ts:1326](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1326) + +## Type Parameters + +### TData + +`TData` = `unknown` + +### TError + +`TError` = [`DefaultError`](DefaultError.md) + +### TVariables + +`TVariables` = `void` + +### TOnMutateResult + +`TOnMutateResult` = `unknown` + +## Parameters + +### rest + +...[`MutateFunctionRest`](MutateFunctionRest.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\> + +## Returns + +`Promise`\<`TData`\> diff --git a/docs/framework/lit/reference/type-aliases/MutateFunctionRest.md b/docs/framework/lit/reference/type-aliases/MutateFunctionRest.md new file mode 100644 index 00000000000..3902f1082f9 --- /dev/null +++ b/docs/framework/lit/reference/type-aliases/MutateFunctionRest.md @@ -0,0 +1,28 @@ +--- +id: MutateFunctionRest +title: MutateFunctionRest +--- + +```ts +type MutateFunctionRest = undefined extends TVariables ? [TVariables, MutateOptions] : [TVariables, MutateOptions]; +``` + +Defined in: [packages/query-core/src/types.ts:1311](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1311) + +## Type Parameters + +### TData + +`TData` = `unknown` + +### TError + +`TError` = [`DefaultError`](DefaultError.md) + +### TVariables + +`TVariables` = `void` + +### TOnMutateResult + +`TOnMutateResult` = `unknown` diff --git a/docs/framework/lit/reference/type-aliases/MutationCacheNotifyEvent.md b/docs/framework/lit/reference/type-aliases/MutationCacheNotifyEvent.md new file mode 100644 index 00000000000..14d5f61a409 --- /dev/null +++ b/docs/framework/lit/reference/type-aliases/MutationCacheNotifyEvent.md @@ -0,0 +1,20 @@ +--- +id: MutationCacheNotifyEvent +title: MutationCacheNotifyEvent +--- + +```ts +type MutationCacheNotifyEvent = + | NotifyEventMutationAdded + | NotifyEventMutationRemoved + | NotifyEventMutationObserverAdded + | NotifyEventMutationObserverRemoved + | NotifyEventMutationObserverOptionsUpdated + | NotifyEventMutationUpdated; +``` + +Defined in: [packages/query-core/src/mutationCache.ts:98](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationCache.ts#L98) + +The event passed to a `MutationCache` subscriber. Fired whenever a mutation is added or removed +from the cache, its state is updated, or one of its observers is added, removed, or has its +options updated. diff --git a/docs/framework/lit/reference/type-aliases/MutationControllerOptions.md b/docs/framework/lit/reference/type-aliases/MutationControllerOptions.md index 8c0a497f768..04c287b11dc 100644 --- a/docs/framework/lit/reference/type-aliases/MutationControllerOptions.md +++ b/docs/framework/lit/reference/type-aliases/MutationControllerOptions.md @@ -19,7 +19,7 @@ Accessor-wrapped options accepted by `createMutationController`. ### TError -`TError` = `DefaultError` +`TError` = [`DefaultError`](DefaultError.md) ### TVariables diff --git a/docs/framework/lit/reference/type-aliases/MutationControllerResult.md b/docs/framework/lit/reference/type-aliases/MutationControllerResult.md index 0e7ab8f01df..9bff6b9c838 100644 --- a/docs/framework/lit/reference/type-aliases/MutationControllerResult.md +++ b/docs/framework/lit/reference/type-aliases/MutationControllerResult.md @@ -19,7 +19,7 @@ Result object produced by a Lit mutation controller. ### TError -`TError` = `DefaultError` +`TError` = [`DefaultError`](DefaultError.md) ### TVariables diff --git a/docs/framework/lit/reference/type-aliases/MutationFunction.md b/docs/framework/lit/reference/type-aliases/MutationFunction.md new file mode 100644 index 00000000000..9bafb3db56b --- /dev/null +++ b/docs/framework/lit/reference/type-aliases/MutationFunction.md @@ -0,0 +1,34 @@ +--- +id: MutationFunction +title: MutationFunction +--- + +```ts +type MutationFunction = (variables, context) => Promise; +``` + +Defined in: [packages/query-core/src/types.ts:1195](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1195) + +## Type Parameters + +### TData + +`TData` = `unknown` + +### TVariables + +`TVariables` = `unknown` + +## Parameters + +### variables + +`TVariables` + +### context + +[`MutationFunctionContext`](MutationFunctionContext.md) + +## Returns + +`Promise`\<`TData`\> diff --git a/docs/framework/lit/reference/type-aliases/MutationFunctionContext.md b/docs/framework/lit/reference/type-aliases/MutationFunctionContext.md new file mode 100644 index 00000000000..0207256c702 --- /dev/null +++ b/docs/framework/lit/reference/type-aliases/MutationFunctionContext.md @@ -0,0 +1,40 @@ +--- +id: MutationFunctionContext +title: MutationFunctionContext +--- + +```ts +type MutationFunctionContext = object; +``` + +Defined in: [packages/query-core/src/types.ts:1189](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1189) + +## Properties + +### client + +```ts +client: QueryClient; +``` + +Defined in: [packages/query-core/src/types.ts:1190](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1190) + +*** + +### meta + +```ts +meta: MutationMeta | undefined; +``` + +Defined in: [packages/query-core/src/types.ts:1191](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1191) + +*** + +### mutationKey? + +```ts +optional mutationKey: MutationKey; +``` + +Defined in: [packages/query-core/src/types.ts:1192](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1192) diff --git a/docs/framework/lit/reference/type-aliases/MutationKey.md b/docs/framework/lit/reference/type-aliases/MutationKey.md new file mode 100644 index 00000000000..9d1d7f0f77b --- /dev/null +++ b/docs/framework/lit/reference/type-aliases/MutationKey.md @@ -0,0 +1,10 @@ +--- +id: MutationKey +title: MutationKey +--- + +```ts +type MutationKey = Register extends object ? TMutationKey extends ReadonlyArray ? TMutationKey : TMutationKey extends unknown[] ? TMutationKey : ReadonlyArray : ReadonlyArray; +``` + +Defined in: [packages/query-core/src/types.ts:1165](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1165) diff --git a/docs/framework/lit/reference/type-aliases/MutationMeta.md b/docs/framework/lit/reference/type-aliases/MutationMeta.md new file mode 100644 index 00000000000..ff1f9b4bf94 --- /dev/null +++ b/docs/framework/lit/reference/type-aliases/MutationMeta.md @@ -0,0 +1,10 @@ +--- +id: MutationMeta +title: MutationMeta +--- + +```ts +type MutationMeta = Register extends object ? TMutationMeta extends Record ? TMutationMeta : Record : Record; +``` + +Defined in: [packages/query-core/src/types.ts:1181](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1181) diff --git a/docs/framework/lit/reference/type-aliases/MutationObserverResult.md b/docs/framework/lit/reference/type-aliases/MutationObserverResult.md new file mode 100644 index 00000000000..c865ae31c27 --- /dev/null +++ b/docs/framework/lit/reference/type-aliases/MutationObserverResult.md @@ -0,0 +1,32 @@ +--- +id: MutationObserverResult +title: MutationObserverResult +--- + +```ts +type MutationObserverResult = + | MutationObserverIdleResult + | MutationObserverLoadingResult + | MutationObserverErrorResult +| MutationObserverSuccessResult; +``` + +Defined in: [packages/query-core/src/types.ts:1484](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1484) + +## Type Parameters + +### TData + +`TData` = `unknown` + +### TError + +`TError` = [`DefaultError`](DefaultError.md) + +### TVariables + +`TVariables` = `void` + +### TOnMutateResult + +`TOnMutateResult` = `unknown` diff --git a/docs/framework/lit/reference/type-aliases/MutationResultAccessor.md b/docs/framework/lit/reference/type-aliases/MutationResultAccessor.md index 513605f4dd5..4e142d4b299 100644 --- a/docs/framework/lit/reference/type-aliases/MutationResultAccessor.md +++ b/docs/framework/lit/reference/type-aliases/MutationResultAccessor.md @@ -42,7 +42,7 @@ Throws synchronously if no `QueryClient` can be resolved. ##### args -...`Parameters`\<`MutateFunction`\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\>\> +...`Parameters`\<[`MutateFunction`](MutateFunction.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\>\> #### Returns diff --git a/docs/framework/lit/reference/type-aliases/MutationScope.md b/docs/framework/lit/reference/type-aliases/MutationScope.md new file mode 100644 index 00000000000..1d6a91bd434 --- /dev/null +++ b/docs/framework/lit/reference/type-aliases/MutationScope.md @@ -0,0 +1,20 @@ +--- +id: MutationScope +title: MutationScope +--- + +```ts +type MutationScope = object; +``` + +Defined in: [packages/query-core/src/types.ts:1177](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1177) + +## Properties + +### id + +```ts +id: string; +``` + +Defined in: [packages/query-core/src/types.ts:1178](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1178) diff --git a/docs/framework/lit/reference/type-aliases/MutationStateOptions.md b/docs/framework/lit/reference/type-aliases/MutationStateOptions.md index 4048f7470ac..937b1c0ba8d 100644 --- a/docs/framework/lit/reference/type-aliases/MutationStateOptions.md +++ b/docs/framework/lit/reference/type-aliases/MutationStateOptions.md @@ -45,7 +45,7 @@ Maps each matching mutation to the value returned by the accessor. ##### mutation -`Mutation` +[`Mutation`](../classes/Mutation.md) #### Returns diff --git a/docs/framework/lit/reference/type-aliases/MutationStatus.md b/docs/framework/lit/reference/type-aliases/MutationStatus.md new file mode 100644 index 00000000000..cf12d3d3ee3 --- /dev/null +++ b/docs/framework/lit/reference/type-aliases/MutationStatus.md @@ -0,0 +1,10 @@ +--- +id: MutationStatus +title: MutationStatus +--- + +```ts +type MutationStatus = "idle" | "pending" | "success" | "error"; +``` + +Defined in: [packages/query-core/src/types.ts:1175](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1175) diff --git a/docs/framework/lit/reference/type-aliases/NetworkMode.md b/docs/framework/lit/reference/type-aliases/NetworkMode.md new file mode 100644 index 00000000000..94ae0ba76ed --- /dev/null +++ b/docs/framework/lit/reference/type-aliases/NetworkMode.md @@ -0,0 +1,10 @@ +--- +id: NetworkMode +title: NetworkMode +--- + +```ts +type NetworkMode = "online" | "always" | "offlineFirst"; +``` + +Defined in: [packages/query-core/src/types.ts:223](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L223) diff --git a/docs/framework/lit/reference/type-aliases/NonUndefinedGuard.md b/docs/framework/lit/reference/type-aliases/NonUndefinedGuard.md new file mode 100644 index 00000000000..4aaf208013b --- /dev/null +++ b/docs/framework/lit/reference/type-aliases/NonUndefinedGuard.md @@ -0,0 +1,16 @@ +--- +id: NonUndefinedGuard +title: NonUndefinedGuard +--- + +```ts +type NonUndefinedGuard = T extends undefined ? never : T; +``` + +Defined in: [packages/query-core/src/types.ts:12](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L12) + +## Type Parameters + +### T + +`T` diff --git a/docs/framework/lit/reference/type-aliases/NotifyEventType.md b/docs/framework/lit/reference/type-aliases/NotifyEventType.md new file mode 100644 index 00000000000..b87340530c4 --- /dev/null +++ b/docs/framework/lit/reference/type-aliases/NotifyEventType.md @@ -0,0 +1,17 @@ +--- +id: NotifyEventType +title: NotifyEventType +--- + +```ts +type NotifyEventType = + | "added" + | "removed" + | "updated" + | "observerAdded" + | "observerRemoved" + | "observerResultsUpdated" + | "observerOptionsUpdated"; +``` + +Defined in: [packages/query-core/src/types.ts:1530](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1530) diff --git a/docs/framework/lit/reference/type-aliases/NotifyOnChangeProps.md b/docs/framework/lit/reference/type-aliases/NotifyOnChangeProps.md new file mode 100644 index 00000000000..34f413c37f5 --- /dev/null +++ b/docs/framework/lit/reference/type-aliases/NotifyOnChangeProps.md @@ -0,0 +1,17 @@ +--- +id: NotifyOnChangeProps +title: NotifyOnChangeProps +--- + +```ts +type NotifyOnChangeProps = + | keyof InfiniteQueryObserverResult[] + | "all" + | undefined + | () => + | keyof InfiniteQueryObserverResult[] + | "all" + | undefined; +``` + +Defined in: [packages/query-core/src/types.ts:225](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L225) diff --git a/docs/framework/lit/reference/type-aliases/OmitKeyof.md b/docs/framework/lit/reference/type-aliases/OmitKeyof.md new file mode 100644 index 00000000000..39de92462b8 --- /dev/null +++ b/docs/framework/lit/reference/type-aliases/OmitKeyof.md @@ -0,0 +1,28 @@ +--- +id: OmitKeyof +title: OmitKeyof +--- + +```ts +type OmitKeyof = Omit; +``` + +Defined in: [packages/query-core/src/types.ts:19](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L19) + +## Type Parameters + +### TObject + +`TObject` + +### TKey + +`TKey` *extends* `TStrictly` *extends* `"safely"` ? + \| keyof `TObject` + \| `string` & `Record`\<`never`, `never`\> + \| `number` & `Record`\<`never`, `never`\> + \| `symbol` & `Record`\<`never`, `never`\> : keyof `TObject` + +### TStrictly + +`TStrictly` *extends* `"strictly"` \| `"safely"` = `"strictly"` diff --git a/docs/framework/lit/reference/type-aliases/Override.md b/docs/framework/lit/reference/type-aliases/Override.md new file mode 100644 index 00000000000..8abcecd1e1b --- /dev/null +++ b/docs/framework/lit/reference/type-aliases/Override.md @@ -0,0 +1,20 @@ +--- +id: Override +title: Override +--- + +```ts +type Override = { [AKey in keyof TTargetA]: AKey extends keyof TTargetB ? TTargetB[AKey] : TTargetA[AKey] }; +``` + +Defined in: [packages/query-core/src/types.ts:31](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L31) + +## Type Parameters + +### TTargetA + +`TTargetA` + +### TTargetB + +`TTargetB` diff --git a/docs/framework/lit/reference/type-aliases/PlaceholderDataFunction.md b/docs/framework/lit/reference/type-aliases/PlaceholderDataFunction.md new file mode 100644 index 00000000000..cd40f28b41e --- /dev/null +++ b/docs/framework/lit/reference/type-aliases/PlaceholderDataFunction.md @@ -0,0 +1,42 @@ +--- +id: PlaceholderDataFunction +title: PlaceholderDataFunction +--- + +```ts +type PlaceholderDataFunction = (previousData, previousQuery) => TQueryData | undefined; +``` + +Defined in: [packages/query-core/src/types.ts:177](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L177) + +## Type Parameters + +### TQueryFnData + +`TQueryFnData` = `unknown` + +### TError + +`TError` = [`DefaultError`](DefaultError.md) + +### TQueryData + +`TQueryData` = `TQueryFnData` + +### TQueryKey + +`TQueryKey` *extends* [`QueryKey`](QueryKey.md) = [`QueryKey`](QueryKey.md) + +## Parameters + +### previousData + +`TQueryData` | `undefined` + +### previousQuery + +[`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryData`, `TQueryKey`\> | `undefined` + +## Returns + +`TQueryData` \| `undefined` diff --git a/docs/framework/lit/reference/type-aliases/QueriesPlaceholderDataFunction.md b/docs/framework/lit/reference/type-aliases/QueriesPlaceholderDataFunction.md new file mode 100644 index 00000000000..5d3fca8c9e0 --- /dev/null +++ b/docs/framework/lit/reference/type-aliases/QueriesPlaceholderDataFunction.md @@ -0,0 +1,30 @@ +--- +id: QueriesPlaceholderDataFunction +title: QueriesPlaceholderDataFunction +--- + +```ts +type QueriesPlaceholderDataFunction = (previousData, previousQuery) => TQueryData | undefined; +``` + +Defined in: [packages/query-core/src/types.ts:187](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L187) + +## Type Parameters + +### TQueryData + +`TQueryData` + +## Parameters + +### previousData + +`undefined` + +### previousQuery + +`undefined` + +## Returns + +`TQueryData` \| `undefined` diff --git a/docs/framework/lit/reference/type-aliases/QueryBooleanOption.md b/docs/framework/lit/reference/type-aliases/QueryBooleanOption.md new file mode 100644 index 00000000000..9759e3ddb42 --- /dev/null +++ b/docs/framework/lit/reference/type-aliases/QueryBooleanOption.md @@ -0,0 +1,28 @@ +--- +id: QueryBooleanOption +title: QueryBooleanOption +--- + +```ts +type QueryBooleanOption = boolean | (query) => boolean; +``` + +Defined in: [packages/query-core/src/types.ts:119](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L119) + +## Type Parameters + +### TQueryFnData + +`TQueryFnData` = `unknown` + +### TError + +`TError` = [`DefaultError`](DefaultError.md) + +### TData + +`TData` = `TQueryFnData` + +### TQueryKey + +`TQueryKey` *extends* [`QueryKey`](QueryKey.md) = [`QueryKey`](QueryKey.md) diff --git a/docs/framework/lit/reference/type-aliases/QueryCacheNotifyEvent.md b/docs/framework/lit/reference/type-aliases/QueryCacheNotifyEvent.md new file mode 100644 index 00000000000..0d4cadc4f89 --- /dev/null +++ b/docs/framework/lit/reference/type-aliases/QueryCacheNotifyEvent.md @@ -0,0 +1,21 @@ +--- +id: QueryCacheNotifyEvent +title: QueryCacheNotifyEvent +--- + +```ts +type QueryCacheNotifyEvent = + | NotifyEventQueryAdded + | NotifyEventQueryRemoved + | NotifyEventQueryUpdated + | NotifyEventQueryObserverAdded + | NotifyEventQueryObserverRemoved + | NotifyEventQueryObserverResultsUpdated + | NotifyEventQueryObserverOptionsUpdated; +``` + +Defined in: [packages/query-core/src/queryCache.ts:85](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryCache.ts#L85) + +The event passed to a `QueryCache` subscriber. Fired whenever a query is added or removed from +the cache, its state is updated (e.g. via `query.setState` or `queryClient.removeQueries`), or +one of its observers is added, removed, or has its results or options updated. diff --git a/docs/framework/lit/reference/type-aliases/QueryControllerOptions.md b/docs/framework/lit/reference/type-aliases/QueryControllerOptions.md index 332769cedae..4a8bf18f51a 100644 --- a/docs/framework/lit/reference/type-aliases/QueryControllerOptions.md +++ b/docs/framework/lit/reference/type-aliases/QueryControllerOptions.md @@ -19,7 +19,7 @@ Accessor-wrapped options accepted by `createQueryController`. ### TError -`TError` = `DefaultError` +`TError` = [`DefaultError`](DefaultError.md) ### TData @@ -31,4 +31,4 @@ Accessor-wrapped options accepted by `createQueryController`. ### TQueryKey -`TQueryKey` *extends* `QueryKey` = `QueryKey` +`TQueryKey` *extends* [`QueryKey`](QueryKey.md) = [`QueryKey`](QueryKey.md) diff --git a/docs/framework/lit/reference/type-aliases/QueryControllerResult.md b/docs/framework/lit/reference/type-aliases/QueryControllerResult.md index 989ab2227e6..3b29b74fa11 100644 --- a/docs/framework/lit/reference/type-aliases/QueryControllerResult.md +++ b/docs/framework/lit/reference/type-aliases/QueryControllerResult.md @@ -19,4 +19,4 @@ Result object produced by a Lit query controller. ### TError -`TError` = `DefaultError` +`TError` = [`DefaultError`](DefaultError.md) diff --git a/docs/framework/lit/reference/type-aliases/QueryFunction.md b/docs/framework/lit/reference/type-aliases/QueryFunction.md new file mode 100644 index 00000000000..306367388a1 --- /dev/null +++ b/docs/framework/lit/reference/type-aliases/QueryFunction.md @@ -0,0 +1,34 @@ +--- +id: QueryFunction +title: QueryFunction +--- + +```ts +type QueryFunction = (context) => T | Promise; +``` + +Defined in: [packages/query-core/src/types.ts:102](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L102) + +## Type Parameters + +### T + +`T` = `unknown` + +### TQueryKey + +`TQueryKey` *extends* [`QueryKey`](QueryKey.md) = [`QueryKey`](QueryKey.md) + +### TPageParam + +`TPageParam` = `never` + +## Parameters + +### context + +[`QueryFunctionContext`](QueryFunctionContext.md)\<`TQueryKey`, `TPageParam`\> + +## Returns + +`T` \| `Promise`\<`T`\> diff --git a/docs/framework/lit/reference/type-aliases/QueryFunctionContext.md b/docs/framework/lit/reference/type-aliases/QueryFunctionContext.md new file mode 100644 index 00000000000..d2c9fe3e2b2 --- /dev/null +++ b/docs/framework/lit/reference/type-aliases/QueryFunctionContext.md @@ -0,0 +1,20 @@ +--- +id: QueryFunctionContext +title: QueryFunctionContext +--- + +```ts +type QueryFunctionContext = [TPageParam] extends [never] ? object : object; +``` + +Defined in: [packages/query-core/src/types.ts:144](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L144) + +## Type Parameters + +### TQueryKey + +`TQueryKey` *extends* [`QueryKey`](QueryKey.md) = [`QueryKey`](QueryKey.md) + +### TPageParam + +`TPageParam` = `never` diff --git a/docs/framework/lit/reference/type-aliases/QueryKey.md b/docs/framework/lit/reference/type-aliases/QueryKey.md new file mode 100644 index 00000000000..1a3f34cde18 --- /dev/null +++ b/docs/framework/lit/reference/type-aliases/QueryKey.md @@ -0,0 +1,10 @@ +--- +id: QueryKey +title: QueryKey +--- + +```ts +type QueryKey = Register extends object ? TQueryKey extends ReadonlyArray ? TQueryKey : TQueryKey extends unknown[] ? TQueryKey : ReadonlyArray : ReadonlyArray; +``` + +Defined in: [packages/query-core/src/types.ts:51](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L51) diff --git a/docs/framework/lit/reference/type-aliases/QueryKeyHashFunction.md b/docs/framework/lit/reference/type-aliases/QueryKeyHashFunction.md new file mode 100644 index 00000000000..feda96373cc --- /dev/null +++ b/docs/framework/lit/reference/type-aliases/QueryKeyHashFunction.md @@ -0,0 +1,26 @@ +--- +id: QueryKeyHashFunction +title: QueryKeyHashFunction +--- + +```ts +type QueryKeyHashFunction = (queryKey) => string; +``` + +Defined in: [packages/query-core/src/types.ts:192](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L192) + +## Type Parameters + +### TQueryKey + +`TQueryKey` *extends* [`QueryKey`](QueryKey.md) + +## Parameters + +### queryKey + +`TQueryKey` + +## Returns + +`string` diff --git a/docs/framework/lit/reference/type-aliases/QueryKeyWithDataTag.md b/docs/framework/lit/reference/type-aliases/QueryKeyWithDataTag.md new file mode 100644 index 00000000000..6613f74be9e --- /dev/null +++ b/docs/framework/lit/reference/type-aliases/QueryKeyWithDataTag.md @@ -0,0 +1,34 @@ +--- +id: QueryKeyWithDataTag +title: QueryKeyWithDataTag +--- + +```ts +type QueryKeyWithDataTag = object; +``` + +Defined in: [packages/query-core/src/types.ts:82](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L82) + +## Type Parameters + +### TQueryKey + +`TQueryKey` *extends* [`QueryKey`](QueryKey.md) = [`QueryKey`](QueryKey.md) + +### TQueryFnData + +`TQueryFnData` = `unknown` + +### TError + +`TError` = [`DefaultError`](DefaultError.md) + +## Properties + +### queryKey + +```ts +queryKey: DataTag; +``` + +Defined in: [packages/query-core/src/types.ts:87](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L87) diff --git a/docs/framework/lit/reference/type-aliases/QueryMeta.md b/docs/framework/lit/reference/type-aliases/QueryMeta.md new file mode 100644 index 00000000000..c12917b2cce --- /dev/null +++ b/docs/framework/lit/reference/type-aliases/QueryMeta.md @@ -0,0 +1,10 @@ +--- +id: QueryMeta +title: QueryMeta +--- + +```ts +type QueryMeta = Register extends object ? TQueryMeta extends Record ? TQueryMeta : Record : Record; +``` + +Defined in: [packages/query-core/src/types.ts:215](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L215) diff --git a/docs/framework/lit/reference/type-aliases/QueryObserverResult.md b/docs/framework/lit/reference/type-aliases/QueryObserverResult.md new file mode 100644 index 00000000000..3891bca3da3 --- /dev/null +++ b/docs/framework/lit/reference/type-aliases/QueryObserverResult.md @@ -0,0 +1,25 @@ +--- +id: QueryObserverResult +title: QueryObserverResult +--- + +```ts +type QueryObserverResult = + | DefinedQueryObserverResult + | QueryObserverLoadingErrorResult + | QueryObserverLoadingResult + | QueryObserverPendingResult +| QueryObserverPlaceholderResult; +``` + +Defined in: [packages/query-core/src/types.ts:994](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L994) + +## Type Parameters + +### TData + +`TData` = `unknown` + +### TError + +`TError` = [`DefaultError`](DefaultError.md) diff --git a/docs/framework/lit/reference/type-aliases/QueryPersister.md b/docs/framework/lit/reference/type-aliases/QueryPersister.md new file mode 100644 index 00000000000..72e80165b0d --- /dev/null +++ b/docs/framework/lit/reference/type-aliases/QueryPersister.md @@ -0,0 +1,24 @@ +--- +id: QueryPersister +title: QueryPersister +--- + +```ts +type QueryPersister = [TPageParam] extends [never] ? (queryFn, context, query) => T | Promise : (queryFn, context, query) => T | Promise; +``` + +Defined in: [packages/query-core/src/types.ts:128](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L128) + +## Type Parameters + +### T + +`T` = `unknown` + +### TQueryKey + +`TQueryKey` *extends* [`QueryKey`](QueryKey.md) = [`QueryKey`](QueryKey.md) + +### TPageParam + +`TPageParam` = `never` diff --git a/docs/framework/lit/reference/type-aliases/QueryResultAccessor.md b/docs/framework/lit/reference/type-aliases/QueryResultAccessor.md index bf4dad0371e..010f375e4ca 100644 --- a/docs/framework/lit/reference/type-aliases/QueryResultAccessor.md +++ b/docs/framework/lit/reference/type-aliases/QueryResultAccessor.md @@ -46,7 +46,7 @@ Resolves with an optimistic query result, fetching first when needed. #### Returns -`Promise`\<`QueryObserverResult`\<`TData`, `TError`\>\> +`Promise`\<[`QueryObserverResult`](QueryObserverResult.md)\<`TData`, `TError`\>\> ## Type Parameters diff --git a/docs/framework/lit/reference/type-aliases/QueryStatus.md b/docs/framework/lit/reference/type-aliases/QueryStatus.md new file mode 100644 index 00000000000..bab00f6f423 --- /dev/null +++ b/docs/framework/lit/reference/type-aliases/QueryStatus.md @@ -0,0 +1,10 @@ +--- +id: QueryStatus +title: QueryStatus +--- + +```ts +type QueryStatus = "pending" | "error" | "success"; +``` + +Defined in: [packages/query-core/src/types.ts:761](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L761) diff --git a/docs/framework/lit/reference/type-aliases/SkipToken.md b/docs/framework/lit/reference/type-aliases/SkipToken.md new file mode 100644 index 00000000000..3a5791b982e --- /dev/null +++ b/docs/framework/lit/reference/type-aliases/SkipToken.md @@ -0,0 +1,12 @@ +--- +id: SkipToken +title: SkipToken +--- + +```ts +type SkipToken = typeof skipToken; +``` + +Defined in: [packages/query-core/src/utils.ts:526](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L526) + +The type of the [skipToken](../variables/skipToken.md) sentinel value. diff --git a/docs/framework/lit/reference/type-aliases/StaleTime.md b/docs/framework/lit/reference/type-aliases/StaleTime.md new file mode 100644 index 00000000000..3e7e21608be --- /dev/null +++ b/docs/framework/lit/reference/type-aliases/StaleTime.md @@ -0,0 +1,10 @@ +--- +id: StaleTime +title: StaleTime +--- + +```ts +type StaleTime = number | "static"; +``` + +Defined in: [packages/query-core/src/types.ts:108](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L108) diff --git a/docs/framework/lit/reference/type-aliases/StaleTimeFunction.md b/docs/framework/lit/reference/type-aliases/StaleTimeFunction.md new file mode 100644 index 00000000000..b1c541fa64e --- /dev/null +++ b/docs/framework/lit/reference/type-aliases/StaleTimeFunction.md @@ -0,0 +1,28 @@ +--- +id: StaleTimeFunction +title: StaleTimeFunction +--- + +```ts +type StaleTimeFunction = StaleTime | (query) => StaleTime; +``` + +Defined in: [packages/query-core/src/types.ts:110](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L110) + +## Type Parameters + +### TQueryFnData + +`TQueryFnData` = `unknown` + +### TError + +`TError` = [`DefaultError`](DefaultError.md) + +### TData + +`TData` = `TQueryFnData` + +### TQueryKey + +`TQueryKey` *extends* [`QueryKey`](QueryKey.md) = [`QueryKey`](QueryKey.md) diff --git a/docs/framework/lit/reference/type-aliases/ThrowOnError.md b/docs/framework/lit/reference/type-aliases/ThrowOnError.md new file mode 100644 index 00000000000..134683388ef --- /dev/null +++ b/docs/framework/lit/reference/type-aliases/ThrowOnError.md @@ -0,0 +1,28 @@ +--- +id: ThrowOnError +title: ThrowOnError +--- + +```ts +type ThrowOnError = boolean | (error, query) => boolean; +``` + +Defined in: [packages/query-core/src/types.ts:368](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L368) + +## Type Parameters + +### TQueryFnData + +`TQueryFnData` + +### TError + +`TError` + +### TQueryData + +`TQueryData` + +### TQueryKey + +`TQueryKey` *extends* [`QueryKey`](QueryKey.md) diff --git a/docs/framework/lit/reference/type-aliases/TimeoutCallback.md b/docs/framework/lit/reference/type-aliases/TimeoutCallback.md new file mode 100644 index 00000000000..773b5fdaeb9 --- /dev/null +++ b/docs/framework/lit/reference/type-aliases/TimeoutCallback.md @@ -0,0 +1,27 @@ +--- +id: TimeoutCallback +title: TimeoutCallback +--- + +```ts +type TimeoutCallback = (_) => void; +``` + +Defined in: [packages/query-core/src/timeoutManager.ts:9](https://github.com/TanStack/query/blob/main/packages/query-core/src/timeoutManager.ts#L9) + +[TimeoutManager](../interfaces/TimeoutManager.md) does not support passing arguments to the callback. + +`(_: void)` is the argument type inferred by TypeScript's default typings for +`setTimeout(cb, number)`. +If we don't accept a single void argument, then +`new Promise(resolve => timeoutManager.setTimeout(resolve, N))` is a type error. + +## Parameters + +### \_ + +`void` + +## Returns + +`void` diff --git a/docs/framework/lit/reference/type-aliases/TimeoutProvider.md b/docs/framework/lit/reference/type-aliases/TimeoutProvider.md new file mode 100644 index 00000000000..3509105bcd1 --- /dev/null +++ b/docs/framework/lit/reference/type-aliases/TimeoutProvider.md @@ -0,0 +1,112 @@ +--- +id: TimeoutProvider +title: TimeoutProvider +--- + +```ts +type TimeoutProvider = object; +``` + +Defined in: [packages/query-core/src/timeoutManager.ts:28](https://github.com/TanStack/query/blob/main/packages/query-core/src/timeoutManager.ts#L28) + +Backend for timer functions. + +Timers are performance-sensitive: short-lived timers (delays under a few seconds) tend to be +latency-sensitive, while long-lived ones may benefit more from coalescing — batching timers +with similar deadlines together — which the default provider (backed by the platform's global +`setTimeout`/`setInterval`) does not do. A custom provider can implement coalescing, and can +also support delays longer than the ~24-day maximum of the global `setTimeout`. + +## Type Parameters + +### TTimerId + +`TTimerId` *extends* [`ManagedTimerId`](ManagedTimerId.md) = [`ManagedTimerId`](ManagedTimerId.md) + +## Properties + +### clearInterval() + +```ts +readonly clearInterval: (intervalId) => void; +``` + +Defined in: [packages/query-core/src/timeoutManager.ts:34](https://github.com/TanStack/query/blob/main/packages/query-core/src/timeoutManager.ts#L34) + +#### Parameters + +##### intervalId + +`TTimerId` | `undefined` + +#### Returns + +`void` + +*** + +### clearTimeout() + +```ts +readonly clearTimeout: (timeoutId) => void; +``` + +Defined in: [packages/query-core/src/timeoutManager.ts:31](https://github.com/TanStack/query/blob/main/packages/query-core/src/timeoutManager.ts#L31) + +#### Parameters + +##### timeoutId + +`TTimerId` | `undefined` + +#### Returns + +`void` + +*** + +### setInterval() + +```ts +readonly setInterval: (callback, delay) => TTimerId; +``` + +Defined in: [packages/query-core/src/timeoutManager.ts:33](https://github.com/TanStack/query/blob/main/packages/query-core/src/timeoutManager.ts#L33) + +#### Parameters + +##### callback + +[`TimeoutCallback`](TimeoutCallback.md) + +##### delay + +`number` + +#### Returns + +`TTimerId` + +*** + +### setTimeout() + +```ts +readonly setTimeout: (callback, delay) => TTimerId; +``` + +Defined in: [packages/query-core/src/timeoutManager.ts:30](https://github.com/TanStack/query/blob/main/packages/query-core/src/timeoutManager.ts#L30) + +#### Parameters + +##### callback + +[`TimeoutCallback`](TimeoutCallback.md) + +##### delay + +`number` + +#### Returns + +`TTimerId` diff --git a/docs/framework/lit/reference/type-aliases/UndefinedInitialDataOptions.md b/docs/framework/lit/reference/type-aliases/UndefinedInitialDataOptions.md index d8002a3113e..f32722409fb 100644 --- a/docs/framework/lit/reference/type-aliases/UndefinedInitialDataOptions.md +++ b/docs/framework/lit/reference/type-aliases/UndefinedInitialDataOptions.md @@ -29,7 +29,7 @@ optional initialData: ### TError -`TError` = `DefaultError` +`TError` = [`DefaultError`](DefaultError.md) ### TData @@ -37,4 +37,4 @@ optional initialData: ### TQueryKey -`TQueryKey` *extends* `QueryKey` = `QueryKey` +`TQueryKey` *extends* [`QueryKey`](QueryKey.md) = [`QueryKey`](QueryKey.md) diff --git a/docs/framework/lit/reference/type-aliases/UnsetMarker.md b/docs/framework/lit/reference/type-aliases/UnsetMarker.md new file mode 100644 index 00000000000..8b9c14e1907 --- /dev/null +++ b/docs/framework/lit/reference/type-aliases/UnsetMarker.md @@ -0,0 +1,10 @@ +--- +id: UnsetMarker +title: UnsetMarker +--- + +```ts +type UnsetMarker = typeof unsetMarker; +``` + +Defined in: [packages/query-core/src/types.ts:66](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L66) diff --git a/docs/framework/lit/reference/type-aliases/UnusedSkipTokenOptions.md b/docs/framework/lit/reference/type-aliases/UnusedSkipTokenOptions.md index ba2c09c48ea..0b1f20119fc 100644 --- a/docs/framework/lit/reference/type-aliases/UnusedSkipTokenOptions.md +++ b/docs/framework/lit/reference/type-aliases/UnusedSkipTokenOptions.md @@ -27,7 +27,7 @@ optional queryFn: Exclude = TOutput | (input) => TOutput; +``` + +Defined in: [packages/query-core/src/utils.ts:105](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L105) + +Either a plain value of type `TOutput`, or a function that receives `TInput` and returns `TOutput`. +Used for example by `setQueryData`-style updaters, which accept either the new data directly or a +function that computes it from the previous data. See functionalUpdate. + +## Type Parameters + +### TInput + +`TInput` + +### TOutput + +`TOutput` + +## Example + +```ts +queryClient.setQueryData(['posts'], newPosts) + +// Or, using an updater function that receives the current data: +queryClient.setQueryData(['posts'], (oldPosts) => + oldPosts ? [...oldPosts, newPost] : oldPosts, +) +``` diff --git a/docs/framework/lit/reference/type-aliases/WithRequired.md b/docs/framework/lit/reference/type-aliases/WithRequired.md new file mode 100644 index 00000000000..a40a48c865b --- /dev/null +++ b/docs/framework/lit/reference/type-aliases/WithRequired.md @@ -0,0 +1,20 @@ +--- +id: WithRequired +title: WithRequired +--- + +```ts +type WithRequired = TTarget & { [_ in TKey]: {} }; +``` + +Defined in: [packages/query-core/src/types.ts:524](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L524) + +## Type Parameters + +### TTarget + +`TTarget` + +### TKey + +`TKey` *extends* keyof `TTarget` diff --git a/docs/framework/lit/reference/type-aliases/dataTagErrorSymbol.md b/docs/framework/lit/reference/type-aliases/dataTagErrorSymbol.md new file mode 100644 index 00000000000..26148a94d6e --- /dev/null +++ b/docs/framework/lit/reference/type-aliases/dataTagErrorSymbol.md @@ -0,0 +1,10 @@ +--- +id: dataTagErrorSymbol +title: dataTagErrorSymbol +--- + +```ts +type dataTagErrorSymbol = typeof dataTagErrorSymbol; +``` + +Defined in: [packages/query-core/src/types.ts:63](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L63) diff --git a/docs/framework/lit/reference/type-aliases/dataTagSymbol.md b/docs/framework/lit/reference/type-aliases/dataTagSymbol.md new file mode 100644 index 00000000000..0012c108cc5 --- /dev/null +++ b/docs/framework/lit/reference/type-aliases/dataTagSymbol.md @@ -0,0 +1,10 @@ +--- +id: dataTagSymbol +title: dataTagSymbol +--- + +```ts +type dataTagSymbol = typeof dataTagSymbol; +``` + +Defined in: [packages/query-core/src/types.ts:61](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L61) diff --git a/docs/framework/lit/reference/variables/dataTagErrorSymbol.md b/docs/framework/lit/reference/variables/dataTagErrorSymbol.md new file mode 100644 index 00000000000..20bab62fb01 --- /dev/null +++ b/docs/framework/lit/reference/variables/dataTagErrorSymbol.md @@ -0,0 +1,10 @@ +--- +id: dataTagErrorSymbol +title: dataTagErrorSymbol +--- + +```ts +const dataTagErrorSymbol: typeof dataTagErrorSymbol; +``` + +Defined in: [packages/query-core/src/types.ts:63](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L63) diff --git a/docs/framework/lit/reference/variables/dataTagSymbol.md b/docs/framework/lit/reference/variables/dataTagSymbol.md new file mode 100644 index 00000000000..83dd68a56e9 --- /dev/null +++ b/docs/framework/lit/reference/variables/dataTagSymbol.md @@ -0,0 +1,10 @@ +--- +id: dataTagSymbol +title: dataTagSymbol +--- + +```ts +const dataTagSymbol: typeof dataTagSymbol; +``` + +Defined in: [packages/query-core/src/types.ts:61](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L61) diff --git a/docs/framework/lit/reference/variables/defaultScheduler.md b/docs/framework/lit/reference/variables/defaultScheduler.md new file mode 100644 index 00000000000..70e14d3f846 --- /dev/null +++ b/docs/framework/lit/reference/variables/defaultScheduler.md @@ -0,0 +1,13 @@ +--- +id: defaultScheduler +title: defaultScheduler +--- + +```ts +const defaultScheduler: ScheduleFunction = systemSetTimeoutZero; +``` + +Defined in: [packages/query-core/src/notifyManager.ts:19](https://github.com/TanStack/query/blob/main/packages/query-core/src/notifyManager.ts#L19) + +Default scheduling function used by the notify manager. +Schedules the callback with the system's `setTimeout(callback, 0)`. diff --git a/docs/framework/lit/reference/variables/environmentManager.md b/docs/framework/lit/reference/variables/environmentManager.md new file mode 100644 index 00000000000..ed333b8747b --- /dev/null +++ b/docs/framework/lit/reference/variables/environmentManager.md @@ -0,0 +1,59 @@ +--- +id: environmentManager +title: environmentManager +--- + +```ts +const environmentManager: object; +``` + +Defined in: [packages/query-core/src/environmentManager.ts:29](https://github.com/TanStack/query/blob/main/packages/query-core/src/environmentManager.ts#L29) + +Manages how TanStack Query detects whether the current runtime should be treated as +server-side, which disables scheduling refetch timers and changes the default `retry` count +and `gcTime`. By default, the detection treats a missing `window` (or the presence of a +`Deno` global) as server. + +Override this for runtimes where that default detection would give the wrong answer — for +example, a Service Worker, where `window` is undefined even though the environment should +behave like a client. + +## Type Declaration + +### isServer() + +```ts +isServer: () => boolean; +``` + +Returns whether the current runtime should be treated as a server environment. + +#### Returns + +`boolean` + +### setIsServer() + +```ts +setIsServer(isServerValue): void; +``` + +Overrides the server check globally. + +#### Parameters + +##### isServerValue + +`IsServerValue` + +#### Returns + +`void` + +## Example + +```ts +import { environmentManager } from '@tanstack/query-core' + +environmentManager.setIsServer(() => false) +``` diff --git a/docs/framework/lit/reference/variables/focusManager.md b/docs/framework/lit/reference/variables/focusManager.md new file mode 100644 index 00000000000..86477849e06 --- /dev/null +++ b/docs/framework/lit/reference/variables/focusManager.md @@ -0,0 +1,12 @@ +--- +id: focusManager +title: focusManager +--- + +```ts +const focusManager: FocusManager; +``` + +Defined in: [packages/query-core/src/focusManager.ts:142](https://github.com/TanStack/query/blob/main/packages/query-core/src/focusManager.ts#L142) + +Singleton instance of [FocusManager](../interfaces/FocusManager.md), used to manage and observe the focus state within TanStack Query. diff --git a/docs/framework/lit/reference/variables/isServer.md b/docs/framework/lit/reference/variables/isServer.md new file mode 100644 index 00000000000..16aa39d1244 --- /dev/null +++ b/docs/framework/lit/reference/variables/isServer.md @@ -0,0 +1,14 @@ +--- +id: isServer +title: isServer +--- + +```ts +const isServer: boolean; +``` + +Defined in: [packages/query-core/src/utils.ts:114](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L114) + +## Deprecated + +use `environmentManager.isServer()` instead. diff --git a/docs/framework/lit/reference/variables/notifyManager.md b/docs/framework/lit/reference/variables/notifyManager.md new file mode 100644 index 00000000000..4bdf3478be0 --- /dev/null +++ b/docs/framework/lit/reference/variables/notifyManager.md @@ -0,0 +1,166 @@ +--- +id: notifyManager +title: notifyManager +--- + +```ts +const notifyManager: object; +``` + +Defined in: [packages/query-core/src/notifyManager.ts:144](https://github.com/TanStack/query/blob/main/packages/query-core/src/notifyManager.ts#L144) + +Handles scheduling and batching callbacks in TanStack Query. + +## Type Declaration + +### batch() + +```ts +readonly batch: (callback) => T; +``` + +Batches all updates scheduled inside the passed callback. +This is mainly used internally to optimize query client updating. +Batches can be nested; the queue is only flushed once the outermost `batch` call finishes. +The return value of `callback` is passed through. + +#### Type Parameters + +##### T + +`T` + +#### Parameters + +##### callback + +() => `T` + +#### Returns + +`T` + +### batchCalls() + +```ts +readonly batchCalls: (callback) => BatchCallsCallback; +``` + +All calls to the wrapped function will be batched. + +#### Type Parameters + +##### T + +`T` *extends* `unknown`[] + +#### Parameters + +##### callback + +`BatchCallsCallback`\<`T`\> + +#### Returns + +`BatchCallsCallback`\<`T`\> + +### schedule() + +```ts +schedule: (callback) => void; +``` + +Schedules a function to be run on the next batch. +By default, the batch is run with a `setTimeout`, but this can be configured via `setScheduler`. + +#### Parameters + +##### callback + +`NotifyCallback` + +#### Returns + +`void` + +### setBatchNotifyFunction() + +```ts +readonly setBatchNotifyFunction: (fn) => void; +``` + +Use this method to set a custom function to batch notifications together into a single tick. +Framework adapters use this to plug in their own batching primitive, so that a single query +update only triggers one re-render instead of one per subscriber. + +#### Parameters + +##### fn + +`BatchNotifyFunction` + +#### Returns + +`void` + +#### Example + +```ts +import { notifyManager } from '@tanstack/query-core' +import { batch } from 'solid-js' + +notifyManager.setBatchNotifyFunction(batch) +``` + +### setNotifyFunction() + +```ts +readonly setNotifyFunction: (fn) => void; +``` + +Use this method to set a custom notify function. +This can be used to for example wrap notifications with `React.act` while running tests. + +#### Parameters + +##### fn + +`NotifyFunction` + +#### Returns + +`void` + +### setScheduler() + +```ts +readonly setScheduler: (fn) => void; +``` + +Configures a custom callback that schedules when the next batch runs. +The default behavior is `setTimeout(callback, 0)`. + +#### Parameters + +##### fn + +`ScheduleFunction` + +#### Returns + +`void` + +#### Example + +```ts +import { notifyManager } from '@tanstack/query-core' + +// Schedule batches in the next microtask +notifyManager.setScheduler(queueMicrotask) + +// Schedule batches before the next frame is rendered +notifyManager.setScheduler(requestAnimationFrame) + +// Schedule batches some time in the future +notifyManager.setScheduler((cb) => setTimeout(cb, 10)) +``` diff --git a/docs/framework/lit/reference/variables/onlineManager.md b/docs/framework/lit/reference/variables/onlineManager.md new file mode 100644 index 00000000000..2eeec5385d8 --- /dev/null +++ b/docs/framework/lit/reference/variables/onlineManager.md @@ -0,0 +1,12 @@ +--- +id: onlineManager +title: onlineManager +--- + +```ts +const onlineManager: OnlineManager; +``` + +Defined in: [packages/query-core/src/onlineManager.ts:117](https://github.com/TanStack/query/blob/main/packages/query-core/src/onlineManager.ts#L117) + +Singleton instance of [OnlineManager](../interfaces/OnlineManager.md), used to manage and observe the online state within TanStack Query. diff --git a/docs/framework/lit/reference/variables/skipToken.md b/docs/framework/lit/reference/variables/skipToken.md new file mode 100644 index 00000000000..a390d0b7b66 --- /dev/null +++ b/docs/framework/lit/reference/variables/skipToken.md @@ -0,0 +1,23 @@ +--- +id: skipToken +title: skipToken +--- + +```ts +const skipToken: typeof skipToken; +``` + +Defined in: [packages/query-core/src/utils.ts:522](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L522) + +Sentinel value that can be passed as a query's `queryFn` to conditionally disable the query (equivalent +to `enabled: false`) while preserving full type inference for the query's data. Unlike `enabled: false`, +a query disabled via `skipToken` cannot be triggered with `refetch`. + +## Example + +```ts +new QueryObserver(queryClient, { + queryKey: ['post', postId], + queryFn: postId != null ? () => fetchPost(postId) : skipToken, +}) +``` diff --git a/docs/framework/lit/reference/variables/timeoutManager.md b/docs/framework/lit/reference/variables/timeoutManager.md new file mode 100644 index 00000000000..1eca1a5f343 --- /dev/null +++ b/docs/framework/lit/reference/variables/timeoutManager.md @@ -0,0 +1,12 @@ +--- +id: timeoutManager +title: timeoutManager +--- + +```ts +const timeoutManager: TimeoutManager; +``` + +Defined in: [packages/query-core/src/timeoutManager.ts:232](https://github.com/TanStack/query/blob/main/packages/query-core/src/timeoutManager.ts#L232) + +Singleton instance of [TimeoutManager](../interfaces/TimeoutManager.md), used throughout TanStack Query to schedule and cancel timers. diff --git a/docs/framework/lit/reference/variables/unsetMarker.md b/docs/framework/lit/reference/variables/unsetMarker.md new file mode 100644 index 00000000000..d19ee65b38e --- /dev/null +++ b/docs/framework/lit/reference/variables/unsetMarker.md @@ -0,0 +1,10 @@ +--- +id: unsetMarker +title: unsetMarker +--- + +```ts +const unsetMarker: typeof unsetMarker; +``` + +Defined in: [packages/query-core/src/types.ts:65](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L65) diff --git a/docs/framework/preact/guides/ssr.md b/docs/framework/preact/guides/ssr.md index 2367e0c336e..b01c174b318 100644 --- a/docs/framework/preact/guides/ssr.md +++ b/docs/framework/preact/guides/ssr.md @@ -360,6 +360,6 @@ On the server, `gcTime` defaults to `Infinity` which disables manual garbage col Avoid setting `gcTime` to `0` as it may result in a hydration error. This occurs because the [Hydration Boundary](../reference/functions/HydrationBoundary.md) places necessary data into the cache for rendering, but if the garbage collector removes the data before the rendering completes, issues may arise. If you require a shorter `gcTime`, we recommend setting it to `2 * 1000` to allow sufficient time for the app to reference the data. -To clear the cache after it is not needed and to lower memory consumption, you can add a call to [`queryClient.clear()`](../../../reference/QueryClient.md#queryclientclear) after the request is handled and dehydrated state has been sent to the client. +To clear the cache after it is not needed and to lower memory consumption, you can add a call to [`queryClient.clear()`](../reference/classes/QueryClient.md#clear) after the request is handled and dehydrated state has been sent to the client. Alternatively, you can set a smaller `gcTime`. diff --git a/docs/framework/preact/reference/classes/CancelledError.md b/docs/framework/preact/reference/classes/CancelledError.md new file mode 100644 index 00000000000..7fded5da20f --- /dev/null +++ b/docs/framework/preact/reference/classes/CancelledError.md @@ -0,0 +1,273 @@ +--- +id: CancelledError +title: CancelledError +--- + +Defined in: [packages/query-core/src/retryer.ts:77](https://github.com/TanStack/query/blob/main/packages/query-core/src/retryer.ts#L77) + +The error thrown by a `Retryer` (and surfaced to `query.promise`/`mutation`) when a fetch is cancelled, e.g. via +`query.cancel()`. `revert`, if `true`, tells the caller to restore the state the query was in before the fetch +started instead of surfacing the error. `silent`, if `true`, tells the caller to suppress this error and instead +resolve with the promise of the fetch that triggered the cancellation. + +## Example + +```ts +query.cancel() + +try { + await query.promise +} catch (error) { + if (error instanceof CancelledError) { + // the fetch was cancelled, e.g. via `query.cancel()` + } +} +``` + +## Extends + +- `Error` + +## Constructors + +### Constructor + +```ts +new CancelledError(options?): CancelledError; +``` + +Defined in: [packages/query-core/src/retryer.ts:80](https://github.com/TanStack/query/blob/main/packages/query-core/src/retryer.ts#L80) + +#### Parameters + +##### options? + +[`CancelOptions`](../interfaces/CancelOptions.md) + +#### Returns + +`CancelledError` + +#### Overrides + +```ts +Error.constructor +``` + +## Properties + +### cause? + +```ts +optional cause: unknown; +``` + +Defined in: node\_modules/.pnpm/typescript@6.0.3/node\_modules/typescript/lib/lib.es2022.error.d.ts:24 + +#### Inherited from + +```ts +Error.cause +``` + +*** + +### message + +```ts +message: string; +``` + +Defined in: node\_modules/.pnpm/typescript@6.0.3/node\_modules/typescript/lib/lib.es5.d.ts:1075 + +#### Inherited from + +```ts +Error.message +``` + +*** + +### name + +```ts +name: string; +``` + +Defined in: node\_modules/.pnpm/typescript@6.0.3/node\_modules/typescript/lib/lib.es5.d.ts:1074 + +#### Inherited from + +```ts +Error.name +``` + +*** + +### revert? + +```ts +optional revert: boolean; +``` + +Defined in: [packages/query-core/src/retryer.ts:78](https://github.com/TanStack/query/blob/main/packages/query-core/src/retryer.ts#L78) + +*** + +### silent? + +```ts +optional silent: boolean; +``` + +Defined in: [packages/query-core/src/retryer.ts:79](https://github.com/TanStack/query/blob/main/packages/query-core/src/retryer.ts#L79) + +*** + +### stack? + +```ts +optional stack: string; +``` + +Defined in: node\_modules/.pnpm/typescript@6.0.3/node\_modules/typescript/lib/lib.es5.d.ts:1076 + +#### Inherited from + +```ts +Error.stack +``` + +*** + +### stackTraceLimit + +```ts +static stackTraceLimit: number; +``` + +Defined in: node\_modules/.pnpm/@types+node@22.19.15/node\_modules/@types/node/globals.d.ts:68 + +The `Error.stackTraceLimit` property specifies the number of stack frames +collected by a stack trace (whether generated by `new Error().stack` or +`Error.captureStackTrace(obj)`). + +The default value is `10` but may be set to any valid JavaScript number. Changes +will affect any stack trace captured _after_ the value has been changed. + +If set to a non-number value, or set to a negative number, stack traces will +not capture any frames. + +#### Inherited from + +```ts +Error.stackTraceLimit +``` + +## Methods + +### captureStackTrace() + +```ts +static captureStackTrace(targetObject, constructorOpt?): void; +``` + +Defined in: node\_modules/.pnpm/@types+node@22.19.15/node\_modules/@types/node/globals.d.ts:52 + +Creates a `.stack` property on `targetObject`, which when accessed returns +a string representing the location in the code at which +`Error.captureStackTrace()` was called. + +```js +const myObject = {}; +Error.captureStackTrace(myObject); +myObject.stack; // Similar to `new Error().stack` +``` + +The first line of the trace will be prefixed with +`${myObject.name}: ${myObject.message}`. + +The optional `constructorOpt` argument accepts a function. If given, all frames +above `constructorOpt`, including `constructorOpt`, will be omitted from the +generated stack trace. + +The `constructorOpt` argument is useful for hiding implementation +details of error generation from the user. For instance: + +```js +function a() { + b(); +} + +function b() { + c(); +} + +function c() { + // Create an error without stack trace to avoid calculating the stack trace twice. + const { stackTraceLimit } = Error; + Error.stackTraceLimit = 0; + const error = new Error(); + Error.stackTraceLimit = stackTraceLimit; + + // Capture the stack trace above function b + Error.captureStackTrace(error, b); // Neither function c, nor b is included in the stack trace + throw error; +} + +a(); +``` + +#### Parameters + +##### targetObject + +`object` + +##### constructorOpt? + +`Function` + +#### Returns + +`void` + +#### Inherited from + +```ts +Error.captureStackTrace +``` + +*** + +### prepareStackTrace() + +```ts +static prepareStackTrace(err, stackTraces): any; +``` + +Defined in: node\_modules/.pnpm/@types+node@22.19.15/node\_modules/@types/node/globals.d.ts:56 + +#### Parameters + +##### err + +`Error` + +##### stackTraces + +`CallSite`[] + +#### Returns + +`any` + +#### See + +https://v8.dev/docs/stack-trace-api#customizing-stack-traces + +#### Inherited from + +```ts +Error.prepareStackTrace +``` diff --git a/docs/framework/preact/reference/classes/InfiniteQueryObserver.md b/docs/framework/preact/reference/classes/InfiniteQueryObserver.md new file mode 100644 index 00000000000..af43087a3ad --- /dev/null +++ b/docs/framework/preact/reference/classes/InfiniteQueryObserver.md @@ -0,0 +1,665 @@ +--- +id: InfiniteQueryObserver +title: InfiniteQueryObserver +--- + +Defined in: [packages/query-core/src/infiniteQueryObserver.ts:41](https://github.com/TanStack/query/blob/main/packages/query-core/src/infiniteQueryObserver.ts#L41) + +An `InfiniteQueryObserver` extends `QueryObserver` to observe and switch +between infinite queries. It augments the base `QueryObserverResult` with +infinite-query-specific fields and methods, such as `hasNextPage` and +`fetchNextPage`, and is the primitive that framework adapters (e.g. +`useInfiniteQuery`) build their hooks on top of. + +## Example + +```ts +const observer = new InfiniteQueryObserver(queryClient, { + queryKey: ['projects'], + queryFn: ({ pageParam }) => fetchProjects(pageParam), + initialPageParam: 0, + getNextPageParam: (lastPage) => lastPage.nextCursor, +}) + +const unsubscribe = observer.subscribe((result) => console.log(result)) +``` + +## Extends + +- [`QueryObserver`](QueryObserver.md)\<`TQueryFnData`, `TError`, `TData`, [`InfiniteData`](../interfaces/InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\> + +## Type Parameters + +### TQueryFnData + +`TQueryFnData` = `unknown` + +### TError + +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) + +### TData + +`TData` = [`InfiniteData`](../interfaces/InfiniteData.md)\<`TQueryFnData`\> + +### TQueryKey + +`TQueryKey` *extends* [`QueryKey`](../type-aliases/QueryKey.md) = [`QueryKey`](../type-aliases/QueryKey.md) + +### TPageParam + +`TPageParam` = `unknown` + +## Constructors + +### Constructor + +```ts +new InfiniteQueryObserver(client, options): InfiniteQueryObserver; +``` + +Defined in: [packages/query-core/src/infiniteQueryObserver.ts:83](https://github.com/TanStack/query/blob/main/packages/query-core/src/infiniteQueryObserver.ts#L83) + +#### Parameters + +##### client + +[`QueryClient`](QueryClient.md) + +##### options + +[`InfiniteQueryObserverOptions`](../interfaces/InfiniteQueryObserverOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`, `TPageParam`\> + +#### Returns + +`InfiniteQueryObserver`\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`, `TPageParam`\> + +#### Overrides + +[`QueryObserver`](QueryObserver.md).[`constructor`](QueryObserver.md#constructor) + +## Properties + +### fetch + +```ts +protected fetch: ReplaceReturnType<(fetchOptions) => Promise>, Promise>>; +``` + +Defined in: [packages/query-core/src/infiniteQueryObserver.ts:72](https://github.com/TanStack/query/blob/main/packages/query-core/src/infiniteQueryObserver.ts#L72) + +#### Overrides + +```ts +QueryObserver.fetch +``` + +*** + +### getCurrentResult + +```ts +getCurrentResult: ReplaceReturnType<() => QueryObserverResult, InfiniteQueryObserverResult>; +``` + +Defined in: [packages/query-core/src/infiniteQueryObserver.ts:60](https://github.com/TanStack/query/blob/main/packages/query-core/src/infiniteQueryObserver.ts#L60) + +Returns the most recently computed `QueryObserverResult` for the +observed query. This is a point-in-time read; to be notified of updates +as they happen, subscribe to the observer instead (its inherited +`subscribe` method). + +#### Example + +```ts +const result = observer.getCurrentResult() +console.log(result.status, result.data) +``` + +#### Overrides + +```ts +QueryObserver.getCurrentResult +``` + +*** + +### listeners + +```ts +protected listeners: Set>; +``` + +Defined in: [packages/query-core/src/subscribable.ts:2](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L2) + +#### Inherited from + +[`QueryObserver`](QueryObserver.md).[`listeners`](QueryObserver.md#listeners) + +*** + +### options + +```ts +options: QueryObserverOptions, TQueryKey>; +``` + +Defined in: [packages/query-core/src/queryObserver.ts:89](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L89) + +#### Inherited from + +[`QueryObserver`](QueryObserver.md).[`options`](QueryObserver.md#options) + +*** + +### subscribe() + +```ts +subscribe: (listener) => () => void; +``` + +Defined in: [packages/query-core/src/infiniteQueryObserver.ts:55](https://github.com/TanStack/query/blob/main/packages/query-core/src/infiniteQueryObserver.ts#L55) + +#### Parameters + +##### listener + +`InfiniteQueryObserverListener` + +#### Returns + +```ts +(): void; +``` + +##### Returns + +`void` + +#### Overrides + +```ts +QueryObserver.subscribe +``` + +## Methods + +### bindMethods() + +```ts +protected bindMethods(): void; +``` + +Defined in: [packages/query-core/src/infiniteQueryObserver.ts:96](https://github.com/TanStack/query/blob/main/packages/query-core/src/infiniteQueryObserver.ts#L96) + +#### Returns + +`void` + +#### Overrides + +[`QueryObserver`](QueryObserver.md).[`bindMethods`](QueryObserver.md#bindmethods) + +*** + +### createResult() + +```ts +protected createResult(query, options): InfiniteQueryObserverResult; +``` + +Defined in: [packages/query-core/src/infiniteQueryObserver.ts:201](https://github.com/TanStack/query/blob/main/packages/query-core/src/infiniteQueryObserver.ts#L201) + +#### Parameters + +##### query + +[`Query`](Query.md)\<`TQueryFnData`, `TError`, [`InfiniteData`](../interfaces/InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\> + +##### options + +[`InfiniteQueryObserverOptions`](../interfaces/InfiniteQueryObserverOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`, `TPageParam`\> + +#### Returns + +[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\> + +#### Overrides + +[`QueryObserver`](QueryObserver.md).[`createResult`](QueryObserver.md#createresult) + +*** + +### destroy() + +```ts +destroy(): void; +``` + +Defined in: [packages/query-core/src/queryObserver.ts:161](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L161) + +Stops observing the current query: clears all listeners, cancels the +stale and refetch-interval timers, and removes this observer from the +query it was observing. + +#### Returns + +`void` + +#### Inherited from + +[`QueryObserver`](QueryObserver.md).[`destroy`](QueryObserver.md#destroy) + +*** + +### fetchNextPage() + +```ts +fetchNextPage(options?): Promise>; +``` + +Defined in: [packages/query-core/src/infiniteQueryObserver.ts:161](https://github.com/TanStack/query/blob/main/packages/query-core/src/infiniteQueryObserver.ts#L161) + +Fetches the next page of the infinite query and returns a promise that +resolves with the resulting `InfiniteQueryObserverResult`. The page +param used for the fetch is determined by `getNextPageParam`, which +receives the current pages/page params and whose result also determines +`hasNextPage`. + +#### Parameters + +##### options? + +[`FetchNextPageOptions`](../interfaces/FetchNextPageOptions.md) + +#### Returns + +`Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> + +#### Example + +```ts +const { hasNextPage } = observer.getCurrentResult() + +if (hasNextPage) { + await observer.fetchNextPage() +} +``` + +#### See + +[InfiniteQueryObserver#fetchPreviousPage](#fetchpreviouspage) + +*** + +### fetchOptimistic() + +```ts +fetchOptimistic(options): Promise>; +``` + +Defined in: [packages/query-core/src/queryObserver.ts:395](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L395) + +Fetches a query defined by the given options without affecting this +observer's own tracked query or result, and returns a promise that +resolves with the `QueryObserverResult` for that fetch. This is useful +for prefetching data that another observer (e.g. a query about to be +navigated to) will need, ahead of time. + +#### Parameters + +##### options + +[`QueryObserverOptions`](../interfaces/QueryObserverOptions.md)\<`TQueryFnData`, `TError`, `TData`, [`InfiniteData`](../interfaces/InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\> + +#### Returns + +`Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> + +#### Example + +```ts +const result = await observer.fetchOptimistic({ + queryKey: ['posts', 2], + queryFn: () => fetchPost(2), +}) +console.log(result.data) +``` + +#### Inherited from + +[`QueryObserver`](QueryObserver.md).[`fetchOptimistic`](QueryObserver.md#fetchoptimistic) + +*** + +### fetchPreviousPage() + +```ts +fetchPreviousPage(options?): Promise>; +``` + +Defined in: [packages/query-core/src/infiniteQueryObserver.ts:190](https://github.com/TanStack/query/blob/main/packages/query-core/src/infiniteQueryObserver.ts#L190) + +Fetches the previous page of the infinite query and returns a promise +that resolves with the resulting `InfiniteQueryObserverResult`. The page +param used for the fetch is determined by `getPreviousPageParam`, which +receives the current pages/page params and whose result also determines +`hasPreviousPage`. + +#### Parameters + +##### options? + +[`FetchPreviousPageOptions`](../interfaces/FetchPreviousPageOptions.md) + +#### Returns + +`Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> + +#### Example + +```ts +const { hasPreviousPage } = observer.getCurrentResult() + +if (hasPreviousPage) { + await observer.fetchPreviousPage() +} +``` + +#### See + +[InfiniteQueryObserver#fetchNextPage](#fetchnextpage) + +*** + +### getCurrentQuery() + +```ts +getCurrentQuery(): Query, TQueryKey>; +``` + +Defined in: [packages/query-core/src/queryObserver.ts:357](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L357) + +Returns the `Query` instance this observer is currently observing. + +#### Returns + +[`Query`](Query.md)\<`TQueryFnData`, `TError`, [`InfiniteData`](../interfaces/InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\> + +#### Inherited from + +[`QueryObserver`](QueryObserver.md).[`getCurrentQuery`](QueryObserver.md#getcurrentquery) + +*** + +### getOptimisticResult() + +```ts +getOptimisticResult(options): InfiniteQueryObserverResult; +``` + +Defined in: [packages/query-core/src/infiniteQueryObserver.ts:127](https://github.com/TanStack/query/blob/main/packages/query-core/src/infiniteQueryObserver.ts#L127) + +The infinite-query counterpart of [QueryObserver#getOptimisticResult](QueryObserver.md#getoptimisticresult), marking the +options as an infinite query before delegating to it. Called by framework adapters (e.g. +`useInfiniteQuery`) ahead of subscribing, to compute the current `InfiniteQueryObserverResult` +synchronously. + +#### Parameters + +##### options + +[`DefaultedInfiniteQueryObserverOptions`](../type-aliases/DefaultedInfiniteQueryObserverOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`, `TPageParam`\> + +#### Returns + +[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\> + +#### Overrides + +[`QueryObserver`](QueryObserver.md).[`getOptimisticResult`](QueryObserver.md#getoptimisticresult) + +*** + +### hasListeners() + +```ts +hasListeners(): boolean; +``` + +Defined in: [packages/query-core/src/subscribable.ts:19](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L19) + +#### Returns + +`boolean` + +#### Inherited from + +[`QueryObserver`](QueryObserver.md).[`hasListeners`](QueryObserver.md#haslisteners) + +*** + +### onSubscribe() + +```ts +protected onSubscribe(): void; +``` + +Defined in: [packages/query-core/src/queryObserver.ts:110](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L110) + +#### Returns + +`void` + +#### Inherited from + +[`QueryObserver`](QueryObserver.md).[`onSubscribe`](QueryObserver.md#onsubscribe) + +*** + +### onUnsubscribe() + +```ts +protected onUnsubscribe(): void; +``` + +Defined in: [packages/query-core/src/queryObserver.ts:124](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L124) + +#### Returns + +`void` + +#### Inherited from + +[`QueryObserver`](QueryObserver.md).[`onUnsubscribe`](QueryObserver.md#onunsubscribe) + +*** + +### refetch() + +```ts +refetch(__namedParameters): Promise>; +``` + +Defined in: [packages/query-core/src/queryObserver.ts:371](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L371) + +Refetches the observed query and returns a promise that resolves with +the resulting `QueryObserverResult`. + +#### Parameters + +##### \_\_namedParameters + +[`RefetchOptions`](../interfaces/RefetchOptions.md) = `{}` + +#### Returns + +`Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> + +#### Example + +```ts +const result = await observer.refetch({ cancelRefetch: false }) +console.log(result.data) +``` + +#### Inherited from + +[`QueryObserver`](QueryObserver.md).[`refetch`](QueryObserver.md#refetch) + +*** + +### setOptions() + +```ts +setOptions(options): void; +``` + +Defined in: [packages/query-core/src/infiniteQueryObserver.ts:108](https://github.com/TanStack/query/blob/main/packages/query-core/src/infiniteQueryObserver.ts#L108) + +Updates the observer's options. Behaves the same as +`QueryObserver.setOptions`, additionally marking the options as +belonging to an infinite query before delegating to the base +implementation. + +#### Parameters + +##### options + +[`InfiniteQueryObserverOptions`](../interfaces/InfiniteQueryObserverOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`, `TPageParam`\> + +#### Returns + +`void` + +#### Overrides + +[`QueryObserver`](QueryObserver.md).[`setOptions`](QueryObserver.md#setoptions) + +*** + +### shouldFetchOnReconnect() + +```ts +shouldFetchOnReconnect(): boolean; +``` + +Defined in: [packages/query-core/src/queryObserver.ts:135](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L135) + +Returns whether the observed query is currently stale and configured +(via the `refetchOnReconnect` option) to refetch when the network +reconnects. + +#### Returns + +`boolean` + +#### Inherited from + +[`QueryObserver`](QueryObserver.md).[`shouldFetchOnReconnect`](QueryObserver.md#shouldfetchonreconnect) + +*** + +### shouldFetchOnWindowFocus() + +```ts +shouldFetchOnWindowFocus(): boolean; +``` + +Defined in: [packages/query-core/src/queryObserver.ts:148](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L148) + +Returns whether the observed query is currently stale and configured +(via the `refetchOnWindowFocus` option) to refetch when the window +regains focus. + +#### Returns + +`boolean` + +#### Inherited from + +[`QueryObserver`](QueryObserver.md).[`shouldFetchOnWindowFocus`](QueryObserver.md#shouldfetchonwindowfocus) + +*** + +### trackProp() + +```ts +trackProp(key): void; +``` + +Defined in: [packages/query-core/src/queryObserver.ts:350](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L350) + +Records that the given `QueryObserverResult` property was read, so a subsequent update only +notifies this observer if a tracked property actually changed. Normally called indirectly via +[QueryObserver#trackResult](QueryObserver.md#trackresult)'s proxy; exposed directly for adapters that track property +access themselves (e.g. through their own reactivity system) instead of via the proxy. + +#### Parameters + +##### key + +`"error"` | `"data"` | `"isError"` | `"isPending"` | `"isLoading"` | `"isLoadingError"` | `"isRefetchError"` | `"isSuccess"` | `"isPlaceholderData"` | `"status"` | `"dataUpdatedAt"` | `"errorUpdatedAt"` | `"failureCount"` | `"failureReason"` | `"errorUpdateCount"` | `"isFetched"` | `"isFetchedAfterMount"` | `"isFetching"` | `"isInitialLoading"` | `"isPaused"` | `"isRefetching"` | `"isStale"` | `"isEnabled"` | `"refetch"` | `"fetchStatus"` + +#### Returns + +`void` + +#### Inherited from + +[`QueryObserver`](QueryObserver.md).[`trackProp`](QueryObserver.md#trackprop) + +*** + +### trackResult() + +```ts +trackResult(result, onPropTracked?): QueryObserverResult; +``` + +Defined in: [packages/query-core/src/queryObserver.ts:331](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L331) + +Wraps a `QueryObserverResult` in a `Proxy` that records which properties are read, via +[QueryObserver#trackProp](QueryObserver.md#trackprop) (and an optional `onPropTracked` callback). Used by framework +adapters when `notifyOnChangeProps` is not set, to implement its default "only re-render on +properties you actually read" behavior. + +#### Parameters + +##### result + +[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\> + +##### onPropTracked? + +(`key`) => `void` + +#### Returns + +[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\> + +#### Inherited from + +[`QueryObserver`](QueryObserver.md).[`trackResult`](QueryObserver.md#trackresult) + +*** + +### updateResult() + +```ts +updateResult(): void; +``` + +Defined in: [packages/query-core/src/queryObserver.ts:735](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L735) + +Recomputes and stores the current result from the current query/options, notifying listeners +if it changed. Framework adapters call this right after subscribing to make sure no query +update was missed in the gap between creating the observer and subscribing to it. + +#### Returns + +`void` + +#### Inherited from + +[`QueryObserver`](QueryObserver.md).[`updateResult`](QueryObserver.md#updateresult) diff --git a/docs/framework/preact/reference/classes/Mutation.md b/docs/framework/preact/reference/classes/Mutation.md new file mode 100644 index 00000000000..e038a9cd394 --- /dev/null +++ b/docs/framework/preact/reference/classes/Mutation.md @@ -0,0 +1,330 @@ +--- +id: Mutation +title: Mutation +--- + +Defined in: [packages/query-core/src/mutation.ts:135](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L135) + +Represents a single mutation attempt. A `Mutation` holds the mutation's +options, state (data/error/status), and the `MutationObserver`s currently +subscribed to it. + +Instances are created and managed internally by `MutationCache`; application +code typically interacts with mutations indirectly through `QueryClient` or +a framework hook like `useMutation`. Direct access to a `Mutation` instance +is possible via `mutationCache.find()`/`getAll()` for inspecting cache state. + +## Example + +```ts +const mutationCache = queryClient.getMutationCache() + +const mutation = mutationCache.find({ mutationKey: ['addPost'] }) +``` + +## Extends + +- `Removable` + +## Type Parameters + +### TData + +`TData` = `unknown` + +### TError + +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) + +### TVariables + +`TVariables` = `unknown` + +### TOnMutateResult + +`TOnMutateResult` = `unknown` + +## Constructors + +### Constructor + +```ts +new Mutation(config): Mutation; +``` + +Defined in: [packages/query-core/src/mutation.ts:152](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L152) + +#### Parameters + +##### config + +`MutationConfig`\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\> + +#### Returns + +`Mutation`\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\> + +#### Overrides + +```ts +Removable.constructor +``` + +## Properties + +### gcTime + +```ts +gcTime: number; +``` + +Defined in: [packages/query-core/src/removable.ts:7](https://github.com/TanStack/query/blob/main/packages/query-core/src/removable.ts#L7) + +#### Inherited from + +```ts +Removable.gcTime +``` + +*** + +### mutationId + +```ts +readonly mutationId: number; +``` + +Defined in: [packages/query-core/src/mutation.ts:143](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L143) + +*** + +### options + +```ts +options: MutationOptions; +``` + +Defined in: [packages/query-core/src/mutation.ts:142](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L142) + +*** + +### state + +```ts +state: MutationState; +``` + +Defined in: [packages/query-core/src/mutation.ts:141](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L141) + +## Accessors + +### meta + +#### Get Signature + +```ts +get meta(): Record | undefined; +``` + +Defined in: [packages/query-core/src/mutation.ts:179](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L179) + +The `meta` object passed in the mutation's options, if any. + +##### Returns + +`Record`\<`string`, `unknown`\> \| `undefined` + +## Methods + +### clearGcTimeout() + +```ts +protected clearGcTimeout(): void; +``` + +Defined in: [packages/query-core/src/removable.ts:32](https://github.com/TanStack/query/blob/main/packages/query-core/src/removable.ts#L32) + +#### Returns + +`void` + +#### Inherited from + +```ts +Removable.clearGcTimeout +``` + +*** + +### continue() + +```ts +continue(): Promise; +``` + +Defined in: [packages/query-core/src/mutation.ts:243](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L243) + +Resumes a mutation that is currently paused or was restored from a +dehydrated, still-`pending` state. + +- If this mutation has an active retryer (it paused mid-attempt, e.g. due + to the network mode or scope-based queuing), its retryer is resumed. +- Otherwise, if the mutation's status is still `pending` (e.g. it was + dehydrated while an attempt was in flight and never got a retryer in + this instance), `execute` is called again with the last known variables. +- Otherwise the mutation has already settled and this resolves immediately + without running anything again. + +#### Returns + +`Promise`\<`unknown`\> + +#### Example + +```ts +// typically driven by reconnect handling, e.g. queryClient.resumePausedMutations() +const mutation = mutationCache.find({ mutationKey: ['addPost'] }) +await mutation?.continue() +``` + +#### See + +[Mutation#execute](#execute) + +*** + +### destroy() + +```ts +destroy(): void; +``` + +Defined in: [packages/query-core/src/removable.ts:10](https://github.com/TanStack/query/blob/main/packages/query-core/src/removable.ts#L10) + +#### Returns + +`void` + +#### Inherited from + +```ts +Removable.destroy +``` + +*** + +### execute() + +```ts +execute(variables): Promise; +``` + +Defined in: [packages/query-core/src/mutation.ts:284](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L284) + +Runs the mutation function for the given variables through a retryer, and +drives the mutation's state and lifecycle callbacks through to settlement. + +If this mutation's state is already `pending` when `execute` is called +(i.e. it was restored, still in-flight, from a dehydrated state), the +`onMutate` step is skipped and a `continue` action is dispatched to +unpause it; otherwise a `pending` action is dispatched first, then the +mutation cache's `onMutate` and the mutation's own `onMutate` option are +awaited in that order, and the resulting context is stored. + +The mutation function is then run (subject to `retry`/`retryDelay`/ +`networkMode`, and to the mutation cache's scope-based serialization). +On success, the cache's `onSuccess`/`onSettled` callbacks run before the +mutation's own `onSuccess`/`onSettled` options, a `success` action is +dispatched, and the resolved data is returned. On failure, the same +cache-then-option ordering is used for `onError`/`onSettled`, but each of +those four callbacks is individually caught so that a throwing callback +cannot mask the original error; an `error` action is then dispatched and +the original error is re-thrown. + +#### Parameters + +##### variables + +`TVariables` + +#### Returns + +`Promise`\<`TData`\> + +#### Example + +```ts +// Called internally by `MutationObserver.mutate` and `Mutation.continue` — +// applications normally trigger mutations through those, not this method. +const data = await mutation.execute(variables) +``` + +#### See + +[Mutation#continue](#continue) + +*** + +### optionalRemove() + +```ts +protected optionalRemove(): void; +``` + +Defined in: [packages/query-core/src/mutation.ts:212](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L212) + +#### Returns + +`void` + +#### Overrides + +```ts +Removable.optionalRemove +``` + +*** + +### scheduleGc() + +```ts +protected scheduleGc(): void; +``` + +Defined in: [packages/query-core/src/removable.ts:14](https://github.com/TanStack/query/blob/main/packages/query-core/src/removable.ts#L14) + +#### Returns + +`void` + +#### Inherited from + +```ts +Removable.scheduleGc +``` + +*** + +### updateGcTime() + +```ts +protected updateGcTime(newGcTime): void; +``` + +Defined in: [packages/query-core/src/removable.ts:24](https://github.com/TanStack/query/blob/main/packages/query-core/src/removable.ts#L24) + +#### Parameters + +##### newGcTime + +`number` | `undefined` + +#### Returns + +`void` + +#### Inherited from + +```ts +Removable.updateGcTime +``` diff --git a/docs/framework/preact/reference/classes/MutationCache.md b/docs/framework/preact/reference/classes/MutationCache.md new file mode 100644 index 00000000000..5a172b4cb9b --- /dev/null +++ b/docs/framework/preact/reference/classes/MutationCache.md @@ -0,0 +1,316 @@ +--- +id: MutationCache +title: MutationCache +--- + +Defined in: [packages/query-core/src/mutationCache.ts:124](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationCache.ts#L124) + +The `MutationCache` is the storage for mutations. + +Normally, you will not interact with the `MutationCache` directly and instead use a +`QueryClient`. You can subscribe to it (inherited from `Subscribable`) to be informed of +safe/known updates to the cache, such as mutations being added, removed, or updated. + +## Example + +```ts +const unsubscribe = mutationCache.subscribe((event) => { + console.log(event.type, event.mutation) +}) +``` + +## Extends + +- `Subscribable`\<`MutationCacheListener`\> + +## Constructors + +### Constructor + +```ts +new MutationCache(config): MutationCache; +``` + +Defined in: [packages/query-core/src/mutationCache.ts:129](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationCache.ts#L129) + +#### Parameters + +##### config + +[`MutationCacheConfig`](../interfaces/MutationCacheConfig.md) = `{}` + +#### Returns + +`MutationCache` + +#### Overrides + +```ts +Subscribable.constructor +``` + +## Properties + +### config + +```ts +config: MutationCacheConfig = {}; +``` + +Defined in: [packages/query-core/src/mutationCache.ts:129](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationCache.ts#L129) + +*** + +### listeners + +```ts +protected listeners: Set; +``` + +Defined in: [packages/query-core/src/subscribable.ts:2](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L2) + +#### Inherited from + +```ts +Subscribable.listeners +``` + +## Methods + +### clear() + +```ts +clear(): void; +``` + +Defined in: [packages/query-core/src/mutationCache.ts:236](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationCache.ts#L236) + +Removes all mutations from the cache. + +#### Returns + +`void` + +#### Example + +```ts +const mutationCache = queryClient.getMutationCache() + +mutationCache.clear() +``` + +*** + +### find() + +```ts +find(filters): + | Mutation + | undefined; +``` + +Defined in: [packages/query-core/src/mutationCache.ts:278](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationCache.ts#L278) + +A slightly more advanced method that can be used to get an existing mutation instance from +the cache. If the mutation does not exist, `undefined` is returned. + +This is not typically needed for most applications, but can come in handy when needing more +information about a mutation in rare scenarios. + +#### Type Parameters + +##### TData + +`TData` = `unknown` + +##### TError + +`TError` = `Error` + +##### TVariables + +`TVariables` = `any` + +##### TOnMutateResult + +`TOnMutateResult` = `unknown` + +#### Parameters + +##### filters + +[`MutationFilters`](../interfaces/MutationFilters.md) + +#### Returns + + \| [`Mutation`](Mutation.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\> + \| `undefined` + +#### See + +[MutationCache#findAll](#findall) + +#### Example + +```ts +const mutationCache = queryClient.getMutationCache() + +const mutation = mutationCache.find({ mutationKey: ['addPost'] }) +``` + +*** + +### findAll() + +```ts +findAll(filters): Mutation[]; +``` + +Defined in: [packages/query-core/src/mutationCache.ts:308](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationCache.ts#L308) + +An even more advanced method that can be used to get existing mutation instances from the +cache that match the given filters. If no mutations match, an empty array is returned. + +This is not typically needed for most applications, but can come in handy when needing more +information about mutations in rare scenarios. + +#### Parameters + +##### filters + +[`MutationFilters`](../interfaces/MutationFilters.md) = `{}` + +#### Returns + +[`Mutation`](Mutation.md)\<`unknown`, `Error`, `unknown`, `unknown`\>[] + +#### See + +[MutationCache#find](#find) + +#### Example + +```ts +const mutationCache = queryClient.getMutationCache() + +const mutations = mutationCache.findAll({ mutationKey: ['addPost'] }) +``` + +*** + +### getAll() + +```ts +getAll(): Mutation[]; +``` + +Defined in: [packages/query-core/src/mutationCache.ts:259](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationCache.ts#L259) + +Returns all mutations within the cache. + +This is not typically needed for most applications, but can come in handy when needing more +information about a mutation in rare scenarios. + +#### Returns + +[`Mutation`](Mutation.md)\<`unknown`, `Error`, `unknown`, `unknown`\>[] + +#### Example + +```ts +const mutationCache = queryClient.getMutationCache() + +const mutations = mutationCache.getAll() +``` + +*** + +### hasListeners() + +```ts +hasListeners(): boolean; +``` + +Defined in: [packages/query-core/src/subscribable.ts:19](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L19) + +#### Returns + +`boolean` + +#### Inherited from + +```ts +Subscribable.hasListeners +``` + +*** + +### onSubscribe() + +```ts +protected onSubscribe(): void; +``` + +Defined in: [packages/query-core/src/subscribable.ts:23](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L23) + +#### Returns + +`void` + +#### Inherited from + +```ts +Subscribable.onSubscribe +``` + +*** + +### onUnsubscribe() + +```ts +protected onUnsubscribe(): void; +``` + +Defined in: [packages/query-core/src/subscribable.ts:27](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L27) + +#### Returns + +`void` + +#### Inherited from + +```ts +Subscribable.onUnsubscribe +``` + +*** + +### subscribe() + +```ts +subscribe(listener): () => void; +``` + +Defined in: [packages/query-core/src/subscribable.ts:8](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L8) + +#### Parameters + +##### listener + +`MutationCacheListener` + +#### Returns + +```ts +(): void; +``` + +##### Returns + +`void` + +#### Inherited from + +```ts +Subscribable.subscribe +``` diff --git a/docs/framework/preact/reference/classes/MutationObserver.md b/docs/framework/preact/reference/classes/MutationObserver.md new file mode 100644 index 00000000000..a121c67b0e8 --- /dev/null +++ b/docs/framework/preact/reference/classes/MutationObserver.md @@ -0,0 +1,335 @@ +--- +id: MutationObserver +title: MutationObserver +--- + +Defined in: [packages/query-core/src/mutationObserver.ts:38](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationObserver.ts#L38) + +Observes a single mutation and derives a `MutationObserverResult` from it. +A framework hook like `useMutation` creates one `MutationObserver` per hook +call, keeps it stable across re-renders, calls `setOptions` when the options +passed to the hook change, subscribes to it to re-render on updates, and +reads `getCurrentResult()` for the value to return. Calling `mutate()` +builds a new underlying `Mutation` in the `MutationCache` and executes it. + +## Example + +```ts +const observer = new MutationObserver(queryClient, { + mutationFn: (variables: { title: string }) => addPost(variables), +}) +``` + +## Extends + +- `Subscribable`\<`MutationObserverListener`\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\>\> + +## Type Parameters + +### TData + +`TData` = `unknown` + +### TError + +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) + +### TVariables + +`TVariables` = `void` + +### TOnMutateResult + +`TOnMutateResult` = `unknown` + +## Constructors + +### Constructor + +```ts +new MutationObserver(client, options): MutationObserver; +``` + +Defined in: [packages/query-core/src/mutationObserver.ts:58](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationObserver.ts#L58) + +#### Parameters + +##### client + +[`QueryClient`](QueryClient.md) + +##### options + +[`MutationObserverOptions`](../interfaces/MutationObserverOptions.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\> + +#### Returns + +`MutationObserver`\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\> + +#### Overrides + +```ts +Subscribable< + MutationObserverListener +>.constructor +``` + +## Properties + +### listeners + +```ts +protected listeners: Set>; +``` + +Defined in: [packages/query-core/src/subscribable.ts:2](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L2) + +#### Inherited from + +```ts +Subscribable.listeners +``` + +*** + +### options + +```ts +options: MutationObserverOptions; +``` + +Defined in: [packages/query-core/src/mutationObserver.ts:46](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationObserver.ts#L46) + +## Methods + +### bindMethods() + +```ts +protected bindMethods(): void; +``` + +Defined in: [packages/query-core/src/mutationObserver.ts:75](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationObserver.ts#L75) + +#### Returns + +`void` + +*** + +### getCurrentResult() + +```ts +getCurrentResult(): MutationObserverResult; +``` + +Defined in: [packages/query-core/src/mutationObserver.ts:155](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationObserver.ts#L155) + +Returns the observer's current result, derived from the observed +mutation's state (or the default, `idle` state if no mutation has been +built yet, e.g. before the first `mutate()` call or after `reset()`). + +#### Returns + +[`MutationObserverResult`](../type-aliases/MutationObserverResult.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\> + +*** + +### hasListeners() + +```ts +hasListeners(): boolean; +``` + +Defined in: [packages/query-core/src/subscribable.ts:19](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L19) + +#### Returns + +`boolean` + +#### Inherited from + +```ts +Subscribable.hasListeners +``` + +*** + +### mutate() + +```ts +mutate(variables, options?): Promise; +``` + +Defined in: [packages/query-core/src/mutationObserver.ts:207](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationObserver.ts#L207) + +Builds a new `Mutation` in the `MutationCache` using the observer's +current options, detaches this observer from any previously observed +mutation, attaches it to the new one, and executes it with the given +variables. + +The optional per-call `options` (`onSuccess`/`onError`/`onSettled`) are +invoked once the mutation settles, in addition to any callbacks defined +on the observer's own options. + +#### Parameters + +##### variables + +`TVariables` + +##### options? + +[`MutateOptions`](../interfaces/MutateOptions.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\> + +#### Returns + +`Promise`\<`TData`\> + +#### Example + +```ts +await observer.mutate( + { title: 'New post' }, + { onSuccess: (data) => console.log(data) }, +) +``` + +*** + +### onSubscribe() + +```ts +protected onSubscribe(): void; +``` + +Defined in: [packages/query-core/src/mutationObserver.ts:127](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationObserver.ts#L127) + +#### Returns + +`void` + +#### Overrides + +```ts +Subscribable.onSubscribe +``` + +*** + +### onUnsubscribe() + +```ts +protected onUnsubscribe(): void; +``` + +Defined in: [packages/query-core/src/mutationObserver.ts:135](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationObserver.ts#L135) + +#### Returns + +`void` + +#### Overrides + +```ts +Subscribable.onUnsubscribe +``` + +*** + +### reset() + +```ts +reset(): void; +``` + +Defined in: [packages/query-core/src/mutationObserver.ts:180](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationObserver.ts#L180) + +Detaches the observer from the mutation it is currently observing (if +any) and resets the observed result back to its default, `idle` state. + +This does not cancel an in-flight mutation; the mutation itself keeps +running to completion and its own callbacks still fire, but this +observer stops reflecting its state and a subsequent `mutate()` call +will build a brand new mutation. + +#### Returns + +`void` + +#### Example + +```ts +observer.reset() +``` + +#### See + +[MutationObserver#mutate](#mutate) + +*** + +### setOptions() + +```ts +setOptions(options): void; +``` + +Defined in: [packages/query-core/src/mutationObserver.ts:96](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationObserver.ts#L96) + +Updates the observer's options. + +If the new `mutationKey` differs from the previous one (and both were +defined), the observer is reset, detaching it from the mutation it was +observing. Otherwise, if the currently observed mutation is still +`pending`, its options are updated in place as well. + +#### Parameters + +##### options + +[`MutationObserverOptions`](../interfaces/MutationObserverOptions.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\> + +#### Returns + +`void` + +#### Example + +```ts +observer.setOptions({ + mutationFn: (variables: { title: string }) => addPost(variables), + onSuccess: (data) => console.log(data), +}) +``` + +*** + +### subscribe() + +```ts +subscribe(listener): () => void; +``` + +Defined in: [packages/query-core/src/subscribable.ts:8](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L8) + +#### Parameters + +##### listener + +`MutationObserverListener` + +#### Returns + +```ts +(): void; +``` + +##### Returns + +`void` + +#### Inherited from + +```ts +Subscribable.subscribe +``` diff --git a/docs/framework/preact/reference/classes/QueriesObserver.md b/docs/framework/preact/reference/classes/QueriesObserver.md new file mode 100644 index 00000000000..379e6fc95ee --- /dev/null +++ b/docs/framework/preact/reference/classes/QueriesObserver.md @@ -0,0 +1,325 @@ +--- +id: QueriesObserver +title: QueriesObserver +--- + +Defined in: [packages/query-core/src/queriesObserver.ts:56](https://github.com/TanStack/query/blob/main/packages/query-core/src/queriesObserver.ts#L56) + +A `QueriesObserver` watches an array of queries at once, exposing them as +a single array of `QueryObserverResult`s (or, when a `combine` option is +given, as a combined value derived from that array). It manages one +internal `QueryObserver` per query, and is the primitive that framework +adapters (e.g. `useQueries`) build their hooks on top of. + +## Example + +```ts +const observer = new QueriesObserver(queryClient, [ + { queryKey: ['post', 1], queryFn: fetchPost }, + { queryKey: ['post', 2], queryFn: fetchPost }, +]) + +const unsubscribe = observer.subscribe((result) => { + console.log(result) +}) +``` + +## Extends + +- `Subscribable`\<`QueriesObserverListener`\> + +## Type Parameters + +### TCombinedResult + +`TCombinedResult` = [`QueryObserverResult`](../type-aliases/QueryObserverResult.md)[] + +## Constructors + +### Constructor + +```ts +new QueriesObserver( + client, + queries, +options?): QueriesObserver; +``` + +Defined in: [packages/query-core/src/queriesObserver.ts:70](https://github.com/TanStack/query/blob/main/packages/query-core/src/queriesObserver.ts#L70) + +#### Parameters + +##### client + +[`QueryClient`](QueryClient.md) + +##### queries + +[`QueryObserverOptions`](../interfaces/QueryObserverOptions.md)\<`any`, `any`, `any`, `any`, `any`, `never`\>[] + +##### options? + +[`QueriesObserverOptions`](../interfaces/QueriesObserverOptions.md)\<`TCombinedResult`\> + +#### Returns + +`QueriesObserver`\<`TCombinedResult`\> + +#### Overrides + +```ts +Subscribable.constructor +``` + +## Properties + +### listeners + +```ts +protected listeners: Set; +``` + +Defined in: [packages/query-core/src/subscribable.ts:2](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L2) + +#### Inherited from + +```ts +Subscribable.listeners +``` + +## Methods + +### destroy() + +```ts +destroy(): void; +``` + +Defined in: [packages/query-core/src/queriesObserver.ts:106](https://github.com/TanStack/query/blob/main/packages/query-core/src/queriesObserver.ts#L106) + +Stops observing all queries: clears all listeners and destroys every +underlying `QueryObserver` this observer manages. + +#### Returns + +`void` + +*** + +### getCurrentResult() + +```ts +getCurrentResult(): QueryObserverResult[]; +``` + +Defined in: [packages/query-core/src/queriesObserver.ts:210](https://github.com/TanStack/query/blob/main/packages/query-core/src/queriesObserver.ts#L210) + +Returns the most recently computed array of `QueryObserverResult`s, one +per observed query, in the same order as the queries passed to the +constructor or `setQueries`. + +#### Returns + +[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)[] + +#### Example + +```ts +const results = observer.getCurrentResult() +const data = results.map((result) => result.data) +``` + +*** + +### getObservers() + +```ts +getObservers(): QueryObserver[]; +``` + +Defined in: [packages/query-core/src/queriesObserver.ts:227](https://github.com/TanStack/query/blob/main/packages/query-core/src/queriesObserver.ts#L227) + +Returns the underlying `QueryObserver` instances this observer manages, +in the same order as the queries passed to the constructor or +`setQueries`. + +#### Returns + +[`QueryObserver`](QueryObserver.md)\<`unknown`, `Error`, `unknown`, `unknown`, readonly `unknown`[]\>[] + +*** + +### getOptimisticResult() + +```ts +getOptimisticResult(queries, combine): [QueryObserverResult[], (r?) => TCombinedResult, () => QueryObserverResult[]]; +``` + +Defined in: [packages/query-core/src/queriesObserver.ts:238](https://github.com/TanStack/query/blob/main/packages/query-core/src/queriesObserver.ts#L238) + +The `QueriesObserver` counterpart of [QueryObserver#getOptimisticResult](QueryObserver.md#getoptimisticresult) — computes +the result for the given (already-defaulted) queries right now, synchronously. Called by +framework adapters (e.g. `useQueries`) ahead of subscribing, returning a tuple of the raw +per-query results, a function to compute the combined result from them, and a function to +wrap the results for property-access tracking. + +#### Parameters + +##### queries + +[`QueryObserverOptions`](../interfaces/QueryObserverOptions.md)\<`unknown`, `Error`, `unknown`, `unknown`, readonly `unknown`[], `never`\>[] + +##### combine + +`CombineFn`\<`TCombinedResult`\> | `undefined` + +#### Returns + +\[[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)[], (`r?`) => `TCombinedResult`, () => [`QueryObserverResult`](../type-aliases/QueryObserverResult.md)[]\] + +*** + +### getQueries() + +```ts +getQueries(): Query[]; +``` + +Defined in: [packages/query-core/src/queriesObserver.ts:218](https://github.com/TanStack/query/blob/main/packages/query-core/src/queriesObserver.ts#L218) + +Returns the underlying `Query` instances currently being observed, in +the same order as the queries passed to the constructor or `setQueries`. + +#### Returns + +[`Query`](Query.md)\<`unknown`, `Error`, `unknown`, readonly `unknown`[]\>[] + +*** + +### hasListeners() + +```ts +hasListeners(): boolean; +``` + +Defined in: [packages/query-core/src/subscribable.ts:19](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L19) + +#### Returns + +`boolean` + +#### Inherited from + +```ts +Subscribable.hasListeners +``` + +*** + +### onSubscribe() + +```ts +protected onSubscribe(): void; +``` + +Defined in: [packages/query-core/src/queriesObserver.ts:86](https://github.com/TanStack/query/blob/main/packages/query-core/src/queriesObserver.ts#L86) + +#### Returns + +`void` + +#### Overrides + +```ts +Subscribable.onSubscribe +``` + +*** + +### onUnsubscribe() + +```ts +protected onUnsubscribe(): void; +``` + +Defined in: [packages/query-core/src/queriesObserver.ts:96](https://github.com/TanStack/query/blob/main/packages/query-core/src/queriesObserver.ts#L96) + +#### Returns + +`void` + +#### Overrides + +```ts +Subscribable.onUnsubscribe +``` + +*** + +### setQueries() + +```ts +setQueries(queries, options?): void; +``` + +Defined in: [packages/query-core/src/queriesObserver.ts:127](https://github.com/TanStack/query/blob/main/packages/query-core/src/queriesObserver.ts#L127) + +Replaces the set of queries being observed. Existing `QueryObserver`s +are reused for queries that match an already-observed query hash; +observers for queries that are no longer present are destroyed, and new +observers are created and subscribed to for newly added queries. + +#### Parameters + +##### queries + +[`QueryObserverOptions`](../interfaces/QueryObserverOptions.md)\<`unknown`, `Error`, `unknown`, `unknown`, readonly `unknown`[], `never`\>[] + +##### options? + +[`QueriesObserverOptions`](../interfaces/QueriesObserverOptions.md)\<`TCombinedResult`\> + +#### Returns + +`void` + +#### Example + +```ts +observer.setQueries([ + { queryKey: ['post', 1], queryFn: fetchPost }, + { queryKey: ['post', 3], queryFn: fetchPost }, +]) +``` + +*** + +### subscribe() + +```ts +subscribe(listener): () => void; +``` + +Defined in: [packages/query-core/src/subscribable.ts:8](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L8) + +#### Parameters + +##### listener + +`QueriesObserverListener` + +#### Returns + +```ts +(): void; +``` + +##### Returns + +`void` + +#### Inherited from + +```ts +Subscribable.subscribe +``` diff --git a/docs/framework/preact/reference/classes/Query.md b/docs/framework/preact/reference/classes/Query.md new file mode 100644 index 00000000000..bc15461e541 --- /dev/null +++ b/docs/framework/preact/reference/classes/Query.md @@ -0,0 +1,585 @@ +--- +id: Query +title: Query +--- + +Defined in: [packages/query-core/src/query.ts:225](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L225) + +Represents a single cached query. A `Query` holds the query's key, options, +state (data/error/status), and the observers currently subscribed to it. + +Instances are created and managed internally by `QueryCache`; application +code typically interacts with queries indirectly through `QueryClient` or +a framework hook like `useQuery`. Direct access to a `Query` instance is +possible via `queryCache.find()`/`findAll()` for inspecting cache state. + +## Example + +```ts +const queryCache = queryClient.getQueryCache() +const query = queryCache.find({ queryKey: ['posts'] }) + +if (query) { + console.log(query.state.dataUpdatedAt) +} +``` + +## Extends + +- `Removable` + +## Type Parameters + +### TQueryFnData + +`TQueryFnData` = `unknown` + +### TError + +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) + +### TData + +`TData` = `TQueryFnData` + +### TQueryKey + +`TQueryKey` *extends* [`QueryKey`](../type-aliases/QueryKey.md) = [`QueryKey`](../type-aliases/QueryKey.md) + +## Constructors + +### Constructor + +```ts +new Query(config): Query; +``` + +Defined in: [packages/query-core/src/query.ts:246](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L246) + +#### Parameters + +##### config + +`QueryConfig`\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`\> + +#### Returns + +`Query`\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`\> + +#### Overrides + +```ts +Removable.constructor +``` + +## Properties + +### gcTime + +```ts +gcTime: number; +``` + +Defined in: [packages/query-core/src/removable.ts:7](https://github.com/TanStack/query/blob/main/packages/query-core/src/removable.ts#L7) + +#### Inherited from + +```ts +Removable.gcTime +``` + +*** + +### observers + +```ts +observers: QueryObserver[]; +``` + +Defined in: [packages/query-core/src/query.ts:242](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L242) + +*** + +### options + +```ts +options: QueryOptions; +``` + +Defined in: [packages/query-core/src/query.ts:233](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L233) + +*** + +### queryHash + +```ts +queryHash: string; +``` + +Defined in: [packages/query-core/src/query.ts:232](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L232) + +*** + +### queryKey + +```ts +queryKey: TQueryKey; +``` + +Defined in: [packages/query-core/src/query.ts:231](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L231) + +*** + +### state + +```ts +state: QueryState; +``` + +Defined in: [packages/query-core/src/query.ts:234](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L234) + +## Accessors + +### meta + +#### Get Signature + +```ts +get meta(): Record | undefined; +``` + +Defined in: [packages/query-core/src/query.ts:264](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L264) + +The `meta` object passed in the query's options, if any. + +##### Returns + +`Record`\<`string`, `unknown`\> \| `undefined` + +*** + +### promise + +#### Get Signature + +```ts +get promise(): Promise | undefined; +``` + +Defined in: [packages/query-core/src/query.ts:277](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L277) + +The promise for the currently in-flight fetch, if the query is fetching. +`undefined` when the query is not fetching. + +##### Returns + +`Promise`\<`TData`\> \| `undefined` + +## Methods + +### cancel() + +```ts +cancel(options?): Promise; +``` + +Defined in: [packages/query-core/src/query.ts:348](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L348) + +Cancels the query's currently in-flight fetch, if any. +- Returns a promise that resolves once the cancellation has settled. +- If no fetch is in progress, resolves immediately. + +#### Parameters + +##### options? + +[`CancelOptions`](../interfaces/CancelOptions.md) + +#### Returns + +`Promise`\<`void`\> + +#### Example + +```ts +await query.cancel() +``` + +*** + +### clearGcTimeout() + +```ts +protected clearGcTimeout(): void; +``` + +Defined in: [packages/query-core/src/removable.ts:32](https://github.com/TanStack/query/blob/main/packages/query-core/src/removable.ts#L32) + +#### Returns + +`void` + +#### Inherited from + +```ts +Removable.clearGcTimeout +``` + +*** + +### destroy() + +```ts +destroy(): void; +``` + +Defined in: [packages/query-core/src/query.ts:361](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L361) + +Clears the query's garbage collection timeout and silently cancels any +in-flight fetch. Called by `QueryCache` when the query is removed from +the cache. + +#### Returns + +`void` + +#### See + +[Query#cancel](#cancel) + +#### Overrides + +```ts +Removable.destroy +``` + +*** + +### fetch() + +```ts +fetch(options?, fetchOptions?): Promise; +``` + +Defined in: [packages/query-core/src/query.ts:590](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L590) + +Fetches the query, i.e. runs its `queryFn` (through any configured +retryer/behavior) and updates the query's state with the result. +- If a fetch is already in flight, returns its promise instead of + starting a new one, unless `fetchOptions.cancelRefetch` is set and the + query already has data, in which case the current fetch is silently + cancelled first. +- If `options` is passed, it replaces the query's current options + before fetching. + +#### Parameters + +##### options? + +[`QueryOptions`](../interfaces/QueryOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`, `never`\> + +##### fetchOptions? + +`FetchOptions`\<`TQueryFnData`\> + +#### Returns + +`Promise`\<`TData`\> + +*** + +### getObserversCount() + +```ts +getObserversCount(): number; +``` + +Defined in: [packages/query-core/src/query.ts:560](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L560) + +Returns the number of observers currently subscribed to this query. + +#### Returns + +`number` + +#### Example + +```ts +if (query.getObserversCount() === 0) { + // no component is currently watching this query +} +``` + +*** + +### invalidate() + +```ts +invalidate(): void; +``` + +Defined in: [packages/query-core/src/query.ts:574](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L574) + +Marks the query as invalidated, unless it is already invalidated. This +updates `state.isInvalidated` and notifies observers, but does not by +itself trigger a refetch. + +#### Returns + +`void` + +#### Example + +```ts +query.invalidate() +``` + +*** + +### isActive() + +```ts +isActive(): boolean; +``` + +Defined in: [packages/query-core/src/query.ts:386](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L386) + +Returns `true` if the query has at least one observer for which `enabled` +does not resolve to `false`. + +#### Returns + +`boolean` + +*** + +### isDisabled() + +```ts +isDisabled(): boolean; +``` + +Defined in: [packages/query-core/src/query.ts:400](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L400) + +Returns `true` if the query is disabled, meaning it will not fetch +automatically. +- If the query has observers, it is disabled when none of them are active + (see `isActive`). +- If the query has no observers, it is disabled when its `queryFn` is + `skipToken` or it has never been fetched. + +#### Returns + +`boolean` + +*** + +### isFetched() + +```ts +isFetched(): boolean; +``` + +Defined in: [packages/query-core/src/query.ts:412](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L412) + +Returns `true` if the query has been fetched, i.e. it has resolved with +either data or an error at least once. + +#### Returns + +`boolean` + +*** + +### isStale() + +```ts +isStale(): boolean; +``` + +Defined in: [packages/query-core/src/query.ts:447](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L447) + +Returns `true` if the query is stale. +- If the query has observers, defers to whether any observer's current + result reports `isStale` (which accounts for each observer's own + `staleTime` and `enabled` state). +- If the query has no observers, it is considered stale when it has no + data or has been invalidated. + +#### Returns + +`boolean` + +#### See + +[Query#isStaleByTime](#isstalebytime) + +#### Example + +```ts +if (query.isStale()) { + // refetch or otherwise treat the cached data as outdated +} +``` + +*** + +### isStaleByTime() + +```ts +isStaleByTime(staleTime): boolean; +``` + +Defined in: [packages/query-core/src/query.ts:473](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L473) + +Returns `true` if the query's data is stale relative to the given +`staleTime` (defaults to `0`). +- A query with no data is always stale. +- `staleTime: 'static'` is never stale. +- An invalidated query is always stale. +- Otherwise, staleness is based on elapsed time since `dataUpdatedAt`. + +#### Parameters + +##### staleTime + +[`StaleTime`](../type-aliases/StaleTime.md) = `0` + +#### Returns + +`boolean` + +#### See + +[Query#isStale](#isstale) + +#### Example + +```ts +const isStale = query.isStaleByTime(1000 * 60) +``` + +*** + +### isStatic() + +```ts +isStatic(): boolean; +``` + +Defined in: [packages/query-core/src/query.ts:420](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L420) + +Returns `true` if the query has at least one observer configured with +`staleTime: 'static'`, meaning it is treated as never stale. + +#### Returns + +`boolean` + +*** + +### optionalRemove() + +```ts +protected optionalRemove(): void; +``` + +Defined in: [packages/query-core/src/query.ts:305](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L305) + +#### Returns + +`void` + +#### Overrides + +```ts +Removable.optionalRemove +``` + +*** + +### reset() + +```ts +reset(): void; +``` + +Defined in: [packages/query-core/src/query.ts:377](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L377) + +Resets the query back to its initial state (the state it had when it was +first created, e.g. any `initialData`), destroying it first to cancel any +in-flight fetch. + +#### Returns + +`void` + +*** + +### scheduleGc() + +```ts +protected scheduleGc(): void; +``` + +Defined in: [packages/query-core/src/removable.ts:14](https://github.com/TanStack/query/blob/main/packages/query-core/src/removable.ts#L14) + +#### Returns + +`void` + +#### Inherited from + +```ts +Removable.scheduleGc +``` + +*** + +### setState() + +```ts +setState(state): void; +``` + +Defined in: [packages/query-core/src/query.ts:334](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L334) + +Merges the given partial state directly into this query's state, notifying observers. Used +by persistence and broadcast plugins to restore a state snapshot, and by devtools to let a +user manually trigger a loading/error state or edit the cached data. + +#### Parameters + +##### state + +`Partial`\<[`QueryState`](../interfaces/QueryState.md)\<`TData`, `TError`\>\> + +#### Returns + +`void` + +*** + +### updateGcTime() + +```ts +protected updateGcTime(newGcTime): void; +``` + +Defined in: [packages/query-core/src/removable.ts:24](https://github.com/TanStack/query/blob/main/packages/query-core/src/removable.ts#L24) + +#### Parameters + +##### newGcTime + +`number` | `undefined` + +#### Returns + +`void` + +#### Inherited from + +```ts +Removable.updateGcTime +``` diff --git a/docs/framework/preact/reference/classes/QueryCache.md b/docs/framework/preact/reference/classes/QueryCache.md new file mode 100644 index 00000000000..b7a577b5e54 --- /dev/null +++ b/docs/framework/preact/reference/classes/QueryCache.md @@ -0,0 +1,471 @@ +--- +id: QueryCache +title: QueryCache +--- + +Defined in: [packages/query-core/src/queryCache.ts:123](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryCache.ts#L123) + +The `QueryCache` is the storage mechanism for TanStack Query. It stores all the data, meta +information, and state of the queries it contains. + +Normally, you will not interact with the `QueryCache` directly and instead use a `QueryClient` +for a specific cache. You can subscribe to it (inherited from `Subscribable`) to be informed of +safe/known updates to the cache, such as queries being added, removed, or updated — updates made +outside of the cache's own tracked mechanisms (e.g. mutating a query's state object directly) do +not notify subscribers. + +## Example + +```ts +const unsubscribe = queryCache.subscribe((event) => { + console.log(event.type, event.query) +}) +``` + +## Extends + +- `Subscribable`\<`QueryCacheListener`\> + +## Constructors + +### Constructor + +```ts +new QueryCache(config): QueryCache; +``` + +Defined in: [packages/query-core/src/queryCache.ts:126](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryCache.ts#L126) + +#### Parameters + +##### config + +[`QueryCacheConfig`](../interfaces/QueryCacheConfig.md) = `{}` + +#### Returns + +`QueryCache` + +#### Overrides + +```ts +Subscribable.constructor +``` + +## Properties + +### config + +```ts +config: QueryCacheConfig = {}; +``` + +Defined in: [packages/query-core/src/queryCache.ts:126](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryCache.ts#L126) + +*** + +### listeners + +```ts +protected listeners: Set; +``` + +Defined in: [packages/query-core/src/subscribable.ts:2](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L2) + +#### Inherited from + +```ts +Subscribable.listeners +``` + +## Methods + +### build() + +```ts +build( + client, + options, +state?): Query; +``` + +Defined in: [packages/query-core/src/queryCache.ts:147](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryCache.ts#L147) + +Returns the existing `Query` instance for the given options' `queryKey`/`queryHash`, or +builds and adds a new one to the cache if none exists yet. Used by framework adapters and +plugins (e.g. broadcast/persistence) that need to get-or-create a `Query` directly, bypassing +the reactive `QueryObserver` machinery. + +#### Type Parameters + +##### TQueryFnData + +`TQueryFnData` = `unknown` + +##### TError + +`TError` = `Error` + +##### TData + +`TData` = `TQueryFnData` + +##### TQueryKey + +`TQueryKey` *extends* readonly `unknown`[] = readonly `unknown`[] + +#### Parameters + +##### client + +[`QueryClient`](QueryClient.md) + +##### options + +[`WithRequired`](../type-aliases/WithRequired.md)\<[`QueryOptions`](../interfaces/QueryOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`, `never`\>, `"queryKey"`\> + +##### state? + +[`QueryState`](../interfaces/QueryState.md)\<`TData`, `TError`\> + +#### Returns + +[`Query`](Query.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`\> + +#### Example + +```ts +const queryCache = queryClient.getQueryCache() + +const query = queryCache.build(queryClient, { + queryKey: ['posts'], + queryFn: fetchPosts, +}) +``` + +*** + +### clear() + +```ts +clear(): void; +``` + +Defined in: [packages/query-core/src/queryCache.ts:232](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryCache.ts#L232) + +Removes all queries from the cache. + +#### Returns + +`void` + +#### Example + +```ts +const queryCache = queryClient.getQueryCache() + +queryCache.clear() +``` + +*** + +### find() + +```ts +find(filters): + | Query + | undefined; +``` + +Defined in: [packages/query-core/src/queryCache.ts:299](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryCache.ts#L299) + +A slightly more advanced method that can be used to get an existing query instance from the +cache. This instance not only contains all the state for the query, but all of the instances, +and underlying guts of the query as well. If the query does not exist, `undefined` is +returned. + +This is not typically needed for most applications, but can come in handy when needing more +information about a query in rare scenarios (e.g. looking at `query.state.dataUpdatedAt` to +decide whether a query is fresh enough to be used as an initial value). + +#### Type Parameters + +##### TQueryFnData + +`TQueryFnData` = `unknown` + +##### TError + +`TError` = `Error` + +##### TData + +`TData` = `TQueryFnData` + +#### Parameters + +##### filters + +[`WithRequired`](../type-aliases/WithRequired.md)\<[`QueryFilters`](../interfaces/QueryFilters.md)\, `"queryKey"`\> + +#### Returns + + \| [`Query`](Query.md)\<`TQueryFnData`, `TError`, `TData`, readonly `unknown`[]\> + \| `undefined` + +#### See + +[QueryCache#findAll](#findall) + +#### Example + +```ts +const queryCache = queryClient.getQueryCache() + +const query = queryCache.find({ queryKey: ['posts'] }) +``` + +*** + +### findAll() + +```ts +findAll(filters): Query[]; +``` + +Defined in: [packages/query-core/src/queryCache.ts:324](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryCache.ts#L324) + +An even more advanced method that can be used to get existing query instances from the cache +that partially match a query key. If no queries match, an empty array is returned. + +This is not typically needed for most applications, but can come in handy when needing more +information about queries in rare scenarios. + +#### Parameters + +##### filters + +[`QueryFilters`](../interfaces/QueryFilters.md)\<`any`\> = `{}` + +#### Returns + +[`Query`](Query.md)\<`unknown`, `Error`, `unknown`, readonly `unknown`[]\>[] + +#### See + +[QueryCache#find](#find) + +#### Example + +```ts +const queryCache = queryClient.getQueryCache() + +const queries = queryCache.findAll({ queryKey: ['posts'] }) +``` + +*** + +### get() + +```ts +get(queryHash): + | Query + | undefined; +``` + +Defined in: [packages/query-core/src/queryCache.ts:254](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryCache.ts#L254) + +Returns the `Query` instance stored under the given `queryHash`, or `undefined` if none +exists. Unlike [QueryCache#find](#find), this looks up by the already-computed hash rather +than by `QueryFilters`. Used by plugins (e.g. broadcast/hydration) that already have a hash +to look up directly. + +#### Type Parameters + +##### TQueryFnData + +`TQueryFnData` = `unknown` + +##### TError + +`TError` = `Error` + +##### TData + +`TData` = `TQueryFnData` + +##### TQueryKey + +`TQueryKey` *extends* readonly `unknown`[] = readonly `unknown`[] + +#### Parameters + +##### queryHash + +`string` + +#### Returns + + \| [`Query`](Query.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`\> + \| `undefined` + +#### Example + +```ts +const queryCache = queryClient.getQueryCache() +const queryHash = hashKey(['posts']) + +const query = queryCache.get(queryHash) +``` + +*** + +### getAll() + +```ts +getAll(): Query[]; +``` + +Defined in: [packages/query-core/src/queryCache.ts:277](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryCache.ts#L277) + +Returns all queries within the cache. + +#### Returns + +[`Query`](Query.md)\<`unknown`, `Error`, `unknown`, readonly `unknown`[]\>[] + +#### Example + +```ts +const queryCache = queryClient.getQueryCache() + +const queries = queryCache.getAll() +``` + +*** + +### hasListeners() + +```ts +hasListeners(): boolean; +``` + +Defined in: [packages/query-core/src/subscribable.ts:19](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L19) + +#### Returns + +`boolean` + +#### Inherited from + +```ts +Subscribable.hasListeners +``` + +*** + +### onSubscribe() + +```ts +protected onSubscribe(): void; +``` + +Defined in: [packages/query-core/src/subscribable.ts:23](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L23) + +#### Returns + +`void` + +#### Inherited from + +```ts +Subscribable.onSubscribe +``` + +*** + +### onUnsubscribe() + +```ts +protected onUnsubscribe(): void; +``` + +Defined in: [packages/query-core/src/subscribable.ts:27](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L27) + +#### Returns + +`void` + +#### Inherited from + +```ts +Subscribable.onUnsubscribe +``` + +*** + +### remove() + +```ts +remove(query): void; +``` + +Defined in: [packages/query-core/src/queryCache.ts:208](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryCache.ts#L208) + +Destroys the given `Query` and removes it from the cache, notifying subscribers with a +`'removed'` event. A no-op if the query is no longer the one currently stored under its hash +(e.g. it was already replaced). Used by plugins (e.g. the broadcast client) that mirror +removals across `QueryCache` instances. + +#### Parameters + +##### query + +[`Query`](Query.md)\<`any`, `any`, `any`, `any`\> + +#### Returns + +`void` + +#### Example + +```ts +const queryCache = queryClient.getQueryCache() +const query = queryCache.find({ queryKey: ['posts'] }) + +if (query) { + queryCache.remove(query) +} +``` + +*** + +### subscribe() + +```ts +subscribe(listener): () => void; +``` + +Defined in: [packages/query-core/src/subscribable.ts:8](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L8) + +#### Parameters + +##### listener + +`QueryCacheListener` + +#### Returns + +```ts +(): void; +``` + +##### Returns + +`void` + +#### Inherited from + +```ts +Subscribable.subscribe +``` diff --git a/docs/framework/preact/reference/classes/QueryClient.md b/docs/framework/preact/reference/classes/QueryClient.md new file mode 100644 index 00000000000..c7d1a034545 --- /dev/null +++ b/docs/framework/preact/reference/classes/QueryClient.md @@ -0,0 +1,1466 @@ +--- +id: QueryClient +title: QueryClient +--- + +Defined in: [packages/query-core/src/queryClient.ts:79](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L79) + +`QueryClient` is used to interact with a cache of queries and mutations. It owns a +`QueryCache` and a `MutationCache` (creating default ones if none are passed in) and holds +the default options that are applied to queries and mutations created through it. + +## Example + +```ts +const queryClient = new QueryClient({ + defaultOptions: { + queries: { + staleTime: Infinity, + }, + }, +}) + +await queryClient.query({ queryKey: ['posts'], queryFn: fetchPosts }) +``` + +## Constructors + +### Constructor + +```ts +new QueryClient(config): QueryClient; +``` + +Defined in: [packages/query-core/src/queryClient.ts:89](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L89) + +#### Parameters + +##### config + +[`QueryClientConfig`](../interfaces/QueryClientConfig.md) = `{}` + +#### Returns + +`QueryClient` + +## Methods + +### cancelQueries() + +```ts +cancelQueries(filters?, cancelOptions?): Promise; +``` + +Defined in: [packages/query-core/src/queryClient.ts:432](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L432) + +Cancels outgoing fetches for queries matching the given filters. Most useful when performing +optimistic updates, since any outgoing refetch that resolves afterwards would otherwise +overwrite the optimistic update. By default (`revert: true`), a cancelled query's data is +reverted to its state before the outgoing fetch started. + +The returned promise never rejects, even if individual cancellations fail. + +#### Type Parameters + +##### TTaggedQueryKey + +`TTaggedQueryKey` *extends* readonly `unknown`[] = readonly `unknown`[] + +#### Parameters + +##### filters? + +[`QueryFilters`](../interfaces/QueryFilters.md)\<`TTaggedQueryKey`\> + +##### cancelOptions? + +[`CancelOptions`](../interfaces/CancelOptions.md) = `{}` + +#### Returns + +`Promise`\<`void`\> + +#### Example + +```ts +await queryClient.cancelQueries({ queryKey: ['posts'], exact: true }) +``` + +*** + +### clear() + +```ts +clear(): void; +``` + +Defined in: [packages/query-core/src/queryClient.ts:1083](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L1083) + +Clears both the query cache and the mutation cache this client is connected to. + +#### Returns + +`void` + +#### Example + +```ts +import { QueryClient } from '@tanstack/query-core' + +const queryClient = new QueryClient() +queryClient.clear() +``` + +*** + +### defaultMutationOptions() + +```ts +defaultMutationOptions(options?): T; +``` + +Defined in: [packages/query-core/src/queryClient.ts:1057](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L1057) + +The mutation counterpart of [QueryClient#defaultQueryOptions](#defaultqueryoptions). Called by framework +adapters (e.g. inside `useMutation`) to merge `queryClient.setMutationDefaults` for the +given `mutationKey`, then the client's `defaultOptions.mutations`, then the caller's options +on top. A no-op if the options are already defaulted (`_defaulted: true`). + +#### Type Parameters + +##### T + +`T` *extends* [`MutationOptions`](../interfaces/MutationOptions.md)\<`any`, `any`, `any`, `any`\> + +#### Parameters + +##### options? + +`T` + +#### Returns + +`T` + +*** + +### defaultQueryOptions() + +```ts +defaultQueryOptions(options): DefaultedQueryObserverOptions; +``` + +Defined in: [packages/query-core/src/queryClient.ts:970](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L970) + +Called by framework adapters (e.g. inside `useQuery`) to resolve the options passed by the +caller into their final, defaulted form: merging `queryClient.setQueryDefaults` for the +given `queryKey`, then the client's own `defaultOptions.queries`, then the caller's options +on top. A no-op if the options are already defaulted (`_defaulted: true`). + +#### Type Parameters + +##### TQueryFnData + +`TQueryFnData` = `unknown` + +##### TError + +`TError` = `Error` + +##### TData + +`TData` = `TQueryFnData` + +##### TQueryData + +`TQueryData` = `TQueryFnData` + +##### TQueryKey + +`TQueryKey` *extends* readonly `unknown`[] = readonly `unknown`[] + +##### TPageParam + +`TPageParam` = `never` + +#### Parameters + +##### options + +[`QueryObserverOptions`](../interfaces/QueryObserverOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryData`, `TQueryKey`, `TPageParam`\> | [`DefaultedQueryObserverOptions`](../type-aliases/DefaultedQueryObserverOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryData`, `TQueryKey`\> + +#### Returns + +[`DefaultedQueryObserverOptions`](../type-aliases/DefaultedQueryObserverOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryData`, `TQueryKey`\> + +*** + +### ~~ensureInfiniteQueryData()~~ + +```ts +ensureInfiniteQueryData(options): Promise>; +``` + +Defined in: [packages/query-core/src/queryClient.ts:735](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L735) + +#### Type Parameters + +##### TQueryFnData + +`TQueryFnData` + +##### TError + +`TError` = `Error` + +##### TData + +`TData` = `TQueryFnData` + +##### TQueryKey + +`TQueryKey` *extends* readonly `unknown`[] = readonly `unknown`[] + +##### TPageParam + +`TPageParam` = `unknown` + +#### Parameters + +##### options + +[`EnsureInfiniteQueryDataOptions`](../type-aliases/EnsureInfiniteQueryDataOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`, `TPageParam`\> + +#### Returns + +`Promise`\<[`InfiniteData`](../interfaces/InfiniteData.md)\<`TData`, `TPageParam`\>\> + +#### Deprecated + +Use queryClient.infiniteQuery({ ...options, staleTime: 'static' }) instead. This method will be removed in the next major version. + +*** + +### ~~ensureQueryData()~~ + +```ts +ensureQueryData(options): Promise; +``` + +Defined in: [packages/query-core/src/queryClient.ts:197](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L197) + +#### Type Parameters + +##### TQueryFnData + +`TQueryFnData` + +##### TError + +`TError` = `Error` + +##### TData + +`TData` = `TQueryFnData` + +##### TQueryKey + +`TQueryKey` *extends* readonly `unknown`[] = readonly `unknown`[] + +#### Parameters + +##### options + +[`EnsureQueryDataOptions`](../interfaces/EnsureQueryDataOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`\> + +#### Returns + +`Promise`\<`TData`\> + +#### Deprecated + +Use queryClient.query({ ...options, staleTime: 'static' }) instead. This method will be removed in the next major version. + +*** + +### ~~fetchInfiniteQuery()~~ + +```ts +fetchInfiniteQuery(options): Promise>; +``` + +Defined in: [packages/query-core/src/queryClient.ts:692](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L692) + +#### Type Parameters + +##### TQueryFnData + +`TQueryFnData` + +##### TError + +`TError` = `Error` + +##### TData + +`TData` = `TQueryFnData` + +##### TQueryKey + +`TQueryKey` *extends* readonly `unknown`[] = readonly `unknown`[] + +##### TPageParam + +`TPageParam` = `unknown` + +#### Parameters + +##### options + +[`FetchInfiniteQueryOptions`](../type-aliases/FetchInfiniteQueryOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`, `TPageParam`\> + +#### Returns + +`Promise`\<[`InfiniteData`](../interfaces/InfiniteData.md)\<`TData`, `TPageParam`\>\> + +#### Deprecated + +Use queryClient.infiniteQuery(options) instead. This method will be removed in the next major version. + +*** + +### ~~fetchQuery()~~ + +```ts +fetchQuery(options): Promise; +``` + +Defined in: [packages/query-core/src/queryClient.ts:600](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L600) + +#### Type Parameters + +##### TQueryFnData + +`TQueryFnData` + +##### TError + +`TError` = `Error` + +##### TData + +`TData` = `TQueryFnData` + +##### TQueryKey + +`TQueryKey` *extends* readonly `unknown`[] = readonly `unknown`[] + +##### TPageParam + +`TPageParam` = `never` + +#### Parameters + +##### options + +[`FetchQueryOptions`](../interfaces/FetchQueryOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`, `TPageParam`\> + +#### Returns + +`Promise`\<`TData`\> + +#### Deprecated + +Use queryClient.query(options) instead. This method will be removed in the next major version. + +*** + +### getDefaultOptions() + +```ts +getDefaultOptions(): DefaultOptions; +``` + +Defined in: [packages/query-core/src/queryClient.ts:818](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L818) + +Returns the default options that were set when creating the client, or via +[QueryClient#setDefaultOptions](#setdefaultoptions). + +#### Returns + +[`DefaultOptions`](../interfaces/DefaultOptions.md) + +#### Example + +```ts +import { QueryClient } from '@tanstack/query-core' + +const queryClient = new QueryClient() +const defaultOptions = queryClient.getDefaultOptions() +``` + +*** + +### getMutationCache() + +```ts +getMutationCache(): MutationCache; +``` + +Defined in: [packages/query-core/src/queryClient.ts:802](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L802) + +Returns the mutation cache this client is connected to. + +#### Returns + +[`MutationCache`](MutationCache.md) + +#### Example + +```ts +import { QueryClient } from '@tanstack/query-core' + +const queryClient = new QueryClient() +const mutationCache = queryClient.getMutationCache() +const mutations = mutationCache.findAll({ status: 'pending' }) +``` + +*** + +### getMutationDefaults() + +```ts +getMutationDefaults(mutationKey): OmitKeyof, "mutationKey">; +``` + +Defined in: [packages/query-core/src/queryClient.ts:945](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L945) + +Returns the default options registered for mutations whose mutation key partially matches +the given `mutationKey`, via [QueryClient#setMutationDefaults](#setmutationdefaults). If multiple registered +defaults match, they are merged together in registration order. + +#### Parameters + +##### mutationKey + +readonly `unknown`[] + +#### Returns + +[`OmitKeyof`](../type-aliases/OmitKeyof.md)\<[`MutationObserverOptions`](../interfaces/MutationObserverOptions.md)\<`any`, `any`, `any`, `any`\>, `"mutationKey"`\> + +#### Example + +```ts +const defaultOptions = queryClient.getMutationDefaults(['addPost']) +``` + +*** + +### getQueriesData() + +```ts +getQueriesData(filters): [readonly unknown[], TQueryFnData | undefined][]; +``` + +Defined in: [packages/query-core/src/queryClient.ts:240](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L240) + +Imperative (non-reactive) way to retrieve the cached data of multiple queries at once. +Only queries matching the given filters are returned; if none match, an empty array is +returned. + +Because the matched queries can hold data of different shapes (e.g. a broad filter can match +queries with unrelated data types), the `TQueryFnData` generic defaults to `unknown` rather +than being inferred. Passing a more specific type is a convenience for call sites that know +every matched query holds the same shape — it is not checked against the actual cache +contents. + +#### Type Parameters + +##### TQueryFnData + +`TQueryFnData` = `unknown` + +##### TQueryFilters + +`TQueryFilters` *extends* [`QueryFilters`](../interfaces/QueryFilters.md)\<`any`\> = [`QueryFilters`](../interfaces/QueryFilters.md)\ + +#### Parameters + +##### filters + +`TQueryFilters` + +#### Returns + +\[readonly `unknown`[], `TQueryFnData` \| `undefined`\][] + +#### See + +[QueryClient#getQueryData](#getquerydata) + +#### Example + +```ts +const data = queryClient.getQueriesData({ queryKey: ['posts'] }) +``` + +*** + +### getQueryCache() + +```ts +getQueryCache(): QueryCache; +``` + +Defined in: [packages/query-core/src/queryClient.ts:786](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L786) + +Returns the query cache this client is connected to. + +#### Returns + +[`QueryCache`](QueryCache.md) + +#### Example + +```ts +import { QueryClient } from '@tanstack/query-core' + +const queryClient = new QueryClient() +const queryCache = queryClient.getQueryCache() +const queries = queryCache.findAll({ queryKey: ['posts'] }) +``` + +*** + +### getQueryData() + +```ts +getQueryData(queryKey): TInferredQueryFnData | undefined; +``` + +Defined in: [packages/query-core/src/queryClient.ts:183](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L183) + +Imperative (non-reactive) way to retrieve data for a QueryKey. +Should only be used in callbacks or functions where reading the latest data is necessary, e.g. for optimistic updates. + +Hint: Do not use this function inside a component, because it won't receive updates. +Use `useQuery` to create a `QueryObserver` that subscribes to changes. + +#### Type Parameters + +##### TQueryFnData + +`TQueryFnData` = `unknown` + +##### TTaggedQueryKey + +`TTaggedQueryKey` *extends* readonly `unknown`[] = readonly `unknown`[] + +##### TInferredQueryFnData + +`TInferredQueryFnData` = [`InferDataFromTag`](../type-aliases/InferDataFromTag.md)\<`TQueryFnData`, `TTaggedQueryKey`\> + +#### Parameters + +##### queryKey + +`TTaggedQueryKey` + +#### Returns + +`TInferredQueryFnData` \| `undefined` + +#### See + +[QueryClient#getQueriesData](#getqueriesdata) + +*** + +### getQueryDefaults() + +```ts +getQueryDefaults(queryKey): OmitKeyof, "queryKey">; +``` + +Defined in: [packages/query-core/src/queryClient.ts:888](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L888) + +Returns the default options registered for queries whose query key partially matches the +given `queryKey`, via [QueryClient#setQueryDefaults](#setquerydefaults). If multiple registered defaults +match, they are merged together in registration order. + +#### Parameters + +##### queryKey + +readonly `unknown`[] + +#### Returns + +[`OmitKeyof`](../type-aliases/OmitKeyof.md)\<[`QueryObserverOptions`](../interfaces/QueryObserverOptions.md)\<`any`, `any`, `any`, `any`, `any`\>, `"queryKey"`\> + +#### Example + +```ts +const defaultOptions = queryClient.getQueryDefaults(['posts']) +``` + +*** + +### getQueryState() + +```ts +getQueryState(queryKey): + | QueryState + | undefined; +``` + +Defined in: [packages/query-core/src/queryClient.ts:350](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L350) + +Imperative (non-reactive) way to retrieve an existing query's state. If the query does not +exist, `undefined` is returned. + +#### Type Parameters + +##### TQueryFnData + +`TQueryFnData` = `unknown` + +##### TError + +`TError` = `Error` + +##### TTaggedQueryKey + +`TTaggedQueryKey` *extends* readonly `unknown`[] = readonly `unknown`[] + +##### TInferredQueryFnData + +`TInferredQueryFnData` = [`InferDataFromTag`](../type-aliases/InferDataFromTag.md)\<`TQueryFnData`, `TTaggedQueryKey`\> + +##### TInferredError + +`TInferredError` = [`InferErrorFromTag`](../type-aliases/InferErrorFromTag.md)\<`TError`, `TTaggedQueryKey`\> + +#### Parameters + +##### queryKey + +`TTaggedQueryKey` + +#### Returns + + \| [`QueryState`](../interfaces/QueryState.md)\<`TInferredQueryFnData`, `TInferredError`\> + \| `undefined` + +#### Example + +```ts +const state = queryClient.getQueryState(['posts']) +console.log(state?.dataUpdatedAt) +``` + +*** + +### infiniteQuery() + +```ts +infiniteQuery(options): Promise[] ? InfiniteData : TData>; +``` + +Defined in: [packages/query-core/src/queryClient.ts:666](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L666) + +Asynchronous method to fetch and cache an infinite query, resolving with an +[InfiniteData](../interfaces/InfiniteData.md) object or throwing with the error. + +Behaves like [QueryClient#query](#query), accepting the same options (minus +`initialPageParam`), plus the required `initialPageParam`, and an optional `pages` / +`getNextPageParam` pair used to refetch a fixed number of pages from the start. + +This method replaces the deprecated `fetchInfiniteQuery`, and — combined with +`{ staleTime: 'static' }` — the deprecated `ensureInfiniteQueryData`. + +#### Type Parameters + +##### TQueryFnData + +`TQueryFnData` + +##### TError + +`TError` = `Error` + +##### TData + +`TData` = [`InfiniteData`](../interfaces/InfiniteData.md)\<`TQueryFnData`, `unknown`\> + +##### TQueryKey + +`TQueryKey` *extends* readonly `unknown`[] = readonly `unknown`[] + +##### TPageParam + +`TPageParam` = `unknown` + +#### Parameters + +##### options + +[`InfiniteQueryExecuteOptions`](../type-aliases/InfiniteQueryExecuteOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`, `TPageParam`\> + +#### Returns + +`Promise`\<`TData`[] *extends* [`InfiniteData`](../interfaces/InfiniteData.md)\<`TQueryFnData`, `unknown`\>[] ? [`InfiniteData`](../interfaces/InfiniteData.md)\<`TQueryFnData`, `TPageParam`\> : `TData`\> + +#### Example + +```ts +try { + const data = await queryClient.infiniteQuery({ queryKey, queryFn, initialPageParam: 0 }) + console.log(data.pages) +} catch (error) { + console.log(error) +} +``` + +*** + +### invalidateQueries() + +```ts +invalidateQueries(filters?, options?): Promise; +``` + +Defined in: [packages/query-core/src/queryClient.ts:460](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L460) + +Marks queries matching the given filters as invalidated. Unlike +[QueryClient#removeQueries](#removequeries), invalidated queries stay in the cache. + +Unless `filters.refetchType` is `'none'`, matching queries are then refetched via +[QueryClient#refetchQueries](#refetchqueries), using `filters.refetchType` if set, otherwise +`filters.type`, otherwise `'active'`. + +#### Type Parameters + +##### TTaggedQueryKey + +`TTaggedQueryKey` *extends* readonly `unknown`[] = readonly `unknown`[] + +#### Parameters + +##### filters? + +[`InvalidateQueryFilters`](../interfaces/InvalidateQueryFilters.md)\<`TTaggedQueryKey`\> + +##### options? + +[`InvalidateOptions`](../interfaces/InvalidateOptions.md) = `{}` + +#### Returns + +`Promise`\<`void`\> + +#### Example + +```ts +await queryClient.invalidateQueries({ queryKey: ['posts'], refetchType: 'active' }) +``` + +*** + +### isFetching() + +```ts +isFetching(filters?): number; +``` + +Defined in: [packages/query-core/src/queryClient.ts:150](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L150) + +Returns the number of queries in the cache that are currently fetching, optionally +matching a set of filters. This includes background-fetching, loading new pages, and +loading more infinite query results. + +#### Type Parameters + +##### TQueryFilters + +`TQueryFilters` *extends* [`QueryFilters`](../interfaces/QueryFilters.md)\<`any`\> = [`QueryFilters`](../interfaces/QueryFilters.md)\ + +#### Parameters + +##### filters? + +`TQueryFilters` + +#### Returns + +`number` + +#### Example + +```ts +if (queryClient.isFetching()) { + console.log('At least one query is fetching!') +} +``` + +*** + +### isMutating() + +```ts +isMutating(filters?): number; +``` + +Defined in: [packages/query-core/src/queryClient.ts:168](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L168) + +Returns the number of mutations in the cache that are currently pending, optionally +matching a set of filters. + +#### Type Parameters + +##### TMutationFilters + +`TMutationFilters` *extends* [`MutationFilters`](../interfaces/MutationFilters.md)\<`any`, `any`, `unknown`, `unknown`\> = [`MutationFilters`](../interfaces/MutationFilters.md)\<`unknown`, `Error`, `unknown`, `unknown`\> + +#### Parameters + +##### filters? + +`TMutationFilters` + +#### Returns + +`number` + +#### Example + +```ts +if (queryClient.isMutating()) { + console.log('At least one mutation is pending!') +} +``` + +*** + +### mount() + +```ts +mount(): void; +``` + +Defined in: [packages/query-core/src/queryClient.ts:104](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L104) + +Called by a framework adapter's `QueryClientProvider`-equivalent when it mounts, to start +listening for focus/online events and resume paused mutations. Ref-counted via an internal +mount count, so nested or multiple providers sharing the same `QueryClient` don't tear down +the shared listeners until the last one unmounts. + +#### Returns + +`void` + +*** + +### ~~prefetchInfiniteQuery()~~ + +```ts +prefetchInfiniteQuery(options): Promise; +``` + +Defined in: [packages/query-core/src/queryClient.ts:714](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L714) + +#### Type Parameters + +##### TQueryFnData + +`TQueryFnData` + +##### TError + +`TError` = `Error` + +##### TData + +`TData` = `TQueryFnData` + +##### TQueryKey + +`TQueryKey` *extends* readonly `unknown`[] = readonly `unknown`[] + +##### TPageParam + +`TPageParam` = `unknown` + +#### Parameters + +##### options + +[`FetchInfiniteQueryOptions`](../type-aliases/FetchInfiniteQueryOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`, `TPageParam`\> + +#### Returns + +`Promise`\<`void`\> + +#### Deprecated + +Use queryClient.infiniteQuery(options) instead. You can swallow errors with `.catch(noop)`. This method will be removed in the next major version. + +*** + +### ~~prefetchQuery()~~ + +```ts +prefetchQuery(options): Promise; +``` + +Defined in: [packages/query-core/src/queryClient.ts:634](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L634) + +#### Type Parameters + +##### TQueryFnData + +`TQueryFnData` = `unknown` + +##### TError + +`TError` = `Error` + +##### TData + +`TData` = `TQueryFnData` + +##### TQueryKey + +`TQueryKey` *extends* readonly `unknown`[] = readonly `unknown`[] + +#### Parameters + +##### options + +[`FetchQueryOptions`](../interfaces/FetchQueryOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`\> + +#### Returns + +`Promise`\<`void`\> + +#### Deprecated + +Use queryClient.query(options) instead. You can swallow errors with `.catch(noop)`. This method will be removed in the next major version. + +*** + +### query() + +```ts +query(options): Promise; +``` + +Defined in: [packages/query-core/src/queryClient.ts:554](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L554) + +Asynchronous method to fetch and cache a query, resolving with the data or throwing with +the error. + +If the query already exists in the cache and its data is not stale (per the given +`staleTime`), the cached data is returned without fetching. Otherwise, the query is fetched +and the promise resolves once the fetch settles. If a `select` function is provided, it is +applied to the data in both cases (cached or freshly fetched) before it is returned. + +Unlike a reactive observer, retries are disabled by default here (`retry: false`) unless +explicitly configured, since there is no component to catch a thrown error and retry through +re-render. + +The accepted options are `QueryObserverOptions` minus the fields that only make sense for a +reactive observer — `enabled`, `refetchInterval`, `refetchIntervalInBackground`, +`refetchOnWindowFocus`, `refetchOnReconnect`, `refetchOnMount`, `retryOnMount`, +`notifyOnChangeProps`, `throwOnError`, `suspense`, and `placeholderData` are not part of this +method's options. + +This method replaces the deprecated `fetchQuery`, and — combined with +`{ staleTime: 'static' }` — the deprecated `ensureQueryData`. + +#### Type Parameters + +##### TQueryFnData + +`TQueryFnData` + +##### TError + +`TError` = `Error` + +##### TData + +`TData` = `TQueryFnData` + +##### TQueryData + +`TQueryData` = `TQueryFnData` + +##### TQueryKey + +`TQueryKey` *extends* readonly `unknown`[] = readonly `unknown`[] + +##### TPageParam + +`TPageParam` = `never` + +#### Parameters + +##### options + +[`QueryExecuteOptions`](../interfaces/QueryExecuteOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryData`, `TQueryKey`, `TPageParam`\> + +#### Returns + +`Promise`\<`TData`\> + +#### Example + +```ts +try { + const data = await queryClient.query({ queryKey, queryFn, staleTime: 10000 }) +} catch (error) { + console.log(error) +} +``` + +*** + +### refetchQueries() + +```ts +refetchQueries(filters?, options?): Promise; +``` + +Defined in: [packages/query-core/src/queryClient.ts:497](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L497) + +Refetches queries matching the given filters, regardless of whether they are stale. Without +filters, every query in the cache is refetched. Queries that are disabled, or static (only +have observers with a static `staleTime`), are never refetched. + +By default (`cancelRefetch: true`), a currently running fetch is cancelled before the new +one starts. The returned promise resolves once all matching queries have settled; it does +not reject on individual query failures unless `throwOnError` is set. + +#### Type Parameters + +##### TTaggedQueryKey + +`TTaggedQueryKey` *extends* readonly `unknown`[] = readonly `unknown`[] + +#### Parameters + +##### filters? + +[`RefetchQueryFilters`](../interfaces/RefetchQueryFilters.md)\<`TTaggedQueryKey`\> + +##### options? + +[`RefetchOptions`](../interfaces/RefetchOptions.md) = `{}` + +#### Returns + +`Promise`\<`void`\> + +#### Example + +```ts +// refetch all active queries partially matching a query key: +await queryClient.refetchQueries({ queryKey: ['posts'], type: 'active' }) +``` + +*** + +### removeQueries() + +```ts +removeQueries(filters?): void; +``` + +Defined in: [packages/query-core/src/queryClient.ts:376](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L376) + +Removes queries from the cache that match the given filters. Unlike +[QueryClient#invalidateQueries](#invalidatequeries) or [QueryClient#refetchQueries](#refetchqueries), this removes +matching queries from the cache instead of refetching them. Without filters, every query in +the cache is removed. + +#### Type Parameters + +##### TTaggedQueryKey + +`TTaggedQueryKey` *extends* readonly `unknown`[] = readonly `unknown`[] + +#### Parameters + +##### filters? + +[`QueryFilters`](../interfaces/QueryFilters.md)\<`TTaggedQueryKey`\> + +#### Returns + +`void` + +#### Example + +```ts +queryClient.removeQueries({ queryKey: ['posts'], exact: true }) +``` + +*** + +### resetQueries() + +```ts +resetQueries(filters?, options?): Promise; +``` + +Defined in: [packages/query-core/src/queryClient.ts:397](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L397) + +Resets queries matching the given filters back to their initial state (e.g. any +`initialData`), notifying subscribers rather than removing them. Active queries among the +matched set are then refetched, and the returned promise resolves once that refetch settles. + +#### Type Parameters + +##### TTaggedQueryKey + +`TTaggedQueryKey` *extends* readonly `unknown`[] = readonly `unknown`[] + +#### Parameters + +##### filters? + +[`QueryFilters`](../interfaces/QueryFilters.md)\<`TTaggedQueryKey`\> + +##### options? + +[`ResetOptions`](../interfaces/ResetOptions.md) + +#### Returns + +`Promise`\<`void`\> + +#### Example + +```ts +await queryClient.resetQueries({ queryKey: ['posts'], exact: true }) +``` + +*** + +### resumePausedMutations() + +```ts +resumePausedMutations(): Promise; +``` + +Defined in: [packages/query-core/src/queryClient.ts:767](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L767) + +Resumes mutations that were paused because there was no network connection. Does nothing +(resolving immediately) if the client is currently offline. + +#### Returns + +`Promise`\<`unknown`\> + +#### Example + +```ts +import { QueryClient } from '@tanstack/query-core' + +const queryClient = new QueryClient() +await queryClient.resumePausedMutations() +``` + +*** + +### setDefaultOptions() + +```ts +setDefaultOptions(options): void; +``` + +Defined in: [packages/query-core/src/queryClient.ts:839](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L839) + +Dynamically sets the default options for this client, overwriting any previously defined +default options. + +#### Parameters + +##### options + +[`DefaultOptions`](../interfaces/DefaultOptions.md) + +#### Returns + +`void` + +#### See + +[QueryClient#getDefaultOptions](#getdefaultoptions) + +#### Example + +```ts +import { QueryClient } from '@tanstack/query-core' + +const queryClient = new QueryClient() +queryClient.setDefaultOptions({ + queries: { + staleTime: Infinity, + }, +}) +``` + +*** + +### setMutationDefaults() + +```ts +setMutationDefaults(mutationKey, options): void; +``` + +Defined in: [packages/query-core/src/queryClient.ts:917](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L917) + +Sets default options for mutations whose mutation key partially matches the given +`mutationKey`. As with [QueryClient#setQueryDefaults](#setquerydefaults), the order of registration +matters when several registered defaults match the same mutation key. + +#### Type Parameters + +##### TData + +`TData` = `unknown` + +##### TError + +`TError` = `Error` + +##### TVariables + +`TVariables` = `void` + +##### TOnMutateResult + +`TOnMutateResult` = `unknown` + +#### Parameters + +##### mutationKey + +readonly `unknown`[] + +##### options + +[`OmitKeyof`](../type-aliases/OmitKeyof.md)\<[`MutationObserverOptions`](../interfaces/MutationObserverOptions.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\>, `"mutationKey"`\> + +#### Returns + +`void` + +#### See + +[QueryClient#getMutationDefaults](#getmutationdefaults) + +#### Example + +```ts +queryClient.setMutationDefaults(['addPost'], { mutationFn: addPost }) +``` + +*** + +### setQueriesData() + +```ts +setQueriesData( + filters, + updater, + options?): [readonly unknown[], TQueryFnData | undefined][]; +``` + +Defined in: [packages/query-core/src/queryClient.ts:319](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L319) + +Synchronous way to immediately update the cached data of multiple queries at once, using +filters or partial query key matching. Only queries that already exist and match the given +filters are updated; no new cache entries are created. Internally this calls +[QueryClient#setQueryData](#setquerydata) for each matching query. + +#### Type Parameters + +##### TQueryFnData + +`TQueryFnData` + +##### TQueryFilters + +`TQueryFilters` *extends* [`QueryFilters`](../interfaces/QueryFilters.md)\<`any`\> = [`QueryFilters`](../interfaces/QueryFilters.md)\ + +#### Parameters + +##### filters + +`TQueryFilters` + +##### updater + +[`Updater`](../type-aliases/Updater.md)\<`NoInfer`\<`TQueryFnData`\> \| `undefined`, `NoInfer`\<`TQueryFnData`\> \| `undefined`\> + +##### options? + +[`SetDataOptions`](../interfaces/SetDataOptions.md) + +#### Returns + +\[readonly `unknown`[], `TQueryFnData` \| `undefined`\][] + +#### Example + +```ts +queryClient.setQueriesData({ queryKey: ['posts'] }, (oldPosts) => + oldPosts ? oldPosts.filter((post) => post.id !== deletedId) : oldPosts, +) +``` + +*** + +### setQueryData() + +```ts +setQueryData( + queryKey, + updater, + options?): NoInfer | undefined; +``` + +Defined in: [packages/query-core/src/queryClient.ts:271](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L271) + +Synchronous way to immediately update a query's cached data. If the updater (or the value +passed) resolves to `undefined`, the cache is left untouched and no query is created; +otherwise, if the query does not exist yet, it will be created. To update multiple queries +at once by partially matching query keys, use [QueryClient#setQueriesData](#setqueriesdata) instead. + +Updates must be performed immutably: do not mutate `oldData`, or data previously retrieved +via [QueryClient#getQueryData](#getquerydata), in place. + +#### Type Parameters + +##### TQueryFnData + +`TQueryFnData` = `unknown` + +##### TTaggedQueryKey + +`TTaggedQueryKey` *extends* readonly `unknown`[] = readonly `unknown`[] + +##### TInferredQueryFnData + +`TInferredQueryFnData` = [`InferDataFromTag`](../type-aliases/InferDataFromTag.md)\<`TQueryFnData`, `TTaggedQueryKey`\> + +#### Parameters + +##### queryKey + +`TTaggedQueryKey` + +The query key to set data for. + +##### updater + +[`Updater`](../type-aliases/Updater.md)\<`NoInfer`\<`TInferredQueryFnData`\> \| `undefined`, `NoInfer`\<`TInferredQueryFnData`\> \| `undefined`\> + +Either the new data, or a function that receives the current data (which +may be `undefined`) and returns the new data. + +##### options? + +[`SetDataOptions`](../interfaces/SetDataOptions.md) + +#### Returns + +`NoInfer`\<`TInferredQueryFnData`\> \| `undefined` + +#### Example + +```ts +queryClient.setQueryData(['posts'], newPosts) + +// Or, using an updater function that receives the current data: +queryClient.setQueryData(['posts'], (oldPosts) => [...oldPosts, newPost]) +``` + +*** + +### setQueryDefaults() + +```ts +setQueryDefaults(queryKey, options): void; +``` + +Defined in: [packages/query-core/src/queryClient.ts:858](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L858) + +Sets default options for queries whose query key partially matches the given `queryKey`. + +If several registered query defaults match a given query key, they are merged together in +registration order by [QueryClient#getQueryDefaults](#getquerydefaults), so register defaults from the +most generic key to the least generic one — more specific defaults should be registered +after more generic ones so they take precedence. + +#### Type Parameters + +##### TQueryFnData + +`TQueryFnData` = `unknown` + +##### TError + +`TError` = `Error` + +##### TData + +`TData` = `TQueryFnData` + +##### TQueryData + +`TQueryData` = `TQueryFnData` + +#### Parameters + +##### queryKey + +readonly `unknown`[] + +##### options + +`Partial`\<[`OmitKeyof`](../type-aliases/OmitKeyof.md)\<[`QueryObserverOptions`](../interfaces/QueryObserverOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryData`\>, `"queryKey"`\>\> + +#### Returns + +`void` + +#### Example + +```ts +queryClient.setQueryDefaults(['posts'], { queryFn: fetchPosts }) + +await queryClient.query({ queryKey: ['posts'] }) +``` + +*** + +### unmount() + +```ts +unmount(): void; +``` + +Defined in: [packages/query-core/src/queryClient.ts:127](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L127) + +The inverse of [QueryClient#mount](#mount) — called by a framework adapter's +`QueryClientProvider`-equivalent when it unmounts. Only tears down the focus/online +listeners once the mount count returns to `0`. + +#### Returns + +`void` diff --git a/docs/framework/preact/reference/classes/QueryObserver.md b/docs/framework/preact/reference/classes/QueryObserver.md new file mode 100644 index 00000000000..51ff16910df --- /dev/null +++ b/docs/framework/preact/reference/classes/QueryObserver.md @@ -0,0 +1,555 @@ +--- +id: QueryObserver +title: QueryObserver +--- + +Defined in: [packages/query-core/src/queryObserver.ts:57](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L57) + +A `QueryObserver` watches a single query in the `QueryCache` and computes a +`QueryObserverResult` from its state, recomputing and notifying subscribers +whenever the underlying query (or the observer's options) changes. It is +the primitive that framework adapters (e.g. `useQuery`) build their hooks +on top of, but it can also be used directly to observe and switch between +queries outside of any framework. + +## Example + +```ts +const observer = new QueryObserver(queryClient, { + queryKey: ['posts'], + queryFn: fetchPosts, +}) + +const unsubscribe = observer.subscribe((result) => { + console.log(result.data) +}) +``` + +## Extends + +- `Subscribable`\<`QueryObserverListener`\<`TData`, `TError`\>\> + +## Extended by + +- [`InfiniteQueryObserver`](InfiniteQueryObserver.md) + +## Type Parameters + +### TQueryFnData + +`TQueryFnData` = `unknown` + +### TError + +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) + +### TData + +`TData` = `TQueryFnData` + +### TQueryData + +`TQueryData` = `TQueryFnData` + +### TQueryKey + +`TQueryKey` *extends* [`QueryKey`](../type-aliases/QueryKey.md) = [`QueryKey`](../type-aliases/QueryKey.md) + +## Constructors + +### Constructor + +```ts +new QueryObserver(client, options): QueryObserver; +``` + +Defined in: [packages/query-core/src/queryObserver.ts:87](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L87) + +#### Parameters + +##### client + +[`QueryClient`](QueryClient.md) + +##### options + +[`QueryObserverOptions`](../interfaces/QueryObserverOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryData`, `TQueryKey`\> + +#### Returns + +`QueryObserver`\<`TQueryFnData`, `TError`, `TData`, `TQueryData`, `TQueryKey`\> + +#### Overrides + +```ts +Subscribable>.constructor +``` + +## Properties + +### listeners + +```ts +protected listeners: Set>; +``` + +Defined in: [packages/query-core/src/subscribable.ts:2](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L2) + +#### Inherited from + +```ts +Subscribable.listeners +``` + +*** + +### options + +```ts +options: QueryObserverOptions; +``` + +Defined in: [packages/query-core/src/queryObserver.ts:89](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L89) + +## Methods + +### bindMethods() + +```ts +protected bindMethods(): void; +``` + +Defined in: [packages/query-core/src/queryObserver.ts:106](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L106) + +#### Returns + +`void` + +*** + +### createResult() + +```ts +protected createResult(query, options): QueryObserverResult; +``` + +Defined in: [packages/query-core/src/queryObserver.ts:559](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L559) + +#### Parameters + +##### query + +[`Query`](Query.md)\<`TQueryFnData`, `TError`, `TQueryData`, `TQueryKey`\> + +##### options + +[`QueryObserverOptions`](../interfaces/QueryObserverOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryData`, `TQueryKey`\> + +#### Returns + +[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\> + +*** + +### destroy() + +```ts +destroy(): void; +``` + +Defined in: [packages/query-core/src/queryObserver.ts:161](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L161) + +Stops observing the current query: clears all listeners, cancels the +stale and refetch-interval timers, and removes this observer from the +query it was observing. + +#### Returns + +`void` + +*** + +### fetch() + +```ts +protected fetch(fetchOptions): Promise>; +``` + +Defined in: [packages/query-core/src/queryObserver.ts:448](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L448) + +#### Parameters + +##### fetchOptions + +`ObserverFetchOptions` + +#### Returns + +`Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> + +*** + +### fetchOptimistic() + +```ts +fetchOptimistic(options): Promise>; +``` + +Defined in: [packages/query-core/src/queryObserver.ts:395](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L395) + +Fetches a query defined by the given options without affecting this +observer's own tracked query or result, and returns a promise that +resolves with the `QueryObserverResult` for that fetch. This is useful +for prefetching data that another observer (e.g. a query about to be +navigated to) will need, ahead of time. + +#### Parameters + +##### options + +[`QueryObserverOptions`](../interfaces/QueryObserverOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryData`, `TQueryKey`\> + +#### Returns + +`Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> + +#### Example + +```ts +const result = await observer.fetchOptimistic({ + queryKey: ['posts', 2], + queryFn: () => fetchPost(2), +}) +console.log(result.data) +``` + +*** + +### getCurrentQuery() + +```ts +getCurrentQuery(): Query; +``` + +Defined in: [packages/query-core/src/queryObserver.ts:357](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L357) + +Returns the `Query` instance this observer is currently observing. + +#### Returns + +[`Query`](Query.md)\<`TQueryFnData`, `TError`, `TQueryData`, `TQueryKey`\> + +*** + +### getCurrentResult() + +```ts +getCurrentResult(): QueryObserverResult; +``` + +Defined in: [packages/query-core/src/queryObserver.ts:321](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L321) + +Returns the most recently computed `QueryObserverResult` for the +observed query. This is a point-in-time read; to be notified of updates +as they happen, subscribe to the observer instead (its inherited +`subscribe` method). + +#### Returns + +[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\> + +#### Example + +```ts +const result = observer.getCurrentResult() +console.log(result.status, result.data) +``` + +*** + +### getOptimisticResult() + +```ts +getOptimisticResult(options): QueryObserverResult; +``` + +Defined in: [packages/query-core/src/queryObserver.ts:272](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L272) + +Computes the result the observer would produce for the given (already-defaulted) options +right now, building the underlying `Query` if it doesn't exist yet, without waiting for a +subscription callback. Called by framework adapters on every render (e.g. `useQuery`) so the +returned value is available synchronously, ahead of `setOptions` triggering an actual fetch. + +#### Parameters + +##### options + +[`DefaultedQueryObserverOptions`](../type-aliases/DefaultedQueryObserverOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryData`, `TQueryKey`\> + +#### Returns + +[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\> + +*** + +### hasListeners() + +```ts +hasListeners(): boolean; +``` + +Defined in: [packages/query-core/src/subscribable.ts:19](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L19) + +#### Returns + +`boolean` + +#### Inherited from + +```ts +Subscribable.hasListeners +``` + +*** + +### onSubscribe() + +```ts +protected onSubscribe(): void; +``` + +Defined in: [packages/query-core/src/queryObserver.ts:110](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L110) + +#### Returns + +`void` + +#### Overrides + +```ts +Subscribable.onSubscribe +``` + +*** + +### onUnsubscribe() + +```ts +protected onUnsubscribe(): void; +``` + +Defined in: [packages/query-core/src/queryObserver.ts:124](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L124) + +#### Returns + +`void` + +#### Overrides + +```ts +Subscribable.onUnsubscribe +``` + +*** + +### refetch() + +```ts +refetch(__namedParameters): Promise>; +``` + +Defined in: [packages/query-core/src/queryObserver.ts:371](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L371) + +Refetches the observed query and returns a promise that resolves with +the resulting `QueryObserverResult`. + +#### Parameters + +##### \_\_namedParameters + +[`RefetchOptions`](../interfaces/RefetchOptions.md) = `{}` + +#### Returns + +`Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> + +#### Example + +```ts +const result = await observer.refetch({ cancelRefetch: false }) +console.log(result.data) +``` + +*** + +### setOptions() + +```ts +setOptions(options): void; +``` + +Defined in: [packages/query-core/src/queryObserver.ts:182](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L182) + +Updates the observer's options. This will re-resolve the query being +observed (switching to a different query if the `queryKey` changed), +trigger a fetch if the new options require one and the observer has +subscribers, recompute the current result, and reschedule the stale and +refetch-interval timers as needed. + +#### Parameters + +##### options + +[`QueryObserverOptions`](../interfaces/QueryObserverOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryData`, `TQueryKey`\> + +#### Returns + +`void` + +#### Example + +```ts +observer.setOptions({ queryKey: ['posts', 1], queryFn: () => fetchPost(1) }) +// later: switch to a different query, reusing the same observer +observer.setOptions({ queryKey: ['posts', 2], queryFn: () => fetchPost(2) }) +``` + +*** + +### shouldFetchOnReconnect() + +```ts +shouldFetchOnReconnect(): boolean; +``` + +Defined in: [packages/query-core/src/queryObserver.ts:135](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L135) + +Returns whether the observed query is currently stale and configured +(via the `refetchOnReconnect` option) to refetch when the network +reconnects. + +#### Returns + +`boolean` + +*** + +### shouldFetchOnWindowFocus() + +```ts +shouldFetchOnWindowFocus(): boolean; +``` + +Defined in: [packages/query-core/src/queryObserver.ts:148](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L148) + +Returns whether the observed query is currently stale and configured +(via the `refetchOnWindowFocus` option) to refetch when the window +regains focus. + +#### Returns + +`boolean` + +*** + +### subscribe() + +```ts +subscribe(listener): () => void; +``` + +Defined in: [packages/query-core/src/subscribable.ts:8](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L8) + +#### Parameters + +##### listener + +`QueryObserverListener` + +#### Returns + +```ts +(): void; +``` + +##### Returns + +`void` + +#### Inherited from + +```ts +Subscribable.subscribe +``` + +*** + +### trackProp() + +```ts +trackProp(key): void; +``` + +Defined in: [packages/query-core/src/queryObserver.ts:350](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L350) + +Records that the given `QueryObserverResult` property was read, so a subsequent update only +notifies this observer if a tracked property actually changed. Normally called indirectly via +[QueryObserver#trackResult](#trackresult)'s proxy; exposed directly for adapters that track property +access themselves (e.g. through their own reactivity system) instead of via the proxy. + +#### Parameters + +##### key + +`"error"` | `"data"` | `"isError"` | `"isPending"` | `"isLoading"` | `"isLoadingError"` | `"isRefetchError"` | `"isSuccess"` | `"isPlaceholderData"` | `"status"` | `"dataUpdatedAt"` | `"errorUpdatedAt"` | `"failureCount"` | `"failureReason"` | `"errorUpdateCount"` | `"isFetched"` | `"isFetchedAfterMount"` | `"isFetching"` | `"isInitialLoading"` | `"isPaused"` | `"isRefetching"` | `"isStale"` | `"isEnabled"` | `"refetch"` | `"fetchStatus"` + +#### Returns + +`void` + +*** + +### trackResult() + +```ts +trackResult(result, onPropTracked?): QueryObserverResult; +``` + +Defined in: [packages/query-core/src/queryObserver.ts:331](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L331) + +Wraps a `QueryObserverResult` in a `Proxy` that records which properties are read, via +[QueryObserver#trackProp](#trackprop) (and an optional `onPropTracked` callback). Used by framework +adapters when `notifyOnChangeProps` is not set, to implement its default "only re-render on +properties you actually read" behavior. + +#### Parameters + +##### result + +[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\> + +##### onPropTracked? + +(`key`) => `void` + +#### Returns + +[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\> + +*** + +### updateResult() + +```ts +updateResult(): void; +``` + +Defined in: [packages/query-core/src/queryObserver.ts:735](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L735) + +Recomputes and stores the current result from the current query/options, notifying listeners +if it changed. Framework adapters call this right after subscribing to make sure no query +update was missed in the gap between creating the observer and subscribing to it. + +#### Returns + +`void` diff --git a/docs/framework/preact/reference/functions/HydrationBoundary.md b/docs/framework/preact/reference/functions/HydrationBoundary.md index 9361aad8204..68e0b9b03a9 100644 --- a/docs/framework/preact/reference/functions/HydrationBoundary.md +++ b/docs/framework/preact/reference/functions/HydrationBoundary.md @@ -7,7 +7,7 @@ title: HydrationBoundary function HydrationBoundary(__namedParameters): Element; ``` -Defined in: [preact-query/src/HydrationBoundary.tsx:87](https://github.com/TanStack/query/blob/main/packages/preact-query/src/HydrationBoundary.tsx#L87) +Defined in: [packages/preact-query/src/HydrationBoundary.tsx:87](https://github.com/TanStack/query/blob/main/packages/preact-query/src/HydrationBoundary.tsx#L87) `HydrationBoundary` adds a previously dehydrated state into the `queryClient` that would be returned by `useQueryClient()`. If the client already contains data, the new queries will be intelligently merged based on diff --git a/docs/framework/preact/reference/functions/QueryClientProvider.md b/docs/framework/preact/reference/functions/QueryClientProvider.md index 4795634bfaa..aab9bbf4b6a 100644 --- a/docs/framework/preact/reference/functions/QueryClientProvider.md +++ b/docs/framework/preact/reference/functions/QueryClientProvider.md @@ -7,7 +7,7 @@ title: QueryClientProvider function QueryClientProvider(__namedParameters): VNode; ``` -Defined in: [preact-query/src/QueryClientProvider.tsx:70](https://github.com/TanStack/query/blob/main/packages/preact-query/src/QueryClientProvider.tsx#L70) +Defined in: [packages/preact-query/src/QueryClientProvider.tsx:70](https://github.com/TanStack/query/blob/main/packages/preact-query/src/QueryClientProvider.tsx#L70) Use the `QueryClientProvider` component to connect and provide a `QueryClient` to your application. Also calls `client.mount()`/`client.unmount()` as this component mounts/unmounts, which subscribes the client to diff --git a/docs/framework/preact/reference/functions/QueryErrorResetBoundary.md b/docs/framework/preact/reference/functions/QueryErrorResetBoundary.md index 070d4a909ea..f9b670fb653 100644 --- a/docs/framework/preact/reference/functions/QueryErrorResetBoundary.md +++ b/docs/framework/preact/reference/functions/QueryErrorResetBoundary.md @@ -7,7 +7,7 @@ title: QueryErrorResetBoundary function QueryErrorResetBoundary(__namedParameters): Element; ``` -Defined in: [preact-query/src/QueryErrorResetBoundary.tsx:159](https://github.com/TanStack/query/blob/main/packages/preact-query/src/QueryErrorResetBoundary.tsx#L159) +Defined in: [packages/preact-query/src/QueryErrorResetBoundary.tsx:159](https://github.com/TanStack/query/blob/main/packages/preact-query/src/QueryErrorResetBoundary.tsx#L159) When using `suspense` or `throwOnError` in your queries, you need a way to let queries know that you want to try again when re-rendering after some error occurred. With the `QueryErrorResetBoundary` component you can diff --git a/docs/framework/preact/reference/functions/defaultShouldDehydrateMutation.md b/docs/framework/preact/reference/functions/defaultShouldDehydrateMutation.md new file mode 100644 index 00000000000..940f8745a5d --- /dev/null +++ b/docs/framework/preact/reference/functions/defaultShouldDehydrateMutation.md @@ -0,0 +1,23 @@ +--- +id: defaultShouldDehydrateMutation +title: defaultShouldDehydrateMutation +--- + +```ts +function defaultShouldDehydrateMutation(mutation): boolean; +``` + +Defined in: [packages/query-core/src/hydration.ts:177](https://github.com/TanStack/query/blob/main/packages/query-core/src/hydration.ts#L177) + +The default `shouldDehydrateMutation` predicate used by `dehydrate`. Only dehydrates mutations that are +currently paused (e.g. paused by `networkMode` while offline). + +## Parameters + +### mutation + +[`Mutation`](../classes/Mutation.md) + +## Returns + +`boolean` diff --git a/docs/framework/preact/reference/functions/defaultShouldDehydrateQuery.md b/docs/framework/preact/reference/functions/defaultShouldDehydrateQuery.md new file mode 100644 index 00000000000..abf19439d8a --- /dev/null +++ b/docs/framework/preact/reference/functions/defaultShouldDehydrateQuery.md @@ -0,0 +1,23 @@ +--- +id: defaultShouldDehydrateQuery +title: defaultShouldDehydrateQuery +--- + +```ts +function defaultShouldDehydrateQuery(query): boolean; +``` + +Defined in: [packages/query-core/src/hydration.ts:185](https://github.com/TanStack/query/blob/main/packages/query-core/src/hydration.ts#L185) + +The default `shouldDehydrateQuery` predicate used by `dehydrate`. Only dehydrates queries whose status is +`'success'`. + +## Parameters + +### query + +[`Query`](../classes/Query.md) + +## Returns + +`boolean` diff --git a/docs/framework/preact/reference/functions/dehydrate.md b/docs/framework/preact/reference/functions/dehydrate.md new file mode 100644 index 00000000000..33cdcd3940d --- /dev/null +++ b/docs/framework/preact/reference/functions/dehydrate.md @@ -0,0 +1,43 @@ +--- +id: dehydrate +title: dehydrate +--- + +```ts +function dehydrate(client, options): DehydratedState; +``` + +Defined in: [packages/query-core/src/hydration.ts:207](https://github.com/TanStack/query/blob/main/packages/query-core/src/hydration.ts#L207) + +Dehydrates a `QueryClient`'s cache (queries and mutations) into a plain, serializable `DehydratedState`, +typically to embed in server-rendered markup and later restore into a client-side `QueryClient` via `hydrate`. +Which queries/mutations are included, and how their data/errors are transformed, is controlled by `options`, +falling back to the client's `dehydrate` default options, and finally to `defaultShouldDehydrateQuery` / +`defaultShouldDehydrateMutation`. + +## Parameters + +### client + +[`QueryClient`](../classes/QueryClient.md) + +### options + +[`DehydrateOptions`](../interfaces/DehydrateOptions.md) = `{}` + +## Returns + +[`DehydratedState`](../interfaces/DehydratedState.md) + +## Example + +```ts +const queryClient = new QueryClient() + +await queryClient.prefetchQuery({ + queryKey: ['posts'], + queryFn: getPosts, +}) + +const dehydratedState = dehydrate(queryClient) +``` diff --git a/docs/framework/preact/reference/functions/dehydrateQuery.md b/docs/framework/preact/reference/functions/dehydrateQuery.md new file mode 100644 index 00000000000..2314f52fd91 --- /dev/null +++ b/docs/framework/preact/reference/functions/dehydrateQuery.md @@ -0,0 +1,43 @@ +--- +id: dehydrateQuery +title: dehydrateQuery +--- + +```ts +function dehydrateQuery( + query, + serializeData?, + shouldRedactErrors?): DehydratedQuery; +``` + +Defined in: [packages/query-core/src/hydration.ts:148](https://github.com/TanStack/query/blob/main/packages/query-core/src/hydration.ts#L148) + +Dehydrates a single `Query` into a serializable `DehydratedQuery` snapshot. Note that most query config (e.g. +`queryFn`, `staleTime`) is not dehydrated but instead meant to be configured again when consuming the +de/rehydrated data, typically with `useQuery` on the client. If the query is still `pending`, its in-flight +promise is dehydrated too so it can be resumed on the other side instead of re-fetched. + +## Parameters + +### query + +[`Query`](../classes/Query.md) + +The query to dehydrate. + +### serializeData? + +`TransformerFn` + +Optional transform applied to `query.state.data` before it is included in the snapshot. + +### shouldRedactErrors? + +(`error`) => `boolean` + +Optional predicate; if it returns `false` for the promise's rejection error, that +error is kept as-is instead of being redacted. + +## Returns + +`DehydratedQuery` diff --git a/docs/framework/preact/reference/functions/experimental_streamedQuery.md b/docs/framework/preact/reference/functions/experimental_streamedQuery.md new file mode 100644 index 00000000000..4c490322d60 --- /dev/null +++ b/docs/framework/preact/reference/functions/experimental_streamedQuery.md @@ -0,0 +1,52 @@ +--- +id: experimental_streamedQuery +title: experimental_streamedQuery +--- + +```ts +function experimental_streamedQuery(streamFn): QueryFunction; +``` + +Defined in: [packages/query-core/src/streamedQuery.ts:75](https://github.com/TanStack/query/blob/main/packages/query-core/src/streamedQuery.ts#L75) + +This is a helper function to create a query function that streams data from an AsyncIterable. +Data will be an Array of all the chunks received. +The query will be in a 'pending' state until the first chunk of data is received, but will go to 'success' after that. +The query will stay in fetchStatus 'fetching' until the stream ends. + +## Type Parameters + +### TQueryFnData + +`TQueryFnData` = `unknown` + +### TData + +`TData` = `TQueryFnData`[] + +### TQueryKey + +`TQueryKey` *extends* readonly `unknown`[] = readonly `unknown`[] + +## Parameters + +### streamFn + +`StreamedQueryParams`\<`TQueryFnData`, `TData`, `TQueryKey`\> + +The function that returns an AsyncIterable to stream data from. + +## Returns + +[`QueryFunction`](../type-aliases/QueryFunction.md)\<`TData`, `TQueryKey`\> + +## Example + +```ts +await queryClient.query({ + queryKey: ['data'], + queryFn: streamedQuery({ + streamFn: fetchDataInChunks, + }), +}) +``` diff --git a/docs/framework/preact/reference/functions/hashKey.md b/docs/framework/preact/reference/functions/hashKey.md new file mode 100644 index 00000000000..dc774c032ce --- /dev/null +++ b/docs/framework/preact/reference/functions/hashKey.md @@ -0,0 +1,30 @@ +--- +id: hashKey +title: hashKey +--- + +```ts +function hashKey(queryKey): string; +``` + +Defined in: [packages/query-core/src/utils.ts:284](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L284) + +Default query & mutation keys hash function. +Hashes the value into a stable hash. + +## Parameters + +### queryKey + +readonly `unknown`[] + +## Returns + +`string` + +## Example + +```ts +// Object keys are sorted, so key order doesn't affect the hash: +hashKey(['todos', { page: 1, filter: 'done' }]) // === '["todos",{"filter":"done","page":1}]' +``` diff --git a/docs/framework/preact/reference/functions/hydrate.md b/docs/framework/preact/reference/functions/hydrate.md new file mode 100644 index 00000000000..c0093b57457 --- /dev/null +++ b/docs/framework/preact/reference/functions/hydrate.md @@ -0,0 +1,49 @@ +--- +id: hydrate +title: hydrate +--- + +```ts +function hydrate( + client, + dehydratedState, + options?): void; +``` + +Defined in: [packages/query-core/src/hydration.ts:264](https://github.com/TanStack/query/blob/main/packages/query-core/src/hydration.ts#L264) + +Restores a `DehydratedState` (as produced by `dehydrate`) into a `QueryClient`'s cache, typically to seed the +client with data already fetched on the server. `mutations` and `queries` are each optional on `dehydratedState`. +Queries not yet in the cache are built from the dehydrated snapshot; queries that already exist are only updated +when the dehydrated data is newer than what's already cached. Newly built queries have their `fetchStatus` reset +to `'idle'` so they don't hydrate stuck in a fetching state. If a dehydrated query still had an in-flight +promise, it is resumed via `query.fetch()` (reusing that promise as `initialPromise`) rather than re-invoking +`queryFn`. + +## Parameters + +### client + +[`QueryClient`](../classes/QueryClient.md) + +### dehydratedState + +`Partial`\<[`DehydratedState`](../interfaces/DehydratedState.md)\> + +### options? + +[`HydrateOptions`](../interfaces/HydrateOptions.md) + +## Returns + +`void` + +## Example + +```ts +// dehydratedState was produced by `dehydrate` on the server +// and sent to the client, e.g. embedded in server-rendered markup. +const queryClient = new QueryClient() + +hydrate(queryClient, dehydratedState) +``` diff --git a/docs/framework/preact/reference/functions/infiniteQueryOptions.md b/docs/framework/preact/reference/functions/infiniteQueryOptions.md index af2d8e8fcc8..e1439dfbc3f 100644 --- a/docs/framework/preact/reference/functions/infiniteQueryOptions.md +++ b/docs/framework/preact/reference/functions/infiniteQueryOptions.md @@ -9,7 +9,7 @@ title: infiniteQueryOptions function infiniteQueryOptions(options): UseInfiniteQueryOptions & object & QueryKeyWithDataTag, TError>; ``` -Defined in: [preact-query/src/infiniteQueryOptions.ts:171](https://github.com/TanStack/query/blob/main/packages/preact-query/src/infiniteQueryOptions.ts#L171) +Defined in: [packages/preact-query/src/infiniteQueryOptions.ts:171](https://github.com/TanStack/query/blob/main/packages/preact-query/src/infiniteQueryOptions.ts#L171) You can generally pass everything to `infiniteQueryOptions` that you can also pass to `useInfiniteQuery`. These options can be shared across hooks and imperative APIs such as `queryClient.infiniteQuery`. @@ -29,7 +29,7 @@ This overload is selected when `initialData` is set. #### TData -`TData` = `InfiniteData`\<`TQueryFnData`, `unknown`\> +`TData` = [`InfiniteData`](../interfaces/InfiniteData.md)\<`TQueryFnData`, `unknown`\> #### TQueryKey @@ -95,7 +95,7 @@ function Projects() { function infiniteQueryOptions(options): OmitKeyof, "queryFn"> & object & QueryKeyWithDataTag, TError>; ``` -Defined in: [preact-query/src/infiniteQueryOptions.ts:233](https://github.com/TanStack/query/blob/main/packages/preact-query/src/infiniteQueryOptions.ts#L233) +Defined in: [packages/preact-query/src/infiniteQueryOptions.ts:233](https://github.com/TanStack/query/blob/main/packages/preact-query/src/infiniteQueryOptions.ts#L233) You can generally pass everything to `infiniteQueryOptions` that you can also pass to `useInfiniteQuery`. These options can be shared across hooks and imperative APIs such as `queryClient.infiniteQuery`. @@ -113,7 +113,7 @@ These options can be shared across hooks and imperative APIs such as `queryClien #### TData -`TData` = `InfiniteData`\<`TQueryFnData`, `unknown`\> +`TData` = [`InfiniteData`](../interfaces/InfiniteData.md)\<`TQueryFnData`, `unknown`\> #### TQueryKey @@ -178,7 +178,7 @@ function Comments({ postId }: { postId: string }) { function infiniteQueryOptions(options): UseInfiniteQueryOptions & object & QueryKeyWithDataTag, TError>; ``` -Defined in: [preact-query/src/infiniteQueryOptions.ts:295](https://github.com/TanStack/query/blob/main/packages/preact-query/src/infiniteQueryOptions.ts#L295) +Defined in: [packages/preact-query/src/infiniteQueryOptions.ts:295](https://github.com/TanStack/query/blob/main/packages/preact-query/src/infiniteQueryOptions.ts#L295) You can generally pass everything to `infiniteQueryOptions` that you can also pass to `useInfiniteQuery`. These options can be shared across hooks and imperative APIs such as `queryClient.infiniteQuery`. @@ -196,7 +196,7 @@ These options can be shared across hooks and imperative APIs such as `queryClien #### TData -`TData` = `InfiniteData`\<`TQueryFnData`, `unknown`\> +`TData` = [`InfiniteData`](../interfaces/InfiniteData.md)\<`TQueryFnData`, `unknown`\> #### TQueryKey diff --git a/docs/framework/preact/reference/functions/isCancelledError.md b/docs/framework/preact/reference/functions/isCancelledError.md new file mode 100644 index 00000000000..c8f57c4b94d --- /dev/null +++ b/docs/framework/preact/reference/functions/isCancelledError.md @@ -0,0 +1,24 @@ +--- +id: isCancelledError +title: isCancelledError +--- + +```ts +function isCancelledError(value): value is CancelledError; +``` + +Defined in: [packages/query-core/src/retryer.ts:90](https://github.com/TanStack/query/blob/main/packages/query-core/src/retryer.ts#L90) + +## Parameters + +### value + +`any` + +## Returns + +`value is CancelledError` + +## Deprecated + +Use instanceof `CancelledError` instead. diff --git a/docs/framework/preact/reference/functions/keepPreviousData.md b/docs/framework/preact/reference/functions/keepPreviousData.md new file mode 100644 index 00000000000..6a84f4c5970 --- /dev/null +++ b/docs/framework/preact/reference/functions/keepPreviousData.md @@ -0,0 +1,40 @@ +--- +id: keepPreviousData +title: keepPreviousData +--- + +```ts +function keepPreviousData(previousData): T | undefined; +``` + +Defined in: [packages/query-core/src/utils.ts:493](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L493) + +Intended to be passed as a query's `placeholderData` option, for example +`placeholderData: keepPreviousData`. Instead of resetting the query's data to `undefined` while a new +query key is fetching, it keeps displaying the previously fetched data until the new data arrives. + +## Type Parameters + +### T + +`T` + +## Parameters + +### previousData + +`T` | `undefined` + +## Returns + +`T` \| `undefined` + +## Example + +```ts +new QueryObserver(queryClient, { + queryKey: ['posts', page], + queryFn: () => fetchPosts(page), + placeholderData: keepPreviousData, +}) +``` diff --git a/docs/framework/preact/reference/functions/matchMutation.md b/docs/framework/preact/reference/functions/matchMutation.md new file mode 100644 index 00000000000..40210da4cf1 --- /dev/null +++ b/docs/framework/preact/reference/functions/matchMutation.md @@ -0,0 +1,38 @@ +--- +id: matchMutation +title: matchMutation +--- + +```ts +function matchMutation(filters, mutation): boolean; +``` + +Defined in: [packages/query-core/src/utils.ts:237](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L237) + +Checks whether a mutation matches the given [MutationFilters](../interfaces/MutationFilters.md). +Every filter that is specified must match; filters that are left unspecified are ignored. +If a `mutationKey` filter is provided but the mutation has no `mutationKey` of its own, it does not match. + +## Parameters + +### filters + +[`MutationFilters`](../interfaces/MutationFilters.md) + +### mutation + +[`Mutation`](../classes/Mutation.md)\<`any`, `any`\> + +## Returns + +`boolean` + +## Example + +```ts +const mutationCache = queryClient.getMutationCache() + +const matchingMutations = mutationCache + .getAll() + .filter((mutation) => matchMutation({ mutationKey: ['addPost'] }, mutation)) +``` diff --git a/docs/framework/preact/reference/functions/matchQuery.md b/docs/framework/preact/reference/functions/matchQuery.md new file mode 100644 index 00000000000..4c54b2df995 --- /dev/null +++ b/docs/framework/preact/reference/functions/matchQuery.md @@ -0,0 +1,37 @@ +--- +id: matchQuery +title: matchQuery +--- + +```ts +function matchQuery(filters, query): boolean; +``` + +Defined in: [packages/query-core/src/utils.ts:175](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L175) + +Checks whether a query matches the given [QueryFilters](../interfaces/QueryFilters.md). +Every filter that is specified must match; filters that are left unspecified are ignored. + +## Parameters + +### filters + +[`QueryFilters`](../interfaces/QueryFilters.md) + +### query + +[`Query`](../classes/Query.md)\<`any`, `any`, `any`, `any`\> + +## Returns + +`boolean` + +## Example + +```ts +const queryCache = queryClient.getQueryCache() + +const matchingQueries = queryCache + .getAll() + .filter((query) => matchQuery({ queryKey: ['posts'] }, query)) +``` diff --git a/docs/framework/preact/reference/functions/mutationOptions.md b/docs/framework/preact/reference/functions/mutationOptions.md index 47847cb0bed..ac38fd049c5 100644 --- a/docs/framework/preact/reference/functions/mutationOptions.md +++ b/docs/framework/preact/reference/functions/mutationOptions.md @@ -9,7 +9,7 @@ title: mutationOptions function mutationOptions(options): WithRequired, "mutationKey">; ``` -Defined in: [preact-query/src/mutationOptions.ts:34](https://github.com/TanStack/query/blob/main/packages/preact-query/src/mutationOptions.ts#L34) +Defined in: [packages/preact-query/src/mutationOptions.ts:34](https://github.com/TanStack/query/blob/main/packages/preact-query/src/mutationOptions.ts#L34) You can generally pass everything to `mutationOptions` that you can also pass to `useMutation`. A `mutationKey` is required on this overload so the mutation can be looked up later, e.g. with @@ -37,14 +37,14 @@ You can generally pass everything to `mutationOptions` that you can also pass to #### options -`WithRequired`\<[`UseMutationOptions`](../interfaces/UseMutationOptions.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\>, `"mutationKey"`\> +[`WithRequired`](../type-aliases/WithRequired.md)\<[`UseMutationOptions`](../interfaces/UseMutationOptions.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\>, `"mutationKey"`\> The mutation options to use, identical to what you'd pass to `useMutation`, with a required `mutationKey`. ### Returns -`WithRequired`\<[`UseMutationOptions`](../interfaces/UseMutationOptions.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\>, `"mutationKey"`\> +[`WithRequired`](../type-aliases/WithRequired.md)\<[`UseMutationOptions`](../interfaces/UseMutationOptions.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\>, `"mutationKey"`\> The same options object, unchanged. @@ -78,7 +78,7 @@ function SavingIndicator() { function mutationOptions(options): Omit, "mutationKey">; ``` -Defined in: [preact-query/src/mutationOptions.ts:74](https://github.com/TanStack/query/blob/main/packages/preact-query/src/mutationOptions.ts#L74) +Defined in: [packages/preact-query/src/mutationOptions.ts:74](https://github.com/TanStack/query/blob/main/packages/preact-query/src/mutationOptions.ts#L74) You can generally pass everything to `mutationOptions` that you can also pass to `useMutation`. No `mutationKey` is required on this overload — use this when you don't need to target the mutation via a diff --git a/docs/framework/preact/reference/functions/noop.md b/docs/framework/preact/reference/functions/noop.md new file mode 100644 index 00000000000..01fb409f4e9 --- /dev/null +++ b/docs/framework/preact/reference/functions/noop.md @@ -0,0 +1,32 @@ +--- +id: noop +title: noop +--- + +## Call Signature + +```ts +function noop(): void; +``` + +Defined in: [packages/query-core/src/utils.ts:119](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L119) + +A function that does nothing. + +### Returns + +`void` + +## Call Signature + +```ts +function noop(): undefined; +``` + +Defined in: [packages/query-core/src/utils.ts:120](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L120) + +A function that does nothing. + +### Returns + +`undefined` diff --git a/docs/framework/preact/reference/functions/partialMatchKey.md b/docs/framework/preact/reference/functions/partialMatchKey.md new file mode 100644 index 00000000000..4db67323e9b --- /dev/null +++ b/docs/framework/preact/reference/functions/partialMatchKey.md @@ -0,0 +1,26 @@ +--- +id: partialMatchKey +title: partialMatchKey +--- + +```ts +function partialMatchKey(a, b): boolean; +``` + +Defined in: [packages/query-core/src/utils.ts:300](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L300) + +Checks if key `b` partially matches with key `a`. + +## Parameters + +### a + +readonly `unknown`[] + +### b + +readonly `unknown`[] + +## Returns + +`boolean` diff --git a/docs/framework/preact/reference/functions/queryOptions.md b/docs/framework/preact/reference/functions/queryOptions.md index ac200a49bfe..2d39a583ad2 100644 --- a/docs/framework/preact/reference/functions/queryOptions.md +++ b/docs/framework/preact/reference/functions/queryOptions.md @@ -9,7 +9,7 @@ title: queryOptions function queryOptions(options): Omit, "queryFn"> & object & QueryKeyWithDataTag; ``` -Defined in: [preact-query/src/queryOptions.ts:143](https://github.com/TanStack/query/blob/main/packages/preact-query/src/queryOptions.ts#L143) +Defined in: [packages/preact-query/src/queryOptions.ts:143](https://github.com/TanStack/query/blob/main/packages/preact-query/src/queryOptions.ts#L143) You can generally pass everything to `queryOptions` that you can also pass to `useQuery`. These options can be shared across hooks and imperative APIs such as `queryClient.query`. `options.queryKey` is required and @@ -85,7 +85,7 @@ function Posts() { function queryOptions(options): OmitKeyof, "queryFn"> & object & QueryKeyWithDataTag; ``` -Defined in: [preact-query/src/queryOptions.ts:184](https://github.com/TanStack/query/blob/main/packages/preact-query/src/queryOptions.ts#L184) +Defined in: [packages/preact-query/src/queryOptions.ts:184](https://github.com/TanStack/query/blob/main/packages/preact-query/src/queryOptions.ts#L184) You can generally pass everything to `queryOptions` that you can also pass to `useQuery`. These options can be shared across hooks and imperative APIs such as `queryClient.query`. `options.queryKey` is required and @@ -154,7 +154,7 @@ function Post({ id }: { id: string }) { function queryOptions(options): UseQueryOptions & object & QueryKeyWithDataTag; ``` -Defined in: [preact-query/src/queryOptions.ts:248](https://github.com/TanStack/query/blob/main/packages/preact-query/src/queryOptions.ts#L248) +Defined in: [packages/preact-query/src/queryOptions.ts:248](https://github.com/TanStack/query/blob/main/packages/preact-query/src/queryOptions.ts#L248) You can generally pass everything to `queryOptions` that you can also pass to `useQuery`. These options can be shared across hooks and imperative APIs such as `queryClient.query`. `options.queryKey` is required and diff --git a/docs/framework/preact/reference/functions/replaceEqualDeep.md b/docs/framework/preact/reference/functions/replaceEqualDeep.md new file mode 100644 index 00000000000..6a81c3907fb --- /dev/null +++ b/docs/framework/preact/reference/functions/replaceEqualDeep.md @@ -0,0 +1,41 @@ +--- +id: replaceEqualDeep +title: replaceEqualDeep +--- + +```ts +function replaceEqualDeep( + a, + b, + depth?): T; +``` + +Defined in: [packages/query-core/src/utils.ts:339](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L339) + +This function returns `a` if `b` is deeply equal. +If not, it will replace any deeply equal children of `b` with those of `a`. +This can be used for structural sharing between JSON values for example. + +## Type Parameters + +### T + +`T` + +## Parameters + +### a + +`unknown` + +### b + +`T` + +### depth? + +`number` + +## Returns + +`T` diff --git a/docs/framework/preact/reference/functions/shouldThrowError.md b/docs/framework/preact/reference/functions/shouldThrowError.md new file mode 100644 index 00000000000..1f1e62a8d0e --- /dev/null +++ b/docs/framework/preact/reference/functions/shouldThrowError.md @@ -0,0 +1,45 @@ +--- +id: shouldThrowError +title: shouldThrowError +--- + +```ts +function shouldThrowError(throwOnError, params): boolean; +``` + +Defined in: [packages/query-core/src/utils.ts:576](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L576) + +Resolves a `throwOnError` option to a boolean. +If `throwOnError` is a function, it is called with `params` (e.g. the error and, depending on the caller, +additional context such as the query or mutation) and its result is returned, allowing the throwing +behavior to be decided per error. Otherwise, `throwOnError` itself is coerced to a boolean (`undefined` +resolves to `false`). + +## Type Parameters + +### T + +`T` *extends* (...`args`) => `boolean` + +## Parameters + +### throwOnError + +`boolean` | `T` | `undefined` + +### params + +`Parameters`\<`T`\> + +## Returns + +`boolean` + +## Example + +```ts +const throwOnError = + query.state.error && typeof options.throwOnError === 'function' + ? shouldThrowError(options.throwOnError, [query.state.error, query]) + : options.throwOnError +``` diff --git a/docs/framework/preact/reference/functions/useInfiniteQuery.md b/docs/framework/preact/reference/functions/useInfiniteQuery.md index 34f7ae82def..ff94b7f66b3 100644 --- a/docs/framework/preact/reference/functions/useInfiniteQuery.md +++ b/docs/framework/preact/reference/functions/useInfiniteQuery.md @@ -9,7 +9,7 @@ title: useInfiniteQuery function useInfiniteQuery(options, queryClient?): DefinedUseInfiniteQueryResult; ``` -Defined in: [preact-query/src/useInfiniteQuery.ts:65](https://github.com/TanStack/query/blob/main/packages/preact-query/src/useInfiniteQuery.ts#L65) +Defined in: [packages/preact-query/src/useInfiniteQuery.ts:65](https://github.com/TanStack/query/blob/main/packages/preact-query/src/useInfiniteQuery.ts#L65) The options for `useInfiniteQuery` are identical to `useQuery`, with the addition of `initialPageParam`, `getNextPageParam`, `getPreviousPageParam`, and `maxPages`. @@ -28,7 +28,7 @@ This overload is selected when `initialData` is set. #### TData -`TData` = `InfiniteData`\<`TQueryFnData`, `unknown`\> +`TData` = [`InfiniteData`](../interfaces/InfiniteData.md)\<`TQueryFnData`, `unknown`\> #### TQueryKey @@ -48,7 +48,7 @@ The [DefinedInitialDataInfiniteOptions](../type-aliases/DefinedInitialDataInfini #### queryClient? -`QueryClient` +[`QueryClient`](../classes/QueryClient.md) Use this to use a custom `QueryClient`. Otherwise, the one from the nearest context will be used. @@ -105,7 +105,7 @@ function Projects() { function useInfiniteQuery(options, queryClient?): UseInfiniteQueryResult; ``` -Defined in: [preact-query/src/useInfiniteQuery.ts:191](https://github.com/TanStack/query/blob/main/packages/preact-query/src/useInfiniteQuery.ts#L191) +Defined in: [packages/preact-query/src/useInfiniteQuery.ts:191](https://github.com/TanStack/query/blob/main/packages/preact-query/src/useInfiniteQuery.ts#L191) The options for `useInfiniteQuery` are identical to `useQuery`, with the addition of `initialPageParam`, `getNextPageParam`, `getPreviousPageParam`, and `maxPages`. @@ -122,7 +122,7 @@ The options for `useInfiniteQuery` are identical to `useQuery`, with the additio #### TData -`TData` = `InfiniteData`\<`TQueryFnData`, `unknown`\> +`TData` = [`InfiniteData`](../interfaces/InfiniteData.md)\<`TQueryFnData`, `unknown`\> #### TQueryKey @@ -142,7 +142,7 @@ The [UndefinedInitialDataInfiniteOptions](../type-aliases/UndefinedInitialDataIn #### queryClient? -`QueryClient` +[`QueryClient`](../classes/QueryClient.md) Use this to use a custom `QueryClient`. Otherwise, the one from the nearest context will be used. @@ -265,7 +265,7 @@ function Projects() { function useInfiniteQuery(options, queryClient?): UseInfiniteQueryResult; ``` -Defined in: [preact-query/src/useInfiniteQuery.ts:347](https://github.com/TanStack/query/blob/main/packages/preact-query/src/useInfiniteQuery.ts#L347) +Defined in: [packages/preact-query/src/useInfiniteQuery.ts:347](https://github.com/TanStack/query/blob/main/packages/preact-query/src/useInfiniteQuery.ts#L347) The options for `useInfiniteQuery` are identical to `useQuery`, with the addition of `initialPageParam`, `getNextPageParam`, `getPreviousPageParam`, and `maxPages`. @@ -282,7 +282,7 @@ The options for `useInfiniteQuery` are identical to `useQuery`, with the additio #### TData -`TData` = `InfiniteData`\<`TQueryFnData`, `unknown`\> +`TData` = [`InfiniteData`](../interfaces/InfiniteData.md)\<`TQueryFnData`, `unknown`\> #### TQueryKey @@ -302,7 +302,7 @@ The [UseInfiniteQueryOptions](../interfaces/UseInfiniteQueryOptions.md) to use #### queryClient? -`QueryClient` +[`QueryClient`](../classes/QueryClient.md) Use this to use a custom `QueryClient`. Otherwise, the one from the nearest context will be used. diff --git a/docs/framework/preact/reference/functions/useIsFetching.md b/docs/framework/preact/reference/functions/useIsFetching.md index 2a85ba9866b..5e4f6078b14 100644 --- a/docs/framework/preact/reference/functions/useIsFetching.md +++ b/docs/framework/preact/reference/functions/useIsFetching.md @@ -7,7 +7,7 @@ title: useIsFetching function useIsFetching(filters?, queryClient?): number; ``` -Defined in: [preact-query/src/useIsFetching.ts:44](https://github.com/TanStack/query/blob/main/packages/preact-query/src/useIsFetching.ts#L44) +Defined in: [packages/preact-query/src/useIsFetching.ts:44](https://github.com/TanStack/query/blob/main/packages/preact-query/src/useIsFetching.ts#L44) The `useIsFetching` hook returns the `number` of the queries that your application is loading or fetching in the background (useful for app-wide loading indicators). @@ -16,13 +16,13 @@ the background (useful for app-wide loading indicators). ### filters? -`QueryFilters`\ +[`QueryFilters`](../interfaces/QueryFilters.md)\ -The QueryFilters to narrow down the matched queries. +The [QueryFilters](../interfaces/QueryFilters.md) to narrow down the matched queries. ### queryClient? -`QueryClient` +[`QueryClient`](../classes/QueryClient.md) Use this to use a custom `QueryClient`. Otherwise, the one from the nearest context will be used. diff --git a/docs/framework/preact/reference/functions/useIsMutating.md b/docs/framework/preact/reference/functions/useIsMutating.md index 3c3cce2caaa..78150aa4390 100644 --- a/docs/framework/preact/reference/functions/useIsMutating.md +++ b/docs/framework/preact/reference/functions/useIsMutating.md @@ -7,7 +7,7 @@ title: useIsMutating function useIsMutating(filters?, queryClient?): number; ``` -Defined in: [preact-query/src/useMutationState.ts:35](https://github.com/TanStack/query/blob/main/packages/preact-query/src/useMutationState.ts#L35) +Defined in: [packages/preact-query/src/useMutationState.ts:35](https://github.com/TanStack/query/blob/main/packages/preact-query/src/useMutationState.ts#L35) The `useIsMutating` hook returns the `number` of mutations that your application currently has `pending` (useful for app-wide loading indicators). @@ -16,13 +16,13 @@ The `useIsMutating` hook returns the `number` of mutations that your application ### filters? -`MutationFilters`\<`unknown`, `Error`, `unknown`, `unknown`\> +[`MutationFilters`](../interfaces/MutationFilters.md)\<`unknown`, `Error`, `unknown`, `unknown`\> -The MutationFilters to narrow down the matched mutations. +The [MutationFilters](../interfaces/MutationFilters.md) to narrow down the matched mutations. ### queryClient? -`QueryClient` +[`QueryClient`](../classes/QueryClient.md) Use this to use a custom `QueryClient`. Otherwise, the one from the nearest context will be used. diff --git a/docs/framework/preact/reference/functions/useIsRestoring.md b/docs/framework/preact/reference/functions/useIsRestoring.md index e81909e2221..17d26e9ad8c 100644 --- a/docs/framework/preact/reference/functions/useIsRestoring.md +++ b/docs/framework/preact/reference/functions/useIsRestoring.md @@ -7,7 +7,7 @@ title: useIsRestoring function useIsRestoring(): boolean; ``` -Defined in: [preact-query/src/IsRestoringProvider.ts:13](https://github.com/TanStack/query/blob/main/packages/preact-query/src/IsRestoringProvider.ts#L13) +Defined in: [packages/preact-query/src/IsRestoringProvider.ts:13](https://github.com/TanStack/query/blob/main/packages/preact-query/src/IsRestoringProvider.ts#L13) If you are using `PersistQueryClientProvider`, you can also use the `useIsRestoring` hook alongside it to check if a restore is currently in progress. `useQuery` and friends also check this internally to avoid diff --git a/docs/framework/preact/reference/functions/useMutation.md b/docs/framework/preact/reference/functions/useMutation.md index 354feabe433..5e7af270612 100644 --- a/docs/framework/preact/reference/functions/useMutation.md +++ b/docs/framework/preact/reference/functions/useMutation.md @@ -7,7 +7,7 @@ title: useMutation function useMutation(options, queryClient?): UseMutationResult; ``` -Defined in: [preact-query/src/useMutation.ts:192](https://github.com/TanStack/query/blob/main/packages/preact-query/src/useMutation.ts#L192) +Defined in: [packages/preact-query/src/useMutation.ts:192](https://github.com/TanStack/query/blob/main/packages/preact-query/src/useMutation.ts#L192) Unlike queries, mutations are typically used to create/update/delete data or perform server side-effects. `useMutation` is the hook for that. @@ -40,7 +40,7 @@ The [UseMutationOptions](../interfaces/UseMutationOptions.md) to use — everyth ### queryClient? -`QueryClient` +[`QueryClient`](../classes/QueryClient.md) Use this to use a custom `QueryClient`. Otherwise, the one from the nearest context will be used. diff --git a/docs/framework/preact/reference/functions/useMutationState.md b/docs/framework/preact/reference/functions/useMutationState.md index 8e27be52f67..61bf6aa635f 100644 --- a/docs/framework/preact/reference/functions/useMutationState.md +++ b/docs/framework/preact/reference/functions/useMutationState.md @@ -7,21 +7,21 @@ title: useMutationState function useMutationState(options, queryClient?): TResult[]; ``` -Defined in: [preact-query/src/useMutationState.ts:157](https://github.com/TanStack/query/blob/main/packages/preact-query/src/useMutationState.ts#L157) +Defined in: [packages/preact-query/src/useMutationState.ts:157](https://github.com/TanStack/query/blob/main/packages/preact-query/src/useMutationState.ts#L157) `useMutationState` is a hook that gives you access to all mutations in the `MutationCache`. You can pass -`filters` (MutationFilters) to narrow down your mutations, and `select` to transform the mutation +`filters` ([MutationFilters](../interfaces/MutationFilters.md)) to narrow down your mutations, and `select` to transform the mutation state. ## Type Parameters ### TResult -`TResult` = `MutationState`\<`unknown`, `Error`, `unknown`, `unknown`\> +`TResult` = [`MutationState`](../interfaces/MutationState.md)\<`unknown`, `Error`, `unknown`, `unknown`\> ### TMutation -`TMutation` *extends* `Mutation`\<`any`, `any`, `any`, `any`\> = `MutationTypeFromResult`\<`TResult`\> +`TMutation` *extends* [`Mutation`](../classes/Mutation.md)\<`any`, `any`, `any`, `any`\> = `MutationTypeFromResult`\<`TResult`\> ## Parameters @@ -34,7 +34,7 @@ mutation state. ### queryClient? -`QueryClient` +[`QueryClient`](../classes/QueryClient.md) Use this to use a custom `QueryClient`. Otherwise, the one from the nearest context will be used. diff --git a/docs/framework/preact/reference/functions/usePrefetchInfiniteQuery.md b/docs/framework/preact/reference/functions/usePrefetchInfiniteQuery.md index b3995ea24db..3da9d34ad1f 100644 --- a/docs/framework/preact/reference/functions/usePrefetchInfiniteQuery.md +++ b/docs/framework/preact/reference/functions/usePrefetchInfiniteQuery.md @@ -7,7 +7,7 @@ title: usePrefetchInfiniteQuery function usePrefetchInfiniteQuery(options, queryClient?): void; ``` -Defined in: [preact-query/src/usePrefetchInfiniteQuery.tsx:51](https://github.com/TanStack/query/blob/main/packages/preact-query/src/usePrefetchInfiniteQuery.tsx#L51) +Defined in: [packages/preact-query/src/usePrefetchInfiniteQuery.tsx:51](https://github.com/TanStack/query/blob/main/packages/preact-query/src/usePrefetchInfiniteQuery.tsx#L51) `usePrefetchInfiniteQuery` does not return anything, it should be used just to fire a prefetch during render, before a suspense boundary that wraps a component that uses `useSuspenseInfiniteQuery`. You can pass @@ -55,7 +55,7 @@ The [UsePrefetchInfiniteQueryOptions](../type-aliases/UsePrefetchInfiniteQueryOp ### queryClient? -`QueryClient` +[`QueryClient`](../classes/QueryClient.md) Use this to use a custom `QueryClient`. Otherwise, the one from the nearest context will be used. diff --git a/docs/framework/preact/reference/functions/usePrefetchQuery.md b/docs/framework/preact/reference/functions/usePrefetchQuery.md index 872a6f57ec4..3fbd25b4d6a 100644 --- a/docs/framework/preact/reference/functions/usePrefetchQuery.md +++ b/docs/framework/preact/reference/functions/usePrefetchQuery.md @@ -7,7 +7,7 @@ title: usePrefetchQuery function usePrefetchQuery(options, queryClient?): void; ``` -Defined in: [preact-query/src/usePrefetchQuery.tsx:42](https://github.com/TanStack/query/blob/main/packages/preact-query/src/usePrefetchQuery.tsx#L42) +Defined in: [packages/preact-query/src/usePrefetchQuery.tsx:42](https://github.com/TanStack/query/blob/main/packages/preact-query/src/usePrefetchQuery.tsx#L42) `usePrefetchQuery` does not return anything, it should be used just to fire a prefetch during render, before a suspense boundary that wraps a component that uses `useSuspenseQuery`. You can pass everything to @@ -50,7 +50,7 @@ The [UsePrefetchQueryOptions](../type-aliases/UsePrefetchQueryOptions.md) to use ### queryClient? -`QueryClient` +[`QueryClient`](../classes/QueryClient.md) Use this to use a custom `QueryClient`. Otherwise, the one from the nearest context will be used. diff --git a/docs/framework/preact/reference/functions/useQueries.md b/docs/framework/preact/reference/functions/useQueries.md index b5d9317ee70..6688d8d5614 100644 --- a/docs/framework/preact/reference/functions/useQueries.md +++ b/docs/framework/preact/reference/functions/useQueries.md @@ -7,7 +7,7 @@ title: useQueries function useQueries(__namedParameters, queryClient?): TCombinedResult; ``` -Defined in: [preact-query/src/useQueries.ts:302](https://github.com/TanStack/query/blob/main/packages/preact-query/src/useQueries.ts#L302) +Defined in: [packages/preact-query/src/useQueries.ts:302](https://github.com/TanStack/query/blob/main/packages/preact-query/src/useQueries.ts#L302) The `useQueries` hook can be used to fetch a variable number of queries. @@ -50,7 +50,7 @@ shared to be as referentially stable as possible. An array with query option objects, mostly identical to `useQuery` — except that `queryClient` and `subscribed` aren't accepted per-query (`subscribed` is a top-level option here instead), and -`placeholderData` accepts a QueriesPlaceholderDataFunction, which is called with `previousData` +`placeholderData` accepts a [QueriesPlaceholderDataFunction](../type-aliases/QueriesPlaceholderDataFunction.md), which is called with `previousData` and `previousQuery` always `undefined`, rather than `useQuery`'s placeholder function. #### subscribed? @@ -67,7 +67,7 @@ true ### queryClient? -`QueryClient` +[`QueryClient`](../classes/QueryClient.md) Use this to provide a custom `QueryClient`. Otherwise, the one from the nearest context will be used. diff --git a/docs/framework/preact/reference/functions/useQuery.md b/docs/framework/preact/reference/functions/useQuery.md index 55242ebc4cb..3c38353336f 100644 --- a/docs/framework/preact/reference/functions/useQuery.md +++ b/docs/framework/preact/reference/functions/useQuery.md @@ -9,7 +9,7 @@ title: useQuery function useQuery(options, queryClient?): DefinedUseQueryResult; ``` -Defined in: [preact-query/src/useQuery.ts:50](https://github.com/TanStack/query/blob/main/packages/preact-query/src/useQuery.ts#L50) +Defined in: [packages/preact-query/src/useQuery.ts:50](https://github.com/TanStack/query/blob/main/packages/preact-query/src/useQuery.ts#L50) This overload is selected when `initialData` is set, so the resulting `data` is never `undefined`. @@ -41,7 +41,7 @@ The [DefinedInitialDataOptions](../type-aliases/DefinedInitialDataOptions.md) to #### queryClient? -`QueryClient` +[`QueryClient`](../classes/QueryClient.md) Use this to use a custom `QueryClient`. Otherwise, the one from the nearest context will be used. @@ -89,7 +89,7 @@ function Posts() { function useQuery(options, queryClient?): UseQueryResult; ``` -Defined in: [preact-query/src/useQuery.ts:117](https://github.com/TanStack/query/blob/main/packages/preact-query/src/useQuery.ts#L117) +Defined in: [packages/preact-query/src/useQuery.ts:117](https://github.com/TanStack/query/blob/main/packages/preact-query/src/useQuery.ts#L117) ### Type Parameters @@ -119,7 +119,7 @@ The [UndefinedInitialDataOptions](../type-aliases/UndefinedInitialDataOptions.md #### queryClient? -`QueryClient` +[`QueryClient`](../classes/QueryClient.md) Use this to use a custom `QueryClient`. Otherwise, the one from the nearest context will be used. @@ -190,7 +190,7 @@ function Posts() { function useQuery(options, queryClient?): UseQueryResult; ``` -Defined in: [preact-query/src/useQuery.ts:281](https://github.com/TanStack/query/blob/main/packages/preact-query/src/useQuery.ts#L281) +Defined in: [packages/preact-query/src/useQuery.ts:281](https://github.com/TanStack/query/blob/main/packages/preact-query/src/useQuery.ts#L281) ### Type Parameters @@ -220,7 +220,7 @@ The [UseQueryOptions](../interfaces/UseQueryOptions.md) to use — everything yo #### queryClient? -`QueryClient` +[`QueryClient`](../classes/QueryClient.md) Use this to use a custom `QueryClient`. Otherwise, the one from the nearest context will be used. diff --git a/docs/framework/preact/reference/functions/useQueryClient.md b/docs/framework/preact/reference/functions/useQueryClient.md index 0e075039e25..bc98c2f9d13 100644 --- a/docs/framework/preact/reference/functions/useQueryClient.md +++ b/docs/framework/preact/reference/functions/useQueryClient.md @@ -7,7 +7,7 @@ title: useQueryClient function useQueryClient(queryClient?): QueryClient; ``` -Defined in: [preact-query/src/QueryClientProvider.tsx:21](https://github.com/TanStack/query/blob/main/packages/preact-query/src/QueryClientProvider.tsx#L21) +Defined in: [packages/preact-query/src/QueryClientProvider.tsx:21](https://github.com/TanStack/query/blob/main/packages/preact-query/src/QueryClientProvider.tsx#L21) The `useQueryClient` hook returns the current `QueryClient` instance. @@ -15,14 +15,14 @@ The `useQueryClient` hook returns the current `QueryClient` instance. ### queryClient? -`QueryClient` +[`QueryClient`](../classes/QueryClient.md) Use this to use a custom `QueryClient`. Otherwise, the one from the nearest context will be used. ## Returns -`QueryClient` +[`QueryClient`](../classes/QueryClient.md) The current `QueryClient` instance. diff --git a/docs/framework/preact/reference/functions/useQueryErrorResetBoundary.md b/docs/framework/preact/reference/functions/useQueryErrorResetBoundary.md index 15ec961a2b7..bf96a7d86f0 100644 --- a/docs/framework/preact/reference/functions/useQueryErrorResetBoundary.md +++ b/docs/framework/preact/reference/functions/useQueryErrorResetBoundary.md @@ -7,7 +7,7 @@ title: useQueryErrorResetBoundary function useQueryErrorResetBoundary(): QueryErrorResetBoundaryValue; ``` -Defined in: [preact-query/src/QueryErrorResetBoundary.tsx:85](https://github.com/TanStack/query/blob/main/packages/preact-query/src/QueryErrorResetBoundary.tsx#L85) +Defined in: [packages/preact-query/src/QueryErrorResetBoundary.tsx:85](https://github.com/TanStack/query/blob/main/packages/preact-query/src/QueryErrorResetBoundary.tsx#L85) This hook will reset any query errors within the closest `QueryErrorResetBoundary`. If there is no boundary defined it will reset them globally. diff --git a/docs/framework/preact/reference/functions/useSuspenseInfiniteQuery.md b/docs/framework/preact/reference/functions/useSuspenseInfiniteQuery.md index 2cde233cc01..2e198fe020b 100644 --- a/docs/framework/preact/reference/functions/useSuspenseInfiniteQuery.md +++ b/docs/framework/preact/reference/functions/useSuspenseInfiniteQuery.md @@ -7,7 +7,7 @@ title: useSuspenseInfiniteQuery function useSuspenseInfiniteQuery(options, queryClient?): UseSuspenseInfiniteQueryResult; ``` -Defined in: [preact-query/src/useSuspenseInfiniteQuery.ts:124](https://github.com/TanStack/query/blob/main/packages/preact-query/src/useSuspenseInfiniteQuery.ts#L124) +Defined in: [packages/preact-query/src/useSuspenseInfiniteQuery.ts:124](https://github.com/TanStack/query/blob/main/packages/preact-query/src/useSuspenseInfiniteQuery.ts#L124) The options for `useSuspenseInfiniteQuery` are the same as for `useInfiniteQuery`, except for `throwOnError`, `enabled`, and `placeholderData`. @@ -26,7 +26,7 @@ Caveat: cancellation does not work. ### TData -`TData` = `InfiniteData`\<`TQueryFnData`, `unknown`\> +`TData` = [`InfiniteData`](../interfaces/InfiniteData.md)\<`TQueryFnData`, `unknown`\> ### TQueryKey @@ -46,7 +46,7 @@ The [UseSuspenseInfiniteQueryOptions](../interfaces/UseSuspenseInfiniteQueryOpti ### queryClient? -`QueryClient` +[`QueryClient`](../classes/QueryClient.md) Use this to use a custom `QueryClient`. Otherwise, the one from the nearest context will be used. diff --git a/docs/framework/preact/reference/functions/useSuspenseQueries.md b/docs/framework/preact/reference/functions/useSuspenseQueries.md index 5eff3f39eb5..d9a4ce39046 100644 --- a/docs/framework/preact/reference/functions/useSuspenseQueries.md +++ b/docs/framework/preact/reference/functions/useSuspenseQueries.md @@ -9,7 +9,7 @@ title: useSuspenseQueries function useSuspenseQueries(options, queryClient?): TCombinedResult; ``` -Defined in: [preact-query/src/useSuspenseQueries.ts:409](https://github.com/TanStack/query/blob/main/packages/preact-query/src/useSuspenseQueries.ts#L409) +Defined in: [packages/preact-query/src/useSuspenseQueries.ts:409](https://github.com/TanStack/query/blob/main/packages/preact-query/src/useSuspenseQueries.ts#L409) The options for `useSuspenseQueries` are the same as for `useQueries`, except that the top-level `subscribed` option isn't supported, and each `query` can't have `throwOnError`, `enabled`, or `placeholderData`. @@ -46,7 +46,7 @@ An array with query option objects identical to `useSuspenseQuery`. #### queryClient? -`QueryClient` +[`QueryClient`](../classes/QueryClient.md) Use this to provide a custom `QueryClient`. Otherwise, the one from the nearest context will be used. @@ -279,7 +279,7 @@ function ErrorBoundary({ function useSuspenseQueries(options, queryClient?): TCombinedResult; ``` -Defined in: [preact-query/src/useSuspenseQueries.ts:589](https://github.com/TanStack/query/blob/main/packages/preact-query/src/useSuspenseQueries.ts#L589) +Defined in: [packages/preact-query/src/useSuspenseQueries.ts:589](https://github.com/TanStack/query/blob/main/packages/preact-query/src/useSuspenseQueries.ts#L589) The options for `useSuspenseQueries` are the same as for `useQueries`, except that the top-level `subscribed` option isn't supported, and each `query` can't have `throwOnError`, `enabled`, or `placeholderData`. @@ -315,7 +315,7 @@ An array with query option objects identical to `useSuspenseQuery`. #### queryClient? -`QueryClient` +[`QueryClient`](../classes/QueryClient.md) Use this to provide a custom `QueryClient`. Otherwise, the one from the nearest context will be used. diff --git a/docs/framework/preact/reference/functions/useSuspenseQuery.md b/docs/framework/preact/reference/functions/useSuspenseQuery.md index 29f892a1656..2cb0ebb317c 100644 --- a/docs/framework/preact/reference/functions/useSuspenseQuery.md +++ b/docs/framework/preact/reference/functions/useSuspenseQuery.md @@ -7,7 +7,7 @@ title: useSuspenseQuery function useSuspenseQuery(options, queryClient?): UseSuspenseQueryResult; ``` -Defined in: [preact-query/src/useSuspenseQuery.ts:95](https://github.com/TanStack/query/blob/main/packages/preact-query/src/useSuspenseQuery.ts#L95) +Defined in: [packages/preact-query/src/useSuspenseQuery.ts:95](https://github.com/TanStack/query/blob/main/packages/preact-query/src/useSuspenseQuery.ts#L95) The options for `useSuspenseQuery` are the same as for `useQuery`, except for `throwOnError`, `enabled`, and `placeholderData`. @@ -42,7 +42,7 @@ The [UseSuspenseQueryOptions](../interfaces/UseSuspenseQueryOptions.md) to use ### queryClient? -`QueryClient` +[`QueryClient`](../classes/QueryClient.md) Use this to use a custom `QueryClient`. Otherwise, the one from the nearest context will be used. diff --git a/docs/framework/preact/reference/index.md b/docs/framework/preact/reference/index.md index 4a8bb8f6a28..2ca0ffb9238 100644 --- a/docs/framework/preact/reference/index.md +++ b/docs/framework/preact/reference/index.md @@ -3,10 +3,81 @@ id: "@tanstack/preact-query" title: "@tanstack/preact-query" --- +## Classes + +- [CancelledError](classes/CancelledError.md) +- [InfiniteQueryObserver](classes/InfiniteQueryObserver.md) +- [Mutation](classes/Mutation.md) +- [MutationCache](classes/MutationCache.md) +- [MutationObserver](classes/MutationObserver.md) +- [QueriesObserver](classes/QueriesObserver.md) +- [Query](classes/Query.md) +- [QueryCache](classes/QueryCache.md) +- [QueryClient](classes/QueryClient.md) +- [QueryObserver](classes/QueryObserver.md) + ## Interfaces +- [CancelOptions](interfaces/CancelOptions.md) +- [DefaultOptions](interfaces/DefaultOptions.md) +- [DehydratedState](interfaces/DehydratedState.md) +- [DehydrateOptions](interfaces/DehydrateOptions.md) +- [~~EnsureQueryDataOptions~~](interfaces/EnsureQueryDataOptions.md) +- [FetchNextPageOptions](interfaces/FetchNextPageOptions.md) +- [FetchPreviousPageOptions](interfaces/FetchPreviousPageOptions.md) +- [~~FetchQueryOptions~~](interfaces/FetchQueryOptions.md) +- [FocusManager](interfaces/FocusManager.md) +- [HydrateOptions](interfaces/HydrateOptions.md) - [HydrationBoundaryProps](interfaces/HydrationBoundaryProps.md) +- [InfiniteData](interfaces/InfiniteData.md) +- [InfiniteQueryObserverBaseResult](interfaces/InfiniteQueryObserverBaseResult.md) +- [InfiniteQueryObserverLoadingErrorResult](interfaces/InfiniteQueryObserverLoadingErrorResult.md) +- [InfiniteQueryObserverLoadingResult](interfaces/InfiniteQueryObserverLoadingResult.md) +- [InfiniteQueryObserverOptions](interfaces/InfiniteQueryObserverOptions.md) +- [InfiniteQueryObserverPendingResult](interfaces/InfiniteQueryObserverPendingResult.md) +- [InfiniteQueryObserverPlaceholderResult](interfaces/InfiniteQueryObserverPlaceholderResult.md) +- [InfiniteQueryObserverRefetchErrorResult](interfaces/InfiniteQueryObserverRefetchErrorResult.md) +- [InfiniteQueryObserverSuccessResult](interfaces/InfiniteQueryObserverSuccessResult.md) +- [InfiniteQueryPageParamsOptions](interfaces/InfiniteQueryPageParamsOptions.md) +- [InitialPageParam](interfaces/InitialPageParam.md) +- [InvalidateOptions](interfaces/InvalidateOptions.md) +- [InvalidateQueryFilters](interfaces/InvalidateQueryFilters.md) +- [MutateOptions](interfaces/MutateOptions.md) +- [MutationCacheConfig](interfaces/MutationCacheConfig.md) +- [MutationFilters](interfaces/MutationFilters.md) +- [MutationObserverBaseResult](interfaces/MutationObserverBaseResult.md) +- [MutationObserverErrorResult](interfaces/MutationObserverErrorResult.md) +- [MutationObserverIdleResult](interfaces/MutationObserverIdleResult.md) +- [MutationObserverLoadingResult](interfaces/MutationObserverLoadingResult.md) +- [MutationObserverOptions](interfaces/MutationObserverOptions.md) +- [MutationObserverSuccessResult](interfaces/MutationObserverSuccessResult.md) +- [MutationOptions](interfaces/MutationOptions.md) +- [MutationState](interfaces/MutationState.md) +- [NotifyEvent](interfaces/NotifyEvent.md) +- [OnlineManager](interfaces/OnlineManager.md) +- [QueriesObserverOptions](interfaces/QueriesObserverOptions.md) +- [QueryCacheConfig](interfaces/QueryCacheConfig.md) +- [QueryClientConfig](interfaces/QueryClientConfig.md) - [QueryErrorResetBoundaryProps](interfaces/QueryErrorResetBoundaryProps.md) +- [QueryExecuteOptions](interfaces/QueryExecuteOptions.md) +- [QueryFilters](interfaces/QueryFilters.md) +- [QueryObserverBaseResult](interfaces/QueryObserverBaseResult.md) +- [QueryObserverLoadingErrorResult](interfaces/QueryObserverLoadingErrorResult.md) +- [QueryObserverLoadingResult](interfaces/QueryObserverLoadingResult.md) +- [QueryObserverOptions](interfaces/QueryObserverOptions.md) +- [QueryObserverPendingResult](interfaces/QueryObserverPendingResult.md) +- [QueryObserverPlaceholderResult](interfaces/QueryObserverPlaceholderResult.md) +- [QueryObserverRefetchErrorResult](interfaces/QueryObserverRefetchErrorResult.md) +- [QueryObserverSuccessResult](interfaces/QueryObserverSuccessResult.md) +- [QueryOptions](interfaces/QueryOptions.md) +- [QueryState](interfaces/QueryState.md) +- [RefetchOptions](interfaces/RefetchOptions.md) +- [RefetchQueryFilters](interfaces/RefetchQueryFilters.md) +- [Register](interfaces/Register.md) +- [ResetOptions](interfaces/ResetOptions.md) +- [ResultOptions](interfaces/ResultOptions.md) +- [SetDataOptions](interfaces/SetDataOptions.md) +- [TimeoutManager](interfaces/TimeoutManager.md) - [UseBaseQueryOptions](interfaces/UseBaseQueryOptions.md) - [UseInfiniteQueryOptions](interfaces/UseInfiniteQueryOptions.md) - [UseMutationOptions](interfaces/UseMutationOptions.md) @@ -16,29 +87,87 @@ title: "@tanstack/preact-query" ## Type Aliases +- [AnyDataTag](type-aliases/AnyDataTag.md) - [AnyUseBaseQueryOptions](type-aliases/AnyUseBaseQueryOptions.md) - [AnyUseInfiniteQueryOptions](type-aliases/AnyUseInfiniteQueryOptions.md) - [AnyUseMutationOptions](type-aliases/AnyUseMutationOptions.md) - [AnyUseQueryOptions](type-aliases/AnyUseQueryOptions.md) - [AnyUseSuspenseInfiniteQueryOptions](type-aliases/AnyUseSuspenseInfiniteQueryOptions.md) - [AnyUseSuspenseQueryOptions](type-aliases/AnyUseSuspenseQueryOptions.md) +- [DataTag](type-aliases/DataTag.md) +- [dataTagErrorSymbol](type-aliases/dataTagErrorSymbol.md) +- [dataTagSymbol](type-aliases/dataTagSymbol.md) +- [DefaultedInfiniteQueryObserverOptions](type-aliases/DefaultedInfiniteQueryObserverOptions.md) +- [DefaultedQueryObserverOptions](type-aliases/DefaultedQueryObserverOptions.md) +- [DefaultError](type-aliases/DefaultError.md) +- [DefinedInfiniteQueryObserverResult](type-aliases/DefinedInfiniteQueryObserverResult.md) - [DefinedInitialDataInfiniteOptions](type-aliases/DefinedInitialDataInfiniteOptions.md) - [DefinedInitialDataOptions](type-aliases/DefinedInitialDataOptions.md) +- [DefinedQueryObserverResult](type-aliases/DefinedQueryObserverResult.md) - [DefinedUseInfiniteQueryResult](type-aliases/DefinedUseInfiniteQueryResult.md) - [DefinedUseQueryResult](type-aliases/DefinedUseQueryResult.md) +- [DistributiveOmit](type-aliases/DistributiveOmit.md) +- [~~EnsureInfiniteQueryDataOptions~~](type-aliases/EnsureInfiniteQueryDataOptions.md) +- [~~FetchInfiniteQueryOptions~~](type-aliases/FetchInfiniteQueryOptions.md) +- [FetchStatus](type-aliases/FetchStatus.md) +- [GetNextPageParamFunction](type-aliases/GetNextPageParamFunction.md) +- [GetPreviousPageParamFunction](type-aliases/GetPreviousPageParamFunction.md) +- [InferDataFromTag](type-aliases/InferDataFromTag.md) +- [InferErrorFromTag](type-aliases/InferErrorFromTag.md) +- [InfiniteQueryExecuteOptions](type-aliases/InfiniteQueryExecuteOptions.md) +- [InfiniteQueryObserverResult](type-aliases/InfiniteQueryObserverResult.md) +- [InitialDataFunction](type-aliases/InitialDataFunction.md) +- [ManagedTimerId](type-aliases/ManagedTimerId.md) +- [MutateFunction](type-aliases/MutateFunction.md) +- [MutateFunctionRest](type-aliases/MutateFunctionRest.md) +- [MutationCacheNotifyEvent](type-aliases/MutationCacheNotifyEvent.md) +- [MutationFunction](type-aliases/MutationFunction.md) +- [MutationFunctionContext](type-aliases/MutationFunctionContext.md) +- [MutationKey](type-aliases/MutationKey.md) +- [MutationMeta](type-aliases/MutationMeta.md) +- [MutationObserverResult](type-aliases/MutationObserverResult.md) +- [MutationScope](type-aliases/MutationScope.md) +- [MutationStatus](type-aliases/MutationStatus.md) +- [NetworkMode](type-aliases/NetworkMode.md) +- [NonUndefinedGuard](type-aliases/NonUndefinedGuard.md) +- [NotifyEventType](type-aliases/NotifyEventType.md) +- [NotifyOnChangeProps](type-aliases/NotifyOnChangeProps.md) +- [OmitKeyof](type-aliases/OmitKeyof.md) +- [Override](type-aliases/Override.md) +- [PlaceholderDataFunction](type-aliases/PlaceholderDataFunction.md) - [QueriesOptions](type-aliases/QueriesOptions.md) +- [QueriesPlaceholderDataFunction](type-aliases/QueriesPlaceholderDataFunction.md) - [QueriesResults](type-aliases/QueriesResults.md) +- [QueryBooleanOption](type-aliases/QueryBooleanOption.md) +- [QueryCacheNotifyEvent](type-aliases/QueryCacheNotifyEvent.md) - [QueryClientProviderProps](type-aliases/QueryClientProviderProps.md) - [QueryErrorClearResetFunction](type-aliases/QueryErrorClearResetFunction.md) - [QueryErrorIsResetFunction](type-aliases/QueryErrorIsResetFunction.md) - [QueryErrorResetBoundaryFunction](type-aliases/QueryErrorResetBoundaryFunction.md) - [QueryErrorResetFunction](type-aliases/QueryErrorResetFunction.md) +- [QueryFunction](type-aliases/QueryFunction.md) +- [QueryFunctionContext](type-aliases/QueryFunctionContext.md) +- [QueryKey](type-aliases/QueryKey.md) +- [QueryKeyHashFunction](type-aliases/QueryKeyHashFunction.md) +- [QueryKeyWithDataTag](type-aliases/QueryKeyWithDataTag.md) +- [QueryMeta](type-aliases/QueryMeta.md) +- [QueryObserverResult](type-aliases/QueryObserverResult.md) +- [QueryPersister](type-aliases/QueryPersister.md) +- [QueryStatus](type-aliases/QueryStatus.md) +- [SkipToken](type-aliases/SkipToken.md) +- [StaleTime](type-aliases/StaleTime.md) +- [StaleTimeFunction](type-aliases/StaleTimeFunction.md) - [SuspenseQueriesOptions](type-aliases/SuspenseQueriesOptions.md) - [SuspenseQueriesResults](type-aliases/SuspenseQueriesResults.md) +- [ThrowOnError](type-aliases/ThrowOnError.md) +- [TimeoutCallback](type-aliases/TimeoutCallback.md) +- [TimeoutProvider](type-aliases/TimeoutProvider.md) - [UndefinedInitialDataInfiniteOptions](type-aliases/UndefinedInitialDataInfiniteOptions.md) - [UndefinedInitialDataOptions](type-aliases/UndefinedInitialDataOptions.md) +- [UnsetMarker](type-aliases/UnsetMarker.md) - [UnusedSkipTokenInfiniteOptions](type-aliases/UnusedSkipTokenInfiniteOptions.md) - [UnusedSkipTokenOptions](type-aliases/UnusedSkipTokenOptions.md) +- [Updater](type-aliases/Updater.md) - [UseBaseMutationResult](type-aliases/UseBaseMutationResult.md) - [UseBaseQueryResult](type-aliases/UseBaseQueryResult.md) - [UseInfiniteQueryResult](type-aliases/UseInfiniteQueryResult.md) @@ -50,20 +179,47 @@ title: "@tanstack/preact-query" - [UseQueryResult](type-aliases/UseQueryResult.md) - [UseSuspenseInfiniteQueryResult](type-aliases/UseSuspenseInfiniteQueryResult.md) - [UseSuspenseQueryResult](type-aliases/UseSuspenseQueryResult.md) +- [WithRequired](type-aliases/WithRequired.md) ## Variables +- [dataTagErrorSymbol](variables/dataTagErrorSymbol.md) +- [dataTagSymbol](variables/dataTagSymbol.md) +- [defaultScheduler](variables/defaultScheduler.md) +- [environmentManager](variables/environmentManager.md) +- [focusManager](variables/focusManager.md) - [IsRestoringProvider](variables/IsRestoringProvider.md) +- [~~isServer~~](variables/isServer.md) +- [notifyManager](variables/notifyManager.md) +- [onlineManager](variables/onlineManager.md) - [QueryClientContext](variables/QueryClientContext.md) +- [skipToken](variables/skipToken.md) +- [timeoutManager](variables/timeoutManager.md) +- [unsetMarker](variables/unsetMarker.md) ## Functions +- [defaultShouldDehydrateMutation](functions/defaultShouldDehydrateMutation.md) +- [defaultShouldDehydrateQuery](functions/defaultShouldDehydrateQuery.md) +- [dehydrate](functions/dehydrate.md) +- [dehydrateQuery](functions/dehydrateQuery.md) +- [experimental\_streamedQuery](functions/experimental_streamedQuery.md) +- [hashKey](functions/hashKey.md) +- [hydrate](functions/hydrate.md) - [HydrationBoundary](functions/HydrationBoundary.md) - [infiniteQueryOptions](functions/infiniteQueryOptions.md) +- [~~isCancelledError~~](functions/isCancelledError.md) +- [keepPreviousData](functions/keepPreviousData.md) +- [matchMutation](functions/matchMutation.md) +- [matchQuery](functions/matchQuery.md) - [mutationOptions](functions/mutationOptions.md) +- [noop](functions/noop.md) +- [partialMatchKey](functions/partialMatchKey.md) - [QueryClientProvider](functions/QueryClientProvider.md) - [QueryErrorResetBoundary](functions/QueryErrorResetBoundary.md) - [queryOptions](functions/queryOptions.md) +- [replaceEqualDeep](functions/replaceEqualDeep.md) +- [shouldThrowError](functions/shouldThrowError.md) - [useInfiniteQuery](functions/useInfiniteQuery.md) - [useIsFetching](functions/useIsFetching.md) - [useIsMutating](functions/useIsMutating.md) diff --git a/docs/framework/preact/reference/interfaces/CancelOptions.md b/docs/framework/preact/reference/interfaces/CancelOptions.md new file mode 100644 index 00000000000..b7464c48e50 --- /dev/null +++ b/docs/framework/preact/reference/interfaces/CancelOptions.md @@ -0,0 +1,26 @@ +--- +id: CancelOptions +title: CancelOptions +--- + +Defined in: [packages/query-core/src/types.ts:1521](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1521) + +## Properties + +### revert? + +```ts +optional revert: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1522](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1522) + +*** + +### silent? + +```ts +optional silent: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1523](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1523) diff --git a/docs/framework/preact/reference/interfaces/DefaultOptions.md b/docs/framework/preact/reference/interfaces/DefaultOptions.md new file mode 100644 index 00000000000..e45a56f075f --- /dev/null +++ b/docs/framework/preact/reference/interfaces/DefaultOptions.md @@ -0,0 +1,84 @@ +--- +id: DefaultOptions +title: DefaultOptions +--- + +Defined in: [packages/query-core/src/types.ts:1507](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1507) + +## Type Parameters + +### TError + +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) + +## Properties + +### dehydrate? + +```ts +optional dehydrate: DehydrateOptions; +``` + +Defined in: [packages/query-core/src/types.ts:1518](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1518) + +Default options used when dehydrating the client's caches; see [DehydrateOptions](DehydrateOptions.md). + +*** + +### hydrate? + +```ts +optional hydrate: object; +``` + +Defined in: [packages/query-core/src/types.ts:1516](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1516) + +Default options used when hydrating queries; see [HydrateOptions](HydrateOptions.md). + +#### deserializeData? + +```ts +optional deserializeData: TransformerFn; +``` + +Transforms a query's `data` after it is read from the dehydrated state, reversing `serializeData`. + +#### mutations? + +```ts +optional mutations: MutationOptions; +``` + +Default options merged into every mutation restored from the dehydrated state. + +#### queries? + +```ts +optional queries: QueryOptions; +``` + +Default options merged into every query restored from the dehydrated state. + +*** + +### mutations? + +```ts +optional mutations: MutationObserverOptions; +``` + +Defined in: [packages/query-core/src/types.ts:1514](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1514) + +Default options applied to every mutation, unless overridden per-mutation. + +*** + +### queries? + +```ts +optional queries: OmitKeyof, "queryKey" | "suspense", "strictly">; +``` + +Defined in: [packages/query-core/src/types.ts:1509](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1509) + +Default options applied to every query, unless overridden per-query. diff --git a/docs/framework/preact/reference/interfaces/DehydrateOptions.md b/docs/framework/preact/reference/interfaces/DehydrateOptions.md new file mode 100644 index 00000000000..e862ae88b43 --- /dev/null +++ b/docs/framework/preact/reference/interfaces/DehydrateOptions.md @@ -0,0 +1,89 @@ +--- +id: DehydrateOptions +title: DehydrateOptions +--- + +Defined in: [packages/query-core/src/hydration.ts:42](https://github.com/TanStack/query/blob/main/packages/query-core/src/hydration.ts#L42) + +Options for `dehydrate`, controlling which queries/mutations are included in the resulting `DehydratedState` and +how their data/errors are transformed before being serialized (e.g. for embedding in server-rendered markup). + +## Properties + +### serializeData? + +```ts +optional serializeData: TransformerFn; +``` + +Defined in: [packages/query-core/src/hydration.ts:44](https://github.com/TanStack/query/blob/main/packages/query-core/src/hydration.ts#L44) + +Transforms a query's `data` before it is dehydrated. Useful for non-JSON-serializable data. + +*** + +### shouldDehydrateMutation()? + +```ts +optional shouldDehydrateMutation: (mutation) => boolean; +``` + +Defined in: [packages/query-core/src/hydration.ts:46](https://github.com/TanStack/query/blob/main/packages/query-core/src/hydration.ts#L46) + +Predicate to decide whether a given `Mutation` should be dehydrated. Defaults to `defaultShouldDehydrateMutation`. + +#### Parameters + +##### mutation + +[`Mutation`](../classes/Mutation.md) + +#### Returns + +`boolean` + +*** + +### shouldDehydrateQuery()? + +```ts +optional shouldDehydrateQuery: (query) => boolean; +``` + +Defined in: [packages/query-core/src/hydration.ts:48](https://github.com/TanStack/query/blob/main/packages/query-core/src/hydration.ts#L48) + +Predicate to decide whether a given `Query` should be dehydrated. Defaults to `defaultShouldDehydrateQuery`. + +#### Parameters + +##### query + +[`Query`](../classes/Query.md) + +#### Returns + +`boolean` + +*** + +### shouldRedactErrors()? + +```ts +optional shouldRedactErrors: (error) => boolean; +``` + +Defined in: [packages/query-core/src/hydration.ts:54](https://github.com/TanStack/query/blob/main/packages/query-core/src/hydration.ts#L54) + +Predicate to decide whether a query's error should be redacted before dehydration. Errors are redacted +(replaced with a generic `Error('redacted')`) unless this function is provided and returns `false` for the +given error, in which case the original error is kept. + +#### Parameters + +##### error + +`unknown` + +#### Returns + +`boolean` diff --git a/docs/framework/preact/reference/interfaces/DehydratedState.md b/docs/framework/preact/reference/interfaces/DehydratedState.md new file mode 100644 index 00000000000..be034c9e8fd --- /dev/null +++ b/docs/framework/preact/reference/interfaces/DehydratedState.md @@ -0,0 +1,30 @@ +--- +id: DehydratedState +title: DehydratedState +--- + +Defined in: [packages/query-core/src/hydration.ts:94](https://github.com/TanStack/query/blob/main/packages/query-core/src/hydration.ts#L94) + +A serializable snapshot of a `QueryClient`'s cache, as produced by `dehydrate` and consumed by `hydrate`. Typically +transported from server to client (e.g. embedded in server-rendered markup) to seed the client's cache with data +that has already been fetched, avoiding a redundant fetch on the client. + +## Properties + +### mutations + +```ts +mutations: DehydratedMutation[]; +``` + +Defined in: [packages/query-core/src/hydration.ts:95](https://github.com/TanStack/query/blob/main/packages/query-core/src/hydration.ts#L95) + +*** + +### queries + +```ts +queries: DehydratedQuery[]; +``` + +Defined in: [packages/query-core/src/hydration.ts:96](https://github.com/TanStack/query/blob/main/packages/query-core/src/hydration.ts#L96) diff --git a/docs/framework/preact/reference/interfaces/EnsureQueryDataOptions.md b/docs/framework/preact/reference/interfaces/EnsureQueryDataOptions.md new file mode 100644 index 00000000000..a67082af57e --- /dev/null +++ b/docs/framework/preact/reference/interfaces/EnsureQueryDataOptions.md @@ -0,0 +1,350 @@ +--- +id: EnsureQueryDataOptions +title: EnsureQueryDataOptions +--- + +Defined in: [packages/query-core/src/types.ts:614](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L614) + +## Deprecated + +## Extends + +- [`FetchQueryOptions`](FetchQueryOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`, `TPageParam`\> + +## Type Parameters + +### TQueryFnData + +`TQueryFnData` = `unknown` + +### TError + +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) + +### TData + +`TData` = `TQueryFnData` + +### TQueryKey + +`TQueryKey` *extends* [`QueryKey`](../type-aliases/QueryKey.md) = [`QueryKey`](../type-aliases/QueryKey.md) + +### TPageParam + +`TPageParam` = `never` + +## Properties + +### ~~gcTime?~~ + +```ts +optional gcTime: number; +``` + +Defined in: [packages/query-core/src/types.ts:277](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L277) + +The time in milliseconds that unused/inactive cache data remains in memory. +When a query's cache becomes unused or inactive, that cache data will be garbage collected after this duration. +When different garbage collection times are specified, the longest one will be used. +Setting it to `Infinity` will disable garbage collection. + +Defaults to `5 * 60 * 1000` (5 minutes), or `Infinity` during SSR. + +Note: the maximum allowed time is about 24 days, imposed by `setTimeout`'s 32-bit signed integer delay — see +`timeoutManager.setTimeoutProvider` for a workaround. + +#### Inherited from + +[`FetchQueryOptions`](FetchQueryOptions.md).[`gcTime`](FetchQueryOptions.md#gctime) + +*** + +### ~~initialData?~~ + +```ts +optional initialData: + | TData +| InitialDataFunction; +``` + +Defined in: [packages/query-core/src/types.ts:317](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L317) + +If set, this value will be used as the initial data for the query cache (as long as the query hasn't been +created or cached yet). +If set to a function, the function will be called **once** during the shared/root query initialization, and be +expected to synchronously return the initial data. +Initial data is considered stale by default unless a `staleTime` has been set. +`initialData` **is persisted** to the cache. + +#### Inherited from + +[`FetchQueryOptions`](FetchQueryOptions.md).[`initialData`](FetchQueryOptions.md#initialdata) + +*** + +### ~~initialDataUpdatedAt?~~ + +```ts +optional initialDataUpdatedAt: number | () => number | undefined; +``` + +Defined in: [packages/query-core/src/types.ts:321](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L321) + +If set, this value will be used as the time (in milliseconds) of when the `initialData` itself was last updated. + +#### Inherited from + +[`FetchQueryOptions`](FetchQueryOptions.md).[`initialDataUpdatedAt`](FetchQueryOptions.md#initialdataupdatedat) + +*** + +### ~~initialPageParam?~~ + +```ts +optional initialPageParam: undefined; +``` + +Defined in: [packages/query-core/src/types.ts:605](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L605) + +#### Inherited from + +[`FetchQueryOptions`](FetchQueryOptions.md).[`initialPageParam`](FetchQueryOptions.md#initialpageparam) + +*** + +### ~~maxPages?~~ + +```ts +optional maxPages: number; +``` + +Defined in: [packages/query-core/src/types.ts:345](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L345) + +Maximum number of pages to store in the data of an infinite query. + +#### Inherited from + +[`FetchQueryOptions`](FetchQueryOptions.md).[`maxPages`](FetchQueryOptions.md#maxpages) + +*** + +### ~~meta?~~ + +```ts +optional meta: Record; +``` + +Defined in: [packages/query-core/src/types.ts:341](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L341) + +Additional payload to be stored on each query. +Use this property to pass information that can be used in other places. + +#### Inherited from + +[`FetchQueryOptions`](FetchQueryOptions.md).[`meta`](FetchQueryOptions.md#meta) + +*** + +### ~~networkMode?~~ + +```ts +optional networkMode: NetworkMode; +``` + +Defined in: [packages/query-core/src/types.ts:265](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L265) + +Controls whether a query is allowed to run based on the current network connectivity. + +Defaults to `'online'`. + +#### See + +[Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. + +#### Inherited from + +[`FetchQueryOptions`](FetchQueryOptions.md).[`networkMode`](FetchQueryOptions.md#networkmode) + +*** + +### ~~persister?~~ + +```ts +optional persister: QueryPersister, TPageParam>; +``` + +Defined in: [packages/query-core/src/types.ts:290](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L290) + +This option can be used to persist the result of a query to an external storage, bypassing the need to actually +call the `queryFn`. Useful for persisting a query's data across e.g. server/client boundaries. + +#### Inherited from + +[`FetchQueryOptions`](FetchQueryOptions.md).[`persister`](FetchQueryOptions.md#persister) + +*** + +### ~~queryFn?~~ + +```ts +optional queryFn: + | typeof skipToken +| QueryFunction; +``` + +Defined in: [packages/query-core/src/types.ts:285](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L285) + +The function that the query will use to request data. +Required, unless a default query function has been set via `queryClient.setQueryDefaults` or +`queryClient.setDefaultOptions`. +Receives a [QueryFunctionContext](../type-aliases/QueryFunctionContext.md). +Must return a promise that will either resolve data or throw an error. The data cannot be `undefined`. + +#### Inherited from + +[`FetchQueryOptions`](FetchQueryOptions.md).[`queryFn`](FetchQueryOptions.md#queryfn) + +*** + +### ~~queryHash?~~ + +```ts +optional queryHash: string; +``` + +Defined in: [packages/query-core/src/types.ts:295](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L295) + +The hashed form of `queryKey`, computed with `queryKeyHashFn` (or the default hashing function otherwise). Used +as the actual cache key internally. + +#### Inherited from + +[`FetchQueryOptions`](FetchQueryOptions.md).[`queryHash`](FetchQueryOptions.md#queryhash) + +*** + +### ~~queryKey~~ + +```ts +queryKey: TQueryKey & object; +``` + +Defined in: [packages/query-core/src/types.ts:304](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L304) + +The query key to use for this query. + +The query key will be hashed into a stable hash. See [Query Keys](https://tanstack.com/query/latest/docs/framework/react/guides/query-keys) +for more information. + +The query will automatically update when this key changes (as long as `enabled` is not set to `false`). + +#### Inherited from + +[`FetchQueryOptions`](FetchQueryOptions.md).[`queryKey`](FetchQueryOptions.md#querykey) + +*** + +### ~~queryKeyHashFn?~~ + +```ts +optional queryKeyHashFn: QueryKeyHashFunction; +``` + +Defined in: [packages/query-core/src/types.ts:308](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L308) + +If specified, this function is used to hash the `queryKey` to a string. + +#### Inherited from + +[`FetchQueryOptions`](FetchQueryOptions.md).[`queryKeyHashFn`](FetchQueryOptions.md#querykeyhashfn) + +*** + +### ~~retry?~~ + +```ts +optional retry: RetryValue; +``` + +Defined in: [packages/query-core/src/types.ts:246](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L246) + +If `false`, failed queries will not retry by default. +If `true`, failed queries will retry infinitely. +If set to an integer number, e.g. 3, failed queries will retry until the failed query count meets that number. +If set to a function `(failureCount, error) => boolean` failed queries will retry until the function returns false. + +Defaults to `3` on the client and `0` on the server. + +#### Inherited from + +[`FetchQueryOptions`](FetchQueryOptions.md).[`retry`](FetchQueryOptions.md#retry) + +*** + +### ~~retryDelay?~~ + +```ts +optional retryDelay: RetryDelayValue; +``` + +Defined in: [packages/query-core/src/types.ts:258](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L258) + +This function receives a `retryAttempt` integer and the actual Error and returns the delay to apply before the +next attempt in milliseconds. + +A function like `attempt => Math.min(attempt > 1 ? 2 ** attempt * 1000 : 1000, 30 * 1000)` applies exponential +backoff. + +A function like `attempt => attempt * 1000` applies linear backoff. + +Defaults to a function that applies exponential backoff, capped at 30 seconds. + +#### Inherited from + +[`FetchQueryOptions`](FetchQueryOptions.md).[`retryDelay`](FetchQueryOptions.md#retrydelay) + +*** + +### ~~revalidateIfStale?~~ + +```ts +optional revalidateIfStale: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:627](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L627) + +*** + +### ~~staleTime?~~ + +```ts +optional staleTime: StaleTimeFunction; +``` + +Defined in: [packages/query-core/src/types.ts:610](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L610) + +The time in milliseconds after data is considered stale. +If the data is fresh it will be returned from the cache. + +#### Inherited from + +[`FetchQueryOptions`](FetchQueryOptions.md).[`staleTime`](FetchQueryOptions.md#staletime) + +*** + +### ~~structuralSharing?~~ + +```ts +optional structuralSharing: boolean | (oldData, newData) => unknown; +``` + +Defined in: [packages/query-core/src/types.ts:330](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L330) + +Set this to `false` to disable structural sharing between query results. +Set this to a function which accepts the old and new data and returns resolved data of the same type to implement custom structural sharing logic. + +Defaults to `true`. + +#### Inherited from + +[`FetchQueryOptions`](FetchQueryOptions.md).[`structuralSharing`](FetchQueryOptions.md#structuralsharing) diff --git a/docs/framework/preact/reference/interfaces/FetchNextPageOptions.md b/docs/framework/preact/reference/interfaces/FetchNextPageOptions.md new file mode 100644 index 00000000000..b79cdbe19b3 --- /dev/null +++ b/docs/framework/preact/reference/interfaces/FetchNextPageOptions.md @@ -0,0 +1,46 @@ +--- +id: FetchNextPageOptions +title: FetchNextPageOptions +--- + +Defined in: [packages/query-core/src/types.ts:737](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L737) + +## Extends + +- [`ResultOptions`](ResultOptions.md) + +## Properties + +### cancelRefetch? + +```ts +optional cancelRefetch: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:746](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L746) + +If set to `true`, calling `fetchNextPage` repeatedly will invoke `queryFn` every time, +whether the previous invocation has resolved or not. Also, the result from previous invocations will be ignored. + +If set to `false`, calling `fetchNextPage` repeatedly won't have any effect until the first invocation has resolved. + +Defaults to `true`. + +*** + +### throwOnError? + +```ts +optional throwOnError: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:701](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L701) + +If set to `true`, the method throws if any of the underlying query refetch tasks fail. + +Defaults to `false`, in which case failed refetches are swallowed and not surfaced to the +caller. + +#### Inherited from + +[`ResultOptions`](ResultOptions.md).[`throwOnError`](ResultOptions.md#throwonerror) diff --git a/docs/framework/preact/reference/interfaces/FetchPreviousPageOptions.md b/docs/framework/preact/reference/interfaces/FetchPreviousPageOptions.md new file mode 100644 index 00000000000..fd5a08767b6 --- /dev/null +++ b/docs/framework/preact/reference/interfaces/FetchPreviousPageOptions.md @@ -0,0 +1,46 @@ +--- +id: FetchPreviousPageOptions +title: FetchPreviousPageOptions +--- + +Defined in: [packages/query-core/src/types.ts:749](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L749) + +## Extends + +- [`ResultOptions`](ResultOptions.md) + +## Properties + +### cancelRefetch? + +```ts +optional cancelRefetch: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:758](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L758) + +If set to `true`, calling `fetchPreviousPage` repeatedly will invoke `queryFn` every time, +whether the previous invocation has resolved or not. Also, the result from previous invocations will be ignored. + +If set to `false`, calling `fetchPreviousPage` repeatedly won't have any effect until the first invocation has resolved. + +Defaults to `true`. + +*** + +### throwOnError? + +```ts +optional throwOnError: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:701](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L701) + +If set to `true`, the method throws if any of the underlying query refetch tasks fail. + +Defaults to `false`, in which case failed refetches are swallowed and not surfaced to the +caller. + +#### Inherited from + +[`ResultOptions`](ResultOptions.md).[`throwOnError`](ResultOptions.md#throwonerror) diff --git a/docs/framework/preact/reference/interfaces/FetchQueryOptions.md b/docs/framework/preact/reference/interfaces/FetchQueryOptions.md new file mode 100644 index 00000000000..b00973badc0 --- /dev/null +++ b/docs/framework/preact/reference/interfaces/FetchQueryOptions.md @@ -0,0 +1,364 @@ +--- +id: FetchQueryOptions +title: FetchQueryOptions +--- + +Defined in: [packages/query-core/src/types.ts:595](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L595) + +## Deprecated + +## Extends + +- [`WithRequired`](../type-aliases/WithRequired.md)\<[`QueryOptions`](QueryOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`, `TPageParam`\>, `"queryKey"`\> + +## Extended by + +- [`EnsureQueryDataOptions`](EnsureQueryDataOptions.md) + +## Type Parameters + +### TQueryFnData + +`TQueryFnData` = `unknown` + +### TError + +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) + +### TData + +`TData` = `TQueryFnData` + +### TQueryKey + +`TQueryKey` *extends* [`QueryKey`](../type-aliases/QueryKey.md) = [`QueryKey`](../type-aliases/QueryKey.md) + +### TPageParam + +`TPageParam` = `never` + +## Properties + +### ~~gcTime?~~ + +```ts +optional gcTime: number; +``` + +Defined in: [packages/query-core/src/types.ts:277](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L277) + +The time in milliseconds that unused/inactive cache data remains in memory. +When a query's cache becomes unused or inactive, that cache data will be garbage collected after this duration. +When different garbage collection times are specified, the longest one will be used. +Setting it to `Infinity` will disable garbage collection. + +Defaults to `5 * 60 * 1000` (5 minutes), or `Infinity` during SSR. + +Note: the maximum allowed time is about 24 days, imposed by `setTimeout`'s 32-bit signed integer delay — see +`timeoutManager.setTimeoutProvider` for a workaround. + +#### Inherited from + +```ts +WithRequired.gcTime +``` + +*** + +### ~~initialData?~~ + +```ts +optional initialData: + | TData +| InitialDataFunction; +``` + +Defined in: [packages/query-core/src/types.ts:317](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L317) + +If set, this value will be used as the initial data for the query cache (as long as the query hasn't been +created or cached yet). +If set to a function, the function will be called **once** during the shared/root query initialization, and be +expected to synchronously return the initial data. +Initial data is considered stale by default unless a `staleTime` has been set. +`initialData` **is persisted** to the cache. + +#### Inherited from + +```ts +WithRequired.initialData +``` + +*** + +### ~~initialDataUpdatedAt?~~ + +```ts +optional initialDataUpdatedAt: number | () => number | undefined; +``` + +Defined in: [packages/query-core/src/types.ts:321](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L321) + +If set, this value will be used as the time (in milliseconds) of when the `initialData` itself was last updated. + +#### Inherited from + +```ts +WithRequired.initialDataUpdatedAt +``` + +*** + +### ~~initialPageParam?~~ + +```ts +optional initialPageParam: undefined; +``` + +Defined in: [packages/query-core/src/types.ts:605](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L605) + +*** + +### ~~maxPages?~~ + +```ts +optional maxPages: number; +``` + +Defined in: [packages/query-core/src/types.ts:345](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L345) + +Maximum number of pages to store in the data of an infinite query. + +#### Inherited from + +```ts +WithRequired.maxPages +``` + +*** + +### ~~meta?~~ + +```ts +optional meta: Record; +``` + +Defined in: [packages/query-core/src/types.ts:341](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L341) + +Additional payload to be stored on each query. +Use this property to pass information that can be used in other places. + +#### Inherited from + +```ts +WithRequired.meta +``` + +*** + +### ~~networkMode?~~ + +```ts +optional networkMode: NetworkMode; +``` + +Defined in: [packages/query-core/src/types.ts:265](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L265) + +Controls whether a query is allowed to run based on the current network connectivity. + +Defaults to `'online'`. + +#### See + +[Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. + +#### Inherited from + +```ts +WithRequired.networkMode +``` + +*** + +### ~~persister?~~ + +```ts +optional persister: QueryPersister, TPageParam>; +``` + +Defined in: [packages/query-core/src/types.ts:290](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L290) + +This option can be used to persist the result of a query to an external storage, bypassing the need to actually +call the `queryFn`. Useful for persisting a query's data across e.g. server/client boundaries. + +#### Inherited from + +```ts +WithRequired.persister +``` + +*** + +### ~~queryFn?~~ + +```ts +optional queryFn: + | typeof skipToken +| QueryFunction; +``` + +Defined in: [packages/query-core/src/types.ts:285](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L285) + +The function that the query will use to request data. +Required, unless a default query function has been set via `queryClient.setQueryDefaults` or +`queryClient.setDefaultOptions`. +Receives a [QueryFunctionContext](../type-aliases/QueryFunctionContext.md). +Must return a promise that will either resolve data or throw an error. The data cannot be `undefined`. + +#### Inherited from + +```ts +WithRequired.queryFn +``` + +*** + +### ~~queryHash?~~ + +```ts +optional queryHash: string; +``` + +Defined in: [packages/query-core/src/types.ts:295](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L295) + +The hashed form of `queryKey`, computed with `queryKeyHashFn` (or the default hashing function otherwise). Used +as the actual cache key internally. + +#### Inherited from + +```ts +WithRequired.queryHash +``` + +*** + +### ~~queryKey~~ + +```ts +queryKey: TQueryKey & object; +``` + +Defined in: [packages/query-core/src/types.ts:304](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L304) + +The query key to use for this query. + +The query key will be hashed into a stable hash. See [Query Keys](https://tanstack.com/query/latest/docs/framework/react/guides/query-keys) +for more information. + +The query will automatically update when this key changes (as long as `enabled` is not set to `false`). + +#### Inherited from + +```ts +WithRequired.queryKey +``` + +*** + +### ~~queryKeyHashFn?~~ + +```ts +optional queryKeyHashFn: QueryKeyHashFunction; +``` + +Defined in: [packages/query-core/src/types.ts:308](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L308) + +If specified, this function is used to hash the `queryKey` to a string. + +#### Inherited from + +```ts +WithRequired.queryKeyHashFn +``` + +*** + +### ~~retry?~~ + +```ts +optional retry: RetryValue; +``` + +Defined in: [packages/query-core/src/types.ts:246](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L246) + +If `false`, failed queries will not retry by default. +If `true`, failed queries will retry infinitely. +If set to an integer number, e.g. 3, failed queries will retry until the failed query count meets that number. +If set to a function `(failureCount, error) => boolean` failed queries will retry until the function returns false. + +Defaults to `3` on the client and `0` on the server. + +#### Inherited from + +```ts +WithRequired.retry +``` + +*** + +### ~~retryDelay?~~ + +```ts +optional retryDelay: RetryDelayValue; +``` + +Defined in: [packages/query-core/src/types.ts:258](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L258) + +This function receives a `retryAttempt` integer and the actual Error and returns the delay to apply before the +next attempt in milliseconds. + +A function like `attempt => Math.min(attempt > 1 ? 2 ** attempt * 1000 : 1000, 30 * 1000)` applies exponential +backoff. + +A function like `attempt => attempt * 1000` applies linear backoff. + +Defaults to a function that applies exponential backoff, capped at 30 seconds. + +#### Inherited from + +```ts +WithRequired.retryDelay +``` + +*** + +### ~~staleTime?~~ + +```ts +optional staleTime: StaleTimeFunction; +``` + +Defined in: [packages/query-core/src/types.ts:610](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L610) + +The time in milliseconds after data is considered stale. +If the data is fresh it will be returned from the cache. + +*** + +### ~~structuralSharing?~~ + +```ts +optional structuralSharing: boolean | (oldData, newData) => unknown; +``` + +Defined in: [packages/query-core/src/types.ts:330](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L330) + +Set this to `false` to disable structural sharing between query results. +Set this to a function which accepts the old and new data and returns resolved data of the same type to implement custom structural sharing logic. + +Defaults to `true`. + +#### Inherited from + +```ts +WithRequired.structuralSharing +``` diff --git a/docs/framework/preact/reference/interfaces/FocusManager.md b/docs/framework/preact/reference/interfaces/FocusManager.md new file mode 100644 index 00000000000..1ab81dc6357 --- /dev/null +++ b/docs/framework/preact/reference/interfaces/FocusManager.md @@ -0,0 +1,237 @@ +--- +id: FocusManager +title: FocusManager +--- + +Defined in: [packages/query-core/src/focusManager.ts:14](https://github.com/TanStack/query/blob/main/packages/query-core/src/focusManager.ts#L14) + +The `FocusManager` manages the focus state within TanStack Query. + +It can be used to change the default event listeners or to manually change the focus state. + +## Extends + +- `Subscribable`\<`Listener`\> + +## Properties + +### listeners + +```ts +protected listeners: Set; +``` + +Defined in: [packages/query-core/src/subscribable.ts:2](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L2) + +#### Inherited from + +```ts +Subscribable.listeners +``` + +## Methods + +### hasListeners() + +```ts +hasListeners(): boolean; +``` + +Defined in: [packages/query-core/src/subscribable.ts:19](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L19) + +#### Returns + +`boolean` + +#### Inherited from + +```ts +Subscribable.hasListeners +``` + +*** + +### isFocused() + +```ts +isFocused(): boolean; +``` + +Defined in: [packages/query-core/src/focusManager.ts:128](https://github.com/TanStack/query/blob/main/packages/query-core/src/focusManager.ts#L128) + +`isFocused` can be used to get the current focus state. + +#### Returns + +`boolean` + +*** + +### onFocus() + +```ts +onFocus(): void; +``` + +Defined in: [packages/query-core/src/focusManager.ts:118](https://github.com/TanStack/query/blob/main/packages/query-core/src/focusManager.ts#L118) + +`onFocus` notifies all subscribed listeners with the current focus state. + +#### Returns + +`void` + +*** + +### onSubscribe() + +```ts +protected onSubscribe(): void; +``` + +Defined in: [packages/query-core/src/focusManager.ts:39](https://github.com/TanStack/query/blob/main/packages/query-core/src/focusManager.ts#L39) + +#### Returns + +`void` + +#### Overrides + +```ts +Subscribable.onSubscribe +``` + +*** + +### onUnsubscribe() + +```ts +protected onUnsubscribe(): void; +``` + +Defined in: [packages/query-core/src/focusManager.ts:45](https://github.com/TanStack/query/blob/main/packages/query-core/src/focusManager.ts#L45) + +#### Returns + +`void` + +#### Overrides + +```ts +Subscribable.onUnsubscribe +``` + +*** + +### setEventListener() + +```ts +setEventListener(setup): void; +``` + +Defined in: [packages/query-core/src/focusManager.ts:77](https://github.com/TanStack/query/blob/main/packages/query-core/src/focusManager.ts#L77) + +`setEventListener` can be used to set a custom event listener that will +be used to determine the focus state. The provided `setup` function +receives a `setFocused` callback: call it with a `boolean` to manually +set the focus state, or with no arguments to re-evaluate the current +focus state and notify subscribers. + +#### Parameters + +##### setup + +`SetupFn` + +#### Returns + +`void` + +#### Example + +```ts +import { focusManager } from '@tanstack/query-core' + +focusManager.setEventListener((handleFocus) => { + const listener = () => handleFocus() + // Listen to visibilitychange + if (typeof window !== 'undefined' && window.addEventListener) { + window.addEventListener('visibilitychange', listener, false) + } + + return () => { + // Be sure to unsubscribe if a new handler is set + window.removeEventListener('visibilitychange', listener) + } +}) +``` + +*** + +### setFocused() + +```ts +setFocused(focused?): void; +``` + +Defined in: [packages/query-core/src/focusManager.ts:107](https://github.com/TanStack/query/blob/main/packages/query-core/src/focusManager.ts#L107) + +`setFocused` can be used to manually set the focus state. Set `undefined` +to fall back to the default focus check. + +#### Parameters + +##### focused? + +`boolean` + +#### Returns + +`void` + +#### Example + +```ts +import { focusManager } from '@tanstack/query-core' + +// Set focused +focusManager.setFocused(true) + +// Set unfocused +focusManager.setFocused(false) + +// Fallback to the default focus check +focusManager.setFocused(undefined) +``` + +*** + +### subscribe() + +```ts +subscribe(listener): () => void; +``` + +Defined in: [packages/query-core/src/subscribable.ts:8](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L8) + +#### Parameters + +##### listener + +`Listener` + +#### Returns + +```ts +(): void; +``` + +##### Returns + +`void` + +#### Inherited from + +```ts +Subscribable.subscribe +``` diff --git a/docs/framework/preact/reference/interfaces/HydrateOptions.md b/docs/framework/preact/reference/interfaces/HydrateOptions.md new file mode 100644 index 00000000000..fe8b92317e3 --- /dev/null +++ b/docs/framework/preact/reference/interfaces/HydrateOptions.md @@ -0,0 +1,43 @@ +--- +id: HydrateOptions +title: HydrateOptions +--- + +Defined in: [packages/query-core/src/hydration.ts:61](https://github.com/TanStack/query/blob/main/packages/query-core/src/hydration.ts#L61) + +Options for `hydrate`, controlling the default options applied to queries/mutations restored from a +`DehydratedState`, and how to reverse any transformation applied by `DehydrateOptions.serializeData`. + +## Properties + +### defaultOptions? + +```ts +optional defaultOptions: object; +``` + +Defined in: [packages/query-core/src/hydration.ts:62](https://github.com/TanStack/query/blob/main/packages/query-core/src/hydration.ts#L62) + +#### deserializeData? + +```ts +optional deserializeData: TransformerFn; +``` + +Transforms a query's `data` after it is read from the dehydrated state, reversing `serializeData`. + +#### mutations? + +```ts +optional mutations: MutationOptions; +``` + +Default options merged into every mutation restored from the dehydrated state. + +#### queries? + +```ts +optional queries: QueryOptions; +``` + +Default options merged into every query restored from the dehydrated state. diff --git a/docs/framework/preact/reference/interfaces/HydrationBoundaryProps.md b/docs/framework/preact/reference/interfaces/HydrationBoundaryProps.md index 16b34036647..223a3168825 100644 --- a/docs/framework/preact/reference/interfaces/HydrationBoundaryProps.md +++ b/docs/framework/preact/reference/interfaces/HydrationBoundaryProps.md @@ -3,7 +3,7 @@ id: HydrationBoundaryProps title: HydrationBoundaryProps --- -Defined in: [preact-query/src/HydrationBoundary.tsx:17](https://github.com/TanStack/query/blob/main/packages/preact-query/src/HydrationBoundary.tsx#L17) +Defined in: [packages/preact-query/src/HydrationBoundary.tsx:17](https://github.com/TanStack/query/blob/main/packages/preact-query/src/HydrationBoundary.tsx#L17) The props accepted by `HydrationBoundary`. @@ -15,7 +15,7 @@ The props accepted by `HydrationBoundary`. optional children: ComponentChildren; ``` -Defined in: [preact-query/src/HydrationBoundary.tsx:37](https://github.com/TanStack/query/blob/main/packages/preact-query/src/HydrationBoundary.tsx#L37) +Defined in: [packages/preact-query/src/HydrationBoundary.tsx:37](https://github.com/TanStack/query/blob/main/packages/preact-query/src/HydrationBoundary.tsx#L37) The components to render — always rendered unconditionally, not gated on hydration. New queries are hydrated into the cache during render; for queries that already exist in the cache, only newer dehydrated @@ -30,7 +30,7 @@ lands. optional options: OmitKeyof & object; ``` -Defined in: [preact-query/src/HydrationBoundary.tsx:25](https://github.com/TanStack/query/blob/main/packages/preact-query/src/HydrationBoundary.tsx#L25) +Defined in: [packages/preact-query/src/HydrationBoundary.tsx:25](https://github.com/TanStack/query/blob/main/packages/preact-query/src/HydrationBoundary.tsx#L25) Optional. Note: unlike `hydrate`, `mutations` cannot be set here. @@ -40,6 +40,9 @@ Optional. Note: unlike `hydrate`, `mutations` cannot be set here. ```ts optional defaultOptions: OmitKeyof<{ + deserializeData?: TransformerFn; + mutations?: MutationOptions; + queries?: QueryOptions; }, "mutations">; ``` @@ -51,7 +54,7 @@ optional defaultOptions: OmitKeyof<{ optional queryClient: QueryClient; ``` -Defined in: [preact-query/src/HydrationBoundary.tsx:41](https://github.com/TanStack/query/blob/main/packages/preact-query/src/HydrationBoundary.tsx#L41) +Defined in: [packages/preact-query/src/HydrationBoundary.tsx:41](https://github.com/TanStack/query/blob/main/packages/preact-query/src/HydrationBoundary.tsx#L41) Use this to use a custom `QueryClient`. Otherwise, the one from the nearest context will be used. @@ -63,6 +66,6 @@ Use this to use a custom `QueryClient`. Otherwise, the one from the nearest cont state: DehydratedState | null | undefined; ``` -Defined in: [preact-query/src/HydrationBoundary.tsx:21](https://github.com/TanStack/query/blob/main/packages/preact-query/src/HydrationBoundary.tsx#L21) +Defined in: [packages/preact-query/src/HydrationBoundary.tsx:21](https://github.com/TanStack/query/blob/main/packages/preact-query/src/HydrationBoundary.tsx#L21) The state to hydrate. diff --git a/docs/framework/preact/reference/interfaces/InfiniteData.md b/docs/framework/preact/reference/interfaces/InfiniteData.md new file mode 100644 index 00000000000..4d7ad595c2d --- /dev/null +++ b/docs/framework/preact/reference/interfaces/InfiniteData.md @@ -0,0 +1,36 @@ +--- +id: InfiniteData +title: InfiniteData +--- + +Defined in: [packages/query-core/src/types.ts:210](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L210) + +## Type Parameters + +### TData + +`TData` + +### TPageParam + +`TPageParam` = `unknown` + +## Properties + +### pageParams + +```ts +pageParams: TPageParam[]; +``` + +Defined in: [packages/query-core/src/types.ts:212](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L212) + +*** + +### pages + +```ts +pages: TData[]; +``` + +Defined in: [packages/query-core/src/types.ts:211](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L211) diff --git a/docs/framework/preact/reference/interfaces/InfiniteQueryObserverBaseResult.md b/docs/framework/preact/reference/interfaces/InfiniteQueryObserverBaseResult.md new file mode 100644 index 00000000000..0aa01962aa5 --- /dev/null +++ b/docs/framework/preact/reference/interfaces/InfiniteQueryObserverBaseResult.md @@ -0,0 +1,577 @@ +--- +id: InfiniteQueryObserverBaseResult +title: InfiniteQueryObserverBaseResult +--- + +Defined in: [packages/query-core/src/types.ts:1001](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1001) + +## Extends + +- [`QueryObserverBaseResult`](QueryObserverBaseResult.md)\<`TData`, `TError`\> + +## Extended by + +- [`InfiniteQueryObserverPendingResult`](InfiniteQueryObserverPendingResult.md) +- [`InfiniteQueryObserverLoadingResult`](InfiniteQueryObserverLoadingResult.md) +- [`InfiniteQueryObserverLoadingErrorResult`](InfiniteQueryObserverLoadingErrorResult.md) +- [`InfiniteQueryObserverRefetchErrorResult`](InfiniteQueryObserverRefetchErrorResult.md) +- [`InfiniteQueryObserverSuccessResult`](InfiniteQueryObserverSuccessResult.md) +- [`InfiniteQueryObserverPlaceholderResult`](InfiniteQueryObserverPlaceholderResult.md) + +## Type Parameters + +### TData + +`TData` = `unknown` + +### TError + +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) + +## Properties + +### data + +```ts +data: TData | undefined; +``` + +Defined in: [packages/query-core/src/types.ts:771](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L771) + +The last successfully resolved data for the query. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`data`](QueryObserverBaseResult.md#data) + +*** + +### dataUpdatedAt + +```ts +dataUpdatedAt: number; +``` + +Defined in: [packages/query-core/src/types.ts:775](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L775) + +The timestamp for when the query most recently returned the `status` as `"success"`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`dataUpdatedAt`](QueryObserverBaseResult.md#dataupdatedat) + +*** + +### error + +```ts +error: TError | null; +``` + +Defined in: [packages/query-core/src/types.ts:780](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L780) + +The error object for the query, if an error was thrown. +- Defaults to `null`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`error`](QueryObserverBaseResult.md#error) + +*** + +### errorUpdateCount + +```ts +errorUpdateCount: number; +``` + +Defined in: [packages/query-core/src/types.ts:799](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L799) + +The sum of all errors. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`errorUpdateCount`](QueryObserverBaseResult.md#errorupdatecount) + +*** + +### errorUpdatedAt + +```ts +errorUpdatedAt: number; +``` + +Defined in: [packages/query-core/src/types.ts:784](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L784) + +The timestamp for when the query most recently returned the `status` as `"error"`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`errorUpdatedAt`](QueryObserverBaseResult.md#errorupdatedat) + +*** + +### failureCount + +```ts +failureCount: number; +``` + +Defined in: [packages/query-core/src/types.ts:790](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L790) + +The failure count for the query. +- Incremented every time the query fails. +- Reset to `0` when the query succeeds. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`failureCount`](QueryObserverBaseResult.md#failurecount) + +*** + +### failureReason + +```ts +failureReason: TError | null; +``` + +Defined in: [packages/query-core/src/types.ts:795](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L795) + +The failure reason for the query retry. +- Reset to `null` when the query succeeds. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`failureReason`](QueryObserverBaseResult.md#failurereason) + +*** + +### fetchNextPage() + +```ts +fetchNextPage: (options?) => Promise>; +``` + +Defined in: [packages/query-core/src/types.ts:1008](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1008) + +This function allows you to fetch the next "page" of results. + +#### Parameters + +##### options? + +[`FetchNextPageOptions`](FetchNextPageOptions.md) + +#### Returns + +`Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> + +*** + +### fetchPreviousPage() + +```ts +fetchPreviousPage: (options?) => Promise>; +``` + +Defined in: [packages/query-core/src/types.ts:1014](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1014) + +This function allows you to fetch the previous "page" of results. + +#### Parameters + +##### options? + +[`FetchPreviousPageOptions`](FetchPreviousPageOptions.md) + +#### Returns + +`Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> + +*** + +### fetchStatus + +```ts +fetchStatus: FetchStatus; +``` + +Defined in: [packages/query-core/src/types.ts:889](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L889) + +The fetch status of the query. +- `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. +- `paused`: The query wanted to fetch, but has been `paused`. +- `idle`: The query is not fetching. +- See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`fetchStatus`](QueryObserverBaseResult.md#fetchstatus) + +*** + +### hasNextPage + +```ts +hasNextPage: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1020](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1020) + +Will be `true` if there is a next page to be fetched (known via the `getNextPageParam` option). + +*** + +### hasPreviousPage + +```ts +hasPreviousPage: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1024](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1024) + +Will be `true` if there is a previous page to be fetched (known via the `getPreviousPageParam` option). + +*** + +### isEnabled + +```ts +isEnabled: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:867](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L867) + +`true` if this observer is enabled, `false` otherwise. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isEnabled`](QueryObserverBaseResult.md#isenabled) + +*** + +### isError + +```ts +isError: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:804](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L804) + +A derived boolean from the `status` variable, provided for convenience. +- `true` if the query attempt resulted in an error. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isError`](QueryObserverBaseResult.md#iserror) + +*** + +### isFetched + +```ts +isFetched: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:808](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L808) + +Will be `true` if the query has been fetched. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isFetched`](QueryObserverBaseResult.md#isfetched) + +*** + +### isFetchedAfterMount + +```ts +isFetchedAfterMount: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:813](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L813) + +Will be `true` if the query has been fetched after the component mounted. +- This property can be used to not show any previously cached data. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isFetchedAfterMount`](QueryObserverBaseResult.md#isfetchedaftermount) + +*** + +### isFetching + +```ts +isFetching: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:818](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L818) + +A derived boolean from the `fetchStatus` variable, provided for convenience. +- `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isFetching`](QueryObserverBaseResult.md#isfetching) + +*** + +### isFetchingNextPage + +```ts +isFetchingNextPage: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1032](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1032) + +Will be `true` while fetching the next page with `fetchNextPage`. + +*** + +### isFetchingPreviousPage + +```ts +isFetchingPreviousPage: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1040](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1040) + +Will be `true` while fetching the previous page with `fetchPreviousPage`. + +*** + +### isFetchNextPageError + +```ts +isFetchNextPageError: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1028](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1028) + +Will be `true` if the query failed while fetching the next page. + +*** + +### isFetchPreviousPageError + +```ts +isFetchPreviousPageError: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1036](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1036) + +Will be `true` if the query failed while fetching the previous page. + +*** + +### ~~isInitialLoading~~ + +```ts +isInitialLoading: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:836](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L836) + +#### Deprecated + +`isInitialLoading` is being deprecated in favor of `isLoading` +and will be removed in the next major version. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isInitialLoading`](QueryObserverBaseResult.md#isinitialloading) + +*** + +### isLoading + +```ts +isLoading: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:823](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L823) + +Is `true` whenever the first fetch for a query is in-flight. +- Is the same as `isFetching && isPending`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoading`](QueryObserverBaseResult.md#isloading) + +*** + +### isLoadingError + +```ts +isLoadingError: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:831](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L831) + +Will be `true` if the query failed while fetching for the first time. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoadingError`](QueryObserverBaseResult.md#isloadingerror) + +*** + +### isPaused + +```ts +isPaused: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:841](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L841) + +A derived boolean from the `fetchStatus` variable, provided for convenience. +- The query wanted to fetch, but has been `paused`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPaused`](QueryObserverBaseResult.md#ispaused) + +*** + +### isPending + +```ts +isPending: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:827](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L827) + +Will be `pending` if there's no cached data and no query attempt was finished yet. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPending`](QueryObserverBaseResult.md#ispending) + +*** + +### isPlaceholderData + +```ts +isPlaceholderData: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:845](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L845) + +Will be `true` if the data shown is the placeholder data. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPlaceholderData`](QueryObserverBaseResult.md#isplaceholderdata) + +*** + +### isRefetchError + +```ts +isRefetchError: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:849](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L849) + +Will be `true` if the query failed while refetching. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetchError`](QueryObserverBaseResult.md#isrefetcherror) + +*** + +### isRefetching + +```ts +isRefetching: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:854](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L854) + +Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. +- Is the same as `isFetching && !isPending`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetching`](QueryObserverBaseResult.md#isrefetching) + +*** + +### isStale + +```ts +isStale: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:858](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L858) + +Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isStale`](QueryObserverBaseResult.md#isstale) + +*** + +### isSuccess + +```ts +isSuccess: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:863](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L863) + +A derived boolean from the `status` variable, provided for convenience. +- `true` if the query has received a response with no errors and is ready to display its data. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isSuccess`](QueryObserverBaseResult.md#issuccess) + +*** + +### refetch() + +```ts +refetch: (options?) => Promise>; +``` + +Defined in: [packages/query-core/src/types.ts:871](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L871) + +A function to manually refetch the query. + +#### Parameters + +##### options? + +[`RefetchOptions`](RefetchOptions.md) + +#### Returns + +`Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`refetch`](QueryObserverBaseResult.md#refetch) + +*** + +### status + +```ts +status: QueryStatus; +``` + +Defined in: [packages/query-core/src/types.ts:881](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L881) + +The status of the query. +- Will be: + - `pending` if there's no cached data and no query attempt was finished yet. + - `error` if the query attempt resulted in an error. + - `success` if the query has received a response with no errors and is ready to display its data. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`status`](QueryObserverBaseResult.md#status) diff --git a/docs/framework/preact/reference/interfaces/InfiniteQueryObserverLoadingErrorResult.md b/docs/framework/preact/reference/interfaces/InfiniteQueryObserverLoadingErrorResult.md new file mode 100644 index 00000000000..f5e3352f27c --- /dev/null +++ b/docs/framework/preact/reference/interfaces/InfiniteQueryObserverLoadingErrorResult.md @@ -0,0 +1,600 @@ +--- +id: InfiniteQueryObserverLoadingErrorResult +title: InfiniteQueryObserverLoadingErrorResult +--- + +Defined in: [packages/query-core/src/types.ts:1078](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1078) + +## Extends + +- [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md)\<`TData`, `TError`\> + +## Type Parameters + +### TData + +`TData` = `unknown` + +### TError + +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) + +## Properties + +### data + +```ts +data: undefined; +``` + +Defined in: [packages/query-core/src/types.ts:1082](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1082) + +The last successfully resolved data for the query. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`data`](InfiniteQueryObserverBaseResult.md#data) + +*** + +### dataUpdatedAt + +```ts +dataUpdatedAt: number; +``` + +Defined in: [packages/query-core/src/types.ts:775](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L775) + +The timestamp for when the query most recently returned the `status` as `"success"`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`dataUpdatedAt`](InfiniteQueryObserverBaseResult.md#dataupdatedat) + +*** + +### error + +```ts +error: TError; +``` + +Defined in: [packages/query-core/src/types.ts:1083](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1083) + +The error object for the query, if an error was thrown. +- Defaults to `null`. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`error`](InfiniteQueryObserverBaseResult.md#error) + +*** + +### errorUpdateCount + +```ts +errorUpdateCount: number; +``` + +Defined in: [packages/query-core/src/types.ts:799](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L799) + +The sum of all errors. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`errorUpdateCount`](InfiniteQueryObserverBaseResult.md#errorupdatecount) + +*** + +### errorUpdatedAt + +```ts +errorUpdatedAt: number; +``` + +Defined in: [packages/query-core/src/types.ts:784](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L784) + +The timestamp for when the query most recently returned the `status` as `"error"`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`errorUpdatedAt`](InfiniteQueryObserverBaseResult.md#errorupdatedat) + +*** + +### failureCount + +```ts +failureCount: number; +``` + +Defined in: [packages/query-core/src/types.ts:790](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L790) + +The failure count for the query. +- Incremented every time the query fails. +- Reset to `0` when the query succeeds. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`failureCount`](InfiniteQueryObserverBaseResult.md#failurecount) + +*** + +### failureReason + +```ts +failureReason: TError | null; +``` + +Defined in: [packages/query-core/src/types.ts:795](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L795) + +The failure reason for the query retry. +- Reset to `null` when the query succeeds. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`failureReason`](InfiniteQueryObserverBaseResult.md#failurereason) + +*** + +### fetchNextPage() + +```ts +fetchNextPage: (options?) => Promise>; +``` + +Defined in: [packages/query-core/src/types.ts:1008](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1008) + +This function allows you to fetch the next "page" of results. + +#### Parameters + +##### options? + +[`FetchNextPageOptions`](FetchNextPageOptions.md) + +#### Returns + +`Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`fetchNextPage`](InfiniteQueryObserverBaseResult.md#fetchnextpage) + +*** + +### fetchPreviousPage() + +```ts +fetchPreviousPage: (options?) => Promise>; +``` + +Defined in: [packages/query-core/src/types.ts:1014](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1014) + +This function allows you to fetch the previous "page" of results. + +#### Parameters + +##### options? + +[`FetchPreviousPageOptions`](FetchPreviousPageOptions.md) + +#### Returns + +`Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`fetchPreviousPage`](InfiniteQueryObserverBaseResult.md#fetchpreviouspage) + +*** + +### fetchStatus + +```ts +fetchStatus: FetchStatus; +``` + +Defined in: [packages/query-core/src/types.ts:889](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L889) + +The fetch status of the query. +- `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. +- `paused`: The query wanted to fetch, but has been `paused`. +- `idle`: The query is not fetching. +- See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`fetchStatus`](InfiniteQueryObserverBaseResult.md#fetchstatus) + +*** + +### hasNextPage + +```ts +hasNextPage: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1020](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1020) + +Will be `true` if there is a next page to be fetched (known via the `getNextPageParam` option). + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`hasNextPage`](InfiniteQueryObserverBaseResult.md#hasnextpage) + +*** + +### hasPreviousPage + +```ts +hasPreviousPage: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1024](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1024) + +Will be `true` if there is a previous page to be fetched (known via the `getPreviousPageParam` option). + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`hasPreviousPage`](InfiniteQueryObserverBaseResult.md#haspreviouspage) + +*** + +### isEnabled + +```ts +isEnabled: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:867](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L867) + +`true` if this observer is enabled, `false` otherwise. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isEnabled`](InfiniteQueryObserverBaseResult.md#isenabled) + +*** + +### isError + +```ts +isError: true; +``` + +Defined in: [packages/query-core/src/types.ts:1084](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1084) + +A derived boolean from the `status` variable, provided for convenience. +- `true` if the query attempt resulted in an error. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isError`](InfiniteQueryObserverBaseResult.md#iserror) + +*** + +### isFetched + +```ts +isFetched: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:808](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L808) + +Will be `true` if the query has been fetched. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetched`](InfiniteQueryObserverBaseResult.md#isfetched) + +*** + +### isFetchedAfterMount + +```ts +isFetchedAfterMount: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:813](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L813) + +Will be `true` if the query has been fetched after the component mounted. +- This property can be used to not show any previously cached data. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchedAfterMount`](InfiniteQueryObserverBaseResult.md#isfetchedaftermount) + +*** + +### isFetching + +```ts +isFetching: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:818](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L818) + +A derived boolean from the `fetchStatus` variable, provided for convenience. +- `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetching`](InfiniteQueryObserverBaseResult.md#isfetching) + +*** + +### isFetchingNextPage + +```ts +isFetchingNextPage: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1032](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1032) + +Will be `true` while fetching the next page with `fetchNextPage`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchingNextPage`](InfiniteQueryObserverBaseResult.md#isfetchingnextpage) + +*** + +### isFetchingPreviousPage + +```ts +isFetchingPreviousPage: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1040](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1040) + +Will be `true` while fetching the previous page with `fetchPreviousPage`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchingPreviousPage`](InfiniteQueryObserverBaseResult.md#isfetchingpreviouspage) + +*** + +### isFetchNextPageError + +```ts +isFetchNextPageError: false; +``` + +Defined in: [packages/query-core/src/types.ts:1089](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1089) + +Will be `true` if the query failed while fetching the next page. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchNextPageError`](InfiniteQueryObserverBaseResult.md#isfetchnextpageerror) + +*** + +### isFetchPreviousPageError + +```ts +isFetchPreviousPageError: false; +``` + +Defined in: [packages/query-core/src/types.ts:1090](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1090) + +Will be `true` if the query failed while fetching the previous page. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchPreviousPageError`](InfiniteQueryObserverBaseResult.md#isfetchpreviouspageerror) + +*** + +### ~~isInitialLoading~~ + +```ts +isInitialLoading: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:836](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L836) + +#### Deprecated + +`isInitialLoading` is being deprecated in favor of `isLoading` +and will be removed in the next major version. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isInitialLoading`](InfiniteQueryObserverBaseResult.md#isinitialloading) + +*** + +### isLoading + +```ts +isLoading: false; +``` + +Defined in: [packages/query-core/src/types.ts:1086](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1086) + +Is `true` whenever the first fetch for a query is in-flight. +- Is the same as `isFetching && isPending`. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoading`](InfiniteQueryObserverBaseResult.md#isloading) + +*** + +### isLoadingError + +```ts +isLoadingError: true; +``` + +Defined in: [packages/query-core/src/types.ts:1087](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1087) + +Will be `true` if the query failed while fetching for the first time. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoadingError`](InfiniteQueryObserverBaseResult.md#isloadingerror) + +*** + +### isPaused + +```ts +isPaused: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:841](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L841) + +A derived boolean from the `fetchStatus` variable, provided for convenience. +- The query wanted to fetch, but has been `paused`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPaused`](InfiniteQueryObserverBaseResult.md#ispaused) + +*** + +### isPending + +```ts +isPending: false; +``` + +Defined in: [packages/query-core/src/types.ts:1085](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1085) + +Will be `pending` if there's no cached data and no query attempt was finished yet. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPending`](InfiniteQueryObserverBaseResult.md#ispending) + +*** + +### isPlaceholderData + +```ts +isPlaceholderData: false; +``` + +Defined in: [packages/query-core/src/types.ts:1092](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1092) + +Will be `true` if the data shown is the placeholder data. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPlaceholderData`](InfiniteQueryObserverBaseResult.md#isplaceholderdata) + +*** + +### isRefetchError + +```ts +isRefetchError: false; +``` + +Defined in: [packages/query-core/src/types.ts:1088](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1088) + +Will be `true` if the query failed while refetching. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isRefetchError`](InfiniteQueryObserverBaseResult.md#isrefetcherror) + +*** + +### isRefetching + +```ts +isRefetching: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:854](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L854) + +Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. +- Is the same as `isFetching && !isPending`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isRefetching`](InfiniteQueryObserverBaseResult.md#isrefetching) + +*** + +### isStale + +```ts +isStale: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:858](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L858) + +Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isStale`](InfiniteQueryObserverBaseResult.md#isstale) + +*** + +### isSuccess + +```ts +isSuccess: false; +``` + +Defined in: [packages/query-core/src/types.ts:1091](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1091) + +A derived boolean from the `status` variable, provided for convenience. +- `true` if the query has received a response with no errors and is ready to display its data. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isSuccess`](InfiniteQueryObserverBaseResult.md#issuccess) + +*** + +### refetch() + +```ts +refetch: (options?) => Promise>; +``` + +Defined in: [packages/query-core/src/types.ts:871](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L871) + +A function to manually refetch the query. + +#### Parameters + +##### options? + +[`RefetchOptions`](RefetchOptions.md) + +#### Returns + +`Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`refetch`](InfiniteQueryObserverBaseResult.md#refetch) + +*** + +### status + +```ts +status: "error"; +``` + +Defined in: [packages/query-core/src/types.ts:1093](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1093) + +The status of the query. +- Will be: + - `pending` if there's no cached data and no query attempt was finished yet. + - `error` if the query attempt resulted in an error. + - `success` if the query has received a response with no errors and is ready to display its data. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`status`](InfiniteQueryObserverBaseResult.md#status) diff --git a/docs/framework/preact/reference/interfaces/InfiniteQueryObserverLoadingResult.md b/docs/framework/preact/reference/interfaces/InfiniteQueryObserverLoadingResult.md new file mode 100644 index 00000000000..b7aa67744c0 --- /dev/null +++ b/docs/framework/preact/reference/interfaces/InfiniteQueryObserverLoadingResult.md @@ -0,0 +1,600 @@ +--- +id: InfiniteQueryObserverLoadingResult +title: InfiniteQueryObserverLoadingResult +--- + +Defined in: [packages/query-core/src/types.ts:1060](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1060) + +## Extends + +- [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md)\<`TData`, `TError`\> + +## Type Parameters + +### TData + +`TData` = `unknown` + +### TError + +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) + +## Properties + +### data + +```ts +data: undefined; +``` + +Defined in: [packages/query-core/src/types.ts:1064](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1064) + +The last successfully resolved data for the query. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`data`](InfiniteQueryObserverBaseResult.md#data) + +*** + +### dataUpdatedAt + +```ts +dataUpdatedAt: number; +``` + +Defined in: [packages/query-core/src/types.ts:775](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L775) + +The timestamp for when the query most recently returned the `status` as `"success"`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`dataUpdatedAt`](InfiniteQueryObserverBaseResult.md#dataupdatedat) + +*** + +### error + +```ts +error: null; +``` + +Defined in: [packages/query-core/src/types.ts:1065](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1065) + +The error object for the query, if an error was thrown. +- Defaults to `null`. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`error`](InfiniteQueryObserverBaseResult.md#error) + +*** + +### errorUpdateCount + +```ts +errorUpdateCount: number; +``` + +Defined in: [packages/query-core/src/types.ts:799](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L799) + +The sum of all errors. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`errorUpdateCount`](InfiniteQueryObserverBaseResult.md#errorupdatecount) + +*** + +### errorUpdatedAt + +```ts +errorUpdatedAt: number; +``` + +Defined in: [packages/query-core/src/types.ts:784](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L784) + +The timestamp for when the query most recently returned the `status` as `"error"`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`errorUpdatedAt`](InfiniteQueryObserverBaseResult.md#errorupdatedat) + +*** + +### failureCount + +```ts +failureCount: number; +``` + +Defined in: [packages/query-core/src/types.ts:790](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L790) + +The failure count for the query. +- Incremented every time the query fails. +- Reset to `0` when the query succeeds. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`failureCount`](InfiniteQueryObserverBaseResult.md#failurecount) + +*** + +### failureReason + +```ts +failureReason: TError | null; +``` + +Defined in: [packages/query-core/src/types.ts:795](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L795) + +The failure reason for the query retry. +- Reset to `null` when the query succeeds. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`failureReason`](InfiniteQueryObserverBaseResult.md#failurereason) + +*** + +### fetchNextPage() + +```ts +fetchNextPage: (options?) => Promise>; +``` + +Defined in: [packages/query-core/src/types.ts:1008](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1008) + +This function allows you to fetch the next "page" of results. + +#### Parameters + +##### options? + +[`FetchNextPageOptions`](FetchNextPageOptions.md) + +#### Returns + +`Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`fetchNextPage`](InfiniteQueryObserverBaseResult.md#fetchnextpage) + +*** + +### fetchPreviousPage() + +```ts +fetchPreviousPage: (options?) => Promise>; +``` + +Defined in: [packages/query-core/src/types.ts:1014](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1014) + +This function allows you to fetch the previous "page" of results. + +#### Parameters + +##### options? + +[`FetchPreviousPageOptions`](FetchPreviousPageOptions.md) + +#### Returns + +`Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`fetchPreviousPage`](InfiniteQueryObserverBaseResult.md#fetchpreviouspage) + +*** + +### fetchStatus + +```ts +fetchStatus: FetchStatus; +``` + +Defined in: [packages/query-core/src/types.ts:889](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L889) + +The fetch status of the query. +- `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. +- `paused`: The query wanted to fetch, but has been `paused`. +- `idle`: The query is not fetching. +- See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`fetchStatus`](InfiniteQueryObserverBaseResult.md#fetchstatus) + +*** + +### hasNextPage + +```ts +hasNextPage: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1020](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1020) + +Will be `true` if there is a next page to be fetched (known via the `getNextPageParam` option). + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`hasNextPage`](InfiniteQueryObserverBaseResult.md#hasnextpage) + +*** + +### hasPreviousPage + +```ts +hasPreviousPage: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1024](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1024) + +Will be `true` if there is a previous page to be fetched (known via the `getPreviousPageParam` option). + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`hasPreviousPage`](InfiniteQueryObserverBaseResult.md#haspreviouspage) + +*** + +### isEnabled + +```ts +isEnabled: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:867](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L867) + +`true` if this observer is enabled, `false` otherwise. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isEnabled`](InfiniteQueryObserverBaseResult.md#isenabled) + +*** + +### isError + +```ts +isError: false; +``` + +Defined in: [packages/query-core/src/types.ts:1066](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1066) + +A derived boolean from the `status` variable, provided for convenience. +- `true` if the query attempt resulted in an error. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isError`](InfiniteQueryObserverBaseResult.md#iserror) + +*** + +### isFetched + +```ts +isFetched: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:808](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L808) + +Will be `true` if the query has been fetched. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetched`](InfiniteQueryObserverBaseResult.md#isfetched) + +*** + +### isFetchedAfterMount + +```ts +isFetchedAfterMount: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:813](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L813) + +Will be `true` if the query has been fetched after the component mounted. +- This property can be used to not show any previously cached data. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchedAfterMount`](InfiniteQueryObserverBaseResult.md#isfetchedaftermount) + +*** + +### isFetching + +```ts +isFetching: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:818](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L818) + +A derived boolean from the `fetchStatus` variable, provided for convenience. +- `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetching`](InfiniteQueryObserverBaseResult.md#isfetching) + +*** + +### isFetchingNextPage + +```ts +isFetchingNextPage: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1032](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1032) + +Will be `true` while fetching the next page with `fetchNextPage`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchingNextPage`](InfiniteQueryObserverBaseResult.md#isfetchingnextpage) + +*** + +### isFetchingPreviousPage + +```ts +isFetchingPreviousPage: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1040](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1040) + +Will be `true` while fetching the previous page with `fetchPreviousPage`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchingPreviousPage`](InfiniteQueryObserverBaseResult.md#isfetchingpreviouspage) + +*** + +### isFetchNextPageError + +```ts +isFetchNextPageError: false; +``` + +Defined in: [packages/query-core/src/types.ts:1071](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1071) + +Will be `true` if the query failed while fetching the next page. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchNextPageError`](InfiniteQueryObserverBaseResult.md#isfetchnextpageerror) + +*** + +### isFetchPreviousPageError + +```ts +isFetchPreviousPageError: false; +``` + +Defined in: [packages/query-core/src/types.ts:1072](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1072) + +Will be `true` if the query failed while fetching the previous page. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchPreviousPageError`](InfiniteQueryObserverBaseResult.md#isfetchpreviouspageerror) + +*** + +### ~~isInitialLoading~~ + +```ts +isInitialLoading: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:836](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L836) + +#### Deprecated + +`isInitialLoading` is being deprecated in favor of `isLoading` +and will be removed in the next major version. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isInitialLoading`](InfiniteQueryObserverBaseResult.md#isinitialloading) + +*** + +### isLoading + +```ts +isLoading: true; +``` + +Defined in: [packages/query-core/src/types.ts:1068](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1068) + +Is `true` whenever the first fetch for a query is in-flight. +- Is the same as `isFetching && isPending`. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoading`](InfiniteQueryObserverBaseResult.md#isloading) + +*** + +### isLoadingError + +```ts +isLoadingError: false; +``` + +Defined in: [packages/query-core/src/types.ts:1069](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1069) + +Will be `true` if the query failed while fetching for the first time. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoadingError`](InfiniteQueryObserverBaseResult.md#isloadingerror) + +*** + +### isPaused + +```ts +isPaused: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:841](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L841) + +A derived boolean from the `fetchStatus` variable, provided for convenience. +- The query wanted to fetch, but has been `paused`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPaused`](InfiniteQueryObserverBaseResult.md#ispaused) + +*** + +### isPending + +```ts +isPending: true; +``` + +Defined in: [packages/query-core/src/types.ts:1067](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1067) + +Will be `pending` if there's no cached data and no query attempt was finished yet. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPending`](InfiniteQueryObserverBaseResult.md#ispending) + +*** + +### isPlaceholderData + +```ts +isPlaceholderData: false; +``` + +Defined in: [packages/query-core/src/types.ts:1074](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1074) + +Will be `true` if the data shown is the placeholder data. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPlaceholderData`](InfiniteQueryObserverBaseResult.md#isplaceholderdata) + +*** + +### isRefetchError + +```ts +isRefetchError: false; +``` + +Defined in: [packages/query-core/src/types.ts:1070](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1070) + +Will be `true` if the query failed while refetching. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isRefetchError`](InfiniteQueryObserverBaseResult.md#isrefetcherror) + +*** + +### isRefetching + +```ts +isRefetching: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:854](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L854) + +Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. +- Is the same as `isFetching && !isPending`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isRefetching`](InfiniteQueryObserverBaseResult.md#isrefetching) + +*** + +### isStale + +```ts +isStale: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:858](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L858) + +Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isStale`](InfiniteQueryObserverBaseResult.md#isstale) + +*** + +### isSuccess + +```ts +isSuccess: false; +``` + +Defined in: [packages/query-core/src/types.ts:1073](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1073) + +A derived boolean from the `status` variable, provided for convenience. +- `true` if the query has received a response with no errors and is ready to display its data. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isSuccess`](InfiniteQueryObserverBaseResult.md#issuccess) + +*** + +### refetch() + +```ts +refetch: (options?) => Promise>; +``` + +Defined in: [packages/query-core/src/types.ts:871](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L871) + +A function to manually refetch the query. + +#### Parameters + +##### options? + +[`RefetchOptions`](RefetchOptions.md) + +#### Returns + +`Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`refetch`](InfiniteQueryObserverBaseResult.md#refetch) + +*** + +### status + +```ts +status: "pending"; +``` + +Defined in: [packages/query-core/src/types.ts:1075](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1075) + +The status of the query. +- Will be: + - `pending` if there's no cached data and no query attempt was finished yet. + - `error` if the query attempt resulted in an error. + - `success` if the query has received a response with no errors and is ready to display its data. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`status`](InfiniteQueryObserverBaseResult.md#status) diff --git a/docs/framework/preact/reference/interfaces/InfiniteQueryObserverOptions.md b/docs/framework/preact/reference/interfaces/InfiniteQueryObserverOptions.md new file mode 100644 index 00000000000..7670bd8e24b --- /dev/null +++ b/docs/framework/preact/reference/interfaces/InfiniteQueryObserverOptions.md @@ -0,0 +1,624 @@ +--- +id: InfiniteQueryObserverOptions +title: InfiniteQueryObserverOptions +--- + +Defined in: [packages/query-core/src/types.ts:539](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L539) + +## Extends + +- [`QueryObserverOptions`](QueryObserverOptions.md)\<`TQueryFnData`, `TError`, `TData`, [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`, `TPageParam`\>.[`InfiniteQueryPageParamsOptions`](InfiniteQueryPageParamsOptions.md)\<`TQueryFnData`, `TPageParam`\> + +## Type Parameters + +### TQueryFnData + +`TQueryFnData` = `unknown` + +### TError + +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) + +### TData + +`TData` = `TQueryFnData` + +### TQueryKey + +`TQueryKey` *extends* [`QueryKey`](../type-aliases/QueryKey.md) = [`QueryKey`](../type-aliases/QueryKey.md) + +### TPageParam + +`TPageParam` = `unknown` + +## Properties + +### enabled? + +```ts +optional enabled: QueryBooleanOption, TQueryKey>; +``` + +Defined in: [packages/query-core/src/types.ts:398](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L398) + +Set this to `false` or a function that returns `false` to disable automatic refetching when the query mounts or changes query keys. +To refetch the query, use the `refetch` method returned from the `useQuery` instance. +Accepts a boolean or function that returns a boolean. + +Defaults to `true`. + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`enabled`](QueryObserverOptions.md#enabled) + +*** + +### gcTime? + +```ts +optional gcTime: number; +``` + +Defined in: [packages/query-core/src/types.ts:277](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L277) + +The time in milliseconds that unused/inactive cache data remains in memory. +When a query's cache becomes unused or inactive, that cache data will be garbage collected after this duration. +When different garbage collection times are specified, the longest one will be used. +Setting it to `Infinity` will disable garbage collection. + +Defaults to `5 * 60 * 1000` (5 minutes), or `Infinity` during SSR. + +Note: the maximum allowed time is about 24 days, imposed by `setTimeout`'s 32-bit signed integer delay — see +`timeoutManager.setTimeoutProvider` for a workaround. + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`gcTime`](QueryObserverOptions.md#gctime) + +*** + +### getNextPageParam + +```ts +getNextPageParam: GetNextPageParamFunction; +``` + +Defined in: [packages/query-core/src/types.ts:365](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L365) + +This function can be set to automatically get the next cursor for infinite queries. +The result will also be used to determine the value of `hasNextPage`. + +#### Inherited from + +[`InfiniteQueryPageParamsOptions`](InfiniteQueryPageParamsOptions.md).[`getNextPageParam`](InfiniteQueryPageParamsOptions.md#getnextpageparam) + +*** + +### getPreviousPageParam? + +```ts +optional getPreviousPageParam: GetPreviousPageParamFunction; +``` + +Defined in: [packages/query-core/src/types.ts:360](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L360) + +This function can be set to automatically get the previous cursor for infinite queries. +The result will also be used to determine the value of `hasPreviousPage`. + +#### Inherited from + +[`InfiniteQueryPageParamsOptions`](InfiniteQueryPageParamsOptions.md).[`getPreviousPageParam`](InfiniteQueryPageParamsOptions.md#getpreviouspageparam) + +*** + +### initialData? + +```ts +optional initialData: + | InfiniteData +| InitialDataFunction>; +``` + +Defined in: [packages/query-core/src/types.ts:317](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L317) + +If set, this value will be used as the initial data for the query cache (as long as the query hasn't been +created or cached yet). +If set to a function, the function will be called **once** during the shared/root query initialization, and be +expected to synchronously return the initial data. +Initial data is considered stale by default unless a `staleTime` has been set. +`initialData` **is persisted** to the cache. + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`initialData`](QueryObserverOptions.md#initialdata) + +*** + +### initialDataUpdatedAt? + +```ts +optional initialDataUpdatedAt: number | () => number | undefined; +``` + +Defined in: [packages/query-core/src/types.ts:321](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L321) + +If set, this value will be used as the time (in milliseconds) of when the `initialData` itself was last updated. + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`initialDataUpdatedAt`](QueryObserverOptions.md#initialdataupdatedat) + +*** + +### initialPageParam + +```ts +initialPageParam: TPageParam; +``` + +Defined in: [packages/query-core/src/types.ts:349](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L349) + +#### Inherited from + +[`InfiniteQueryPageParamsOptions`](InfiniteQueryPageParamsOptions.md).[`initialPageParam`](InfiniteQueryPageParamsOptions.md#initialpageparam) + +*** + +### maxPages? + +```ts +optional maxPages: number; +``` + +Defined in: [packages/query-core/src/types.ts:345](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L345) + +Maximum number of pages to store in the data of an infinite query. + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`maxPages`](QueryObserverOptions.md#maxpages) + +*** + +### meta? + +```ts +optional meta: Record; +``` + +Defined in: [packages/query-core/src/types.ts:341](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L341) + +Additional payload to be stored on each query. +Use this property to pass information that can be used in other places. + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`meta`](QueryObserverOptions.md#meta) + +*** + +### networkMode? + +```ts +optional networkMode: NetworkMode; +``` + +Defined in: [packages/query-core/src/types.ts:265](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L265) + +Controls whether a query is allowed to run based on the current network connectivity. + +Defaults to `'online'`. + +#### See + +[Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`networkMode`](QueryObserverOptions.md#networkmode) + +*** + +### notifyOnChangeProps? + +```ts +optional notifyOnChangeProps: NotifyOnChangeProps; +``` + +Defined in: [packages/query-core/src/types.ts:484](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L484) + +If set, the component will only re-render if any of the listed properties change. +When set to `['data', 'error']`, the component will only re-render when the `data` or `error` properties change. +When set to `'all'`, the component will re-render whenever a query is updated. +When set to a function, the function will be executed to compute the list of properties. + +Defaults to `undefined`, in which case property access is tracked automatically, and the +component only re-renders when one of the tracked properties changes. + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`notifyOnChangeProps`](QueryObserverOptions.md#notifyonchangeprops) + +*** + +### persister? + +```ts +optional persister: QueryPersister, TPageParam>; +``` + +Defined in: [packages/query-core/src/types.ts:290](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L290) + +This option can be used to persist the result of a query to an external storage, bypassing the need to actually +call the `queryFn`. Useful for persisting a query's data across e.g. server/client boundaries. + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`persister`](QueryObserverOptions.md#persister) + +*** + +### placeholderData? + +```ts +optional placeholderData: + | InfiniteData +| PlaceholderDataFunction, TError, InfiniteData, TQueryKey>; +``` + +Defined in: [packages/query-core/src/types.ts:511](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L511) + +If set, this value will be used as the placeholder data for this particular query observer while the query is still in the `loading` data and no initialData has been provided. + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`placeholderData`](QueryObserverOptions.md#placeholderdata) + +*** + +### queryFn? + +```ts +optional queryFn: + | typeof skipToken +| QueryFunction; +``` + +Defined in: [packages/query-core/src/types.ts:285](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L285) + +The function that the query will use to request data. +Required, unless a default query function has been set via `queryClient.setQueryDefaults` or +`queryClient.setDefaultOptions`. +Receives a [QueryFunctionContext](../type-aliases/QueryFunctionContext.md). +Must return a promise that will either resolve data or throw an error. The data cannot be `undefined`. + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`queryFn`](QueryObserverOptions.md#queryfn) + +*** + +### queryHash? + +```ts +optional queryHash: string; +``` + +Defined in: [packages/query-core/src/types.ts:295](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L295) + +The hashed form of `queryKey`, computed with `queryKeyHashFn` (or the default hashing function otherwise). Used +as the actual cache key internally. + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`queryHash`](QueryObserverOptions.md#queryhash) + +*** + +### queryKey + +```ts +queryKey: TQueryKey & object; +``` + +Defined in: [packages/query-core/src/types.ts:304](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L304) + +The query key to use for this query. + +The query key will be hashed into a stable hash. See [Query Keys](https://tanstack.com/query/latest/docs/framework/react/guides/query-keys) +for more information. + +The query will automatically update when this key changes (as long as `enabled` is not set to `false`). + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`queryKey`](QueryObserverOptions.md#querykey) + +*** + +### queryKeyHashFn? + +```ts +optional queryKeyHashFn: QueryKeyHashFunction; +``` + +Defined in: [packages/query-core/src/types.ts:308](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L308) + +If specified, this function is used to hash the `queryKey` to a string. + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`queryKeyHashFn`](QueryObserverOptions.md#querykeyhashfn) + +*** + +### refetchInterval? + +```ts +optional refetchInterval: number | false | (query) => number | false | undefined; +``` + +Defined in: [packages/query-core/src/types.ts:414](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L414) + +If set to a number, the query will continuously refetch at this frequency in milliseconds. +If set to a function, the function will be executed with the latest data and query to compute a frequency + +Defaults to `false`. + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`refetchInterval`](QueryObserverOptions.md#refetchinterval) + +*** + +### refetchIntervalInBackground? + +```ts +optional refetchIntervalInBackground: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:425](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L425) + +If set to `true`, the query will continue to refetch while their tab/window is in the background. + +Defaults to `false`. + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`refetchIntervalInBackground`](QueryObserverOptions.md#refetchintervalinbackground) + +*** + +### refetchOnMount? + +```ts +optional refetchOnMount: boolean | "always" | (query) => boolean | "always"; +``` + +Defined in: [packages/query-core/src/types.ts:462](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L462) + +If set to `true`, the query will refetch on mount if the data is stale. +If set to `false`, will disable additional instances of a query to trigger background refetch. +If set to `'always'`, the query will always refetch on mount (except when `staleTime: 'static'` is used). +If set to a function, the function will be executed with the latest data and query to compute the value + +Defaults to `true`. + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`refetchOnMount`](QueryObserverOptions.md#refetchonmount) + +*** + +### refetchOnReconnect? + +```ts +optional refetchOnReconnect: boolean | "always" | (query) => boolean | "always"; +``` + +Defined in: [packages/query-core/src/types.ts:448](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L448) + +If set to `true`, the query will refetch on reconnect if the data is stale. +If set to `false`, the query will not refetch on reconnect. +If set to `'always'`, the query will always refetch on reconnect (except when `staleTime: 'static'` is used). +If set to a function, the function will be executed with the latest data and query to compute the value. + +Defaults to `true` unless `networkMode` is `'always'`. + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`refetchOnReconnect`](QueryObserverOptions.md#refetchonreconnect) + +*** + +### refetchOnWindowFocus? + +```ts +optional refetchOnWindowFocus: boolean | "always" | (query) => boolean | "always"; +``` + +Defined in: [packages/query-core/src/types.ts:434](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L434) + +If set to `true`, the query will refetch on window focus if the data is stale. +If set to `false`, the query will not refetch on window focus. +If set to `'always'`, the query will always refetch on window focus (except when `staleTime: 'static'` is used). +If set to a function, the function will be executed with the latest data and query to compute the value. + +Defaults to `true`. + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`refetchOnWindowFocus`](QueryObserverOptions.md#refetchonwindowfocus) + +*** + +### retry? + +```ts +optional retry: RetryValue; +``` + +Defined in: [packages/query-core/src/types.ts:246](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L246) + +If `false`, failed queries will not retry by default. +If `true`, failed queries will retry infinitely. +If set to an integer number, e.g. 3, failed queries will retry until the failed query count meets that number. +If set to a function `(failureCount, error) => boolean` failed queries will retry until the function returns false. + +Defaults to `3` on the client and `0` on the server. + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`retry`](QueryObserverOptions.md#retry) + +*** + +### retryDelay? + +```ts +optional retryDelay: RetryDelayValue; +``` + +Defined in: [packages/query-core/src/types.ts:258](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L258) + +This function receives a `retryAttempt` integer and the actual Error and returns the delay to apply before the +next attempt in milliseconds. + +A function like `attempt => Math.min(attempt > 1 ? 2 ** attempt * 1000 : 1000, 30 * 1000)` applies exponential +backoff. + +A function like `attempt => attempt * 1000` applies linear backoff. + +Defaults to a function that applies exponential backoff, capped at 30 seconds. + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`retryDelay`](QueryObserverOptions.md#retrydelay) + +*** + +### retryOnMount? + +```ts +optional retryOnMount: QueryBooleanOption, TQueryKey>; +``` + +Defined in: [packages/query-core/src/types.ts:474](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L474) + +If set to `false`, the query will not be retried on mount if it contains an error. +If set to a function, the function will be executed with the query to compute the value. + +Defaults to `true`. + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`retryOnMount`](QueryObserverOptions.md#retryonmount) + +*** + +### select()? + +```ts +optional select: (data) => TData; +``` + +Defined in: [packages/query-core/src/types.ts:500](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L500) + +This option can be used to transform or select a part of the data returned by the query function. It affects +the returned `data` value, but does not affect what gets stored in the query cache. +The `select` function will only run if `data` changed, or if the reference to the `select` function itself +changes. To optimize, memoize the function so its reference stays stable across calls. + +#### Parameters + +##### data + +[`InfiniteData`](InfiniteData.md) + +#### Returns + +`TData` + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`select`](QueryObserverOptions.md#select) + +*** + +### staleTime? + +```ts +optional staleTime: StaleTimeFunction, TQueryKey>; +``` + +Defined in: [packages/query-core/src/types.ts:407](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L407) + +The time in milliseconds after data is considered stale. +If set to `Infinity`, the data will never be considered stale. +If set to `'static'`, the data will never be considered stale. +If set to a function, the function will be executed with the query to compute a `staleTime`. + +Defaults to `0`. + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`staleTime`](QueryObserverOptions.md#staletime) + +*** + +### structuralSharing? + +```ts +optional structuralSharing: boolean | (oldData, newData) => unknown; +``` + +Defined in: [packages/query-core/src/types.ts:330](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L330) + +Set this to `false` to disable structural sharing between query results. +Set this to a function which accepts the old and new data and returns resolved data of the same type to implement custom structural sharing logic. + +Defaults to `true`. + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`structuralSharing`](QueryObserverOptions.md#structuralsharing) + +*** + +### suspense? + +```ts +optional suspense: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:507](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L507) + +If set to `true`, the query will suspend when `status === 'pending'` +and throw errors when `status === 'error'`. + +Defaults to `false`. + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`suspense`](QueryObserverOptions.md#suspense) + +*** + +### throwOnError? + +```ts +optional throwOnError: ThrowOnError, TQueryKey>; +``` + +Defined in: [packages/query-core/src/types.ts:493](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L493) + +Whether errors should be thrown instead of setting the `error` property. +If set to `true` or `suspense` is `true`, all errors will be thrown to the error boundary. +If set to `false` and `suspense` is `false`, errors are returned as state. +If set to a function, it will be passed the error and the query, and it should return a boolean indicating whether to show the error in an error boundary (`true`) or return the error as state (`false`). + +Defaults to `false`. + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`throwOnError`](QueryObserverOptions.md#throwonerror) diff --git a/docs/framework/preact/reference/interfaces/InfiniteQueryObserverPendingResult.md b/docs/framework/preact/reference/interfaces/InfiniteQueryObserverPendingResult.md new file mode 100644 index 00000000000..a09301ab6c4 --- /dev/null +++ b/docs/framework/preact/reference/interfaces/InfiniteQueryObserverPendingResult.md @@ -0,0 +1,600 @@ +--- +id: InfiniteQueryObserverPendingResult +title: InfiniteQueryObserverPendingResult +--- + +Defined in: [packages/query-core/src/types.ts:1043](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1043) + +## Extends + +- [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md)\<`TData`, `TError`\> + +## Type Parameters + +### TData + +`TData` = `unknown` + +### TError + +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) + +## Properties + +### data + +```ts +data: undefined; +``` + +Defined in: [packages/query-core/src/types.ts:1047](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1047) + +The last successfully resolved data for the query. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`data`](InfiniteQueryObserverBaseResult.md#data) + +*** + +### dataUpdatedAt + +```ts +dataUpdatedAt: number; +``` + +Defined in: [packages/query-core/src/types.ts:775](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L775) + +The timestamp for when the query most recently returned the `status` as `"success"`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`dataUpdatedAt`](InfiniteQueryObserverBaseResult.md#dataupdatedat) + +*** + +### error + +```ts +error: null; +``` + +Defined in: [packages/query-core/src/types.ts:1048](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1048) + +The error object for the query, if an error was thrown. +- Defaults to `null`. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`error`](InfiniteQueryObserverBaseResult.md#error) + +*** + +### errorUpdateCount + +```ts +errorUpdateCount: number; +``` + +Defined in: [packages/query-core/src/types.ts:799](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L799) + +The sum of all errors. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`errorUpdateCount`](InfiniteQueryObserverBaseResult.md#errorupdatecount) + +*** + +### errorUpdatedAt + +```ts +errorUpdatedAt: number; +``` + +Defined in: [packages/query-core/src/types.ts:784](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L784) + +The timestamp for when the query most recently returned the `status` as `"error"`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`errorUpdatedAt`](InfiniteQueryObserverBaseResult.md#errorupdatedat) + +*** + +### failureCount + +```ts +failureCount: number; +``` + +Defined in: [packages/query-core/src/types.ts:790](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L790) + +The failure count for the query. +- Incremented every time the query fails. +- Reset to `0` when the query succeeds. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`failureCount`](InfiniteQueryObserverBaseResult.md#failurecount) + +*** + +### failureReason + +```ts +failureReason: TError | null; +``` + +Defined in: [packages/query-core/src/types.ts:795](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L795) + +The failure reason for the query retry. +- Reset to `null` when the query succeeds. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`failureReason`](InfiniteQueryObserverBaseResult.md#failurereason) + +*** + +### fetchNextPage() + +```ts +fetchNextPage: (options?) => Promise>; +``` + +Defined in: [packages/query-core/src/types.ts:1008](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1008) + +This function allows you to fetch the next "page" of results. + +#### Parameters + +##### options? + +[`FetchNextPageOptions`](FetchNextPageOptions.md) + +#### Returns + +`Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`fetchNextPage`](InfiniteQueryObserverBaseResult.md#fetchnextpage) + +*** + +### fetchPreviousPage() + +```ts +fetchPreviousPage: (options?) => Promise>; +``` + +Defined in: [packages/query-core/src/types.ts:1014](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1014) + +This function allows you to fetch the previous "page" of results. + +#### Parameters + +##### options? + +[`FetchPreviousPageOptions`](FetchPreviousPageOptions.md) + +#### Returns + +`Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`fetchPreviousPage`](InfiniteQueryObserverBaseResult.md#fetchpreviouspage) + +*** + +### fetchStatus + +```ts +fetchStatus: FetchStatus; +``` + +Defined in: [packages/query-core/src/types.ts:889](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L889) + +The fetch status of the query. +- `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. +- `paused`: The query wanted to fetch, but has been `paused`. +- `idle`: The query is not fetching. +- See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`fetchStatus`](InfiniteQueryObserverBaseResult.md#fetchstatus) + +*** + +### hasNextPage + +```ts +hasNextPage: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1020](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1020) + +Will be `true` if there is a next page to be fetched (known via the `getNextPageParam` option). + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`hasNextPage`](InfiniteQueryObserverBaseResult.md#hasnextpage) + +*** + +### hasPreviousPage + +```ts +hasPreviousPage: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1024](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1024) + +Will be `true` if there is a previous page to be fetched (known via the `getPreviousPageParam` option). + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`hasPreviousPage`](InfiniteQueryObserverBaseResult.md#haspreviouspage) + +*** + +### isEnabled + +```ts +isEnabled: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:867](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L867) + +`true` if this observer is enabled, `false` otherwise. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isEnabled`](InfiniteQueryObserverBaseResult.md#isenabled) + +*** + +### isError + +```ts +isError: false; +``` + +Defined in: [packages/query-core/src/types.ts:1049](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1049) + +A derived boolean from the `status` variable, provided for convenience. +- `true` if the query attempt resulted in an error. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isError`](InfiniteQueryObserverBaseResult.md#iserror) + +*** + +### isFetched + +```ts +isFetched: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:808](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L808) + +Will be `true` if the query has been fetched. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetched`](InfiniteQueryObserverBaseResult.md#isfetched) + +*** + +### isFetchedAfterMount + +```ts +isFetchedAfterMount: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:813](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L813) + +Will be `true` if the query has been fetched after the component mounted. +- This property can be used to not show any previously cached data. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchedAfterMount`](InfiniteQueryObserverBaseResult.md#isfetchedaftermount) + +*** + +### isFetching + +```ts +isFetching: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:818](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L818) + +A derived boolean from the `fetchStatus` variable, provided for convenience. +- `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetching`](InfiniteQueryObserverBaseResult.md#isfetching) + +*** + +### isFetchingNextPage + +```ts +isFetchingNextPage: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1032](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1032) + +Will be `true` while fetching the next page with `fetchNextPage`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchingNextPage`](InfiniteQueryObserverBaseResult.md#isfetchingnextpage) + +*** + +### isFetchingPreviousPage + +```ts +isFetchingPreviousPage: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1040](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1040) + +Will be `true` while fetching the previous page with `fetchPreviousPage`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchingPreviousPage`](InfiniteQueryObserverBaseResult.md#isfetchingpreviouspage) + +*** + +### isFetchNextPageError + +```ts +isFetchNextPageError: false; +``` + +Defined in: [packages/query-core/src/types.ts:1053](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1053) + +Will be `true` if the query failed while fetching the next page. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchNextPageError`](InfiniteQueryObserverBaseResult.md#isfetchnextpageerror) + +*** + +### isFetchPreviousPageError + +```ts +isFetchPreviousPageError: false; +``` + +Defined in: [packages/query-core/src/types.ts:1054](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1054) + +Will be `true` if the query failed while fetching the previous page. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchPreviousPageError`](InfiniteQueryObserverBaseResult.md#isfetchpreviouspageerror) + +*** + +### ~~isInitialLoading~~ + +```ts +isInitialLoading: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:836](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L836) + +#### Deprecated + +`isInitialLoading` is being deprecated in favor of `isLoading` +and will be removed in the next major version. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isInitialLoading`](InfiniteQueryObserverBaseResult.md#isinitialloading) + +*** + +### isLoading + +```ts +isLoading: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:823](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L823) + +Is `true` whenever the first fetch for a query is in-flight. +- Is the same as `isFetching && isPending`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoading`](InfiniteQueryObserverBaseResult.md#isloading) + +*** + +### isLoadingError + +```ts +isLoadingError: false; +``` + +Defined in: [packages/query-core/src/types.ts:1051](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1051) + +Will be `true` if the query failed while fetching for the first time. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoadingError`](InfiniteQueryObserverBaseResult.md#isloadingerror) + +*** + +### isPaused + +```ts +isPaused: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:841](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L841) + +A derived boolean from the `fetchStatus` variable, provided for convenience. +- The query wanted to fetch, but has been `paused`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPaused`](InfiniteQueryObserverBaseResult.md#ispaused) + +*** + +### isPending + +```ts +isPending: true; +``` + +Defined in: [packages/query-core/src/types.ts:1050](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1050) + +Will be `pending` if there's no cached data and no query attempt was finished yet. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPending`](InfiniteQueryObserverBaseResult.md#ispending) + +*** + +### isPlaceholderData + +```ts +isPlaceholderData: false; +``` + +Defined in: [packages/query-core/src/types.ts:1056](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1056) + +Will be `true` if the data shown is the placeholder data. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPlaceholderData`](InfiniteQueryObserverBaseResult.md#isplaceholderdata) + +*** + +### isRefetchError + +```ts +isRefetchError: false; +``` + +Defined in: [packages/query-core/src/types.ts:1052](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1052) + +Will be `true` if the query failed while refetching. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isRefetchError`](InfiniteQueryObserverBaseResult.md#isrefetcherror) + +*** + +### isRefetching + +```ts +isRefetching: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:854](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L854) + +Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. +- Is the same as `isFetching && !isPending`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isRefetching`](InfiniteQueryObserverBaseResult.md#isrefetching) + +*** + +### isStale + +```ts +isStale: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:858](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L858) + +Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isStale`](InfiniteQueryObserverBaseResult.md#isstale) + +*** + +### isSuccess + +```ts +isSuccess: false; +``` + +Defined in: [packages/query-core/src/types.ts:1055](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1055) + +A derived boolean from the `status` variable, provided for convenience. +- `true` if the query has received a response with no errors and is ready to display its data. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isSuccess`](InfiniteQueryObserverBaseResult.md#issuccess) + +*** + +### refetch() + +```ts +refetch: (options?) => Promise>; +``` + +Defined in: [packages/query-core/src/types.ts:871](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L871) + +A function to manually refetch the query. + +#### Parameters + +##### options? + +[`RefetchOptions`](RefetchOptions.md) + +#### Returns + +`Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`refetch`](InfiniteQueryObserverBaseResult.md#refetch) + +*** + +### status + +```ts +status: "pending"; +``` + +Defined in: [packages/query-core/src/types.ts:1057](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1057) + +The status of the query. +- Will be: + - `pending` if there's no cached data and no query attempt was finished yet. + - `error` if the query attempt resulted in an error. + - `success` if the query has received a response with no errors and is ready to display its data. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`status`](InfiniteQueryObserverBaseResult.md#status) diff --git a/docs/framework/preact/reference/interfaces/InfiniteQueryObserverPlaceholderResult.md b/docs/framework/preact/reference/interfaces/InfiniteQueryObserverPlaceholderResult.md new file mode 100644 index 00000000000..58193a987d1 --- /dev/null +++ b/docs/framework/preact/reference/interfaces/InfiniteQueryObserverPlaceholderResult.md @@ -0,0 +1,600 @@ +--- +id: InfiniteQueryObserverPlaceholderResult +title: InfiniteQueryObserverPlaceholderResult +--- + +Defined in: [packages/query-core/src/types.ts:1130](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1130) + +## Extends + +- [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md)\<`TData`, `TError`\> + +## Type Parameters + +### TData + +`TData` = `unknown` + +### TError + +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) + +## Properties + +### data + +```ts +data: TData; +``` + +Defined in: [packages/query-core/src/types.ts:1134](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1134) + +The last successfully resolved data for the query. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`data`](InfiniteQueryObserverBaseResult.md#data) + +*** + +### dataUpdatedAt + +```ts +dataUpdatedAt: number; +``` + +Defined in: [packages/query-core/src/types.ts:775](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L775) + +The timestamp for when the query most recently returned the `status` as `"success"`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`dataUpdatedAt`](InfiniteQueryObserverBaseResult.md#dataupdatedat) + +*** + +### error + +```ts +error: null; +``` + +Defined in: [packages/query-core/src/types.ts:1136](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1136) + +The error object for the query, if an error was thrown. +- Defaults to `null`. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`error`](InfiniteQueryObserverBaseResult.md#error) + +*** + +### errorUpdateCount + +```ts +errorUpdateCount: number; +``` + +Defined in: [packages/query-core/src/types.ts:799](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L799) + +The sum of all errors. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`errorUpdateCount`](InfiniteQueryObserverBaseResult.md#errorupdatecount) + +*** + +### errorUpdatedAt + +```ts +errorUpdatedAt: number; +``` + +Defined in: [packages/query-core/src/types.ts:784](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L784) + +The timestamp for when the query most recently returned the `status` as `"error"`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`errorUpdatedAt`](InfiniteQueryObserverBaseResult.md#errorupdatedat) + +*** + +### failureCount + +```ts +failureCount: number; +``` + +Defined in: [packages/query-core/src/types.ts:790](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L790) + +The failure count for the query. +- Incremented every time the query fails. +- Reset to `0` when the query succeeds. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`failureCount`](InfiniteQueryObserverBaseResult.md#failurecount) + +*** + +### failureReason + +```ts +failureReason: TError | null; +``` + +Defined in: [packages/query-core/src/types.ts:795](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L795) + +The failure reason for the query retry. +- Reset to `null` when the query succeeds. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`failureReason`](InfiniteQueryObserverBaseResult.md#failurereason) + +*** + +### fetchNextPage() + +```ts +fetchNextPage: (options?) => Promise>; +``` + +Defined in: [packages/query-core/src/types.ts:1008](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1008) + +This function allows you to fetch the next "page" of results. + +#### Parameters + +##### options? + +[`FetchNextPageOptions`](FetchNextPageOptions.md) + +#### Returns + +`Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`fetchNextPage`](InfiniteQueryObserverBaseResult.md#fetchnextpage) + +*** + +### fetchPreviousPage() + +```ts +fetchPreviousPage: (options?) => Promise>; +``` + +Defined in: [packages/query-core/src/types.ts:1014](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1014) + +This function allows you to fetch the previous "page" of results. + +#### Parameters + +##### options? + +[`FetchPreviousPageOptions`](FetchPreviousPageOptions.md) + +#### Returns + +`Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`fetchPreviousPage`](InfiniteQueryObserverBaseResult.md#fetchpreviouspage) + +*** + +### fetchStatus + +```ts +fetchStatus: FetchStatus; +``` + +Defined in: [packages/query-core/src/types.ts:889](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L889) + +The fetch status of the query. +- `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. +- `paused`: The query wanted to fetch, but has been `paused`. +- `idle`: The query is not fetching. +- See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`fetchStatus`](InfiniteQueryObserverBaseResult.md#fetchstatus) + +*** + +### hasNextPage + +```ts +hasNextPage: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1020](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1020) + +Will be `true` if there is a next page to be fetched (known via the `getNextPageParam` option). + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`hasNextPage`](InfiniteQueryObserverBaseResult.md#hasnextpage) + +*** + +### hasPreviousPage + +```ts +hasPreviousPage: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1024](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1024) + +Will be `true` if there is a previous page to be fetched (known via the `getPreviousPageParam` option). + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`hasPreviousPage`](InfiniteQueryObserverBaseResult.md#haspreviouspage) + +*** + +### isEnabled + +```ts +isEnabled: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:867](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L867) + +`true` if this observer is enabled, `false` otherwise. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isEnabled`](InfiniteQueryObserverBaseResult.md#isenabled) + +*** + +### isError + +```ts +isError: false; +``` + +Defined in: [packages/query-core/src/types.ts:1135](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1135) + +A derived boolean from the `status` variable, provided for convenience. +- `true` if the query attempt resulted in an error. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isError`](InfiniteQueryObserverBaseResult.md#iserror) + +*** + +### isFetched + +```ts +isFetched: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:808](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L808) + +Will be `true` if the query has been fetched. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetched`](InfiniteQueryObserverBaseResult.md#isfetched) + +*** + +### isFetchedAfterMount + +```ts +isFetchedAfterMount: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:813](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L813) + +Will be `true` if the query has been fetched after the component mounted. +- This property can be used to not show any previously cached data. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchedAfterMount`](InfiniteQueryObserverBaseResult.md#isfetchedaftermount) + +*** + +### isFetching + +```ts +isFetching: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:818](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L818) + +A derived boolean from the `fetchStatus` variable, provided for convenience. +- `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetching`](InfiniteQueryObserverBaseResult.md#isfetching) + +*** + +### isFetchingNextPage + +```ts +isFetchingNextPage: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1032](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1032) + +Will be `true` while fetching the next page with `fetchNextPage`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchingNextPage`](InfiniteQueryObserverBaseResult.md#isfetchingnextpage) + +*** + +### isFetchingPreviousPage + +```ts +isFetchingPreviousPage: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1040](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1040) + +Will be `true` while fetching the previous page with `fetchPreviousPage`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchingPreviousPage`](InfiniteQueryObserverBaseResult.md#isfetchingpreviouspage) + +*** + +### isFetchNextPageError + +```ts +isFetchNextPageError: false; +``` + +Defined in: [packages/query-core/src/types.ts:1143](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1143) + +Will be `true` if the query failed while fetching the next page. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchNextPageError`](InfiniteQueryObserverBaseResult.md#isfetchnextpageerror) + +*** + +### isFetchPreviousPageError + +```ts +isFetchPreviousPageError: false; +``` + +Defined in: [packages/query-core/src/types.ts:1144](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1144) + +Will be `true` if the query failed while fetching the previous page. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchPreviousPageError`](InfiniteQueryObserverBaseResult.md#isfetchpreviouspageerror) + +*** + +### ~~isInitialLoading~~ + +```ts +isInitialLoading: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:836](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L836) + +#### Deprecated + +`isInitialLoading` is being deprecated in favor of `isLoading` +and will be removed in the next major version. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isInitialLoading`](InfiniteQueryObserverBaseResult.md#isinitialloading) + +*** + +### isLoading + +```ts +isLoading: false; +``` + +Defined in: [packages/query-core/src/types.ts:1138](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1138) + +Is `true` whenever the first fetch for a query is in-flight. +- Is the same as `isFetching && isPending`. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoading`](InfiniteQueryObserverBaseResult.md#isloading) + +*** + +### isLoadingError + +```ts +isLoadingError: false; +``` + +Defined in: [packages/query-core/src/types.ts:1139](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1139) + +Will be `true` if the query failed while fetching for the first time. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoadingError`](InfiniteQueryObserverBaseResult.md#isloadingerror) + +*** + +### isPaused + +```ts +isPaused: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:841](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L841) + +A derived boolean from the `fetchStatus` variable, provided for convenience. +- The query wanted to fetch, but has been `paused`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPaused`](InfiniteQueryObserverBaseResult.md#ispaused) + +*** + +### isPending + +```ts +isPending: false; +``` + +Defined in: [packages/query-core/src/types.ts:1137](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1137) + +Will be `pending` if there's no cached data and no query attempt was finished yet. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPending`](InfiniteQueryObserverBaseResult.md#ispending) + +*** + +### isPlaceholderData + +```ts +isPlaceholderData: true; +``` + +Defined in: [packages/query-core/src/types.ts:1142](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1142) + +Will be `true` if the data shown is the placeholder data. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPlaceholderData`](InfiniteQueryObserverBaseResult.md#isplaceholderdata) + +*** + +### isRefetchError + +```ts +isRefetchError: false; +``` + +Defined in: [packages/query-core/src/types.ts:1140](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1140) + +Will be `true` if the query failed while refetching. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isRefetchError`](InfiniteQueryObserverBaseResult.md#isrefetcherror) + +*** + +### isRefetching + +```ts +isRefetching: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:854](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L854) + +Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. +- Is the same as `isFetching && !isPending`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isRefetching`](InfiniteQueryObserverBaseResult.md#isrefetching) + +*** + +### isStale + +```ts +isStale: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:858](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L858) + +Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isStale`](InfiniteQueryObserverBaseResult.md#isstale) + +*** + +### isSuccess + +```ts +isSuccess: true; +``` + +Defined in: [packages/query-core/src/types.ts:1141](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1141) + +A derived boolean from the `status` variable, provided for convenience. +- `true` if the query has received a response with no errors and is ready to display its data. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isSuccess`](InfiniteQueryObserverBaseResult.md#issuccess) + +*** + +### refetch() + +```ts +refetch: (options?) => Promise>; +``` + +Defined in: [packages/query-core/src/types.ts:871](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L871) + +A function to manually refetch the query. + +#### Parameters + +##### options? + +[`RefetchOptions`](RefetchOptions.md) + +#### Returns + +`Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`refetch`](InfiniteQueryObserverBaseResult.md#refetch) + +*** + +### status + +```ts +status: "success"; +``` + +Defined in: [packages/query-core/src/types.ts:1145](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1145) + +The status of the query. +- Will be: + - `pending` if there's no cached data and no query attempt was finished yet. + - `error` if the query attempt resulted in an error. + - `success` if the query has received a response with no errors and is ready to display its data. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`status`](InfiniteQueryObserverBaseResult.md#status) diff --git a/docs/framework/preact/reference/interfaces/InfiniteQueryObserverRefetchErrorResult.md b/docs/framework/preact/reference/interfaces/InfiniteQueryObserverRefetchErrorResult.md new file mode 100644 index 00000000000..4ce469bceed --- /dev/null +++ b/docs/framework/preact/reference/interfaces/InfiniteQueryObserverRefetchErrorResult.md @@ -0,0 +1,600 @@ +--- +id: InfiniteQueryObserverRefetchErrorResult +title: InfiniteQueryObserverRefetchErrorResult +--- + +Defined in: [packages/query-core/src/types.ts:1096](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1096) + +## Extends + +- [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md)\<`TData`, `TError`\> + +## Type Parameters + +### TData + +`TData` = `unknown` + +### TError + +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) + +## Properties + +### data + +```ts +data: TData; +``` + +Defined in: [packages/query-core/src/types.ts:1100](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1100) + +The last successfully resolved data for the query. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`data`](InfiniteQueryObserverBaseResult.md#data) + +*** + +### dataUpdatedAt + +```ts +dataUpdatedAt: number; +``` + +Defined in: [packages/query-core/src/types.ts:775](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L775) + +The timestamp for when the query most recently returned the `status` as `"success"`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`dataUpdatedAt`](InfiniteQueryObserverBaseResult.md#dataupdatedat) + +*** + +### error + +```ts +error: TError; +``` + +Defined in: [packages/query-core/src/types.ts:1101](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1101) + +The error object for the query, if an error was thrown. +- Defaults to `null`. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`error`](InfiniteQueryObserverBaseResult.md#error) + +*** + +### errorUpdateCount + +```ts +errorUpdateCount: number; +``` + +Defined in: [packages/query-core/src/types.ts:799](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L799) + +The sum of all errors. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`errorUpdateCount`](InfiniteQueryObserverBaseResult.md#errorupdatecount) + +*** + +### errorUpdatedAt + +```ts +errorUpdatedAt: number; +``` + +Defined in: [packages/query-core/src/types.ts:784](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L784) + +The timestamp for when the query most recently returned the `status` as `"error"`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`errorUpdatedAt`](InfiniteQueryObserverBaseResult.md#errorupdatedat) + +*** + +### failureCount + +```ts +failureCount: number; +``` + +Defined in: [packages/query-core/src/types.ts:790](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L790) + +The failure count for the query. +- Incremented every time the query fails. +- Reset to `0` when the query succeeds. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`failureCount`](InfiniteQueryObserverBaseResult.md#failurecount) + +*** + +### failureReason + +```ts +failureReason: TError | null; +``` + +Defined in: [packages/query-core/src/types.ts:795](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L795) + +The failure reason for the query retry. +- Reset to `null` when the query succeeds. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`failureReason`](InfiniteQueryObserverBaseResult.md#failurereason) + +*** + +### fetchNextPage() + +```ts +fetchNextPage: (options?) => Promise>; +``` + +Defined in: [packages/query-core/src/types.ts:1008](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1008) + +This function allows you to fetch the next "page" of results. + +#### Parameters + +##### options? + +[`FetchNextPageOptions`](FetchNextPageOptions.md) + +#### Returns + +`Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`fetchNextPage`](InfiniteQueryObserverBaseResult.md#fetchnextpage) + +*** + +### fetchPreviousPage() + +```ts +fetchPreviousPage: (options?) => Promise>; +``` + +Defined in: [packages/query-core/src/types.ts:1014](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1014) + +This function allows you to fetch the previous "page" of results. + +#### Parameters + +##### options? + +[`FetchPreviousPageOptions`](FetchPreviousPageOptions.md) + +#### Returns + +`Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`fetchPreviousPage`](InfiniteQueryObserverBaseResult.md#fetchpreviouspage) + +*** + +### fetchStatus + +```ts +fetchStatus: FetchStatus; +``` + +Defined in: [packages/query-core/src/types.ts:889](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L889) + +The fetch status of the query. +- `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. +- `paused`: The query wanted to fetch, but has been `paused`. +- `idle`: The query is not fetching. +- See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`fetchStatus`](InfiniteQueryObserverBaseResult.md#fetchstatus) + +*** + +### hasNextPage + +```ts +hasNextPage: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1020](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1020) + +Will be `true` if there is a next page to be fetched (known via the `getNextPageParam` option). + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`hasNextPage`](InfiniteQueryObserverBaseResult.md#hasnextpage) + +*** + +### hasPreviousPage + +```ts +hasPreviousPage: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1024](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1024) + +Will be `true` if there is a previous page to be fetched (known via the `getPreviousPageParam` option). + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`hasPreviousPage`](InfiniteQueryObserverBaseResult.md#haspreviouspage) + +*** + +### isEnabled + +```ts +isEnabled: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:867](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L867) + +`true` if this observer is enabled, `false` otherwise. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isEnabled`](InfiniteQueryObserverBaseResult.md#isenabled) + +*** + +### isError + +```ts +isError: true; +``` + +Defined in: [packages/query-core/src/types.ts:1102](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1102) + +A derived boolean from the `status` variable, provided for convenience. +- `true` if the query attempt resulted in an error. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isError`](InfiniteQueryObserverBaseResult.md#iserror) + +*** + +### isFetched + +```ts +isFetched: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:808](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L808) + +Will be `true` if the query has been fetched. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetched`](InfiniteQueryObserverBaseResult.md#isfetched) + +*** + +### isFetchedAfterMount + +```ts +isFetchedAfterMount: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:813](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L813) + +Will be `true` if the query has been fetched after the component mounted. +- This property can be used to not show any previously cached data. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchedAfterMount`](InfiniteQueryObserverBaseResult.md#isfetchedaftermount) + +*** + +### isFetching + +```ts +isFetching: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:818](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L818) + +A derived boolean from the `fetchStatus` variable, provided for convenience. +- `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetching`](InfiniteQueryObserverBaseResult.md#isfetching) + +*** + +### isFetchingNextPage + +```ts +isFetchingNextPage: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1032](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1032) + +Will be `true` while fetching the next page with `fetchNextPage`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchingNextPage`](InfiniteQueryObserverBaseResult.md#isfetchingnextpage) + +*** + +### isFetchingPreviousPage + +```ts +isFetchingPreviousPage: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1040](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1040) + +Will be `true` while fetching the previous page with `fetchPreviousPage`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchingPreviousPage`](InfiniteQueryObserverBaseResult.md#isfetchingpreviouspage) + +*** + +### isFetchNextPageError + +```ts +isFetchNextPageError: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1028](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1028) + +Will be `true` if the query failed while fetching the next page. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchNextPageError`](InfiniteQueryObserverBaseResult.md#isfetchnextpageerror) + +*** + +### isFetchPreviousPageError + +```ts +isFetchPreviousPageError: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1036](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1036) + +Will be `true` if the query failed while fetching the previous page. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchPreviousPageError`](InfiniteQueryObserverBaseResult.md#isfetchpreviouspageerror) + +*** + +### ~~isInitialLoading~~ + +```ts +isInitialLoading: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:836](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L836) + +#### Deprecated + +`isInitialLoading` is being deprecated in favor of `isLoading` +and will be removed in the next major version. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isInitialLoading`](InfiniteQueryObserverBaseResult.md#isinitialloading) + +*** + +### isLoading + +```ts +isLoading: false; +``` + +Defined in: [packages/query-core/src/types.ts:1104](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1104) + +Is `true` whenever the first fetch for a query is in-flight. +- Is the same as `isFetching && isPending`. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoading`](InfiniteQueryObserverBaseResult.md#isloading) + +*** + +### isLoadingError + +```ts +isLoadingError: false; +``` + +Defined in: [packages/query-core/src/types.ts:1105](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1105) + +Will be `true` if the query failed while fetching for the first time. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoadingError`](InfiniteQueryObserverBaseResult.md#isloadingerror) + +*** + +### isPaused + +```ts +isPaused: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:841](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L841) + +A derived boolean from the `fetchStatus` variable, provided for convenience. +- The query wanted to fetch, but has been `paused`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPaused`](InfiniteQueryObserverBaseResult.md#ispaused) + +*** + +### isPending + +```ts +isPending: false; +``` + +Defined in: [packages/query-core/src/types.ts:1103](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1103) + +Will be `pending` if there's no cached data and no query attempt was finished yet. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPending`](InfiniteQueryObserverBaseResult.md#ispending) + +*** + +### isPlaceholderData + +```ts +isPlaceholderData: false; +``` + +Defined in: [packages/query-core/src/types.ts:1108](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1108) + +Will be `true` if the data shown is the placeholder data. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPlaceholderData`](InfiniteQueryObserverBaseResult.md#isplaceholderdata) + +*** + +### isRefetchError + +```ts +isRefetchError: true; +``` + +Defined in: [packages/query-core/src/types.ts:1106](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1106) + +Will be `true` if the query failed while refetching. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isRefetchError`](InfiniteQueryObserverBaseResult.md#isrefetcherror) + +*** + +### isRefetching + +```ts +isRefetching: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:854](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L854) + +Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. +- Is the same as `isFetching && !isPending`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isRefetching`](InfiniteQueryObserverBaseResult.md#isrefetching) + +*** + +### isStale + +```ts +isStale: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:858](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L858) + +Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isStale`](InfiniteQueryObserverBaseResult.md#isstale) + +*** + +### isSuccess + +```ts +isSuccess: false; +``` + +Defined in: [packages/query-core/src/types.ts:1107](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1107) + +A derived boolean from the `status` variable, provided for convenience. +- `true` if the query has received a response with no errors and is ready to display its data. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isSuccess`](InfiniteQueryObserverBaseResult.md#issuccess) + +*** + +### refetch() + +```ts +refetch: (options?) => Promise>; +``` + +Defined in: [packages/query-core/src/types.ts:871](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L871) + +A function to manually refetch the query. + +#### Parameters + +##### options? + +[`RefetchOptions`](RefetchOptions.md) + +#### Returns + +`Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`refetch`](InfiniteQueryObserverBaseResult.md#refetch) + +*** + +### status + +```ts +status: "error"; +``` + +Defined in: [packages/query-core/src/types.ts:1109](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1109) + +The status of the query. +- Will be: + - `pending` if there's no cached data and no query attempt was finished yet. + - `error` if the query attempt resulted in an error. + - `success` if the query has received a response with no errors and is ready to display its data. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`status`](InfiniteQueryObserverBaseResult.md#status) diff --git a/docs/framework/preact/reference/interfaces/InfiniteQueryObserverSuccessResult.md b/docs/framework/preact/reference/interfaces/InfiniteQueryObserverSuccessResult.md new file mode 100644 index 00000000000..131f6d01ae7 --- /dev/null +++ b/docs/framework/preact/reference/interfaces/InfiniteQueryObserverSuccessResult.md @@ -0,0 +1,600 @@ +--- +id: InfiniteQueryObserverSuccessResult +title: InfiniteQueryObserverSuccessResult +--- + +Defined in: [packages/query-core/src/types.ts:1112](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1112) + +## Extends + +- [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md)\<`TData`, `TError`\> + +## Type Parameters + +### TData + +`TData` = `unknown` + +### TError + +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) + +## Properties + +### data + +```ts +data: TData; +``` + +Defined in: [packages/query-core/src/types.ts:1116](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1116) + +The last successfully resolved data for the query. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`data`](InfiniteQueryObserverBaseResult.md#data) + +*** + +### dataUpdatedAt + +```ts +dataUpdatedAt: number; +``` + +Defined in: [packages/query-core/src/types.ts:775](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L775) + +The timestamp for when the query most recently returned the `status` as `"success"`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`dataUpdatedAt`](InfiniteQueryObserverBaseResult.md#dataupdatedat) + +*** + +### error + +```ts +error: null; +``` + +Defined in: [packages/query-core/src/types.ts:1117](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1117) + +The error object for the query, if an error was thrown. +- Defaults to `null`. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`error`](InfiniteQueryObserverBaseResult.md#error) + +*** + +### errorUpdateCount + +```ts +errorUpdateCount: number; +``` + +Defined in: [packages/query-core/src/types.ts:799](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L799) + +The sum of all errors. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`errorUpdateCount`](InfiniteQueryObserverBaseResult.md#errorupdatecount) + +*** + +### errorUpdatedAt + +```ts +errorUpdatedAt: number; +``` + +Defined in: [packages/query-core/src/types.ts:784](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L784) + +The timestamp for when the query most recently returned the `status` as `"error"`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`errorUpdatedAt`](InfiniteQueryObserverBaseResult.md#errorupdatedat) + +*** + +### failureCount + +```ts +failureCount: number; +``` + +Defined in: [packages/query-core/src/types.ts:790](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L790) + +The failure count for the query. +- Incremented every time the query fails. +- Reset to `0` when the query succeeds. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`failureCount`](InfiniteQueryObserverBaseResult.md#failurecount) + +*** + +### failureReason + +```ts +failureReason: TError | null; +``` + +Defined in: [packages/query-core/src/types.ts:795](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L795) + +The failure reason for the query retry. +- Reset to `null` when the query succeeds. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`failureReason`](InfiniteQueryObserverBaseResult.md#failurereason) + +*** + +### fetchNextPage() + +```ts +fetchNextPage: (options?) => Promise>; +``` + +Defined in: [packages/query-core/src/types.ts:1008](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1008) + +This function allows you to fetch the next "page" of results. + +#### Parameters + +##### options? + +[`FetchNextPageOptions`](FetchNextPageOptions.md) + +#### Returns + +`Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`fetchNextPage`](InfiniteQueryObserverBaseResult.md#fetchnextpage) + +*** + +### fetchPreviousPage() + +```ts +fetchPreviousPage: (options?) => Promise>; +``` + +Defined in: [packages/query-core/src/types.ts:1014](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1014) + +This function allows you to fetch the previous "page" of results. + +#### Parameters + +##### options? + +[`FetchPreviousPageOptions`](FetchPreviousPageOptions.md) + +#### Returns + +`Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`fetchPreviousPage`](InfiniteQueryObserverBaseResult.md#fetchpreviouspage) + +*** + +### fetchStatus + +```ts +fetchStatus: FetchStatus; +``` + +Defined in: [packages/query-core/src/types.ts:889](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L889) + +The fetch status of the query. +- `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. +- `paused`: The query wanted to fetch, but has been `paused`. +- `idle`: The query is not fetching. +- See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`fetchStatus`](InfiniteQueryObserverBaseResult.md#fetchstatus) + +*** + +### hasNextPage + +```ts +hasNextPage: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1020](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1020) + +Will be `true` if there is a next page to be fetched (known via the `getNextPageParam` option). + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`hasNextPage`](InfiniteQueryObserverBaseResult.md#hasnextpage) + +*** + +### hasPreviousPage + +```ts +hasPreviousPage: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1024](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1024) + +Will be `true` if there is a previous page to be fetched (known via the `getPreviousPageParam` option). + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`hasPreviousPage`](InfiniteQueryObserverBaseResult.md#haspreviouspage) + +*** + +### isEnabled + +```ts +isEnabled: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:867](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L867) + +`true` if this observer is enabled, `false` otherwise. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isEnabled`](InfiniteQueryObserverBaseResult.md#isenabled) + +*** + +### isError + +```ts +isError: false; +``` + +Defined in: [packages/query-core/src/types.ts:1118](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1118) + +A derived boolean from the `status` variable, provided for convenience. +- `true` if the query attempt resulted in an error. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isError`](InfiniteQueryObserverBaseResult.md#iserror) + +*** + +### isFetched + +```ts +isFetched: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:808](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L808) + +Will be `true` if the query has been fetched. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetched`](InfiniteQueryObserverBaseResult.md#isfetched) + +*** + +### isFetchedAfterMount + +```ts +isFetchedAfterMount: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:813](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L813) + +Will be `true` if the query has been fetched after the component mounted. +- This property can be used to not show any previously cached data. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchedAfterMount`](InfiniteQueryObserverBaseResult.md#isfetchedaftermount) + +*** + +### isFetching + +```ts +isFetching: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:818](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L818) + +A derived boolean from the `fetchStatus` variable, provided for convenience. +- `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetching`](InfiniteQueryObserverBaseResult.md#isfetching) + +*** + +### isFetchingNextPage + +```ts +isFetchingNextPage: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1032](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1032) + +Will be `true` while fetching the next page with `fetchNextPage`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchingNextPage`](InfiniteQueryObserverBaseResult.md#isfetchingnextpage) + +*** + +### isFetchingPreviousPage + +```ts +isFetchingPreviousPage: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1040](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1040) + +Will be `true` while fetching the previous page with `fetchPreviousPage`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchingPreviousPage`](InfiniteQueryObserverBaseResult.md#isfetchingpreviouspage) + +*** + +### isFetchNextPageError + +```ts +isFetchNextPageError: false; +``` + +Defined in: [packages/query-core/src/types.ts:1123](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1123) + +Will be `true` if the query failed while fetching the next page. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchNextPageError`](InfiniteQueryObserverBaseResult.md#isfetchnextpageerror) + +*** + +### isFetchPreviousPageError + +```ts +isFetchPreviousPageError: false; +``` + +Defined in: [packages/query-core/src/types.ts:1124](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1124) + +Will be `true` if the query failed while fetching the previous page. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchPreviousPageError`](InfiniteQueryObserverBaseResult.md#isfetchpreviouspageerror) + +*** + +### ~~isInitialLoading~~ + +```ts +isInitialLoading: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:836](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L836) + +#### Deprecated + +`isInitialLoading` is being deprecated in favor of `isLoading` +and will be removed in the next major version. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isInitialLoading`](InfiniteQueryObserverBaseResult.md#isinitialloading) + +*** + +### isLoading + +```ts +isLoading: false; +``` + +Defined in: [packages/query-core/src/types.ts:1120](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1120) + +Is `true` whenever the first fetch for a query is in-flight. +- Is the same as `isFetching && isPending`. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoading`](InfiniteQueryObserverBaseResult.md#isloading) + +*** + +### isLoadingError + +```ts +isLoadingError: false; +``` + +Defined in: [packages/query-core/src/types.ts:1121](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1121) + +Will be `true` if the query failed while fetching for the first time. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoadingError`](InfiniteQueryObserverBaseResult.md#isloadingerror) + +*** + +### isPaused + +```ts +isPaused: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:841](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L841) + +A derived boolean from the `fetchStatus` variable, provided for convenience. +- The query wanted to fetch, but has been `paused`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPaused`](InfiniteQueryObserverBaseResult.md#ispaused) + +*** + +### isPending + +```ts +isPending: false; +``` + +Defined in: [packages/query-core/src/types.ts:1119](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1119) + +Will be `pending` if there's no cached data and no query attempt was finished yet. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPending`](InfiniteQueryObserverBaseResult.md#ispending) + +*** + +### isPlaceholderData + +```ts +isPlaceholderData: false; +``` + +Defined in: [packages/query-core/src/types.ts:1126](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1126) + +Will be `true` if the data shown is the placeholder data. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPlaceholderData`](InfiniteQueryObserverBaseResult.md#isplaceholderdata) + +*** + +### isRefetchError + +```ts +isRefetchError: false; +``` + +Defined in: [packages/query-core/src/types.ts:1122](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1122) + +Will be `true` if the query failed while refetching. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isRefetchError`](InfiniteQueryObserverBaseResult.md#isrefetcherror) + +*** + +### isRefetching + +```ts +isRefetching: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:854](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L854) + +Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. +- Is the same as `isFetching && !isPending`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isRefetching`](InfiniteQueryObserverBaseResult.md#isrefetching) + +*** + +### isStale + +```ts +isStale: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:858](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L858) + +Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isStale`](InfiniteQueryObserverBaseResult.md#isstale) + +*** + +### isSuccess + +```ts +isSuccess: true; +``` + +Defined in: [packages/query-core/src/types.ts:1125](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1125) + +A derived boolean from the `status` variable, provided for convenience. +- `true` if the query has received a response with no errors and is ready to display its data. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isSuccess`](InfiniteQueryObserverBaseResult.md#issuccess) + +*** + +### refetch() + +```ts +refetch: (options?) => Promise>; +``` + +Defined in: [packages/query-core/src/types.ts:871](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L871) + +A function to manually refetch the query. + +#### Parameters + +##### options? + +[`RefetchOptions`](RefetchOptions.md) + +#### Returns + +`Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`refetch`](InfiniteQueryObserverBaseResult.md#refetch) + +*** + +### status + +```ts +status: "success"; +``` + +Defined in: [packages/query-core/src/types.ts:1127](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1127) + +The status of the query. +- Will be: + - `pending` if there's no cached data and no query attempt was finished yet. + - `error` if the query attempt resulted in an error. + - `success` if the query has received a response with no errors and is ready to display its data. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`status`](InfiniteQueryObserverBaseResult.md#status) diff --git a/docs/framework/preact/reference/interfaces/InfiniteQueryPageParamsOptions.md b/docs/framework/preact/reference/interfaces/InfiniteQueryPageParamsOptions.md new file mode 100644 index 00000000000..c091cc15456 --- /dev/null +++ b/docs/framework/preact/reference/interfaces/InfiniteQueryPageParamsOptions.md @@ -0,0 +1,64 @@ +--- +id: InfiniteQueryPageParamsOptions +title: InfiniteQueryPageParamsOptions +--- + +Defined in: [packages/query-core/src/types.ts:352](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L352) + +## Extends + +- [`InitialPageParam`](InitialPageParam.md)\<`TPageParam`\> + +## Extended by + +- [`InfiniteQueryObserverOptions`](InfiniteQueryObserverOptions.md) + +## Type Parameters + +### TQueryFnData + +`TQueryFnData` = `unknown` + +### TPageParam + +`TPageParam` = `unknown` + +## Properties + +### getNextPageParam + +```ts +getNextPageParam: GetNextPageParamFunction; +``` + +Defined in: [packages/query-core/src/types.ts:365](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L365) + +This function can be set to automatically get the next cursor for infinite queries. +The result will also be used to determine the value of `hasNextPage`. + +*** + +### getPreviousPageParam? + +```ts +optional getPreviousPageParam: GetPreviousPageParamFunction; +``` + +Defined in: [packages/query-core/src/types.ts:360](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L360) + +This function can be set to automatically get the previous cursor for infinite queries. +The result will also be used to determine the value of `hasPreviousPage`. + +*** + +### initialPageParam + +```ts +initialPageParam: TPageParam; +``` + +Defined in: [packages/query-core/src/types.ts:349](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L349) + +#### Inherited from + +[`InitialPageParam`](InitialPageParam.md).[`initialPageParam`](InitialPageParam.md#initialpageparam) diff --git a/docs/framework/preact/reference/interfaces/InitialPageParam.md b/docs/framework/preact/reference/interfaces/InitialPageParam.md new file mode 100644 index 00000000000..46d2b219ea4 --- /dev/null +++ b/docs/framework/preact/reference/interfaces/InitialPageParam.md @@ -0,0 +1,26 @@ +--- +id: InitialPageParam +title: InitialPageParam +--- + +Defined in: [packages/query-core/src/types.ts:348](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L348) + +## Extended by + +- [`InfiniteQueryPageParamsOptions`](InfiniteQueryPageParamsOptions.md) + +## Type Parameters + +### TPageParam + +`TPageParam` = `unknown` + +## Properties + +### initialPageParam + +```ts +initialPageParam: TPageParam; +``` + +Defined in: [packages/query-core/src/types.ts:349](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L349) diff --git a/docs/framework/preact/reference/interfaces/InvalidateOptions.md b/docs/framework/preact/reference/interfaces/InvalidateOptions.md new file mode 100644 index 00000000000..8a81428b035 --- /dev/null +++ b/docs/framework/preact/reference/interfaces/InvalidateOptions.md @@ -0,0 +1,49 @@ +--- +id: InvalidateOptions +title: InvalidateOptions +--- + +Defined in: [packages/query-core/src/types.ts:734](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L734) + +## Extends + +- [`RefetchOptions`](RefetchOptions.md) + +## Properties + +### cancelRefetch? + +```ts +optional cancelRefetch: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:712](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L712) + +If set to `true`, a currently running request will be cancelled before a new request is made + +If set to `false`, no refetch will be made if there is already a request running. + +Defaults to `true`. + +#### Inherited from + +[`RefetchOptions`](RefetchOptions.md).[`cancelRefetch`](RefetchOptions.md#cancelrefetch) + +*** + +### throwOnError? + +```ts +optional throwOnError: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:701](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L701) + +If set to `true`, the method throws if any of the underlying query refetch tasks fail. + +Defaults to `false`, in which case failed refetches are swallowed and not surfaced to the +caller. + +#### Inherited from + +[`RefetchOptions`](RefetchOptions.md).[`throwOnError`](RefetchOptions.md#throwonerror) diff --git a/docs/framework/preact/reference/interfaces/InvalidateQueryFilters.md b/docs/framework/preact/reference/interfaces/InvalidateQueryFilters.md new file mode 100644 index 00000000000..569e42a4e1b --- /dev/null +++ b/docs/framework/preact/reference/interfaces/InvalidateQueryFilters.md @@ -0,0 +1,145 @@ +--- +id: InvalidateQueryFilters +title: InvalidateQueryFilters +--- + +Defined in: [packages/query-core/src/types.ts:715](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L715) + +Filters used to select queries, for example in `queryClient.getQueriesData` or `queryClient.invalidateQueries`. +All provided filters must match; filters that are left unspecified are ignored. + +## Extends + +- [`QueryFilters`](QueryFilters.md)\<`TQueryKey`\> + +## Type Parameters + +### TQueryKey + +`TQueryKey` *extends* [`QueryKey`](../type-aliases/QueryKey.md) = [`QueryKey`](../type-aliases/QueryKey.md) + +## Properties + +### exact? + +```ts +optional exact: boolean; +``` + +Defined in: [packages/query-core/src/utils.ts:41](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L41) + +Match query key exactly + +#### Inherited from + +[`QueryFilters`](QueryFilters.md).[`exact`](QueryFilters.md#exact) + +*** + +### fetchStatus? + +```ts +optional fetchStatus: FetchStatus; +``` + +Defined in: [packages/query-core/src/utils.ts:57](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L57) + +Include queries matching their fetchStatus + +#### Inherited from + +[`QueryFilters`](QueryFilters.md).[`fetchStatus`](QueryFilters.md#fetchstatus) + +*** + +### predicate()? + +```ts +optional predicate: (query) => boolean; +``` + +Defined in: [packages/query-core/src/utils.ts:45](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L45) + +Include queries matching this predicate function + +#### Parameters + +##### query + +[`Query`](../classes/Query.md) + +#### Returns + +`boolean` + +#### Inherited from + +[`QueryFilters`](QueryFilters.md).[`predicate`](QueryFilters.md#predicate) + +*** + +### queryKey? + +```ts +optional queryKey: TQueryKey | TuplePrefixes; +``` + +Defined in: [packages/query-core/src/utils.ts:49](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L49) + +Include queries matching this query key + +#### Inherited from + +[`QueryFilters`](QueryFilters.md).[`queryKey`](QueryFilters.md#querykey) + +*** + +### refetchType? + +```ts +optional refetchType: QueryTypeFilter | "none"; +``` + +Defined in: [packages/query-core/src/types.ts:727](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L727) + +Controls which of the matched (now-invalidated) queries are refetched in the background. + +Defaults to `'active'`. +- `'active'`: only queries with at least one active observer are refetched. +- `'inactive'`: only queries with no active observer are refetched. +- `'all'`: every matched query is refetched, active or not. +- `'none'`: no query is refetched; matched queries are only marked as invalidated. + +*** + +### stale? + +```ts +optional stale: boolean; +``` + +Defined in: [packages/query-core/src/utils.ts:53](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L53) + +Include or exclude stale queries + +#### Inherited from + +[`QueryFilters`](QueryFilters.md).[`stale`](QueryFilters.md#stale) + +*** + +### type? + +```ts +optional type: QueryTypeFilter; +``` + +Defined in: [packages/query-core/src/utils.ts:37](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L37) + +Filter to active queries, inactive queries or all queries + +Defaults to `'all'`. + +#### Inherited from + +[`QueryFilters`](QueryFilters.md).[`type`](QueryFilters.md#type) diff --git a/docs/framework/preact/reference/interfaces/MutateOptions.md b/docs/framework/preact/reference/interfaces/MutateOptions.md new file mode 100644 index 00000000000..34e2a4d4d7e --- /dev/null +++ b/docs/framework/preact/reference/interfaces/MutateOptions.md @@ -0,0 +1,124 @@ +--- +id: MutateOptions +title: MutateOptions +--- + +Defined in: [packages/query-core/src/types.ts:1284](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1284) + +## Type Parameters + +### TData + +`TData` = `unknown` + +### TError + +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) + +### TVariables + +`TVariables` = `void` + +### TOnMutateResult + +`TOnMutateResult` = `unknown` + +## Properties + +### onError()? + +```ts +optional onError: (error, variables, onMutateResult, context) => void; +``` + +Defined in: [packages/query-core/src/types.ts:1296](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1296) + +#### Parameters + +##### error + +`TError` + +##### variables + +`TVariables` + +##### onMutateResult + +`TOnMutateResult` | `undefined` + +##### context + +[`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md) + +#### Returns + +`void` + +*** + +### onSettled()? + +```ts +optional onSettled: (data, error, variables, onMutateResult, context) => void; +``` + +Defined in: [packages/query-core/src/types.ts:1302](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1302) + +#### Parameters + +##### data + +`TData` | `undefined` + +##### error + +`TError` | `null` + +##### variables + +`TVariables` + +##### onMutateResult + +`TOnMutateResult` | `undefined` + +##### context + +[`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md) + +#### Returns + +`void` + +*** + +### onSuccess()? + +```ts +optional onSuccess: (data, variables, onMutateResult, context) => void; +``` + +Defined in: [packages/query-core/src/types.ts:1290](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1290) + +#### Parameters + +##### data + +`TData` + +##### variables + +`TVariables` + +##### onMutateResult + +`TOnMutateResult` | `undefined` + +##### context + +[`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md) + +#### Returns + +`void` diff --git a/docs/framework/preact/reference/interfaces/MutationCacheConfig.md b/docs/framework/preact/reference/interfaces/MutationCacheConfig.md new file mode 100644 index 00000000000..c38d2dc26f4 --- /dev/null +++ b/docs/framework/preact/reference/interfaces/MutationCacheConfig.md @@ -0,0 +1,161 @@ +--- +id: MutationCacheConfig +title: MutationCacheConfig +--- + +Defined in: [packages/query-core/src/mutationCache.ts:26](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationCache.ts#L26) + +Global callbacks that fire for every mutation handled by a `MutationCache`, regardless of which +component or observer triggered it. They differ from the `defaultOptions` provided to a +`QueryClient` in two ways: `defaultOptions` can be overridden by each mutation, while these +callbacks are always called, and `onMutate` here does not allow returning a result. + +If a callback returns a promise, it will be awaited before the mutation continues. + +## Properties + +### onError()? + +```ts +optional onError: (error, variables, onMutateResult, mutation, context) => unknown; +``` + +Defined in: [packages/query-core/src/mutationCache.ts:28](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationCache.ts#L28) + +Called when any mutation in the cache encounters an error. + +#### Parameters + +##### error + +`Error` + +##### variables + +`unknown` + +##### onMutateResult + +`unknown` + +##### mutation + +[`Mutation`](../classes/Mutation.md)\<`unknown`, `unknown`, `unknown`\> + +##### context + +[`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md) + +#### Returns + +`unknown` + +*** + +### onMutate()? + +```ts +optional onMutate: (variables, mutation, context) => unknown; +``` + +Defined in: [packages/query-core/src/mutationCache.ts:44](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationCache.ts#L44) + +Called before any mutation in the cache executes. + +#### Parameters + +##### variables + +`unknown` + +##### mutation + +[`Mutation`](../classes/Mutation.md)\<`unknown`, `unknown`, `unknown`\> + +##### context + +[`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md) + +#### Returns + +`unknown` + +*** + +### onSettled()? + +```ts +optional onSettled: (data, error, variables, onMutateResult, mutation, context) => unknown; +``` + +Defined in: [packages/query-core/src/mutationCache.ts:50](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationCache.ts#L50) + +Called when any mutation in the cache is settled, either successfully or with an error. + +#### Parameters + +##### data + +`unknown` + +##### error + +`Error` | `null` + +##### variables + +`unknown` + +##### onMutateResult + +`unknown` + +##### mutation + +[`Mutation`](../classes/Mutation.md)\<`unknown`, `unknown`, `unknown`\> + +##### context + +[`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md) + +#### Returns + +`unknown` + +*** + +### onSuccess()? + +```ts +optional onSuccess: (data, variables, onMutateResult, mutation, context) => unknown; +``` + +Defined in: [packages/query-core/src/mutationCache.ts:36](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationCache.ts#L36) + +Called when any mutation in the cache is successful. + +#### Parameters + +##### data + +`unknown` + +##### variables + +`unknown` + +##### onMutateResult + +`unknown` + +##### mutation + +[`Mutation`](../classes/Mutation.md)\<`unknown`, `unknown`, `unknown`\> + +##### context + +[`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md) + +#### Returns + +`unknown` diff --git a/docs/framework/preact/reference/interfaces/MutationFilters.md b/docs/framework/preact/reference/interfaces/MutationFilters.md new file mode 100644 index 00000000000..fbc0208e8e1 --- /dev/null +++ b/docs/framework/preact/reference/interfaces/MutationFilters.md @@ -0,0 +1,85 @@ +--- +id: MutationFilters +title: MutationFilters +--- + +Defined in: [packages/query-core/src/utils.ts:64](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L64) + +Filters used to select mutations, for example in `mutationCache.findAll` or `queryClient.isMutating`. +All provided filters must match; filters that are left unspecified are ignored. + +## Type Parameters + +### TData + +`TData` = `unknown` + +### TError + +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) + +### TVariables + +`TVariables` = `unknown` + +### TOnMutateResult + +`TOnMutateResult` = `unknown` + +## Properties + +### exact? + +```ts +optional exact: boolean; +``` + +Defined in: [packages/query-core/src/utils.ts:73](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L73) + +Match mutation key exactly + +*** + +### mutationKey? + +```ts +optional mutationKey: readonly unknown[]; +``` + +Defined in: [packages/query-core/src/utils.ts:83](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L83) + +Include mutations matching this mutation key + +*** + +### predicate()? + +```ts +optional predicate: (mutation) => boolean; +``` + +Defined in: [packages/query-core/src/utils.ts:77](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L77) + +Include mutations matching this predicate function + +#### Parameters + +##### mutation + +[`Mutation`](../classes/Mutation.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\> + +#### Returns + +`boolean` + +*** + +### status? + +```ts +optional status: MutationStatus; +``` + +Defined in: [packages/query-core/src/utils.ts:87](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L87) + +Filter by mutation status diff --git a/docs/framework/preact/reference/interfaces/MutationObserverBaseResult.md b/docs/framework/preact/reference/interfaces/MutationObserverBaseResult.md new file mode 100644 index 00000000000..340a38cc9cc --- /dev/null +++ b/docs/framework/preact/reference/interfaces/MutationObserverBaseResult.md @@ -0,0 +1,291 @@ +--- +id: MutationObserverBaseResult +title: MutationObserverBaseResult +--- + +Defined in: [packages/query-core/src/types.ts:1335](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1335) + +The raw state stored on a `Mutation` instance. This is the underlying state +that observer results (e.g. `MutationObserverResult`) are derived from. + +## Extends + +- [`MutationState`](MutationState.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\> + +## Extended by + +- [`MutationObserverIdleResult`](MutationObserverIdleResult.md) +- [`MutationObserverLoadingResult`](MutationObserverLoadingResult.md) +- [`MutationObserverErrorResult`](MutationObserverErrorResult.md) +- [`MutationObserverSuccessResult`](MutationObserverSuccessResult.md) + +## Type Parameters + +### TData + +`TData` = `unknown` + +### TError + +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) + +### TVariables + +`TVariables` = `void` + +### TOnMutateResult + +`TOnMutateResult` = `unknown` + +## Properties + +### context + +```ts +context: TOnMutateResult | undefined; +``` + +Defined in: [packages/query-core/src/mutation.ts:40](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L40) + +The value returned by `onMutate`, if defined. Passed to `onSuccess`, +`onError` and `onSettled` as the mutation's context. + +#### Inherited from + +[`MutationState`](MutationState.md).[`context`](MutationState.md#context) + +*** + +### data + +```ts +data: TData | undefined; +``` + +Defined in: [packages/query-core/src/types.ts:1344](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1344) + +The last successfully resolved data for the mutation. + +#### Overrides + +[`MutationState`](MutationState.md).[`data`](MutationState.md#data) + +*** + +### error + +```ts +error: TError | null; +``` + +Defined in: [packages/query-core/src/types.ts:1353](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1353) + +The error object for the mutation, if an error was encountered. +- Defaults to `null`. + +#### Overrides + +[`MutationState`](MutationState.md).[`error`](MutationState.md#error) + +*** + +### failureCount + +```ts +failureCount: number; +``` + +Defined in: [packages/query-core/src/mutation.ts:53](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L53) + +The number of times the mutation function has failed for the current attempt. + +#### Inherited from + +[`MutationState`](MutationState.md).[`failureCount`](MutationState.md#failurecount) + +*** + +### failureReason + +```ts +failureReason: TError | null; +``` + +Defined in: [packages/query-core/src/mutation.ts:57](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L57) + +The reason the current attempt failed, as reported by the retryer. + +#### Inherited from + +[`MutationState`](MutationState.md).[`failureReason`](MutationState.md#failurereason) + +*** + +### isError + +```ts +isError: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1358](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1358) + +A boolean variable derived from `status`. +- `true` if the last mutation attempt resulted in an error. + +*** + +### isIdle + +```ts +isIdle: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1363](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1363) + +A boolean variable derived from `status`. +- `true` if the mutation is in its initial state prior to executing. + +*** + +### isPaused + +```ts +isPaused: boolean; +``` + +Defined in: [packages/query-core/src/mutation.ts:62](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L62) + +Whether the mutation is currently paused (see network mode), or is +waiting for another mutation with the same `scope` to finish. + +#### Inherited from + +[`MutationState`](MutationState.md).[`isPaused`](MutationState.md#ispaused) + +*** + +### isPending + +```ts +isPending: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1368](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1368) + +A boolean variable derived from `status`. +- `true` if the mutation is currently executing. + +*** + +### isSuccess + +```ts +isSuccess: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1373](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1373) + +A boolean variable derived from `status`. +- `true` if the last mutation attempt was successful. + +*** + +### mutate + +```ts +mutate: MutateFunction; +``` + +Defined in: [packages/query-core/src/types.ts:1393](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1393) + +The mutation function you can call with variables to trigger the mutation and optionally hooks on additional callback options. + +#### Param + +The variables object to pass to the `mutationFn`. + +#### Param + +This function will fire when the mutation is successful and will be passed the mutation's result. + +#### Param + +This function will fire if the mutation encounters an error and will be passed the error. + +#### Param + +This function will fire when the mutation is either successfully fetched or encounters an error and be passed either the data or error. + +#### Remarks + +- If you make multiple requests, `onSuccess` will fire only after the latest call you've made. +- All the callback functions (`onSuccess`, `onError`, `onSettled`) are void functions, and the returned value will be ignored. + +*** + +### reset() + +```ts +reset: () => void; +``` + +Defined in: [packages/query-core/src/types.ts:1397](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1397) + +A function to clean the mutation internal state (i.e., it resets the mutation to its initial state). + +#### Returns + +`void` + +*** + +### status + +```ts +status: MutationStatus; +``` + +Defined in: [packages/query-core/src/types.ts:1382](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1382) + +The status of the mutation. +- Will be: + - `idle` initial status prior to the mutation function executing. + - `pending` if the mutation is currently executing. + - `error` if the last mutation attempt resulted in an error. + - `success` if the last mutation attempt was successful. + +#### Overrides + +[`MutationState`](MutationState.md).[`status`](MutationState.md#status) + +*** + +### submittedAt + +```ts +submittedAt: number; +``` + +Defined in: [packages/query-core/src/mutation.ts:74](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L74) + +The timestamp for when the mutation was submitted. + +#### Inherited from + +[`MutationState`](MutationState.md).[`submittedAt`](MutationState.md#submittedat) + +*** + +### variables + +```ts +variables: TVariables | undefined; +``` + +Defined in: [packages/query-core/src/types.ts:1348](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1348) + +The variables object passed to the `mutationFn`. + +#### Overrides + +[`MutationState`](MutationState.md).[`variables`](MutationState.md#variables) diff --git a/docs/framework/preact/reference/interfaces/MutationObserverErrorResult.md b/docs/framework/preact/reference/interfaces/MutationObserverErrorResult.md new file mode 100644 index 00000000000..72e459a2e0b --- /dev/null +++ b/docs/framework/preact/reference/interfaces/MutationObserverErrorResult.md @@ -0,0 +1,308 @@ +--- +id: MutationObserverErrorResult +title: MutationObserverErrorResult +--- + +Defined in: [packages/query-core/src/types.ts:1442](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1442) + +The raw state stored on a `Mutation` instance. This is the underlying state +that observer results (e.g. `MutationObserverResult`) are derived from. + +## Extends + +- [`MutationObserverBaseResult`](MutationObserverBaseResult.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\> + +## Type Parameters + +### TData + +`TData` = `unknown` + +### TError + +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) + +### TVariables + +`TVariables` = `void` + +### TOnMutateResult + +`TOnMutateResult` = `unknown` + +## Properties + +### context + +```ts +context: TOnMutateResult | undefined; +``` + +Defined in: [packages/query-core/src/mutation.ts:40](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L40) + +The value returned by `onMutate`, if defined. Passed to `onSuccess`, +`onError` and `onSettled` as the mutation's context. + +#### Inherited from + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`context`](MutationObserverBaseResult.md#context) + +*** + +### data + +```ts +data: undefined; +``` + +Defined in: [packages/query-core/src/types.ts:1453](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1453) + +The last successfully resolved data for the mutation. + +#### Overrides + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`data`](MutationObserverBaseResult.md#data) + +*** + +### error + +```ts +error: TError; +``` + +Defined in: [packages/query-core/src/types.ts:1454](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1454) + +The error object for the mutation, if an error was encountered. +- Defaults to `null`. + +#### Overrides + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`error`](MutationObserverBaseResult.md#error) + +*** + +### failureCount + +```ts +failureCount: number; +``` + +Defined in: [packages/query-core/src/mutation.ts:53](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L53) + +The number of times the mutation function has failed for the current attempt. + +#### Inherited from + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`failureCount`](MutationObserverBaseResult.md#failurecount) + +*** + +### failureReason + +```ts +failureReason: TError | null; +``` + +Defined in: [packages/query-core/src/mutation.ts:57](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L57) + +The reason the current attempt failed, as reported by the retryer. + +#### Inherited from + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`failureReason`](MutationObserverBaseResult.md#failurereason) + +*** + +### isError + +```ts +isError: true; +``` + +Defined in: [packages/query-core/src/types.ts:1456](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1456) + +A boolean variable derived from `status`. +- `true` if the last mutation attempt resulted in an error. + +#### Overrides + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isError`](MutationObserverBaseResult.md#iserror) + +*** + +### isIdle + +```ts +isIdle: false; +``` + +Defined in: [packages/query-core/src/types.ts:1457](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1457) + +A boolean variable derived from `status`. +- `true` if the mutation is in its initial state prior to executing. + +#### Overrides + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isIdle`](MutationObserverBaseResult.md#isidle) + +*** + +### isPaused + +```ts +isPaused: boolean; +``` + +Defined in: [packages/query-core/src/mutation.ts:62](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L62) + +Whether the mutation is currently paused (see network mode), or is +waiting for another mutation with the same `scope` to finish. + +#### Inherited from + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isPaused`](MutationObserverBaseResult.md#ispaused) + +*** + +### isPending + +```ts +isPending: false; +``` + +Defined in: [packages/query-core/src/types.ts:1458](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1458) + +A boolean variable derived from `status`. +- `true` if the mutation is currently executing. + +#### Overrides + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isPending`](MutationObserverBaseResult.md#ispending) + +*** + +### isSuccess + +```ts +isSuccess: false; +``` + +Defined in: [packages/query-core/src/types.ts:1459](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1459) + +A boolean variable derived from `status`. +- `true` if the last mutation attempt was successful. + +#### Overrides + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isSuccess`](MutationObserverBaseResult.md#issuccess) + +*** + +### mutate + +```ts +mutate: MutateFunction; +``` + +Defined in: [packages/query-core/src/types.ts:1393](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1393) + +The mutation function you can call with variables to trigger the mutation and optionally hooks on additional callback options. + +#### Param + +The variables object to pass to the `mutationFn`. + +#### Param + +This function will fire when the mutation is successful and will be passed the mutation's result. + +#### Param + +This function will fire if the mutation encounters an error and will be passed the error. + +#### Param + +This function will fire when the mutation is either successfully fetched or encounters an error and be passed either the data or error. + +#### Remarks + +- If you make multiple requests, `onSuccess` will fire only after the latest call you've made. +- All the callback functions (`onSuccess`, `onError`, `onSettled`) are void functions, and the returned value will be ignored. + +#### Inherited from + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`mutate`](MutationObserverBaseResult.md#mutate) + +*** + +### reset() + +```ts +reset: () => void; +``` + +Defined in: [packages/query-core/src/types.ts:1397](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1397) + +A function to clean the mutation internal state (i.e., it resets the mutation to its initial state). + +#### Returns + +`void` + +#### Inherited from + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`reset`](MutationObserverBaseResult.md#reset) + +*** + +### status + +```ts +status: "error"; +``` + +Defined in: [packages/query-core/src/types.ts:1460](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1460) + +The status of the mutation. +- Will be: + - `idle` initial status prior to the mutation function executing. + - `pending` if the mutation is currently executing. + - `error` if the last mutation attempt resulted in an error. + - `success` if the last mutation attempt was successful. + +#### Overrides + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`status`](MutationObserverBaseResult.md#status) + +*** + +### submittedAt + +```ts +submittedAt: number; +``` + +Defined in: [packages/query-core/src/mutation.ts:74](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L74) + +The timestamp for when the mutation was submitted. + +#### Inherited from + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`submittedAt`](MutationObserverBaseResult.md#submittedat) + +*** + +### variables + +```ts +variables: TVariables; +``` + +Defined in: [packages/query-core/src/types.ts:1455](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1455) + +The variables object passed to the `mutationFn`. + +#### Overrides + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`variables`](MutationObserverBaseResult.md#variables) diff --git a/docs/framework/preact/reference/interfaces/MutationObserverIdleResult.md b/docs/framework/preact/reference/interfaces/MutationObserverIdleResult.md new file mode 100644 index 00000000000..cd8d6eb3130 --- /dev/null +++ b/docs/framework/preact/reference/interfaces/MutationObserverIdleResult.md @@ -0,0 +1,308 @@ +--- +id: MutationObserverIdleResult +title: MutationObserverIdleResult +--- + +Defined in: [packages/query-core/src/types.ts:1400](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1400) + +The raw state stored on a `Mutation` instance. This is the underlying state +that observer results (e.g. `MutationObserverResult`) are derived from. + +## Extends + +- [`MutationObserverBaseResult`](MutationObserverBaseResult.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\> + +## Type Parameters + +### TData + +`TData` = `unknown` + +### TError + +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) + +### TVariables + +`TVariables` = `void` + +### TOnMutateResult + +`TOnMutateResult` = `unknown` + +## Properties + +### context + +```ts +context: TOnMutateResult | undefined; +``` + +Defined in: [packages/query-core/src/mutation.ts:40](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L40) + +The value returned by `onMutate`, if defined. Passed to `onSuccess`, +`onError` and `onSettled` as the mutation's context. + +#### Inherited from + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`context`](MutationObserverBaseResult.md#context) + +*** + +### data + +```ts +data: undefined; +``` + +Defined in: [packages/query-core/src/types.ts:1411](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1411) + +The last successfully resolved data for the mutation. + +#### Overrides + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`data`](MutationObserverBaseResult.md#data) + +*** + +### error + +```ts +error: null; +``` + +Defined in: [packages/query-core/src/types.ts:1413](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1413) + +The error object for the mutation, if an error was encountered. +- Defaults to `null`. + +#### Overrides + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`error`](MutationObserverBaseResult.md#error) + +*** + +### failureCount + +```ts +failureCount: number; +``` + +Defined in: [packages/query-core/src/mutation.ts:53](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L53) + +The number of times the mutation function has failed for the current attempt. + +#### Inherited from + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`failureCount`](MutationObserverBaseResult.md#failurecount) + +*** + +### failureReason + +```ts +failureReason: TError | null; +``` + +Defined in: [packages/query-core/src/mutation.ts:57](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L57) + +The reason the current attempt failed, as reported by the retryer. + +#### Inherited from + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`failureReason`](MutationObserverBaseResult.md#failurereason) + +*** + +### isError + +```ts +isError: false; +``` + +Defined in: [packages/query-core/src/types.ts:1414](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1414) + +A boolean variable derived from `status`. +- `true` if the last mutation attempt resulted in an error. + +#### Overrides + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isError`](MutationObserverBaseResult.md#iserror) + +*** + +### isIdle + +```ts +isIdle: true; +``` + +Defined in: [packages/query-core/src/types.ts:1415](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1415) + +A boolean variable derived from `status`. +- `true` if the mutation is in its initial state prior to executing. + +#### Overrides + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isIdle`](MutationObserverBaseResult.md#isidle) + +*** + +### isPaused + +```ts +isPaused: boolean; +``` + +Defined in: [packages/query-core/src/mutation.ts:62](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L62) + +Whether the mutation is currently paused (see network mode), or is +waiting for another mutation with the same `scope` to finish. + +#### Inherited from + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isPaused`](MutationObserverBaseResult.md#ispaused) + +*** + +### isPending + +```ts +isPending: false; +``` + +Defined in: [packages/query-core/src/types.ts:1416](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1416) + +A boolean variable derived from `status`. +- `true` if the mutation is currently executing. + +#### Overrides + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isPending`](MutationObserverBaseResult.md#ispending) + +*** + +### isSuccess + +```ts +isSuccess: false; +``` + +Defined in: [packages/query-core/src/types.ts:1417](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1417) + +A boolean variable derived from `status`. +- `true` if the last mutation attempt was successful. + +#### Overrides + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isSuccess`](MutationObserverBaseResult.md#issuccess) + +*** + +### mutate + +```ts +mutate: MutateFunction; +``` + +Defined in: [packages/query-core/src/types.ts:1393](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1393) + +The mutation function you can call with variables to trigger the mutation and optionally hooks on additional callback options. + +#### Param + +The variables object to pass to the `mutationFn`. + +#### Param + +This function will fire when the mutation is successful and will be passed the mutation's result. + +#### Param + +This function will fire if the mutation encounters an error and will be passed the error. + +#### Param + +This function will fire when the mutation is either successfully fetched or encounters an error and be passed either the data or error. + +#### Remarks + +- If you make multiple requests, `onSuccess` will fire only after the latest call you've made. +- All the callback functions (`onSuccess`, `onError`, `onSettled`) are void functions, and the returned value will be ignored. + +#### Inherited from + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`mutate`](MutationObserverBaseResult.md#mutate) + +*** + +### reset() + +```ts +reset: () => void; +``` + +Defined in: [packages/query-core/src/types.ts:1397](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1397) + +A function to clean the mutation internal state (i.e., it resets the mutation to its initial state). + +#### Returns + +`void` + +#### Inherited from + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`reset`](MutationObserverBaseResult.md#reset) + +*** + +### status + +```ts +status: "idle"; +``` + +Defined in: [packages/query-core/src/types.ts:1418](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1418) + +The status of the mutation. +- Will be: + - `idle` initial status prior to the mutation function executing. + - `pending` if the mutation is currently executing. + - `error` if the last mutation attempt resulted in an error. + - `success` if the last mutation attempt was successful. + +#### Overrides + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`status`](MutationObserverBaseResult.md#status) + +*** + +### submittedAt + +```ts +submittedAt: number; +``` + +Defined in: [packages/query-core/src/mutation.ts:74](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L74) + +The timestamp for when the mutation was submitted. + +#### Inherited from + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`submittedAt`](MutationObserverBaseResult.md#submittedat) + +*** + +### variables + +```ts +variables: undefined; +``` + +Defined in: [packages/query-core/src/types.ts:1412](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1412) + +The variables object passed to the `mutationFn`. + +#### Overrides + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`variables`](MutationObserverBaseResult.md#variables) diff --git a/docs/framework/preact/reference/interfaces/MutationObserverLoadingResult.md b/docs/framework/preact/reference/interfaces/MutationObserverLoadingResult.md new file mode 100644 index 00000000000..9b70a8558e7 --- /dev/null +++ b/docs/framework/preact/reference/interfaces/MutationObserverLoadingResult.md @@ -0,0 +1,308 @@ +--- +id: MutationObserverLoadingResult +title: MutationObserverLoadingResult +--- + +Defined in: [packages/query-core/src/types.ts:1421](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1421) + +The raw state stored on a `Mutation` instance. This is the underlying state +that observer results (e.g. `MutationObserverResult`) are derived from. + +## Extends + +- [`MutationObserverBaseResult`](MutationObserverBaseResult.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\> + +## Type Parameters + +### TData + +`TData` = `unknown` + +### TError + +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) + +### TVariables + +`TVariables` = `void` + +### TOnMutateResult + +`TOnMutateResult` = `unknown` + +## Properties + +### context + +```ts +context: TOnMutateResult | undefined; +``` + +Defined in: [packages/query-core/src/mutation.ts:40](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L40) + +The value returned by `onMutate`, if defined. Passed to `onSuccess`, +`onError` and `onSettled` as the mutation's context. + +#### Inherited from + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`context`](MutationObserverBaseResult.md#context) + +*** + +### data + +```ts +data: undefined; +``` + +Defined in: [packages/query-core/src/types.ts:1432](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1432) + +The last successfully resolved data for the mutation. + +#### Overrides + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`data`](MutationObserverBaseResult.md#data) + +*** + +### error + +```ts +error: null; +``` + +Defined in: [packages/query-core/src/types.ts:1434](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1434) + +The error object for the mutation, if an error was encountered. +- Defaults to `null`. + +#### Overrides + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`error`](MutationObserverBaseResult.md#error) + +*** + +### failureCount + +```ts +failureCount: number; +``` + +Defined in: [packages/query-core/src/mutation.ts:53](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L53) + +The number of times the mutation function has failed for the current attempt. + +#### Inherited from + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`failureCount`](MutationObserverBaseResult.md#failurecount) + +*** + +### failureReason + +```ts +failureReason: TError | null; +``` + +Defined in: [packages/query-core/src/mutation.ts:57](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L57) + +The reason the current attempt failed, as reported by the retryer. + +#### Inherited from + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`failureReason`](MutationObserverBaseResult.md#failurereason) + +*** + +### isError + +```ts +isError: false; +``` + +Defined in: [packages/query-core/src/types.ts:1435](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1435) + +A boolean variable derived from `status`. +- `true` if the last mutation attempt resulted in an error. + +#### Overrides + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isError`](MutationObserverBaseResult.md#iserror) + +*** + +### isIdle + +```ts +isIdle: false; +``` + +Defined in: [packages/query-core/src/types.ts:1436](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1436) + +A boolean variable derived from `status`. +- `true` if the mutation is in its initial state prior to executing. + +#### Overrides + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isIdle`](MutationObserverBaseResult.md#isidle) + +*** + +### isPaused + +```ts +isPaused: boolean; +``` + +Defined in: [packages/query-core/src/mutation.ts:62](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L62) + +Whether the mutation is currently paused (see network mode), or is +waiting for another mutation with the same `scope` to finish. + +#### Inherited from + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isPaused`](MutationObserverBaseResult.md#ispaused) + +*** + +### isPending + +```ts +isPending: true; +``` + +Defined in: [packages/query-core/src/types.ts:1437](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1437) + +A boolean variable derived from `status`. +- `true` if the mutation is currently executing. + +#### Overrides + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isPending`](MutationObserverBaseResult.md#ispending) + +*** + +### isSuccess + +```ts +isSuccess: false; +``` + +Defined in: [packages/query-core/src/types.ts:1438](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1438) + +A boolean variable derived from `status`. +- `true` if the last mutation attempt was successful. + +#### Overrides + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isSuccess`](MutationObserverBaseResult.md#issuccess) + +*** + +### mutate + +```ts +mutate: MutateFunction; +``` + +Defined in: [packages/query-core/src/types.ts:1393](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1393) + +The mutation function you can call with variables to trigger the mutation and optionally hooks on additional callback options. + +#### Param + +The variables object to pass to the `mutationFn`. + +#### Param + +This function will fire when the mutation is successful and will be passed the mutation's result. + +#### Param + +This function will fire if the mutation encounters an error and will be passed the error. + +#### Param + +This function will fire when the mutation is either successfully fetched or encounters an error and be passed either the data or error. + +#### Remarks + +- If you make multiple requests, `onSuccess` will fire only after the latest call you've made. +- All the callback functions (`onSuccess`, `onError`, `onSettled`) are void functions, and the returned value will be ignored. + +#### Inherited from + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`mutate`](MutationObserverBaseResult.md#mutate) + +*** + +### reset() + +```ts +reset: () => void; +``` + +Defined in: [packages/query-core/src/types.ts:1397](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1397) + +A function to clean the mutation internal state (i.e., it resets the mutation to its initial state). + +#### Returns + +`void` + +#### Inherited from + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`reset`](MutationObserverBaseResult.md#reset) + +*** + +### status + +```ts +status: "pending"; +``` + +Defined in: [packages/query-core/src/types.ts:1439](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1439) + +The status of the mutation. +- Will be: + - `idle` initial status prior to the mutation function executing. + - `pending` if the mutation is currently executing. + - `error` if the last mutation attempt resulted in an error. + - `success` if the last mutation attempt was successful. + +#### Overrides + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`status`](MutationObserverBaseResult.md#status) + +*** + +### submittedAt + +```ts +submittedAt: number; +``` + +Defined in: [packages/query-core/src/mutation.ts:74](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L74) + +The timestamp for when the mutation was submitted. + +#### Inherited from + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`submittedAt`](MutationObserverBaseResult.md#submittedat) + +*** + +### variables + +```ts +variables: TVariables; +``` + +Defined in: [packages/query-core/src/types.ts:1433](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1433) + +The variables object passed to the `mutationFn`. + +#### Overrides + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`variables`](MutationObserverBaseResult.md#variables) diff --git a/docs/framework/preact/reference/interfaces/MutationObserverOptions.md b/docs/framework/preact/reference/interfaces/MutationObserverOptions.md new file mode 100644 index 00000000000..5bab2840a6d --- /dev/null +++ b/docs/framework/preact/reference/interfaces/MutationObserverOptions.md @@ -0,0 +1,322 @@ +--- +id: MutationObserverOptions +title: MutationObserverOptions +--- + +Defined in: [packages/query-core/src/types.ts:1267](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1267) + +## Extends + +- [`MutationOptions`](MutationOptions.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\> + +## Type Parameters + +### TData + +`TData` = `unknown` + +### TError + +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) + +### TVariables + +`TVariables` = `void` + +### TOnMutateResult + +`TOnMutateResult` = `unknown` + +## Properties + +### gcTime? + +```ts +optional gcTime: number; +``` + +Defined in: [packages/query-core/src/types.ts:1260](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1260) + +The time in milliseconds that an unused/inactive mutation remains in memory before it is +garbage collected. + +Defaults to `5 * 60 * 1000` (5 minutes), or `Infinity` during SSR. + +#### Inherited from + +[`MutationOptions`](MutationOptions.md).[`gcTime`](MutationOptions.md#gctime) + +*** + +### meta? + +```ts +optional meta: Record; +``` + +Defined in: [packages/query-core/src/types.ts:1263](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1263) + +#### Inherited from + +[`MutationOptions`](MutationOptions.md).[`meta`](MutationOptions.md#meta) + +*** + +### mutationFn? + +```ts +optional mutationFn: MutationFunction; +``` + +Defined in: [packages/query-core/src/types.ts:1206](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1206) + +#### Inherited from + +[`MutationOptions`](MutationOptions.md).[`mutationFn`](MutationOptions.md#mutationfn) + +*** + +### mutationKey? + +```ts +optional mutationKey: readonly unknown[]; +``` + +Defined in: [packages/query-core/src/types.ts:1207](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1207) + +#### Inherited from + +[`MutationOptions`](MutationOptions.md).[`mutationKey`](MutationOptions.md#mutationkey) + +*** + +### networkMode? + +```ts +optional networkMode: NetworkMode; +``` + +Defined in: [packages/query-core/src/types.ts:1253](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1253) + +Controls whether a mutation is allowed to run based on the current network connectivity. + +Defaults to `'online'`. + +#### See + +[Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. + +#### Inherited from + +[`MutationOptions`](MutationOptions.md).[`networkMode`](MutationOptions.md#networkmode) + +*** + +### onError()? + +```ts +optional onError: (error, variables, onMutateResult, context) => unknown; +``` + +Defined in: [packages/query-core/src/types.ts:1218](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1218) + +#### Parameters + +##### error + +`TError` + +##### variables + +`TVariables` + +##### onMutateResult + +`TOnMutateResult` | `undefined` + +##### context + +[`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md) + +#### Returns + +`unknown` + +#### Inherited from + +[`MutationOptions`](MutationOptions.md).[`onError`](MutationOptions.md#onerror) + +*** + +### onMutate()? + +```ts +optional onMutate: (variables, context) => TOnMutateResult | Promise; +``` + +Defined in: [packages/query-core/src/types.ts:1208](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1208) + +#### Parameters + +##### variables + +`TVariables` + +##### context + +[`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md) + +#### Returns + +`TOnMutateResult` \| `Promise`\<`TOnMutateResult`\> + +#### Inherited from + +[`MutationOptions`](MutationOptions.md).[`onMutate`](MutationOptions.md#onmutate) + +*** + +### onSettled()? + +```ts +optional onSettled: (data, error, variables, onMutateResult, context) => unknown; +``` + +Defined in: [packages/query-core/src/types.ts:1224](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1224) + +#### Parameters + +##### data + +`TData` | `undefined` + +##### error + +`TError` | `null` + +##### variables + +`TVariables` + +##### onMutateResult + +`TOnMutateResult` | `undefined` + +##### context + +[`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md) + +#### Returns + +`unknown` + +#### Inherited from + +[`MutationOptions`](MutationOptions.md).[`onSettled`](MutationOptions.md#onsettled) + +*** + +### onSuccess()? + +```ts +optional onSuccess: (data, variables, onMutateResult, context) => unknown; +``` + +Defined in: [packages/query-core/src/types.ts:1212](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1212) + +#### Parameters + +##### data + +`TData` + +##### variables + +`TVariables` + +##### onMutateResult + +`TOnMutateResult` + +##### context + +[`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md) + +#### Returns + +`unknown` + +#### Inherited from + +[`MutationOptions`](MutationOptions.md).[`onSuccess`](MutationOptions.md#onsuccess) + +*** + +### retry? + +```ts +optional retry: RetryValue; +``` + +Defined in: [packages/query-core/src/types.ts:1239](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1239) + +If `false`, failed mutations will not retry by default. +If `true`, failed mutations will retry infinitely. +If set to an integer number, e.g. 3, failed mutations will retry until the failed mutation count meets that number. +If set to a function `(failureCount, error) => boolean` failed mutations will retry until the function returns false. + +Defaults to `0`. + +#### Inherited from + +[`MutationOptions`](MutationOptions.md).[`retry`](MutationOptions.md#retry) + +*** + +### retryDelay? + +```ts +optional retryDelay: RetryDelayValue; +``` + +Defined in: [packages/query-core/src/types.ts:1246](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1246) + +This function receives a `retryAttempt` integer and the actual Error and returns the delay to apply before the +next attempt in milliseconds. + +Defaults to a function that applies exponential backoff, capped at 30 seconds. + +#### Inherited from + +[`MutationOptions`](MutationOptions.md).[`retryDelay`](MutationOptions.md#retrydelay) + +*** + +### scope? + +```ts +optional scope: MutationScope; +``` + +Defined in: [packages/query-core/src/types.ts:1264](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1264) + +#### Inherited from + +[`MutationOptions`](MutationOptions.md).[`scope`](MutationOptions.md#scope) + +*** + +### throwOnError? + +```ts +optional throwOnError: boolean | (error) => boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1281](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1281) + +Whether errors should be thrown instead of setting the `error` property. +If set to `true`, all errors will be thrown to the nearest error boundary. +If set to a function, it will be passed the error and should return a boolean indicating whether to throw the +error (`true`) or return it as state (`false`). + +Defaults to `false`. diff --git a/docs/framework/preact/reference/interfaces/MutationObserverSuccessResult.md b/docs/framework/preact/reference/interfaces/MutationObserverSuccessResult.md new file mode 100644 index 00000000000..e2e03642f82 --- /dev/null +++ b/docs/framework/preact/reference/interfaces/MutationObserverSuccessResult.md @@ -0,0 +1,308 @@ +--- +id: MutationObserverSuccessResult +title: MutationObserverSuccessResult +--- + +Defined in: [packages/query-core/src/types.ts:1463](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1463) + +The raw state stored on a `Mutation` instance. This is the underlying state +that observer results (e.g. `MutationObserverResult`) are derived from. + +## Extends + +- [`MutationObserverBaseResult`](MutationObserverBaseResult.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\> + +## Type Parameters + +### TData + +`TData` = `unknown` + +### TError + +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) + +### TVariables + +`TVariables` = `void` + +### TOnMutateResult + +`TOnMutateResult` = `unknown` + +## Properties + +### context + +```ts +context: TOnMutateResult | undefined; +``` + +Defined in: [packages/query-core/src/mutation.ts:40](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L40) + +The value returned by `onMutate`, if defined. Passed to `onSuccess`, +`onError` and `onSettled` as the mutation's context. + +#### Inherited from + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`context`](MutationObserverBaseResult.md#context) + +*** + +### data + +```ts +data: TData; +``` + +Defined in: [packages/query-core/src/types.ts:1474](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1474) + +The last successfully resolved data for the mutation. + +#### Overrides + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`data`](MutationObserverBaseResult.md#data) + +*** + +### error + +```ts +error: null; +``` + +Defined in: [packages/query-core/src/types.ts:1475](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1475) + +The error object for the mutation, if an error was encountered. +- Defaults to `null`. + +#### Overrides + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`error`](MutationObserverBaseResult.md#error) + +*** + +### failureCount + +```ts +failureCount: number; +``` + +Defined in: [packages/query-core/src/mutation.ts:53](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L53) + +The number of times the mutation function has failed for the current attempt. + +#### Inherited from + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`failureCount`](MutationObserverBaseResult.md#failurecount) + +*** + +### failureReason + +```ts +failureReason: TError | null; +``` + +Defined in: [packages/query-core/src/mutation.ts:57](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L57) + +The reason the current attempt failed, as reported by the retryer. + +#### Inherited from + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`failureReason`](MutationObserverBaseResult.md#failurereason) + +*** + +### isError + +```ts +isError: false; +``` + +Defined in: [packages/query-core/src/types.ts:1477](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1477) + +A boolean variable derived from `status`. +- `true` if the last mutation attempt resulted in an error. + +#### Overrides + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isError`](MutationObserverBaseResult.md#iserror) + +*** + +### isIdle + +```ts +isIdle: false; +``` + +Defined in: [packages/query-core/src/types.ts:1478](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1478) + +A boolean variable derived from `status`. +- `true` if the mutation is in its initial state prior to executing. + +#### Overrides + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isIdle`](MutationObserverBaseResult.md#isidle) + +*** + +### isPaused + +```ts +isPaused: boolean; +``` + +Defined in: [packages/query-core/src/mutation.ts:62](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L62) + +Whether the mutation is currently paused (see network mode), or is +waiting for another mutation with the same `scope` to finish. + +#### Inherited from + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isPaused`](MutationObserverBaseResult.md#ispaused) + +*** + +### isPending + +```ts +isPending: false; +``` + +Defined in: [packages/query-core/src/types.ts:1479](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1479) + +A boolean variable derived from `status`. +- `true` if the mutation is currently executing. + +#### Overrides + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isPending`](MutationObserverBaseResult.md#ispending) + +*** + +### isSuccess + +```ts +isSuccess: true; +``` + +Defined in: [packages/query-core/src/types.ts:1480](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1480) + +A boolean variable derived from `status`. +- `true` if the last mutation attempt was successful. + +#### Overrides + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isSuccess`](MutationObserverBaseResult.md#issuccess) + +*** + +### mutate + +```ts +mutate: MutateFunction; +``` + +Defined in: [packages/query-core/src/types.ts:1393](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1393) + +The mutation function you can call with variables to trigger the mutation and optionally hooks on additional callback options. + +#### Param + +The variables object to pass to the `mutationFn`. + +#### Param + +This function will fire when the mutation is successful and will be passed the mutation's result. + +#### Param + +This function will fire if the mutation encounters an error and will be passed the error. + +#### Param + +This function will fire when the mutation is either successfully fetched or encounters an error and be passed either the data or error. + +#### Remarks + +- If you make multiple requests, `onSuccess` will fire only after the latest call you've made. +- All the callback functions (`onSuccess`, `onError`, `onSettled`) are void functions, and the returned value will be ignored. + +#### Inherited from + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`mutate`](MutationObserverBaseResult.md#mutate) + +*** + +### reset() + +```ts +reset: () => void; +``` + +Defined in: [packages/query-core/src/types.ts:1397](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1397) + +A function to clean the mutation internal state (i.e., it resets the mutation to its initial state). + +#### Returns + +`void` + +#### Inherited from + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`reset`](MutationObserverBaseResult.md#reset) + +*** + +### status + +```ts +status: "success"; +``` + +Defined in: [packages/query-core/src/types.ts:1481](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1481) + +The status of the mutation. +- Will be: + - `idle` initial status prior to the mutation function executing. + - `pending` if the mutation is currently executing. + - `error` if the last mutation attempt resulted in an error. + - `success` if the last mutation attempt was successful. + +#### Overrides + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`status`](MutationObserverBaseResult.md#status) + +*** + +### submittedAt + +```ts +submittedAt: number; +``` + +Defined in: [packages/query-core/src/mutation.ts:74](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L74) + +The timestamp for when the mutation was submitted. + +#### Inherited from + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`submittedAt`](MutationObserverBaseResult.md#submittedat) + +*** + +### variables + +```ts +variables: TVariables; +``` + +Defined in: [packages/query-core/src/types.ts:1476](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1476) + +The variables object passed to the `mutationFn`. + +#### Overrides + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`variables`](MutationObserverBaseResult.md#variables) diff --git a/docs/framework/preact/reference/interfaces/MutationOptions.md b/docs/framework/preact/reference/interfaces/MutationOptions.md new file mode 100644 index 00000000000..5aabeeb0ca4 --- /dev/null +++ b/docs/framework/preact/reference/interfaces/MutationOptions.md @@ -0,0 +1,257 @@ +--- +id: MutationOptions +title: MutationOptions +--- + +Defined in: [packages/query-core/src/types.ts:1200](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1200) + +## Extended by + +- [`MutationObserverOptions`](MutationObserverOptions.md) + +## Type Parameters + +### TData + +`TData` = `unknown` + +### TError + +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) + +### TVariables + +`TVariables` = `void` + +### TOnMutateResult + +`TOnMutateResult` = `unknown` + +## Properties + +### gcTime? + +```ts +optional gcTime: number; +``` + +Defined in: [packages/query-core/src/types.ts:1260](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1260) + +The time in milliseconds that an unused/inactive mutation remains in memory before it is +garbage collected. + +Defaults to `5 * 60 * 1000` (5 minutes), or `Infinity` during SSR. + +*** + +### meta? + +```ts +optional meta: Record; +``` + +Defined in: [packages/query-core/src/types.ts:1263](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1263) + +*** + +### mutationFn? + +```ts +optional mutationFn: MutationFunction; +``` + +Defined in: [packages/query-core/src/types.ts:1206](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1206) + +*** + +### mutationKey? + +```ts +optional mutationKey: readonly unknown[]; +``` + +Defined in: [packages/query-core/src/types.ts:1207](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1207) + +*** + +### networkMode? + +```ts +optional networkMode: NetworkMode; +``` + +Defined in: [packages/query-core/src/types.ts:1253](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1253) + +Controls whether a mutation is allowed to run based on the current network connectivity. + +Defaults to `'online'`. + +#### See + +[Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. + +*** + +### onError()? + +```ts +optional onError: (error, variables, onMutateResult, context) => unknown; +``` + +Defined in: [packages/query-core/src/types.ts:1218](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1218) + +#### Parameters + +##### error + +`TError` + +##### variables + +`TVariables` + +##### onMutateResult + +`TOnMutateResult` | `undefined` + +##### context + +[`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md) + +#### Returns + +`unknown` + +*** + +### onMutate()? + +```ts +optional onMutate: (variables, context) => TOnMutateResult | Promise; +``` + +Defined in: [packages/query-core/src/types.ts:1208](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1208) + +#### Parameters + +##### variables + +`TVariables` + +##### context + +[`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md) + +#### Returns + +`TOnMutateResult` \| `Promise`\<`TOnMutateResult`\> + +*** + +### onSettled()? + +```ts +optional onSettled: (data, error, variables, onMutateResult, context) => unknown; +``` + +Defined in: [packages/query-core/src/types.ts:1224](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1224) + +#### Parameters + +##### data + +`TData` | `undefined` + +##### error + +`TError` | `null` + +##### variables + +`TVariables` + +##### onMutateResult + +`TOnMutateResult` | `undefined` + +##### context + +[`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md) + +#### Returns + +`unknown` + +*** + +### onSuccess()? + +```ts +optional onSuccess: (data, variables, onMutateResult, context) => unknown; +``` + +Defined in: [packages/query-core/src/types.ts:1212](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1212) + +#### Parameters + +##### data + +`TData` + +##### variables + +`TVariables` + +##### onMutateResult + +`TOnMutateResult` + +##### context + +[`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md) + +#### Returns + +`unknown` + +*** + +### retry? + +```ts +optional retry: RetryValue; +``` + +Defined in: [packages/query-core/src/types.ts:1239](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1239) + +If `false`, failed mutations will not retry by default. +If `true`, failed mutations will retry infinitely. +If set to an integer number, e.g. 3, failed mutations will retry until the failed mutation count meets that number. +If set to a function `(failureCount, error) => boolean` failed mutations will retry until the function returns false. + +Defaults to `0`. + +*** + +### retryDelay? + +```ts +optional retryDelay: RetryDelayValue; +``` + +Defined in: [packages/query-core/src/types.ts:1246](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1246) + +This function receives a `retryAttempt` integer and the actual Error and returns the delay to apply before the +next attempt in milliseconds. + +Defaults to a function that applies exponential backoff, capped at 30 seconds. + +*** + +### scope? + +```ts +optional scope: MutationScope; +``` + +Defined in: [packages/query-core/src/types.ts:1264](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1264) diff --git a/docs/framework/preact/reference/interfaces/MutationState.md b/docs/framework/preact/reference/interfaces/MutationState.md new file mode 100644 index 00000000000..bec050ec1d3 --- /dev/null +++ b/docs/framework/preact/reference/interfaces/MutationState.md @@ -0,0 +1,142 @@ +--- +id: MutationState +title: MutationState +--- + +Defined in: [packages/query-core/src/mutation.ts:30](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L30) + +The raw state stored on a `Mutation` instance. This is the underlying state +that observer results (e.g. `MutationObserverResult`) are derived from. + +## Extended by + +- [`MutationObserverBaseResult`](MutationObserverBaseResult.md) + +## Type Parameters + +### TData + +`TData` = `unknown` + +### TError + +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) + +### TVariables + +`TVariables` = `unknown` + +### TOnMutateResult + +`TOnMutateResult` = `unknown` + +## Properties + +### context + +```ts +context: TOnMutateResult | undefined; +``` + +Defined in: [packages/query-core/src/mutation.ts:40](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L40) + +The value returned by `onMutate`, if defined. Passed to `onSuccess`, +`onError` and `onSettled` as the mutation's context. + +*** + +### data + +```ts +data: TData | undefined; +``` + +Defined in: [packages/query-core/src/mutation.ts:44](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L44) + +The last successfully resolved data for the mutation. + +*** + +### error + +```ts +error: TError | null; +``` + +Defined in: [packages/query-core/src/mutation.ts:49](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L49) + +The error object for the mutation, if the last attempt resulted in an error. +- Defaults to `null`. + +*** + +### failureCount + +```ts +failureCount: number; +``` + +Defined in: [packages/query-core/src/mutation.ts:53](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L53) + +The number of times the mutation function has failed for the current attempt. + +*** + +### failureReason + +```ts +failureReason: TError | null; +``` + +Defined in: [packages/query-core/src/mutation.ts:57](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L57) + +The reason the current attempt failed, as reported by the retryer. + +*** + +### isPaused + +```ts +isPaused: boolean; +``` + +Defined in: [packages/query-core/src/mutation.ts:62](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L62) + +Whether the mutation is currently paused (see network mode), or is +waiting for another mutation with the same `scope` to finish. + +*** + +### status + +```ts +status: MutationStatus; +``` + +Defined in: [packages/query-core/src/mutation.ts:66](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L66) + +The status of the mutation. + +*** + +### submittedAt + +```ts +submittedAt: number; +``` + +Defined in: [packages/query-core/src/mutation.ts:74](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L74) + +The timestamp for when the mutation was submitted. + +*** + +### variables + +```ts +variables: TVariables | undefined; +``` + +Defined in: [packages/query-core/src/mutation.ts:70](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L70) + +The variables the mutation was last called with. diff --git a/docs/framework/preact/reference/interfaces/NotifyEvent.md b/docs/framework/preact/reference/interfaces/NotifyEvent.md new file mode 100644 index 00000000000..4f5b023f49a --- /dev/null +++ b/docs/framework/preact/reference/interfaces/NotifyEvent.md @@ -0,0 +1,16 @@ +--- +id: NotifyEvent +title: NotifyEvent +--- + +Defined in: [packages/query-core/src/types.ts:1539](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1539) + +## Properties + +### type + +```ts +type: NotifyEventType; +``` + +Defined in: [packages/query-core/src/types.ts:1540](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1540) diff --git a/docs/framework/preact/reference/interfaces/OnlineManager.md b/docs/framework/preact/reference/interfaces/OnlineManager.md new file mode 100644 index 00000000000..1a936c91ed9 --- /dev/null +++ b/docs/framework/preact/reference/interfaces/OnlineManager.md @@ -0,0 +1,214 @@ +--- +id: OnlineManager +title: OnlineManager +--- + +Defined in: [packages/query-core/src/onlineManager.ts:15](https://github.com/TanStack/query/blob/main/packages/query-core/src/onlineManager.ts#L15) + +The `OnlineManager` manages the online state within TanStack Query. It can +be used to change the default event listeners or to manually change the +online state. + +By default, the `onlineManager` assumes an active network connection, and +listens to the `online` and `offline` events on the `window` object to +detect changes. + +## Extends + +- `Subscribable`\<`Listener`\> + +## Properties + +### listeners + +```ts +protected listeners: Set; +``` + +Defined in: [packages/query-core/src/subscribable.ts:2](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L2) + +#### Inherited from + +```ts +Subscribable.listeners +``` + +## Methods + +### hasListeners() + +```ts +hasListeners(): boolean; +``` + +Defined in: [packages/query-core/src/subscribable.ts:19](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L19) + +#### Returns + +`boolean` + +#### Inherited from + +```ts +Subscribable.hasListeners +``` + +*** + +### isOnline() + +```ts +isOnline(): boolean; +``` + +Defined in: [packages/query-core/src/onlineManager.ts:109](https://github.com/TanStack/query/blob/main/packages/query-core/src/onlineManager.ts#L109) + +`isOnline` can be used to get the current online state. + +#### Returns + +`boolean` + +*** + +### onSubscribe() + +```ts +protected onSubscribe(): void; +``` + +Defined in: [packages/query-core/src/onlineManager.ts:44](https://github.com/TanStack/query/blob/main/packages/query-core/src/onlineManager.ts#L44) + +#### Returns + +`void` + +#### Overrides + +```ts +Subscribable.onSubscribe +``` + +*** + +### onUnsubscribe() + +```ts +protected onUnsubscribe(): void; +``` + +Defined in: [packages/query-core/src/onlineManager.ts:50](https://github.com/TanStack/query/blob/main/packages/query-core/src/onlineManager.ts#L50) + +#### Returns + +`void` + +#### Overrides + +```ts +Subscribable.onUnsubscribe +``` + +*** + +### setEventListener() + +```ts +setEventListener(setup): void; +``` + +Defined in: [packages/query-core/src/onlineManager.ts:75](https://github.com/TanStack/query/blob/main/packages/query-core/src/onlineManager.ts#L75) + +`setEventListener` can be used to set a custom event listener that will +be used to determine the online state. The provided `setup` function +receives a `setOnline` callback that should be called with a `boolean` +whenever the online state changes. + +#### Parameters + +##### setup + +`SetupFn` + +#### Returns + +`void` + +#### Example + +```ts +import NetInfo from '@react-native-community/netinfo' +import { onlineManager } from '@tanstack/query-core' + +onlineManager.setEventListener((setOnline) => { + return NetInfo.addEventListener((state) => { + setOnline(!!state.isConnected) + }) +}) +``` + +*** + +### setOnline() + +```ts +setOnline(online): void; +``` + +Defined in: [packages/query-core/src/onlineManager.ts:95](https://github.com/TanStack/query/blob/main/packages/query-core/src/onlineManager.ts#L95) + +`setOnline` can be used to manually set the online state. + +#### Parameters + +##### online + +`boolean` + +#### Returns + +`void` + +#### Example + +```ts +import { onlineManager } from '@tanstack/query-core' + +// Set to online +onlineManager.setOnline(true) + +// Set to offline +onlineManager.setOnline(false) +``` + +*** + +### subscribe() + +```ts +subscribe(listener): () => void; +``` + +Defined in: [packages/query-core/src/subscribable.ts:8](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L8) + +#### Parameters + +##### listener + +`Listener` + +#### Returns + +```ts +(): void; +``` + +##### Returns + +`void` + +#### Inherited from + +```ts +Subscribable.subscribe +``` diff --git a/docs/framework/preact/reference/interfaces/QueriesObserverOptions.md b/docs/framework/preact/reference/interfaces/QueriesObserverOptions.md new file mode 100644 index 00000000000..68e7913885d --- /dev/null +++ b/docs/framework/preact/reference/interfaces/QueriesObserverOptions.md @@ -0,0 +1,29 @@ +--- +id: QueriesObserverOptions +title: QueriesObserverOptions +--- + +Defined in: [packages/query-core/src/queriesObserver.ts:23](https://github.com/TanStack/query/blob/main/packages/query-core/src/queriesObserver.ts#L23) + +## Type Parameters + +### TCombinedResult + +`TCombinedResult` = [`QueryObserverResult`](../type-aliases/QueryObserverResult.md)[] + +## Properties + +### combine? + +```ts +optional combine: CombineFn; +``` + +Defined in: [packages/query-core/src/queriesObserver.ts:34](https://github.com/TanStack/query/blob/main/packages/query-core/src/queriesObserver.ts#L34) + +A function that combines the array of `QueryObserverResult`s (one per +observed query) into a single value. The combined value is memoized and +only recomputed when one of the underlying results, the query hashes, or +the `combine` function itself changes. + +Defaults to returning the array of `QueryObserverResult`s unchanged. diff --git a/docs/framework/preact/reference/interfaces/QueryCacheConfig.md b/docs/framework/preact/reference/interfaces/QueryCacheConfig.md new file mode 100644 index 00000000000..3c6aebe496f --- /dev/null +++ b/docs/framework/preact/reference/interfaces/QueryCacheConfig.md @@ -0,0 +1,93 @@ +--- +id: QueryCacheConfig +title: QueryCacheConfig +--- + +Defined in: [packages/query-core/src/queryCache.ts:25](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryCache.ts#L25) + +Global callbacks that fire for every query handled by a `QueryCache`, regardless of which +component or observer triggered it. Unlike `QueryClient`'s `defaultOptions`, which a query can +override, these callbacks are always called. Unlike `MutationCacheConfig`'s callbacks, these +are fire-and-forget: their return value is not awaited before the query settles. + +## Properties + +### onError()? + +```ts +optional onError: (error, query) => void; +``` + +Defined in: [packages/query-core/src/queryCache.ts:27](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryCache.ts#L27) + +Called when any query in the cache encounters an error. + +#### Parameters + +##### error + +`Error` + +##### query + +[`Query`](../classes/Query.md)\<`unknown`, `unknown`, `unknown`\> + +#### Returns + +`void` + +*** + +### onSettled()? + +```ts +optional onSettled: (data, error, query) => void; +``` + +Defined in: [packages/query-core/src/queryCache.ts:34](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryCache.ts#L34) + +Called when any query in the cache is settled, either successfully or with an error. + +#### Parameters + +##### data + +`unknown` + +##### error + +`Error` | `null` + +##### query + +[`Query`](../classes/Query.md)\<`unknown`, `unknown`, `unknown`\> + +#### Returns + +`void` + +*** + +### onSuccess()? + +```ts +optional onSuccess: (data, query) => void; +``` + +Defined in: [packages/query-core/src/queryCache.ts:32](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryCache.ts#L32) + +Called when any query in the cache is successful. + +#### Parameters + +##### data + +`unknown` + +##### query + +[`Query`](../classes/Query.md)\<`unknown`, `unknown`, `unknown`\> + +#### Returns + +`void` diff --git a/docs/framework/preact/reference/interfaces/QueryClientConfig.md b/docs/framework/preact/reference/interfaces/QueryClientConfig.md new file mode 100644 index 00000000000..070e249491f --- /dev/null +++ b/docs/framework/preact/reference/interfaces/QueryClientConfig.md @@ -0,0 +1,43 @@ +--- +id: QueryClientConfig +title: QueryClientConfig +--- + +Defined in: [packages/query-core/src/types.ts:1495](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1495) + +## Properties + +### defaultOptions? + +```ts +optional defaultOptions: DefaultOptions; +``` + +Defined in: [packages/query-core/src/types.ts:1504](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1504) + +Default options for all queries and mutations created through this client. + +*** + +### mutationCache? + +```ts +optional mutationCache: MutationCache; +``` + +Defined in: [packages/query-core/src/types.ts:1502](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1502) + +The mutation cache this client is connected to. A new `MutationCache` is created if not +provided. + +*** + +### queryCache? + +```ts +optional queryCache: QueryCache; +``` + +Defined in: [packages/query-core/src/types.ts:1497](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1497) + +The query cache this client is connected to. A new `QueryCache` is created if not provided. diff --git a/docs/framework/preact/reference/interfaces/QueryErrorResetBoundaryProps.md b/docs/framework/preact/reference/interfaces/QueryErrorResetBoundaryProps.md index a11940b348b..df8d5756552 100644 --- a/docs/framework/preact/reference/interfaces/QueryErrorResetBoundaryProps.md +++ b/docs/framework/preact/reference/interfaces/QueryErrorResetBoundaryProps.md @@ -3,7 +3,7 @@ id: QueryErrorResetBoundaryProps title: QueryErrorResetBoundaryProps --- -Defined in: [preact-query/src/QueryErrorResetBoundary.tsx:103](https://github.com/TanStack/query/blob/main/packages/preact-query/src/QueryErrorResetBoundary.tsx#L103) +Defined in: [packages/preact-query/src/QueryErrorResetBoundary.tsx:103](https://github.com/TanStack/query/blob/main/packages/preact-query/src/QueryErrorResetBoundary.tsx#L103) The props accepted by `QueryErrorResetBoundary`. @@ -17,7 +17,7 @@ children: | QueryErrorResetBoundaryFunction; ``` -Defined in: [preact-query/src/QueryErrorResetBoundary.tsx:108](https://github.com/TanStack/query/blob/main/packages/preact-query/src/QueryErrorResetBoundary.tsx#L108) +Defined in: [packages/preact-query/src/QueryErrorResetBoundary.tsx:108](https://github.com/TanStack/query/blob/main/packages/preact-query/src/QueryErrorResetBoundary.tsx#L108) Either a plain node, or a function that receives the boundary's QueryErrorResetBoundaryValue and returns a node. diff --git a/docs/framework/preact/reference/interfaces/QueryExecuteOptions.md b/docs/framework/preact/reference/interfaces/QueryExecuteOptions.md new file mode 100644 index 00000000000..23d272eb25f --- /dev/null +++ b/docs/framework/preact/reference/interfaces/QueryExecuteOptions.md @@ -0,0 +1,382 @@ +--- +id: QueryExecuteOptions +title: QueryExecuteOptions +--- + +Defined in: [packages/query-core/src/types.ts:574](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L574) + +## Extends + +- [`WithRequired`](../type-aliases/WithRequired.md)\<[`QueryOptions`](QueryOptions.md)\<`TQueryFnData`, `TError`, `TQueryData`, `TQueryKey`, `TPageParam`\>, `"queryKey"`\> + +## Type Parameters + +### TQueryFnData + +`TQueryFnData` = `unknown` + +### TError + +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) + +### TData + +`TData` = `TQueryFnData` + +### TQueryData + +`TQueryData` = `TQueryFnData` + +### TQueryKey + +`TQueryKey` *extends* [`QueryKey`](../type-aliases/QueryKey.md) = [`QueryKey`](../type-aliases/QueryKey.md) + +### TPageParam + +`TPageParam` = `never` + +## Properties + +### gcTime? + +```ts +optional gcTime: number; +``` + +Defined in: [packages/query-core/src/types.ts:277](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L277) + +The time in milliseconds that unused/inactive cache data remains in memory. +When a query's cache becomes unused or inactive, that cache data will be garbage collected after this duration. +When different garbage collection times are specified, the longest one will be used. +Setting it to `Infinity` will disable garbage collection. + +Defaults to `5 * 60 * 1000` (5 minutes), or `Infinity` during SSR. + +Note: the maximum allowed time is about 24 days, imposed by `setTimeout`'s 32-bit signed integer delay — see +`timeoutManager.setTimeoutProvider` for a workaround. + +#### Inherited from + +```ts +WithRequired.gcTime +``` + +*** + +### initialData? + +```ts +optional initialData: + | TQueryData +| InitialDataFunction; +``` + +Defined in: [packages/query-core/src/types.ts:317](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L317) + +If set, this value will be used as the initial data for the query cache (as long as the query hasn't been +created or cached yet). +If set to a function, the function will be called **once** during the shared/root query initialization, and be +expected to synchronously return the initial data. +Initial data is considered stale by default unless a `staleTime` has been set. +`initialData` **is persisted** to the cache. + +#### Inherited from + +```ts +WithRequired.initialData +``` + +*** + +### initialDataUpdatedAt? + +```ts +optional initialDataUpdatedAt: number | () => number | undefined; +``` + +Defined in: [packages/query-core/src/types.ts:321](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L321) + +If set, this value will be used as the time (in milliseconds) of when the `initialData` itself was last updated. + +#### Inherited from + +```ts +WithRequired.initialDataUpdatedAt +``` + +*** + +### initialPageParam? + +```ts +optional initialPageParam: undefined; +``` + +Defined in: [packages/query-core/src/types.ts:585](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L585) + +*** + +### maxPages? + +```ts +optional maxPages: number; +``` + +Defined in: [packages/query-core/src/types.ts:345](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L345) + +Maximum number of pages to store in the data of an infinite query. + +#### Inherited from + +```ts +WithRequired.maxPages +``` + +*** + +### meta? + +```ts +optional meta: Record; +``` + +Defined in: [packages/query-core/src/types.ts:341](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L341) + +Additional payload to be stored on each query. +Use this property to pass information that can be used in other places. + +#### Inherited from + +```ts +WithRequired.meta +``` + +*** + +### networkMode? + +```ts +optional networkMode: NetworkMode; +``` + +Defined in: [packages/query-core/src/types.ts:265](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L265) + +Controls whether a query is allowed to run based on the current network connectivity. + +Defaults to `'online'`. + +#### See + +[Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. + +#### Inherited from + +```ts +WithRequired.networkMode +``` + +*** + +### persister? + +```ts +optional persister: QueryPersister, TPageParam>; +``` + +Defined in: [packages/query-core/src/types.ts:290](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L290) + +This option can be used to persist the result of a query to an external storage, bypassing the need to actually +call the `queryFn`. Useful for persisting a query's data across e.g. server/client boundaries. + +#### Inherited from + +```ts +WithRequired.persister +``` + +*** + +### queryFn? + +```ts +optional queryFn: + | typeof skipToken +| QueryFunction; +``` + +Defined in: [packages/query-core/src/types.ts:285](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L285) + +The function that the query will use to request data. +Required, unless a default query function has been set via `queryClient.setQueryDefaults` or +`queryClient.setDefaultOptions`. +Receives a [QueryFunctionContext](../type-aliases/QueryFunctionContext.md). +Must return a promise that will either resolve data or throw an error. The data cannot be `undefined`. + +#### Inherited from + +```ts +WithRequired.queryFn +``` + +*** + +### queryHash? + +```ts +optional queryHash: string; +``` + +Defined in: [packages/query-core/src/types.ts:295](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L295) + +The hashed form of `queryKey`, computed with `queryKeyHashFn` (or the default hashing function otherwise). Used +as the actual cache key internally. + +#### Inherited from + +```ts +WithRequired.queryHash +``` + +*** + +### queryKey + +```ts +queryKey: TQueryKey & object; +``` + +Defined in: [packages/query-core/src/types.ts:304](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L304) + +The query key to use for this query. + +The query key will be hashed into a stable hash. See [Query Keys](https://tanstack.com/query/latest/docs/framework/react/guides/query-keys) +for more information. + +The query will automatically update when this key changes (as long as `enabled` is not set to `false`). + +#### Inherited from + +```ts +WithRequired.queryKey +``` + +*** + +### queryKeyHashFn? + +```ts +optional queryKeyHashFn: QueryKeyHashFunction; +``` + +Defined in: [packages/query-core/src/types.ts:308](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L308) + +If specified, this function is used to hash the `queryKey` to a string. + +#### Inherited from + +```ts +WithRequired.queryKeyHashFn +``` + +*** + +### retry? + +```ts +optional retry: RetryValue; +``` + +Defined in: [packages/query-core/src/types.ts:246](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L246) + +If `false`, failed queries will not retry by default. +If `true`, failed queries will retry infinitely. +If set to an integer number, e.g. 3, failed queries will retry until the failed query count meets that number. +If set to a function `(failureCount, error) => boolean` failed queries will retry until the function returns false. + +Defaults to `3` on the client and `0` on the server. + +#### Inherited from + +```ts +WithRequired.retry +``` + +*** + +### retryDelay? + +```ts +optional retryDelay: RetryDelayValue; +``` + +Defined in: [packages/query-core/src/types.ts:258](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L258) + +This function receives a `retryAttempt` integer and the actual Error and returns the delay to apply before the +next attempt in milliseconds. + +A function like `attempt => Math.min(attempt > 1 ? 2 ** attempt * 1000 : 1000, 30 * 1000)` applies exponential +backoff. + +A function like `attempt => attempt * 1000` applies linear backoff. + +Defaults to a function that applies exponential backoff, capped at 30 seconds. + +#### Inherited from + +```ts +WithRequired.retryDelay +``` + +*** + +### select()? + +```ts +optional select: (data) => TData; +``` + +Defined in: [packages/query-core/src/types.ts:586](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L586) + +#### Parameters + +##### data + +`TQueryData` + +#### Returns + +`TData` + +*** + +### staleTime? + +```ts +optional staleTime: StaleTimeFunction; +``` + +Defined in: [packages/query-core/src/types.ts:591](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L591) + +The time in milliseconds after data is considered stale. +If the data is fresh it will be returned from the cache. + +*** + +### structuralSharing? + +```ts +optional structuralSharing: boolean | (oldData, newData) => unknown; +``` + +Defined in: [packages/query-core/src/types.ts:330](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L330) + +Set this to `false` to disable structural sharing between query results. +Set this to a function which accepts the old and new data and returns resolved data of the same type to implement custom structural sharing logic. + +Defaults to `true`. + +#### Inherited from + +```ts +WithRequired.structuralSharing +``` diff --git a/docs/framework/preact/reference/interfaces/QueryFilters.md b/docs/framework/preact/reference/interfaces/QueryFilters.md new file mode 100644 index 00000000000..749e4283d0d --- /dev/null +++ b/docs/framework/preact/reference/interfaces/QueryFilters.md @@ -0,0 +1,104 @@ +--- +id: QueryFilters +title: QueryFilters +--- + +Defined in: [packages/query-core/src/utils.ts:31](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L31) + +Filters used to select queries, for example in `queryClient.getQueriesData` or `queryClient.invalidateQueries`. +All provided filters must match; filters that are left unspecified are ignored. + +## Extended by + +- [`InvalidateQueryFilters`](InvalidateQueryFilters.md) +- [`RefetchQueryFilters`](RefetchQueryFilters.md) + +## Type Parameters + +### TQueryKey + +`TQueryKey` *extends* [`QueryKey`](../type-aliases/QueryKey.md) = [`QueryKey`](../type-aliases/QueryKey.md) + +## Properties + +### exact? + +```ts +optional exact: boolean; +``` + +Defined in: [packages/query-core/src/utils.ts:41](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L41) + +Match query key exactly + +*** + +### fetchStatus? + +```ts +optional fetchStatus: FetchStatus; +``` + +Defined in: [packages/query-core/src/utils.ts:57](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L57) + +Include queries matching their fetchStatus + +*** + +### predicate()? + +```ts +optional predicate: (query) => boolean; +``` + +Defined in: [packages/query-core/src/utils.ts:45](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L45) + +Include queries matching this predicate function + +#### Parameters + +##### query + +[`Query`](../classes/Query.md) + +#### Returns + +`boolean` + +*** + +### queryKey? + +```ts +optional queryKey: TQueryKey | TuplePrefixes; +``` + +Defined in: [packages/query-core/src/utils.ts:49](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L49) + +Include queries matching this query key + +*** + +### stale? + +```ts +optional stale: boolean; +``` + +Defined in: [packages/query-core/src/utils.ts:53](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L53) + +Include or exclude stale queries + +*** + +### type? + +```ts +optional type: QueryTypeFilter; +``` + +Defined in: [packages/query-core/src/utils.ts:37](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L37) + +Filter to active queries, inactive queries or all queries + +Defaults to `'all'`. diff --git a/docs/framework/preact/reference/interfaces/QueryObserverBaseResult.md b/docs/framework/preact/reference/interfaces/QueryObserverBaseResult.md new file mode 100644 index 00000000000..ef5fe0ad757 --- /dev/null +++ b/docs/framework/preact/reference/interfaces/QueryObserverBaseResult.md @@ -0,0 +1,358 @@ +--- +id: QueryObserverBaseResult +title: QueryObserverBaseResult +--- + +Defined in: [packages/query-core/src/types.ts:764](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L764) + +## Extended by + +- [`QueryObserverPendingResult`](QueryObserverPendingResult.md) +- [`QueryObserverLoadingResult`](QueryObserverLoadingResult.md) +- [`QueryObserverLoadingErrorResult`](QueryObserverLoadingErrorResult.md) +- [`QueryObserverRefetchErrorResult`](QueryObserverRefetchErrorResult.md) +- [`QueryObserverSuccessResult`](QueryObserverSuccessResult.md) +- [`QueryObserverPlaceholderResult`](QueryObserverPlaceholderResult.md) +- [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md) + +## Type Parameters + +### TData + +`TData` = `unknown` + +### TError + +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) + +## Properties + +### data + +```ts +data: TData | undefined; +``` + +Defined in: [packages/query-core/src/types.ts:771](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L771) + +The last successfully resolved data for the query. + +*** + +### dataUpdatedAt + +```ts +dataUpdatedAt: number; +``` + +Defined in: [packages/query-core/src/types.ts:775](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L775) + +The timestamp for when the query most recently returned the `status` as `"success"`. + +*** + +### error + +```ts +error: TError | null; +``` + +Defined in: [packages/query-core/src/types.ts:780](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L780) + +The error object for the query, if an error was thrown. +- Defaults to `null`. + +*** + +### errorUpdateCount + +```ts +errorUpdateCount: number; +``` + +Defined in: [packages/query-core/src/types.ts:799](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L799) + +The sum of all errors. + +*** + +### errorUpdatedAt + +```ts +errorUpdatedAt: number; +``` + +Defined in: [packages/query-core/src/types.ts:784](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L784) + +The timestamp for when the query most recently returned the `status` as `"error"`. + +*** + +### failureCount + +```ts +failureCount: number; +``` + +Defined in: [packages/query-core/src/types.ts:790](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L790) + +The failure count for the query. +- Incremented every time the query fails. +- Reset to `0` when the query succeeds. + +*** + +### failureReason + +```ts +failureReason: TError | null; +``` + +Defined in: [packages/query-core/src/types.ts:795](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L795) + +The failure reason for the query retry. +- Reset to `null` when the query succeeds. + +*** + +### fetchStatus + +```ts +fetchStatus: FetchStatus; +``` + +Defined in: [packages/query-core/src/types.ts:889](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L889) + +The fetch status of the query. +- `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. +- `paused`: The query wanted to fetch, but has been `paused`. +- `idle`: The query is not fetching. +- See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. + +*** + +### isEnabled + +```ts +isEnabled: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:867](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L867) + +`true` if this observer is enabled, `false` otherwise. + +*** + +### isError + +```ts +isError: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:804](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L804) + +A derived boolean from the `status` variable, provided for convenience. +- `true` if the query attempt resulted in an error. + +*** + +### isFetched + +```ts +isFetched: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:808](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L808) + +Will be `true` if the query has been fetched. + +*** + +### isFetchedAfterMount + +```ts +isFetchedAfterMount: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:813](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L813) + +Will be `true` if the query has been fetched after the component mounted. +- This property can be used to not show any previously cached data. + +*** + +### isFetching + +```ts +isFetching: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:818](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L818) + +A derived boolean from the `fetchStatus` variable, provided for convenience. +- `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. + +*** + +### ~~isInitialLoading~~ + +```ts +isInitialLoading: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:836](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L836) + +#### Deprecated + +`isInitialLoading` is being deprecated in favor of `isLoading` +and will be removed in the next major version. + +*** + +### isLoading + +```ts +isLoading: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:823](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L823) + +Is `true` whenever the first fetch for a query is in-flight. +- Is the same as `isFetching && isPending`. + +*** + +### isLoadingError + +```ts +isLoadingError: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:831](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L831) + +Will be `true` if the query failed while fetching for the first time. + +*** + +### isPaused + +```ts +isPaused: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:841](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L841) + +A derived boolean from the `fetchStatus` variable, provided for convenience. +- The query wanted to fetch, but has been `paused`. + +*** + +### isPending + +```ts +isPending: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:827](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L827) + +Will be `pending` if there's no cached data and no query attempt was finished yet. + +*** + +### isPlaceholderData + +```ts +isPlaceholderData: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:845](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L845) + +Will be `true` if the data shown is the placeholder data. + +*** + +### isRefetchError + +```ts +isRefetchError: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:849](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L849) + +Will be `true` if the query failed while refetching. + +*** + +### isRefetching + +```ts +isRefetching: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:854](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L854) + +Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. +- Is the same as `isFetching && !isPending`. + +*** + +### isStale + +```ts +isStale: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:858](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L858) + +Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. + +*** + +### isSuccess + +```ts +isSuccess: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:863](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L863) + +A derived boolean from the `status` variable, provided for convenience. +- `true` if the query has received a response with no errors and is ready to display its data. + +*** + +### refetch() + +```ts +refetch: (options?) => Promise>; +``` + +Defined in: [packages/query-core/src/types.ts:871](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L871) + +A function to manually refetch the query. + +#### Parameters + +##### options? + +[`RefetchOptions`](RefetchOptions.md) + +#### Returns + +`Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> + +*** + +### status + +```ts +status: QueryStatus; +``` + +Defined in: [packages/query-core/src/types.ts:881](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L881) + +The status of the query. +- Will be: + - `pending` if there's no cached data and no query attempt was finished yet. + - `error` if the query attempt resulted in an error. + - `success` if the query has received a response with no errors and is ready to display its data. diff --git a/docs/framework/preact/reference/interfaces/QueryObserverLoadingErrorResult.md b/docs/framework/preact/reference/interfaces/QueryObserverLoadingErrorResult.md new file mode 100644 index 00000000000..21b39fbffe3 --- /dev/null +++ b/docs/framework/preact/reference/interfaces/QueryObserverLoadingErrorResult.md @@ -0,0 +1,452 @@ +--- +id: QueryObserverLoadingErrorResult +title: QueryObserverLoadingErrorResult +--- + +Defined in: [packages/query-core/src/types.ts:923](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L923) + +## Extends + +- [`QueryObserverBaseResult`](QueryObserverBaseResult.md)\<`TData`, `TError`\> + +## Type Parameters + +### TData + +`TData` = `unknown` + +### TError + +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) + +## Properties + +### data + +```ts +data: undefined; +``` + +Defined in: [packages/query-core/src/types.ts:927](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L927) + +The last successfully resolved data for the query. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`data`](QueryObserverBaseResult.md#data) + +*** + +### dataUpdatedAt + +```ts +dataUpdatedAt: number; +``` + +Defined in: [packages/query-core/src/types.ts:775](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L775) + +The timestamp for when the query most recently returned the `status` as `"success"`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`dataUpdatedAt`](QueryObserverBaseResult.md#dataupdatedat) + +*** + +### error + +```ts +error: TError; +``` + +Defined in: [packages/query-core/src/types.ts:928](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L928) + +The error object for the query, if an error was thrown. +- Defaults to `null`. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`error`](QueryObserverBaseResult.md#error) + +*** + +### errorUpdateCount + +```ts +errorUpdateCount: number; +``` + +Defined in: [packages/query-core/src/types.ts:799](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L799) + +The sum of all errors. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`errorUpdateCount`](QueryObserverBaseResult.md#errorupdatecount) + +*** + +### errorUpdatedAt + +```ts +errorUpdatedAt: number; +``` + +Defined in: [packages/query-core/src/types.ts:784](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L784) + +The timestamp for when the query most recently returned the `status` as `"error"`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`errorUpdatedAt`](QueryObserverBaseResult.md#errorupdatedat) + +*** + +### failureCount + +```ts +failureCount: number; +``` + +Defined in: [packages/query-core/src/types.ts:790](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L790) + +The failure count for the query. +- Incremented every time the query fails. +- Reset to `0` when the query succeeds. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`failureCount`](QueryObserverBaseResult.md#failurecount) + +*** + +### failureReason + +```ts +failureReason: TError | null; +``` + +Defined in: [packages/query-core/src/types.ts:795](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L795) + +The failure reason for the query retry. +- Reset to `null` when the query succeeds. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`failureReason`](QueryObserverBaseResult.md#failurereason) + +*** + +### fetchStatus + +```ts +fetchStatus: FetchStatus; +``` + +Defined in: [packages/query-core/src/types.ts:889](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L889) + +The fetch status of the query. +- `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. +- `paused`: The query wanted to fetch, but has been `paused`. +- `idle`: The query is not fetching. +- See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`fetchStatus`](QueryObserverBaseResult.md#fetchstatus) + +*** + +### isEnabled + +```ts +isEnabled: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:867](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L867) + +`true` if this observer is enabled, `false` otherwise. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isEnabled`](QueryObserverBaseResult.md#isenabled) + +*** + +### isError + +```ts +isError: true; +``` + +Defined in: [packages/query-core/src/types.ts:929](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L929) + +A derived boolean from the `status` variable, provided for convenience. +- `true` if the query attempt resulted in an error. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isError`](QueryObserverBaseResult.md#iserror) + +*** + +### isFetched + +```ts +isFetched: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:808](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L808) + +Will be `true` if the query has been fetched. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isFetched`](QueryObserverBaseResult.md#isfetched) + +*** + +### isFetchedAfterMount + +```ts +isFetchedAfterMount: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:813](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L813) + +Will be `true` if the query has been fetched after the component mounted. +- This property can be used to not show any previously cached data. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isFetchedAfterMount`](QueryObserverBaseResult.md#isfetchedaftermount) + +*** + +### isFetching + +```ts +isFetching: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:818](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L818) + +A derived boolean from the `fetchStatus` variable, provided for convenience. +- `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isFetching`](QueryObserverBaseResult.md#isfetching) + +*** + +### ~~isInitialLoading~~ + +```ts +isInitialLoading: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:836](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L836) + +#### Deprecated + +`isInitialLoading` is being deprecated in favor of `isLoading` +and will be removed in the next major version. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isInitialLoading`](QueryObserverBaseResult.md#isinitialloading) + +*** + +### isLoading + +```ts +isLoading: false; +``` + +Defined in: [packages/query-core/src/types.ts:931](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L931) + +Is `true` whenever the first fetch for a query is in-flight. +- Is the same as `isFetching && isPending`. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoading`](QueryObserverBaseResult.md#isloading) + +*** + +### isLoadingError + +```ts +isLoadingError: true; +``` + +Defined in: [packages/query-core/src/types.ts:932](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L932) + +Will be `true` if the query failed while fetching for the first time. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoadingError`](QueryObserverBaseResult.md#isloadingerror) + +*** + +### isPaused + +```ts +isPaused: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:841](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L841) + +A derived boolean from the `fetchStatus` variable, provided for convenience. +- The query wanted to fetch, but has been `paused`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPaused`](QueryObserverBaseResult.md#ispaused) + +*** + +### isPending + +```ts +isPending: false; +``` + +Defined in: [packages/query-core/src/types.ts:930](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L930) + +Will be `pending` if there's no cached data and no query attempt was finished yet. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPending`](QueryObserverBaseResult.md#ispending) + +*** + +### isPlaceholderData + +```ts +isPlaceholderData: false; +``` + +Defined in: [packages/query-core/src/types.ts:935](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L935) + +Will be `true` if the data shown is the placeholder data. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPlaceholderData`](QueryObserverBaseResult.md#isplaceholderdata) + +*** + +### isRefetchError + +```ts +isRefetchError: false; +``` + +Defined in: [packages/query-core/src/types.ts:933](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L933) + +Will be `true` if the query failed while refetching. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetchError`](QueryObserverBaseResult.md#isrefetcherror) + +*** + +### isRefetching + +```ts +isRefetching: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:854](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L854) + +Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. +- Is the same as `isFetching && !isPending`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetching`](QueryObserverBaseResult.md#isrefetching) + +*** + +### isStale + +```ts +isStale: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:858](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L858) + +Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isStale`](QueryObserverBaseResult.md#isstale) + +*** + +### isSuccess + +```ts +isSuccess: false; +``` + +Defined in: [packages/query-core/src/types.ts:934](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L934) + +A derived boolean from the `status` variable, provided for convenience. +- `true` if the query has received a response with no errors and is ready to display its data. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isSuccess`](QueryObserverBaseResult.md#issuccess) + +*** + +### refetch() + +```ts +refetch: (options?) => Promise>; +``` + +Defined in: [packages/query-core/src/types.ts:871](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L871) + +A function to manually refetch the query. + +#### Parameters + +##### options? + +[`RefetchOptions`](RefetchOptions.md) + +#### Returns + +`Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`refetch`](QueryObserverBaseResult.md#refetch) + +*** + +### status + +```ts +status: "error"; +``` + +Defined in: [packages/query-core/src/types.ts:936](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L936) + +The status of the query. +- Will be: + - `pending` if there's no cached data and no query attempt was finished yet. + - `error` if the query attempt resulted in an error. + - `success` if the query has received a response with no errors and is ready to display its data. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`status`](QueryObserverBaseResult.md#status) diff --git a/docs/framework/preact/reference/interfaces/QueryObserverLoadingResult.md b/docs/framework/preact/reference/interfaces/QueryObserverLoadingResult.md new file mode 100644 index 00000000000..4966390127f --- /dev/null +++ b/docs/framework/preact/reference/interfaces/QueryObserverLoadingResult.md @@ -0,0 +1,452 @@ +--- +id: QueryObserverLoadingResult +title: QueryObserverLoadingResult +--- + +Defined in: [packages/query-core/src/types.ts:907](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L907) + +## Extends + +- [`QueryObserverBaseResult`](QueryObserverBaseResult.md)\<`TData`, `TError`\> + +## Type Parameters + +### TData + +`TData` = `unknown` + +### TError + +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) + +## Properties + +### data + +```ts +data: undefined; +``` + +Defined in: [packages/query-core/src/types.ts:911](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L911) + +The last successfully resolved data for the query. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`data`](QueryObserverBaseResult.md#data) + +*** + +### dataUpdatedAt + +```ts +dataUpdatedAt: number; +``` + +Defined in: [packages/query-core/src/types.ts:775](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L775) + +The timestamp for when the query most recently returned the `status` as `"success"`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`dataUpdatedAt`](QueryObserverBaseResult.md#dataupdatedat) + +*** + +### error + +```ts +error: null; +``` + +Defined in: [packages/query-core/src/types.ts:912](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L912) + +The error object for the query, if an error was thrown. +- Defaults to `null`. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`error`](QueryObserverBaseResult.md#error) + +*** + +### errorUpdateCount + +```ts +errorUpdateCount: number; +``` + +Defined in: [packages/query-core/src/types.ts:799](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L799) + +The sum of all errors. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`errorUpdateCount`](QueryObserverBaseResult.md#errorupdatecount) + +*** + +### errorUpdatedAt + +```ts +errorUpdatedAt: number; +``` + +Defined in: [packages/query-core/src/types.ts:784](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L784) + +The timestamp for when the query most recently returned the `status` as `"error"`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`errorUpdatedAt`](QueryObserverBaseResult.md#errorupdatedat) + +*** + +### failureCount + +```ts +failureCount: number; +``` + +Defined in: [packages/query-core/src/types.ts:790](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L790) + +The failure count for the query. +- Incremented every time the query fails. +- Reset to `0` when the query succeeds. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`failureCount`](QueryObserverBaseResult.md#failurecount) + +*** + +### failureReason + +```ts +failureReason: TError | null; +``` + +Defined in: [packages/query-core/src/types.ts:795](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L795) + +The failure reason for the query retry. +- Reset to `null` when the query succeeds. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`failureReason`](QueryObserverBaseResult.md#failurereason) + +*** + +### fetchStatus + +```ts +fetchStatus: FetchStatus; +``` + +Defined in: [packages/query-core/src/types.ts:889](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L889) + +The fetch status of the query. +- `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. +- `paused`: The query wanted to fetch, but has been `paused`. +- `idle`: The query is not fetching. +- See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`fetchStatus`](QueryObserverBaseResult.md#fetchstatus) + +*** + +### isEnabled + +```ts +isEnabled: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:867](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L867) + +`true` if this observer is enabled, `false` otherwise. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isEnabled`](QueryObserverBaseResult.md#isenabled) + +*** + +### isError + +```ts +isError: false; +``` + +Defined in: [packages/query-core/src/types.ts:913](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L913) + +A derived boolean from the `status` variable, provided for convenience. +- `true` if the query attempt resulted in an error. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isError`](QueryObserverBaseResult.md#iserror) + +*** + +### isFetched + +```ts +isFetched: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:808](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L808) + +Will be `true` if the query has been fetched. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isFetched`](QueryObserverBaseResult.md#isfetched) + +*** + +### isFetchedAfterMount + +```ts +isFetchedAfterMount: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:813](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L813) + +Will be `true` if the query has been fetched after the component mounted. +- This property can be used to not show any previously cached data. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isFetchedAfterMount`](QueryObserverBaseResult.md#isfetchedaftermount) + +*** + +### isFetching + +```ts +isFetching: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:818](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L818) + +A derived boolean from the `fetchStatus` variable, provided for convenience. +- `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isFetching`](QueryObserverBaseResult.md#isfetching) + +*** + +### ~~isInitialLoading~~ + +```ts +isInitialLoading: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:836](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L836) + +#### Deprecated + +`isInitialLoading` is being deprecated in favor of `isLoading` +and will be removed in the next major version. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isInitialLoading`](QueryObserverBaseResult.md#isinitialloading) + +*** + +### isLoading + +```ts +isLoading: true; +``` + +Defined in: [packages/query-core/src/types.ts:915](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L915) + +Is `true` whenever the first fetch for a query is in-flight. +- Is the same as `isFetching && isPending`. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoading`](QueryObserverBaseResult.md#isloading) + +*** + +### isLoadingError + +```ts +isLoadingError: false; +``` + +Defined in: [packages/query-core/src/types.ts:916](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L916) + +Will be `true` if the query failed while fetching for the first time. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoadingError`](QueryObserverBaseResult.md#isloadingerror) + +*** + +### isPaused + +```ts +isPaused: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:841](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L841) + +A derived boolean from the `fetchStatus` variable, provided for convenience. +- The query wanted to fetch, but has been `paused`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPaused`](QueryObserverBaseResult.md#ispaused) + +*** + +### isPending + +```ts +isPending: true; +``` + +Defined in: [packages/query-core/src/types.ts:914](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L914) + +Will be `pending` if there's no cached data and no query attempt was finished yet. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPending`](QueryObserverBaseResult.md#ispending) + +*** + +### isPlaceholderData + +```ts +isPlaceholderData: false; +``` + +Defined in: [packages/query-core/src/types.ts:919](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L919) + +Will be `true` if the data shown is the placeholder data. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPlaceholderData`](QueryObserverBaseResult.md#isplaceholderdata) + +*** + +### isRefetchError + +```ts +isRefetchError: false; +``` + +Defined in: [packages/query-core/src/types.ts:917](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L917) + +Will be `true` if the query failed while refetching. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetchError`](QueryObserverBaseResult.md#isrefetcherror) + +*** + +### isRefetching + +```ts +isRefetching: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:854](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L854) + +Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. +- Is the same as `isFetching && !isPending`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetching`](QueryObserverBaseResult.md#isrefetching) + +*** + +### isStale + +```ts +isStale: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:858](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L858) + +Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isStale`](QueryObserverBaseResult.md#isstale) + +*** + +### isSuccess + +```ts +isSuccess: false; +``` + +Defined in: [packages/query-core/src/types.ts:918](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L918) + +A derived boolean from the `status` variable, provided for convenience. +- `true` if the query has received a response with no errors and is ready to display its data. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isSuccess`](QueryObserverBaseResult.md#issuccess) + +*** + +### refetch() + +```ts +refetch: (options?) => Promise>; +``` + +Defined in: [packages/query-core/src/types.ts:871](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L871) + +A function to manually refetch the query. + +#### Parameters + +##### options? + +[`RefetchOptions`](RefetchOptions.md) + +#### Returns + +`Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`refetch`](QueryObserverBaseResult.md#refetch) + +*** + +### status + +```ts +status: "pending"; +``` + +Defined in: [packages/query-core/src/types.ts:920](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L920) + +The status of the query. +- Will be: + - `pending` if there's no cached data and no query attempt was finished yet. + - `error` if the query attempt resulted in an error. + - `success` if the query has received a response with no errors and is ready to display its data. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`status`](QueryObserverBaseResult.md#status) diff --git a/docs/framework/preact/reference/interfaces/QueryObserverOptions.md b/docs/framework/preact/reference/interfaces/QueryObserverOptions.md new file mode 100644 index 00000000000..c325b42f230 --- /dev/null +++ b/docs/framework/preact/reference/interfaces/QueryObserverOptions.md @@ -0,0 +1,561 @@ +--- +id: QueryObserverOptions +title: QueryObserverOptions +--- + +Defined in: [packages/query-core/src/types.ts:380](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L380) + +## Extends + +- [`WithRequired`](../type-aliases/WithRequired.md)\<[`QueryOptions`](QueryOptions.md)\<`TQueryFnData`, `TError`, `TQueryData`, `TQueryKey`, `TPageParam`\>, `"queryKey"`\> + +## Extended by + +- [`InfiniteQueryObserverOptions`](InfiniteQueryObserverOptions.md) +- [`UseBaseQueryOptions`](UseBaseQueryOptions.md) + +## Type Parameters + +### TQueryFnData + +`TQueryFnData` = `unknown` + +### TError + +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) + +### TData + +`TData` = `TQueryFnData` + +### TQueryData + +`TQueryData` = `TQueryFnData` + +### TQueryKey + +`TQueryKey` *extends* [`QueryKey`](../type-aliases/QueryKey.md) = [`QueryKey`](../type-aliases/QueryKey.md) + +### TPageParam + +`TPageParam` = `never` + +## Properties + +### enabled? + +```ts +optional enabled: QueryBooleanOption; +``` + +Defined in: [packages/query-core/src/types.ts:398](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L398) + +Set this to `false` or a function that returns `false` to disable automatic refetching when the query mounts or changes query keys. +To refetch the query, use the `refetch` method returned from the `useQuery` instance. +Accepts a boolean or function that returns a boolean. + +Defaults to `true`. + +*** + +### gcTime? + +```ts +optional gcTime: number; +``` + +Defined in: [packages/query-core/src/types.ts:277](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L277) + +The time in milliseconds that unused/inactive cache data remains in memory. +When a query's cache becomes unused or inactive, that cache data will be garbage collected after this duration. +When different garbage collection times are specified, the longest one will be used. +Setting it to `Infinity` will disable garbage collection. + +Defaults to `5 * 60 * 1000` (5 minutes), or `Infinity` during SSR. + +Note: the maximum allowed time is about 24 days, imposed by `setTimeout`'s 32-bit signed integer delay — see +`timeoutManager.setTimeoutProvider` for a workaround. + +#### Inherited from + +```ts +WithRequired.gcTime +``` + +*** + +### initialData? + +```ts +optional initialData: + | TQueryData +| InitialDataFunction; +``` + +Defined in: [packages/query-core/src/types.ts:317](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L317) + +If set, this value will be used as the initial data for the query cache (as long as the query hasn't been +created or cached yet). +If set to a function, the function will be called **once** during the shared/root query initialization, and be +expected to synchronously return the initial data. +Initial data is considered stale by default unless a `staleTime` has been set. +`initialData` **is persisted** to the cache. + +#### Inherited from + +```ts +WithRequired.initialData +``` + +*** + +### initialDataUpdatedAt? + +```ts +optional initialDataUpdatedAt: number | () => number | undefined; +``` + +Defined in: [packages/query-core/src/types.ts:321](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L321) + +If set, this value will be used as the time (in milliseconds) of when the `initialData` itself was last updated. + +#### Inherited from + +```ts +WithRequired.initialDataUpdatedAt +``` + +*** + +### maxPages? + +```ts +optional maxPages: number; +``` + +Defined in: [packages/query-core/src/types.ts:345](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L345) + +Maximum number of pages to store in the data of an infinite query. + +#### Inherited from + +```ts +WithRequired.maxPages +``` + +*** + +### meta? + +```ts +optional meta: Record; +``` + +Defined in: [packages/query-core/src/types.ts:341](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L341) + +Additional payload to be stored on each query. +Use this property to pass information that can be used in other places. + +#### Inherited from + +```ts +WithRequired.meta +``` + +*** + +### networkMode? + +```ts +optional networkMode: NetworkMode; +``` + +Defined in: [packages/query-core/src/types.ts:265](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L265) + +Controls whether a query is allowed to run based on the current network connectivity. + +Defaults to `'online'`. + +#### See + +[Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. + +#### Inherited from + +```ts +WithRequired.networkMode +``` + +*** + +### notifyOnChangeProps? + +```ts +optional notifyOnChangeProps: NotifyOnChangeProps; +``` + +Defined in: [packages/query-core/src/types.ts:484](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L484) + +If set, the component will only re-render if any of the listed properties change. +When set to `['data', 'error']`, the component will only re-render when the `data` or `error` properties change. +When set to `'all'`, the component will re-render whenever a query is updated. +When set to a function, the function will be executed to compute the list of properties. + +Defaults to `undefined`, in which case property access is tracked automatically, and the +component only re-renders when one of the tracked properties changes. + +*** + +### persister? + +```ts +optional persister: QueryPersister, TPageParam>; +``` + +Defined in: [packages/query-core/src/types.ts:290](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L290) + +This option can be used to persist the result of a query to an external storage, bypassing the need to actually +call the `queryFn`. Useful for persisting a query's data across e.g. server/client boundaries. + +#### Inherited from + +```ts +WithRequired.persister +``` + +*** + +### placeholderData? + +```ts +optional placeholderData: + | NonFunctionGuard +| PlaceholderDataFunction, TError, NonFunctionGuard, TQueryKey>; +``` + +Defined in: [packages/query-core/src/types.ts:511](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L511) + +If set, this value will be used as the placeholder data for this particular query observer while the query is still in the `loading` data and no initialData has been provided. + +*** + +### queryFn? + +```ts +optional queryFn: + | typeof skipToken +| QueryFunction; +``` + +Defined in: [packages/query-core/src/types.ts:285](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L285) + +The function that the query will use to request data. +Required, unless a default query function has been set via `queryClient.setQueryDefaults` or +`queryClient.setDefaultOptions`. +Receives a [QueryFunctionContext](../type-aliases/QueryFunctionContext.md). +Must return a promise that will either resolve data or throw an error. The data cannot be `undefined`. + +#### Inherited from + +```ts +WithRequired.queryFn +``` + +*** + +### queryHash? + +```ts +optional queryHash: string; +``` + +Defined in: [packages/query-core/src/types.ts:295](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L295) + +The hashed form of `queryKey`, computed with `queryKeyHashFn` (or the default hashing function otherwise). Used +as the actual cache key internally. + +#### Inherited from + +```ts +WithRequired.queryHash +``` + +*** + +### queryKey + +```ts +queryKey: TQueryKey & object; +``` + +Defined in: [packages/query-core/src/types.ts:304](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L304) + +The query key to use for this query. + +The query key will be hashed into a stable hash. See [Query Keys](https://tanstack.com/query/latest/docs/framework/react/guides/query-keys) +for more information. + +The query will automatically update when this key changes (as long as `enabled` is not set to `false`). + +#### Inherited from + +```ts +WithRequired.queryKey +``` + +*** + +### queryKeyHashFn? + +```ts +optional queryKeyHashFn: QueryKeyHashFunction; +``` + +Defined in: [packages/query-core/src/types.ts:308](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L308) + +If specified, this function is used to hash the `queryKey` to a string. + +#### Inherited from + +```ts +WithRequired.queryKeyHashFn +``` + +*** + +### refetchInterval? + +```ts +optional refetchInterval: number | false | (query) => number | false | undefined; +``` + +Defined in: [packages/query-core/src/types.ts:414](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L414) + +If set to a number, the query will continuously refetch at this frequency in milliseconds. +If set to a function, the function will be executed with the latest data and query to compute a frequency + +Defaults to `false`. + +*** + +### refetchIntervalInBackground? + +```ts +optional refetchIntervalInBackground: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:425](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L425) + +If set to `true`, the query will continue to refetch while their tab/window is in the background. + +Defaults to `false`. + +*** + +### refetchOnMount? + +```ts +optional refetchOnMount: boolean | "always" | (query) => boolean | "always"; +``` + +Defined in: [packages/query-core/src/types.ts:462](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L462) + +If set to `true`, the query will refetch on mount if the data is stale. +If set to `false`, will disable additional instances of a query to trigger background refetch. +If set to `'always'`, the query will always refetch on mount (except when `staleTime: 'static'` is used). +If set to a function, the function will be executed with the latest data and query to compute the value + +Defaults to `true`. + +*** + +### refetchOnReconnect? + +```ts +optional refetchOnReconnect: boolean | "always" | (query) => boolean | "always"; +``` + +Defined in: [packages/query-core/src/types.ts:448](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L448) + +If set to `true`, the query will refetch on reconnect if the data is stale. +If set to `false`, the query will not refetch on reconnect. +If set to `'always'`, the query will always refetch on reconnect (except when `staleTime: 'static'` is used). +If set to a function, the function will be executed with the latest data and query to compute the value. + +Defaults to `true` unless `networkMode` is `'always'`. + +*** + +### refetchOnWindowFocus? + +```ts +optional refetchOnWindowFocus: boolean | "always" | (query) => boolean | "always"; +``` + +Defined in: [packages/query-core/src/types.ts:434](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L434) + +If set to `true`, the query will refetch on window focus if the data is stale. +If set to `false`, the query will not refetch on window focus. +If set to `'always'`, the query will always refetch on window focus (except when `staleTime: 'static'` is used). +If set to a function, the function will be executed with the latest data and query to compute the value. + +Defaults to `true`. + +*** + +### retry? + +```ts +optional retry: RetryValue; +``` + +Defined in: [packages/query-core/src/types.ts:246](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L246) + +If `false`, failed queries will not retry by default. +If `true`, failed queries will retry infinitely. +If set to an integer number, e.g. 3, failed queries will retry until the failed query count meets that number. +If set to a function `(failureCount, error) => boolean` failed queries will retry until the function returns false. + +Defaults to `3` on the client and `0` on the server. + +#### Inherited from + +```ts +WithRequired.retry +``` + +*** + +### retryDelay? + +```ts +optional retryDelay: RetryDelayValue; +``` + +Defined in: [packages/query-core/src/types.ts:258](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L258) + +This function receives a `retryAttempt` integer and the actual Error and returns the delay to apply before the +next attempt in milliseconds. + +A function like `attempt => Math.min(attempt > 1 ? 2 ** attempt * 1000 : 1000, 30 * 1000)` applies exponential +backoff. + +A function like `attempt => attempt * 1000` applies linear backoff. + +Defaults to a function that applies exponential backoff, capped at 30 seconds. + +#### Inherited from + +```ts +WithRequired.retryDelay +``` + +*** + +### retryOnMount? + +```ts +optional retryOnMount: QueryBooleanOption; +``` + +Defined in: [packages/query-core/src/types.ts:474](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L474) + +If set to `false`, the query will not be retried on mount if it contains an error. +If set to a function, the function will be executed with the query to compute the value. + +Defaults to `true`. + +*** + +### select()? + +```ts +optional select: (data) => TData; +``` + +Defined in: [packages/query-core/src/types.ts:500](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L500) + +This option can be used to transform or select a part of the data returned by the query function. It affects +the returned `data` value, but does not affect what gets stored in the query cache. +The `select` function will only run if `data` changed, or if the reference to the `select` function itself +changes. To optimize, memoize the function so its reference stays stable across calls. + +#### Parameters + +##### data + +`TQueryData` + +#### Returns + +`TData` + +*** + +### staleTime? + +```ts +optional staleTime: StaleTimeFunction; +``` + +Defined in: [packages/query-core/src/types.ts:407](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L407) + +The time in milliseconds after data is considered stale. +If set to `Infinity`, the data will never be considered stale. +If set to `'static'`, the data will never be considered stale. +If set to a function, the function will be executed with the query to compute a `staleTime`. + +Defaults to `0`. + +*** + +### structuralSharing? + +```ts +optional structuralSharing: boolean | (oldData, newData) => unknown; +``` + +Defined in: [packages/query-core/src/types.ts:330](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L330) + +Set this to `false` to disable structural sharing between query results. +Set this to a function which accepts the old and new data and returns resolved data of the same type to implement custom structural sharing logic. + +Defaults to `true`. + +#### Inherited from + +```ts +WithRequired.structuralSharing +``` + +*** + +### suspense? + +```ts +optional suspense: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:507](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L507) + +If set to `true`, the query will suspend when `status === 'pending'` +and throw errors when `status === 'error'`. + +Defaults to `false`. + +*** + +### throwOnError? + +```ts +optional throwOnError: ThrowOnError; +``` + +Defined in: [packages/query-core/src/types.ts:493](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L493) + +Whether errors should be thrown instead of setting the `error` property. +If set to `true` or `suspense` is `true`, all errors will be thrown to the error boundary. +If set to `false` and `suspense` is `false`, errors are returned as state. +If set to a function, it will be passed the error and the query, and it should return a boolean indicating whether to show the error in an error boundary (`true`) or return the error as state (`false`). + +Defaults to `false`. diff --git a/docs/framework/preact/reference/interfaces/QueryObserverPendingResult.md b/docs/framework/preact/reference/interfaces/QueryObserverPendingResult.md new file mode 100644 index 00000000000..8f00c426b64 --- /dev/null +++ b/docs/framework/preact/reference/interfaces/QueryObserverPendingResult.md @@ -0,0 +1,452 @@ +--- +id: QueryObserverPendingResult +title: QueryObserverPendingResult +--- + +Defined in: [packages/query-core/src/types.ts:892](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L892) + +## Extends + +- [`QueryObserverBaseResult`](QueryObserverBaseResult.md)\<`TData`, `TError`\> + +## Type Parameters + +### TData + +`TData` = `unknown` + +### TError + +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) + +## Properties + +### data + +```ts +data: undefined; +``` + +Defined in: [packages/query-core/src/types.ts:896](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L896) + +The last successfully resolved data for the query. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`data`](QueryObserverBaseResult.md#data) + +*** + +### dataUpdatedAt + +```ts +dataUpdatedAt: number; +``` + +Defined in: [packages/query-core/src/types.ts:775](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L775) + +The timestamp for when the query most recently returned the `status` as `"success"`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`dataUpdatedAt`](QueryObserverBaseResult.md#dataupdatedat) + +*** + +### error + +```ts +error: null; +``` + +Defined in: [packages/query-core/src/types.ts:897](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L897) + +The error object for the query, if an error was thrown. +- Defaults to `null`. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`error`](QueryObserverBaseResult.md#error) + +*** + +### errorUpdateCount + +```ts +errorUpdateCount: number; +``` + +Defined in: [packages/query-core/src/types.ts:799](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L799) + +The sum of all errors. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`errorUpdateCount`](QueryObserverBaseResult.md#errorupdatecount) + +*** + +### errorUpdatedAt + +```ts +errorUpdatedAt: number; +``` + +Defined in: [packages/query-core/src/types.ts:784](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L784) + +The timestamp for when the query most recently returned the `status` as `"error"`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`errorUpdatedAt`](QueryObserverBaseResult.md#errorupdatedat) + +*** + +### failureCount + +```ts +failureCount: number; +``` + +Defined in: [packages/query-core/src/types.ts:790](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L790) + +The failure count for the query. +- Incremented every time the query fails. +- Reset to `0` when the query succeeds. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`failureCount`](QueryObserverBaseResult.md#failurecount) + +*** + +### failureReason + +```ts +failureReason: TError | null; +``` + +Defined in: [packages/query-core/src/types.ts:795](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L795) + +The failure reason for the query retry. +- Reset to `null` when the query succeeds. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`failureReason`](QueryObserverBaseResult.md#failurereason) + +*** + +### fetchStatus + +```ts +fetchStatus: FetchStatus; +``` + +Defined in: [packages/query-core/src/types.ts:889](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L889) + +The fetch status of the query. +- `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. +- `paused`: The query wanted to fetch, but has been `paused`. +- `idle`: The query is not fetching. +- See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`fetchStatus`](QueryObserverBaseResult.md#fetchstatus) + +*** + +### isEnabled + +```ts +isEnabled: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:867](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L867) + +`true` if this observer is enabled, `false` otherwise. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isEnabled`](QueryObserverBaseResult.md#isenabled) + +*** + +### isError + +```ts +isError: false; +``` + +Defined in: [packages/query-core/src/types.ts:898](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L898) + +A derived boolean from the `status` variable, provided for convenience. +- `true` if the query attempt resulted in an error. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isError`](QueryObserverBaseResult.md#iserror) + +*** + +### isFetched + +```ts +isFetched: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:808](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L808) + +Will be `true` if the query has been fetched. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isFetched`](QueryObserverBaseResult.md#isfetched) + +*** + +### isFetchedAfterMount + +```ts +isFetchedAfterMount: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:813](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L813) + +Will be `true` if the query has been fetched after the component mounted. +- This property can be used to not show any previously cached data. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isFetchedAfterMount`](QueryObserverBaseResult.md#isfetchedaftermount) + +*** + +### isFetching + +```ts +isFetching: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:818](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L818) + +A derived boolean from the `fetchStatus` variable, provided for convenience. +- `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isFetching`](QueryObserverBaseResult.md#isfetching) + +*** + +### ~~isInitialLoading~~ + +```ts +isInitialLoading: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:836](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L836) + +#### Deprecated + +`isInitialLoading` is being deprecated in favor of `isLoading` +and will be removed in the next major version. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isInitialLoading`](QueryObserverBaseResult.md#isinitialloading) + +*** + +### isLoading + +```ts +isLoading: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:823](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L823) + +Is `true` whenever the first fetch for a query is in-flight. +- Is the same as `isFetching && isPending`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoading`](QueryObserverBaseResult.md#isloading) + +*** + +### isLoadingError + +```ts +isLoadingError: false; +``` + +Defined in: [packages/query-core/src/types.ts:900](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L900) + +Will be `true` if the query failed while fetching for the first time. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoadingError`](QueryObserverBaseResult.md#isloadingerror) + +*** + +### isPaused + +```ts +isPaused: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:841](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L841) + +A derived boolean from the `fetchStatus` variable, provided for convenience. +- The query wanted to fetch, but has been `paused`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPaused`](QueryObserverBaseResult.md#ispaused) + +*** + +### isPending + +```ts +isPending: true; +``` + +Defined in: [packages/query-core/src/types.ts:899](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L899) + +Will be `pending` if there's no cached data and no query attempt was finished yet. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPending`](QueryObserverBaseResult.md#ispending) + +*** + +### isPlaceholderData + +```ts +isPlaceholderData: false; +``` + +Defined in: [packages/query-core/src/types.ts:903](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L903) + +Will be `true` if the data shown is the placeholder data. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPlaceholderData`](QueryObserverBaseResult.md#isplaceholderdata) + +*** + +### isRefetchError + +```ts +isRefetchError: false; +``` + +Defined in: [packages/query-core/src/types.ts:901](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L901) + +Will be `true` if the query failed while refetching. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetchError`](QueryObserverBaseResult.md#isrefetcherror) + +*** + +### isRefetching + +```ts +isRefetching: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:854](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L854) + +Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. +- Is the same as `isFetching && !isPending`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetching`](QueryObserverBaseResult.md#isrefetching) + +*** + +### isStale + +```ts +isStale: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:858](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L858) + +Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isStale`](QueryObserverBaseResult.md#isstale) + +*** + +### isSuccess + +```ts +isSuccess: false; +``` + +Defined in: [packages/query-core/src/types.ts:902](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L902) + +A derived boolean from the `status` variable, provided for convenience. +- `true` if the query has received a response with no errors and is ready to display its data. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isSuccess`](QueryObserverBaseResult.md#issuccess) + +*** + +### refetch() + +```ts +refetch: (options?) => Promise>; +``` + +Defined in: [packages/query-core/src/types.ts:871](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L871) + +A function to manually refetch the query. + +#### Parameters + +##### options? + +[`RefetchOptions`](RefetchOptions.md) + +#### Returns + +`Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`refetch`](QueryObserverBaseResult.md#refetch) + +*** + +### status + +```ts +status: "pending"; +``` + +Defined in: [packages/query-core/src/types.ts:904](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L904) + +The status of the query. +- Will be: + - `pending` if there's no cached data and no query attempt was finished yet. + - `error` if the query attempt resulted in an error. + - `success` if the query has received a response with no errors and is ready to display its data. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`status`](QueryObserverBaseResult.md#status) diff --git a/docs/framework/preact/reference/interfaces/QueryObserverPlaceholderResult.md b/docs/framework/preact/reference/interfaces/QueryObserverPlaceholderResult.md new file mode 100644 index 00000000000..bbf3da387f9 --- /dev/null +++ b/docs/framework/preact/reference/interfaces/QueryObserverPlaceholderResult.md @@ -0,0 +1,452 @@ +--- +id: QueryObserverPlaceholderResult +title: QueryObserverPlaceholderResult +--- + +Defined in: [packages/query-core/src/types.ts:971](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L971) + +## Extends + +- [`QueryObserverBaseResult`](QueryObserverBaseResult.md)\<`TData`, `TError`\> + +## Type Parameters + +### TData + +`TData` = `unknown` + +### TError + +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) + +## Properties + +### data + +```ts +data: TData; +``` + +Defined in: [packages/query-core/src/types.ts:975](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L975) + +The last successfully resolved data for the query. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`data`](QueryObserverBaseResult.md#data) + +*** + +### dataUpdatedAt + +```ts +dataUpdatedAt: number; +``` + +Defined in: [packages/query-core/src/types.ts:775](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L775) + +The timestamp for when the query most recently returned the `status` as `"success"`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`dataUpdatedAt`](QueryObserverBaseResult.md#dataupdatedat) + +*** + +### error + +```ts +error: null; +``` + +Defined in: [packages/query-core/src/types.ts:977](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L977) + +The error object for the query, if an error was thrown. +- Defaults to `null`. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`error`](QueryObserverBaseResult.md#error) + +*** + +### errorUpdateCount + +```ts +errorUpdateCount: number; +``` + +Defined in: [packages/query-core/src/types.ts:799](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L799) + +The sum of all errors. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`errorUpdateCount`](QueryObserverBaseResult.md#errorupdatecount) + +*** + +### errorUpdatedAt + +```ts +errorUpdatedAt: number; +``` + +Defined in: [packages/query-core/src/types.ts:784](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L784) + +The timestamp for when the query most recently returned the `status` as `"error"`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`errorUpdatedAt`](QueryObserverBaseResult.md#errorupdatedat) + +*** + +### failureCount + +```ts +failureCount: number; +``` + +Defined in: [packages/query-core/src/types.ts:790](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L790) + +The failure count for the query. +- Incremented every time the query fails. +- Reset to `0` when the query succeeds. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`failureCount`](QueryObserverBaseResult.md#failurecount) + +*** + +### failureReason + +```ts +failureReason: TError | null; +``` + +Defined in: [packages/query-core/src/types.ts:795](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L795) + +The failure reason for the query retry. +- Reset to `null` when the query succeeds. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`failureReason`](QueryObserverBaseResult.md#failurereason) + +*** + +### fetchStatus + +```ts +fetchStatus: FetchStatus; +``` + +Defined in: [packages/query-core/src/types.ts:889](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L889) + +The fetch status of the query. +- `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. +- `paused`: The query wanted to fetch, but has been `paused`. +- `idle`: The query is not fetching. +- See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`fetchStatus`](QueryObserverBaseResult.md#fetchstatus) + +*** + +### isEnabled + +```ts +isEnabled: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:867](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L867) + +`true` if this observer is enabled, `false` otherwise. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isEnabled`](QueryObserverBaseResult.md#isenabled) + +*** + +### isError + +```ts +isError: false; +``` + +Defined in: [packages/query-core/src/types.ts:976](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L976) + +A derived boolean from the `status` variable, provided for convenience. +- `true` if the query attempt resulted in an error. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isError`](QueryObserverBaseResult.md#iserror) + +*** + +### isFetched + +```ts +isFetched: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:808](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L808) + +Will be `true` if the query has been fetched. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isFetched`](QueryObserverBaseResult.md#isfetched) + +*** + +### isFetchedAfterMount + +```ts +isFetchedAfterMount: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:813](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L813) + +Will be `true` if the query has been fetched after the component mounted. +- This property can be used to not show any previously cached data. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isFetchedAfterMount`](QueryObserverBaseResult.md#isfetchedaftermount) + +*** + +### isFetching + +```ts +isFetching: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:818](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L818) + +A derived boolean from the `fetchStatus` variable, provided for convenience. +- `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isFetching`](QueryObserverBaseResult.md#isfetching) + +*** + +### ~~isInitialLoading~~ + +```ts +isInitialLoading: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:836](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L836) + +#### Deprecated + +`isInitialLoading` is being deprecated in favor of `isLoading` +and will be removed in the next major version. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isInitialLoading`](QueryObserverBaseResult.md#isinitialloading) + +*** + +### isLoading + +```ts +isLoading: false; +``` + +Defined in: [packages/query-core/src/types.ts:979](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L979) + +Is `true` whenever the first fetch for a query is in-flight. +- Is the same as `isFetching && isPending`. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoading`](QueryObserverBaseResult.md#isloading) + +*** + +### isLoadingError + +```ts +isLoadingError: false; +``` + +Defined in: [packages/query-core/src/types.ts:980](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L980) + +Will be `true` if the query failed while fetching for the first time. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoadingError`](QueryObserverBaseResult.md#isloadingerror) + +*** + +### isPaused + +```ts +isPaused: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:841](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L841) + +A derived boolean from the `fetchStatus` variable, provided for convenience. +- The query wanted to fetch, but has been `paused`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPaused`](QueryObserverBaseResult.md#ispaused) + +*** + +### isPending + +```ts +isPending: false; +``` + +Defined in: [packages/query-core/src/types.ts:978](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L978) + +Will be `pending` if there's no cached data and no query attempt was finished yet. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPending`](QueryObserverBaseResult.md#ispending) + +*** + +### isPlaceholderData + +```ts +isPlaceholderData: true; +``` + +Defined in: [packages/query-core/src/types.ts:983](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L983) + +Will be `true` if the data shown is the placeholder data. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPlaceholderData`](QueryObserverBaseResult.md#isplaceholderdata) + +*** + +### isRefetchError + +```ts +isRefetchError: false; +``` + +Defined in: [packages/query-core/src/types.ts:981](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L981) + +Will be `true` if the query failed while refetching. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetchError`](QueryObserverBaseResult.md#isrefetcherror) + +*** + +### isRefetching + +```ts +isRefetching: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:854](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L854) + +Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. +- Is the same as `isFetching && !isPending`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetching`](QueryObserverBaseResult.md#isrefetching) + +*** + +### isStale + +```ts +isStale: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:858](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L858) + +Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isStale`](QueryObserverBaseResult.md#isstale) + +*** + +### isSuccess + +```ts +isSuccess: true; +``` + +Defined in: [packages/query-core/src/types.ts:982](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L982) + +A derived boolean from the `status` variable, provided for convenience. +- `true` if the query has received a response with no errors and is ready to display its data. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isSuccess`](QueryObserverBaseResult.md#issuccess) + +*** + +### refetch() + +```ts +refetch: (options?) => Promise>; +``` + +Defined in: [packages/query-core/src/types.ts:871](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L871) + +A function to manually refetch the query. + +#### Parameters + +##### options? + +[`RefetchOptions`](RefetchOptions.md) + +#### Returns + +`Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`refetch`](QueryObserverBaseResult.md#refetch) + +*** + +### status + +```ts +status: "success"; +``` + +Defined in: [packages/query-core/src/types.ts:984](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L984) + +The status of the query. +- Will be: + - `pending` if there's no cached data and no query attempt was finished yet. + - `error` if the query attempt resulted in an error. + - `success` if the query has received a response with no errors and is ready to display its data. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`status`](QueryObserverBaseResult.md#status) diff --git a/docs/framework/preact/reference/interfaces/QueryObserverRefetchErrorResult.md b/docs/framework/preact/reference/interfaces/QueryObserverRefetchErrorResult.md new file mode 100644 index 00000000000..345ecab35e1 --- /dev/null +++ b/docs/framework/preact/reference/interfaces/QueryObserverRefetchErrorResult.md @@ -0,0 +1,452 @@ +--- +id: QueryObserverRefetchErrorResult +title: QueryObserverRefetchErrorResult +--- + +Defined in: [packages/query-core/src/types.ts:939](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L939) + +## Extends + +- [`QueryObserverBaseResult`](QueryObserverBaseResult.md)\<`TData`, `TError`\> + +## Type Parameters + +### TData + +`TData` = `unknown` + +### TError + +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) + +## Properties + +### data + +```ts +data: TData; +``` + +Defined in: [packages/query-core/src/types.ts:943](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L943) + +The last successfully resolved data for the query. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`data`](QueryObserverBaseResult.md#data) + +*** + +### dataUpdatedAt + +```ts +dataUpdatedAt: number; +``` + +Defined in: [packages/query-core/src/types.ts:775](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L775) + +The timestamp for when the query most recently returned the `status` as `"success"`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`dataUpdatedAt`](QueryObserverBaseResult.md#dataupdatedat) + +*** + +### error + +```ts +error: TError; +``` + +Defined in: [packages/query-core/src/types.ts:944](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L944) + +The error object for the query, if an error was thrown. +- Defaults to `null`. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`error`](QueryObserverBaseResult.md#error) + +*** + +### errorUpdateCount + +```ts +errorUpdateCount: number; +``` + +Defined in: [packages/query-core/src/types.ts:799](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L799) + +The sum of all errors. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`errorUpdateCount`](QueryObserverBaseResult.md#errorupdatecount) + +*** + +### errorUpdatedAt + +```ts +errorUpdatedAt: number; +``` + +Defined in: [packages/query-core/src/types.ts:784](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L784) + +The timestamp for when the query most recently returned the `status` as `"error"`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`errorUpdatedAt`](QueryObserverBaseResult.md#errorupdatedat) + +*** + +### failureCount + +```ts +failureCount: number; +``` + +Defined in: [packages/query-core/src/types.ts:790](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L790) + +The failure count for the query. +- Incremented every time the query fails. +- Reset to `0` when the query succeeds. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`failureCount`](QueryObserverBaseResult.md#failurecount) + +*** + +### failureReason + +```ts +failureReason: TError | null; +``` + +Defined in: [packages/query-core/src/types.ts:795](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L795) + +The failure reason for the query retry. +- Reset to `null` when the query succeeds. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`failureReason`](QueryObserverBaseResult.md#failurereason) + +*** + +### fetchStatus + +```ts +fetchStatus: FetchStatus; +``` + +Defined in: [packages/query-core/src/types.ts:889](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L889) + +The fetch status of the query. +- `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. +- `paused`: The query wanted to fetch, but has been `paused`. +- `idle`: The query is not fetching. +- See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`fetchStatus`](QueryObserverBaseResult.md#fetchstatus) + +*** + +### isEnabled + +```ts +isEnabled: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:867](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L867) + +`true` if this observer is enabled, `false` otherwise. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isEnabled`](QueryObserverBaseResult.md#isenabled) + +*** + +### isError + +```ts +isError: true; +``` + +Defined in: [packages/query-core/src/types.ts:945](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L945) + +A derived boolean from the `status` variable, provided for convenience. +- `true` if the query attempt resulted in an error. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isError`](QueryObserverBaseResult.md#iserror) + +*** + +### isFetched + +```ts +isFetched: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:808](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L808) + +Will be `true` if the query has been fetched. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isFetched`](QueryObserverBaseResult.md#isfetched) + +*** + +### isFetchedAfterMount + +```ts +isFetchedAfterMount: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:813](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L813) + +Will be `true` if the query has been fetched after the component mounted. +- This property can be used to not show any previously cached data. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isFetchedAfterMount`](QueryObserverBaseResult.md#isfetchedaftermount) + +*** + +### isFetching + +```ts +isFetching: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:818](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L818) + +A derived boolean from the `fetchStatus` variable, provided for convenience. +- `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isFetching`](QueryObserverBaseResult.md#isfetching) + +*** + +### ~~isInitialLoading~~ + +```ts +isInitialLoading: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:836](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L836) + +#### Deprecated + +`isInitialLoading` is being deprecated in favor of `isLoading` +and will be removed in the next major version. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isInitialLoading`](QueryObserverBaseResult.md#isinitialloading) + +*** + +### isLoading + +```ts +isLoading: false; +``` + +Defined in: [packages/query-core/src/types.ts:947](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L947) + +Is `true` whenever the first fetch for a query is in-flight. +- Is the same as `isFetching && isPending`. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoading`](QueryObserverBaseResult.md#isloading) + +*** + +### isLoadingError + +```ts +isLoadingError: false; +``` + +Defined in: [packages/query-core/src/types.ts:948](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L948) + +Will be `true` if the query failed while fetching for the first time. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoadingError`](QueryObserverBaseResult.md#isloadingerror) + +*** + +### isPaused + +```ts +isPaused: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:841](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L841) + +A derived boolean from the `fetchStatus` variable, provided for convenience. +- The query wanted to fetch, but has been `paused`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPaused`](QueryObserverBaseResult.md#ispaused) + +*** + +### isPending + +```ts +isPending: false; +``` + +Defined in: [packages/query-core/src/types.ts:946](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L946) + +Will be `pending` if there's no cached data and no query attempt was finished yet. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPending`](QueryObserverBaseResult.md#ispending) + +*** + +### isPlaceholderData + +```ts +isPlaceholderData: false; +``` + +Defined in: [packages/query-core/src/types.ts:951](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L951) + +Will be `true` if the data shown is the placeholder data. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPlaceholderData`](QueryObserverBaseResult.md#isplaceholderdata) + +*** + +### isRefetchError + +```ts +isRefetchError: true; +``` + +Defined in: [packages/query-core/src/types.ts:949](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L949) + +Will be `true` if the query failed while refetching. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetchError`](QueryObserverBaseResult.md#isrefetcherror) + +*** + +### isRefetching + +```ts +isRefetching: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:854](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L854) + +Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. +- Is the same as `isFetching && !isPending`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetching`](QueryObserverBaseResult.md#isrefetching) + +*** + +### isStale + +```ts +isStale: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:858](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L858) + +Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isStale`](QueryObserverBaseResult.md#isstale) + +*** + +### isSuccess + +```ts +isSuccess: false; +``` + +Defined in: [packages/query-core/src/types.ts:950](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L950) + +A derived boolean from the `status` variable, provided for convenience. +- `true` if the query has received a response with no errors and is ready to display its data. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isSuccess`](QueryObserverBaseResult.md#issuccess) + +*** + +### refetch() + +```ts +refetch: (options?) => Promise>; +``` + +Defined in: [packages/query-core/src/types.ts:871](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L871) + +A function to manually refetch the query. + +#### Parameters + +##### options? + +[`RefetchOptions`](RefetchOptions.md) + +#### Returns + +`Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`refetch`](QueryObserverBaseResult.md#refetch) + +*** + +### status + +```ts +status: "error"; +``` + +Defined in: [packages/query-core/src/types.ts:952](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L952) + +The status of the query. +- Will be: + - `pending` if there's no cached data and no query attempt was finished yet. + - `error` if the query attempt resulted in an error. + - `success` if the query has received a response with no errors and is ready to display its data. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`status`](QueryObserverBaseResult.md#status) diff --git a/docs/framework/preact/reference/interfaces/QueryObserverSuccessResult.md b/docs/framework/preact/reference/interfaces/QueryObserverSuccessResult.md new file mode 100644 index 00000000000..3942655c627 --- /dev/null +++ b/docs/framework/preact/reference/interfaces/QueryObserverSuccessResult.md @@ -0,0 +1,452 @@ +--- +id: QueryObserverSuccessResult +title: QueryObserverSuccessResult +--- + +Defined in: [packages/query-core/src/types.ts:955](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L955) + +## Extends + +- [`QueryObserverBaseResult`](QueryObserverBaseResult.md)\<`TData`, `TError`\> + +## Type Parameters + +### TData + +`TData` = `unknown` + +### TError + +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) + +## Properties + +### data + +```ts +data: TData; +``` + +Defined in: [packages/query-core/src/types.ts:959](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L959) + +The last successfully resolved data for the query. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`data`](QueryObserverBaseResult.md#data) + +*** + +### dataUpdatedAt + +```ts +dataUpdatedAt: number; +``` + +Defined in: [packages/query-core/src/types.ts:775](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L775) + +The timestamp for when the query most recently returned the `status` as `"success"`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`dataUpdatedAt`](QueryObserverBaseResult.md#dataupdatedat) + +*** + +### error + +```ts +error: null; +``` + +Defined in: [packages/query-core/src/types.ts:960](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L960) + +The error object for the query, if an error was thrown. +- Defaults to `null`. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`error`](QueryObserverBaseResult.md#error) + +*** + +### errorUpdateCount + +```ts +errorUpdateCount: number; +``` + +Defined in: [packages/query-core/src/types.ts:799](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L799) + +The sum of all errors. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`errorUpdateCount`](QueryObserverBaseResult.md#errorupdatecount) + +*** + +### errorUpdatedAt + +```ts +errorUpdatedAt: number; +``` + +Defined in: [packages/query-core/src/types.ts:784](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L784) + +The timestamp for when the query most recently returned the `status` as `"error"`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`errorUpdatedAt`](QueryObserverBaseResult.md#errorupdatedat) + +*** + +### failureCount + +```ts +failureCount: number; +``` + +Defined in: [packages/query-core/src/types.ts:790](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L790) + +The failure count for the query. +- Incremented every time the query fails. +- Reset to `0` when the query succeeds. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`failureCount`](QueryObserverBaseResult.md#failurecount) + +*** + +### failureReason + +```ts +failureReason: TError | null; +``` + +Defined in: [packages/query-core/src/types.ts:795](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L795) + +The failure reason for the query retry. +- Reset to `null` when the query succeeds. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`failureReason`](QueryObserverBaseResult.md#failurereason) + +*** + +### fetchStatus + +```ts +fetchStatus: FetchStatus; +``` + +Defined in: [packages/query-core/src/types.ts:889](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L889) + +The fetch status of the query. +- `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. +- `paused`: The query wanted to fetch, but has been `paused`. +- `idle`: The query is not fetching. +- See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`fetchStatus`](QueryObserverBaseResult.md#fetchstatus) + +*** + +### isEnabled + +```ts +isEnabled: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:867](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L867) + +`true` if this observer is enabled, `false` otherwise. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isEnabled`](QueryObserverBaseResult.md#isenabled) + +*** + +### isError + +```ts +isError: false; +``` + +Defined in: [packages/query-core/src/types.ts:961](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L961) + +A derived boolean from the `status` variable, provided for convenience. +- `true` if the query attempt resulted in an error. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isError`](QueryObserverBaseResult.md#iserror) + +*** + +### isFetched + +```ts +isFetched: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:808](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L808) + +Will be `true` if the query has been fetched. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isFetched`](QueryObserverBaseResult.md#isfetched) + +*** + +### isFetchedAfterMount + +```ts +isFetchedAfterMount: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:813](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L813) + +Will be `true` if the query has been fetched after the component mounted. +- This property can be used to not show any previously cached data. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isFetchedAfterMount`](QueryObserverBaseResult.md#isfetchedaftermount) + +*** + +### isFetching + +```ts +isFetching: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:818](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L818) + +A derived boolean from the `fetchStatus` variable, provided for convenience. +- `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isFetching`](QueryObserverBaseResult.md#isfetching) + +*** + +### ~~isInitialLoading~~ + +```ts +isInitialLoading: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:836](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L836) + +#### Deprecated + +`isInitialLoading` is being deprecated in favor of `isLoading` +and will be removed in the next major version. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isInitialLoading`](QueryObserverBaseResult.md#isinitialloading) + +*** + +### isLoading + +```ts +isLoading: false; +``` + +Defined in: [packages/query-core/src/types.ts:963](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L963) + +Is `true` whenever the first fetch for a query is in-flight. +- Is the same as `isFetching && isPending`. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoading`](QueryObserverBaseResult.md#isloading) + +*** + +### isLoadingError + +```ts +isLoadingError: false; +``` + +Defined in: [packages/query-core/src/types.ts:964](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L964) + +Will be `true` if the query failed while fetching for the first time. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoadingError`](QueryObserverBaseResult.md#isloadingerror) + +*** + +### isPaused + +```ts +isPaused: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:841](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L841) + +A derived boolean from the `fetchStatus` variable, provided for convenience. +- The query wanted to fetch, but has been `paused`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPaused`](QueryObserverBaseResult.md#ispaused) + +*** + +### isPending + +```ts +isPending: false; +``` + +Defined in: [packages/query-core/src/types.ts:962](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L962) + +Will be `pending` if there's no cached data and no query attempt was finished yet. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPending`](QueryObserverBaseResult.md#ispending) + +*** + +### isPlaceholderData + +```ts +isPlaceholderData: false; +``` + +Defined in: [packages/query-core/src/types.ts:967](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L967) + +Will be `true` if the data shown is the placeholder data. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPlaceholderData`](QueryObserverBaseResult.md#isplaceholderdata) + +*** + +### isRefetchError + +```ts +isRefetchError: false; +``` + +Defined in: [packages/query-core/src/types.ts:965](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L965) + +Will be `true` if the query failed while refetching. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetchError`](QueryObserverBaseResult.md#isrefetcherror) + +*** + +### isRefetching + +```ts +isRefetching: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:854](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L854) + +Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. +- Is the same as `isFetching && !isPending`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetching`](QueryObserverBaseResult.md#isrefetching) + +*** + +### isStale + +```ts +isStale: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:858](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L858) + +Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isStale`](QueryObserverBaseResult.md#isstale) + +*** + +### isSuccess + +```ts +isSuccess: true; +``` + +Defined in: [packages/query-core/src/types.ts:966](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L966) + +A derived boolean from the `status` variable, provided for convenience. +- `true` if the query has received a response with no errors and is ready to display its data. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isSuccess`](QueryObserverBaseResult.md#issuccess) + +*** + +### refetch() + +```ts +refetch: (options?) => Promise>; +``` + +Defined in: [packages/query-core/src/types.ts:871](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L871) + +A function to manually refetch the query. + +#### Parameters + +##### options? + +[`RefetchOptions`](RefetchOptions.md) + +#### Returns + +`Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`refetch`](QueryObserverBaseResult.md#refetch) + +*** + +### status + +```ts +status: "success"; +``` + +Defined in: [packages/query-core/src/types.ts:968](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L968) + +The status of the query. +- Will be: + - `pending` if there's no cached data and no query attempt was finished yet. + - `error` if the query attempt resulted in an error. + - `success` if the query has received a response with no errors and is ready to display its data. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`status`](QueryObserverBaseResult.md#status) diff --git a/docs/framework/preact/reference/interfaces/QueryOptions.md b/docs/framework/preact/reference/interfaces/QueryOptions.md new file mode 100644 index 00000000000..7e059d3a1d6 --- /dev/null +++ b/docs/framework/preact/reference/interfaces/QueryOptions.md @@ -0,0 +1,247 @@ +--- +id: QueryOptions +title: QueryOptions +--- + +Defined in: [packages/query-core/src/types.ts:231](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L231) + +## Type Parameters + +### TQueryFnData + +`TQueryFnData` = `unknown` + +### TError + +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) + +### TData + +`TData` = `TQueryFnData` + +### TQueryKey + +`TQueryKey` *extends* [`QueryKey`](../type-aliases/QueryKey.md) = [`QueryKey`](../type-aliases/QueryKey.md) + +### TPageParam + +`TPageParam` = `never` + +## Properties + +### gcTime? + +```ts +optional gcTime: number; +``` + +Defined in: [packages/query-core/src/types.ts:277](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L277) + +The time in milliseconds that unused/inactive cache data remains in memory. +When a query's cache becomes unused or inactive, that cache data will be garbage collected after this duration. +When different garbage collection times are specified, the longest one will be used. +Setting it to `Infinity` will disable garbage collection. + +Defaults to `5 * 60 * 1000` (5 minutes), or `Infinity` during SSR. + +Note: the maximum allowed time is about 24 days, imposed by `setTimeout`'s 32-bit signed integer delay — see +`timeoutManager.setTimeoutProvider` for a workaround. + +*** + +### initialData? + +```ts +optional initialData: + | TData +| InitialDataFunction; +``` + +Defined in: [packages/query-core/src/types.ts:317](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L317) + +If set, this value will be used as the initial data for the query cache (as long as the query hasn't been +created or cached yet). +If set to a function, the function will be called **once** during the shared/root query initialization, and be +expected to synchronously return the initial data. +Initial data is considered stale by default unless a `staleTime` has been set. +`initialData` **is persisted** to the cache. + +*** + +### initialDataUpdatedAt? + +```ts +optional initialDataUpdatedAt: number | () => number | undefined; +``` + +Defined in: [packages/query-core/src/types.ts:321](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L321) + +If set, this value will be used as the time (in milliseconds) of when the `initialData` itself was last updated. + +*** + +### maxPages? + +```ts +optional maxPages: number; +``` + +Defined in: [packages/query-core/src/types.ts:345](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L345) + +Maximum number of pages to store in the data of an infinite query. + +*** + +### meta? + +```ts +optional meta: Record; +``` + +Defined in: [packages/query-core/src/types.ts:341](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L341) + +Additional payload to be stored on each query. +Use this property to pass information that can be used in other places. + +*** + +### networkMode? + +```ts +optional networkMode: NetworkMode; +``` + +Defined in: [packages/query-core/src/types.ts:265](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L265) + +Controls whether a query is allowed to run based on the current network connectivity. + +Defaults to `'online'`. + +#### See + +[Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. + +*** + +### persister? + +```ts +optional persister: QueryPersister, TPageParam>; +``` + +Defined in: [packages/query-core/src/types.ts:290](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L290) + +This option can be used to persist the result of a query to an external storage, bypassing the need to actually +call the `queryFn`. Useful for persisting a query's data across e.g. server/client boundaries. + +*** + +### queryFn? + +```ts +optional queryFn: + | QueryFunction + | typeof skipToken; +``` + +Defined in: [packages/query-core/src/types.ts:285](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L285) + +The function that the query will use to request data. +Required, unless a default query function has been set via `queryClient.setQueryDefaults` or +`queryClient.setDefaultOptions`. +Receives a [QueryFunctionContext](../type-aliases/QueryFunctionContext.md). +Must return a promise that will either resolve data or throw an error. The data cannot be `undefined`. + +*** + +### queryHash? + +```ts +optional queryHash: string; +``` + +Defined in: [packages/query-core/src/types.ts:295](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L295) + +The hashed form of `queryKey`, computed with `queryKeyHashFn` (or the default hashing function otherwise). Used +as the actual cache key internally. + +*** + +### queryKey? + +```ts +optional queryKey: TQueryKey; +``` + +Defined in: [packages/query-core/src/types.ts:304](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L304) + +The query key to use for this query. + +The query key will be hashed into a stable hash. See [Query Keys](https://tanstack.com/query/latest/docs/framework/react/guides/query-keys) +for more information. + +The query will automatically update when this key changes (as long as `enabled` is not set to `false`). + +*** + +### queryKeyHashFn? + +```ts +optional queryKeyHashFn: QueryKeyHashFunction; +``` + +Defined in: [packages/query-core/src/types.ts:308](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L308) + +If specified, this function is used to hash the `queryKey` to a string. + +*** + +### retry? + +```ts +optional retry: RetryValue; +``` + +Defined in: [packages/query-core/src/types.ts:246](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L246) + +If `false`, failed queries will not retry by default. +If `true`, failed queries will retry infinitely. +If set to an integer number, e.g. 3, failed queries will retry until the failed query count meets that number. +If set to a function `(failureCount, error) => boolean` failed queries will retry until the function returns false. + +Defaults to `3` on the client and `0` on the server. + +*** + +### retryDelay? + +```ts +optional retryDelay: RetryDelayValue; +``` + +Defined in: [packages/query-core/src/types.ts:258](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L258) + +This function receives a `retryAttempt` integer and the actual Error and returns the delay to apply before the +next attempt in milliseconds. + +A function like `attempt => Math.min(attempt > 1 ? 2 ** attempt * 1000 : 1000, 30 * 1000)` applies exponential +backoff. + +A function like `attempt => attempt * 1000` applies linear backoff. + +Defaults to a function that applies exponential backoff, capped at 30 seconds. + +*** + +### structuralSharing? + +```ts +optional structuralSharing: boolean | (oldData, newData) => unknown; +``` + +Defined in: [packages/query-core/src/types.ts:330](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L330) + +Set this to `false` to disable structural sharing between query results. +Set this to a function which accepts the old and new data and returns resolved data of the same type to implement custom structural sharing logic. + +Defaults to `true`. diff --git a/docs/framework/preact/reference/interfaces/QueryState.md b/docs/framework/preact/reference/interfaces/QueryState.md new file mode 100644 index 00000000000..7dce476d743 --- /dev/null +++ b/docs/framework/preact/reference/interfaces/QueryState.md @@ -0,0 +1,175 @@ +--- +id: QueryState +title: QueryState +--- + +Defined in: [packages/query-core/src/query.ts:52](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L52) + +The raw state stored on a `Query` instance. This is the underlying state +that observer results (e.g. `QueryObserverResult`) are derived from. + +## Type Parameters + +### TData + +`TData` = `unknown` + +### TError + +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) + +## Properties + +### data + +```ts +data: TData | undefined; +``` + +Defined in: [packages/query-core/src/query.ts:56](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L56) + +The last successfully resolved data for the query. + +*** + +### dataUpdateCount + +```ts +dataUpdateCount: number; +``` + +Defined in: [packages/query-core/src/query.ts:60](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L60) + +The number of times the query has successfully resolved. + +*** + +### dataUpdatedAt + +```ts +dataUpdatedAt: number; +``` + +Defined in: [packages/query-core/src/query.ts:64](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L64) + +The timestamp for when the query most recently returned the `status` as `"success"`. + +*** + +### error + +```ts +error: TError | null; +``` + +Defined in: [packages/query-core/src/query.ts:69](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L69) + +The error object for the query, if the last attempt resulted in an error. +- Defaults to `null`. + +*** + +### errorUpdateCount + +```ts +errorUpdateCount: number; +``` + +Defined in: [packages/query-core/src/query.ts:73](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L73) + +The sum of all errors, incremented every time the query resolves with an error. + +*** + +### errorUpdatedAt + +```ts +errorUpdatedAt: number; +``` + +Defined in: [packages/query-core/src/query.ts:77](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L77) + +The timestamp for when the query most recently returned the `status` as `"error"`. + +*** + +### fetchFailureCount + +```ts +fetchFailureCount: number; +``` + +Defined in: [packages/query-core/src/query.ts:83](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L83) + +The failure count for the current fetch. +- Incremented every time the fetch fails. +- Reset to `0` when the fetch succeeds. + +*** + +### fetchFailureReason + +```ts +fetchFailureReason: TError | null; +``` + +Defined in: [packages/query-core/src/query.ts:88](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L88) + +The reason the current fetch failed, as reported by the retryer. +- Reset to `null` when the fetch succeeds. + +*** + +### fetchMeta + +```ts +fetchMeta: FetchMeta | null; +``` + +Defined in: [packages/query-core/src/query.ts:93](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L93) + +Metadata passed to the currently in-flight (or most recent) fetch, e.g. the +`fetchMore` direction for infinite queries. + +*** + +### fetchStatus + +```ts +fetchStatus: FetchStatus; +``` + +Defined in: [packages/query-core/src/query.ts:112](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L112) + +The fetch status of the query. +- `fetching`: the `queryFn` is currently executing. +- `paused`: a fetch wanted to run but has been paused (see network mode). +- `idle`: the query is not fetching. + +*** + +### isInvalidated + +```ts +isInvalidated: boolean; +``` + +Defined in: [packages/query-core/src/query.ts:98](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L98) + +Whether the query has been marked as invalidated via `invalidate()`. +- Reset to `false` whenever the query resolves successfully. + +*** + +### status + +```ts +status: QueryStatus; +``` + +Defined in: [packages/query-core/src/query.ts:105](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L105) + +The status of the query. +- `pending` if there's no cached data and no attempt was finished yet. +- `error` if the last attempt resulted in an error. +- `success` if the query has data. diff --git a/docs/framework/preact/reference/interfaces/RefetchOptions.md b/docs/framework/preact/reference/interfaces/RefetchOptions.md new file mode 100644 index 00000000000..cfcc0498799 --- /dev/null +++ b/docs/framework/preact/reference/interfaces/RefetchOptions.md @@ -0,0 +1,50 @@ +--- +id: RefetchOptions +title: RefetchOptions +--- + +Defined in: [packages/query-core/src/types.ts:704](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L704) + +## Extends + +- [`ResultOptions`](ResultOptions.md) + +## Extended by + +- [`InvalidateOptions`](InvalidateOptions.md) +- [`ResetOptions`](ResetOptions.md) + +## Properties + +### cancelRefetch? + +```ts +optional cancelRefetch: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:712](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L712) + +If set to `true`, a currently running request will be cancelled before a new request is made + +If set to `false`, no refetch will be made if there is already a request running. + +Defaults to `true`. + +*** + +### throwOnError? + +```ts +optional throwOnError: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:701](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L701) + +If set to `true`, the method throws if any of the underlying query refetch tasks fail. + +Defaults to `false`, in which case failed refetches are swallowed and not surfaced to the +caller. + +#### Inherited from + +[`ResultOptions`](ResultOptions.md).[`throwOnError`](ResultOptions.md#throwonerror) diff --git a/docs/framework/preact/reference/interfaces/RefetchQueryFilters.md b/docs/framework/preact/reference/interfaces/RefetchQueryFilters.md new file mode 100644 index 00000000000..c45dfa953f1 --- /dev/null +++ b/docs/framework/preact/reference/interfaces/RefetchQueryFilters.md @@ -0,0 +1,127 @@ +--- +id: RefetchQueryFilters +title: RefetchQueryFilters +--- + +Defined in: [packages/query-core/src/types.ts:730](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L730) + +Filters used to select queries, for example in `queryClient.getQueriesData` or `queryClient.invalidateQueries`. +All provided filters must match; filters that are left unspecified are ignored. + +## Extends + +- [`QueryFilters`](QueryFilters.md)\<`TQueryKey`\> + +## Type Parameters + +### TQueryKey + +`TQueryKey` *extends* [`QueryKey`](../type-aliases/QueryKey.md) = [`QueryKey`](../type-aliases/QueryKey.md) + +## Properties + +### exact? + +```ts +optional exact: boolean; +``` + +Defined in: [packages/query-core/src/utils.ts:41](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L41) + +Match query key exactly + +#### Inherited from + +[`QueryFilters`](QueryFilters.md).[`exact`](QueryFilters.md#exact) + +*** + +### fetchStatus? + +```ts +optional fetchStatus: FetchStatus; +``` + +Defined in: [packages/query-core/src/utils.ts:57](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L57) + +Include queries matching their fetchStatus + +#### Inherited from + +[`QueryFilters`](QueryFilters.md).[`fetchStatus`](QueryFilters.md#fetchstatus) + +*** + +### predicate()? + +```ts +optional predicate: (query) => boolean; +``` + +Defined in: [packages/query-core/src/utils.ts:45](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L45) + +Include queries matching this predicate function + +#### Parameters + +##### query + +[`Query`](../classes/Query.md) + +#### Returns + +`boolean` + +#### Inherited from + +[`QueryFilters`](QueryFilters.md).[`predicate`](QueryFilters.md#predicate) + +*** + +### queryKey? + +```ts +optional queryKey: TQueryKey | TuplePrefixes; +``` + +Defined in: [packages/query-core/src/utils.ts:49](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L49) + +Include queries matching this query key + +#### Inherited from + +[`QueryFilters`](QueryFilters.md).[`queryKey`](QueryFilters.md#querykey) + +*** + +### stale? + +```ts +optional stale: boolean; +``` + +Defined in: [packages/query-core/src/utils.ts:53](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L53) + +Include or exclude stale queries + +#### Inherited from + +[`QueryFilters`](QueryFilters.md).[`stale`](QueryFilters.md#stale) + +*** + +### type? + +```ts +optional type: QueryTypeFilter; +``` + +Defined in: [packages/query-core/src/utils.ts:37](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L37) + +Filter to active queries, inactive queries or all queries + +Defaults to `'all'`. + +#### Inherited from + +[`QueryFilters`](QueryFilters.md).[`type`](QueryFilters.md#type) diff --git a/docs/framework/preact/reference/interfaces/Register.md b/docs/framework/preact/reference/interfaces/Register.md new file mode 100644 index 00000000000..4f442442b48 --- /dev/null +++ b/docs/framework/preact/reference/interfaces/Register.md @@ -0,0 +1,6 @@ +--- +id: Register +title: Register +--- + +Defined in: [packages/query-core/src/types.ts:37](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L37) diff --git a/docs/framework/preact/reference/interfaces/ResetOptions.md b/docs/framework/preact/reference/interfaces/ResetOptions.md new file mode 100644 index 00000000000..9f12324ba27 --- /dev/null +++ b/docs/framework/preact/reference/interfaces/ResetOptions.md @@ -0,0 +1,49 @@ +--- +id: ResetOptions +title: ResetOptions +--- + +Defined in: [packages/query-core/src/types.ts:735](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L735) + +## Extends + +- [`RefetchOptions`](RefetchOptions.md) + +## Properties + +### cancelRefetch? + +```ts +optional cancelRefetch: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:712](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L712) + +If set to `true`, a currently running request will be cancelled before a new request is made + +If set to `false`, no refetch will be made if there is already a request running. + +Defaults to `true`. + +#### Inherited from + +[`RefetchOptions`](RefetchOptions.md).[`cancelRefetch`](RefetchOptions.md#cancelrefetch) + +*** + +### throwOnError? + +```ts +optional throwOnError: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:701](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L701) + +If set to `true`, the method throws if any of the underlying query refetch tasks fail. + +Defaults to `false`, in which case failed refetches are swallowed and not surfaced to the +caller. + +#### Inherited from + +[`RefetchOptions`](RefetchOptions.md).[`throwOnError`](RefetchOptions.md#throwonerror) diff --git a/docs/framework/preact/reference/interfaces/ResultOptions.md b/docs/framework/preact/reference/interfaces/ResultOptions.md new file mode 100644 index 00000000000..42917f20bf0 --- /dev/null +++ b/docs/framework/preact/reference/interfaces/ResultOptions.md @@ -0,0 +1,27 @@ +--- +id: ResultOptions +title: ResultOptions +--- + +Defined in: [packages/query-core/src/types.ts:694](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L694) + +## Extended by + +- [`RefetchOptions`](RefetchOptions.md) +- [`FetchNextPageOptions`](FetchNextPageOptions.md) +- [`FetchPreviousPageOptions`](FetchPreviousPageOptions.md) + +## Properties + +### throwOnError? + +```ts +optional throwOnError: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:701](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L701) + +If set to `true`, the method throws if any of the underlying query refetch tasks fail. + +Defaults to `false`, in which case failed refetches are swallowed and not surfaced to the +caller. diff --git a/docs/framework/preact/reference/interfaces/SetDataOptions.md b/docs/framework/preact/reference/interfaces/SetDataOptions.md new file mode 100644 index 00000000000..bb668fbf162 --- /dev/null +++ b/docs/framework/preact/reference/interfaces/SetDataOptions.md @@ -0,0 +1,16 @@ +--- +id: SetDataOptions +title: SetDataOptions +--- + +Defined in: [packages/query-core/src/types.ts:1526](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1526) + +## Properties + +### updatedAt? + +```ts +optional updatedAt: number; +``` + +Defined in: [packages/query-core/src/types.ts:1527](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1527) diff --git a/docs/framework/preact/reference/interfaces/TimeoutManager.md b/docs/framework/preact/reference/interfaces/TimeoutManager.md new file mode 100644 index 00000000000..95ff07b2ccc --- /dev/null +++ b/docs/framework/preact/reference/interfaces/TimeoutManager.md @@ -0,0 +1,246 @@ +--- +id: TimeoutManager +title: TimeoutManager +--- + +Defined in: [packages/query-core/src/timeoutManager.ts:70](https://github.com/TanStack/query/blob/main/packages/query-core/src/timeoutManager.ts#L70) + +Allows customization of how timeouts are created. + +@tanstack/query-core makes liberal use of timeouts to implement `staleTime` +and `gcTime`. The default TimeoutManager provider uses the platform's global +`setTimeout` implementation, which is known to have scalability issues with +thousands of timeouts on the event loop. + +If you hit this limitation, consider providing a custom TimeoutProvider that +coalesces timeouts. + +## Implements + +- `Omit`\<[`TimeoutProvider`](../type-aliases/TimeoutProvider.md), `"name"`\> + +## Methods + +### clearInterval() + +```ts +clearInterval(intervalId): void; +``` + +Defined in: [packages/query-core/src/timeoutManager.ts:224](https://github.com/TanStack/query/blob/main/packages/query-core/src/timeoutManager.ts#L224) + +`clearInterval` can be used to cancel an interval, like the global +`clearInterval` function. It should be called with an interval ID +returned by `setInterval`. + +#### Parameters + +##### intervalId + +[`ManagedTimerId`](../type-aliases/ManagedTimerId.md) | `undefined` + +#### Returns + +`void` + +#### Example + +```ts +import { timeoutManager } from '@tanstack/query-core' + +const intervalId = timeoutManager.setInterval( + () => console.log('ran at:', new Date()), + 1000, +) + +timeoutManager.clearInterval(intervalId) +``` + +#### Implementation of + +[`TimeoutProvider`](../type-aliases/TimeoutProvider.md).[`clearInterval`](../type-aliases/TimeoutProvider.md#clearinterval) + +*** + +### clearTimeout() + +```ts +clearTimeout(timeoutId): void; +``` + +Defined in: [packages/query-core/src/timeoutManager.ts:179](https://github.com/TanStack/query/blob/main/packages/query-core/src/timeoutManager.ts#L179) + +`clearTimeout` cancels a timeout callback scheduled with `setTimeout`, +like the global `clearTimeout` function. It should be called with a +timer ID returned by `setTimeout`. + +#### Parameters + +##### timeoutId + +[`ManagedTimerId`](../type-aliases/ManagedTimerId.md) | `undefined` + +#### Returns + +`void` + +#### Example + +```ts +import { timeoutManager } from '@tanstack/query-core' + +const timeoutId = timeoutManager.setTimeout( + () => console.log('ran at:', new Date()), + 1000, +) + +timeoutManager.clearTimeout(timeoutId) +``` + +#### Implementation of + +[`TimeoutProvider`](../type-aliases/TimeoutProvider.md).[`clearTimeout`](../type-aliases/TimeoutProvider.md#cleartimeout) + +*** + +### setInterval() + +```ts +setInterval(callback, delay): ManagedTimerId; +``` + +Defined in: [packages/query-core/src/timeoutManager.ts:200](https://github.com/TanStack/query/blob/main/packages/query-core/src/timeoutManager.ts#L200) + +`setInterval` schedules a callback to be called approximately every +`delay` milliseconds, like the global `setInterval` function. + +Like `setTimeout`, it returns a timer ID, which may be a number or an +object that can be coerced to a number via `Symbol.toPrimitive`. + +#### Parameters + +##### callback + +[`TimeoutCallback`](../type-aliases/TimeoutCallback.md) + +##### delay + +`number` + +#### Returns + +[`ManagedTimerId`](../type-aliases/ManagedTimerId.md) + +#### Example + +```ts +import { timeoutManager } from '@tanstack/query-core' + +const intervalId = timeoutManager.setInterval( + () => console.log('ran at:', new Date()), + 1000, +) +``` + +#### Implementation of + +[`TimeoutProvider`](../type-aliases/TimeoutProvider.md).[`setInterval`](../type-aliases/TimeoutProvider.md#setinterval) + +*** + +### setTimeout() + +```ts +setTimeout(callback, delay): ManagedTimerId; +``` + +Defined in: [packages/query-core/src/timeoutManager.ts:155](https://github.com/TanStack/query/blob/main/packages/query-core/src/timeoutManager.ts#L155) + +`setTimeout` schedules a callback to run after approximately `delay` +milliseconds, like the global `setTimeout` function. The callback can be +canceled with `clearTimeout`. + +It returns a timer ID, which may be a number or an object that can be +coerced to a number via `Symbol.toPrimitive`. + +#### Parameters + +##### callback + +[`TimeoutCallback`](../type-aliases/TimeoutCallback.md) + +##### delay + +`number` + +#### Returns + +[`ManagedTimerId`](../type-aliases/ManagedTimerId.md) + +#### Example + +```ts +import { timeoutManager } from '@tanstack/query-core' + +const timeoutId = timeoutManager.setTimeout( + () => console.log('ran at:', new Date()), + 1000, +) + +const timeoutIdNumber: number = Number(timeoutId) +``` + +#### Implementation of + +[`TimeoutProvider`](../type-aliases/TimeoutProvider.md).[`setTimeout`](../type-aliases/TimeoutProvider.md#settimeout) + +*** + +### setTimeoutProvider() + +```ts +setTimeoutProvider(provider): void; +``` + +Defined in: [packages/query-core/src/timeoutManager.ts:106](https://github.com/TanStack/query/blob/main/packages/query-core/src/timeoutManager.ts#L106) + +`setTimeoutProvider` can be used to set a custom implementation of the +`setTimeout`, `clearTimeout`, `setInterval`, `clearInterval` functions, +called a `TimeoutProvider`. + +This may be useful if you notice event loop performance issues with +thousands of queries. A custom TimeoutProvider could also support timer +delays longer than the global `setTimeout` maximum delay value of about +24 days. + +It is important to call `setTimeoutProvider` before creating a +QueryClient or queries, so that the same provider is used consistently +for all timers in the application, since different TimeoutProviders +cannot cancel each others' timers. + +#### Type Parameters + +##### TTimerId + +`TTimerId` *extends* [`ManagedTimerId`](../type-aliases/ManagedTimerId.md) + +#### Parameters + +##### provider + +[`TimeoutProvider`](../type-aliases/TimeoutProvider.md)\<`TTimerId`\> + +#### Returns + +`void` + +#### Example + +```ts +import { timeoutManager, QueryClient } from '@tanstack/query-core' +import { CustomTimeoutProvider } from './CustomTimeoutProvider' + +timeoutManager.setTimeoutProvider(new CustomTimeoutProvider()) + +export const queryClient = new QueryClient() +``` diff --git a/docs/framework/preact/reference/interfaces/UseBaseQueryOptions.md b/docs/framework/preact/reference/interfaces/UseBaseQueryOptions.md index 537e461bbef..693641d559f 100644 --- a/docs/framework/preact/reference/interfaces/UseBaseQueryOptions.md +++ b/docs/framework/preact/reference/interfaces/UseBaseQueryOptions.md @@ -3,14 +3,14 @@ id: UseBaseQueryOptions title: UseBaseQueryOptions --- -Defined in: [preact-query/src/types.ts:46](https://github.com/TanStack/query/blob/main/packages/preact-query/src/types.ts#L46) +Defined in: [packages/preact-query/src/types.ts:46](https://github.com/TanStack/query/blob/main/packages/preact-query/src/types.ts#L46) -The options shared by `useQuery` and `useSuspenseQuery`. Extends QueryObserverOptions from +The options shared by `useQuery` and `useSuspenseQuery`. Extends [QueryObserverOptions](QueryObserverOptions.md) from `@tanstack/query-core` with the `preact-query`-specific `subscribed` option. ## Extends -- `QueryObserverOptions`\<`TQueryFnData`, `TError`, `TData`, `TQueryData`, `TQueryKey`\> +- [`QueryObserverOptions`](QueryObserverOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryData`, `TQueryKey`\> ## Type Parameters @@ -22,7 +22,7 @@ The type your `queryFn` resolves to. ### TError -`TError` = `DefaultError` +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) The type of errors your `queryFn` may throw. @@ -42,19 +42,567 @@ The type of the data actually held in the query cache — the input to `select` ### TQueryKey -`TQueryKey` *extends* `QueryKey` = `QueryKey` +`TQueryKey` *extends* [`QueryKey`](../type-aliases/QueryKey.md) = [`QueryKey`](../type-aliases/QueryKey.md) The type of your `queryKey`. ## Properties +### enabled? + +```ts +optional enabled: QueryBooleanOption; +``` + +Defined in: [packages/query-core/src/types.ts:398](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L398) + +Set this to `false` or a function that returns `false` to disable automatic refetching when the query mounts or changes query keys. +To refetch the query, use the `refetch` method returned from the `useQuery` instance. +Accepts a boolean or function that returns a boolean. + +Defaults to `true`. + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`enabled`](QueryObserverOptions.md#enabled) + +*** + +### gcTime? + +```ts +optional gcTime: number; +``` + +Defined in: [packages/query-core/src/types.ts:277](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L277) + +The time in milliseconds that unused/inactive cache data remains in memory. +When a query's cache becomes unused or inactive, that cache data will be garbage collected after this duration. +When different garbage collection times are specified, the longest one will be used. +Setting it to `Infinity` will disable garbage collection. + +Defaults to `5 * 60 * 1000` (5 minutes), or `Infinity` during SSR. + +Note: the maximum allowed time is about 24 days, imposed by `setTimeout`'s 32-bit signed integer delay — see +`timeoutManager.setTimeoutProvider` for a workaround. + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`gcTime`](QueryObserverOptions.md#gctime) + +*** + +### initialData? + +```ts +optional initialData: + | TQueryData +| InitialDataFunction; +``` + +Defined in: [packages/query-core/src/types.ts:317](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L317) + +If set, this value will be used as the initial data for the query cache (as long as the query hasn't been +created or cached yet). +If set to a function, the function will be called **once** during the shared/root query initialization, and be +expected to synchronously return the initial data. +Initial data is considered stale by default unless a `staleTime` has been set. +`initialData` **is persisted** to the cache. + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`initialData`](QueryObserverOptions.md#initialdata) + +*** + +### initialDataUpdatedAt? + +```ts +optional initialDataUpdatedAt: number | () => number | undefined; +``` + +Defined in: [packages/query-core/src/types.ts:321](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L321) + +If set, this value will be used as the time (in milliseconds) of when the `initialData` itself was last updated. + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`initialDataUpdatedAt`](QueryObserverOptions.md#initialdataupdatedat) + +*** + +### maxPages? + +```ts +optional maxPages: number; +``` + +Defined in: [packages/query-core/src/types.ts:345](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L345) + +Maximum number of pages to store in the data of an infinite query. + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`maxPages`](QueryObserverOptions.md#maxpages) + +*** + +### meta? + +```ts +optional meta: Record; +``` + +Defined in: [packages/query-core/src/types.ts:341](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L341) + +Additional payload to be stored on each query. +Use this property to pass information that can be used in other places. + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`meta`](QueryObserverOptions.md#meta) + +*** + +### networkMode? + +```ts +optional networkMode: NetworkMode; +``` + +Defined in: [packages/query-core/src/types.ts:265](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L265) + +Controls whether a query is allowed to run based on the current network connectivity. + +Defaults to `'online'`. + +#### See + +[Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`networkMode`](QueryObserverOptions.md#networkmode) + +*** + +### notifyOnChangeProps? + +```ts +optional notifyOnChangeProps: NotifyOnChangeProps; +``` + +Defined in: [packages/query-core/src/types.ts:484](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L484) + +If set, the component will only re-render if any of the listed properties change. +When set to `['data', 'error']`, the component will only re-render when the `data` or `error` properties change. +When set to `'all'`, the component will re-render whenever a query is updated. +When set to a function, the function will be executed to compute the list of properties. + +Defaults to `undefined`, in which case property access is tracked automatically, and the +component only re-renders when one of the tracked properties changes. + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`notifyOnChangeProps`](QueryObserverOptions.md#notifyonchangeprops) + +*** + +### persister()? + +```ts +optional persister: (queryFn, context, query) => TQueryFnData | Promise; +``` + +Defined in: [packages/query-core/src/types.ts:290](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L290) + +This option can be used to persist the result of a query to an external storage, bypassing the need to actually +call the `queryFn`. Useful for persisting a query's data across e.g. server/client boundaries. + +#### Parameters + +##### queryFn + +[`QueryFunction`](../type-aliases/QueryFunction.md)\<`TQueryFnData`, `NoInfer`\<`TQueryKey`\>, `never`\> + +##### context + +###### client + +[`QueryClient`](../classes/QueryClient.md) + +###### direction? + +`unknown` + +**Deprecated** + +if you want access to the direction, you can add it to the pageParam + +###### meta + +`Record`\<`string`, `unknown`\> \| `undefined` + +###### pageParam? + +`unknown` + +###### queryKey + +`NoInfer`\<`TQueryKey`\> + +###### signal + +`AbortSignal` + +##### query + +[`Query`](../classes/Query.md) + +#### Returns + +`TQueryFnData` \| `Promise`\<`TQueryFnData`\> + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`persister`](QueryObserverOptions.md#persister) + +*** + +### placeholderData? + +```ts +optional placeholderData: + | NonFunctionGuard +| PlaceholderDataFunction, TError, NonFunctionGuard, TQueryKey>; +``` + +Defined in: [packages/query-core/src/types.ts:511](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L511) + +If set, this value will be used as the placeholder data for this particular query observer while the query is still in the `loading` data and no initialData has been provided. + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`placeholderData`](QueryObserverOptions.md#placeholderdata) + +*** + +### queryFn? + +```ts +optional queryFn: + | typeof skipToken +| QueryFunction; +``` + +Defined in: [packages/query-core/src/types.ts:285](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L285) + +The function that the query will use to request data. +Required, unless a default query function has been set via `queryClient.setQueryDefaults` or +`queryClient.setDefaultOptions`. +Receives a [QueryFunctionContext](../type-aliases/QueryFunctionContext.md). +Must return a promise that will either resolve data or throw an error. The data cannot be `undefined`. + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`queryFn`](QueryObserverOptions.md#queryfn) + +*** + +### queryHash? + +```ts +optional queryHash: string; +``` + +Defined in: [packages/query-core/src/types.ts:295](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L295) + +The hashed form of `queryKey`, computed with `queryKeyHashFn` (or the default hashing function otherwise). Used +as the actual cache key internally. + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`queryHash`](QueryObserverOptions.md#queryhash) + +*** + +### queryKey + +```ts +queryKey: TQueryKey & object; +``` + +Defined in: [packages/query-core/src/types.ts:304](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L304) + +The query key to use for this query. + +The query key will be hashed into a stable hash. See [Query Keys](https://tanstack.com/query/latest/docs/framework/react/guides/query-keys) +for more information. + +The query will automatically update when this key changes (as long as `enabled` is not set to `false`). + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`queryKey`](QueryObserverOptions.md#querykey) + +*** + +### queryKeyHashFn? + +```ts +optional queryKeyHashFn: QueryKeyHashFunction; +``` + +Defined in: [packages/query-core/src/types.ts:308](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L308) + +If specified, this function is used to hash the `queryKey` to a string. + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`queryKeyHashFn`](QueryObserverOptions.md#querykeyhashfn) + +*** + +### refetchInterval? + +```ts +optional refetchInterval: number | false | (query) => number | false | undefined; +``` + +Defined in: [packages/query-core/src/types.ts:414](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L414) + +If set to a number, the query will continuously refetch at this frequency in milliseconds. +If set to a function, the function will be executed with the latest data and query to compute a frequency + +Defaults to `false`. + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`refetchInterval`](QueryObserverOptions.md#refetchinterval) + +*** + +### refetchIntervalInBackground? + +```ts +optional refetchIntervalInBackground: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:425](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L425) + +If set to `true`, the query will continue to refetch while their tab/window is in the background. + +Defaults to `false`. + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`refetchIntervalInBackground`](QueryObserverOptions.md#refetchintervalinbackground) + +*** + +### refetchOnMount? + +```ts +optional refetchOnMount: boolean | "always" | (query) => boolean | "always"; +``` + +Defined in: [packages/query-core/src/types.ts:462](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L462) + +If set to `true`, the query will refetch on mount if the data is stale. +If set to `false`, will disable additional instances of a query to trigger background refetch. +If set to `'always'`, the query will always refetch on mount (except when `staleTime: 'static'` is used). +If set to a function, the function will be executed with the latest data and query to compute the value + +Defaults to `true`. + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`refetchOnMount`](QueryObserverOptions.md#refetchonmount) + +*** + +### refetchOnReconnect? + +```ts +optional refetchOnReconnect: boolean | "always" | (query) => boolean | "always"; +``` + +Defined in: [packages/query-core/src/types.ts:448](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L448) + +If set to `true`, the query will refetch on reconnect if the data is stale. +If set to `false`, the query will not refetch on reconnect. +If set to `'always'`, the query will always refetch on reconnect (except when `staleTime: 'static'` is used). +If set to a function, the function will be executed with the latest data and query to compute the value. + +Defaults to `true` unless `networkMode` is `'always'`. + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`refetchOnReconnect`](QueryObserverOptions.md#refetchonreconnect) + +*** + +### refetchOnWindowFocus? + +```ts +optional refetchOnWindowFocus: boolean | "always" | (query) => boolean | "always"; +``` + +Defined in: [packages/query-core/src/types.ts:434](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L434) + +If set to `true`, the query will refetch on window focus if the data is stale. +If set to `false`, the query will not refetch on window focus. +If set to `'always'`, the query will always refetch on window focus (except when `staleTime: 'static'` is used). +If set to a function, the function will be executed with the latest data and query to compute the value. + +Defaults to `true`. + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`refetchOnWindowFocus`](QueryObserverOptions.md#refetchonwindowfocus) + +*** + +### retry? + +```ts +optional retry: RetryValue; +``` + +Defined in: [packages/query-core/src/types.ts:246](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L246) + +If `false`, failed queries will not retry by default. +If `true`, failed queries will retry infinitely. +If set to an integer number, e.g. 3, failed queries will retry until the failed query count meets that number. +If set to a function `(failureCount, error) => boolean` failed queries will retry until the function returns false. + +Defaults to `3` on the client and `0` on the server. + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`retry`](QueryObserverOptions.md#retry) + +*** + +### retryDelay? + +```ts +optional retryDelay: RetryDelayValue; +``` + +Defined in: [packages/query-core/src/types.ts:258](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L258) + +This function receives a `retryAttempt` integer and the actual Error and returns the delay to apply before the +next attempt in milliseconds. + +A function like `attempt => Math.min(attempt > 1 ? 2 ** attempt * 1000 : 1000, 30 * 1000)` applies exponential +backoff. + +A function like `attempt => attempt * 1000` applies linear backoff. + +Defaults to a function that applies exponential backoff, capped at 30 seconds. + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`retryDelay`](QueryObserverOptions.md#retrydelay) + +*** + +### retryOnMount? + +```ts +optional retryOnMount: QueryBooleanOption; +``` + +Defined in: [packages/query-core/src/types.ts:474](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L474) + +If set to `false`, the query will not be retried on mount if it contains an error. +If set to a function, the function will be executed with the query to compute the value. + +Defaults to `true`. + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`retryOnMount`](QueryObserverOptions.md#retryonmount) + +*** + +### select()? + +```ts +optional select: (data) => TData; +``` + +Defined in: [packages/query-core/src/types.ts:500](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L500) + +This option can be used to transform or select a part of the data returned by the query function. It affects +the returned `data` value, but does not affect what gets stored in the query cache. +The `select` function will only run if `data` changed, or if the reference to the `select` function itself +changes. To optimize, memoize the function so its reference stays stable across calls. + +#### Parameters + +##### data + +`TQueryData` + +#### Returns + +`TData` + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`select`](QueryObserverOptions.md#select) + +*** + +### staleTime? + +```ts +optional staleTime: StaleTimeFunction; +``` + +Defined in: [packages/query-core/src/types.ts:407](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L407) + +The time in milliseconds after data is considered stale. +If set to `Infinity`, the data will never be considered stale. +If set to `'static'`, the data will never be considered stale. +If set to a function, the function will be executed with the query to compute a `staleTime`. + +Defaults to `0`. + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`staleTime`](QueryObserverOptions.md#staletime) + +*** + +### structuralSharing? + +```ts +optional structuralSharing: boolean | (oldData, newData) => unknown; +``` + +Defined in: [packages/query-core/src/types.ts:330](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L330) + +Set this to `false` to disable structural sharing between query results. +Set this to a function which accepts the old and new data and returns resolved data of the same type to implement custom structural sharing logic. + +Defaults to `true`. + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`structuralSharing`](QueryObserverOptions.md#structuralsharing) + +*** + ### subscribed? ```ts optional subscribed: boolean; ``` -Defined in: [preact-query/src/types.ts:64](https://github.com/TanStack/query/blob/main/packages/preact-query/src/types.ts#L64) +Defined in: [packages/preact-query/src/types.ts:64](https://github.com/TanStack/query/blob/main/packages/preact-query/src/types.ts#L64) Set this to `false` to unsubscribe this observer from updates to the query cache. @@ -63,3 +611,43 @@ Set this to `false` to unsubscribe this observer from updates to the query cache ```ts true ``` + +*** + +### suspense? + +```ts +optional suspense: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:507](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L507) + +If set to `true`, the query will suspend when `status === 'pending'` +and throw errors when `status === 'error'`. + +Defaults to `false`. + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`suspense`](QueryObserverOptions.md#suspense) + +*** + +### throwOnError? + +```ts +optional throwOnError: ThrowOnError; +``` + +Defined in: [packages/query-core/src/types.ts:493](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L493) + +Whether errors should be thrown instead of setting the `error` property. +If set to `true` or `suspense` is `true`, all errors will be thrown to the error boundary. +If set to `false` and `suspense` is `false`, errors are returned as state. +If set to a function, it will be passed the error and the query, and it should return a boolean indicating whether to show the error in an error boundary (`true`) or return the error as state (`false`). + +Defaults to `false`. + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`throwOnError`](QueryObserverOptions.md#throwonerror) diff --git a/docs/framework/preact/reference/interfaces/UseInfiniteQueryOptions.md b/docs/framework/preact/reference/interfaces/UseInfiniteQueryOptions.md index e7a6d226843..5befdc4e324 100644 --- a/docs/framework/preact/reference/interfaces/UseInfiniteQueryOptions.md +++ b/docs/framework/preact/reference/interfaces/UseInfiniteQueryOptions.md @@ -3,15 +3,15 @@ id: UseInfiniteQueryOptions title: UseInfiniteQueryOptions --- -Defined in: [preact-query/src/types.ts:237](https://github.com/TanStack/query/blob/main/packages/preact-query/src/types.ts#L237) +Defined in: [packages/preact-query/src/types.ts:237](https://github.com/TanStack/query/blob/main/packages/preact-query/src/types.ts#L237) -The options accepted by `useInfiniteQuery`. Extends InfiniteQueryObserverOptions from +The options accepted by `useInfiniteQuery`. Extends [InfiniteQueryObserverOptions](InfiniteQueryObserverOptions.md) from `@tanstack/query-core` with the `preact-query`-specific `subscribed` option, minus `suspense` (which `preact-query` derives from which hook you call rather than exposing as an option). ## Extends -- `OmitKeyof`\<`InfiniteQueryObserverOptions`\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`, `TPageParam`\>, `"suspense"`\> +- [`OmitKeyof`](../type-aliases/OmitKeyof.md)\<[`InfiniteQueryObserverOptions`](InfiniteQueryObserverOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`, `TPageParam`\>, `"suspense"`\> ## Type Parameters @@ -23,20 +23,20 @@ The type of a single page, as your `queryFn` resolves it. ### TError -`TError` = `DefaultError` +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) The type of errors your `queryFn` may throw. ### TData -`TData` = `InfiniteData`\<`TQueryFnData`\> +`TData` = [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`\> The type `data` ends up as after `select` runs — defaults to `InfiniteData`, the shape of all fetched pages plus their page params. ### TQueryKey -`TQueryKey` *extends* `QueryKey` = `QueryKey` +`TQueryKey` *extends* [`QueryKey`](../type-aliases/QueryKey.md) = [`QueryKey`](../type-aliases/QueryKey.md) The type of your `queryKey`. @@ -48,13 +48,607 @@ The type of the parameter passed to `queryFn` to fetch a given page. ## Properties +### enabled? + +```ts +optional enabled: QueryBooleanOption, TQueryKey>; +``` + +Defined in: [packages/query-core/src/types.ts:398](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L398) + +Set this to `false` or a function that returns `false` to disable automatic refetching when the query mounts or changes query keys. +To refetch the query, use the `refetch` method returned from the `useQuery` instance. +Accepts a boolean or function that returns a boolean. + +Defaults to `true`. + +#### Inherited from + +```ts +OmitKeyof.enabled +``` + +*** + +### gcTime? + +```ts +optional gcTime: number; +``` + +Defined in: [packages/query-core/src/types.ts:277](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L277) + +The time in milliseconds that unused/inactive cache data remains in memory. +When a query's cache becomes unused or inactive, that cache data will be garbage collected after this duration. +When different garbage collection times are specified, the longest one will be used. +Setting it to `Infinity` will disable garbage collection. + +Defaults to `5 * 60 * 1000` (5 minutes), or `Infinity` during SSR. + +Note: the maximum allowed time is about 24 days, imposed by `setTimeout`'s 32-bit signed integer delay — see +`timeoutManager.setTimeoutProvider` for a workaround. + +#### Inherited from + +[`QueryOptions`](QueryOptions.md).[`gcTime`](QueryOptions.md#gctime) + +*** + +### getNextPageParam + +```ts +getNextPageParam: GetNextPageParamFunction; +``` + +Defined in: [packages/query-core/src/types.ts:365](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L365) + +This function can be set to automatically get the next cursor for infinite queries. +The result will also be used to determine the value of `hasNextPage`. + +#### Inherited from + +```ts +OmitKeyof.getNextPageParam +``` + +*** + +### getPreviousPageParam? + +```ts +optional getPreviousPageParam: GetPreviousPageParamFunction; +``` + +Defined in: [packages/query-core/src/types.ts:360](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L360) + +This function can be set to automatically get the previous cursor for infinite queries. +The result will also be used to determine the value of `hasPreviousPage`. + +#### Inherited from + +```ts +OmitKeyof.getPreviousPageParam +``` + +*** + +### initialData? + +```ts +optional initialData: + | InfiniteData +| InitialDataFunction>; +``` + +Defined in: [packages/query-core/src/types.ts:317](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L317) + +If set, this value will be used as the initial data for the query cache (as long as the query hasn't been +created or cached yet). +If set to a function, the function will be called **once** during the shared/root query initialization, and be +expected to synchronously return the initial data. +Initial data is considered stale by default unless a `staleTime` has been set. +`initialData` **is persisted** to the cache. + +#### Inherited from + +```ts +OmitKeyof.initialData +``` + +*** + +### initialDataUpdatedAt? + +```ts +optional initialDataUpdatedAt: number | () => number | undefined; +``` + +Defined in: [packages/query-core/src/types.ts:321](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L321) + +If set, this value will be used as the time (in milliseconds) of when the `initialData` itself was last updated. + +#### Inherited from + +```ts +OmitKeyof.initialDataUpdatedAt +``` + +*** + +### initialPageParam + +```ts +initialPageParam: TPageParam; +``` + +Defined in: [packages/query-core/src/types.ts:349](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L349) + +#### Inherited from + +```ts +OmitKeyof.initialPageParam +``` + +*** + +### maxPages? + +```ts +optional maxPages: number; +``` + +Defined in: [packages/query-core/src/types.ts:345](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L345) + +Maximum number of pages to store in the data of an infinite query. + +#### Inherited from + +[`QueryOptions`](QueryOptions.md).[`maxPages`](QueryOptions.md#maxpages) + +*** + +### meta? + +```ts +optional meta: Record; +``` + +Defined in: [packages/query-core/src/types.ts:341](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L341) + +Additional payload to be stored on each query. +Use this property to pass information that can be used in other places. + +#### Inherited from + +[`QueryOptions`](QueryOptions.md).[`meta`](QueryOptions.md#meta) + +*** + +### networkMode? + +```ts +optional networkMode: NetworkMode; +``` + +Defined in: [packages/query-core/src/types.ts:265](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L265) + +Controls whether a query is allowed to run based on the current network connectivity. + +Defaults to `'online'`. + +#### See + +[Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. + +#### Inherited from + +[`QueryOptions`](QueryOptions.md).[`networkMode`](QueryOptions.md#networkmode) + +*** + +### notifyOnChangeProps? + +```ts +optional notifyOnChangeProps: NotifyOnChangeProps; +``` + +Defined in: [packages/query-core/src/types.ts:484](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L484) + +If set, the component will only re-render if any of the listed properties change. +When set to `['data', 'error']`, the component will only re-render when the `data` or `error` properties change. +When set to `'all'`, the component will re-render whenever a query is updated. +When set to a function, the function will be executed to compute the list of properties. + +Defaults to `undefined`, in which case property access is tracked automatically, and the +component only re-renders when one of the tracked properties changes. + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`notifyOnChangeProps`](QueryObserverOptions.md#notifyonchangeprops) + +*** + +### persister? + +```ts +optional persister: QueryPersister, TPageParam>; +``` + +Defined in: [packages/query-core/src/types.ts:290](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L290) + +This option can be used to persist the result of a query to an external storage, bypassing the need to actually +call the `queryFn`. Useful for persisting a query's data across e.g. server/client boundaries. + +#### Inherited from + +```ts +OmitKeyof.persister +``` + +*** + +### placeholderData? + +```ts +optional placeholderData: + | InfiniteData +| PlaceholderDataFunction, TError, InfiniteData, TQueryKey>; +``` + +Defined in: [packages/query-core/src/types.ts:511](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L511) + +If set, this value will be used as the placeholder data for this particular query observer while the query is still in the `loading` data and no initialData has been provided. + +#### Inherited from + +```ts +OmitKeyof.placeholderData +``` + +*** + +### queryFn? + +```ts +optional queryFn: + | typeof skipToken +| QueryFunction; +``` + +Defined in: [packages/query-core/src/types.ts:285](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L285) + +The function that the query will use to request data. +Required, unless a default query function has been set via `queryClient.setQueryDefaults` or +`queryClient.setDefaultOptions`. +Receives a [QueryFunctionContext](../type-aliases/QueryFunctionContext.md). +Must return a promise that will either resolve data or throw an error. The data cannot be `undefined`. + +#### Inherited from + +```ts +OmitKeyof.queryFn +``` + +*** + +### queryHash? + +```ts +optional queryHash: string; +``` + +Defined in: [packages/query-core/src/types.ts:295](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L295) + +The hashed form of `queryKey`, computed with `queryKeyHashFn` (or the default hashing function otherwise). Used +as the actual cache key internally. + +#### Inherited from + +[`QueryOptions`](QueryOptions.md).[`queryHash`](QueryOptions.md#queryhash) + +*** + +### queryKey + +```ts +queryKey: TQueryKey & object; +``` + +Defined in: [packages/query-core/src/types.ts:304](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L304) + +The query key to use for this query. + +The query key will be hashed into a stable hash. See [Query Keys](https://tanstack.com/query/latest/docs/framework/react/guides/query-keys) +for more information. + +The query will automatically update when this key changes (as long as `enabled` is not set to `false`). + +#### Inherited from + +```ts +OmitKeyof.queryKey +``` + +*** + +### queryKeyHashFn? + +```ts +optional queryKeyHashFn: QueryKeyHashFunction; +``` + +Defined in: [packages/query-core/src/types.ts:308](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L308) + +If specified, this function is used to hash the `queryKey` to a string. + +#### Inherited from + +```ts +OmitKeyof.queryKeyHashFn +``` + +*** + +### refetchInterval? + +```ts +optional refetchInterval: number | false | (query) => number | false | undefined; +``` + +Defined in: [packages/query-core/src/types.ts:414](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L414) + +If set to a number, the query will continuously refetch at this frequency in milliseconds. +If set to a function, the function will be executed with the latest data and query to compute a frequency + +Defaults to `false`. + +#### Inherited from + +```ts +OmitKeyof.refetchInterval +``` + +*** + +### refetchIntervalInBackground? + +```ts +optional refetchIntervalInBackground: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:425](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L425) + +If set to `true`, the query will continue to refetch while their tab/window is in the background. + +Defaults to `false`. + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`refetchIntervalInBackground`](QueryObserverOptions.md#refetchintervalinbackground) + +*** + +### refetchOnMount? + +```ts +optional refetchOnMount: boolean | "always" | (query) => boolean | "always"; +``` + +Defined in: [packages/query-core/src/types.ts:462](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L462) + +If set to `true`, the query will refetch on mount if the data is stale. +If set to `false`, will disable additional instances of a query to trigger background refetch. +If set to `'always'`, the query will always refetch on mount (except when `staleTime: 'static'` is used). +If set to a function, the function will be executed with the latest data and query to compute the value + +Defaults to `true`. + +#### Inherited from + +```ts +OmitKeyof.refetchOnMount +``` + +*** + +### refetchOnReconnect? + +```ts +optional refetchOnReconnect: boolean | "always" | (query) => boolean | "always"; +``` + +Defined in: [packages/query-core/src/types.ts:448](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L448) + +If set to `true`, the query will refetch on reconnect if the data is stale. +If set to `false`, the query will not refetch on reconnect. +If set to `'always'`, the query will always refetch on reconnect (except when `staleTime: 'static'` is used). +If set to a function, the function will be executed with the latest data and query to compute the value. + +Defaults to `true` unless `networkMode` is `'always'`. + +#### Inherited from + +```ts +OmitKeyof.refetchOnReconnect +``` + +*** + +### refetchOnWindowFocus? + +```ts +optional refetchOnWindowFocus: boolean | "always" | (query) => boolean | "always"; +``` + +Defined in: [packages/query-core/src/types.ts:434](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L434) + +If set to `true`, the query will refetch on window focus if the data is stale. +If set to `false`, the query will not refetch on window focus. +If set to `'always'`, the query will always refetch on window focus (except when `staleTime: 'static'` is used). +If set to a function, the function will be executed with the latest data and query to compute the value. + +Defaults to `true`. + +#### Inherited from + +```ts +OmitKeyof.refetchOnWindowFocus +``` + +*** + +### retry? + +```ts +optional retry: RetryValue; +``` + +Defined in: [packages/query-core/src/types.ts:246](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L246) + +If `false`, failed queries will not retry by default. +If `true`, failed queries will retry infinitely. +If set to an integer number, e.g. 3, failed queries will retry until the failed query count meets that number. +If set to a function `(failureCount, error) => boolean` failed queries will retry until the function returns false. + +Defaults to `3` on the client and `0` on the server. + +#### Inherited from + +```ts +OmitKeyof.retry +``` + +*** + +### retryDelay? + +```ts +optional retryDelay: RetryDelayValue; +``` + +Defined in: [packages/query-core/src/types.ts:258](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L258) + +This function receives a `retryAttempt` integer and the actual Error and returns the delay to apply before the +next attempt in milliseconds. + +A function like `attempt => Math.min(attempt > 1 ? 2 ** attempt * 1000 : 1000, 30 * 1000)` applies exponential +backoff. + +A function like `attempt => attempt * 1000` applies linear backoff. + +Defaults to a function that applies exponential backoff, capped at 30 seconds. + +#### Inherited from + +```ts +OmitKeyof.retryDelay +``` + +*** + +### retryOnMount? + +```ts +optional retryOnMount: QueryBooleanOption, TQueryKey>; +``` + +Defined in: [packages/query-core/src/types.ts:474](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L474) + +If set to `false`, the query will not be retried on mount if it contains an error. +If set to a function, the function will be executed with the query to compute the value. + +Defaults to `true`. + +#### Inherited from + +```ts +OmitKeyof.retryOnMount +``` + +*** + +### select()? + +```ts +optional select: (data) => TData; +``` + +Defined in: [packages/query-core/src/types.ts:500](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L500) + +This option can be used to transform or select a part of the data returned by the query function. It affects +the returned `data` value, but does not affect what gets stored in the query cache. +The `select` function will only run if `data` changed, or if the reference to the `select` function itself +changes. To optimize, memoize the function so its reference stays stable across calls. + +#### Parameters + +##### data + +[`InfiniteData`](InfiniteData.md) + +#### Returns + +`TData` + +#### Inherited from + +```ts +OmitKeyof.select +``` + +*** + +### staleTime? + +```ts +optional staleTime: StaleTimeFunction, TQueryKey>; +``` + +Defined in: [packages/query-core/src/types.ts:407](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L407) + +The time in milliseconds after data is considered stale. +If set to `Infinity`, the data will never be considered stale. +If set to `'static'`, the data will never be considered stale. +If set to a function, the function will be executed with the query to compute a `staleTime`. + +Defaults to `0`. + +#### Inherited from + +```ts +OmitKeyof.staleTime +``` + +*** + +### structuralSharing? + +```ts +optional structuralSharing: boolean | (oldData, newData) => unknown; +``` + +Defined in: [packages/query-core/src/types.ts:330](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L330) + +Set this to `false` to disable structural sharing between query results. +Set this to a function which accepts the old and new data and returns resolved data of the same type to implement custom structural sharing logic. + +Defaults to `true`. + +#### Inherited from + +```ts +OmitKeyof.structuralSharing +``` + +*** + ### subscribed? ```ts optional subscribed: boolean; ``` -Defined in: [preact-query/src/types.ts:258](https://github.com/TanStack/query/blob/main/packages/preact-query/src/types.ts#L258) +Defined in: [packages/preact-query/src/types.ts:258](https://github.com/TanStack/query/blob/main/packages/preact-query/src/types.ts#L258) Set this to `false` to unsubscribe this observer from updates to the query cache. @@ -63,3 +657,26 @@ Set this to `false` to unsubscribe this observer from updates to the query cache ```ts true ``` + +*** + +### throwOnError? + +```ts +optional throwOnError: ThrowOnError, TQueryKey>; +``` + +Defined in: [packages/query-core/src/types.ts:493](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L493) + +Whether errors should be thrown instead of setting the `error` property. +If set to `true` or `suspense` is `true`, all errors will be thrown to the error boundary. +If set to `false` and `suspense` is `false`, errors are returned as state. +If set to a function, it will be passed the error and the query, and it should return a boolean indicating whether to show the error in an error boundary (`true`) or return the error as state (`false`). + +Defaults to `false`. + +#### Inherited from + +```ts +OmitKeyof.throwOnError +``` diff --git a/docs/framework/preact/reference/interfaces/UseMutationOptions.md b/docs/framework/preact/reference/interfaces/UseMutationOptions.md index e3b5143b26a..65b0aafe345 100644 --- a/docs/framework/preact/reference/interfaces/UseMutationOptions.md +++ b/docs/framework/preact/reference/interfaces/UseMutationOptions.md @@ -3,14 +3,14 @@ id: UseMutationOptions title: UseMutationOptions --- -Defined in: [preact-query/src/types.ts:411](https://github.com/TanStack/query/blob/main/packages/preact-query/src/types.ts#L411) +Defined in: [packages/preact-query/src/types.ts:411](https://github.com/TanStack/query/blob/main/packages/preact-query/src/types.ts#L411) -The options accepted by `useMutation`. Same as MutationObserverOptions from `@tanstack/query-core`, +The options accepted by `useMutation`. Same as [MutationObserverOptions](MutationObserverOptions.md) from `@tanstack/query-core`, minus the internal `_defaulted` flag. ## Extends -- `OmitKeyof`\<`MutationObserverOptions`\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\>, `"_defaulted"`\> +- [`OmitKeyof`](../type-aliases/OmitKeyof.md)\<[`MutationObserverOptions`](MutationObserverOptions.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\>, `"_defaulted"`\> ## Type Parameters @@ -22,7 +22,7 @@ The type your mutation function resolves to. ### TError -`TError` = `DefaultError` +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) The type of errors your mutation function may throw. @@ -38,3 +38,317 @@ The type of the variable passed to `mutate`/`mutateAsync`. The type returned by `onMutate`, passed to `onSuccess`/`onError`/`onSettled` as their `onMutateResult` parameter — useful for optimistic-update rollback data. + +## Properties + +### gcTime? + +```ts +optional gcTime: number; +``` + +Defined in: [packages/query-core/src/types.ts:1260](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1260) + +The time in milliseconds that an unused/inactive mutation remains in memory before it is +garbage collected. + +Defaults to `5 * 60 * 1000` (5 minutes), or `Infinity` during SSR. + +#### Inherited from + +[`MutationOptions`](MutationOptions.md).[`gcTime`](MutationOptions.md#gctime) + +*** + +### meta? + +```ts +optional meta: Record; +``` + +Defined in: [packages/query-core/src/types.ts:1263](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1263) + +#### Inherited from + +[`MutationOptions`](MutationOptions.md).[`meta`](MutationOptions.md#meta) + +*** + +### mutationFn? + +```ts +optional mutationFn: MutationFunction; +``` + +Defined in: [packages/query-core/src/types.ts:1206](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1206) + +#### Inherited from + +```ts +OmitKeyof.mutationFn +``` + +*** + +### mutationKey? + +```ts +optional mutationKey: readonly unknown[]; +``` + +Defined in: [packages/query-core/src/types.ts:1207](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1207) + +#### Inherited from + +[`MutationOptions`](MutationOptions.md).[`mutationKey`](MutationOptions.md#mutationkey) + +*** + +### networkMode? + +```ts +optional networkMode: NetworkMode; +``` + +Defined in: [packages/query-core/src/types.ts:1253](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1253) + +Controls whether a mutation is allowed to run based on the current network connectivity. + +Defaults to `'online'`. + +#### See + +[Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. + +#### Inherited from + +[`MutationOptions`](MutationOptions.md).[`networkMode`](MutationOptions.md#networkmode) + +*** + +### onError()? + +```ts +optional onError: (error, variables, onMutateResult, context) => unknown; +``` + +Defined in: [packages/query-core/src/types.ts:1218](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1218) + +#### Parameters + +##### error + +`TError` + +##### variables + +`TVariables` + +##### onMutateResult + +`TOnMutateResult` | `undefined` + +##### context + +[`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md) + +#### Returns + +`unknown` + +#### Inherited from + +```ts +OmitKeyof.onError +``` + +*** + +### onMutate()? + +```ts +optional onMutate: (variables, context) => TOnMutateResult | Promise; +``` + +Defined in: [packages/query-core/src/types.ts:1208](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1208) + +#### Parameters + +##### variables + +`TVariables` + +##### context + +[`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md) + +#### Returns + +`TOnMutateResult` \| `Promise`\<`TOnMutateResult`\> + +#### Inherited from + +```ts +OmitKeyof.onMutate +``` + +*** + +### onSettled()? + +```ts +optional onSettled: (data, error, variables, onMutateResult, context) => unknown; +``` + +Defined in: [packages/query-core/src/types.ts:1224](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1224) + +#### Parameters + +##### data + +`TData` | `undefined` + +##### error + +`TError` | `null` + +##### variables + +`TVariables` + +##### onMutateResult + +`TOnMutateResult` | `undefined` + +##### context + +[`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md) + +#### Returns + +`unknown` + +#### Inherited from + +```ts +OmitKeyof.onSettled +``` + +*** + +### onSuccess()? + +```ts +optional onSuccess: (data, variables, onMutateResult, context) => unknown; +``` + +Defined in: [packages/query-core/src/types.ts:1212](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1212) + +#### Parameters + +##### data + +`TData` + +##### variables + +`TVariables` + +##### onMutateResult + +`TOnMutateResult` + +##### context + +[`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md) + +#### Returns + +`unknown` + +#### Inherited from + +```ts +OmitKeyof.onSuccess +``` + +*** + +### retry? + +```ts +optional retry: RetryValue; +``` + +Defined in: [packages/query-core/src/types.ts:1239](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1239) + +If `false`, failed mutations will not retry by default. +If `true`, failed mutations will retry infinitely. +If set to an integer number, e.g. 3, failed mutations will retry until the failed mutation count meets that number. +If set to a function `(failureCount, error) => boolean` failed mutations will retry until the function returns false. + +Defaults to `0`. + +#### Inherited from + +```ts +OmitKeyof.retry +``` + +*** + +### retryDelay? + +```ts +optional retryDelay: RetryDelayValue; +``` + +Defined in: [packages/query-core/src/types.ts:1246](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1246) + +This function receives a `retryAttempt` integer and the actual Error and returns the delay to apply before the +next attempt in milliseconds. + +Defaults to a function that applies exponential backoff, capped at 30 seconds. + +#### Inherited from + +```ts +OmitKeyof.retryDelay +``` + +*** + +### scope? + +```ts +optional scope: MutationScope; +``` + +Defined in: [packages/query-core/src/types.ts:1264](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1264) + +#### Inherited from + +[`MutationOptions`](MutationOptions.md).[`scope`](MutationOptions.md#scope) + +*** + +### throwOnError? + +```ts +optional throwOnError: boolean | (error) => boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1281](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1281) + +Whether errors should be thrown instead of setting the `error` property. +If set to `true`, all errors will be thrown to the nearest error boundary. +If set to a function, it will be passed the error and should return a boolean indicating whether to throw the +error (`true`) or return it as state (`false`). + +Defaults to `false`. + +#### Inherited from + +```ts +OmitKeyof.throwOnError +``` diff --git a/docs/framework/preact/reference/interfaces/UseQueryOptions.md b/docs/framework/preact/reference/interfaces/UseQueryOptions.md index b524552cc68..7001c0cb37f 100644 --- a/docs/framework/preact/reference/interfaces/UseQueryOptions.md +++ b/docs/framework/preact/reference/interfaces/UseQueryOptions.md @@ -3,14 +3,14 @@ id: UseQueryOptions title: UseQueryOptions --- -Defined in: [preact-query/src/types.ts:164](https://github.com/TanStack/query/blob/main/packages/preact-query/src/types.ts#L164) +Defined in: [packages/preact-query/src/types.ts:164](https://github.com/TanStack/query/blob/main/packages/preact-query/src/types.ts#L164) The options accepted by `useQuery`. Same as [UseBaseQueryOptions](UseBaseQueryOptions.md), minus `suspense` (which `preact-query` derives from which hook you call rather than exposing as an option). ## Extends -- `OmitKeyof`\<[`UseBaseQueryOptions`](UseBaseQueryOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryFnData`, `TQueryKey`\>, `"suspense"`\> +- [`OmitKeyof`](../type-aliases/OmitKeyof.md)\<[`UseBaseQueryOptions`](UseBaseQueryOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryFnData`, `TQueryKey`\>, `"suspense"`\> ## Type Parameters @@ -22,7 +22,7 @@ The type your `queryFn` resolves to. ### TError -`TError` = `DefaultError` +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) The type of errors your `queryFn` may throw. @@ -35,19 +35,603 @@ The type `data` ends up as after `select` runs. Defaults to `TQueryFnData` when ### TQueryKey -`TQueryKey` *extends* `QueryKey` = `QueryKey` +`TQueryKey` *extends* [`QueryKey`](../type-aliases/QueryKey.md) = [`QueryKey`](../type-aliases/QueryKey.md) The type of your `queryKey`. ## Properties +### enabled? + +```ts +optional enabled: QueryBooleanOption; +``` + +Defined in: [packages/query-core/src/types.ts:398](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L398) + +Set this to `false` or a function that returns `false` to disable automatic refetching when the query mounts or changes query keys. +To refetch the query, use the `refetch` method returned from the `useQuery` instance. +Accepts a boolean or function that returns a boolean. + +Defaults to `true`. + +#### Inherited from + +```ts +OmitKeyof.enabled +``` + +*** + +### gcTime? + +```ts +optional gcTime: number; +``` + +Defined in: [packages/query-core/src/types.ts:277](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L277) + +The time in milliseconds that unused/inactive cache data remains in memory. +When a query's cache becomes unused or inactive, that cache data will be garbage collected after this duration. +When different garbage collection times are specified, the longest one will be used. +Setting it to `Infinity` will disable garbage collection. + +Defaults to `5 * 60 * 1000` (5 minutes), or `Infinity` during SSR. + +Note: the maximum allowed time is about 24 days, imposed by `setTimeout`'s 32-bit signed integer delay — see +`timeoutManager.setTimeoutProvider` for a workaround. + +#### Inherited from + +[`QueryOptions`](QueryOptions.md).[`gcTime`](QueryOptions.md#gctime) + +*** + +### initialData? + +```ts +optional initialData: + | TQueryFnData +| InitialDataFunction; +``` + +Defined in: [packages/query-core/src/types.ts:317](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L317) + +If set, this value will be used as the initial data for the query cache (as long as the query hasn't been +created or cached yet). +If set to a function, the function will be called **once** during the shared/root query initialization, and be +expected to synchronously return the initial data. +Initial data is considered stale by default unless a `staleTime` has been set. +`initialData` **is persisted** to the cache. + +#### Inherited from + +```ts +OmitKeyof.initialData +``` + +*** + +### initialDataUpdatedAt? + +```ts +optional initialDataUpdatedAt: number | () => number | undefined; +``` + +Defined in: [packages/query-core/src/types.ts:321](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L321) + +If set, this value will be used as the time (in milliseconds) of when the `initialData` itself was last updated. + +#### Inherited from + +```ts +OmitKeyof.initialDataUpdatedAt +``` + +*** + +### maxPages? + +```ts +optional maxPages: number; +``` + +Defined in: [packages/query-core/src/types.ts:345](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L345) + +Maximum number of pages to store in the data of an infinite query. + +#### Inherited from + +[`QueryOptions`](QueryOptions.md).[`maxPages`](QueryOptions.md#maxpages) + +*** + +### meta? + +```ts +optional meta: Record; +``` + +Defined in: [packages/query-core/src/types.ts:341](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L341) + +Additional payload to be stored on each query. +Use this property to pass information that can be used in other places. + +#### Inherited from + +[`QueryOptions`](QueryOptions.md).[`meta`](QueryOptions.md#meta) + +*** + +### networkMode? + +```ts +optional networkMode: NetworkMode; +``` + +Defined in: [packages/query-core/src/types.ts:265](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L265) + +Controls whether a query is allowed to run based on the current network connectivity. + +Defaults to `'online'`. + +#### See + +[Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. + +#### Inherited from + +[`QueryOptions`](QueryOptions.md).[`networkMode`](QueryOptions.md#networkmode) + +*** + +### notifyOnChangeProps? + +```ts +optional notifyOnChangeProps: NotifyOnChangeProps; +``` + +Defined in: [packages/query-core/src/types.ts:484](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L484) + +If set, the component will only re-render if any of the listed properties change. +When set to `['data', 'error']`, the component will only re-render when the `data` or `error` properties change. +When set to `'all'`, the component will re-render whenever a query is updated. +When set to a function, the function will be executed to compute the list of properties. + +Defaults to `undefined`, in which case property access is tracked automatically, and the +component only re-renders when one of the tracked properties changes. + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`notifyOnChangeProps`](QueryObserverOptions.md#notifyonchangeprops) + +*** + +### persister()? + +```ts +optional persister: (queryFn, context, query) => TQueryFnData | Promise; +``` + +Defined in: [packages/query-core/src/types.ts:290](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L290) + +This option can be used to persist the result of a query to an external storage, bypassing the need to actually +call the `queryFn`. Useful for persisting a query's data across e.g. server/client boundaries. + +#### Parameters + +##### queryFn + +[`QueryFunction`](../type-aliases/QueryFunction.md)\<`TQueryFnData`, `NoInfer`\<`TQueryKey`\>, `never`\> + +##### context + +###### client + +[`QueryClient`](../classes/QueryClient.md) + +###### direction? + +`unknown` + +**Deprecated** + +if you want access to the direction, you can add it to the pageParam + +###### meta + +`Record`\<`string`, `unknown`\> \| `undefined` + +###### pageParam? + +`unknown` + +###### queryKey + +`NoInfer`\<`TQueryKey`\> + +###### signal + +`AbortSignal` + +##### query + +[`Query`](../classes/Query.md) + +#### Returns + +`TQueryFnData` \| `Promise`\<`TQueryFnData`\> + +#### Inherited from + +```ts +OmitKeyof.persister +``` + +*** + +### placeholderData? + +```ts +optional placeholderData: + | NonFunctionGuard +| PlaceholderDataFunction, TError, NonFunctionGuard, TQueryKey>; +``` + +Defined in: [packages/query-core/src/types.ts:511](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L511) + +If set, this value will be used as the placeholder data for this particular query observer while the query is still in the `loading` data and no initialData has been provided. + +#### Inherited from + +```ts +OmitKeyof.placeholderData +``` + +*** + +### queryFn? + +```ts +optional queryFn: + | typeof skipToken +| QueryFunction; +``` + +Defined in: [packages/query-core/src/types.ts:285](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L285) + +The function that the query will use to request data. +Required, unless a default query function has been set via `queryClient.setQueryDefaults` or +`queryClient.setDefaultOptions`. +Receives a [QueryFunctionContext](../type-aliases/QueryFunctionContext.md). +Must return a promise that will either resolve data or throw an error. The data cannot be `undefined`. + +#### Inherited from + +```ts +OmitKeyof.queryFn +``` + +*** + +### queryHash? + +```ts +optional queryHash: string; +``` + +Defined in: [packages/query-core/src/types.ts:295](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L295) + +The hashed form of `queryKey`, computed with `queryKeyHashFn` (or the default hashing function otherwise). Used +as the actual cache key internally. + +#### Inherited from + +[`QueryOptions`](QueryOptions.md).[`queryHash`](QueryOptions.md#queryhash) + +*** + +### queryKey + +```ts +queryKey: TQueryKey & object; +``` + +Defined in: [packages/query-core/src/types.ts:304](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L304) + +The query key to use for this query. + +The query key will be hashed into a stable hash. See [Query Keys](https://tanstack.com/query/latest/docs/framework/react/guides/query-keys) +for more information. + +The query will automatically update when this key changes (as long as `enabled` is not set to `false`). + +#### Inherited from + +```ts +OmitKeyof.queryKey +``` + +*** + +### queryKeyHashFn? + +```ts +optional queryKeyHashFn: QueryKeyHashFunction; +``` + +Defined in: [packages/query-core/src/types.ts:308](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L308) + +If specified, this function is used to hash the `queryKey` to a string. + +#### Inherited from + +```ts +OmitKeyof.queryKeyHashFn +``` + +*** + +### refetchInterval? + +```ts +optional refetchInterval: number | false | (query) => number | false | undefined; +``` + +Defined in: [packages/query-core/src/types.ts:414](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L414) + +If set to a number, the query will continuously refetch at this frequency in milliseconds. +If set to a function, the function will be executed with the latest data and query to compute a frequency + +Defaults to `false`. + +#### Inherited from + +```ts +OmitKeyof.refetchInterval +``` + +*** + +### refetchIntervalInBackground? + +```ts +optional refetchIntervalInBackground: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:425](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L425) + +If set to `true`, the query will continue to refetch while their tab/window is in the background. + +Defaults to `false`. + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`refetchIntervalInBackground`](QueryObserverOptions.md#refetchintervalinbackground) + +*** + +### refetchOnMount? + +```ts +optional refetchOnMount: boolean | "always" | (query) => boolean | "always"; +``` + +Defined in: [packages/query-core/src/types.ts:462](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L462) + +If set to `true`, the query will refetch on mount if the data is stale. +If set to `false`, will disable additional instances of a query to trigger background refetch. +If set to `'always'`, the query will always refetch on mount (except when `staleTime: 'static'` is used). +If set to a function, the function will be executed with the latest data and query to compute the value + +Defaults to `true`. + +#### Inherited from + +```ts +OmitKeyof.refetchOnMount +``` + +*** + +### refetchOnReconnect? + +```ts +optional refetchOnReconnect: boolean | "always" | (query) => boolean | "always"; +``` + +Defined in: [packages/query-core/src/types.ts:448](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L448) + +If set to `true`, the query will refetch on reconnect if the data is stale. +If set to `false`, the query will not refetch on reconnect. +If set to `'always'`, the query will always refetch on reconnect (except when `staleTime: 'static'` is used). +If set to a function, the function will be executed with the latest data and query to compute the value. + +Defaults to `true` unless `networkMode` is `'always'`. + +#### Inherited from + +```ts +OmitKeyof.refetchOnReconnect +``` + +*** + +### refetchOnWindowFocus? + +```ts +optional refetchOnWindowFocus: boolean | "always" | (query) => boolean | "always"; +``` + +Defined in: [packages/query-core/src/types.ts:434](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L434) + +If set to `true`, the query will refetch on window focus if the data is stale. +If set to `false`, the query will not refetch on window focus. +If set to `'always'`, the query will always refetch on window focus (except when `staleTime: 'static'` is used). +If set to a function, the function will be executed with the latest data and query to compute the value. + +Defaults to `true`. + +#### Inherited from + +```ts +OmitKeyof.refetchOnWindowFocus +``` + +*** + +### retry? + +```ts +optional retry: RetryValue; +``` + +Defined in: [packages/query-core/src/types.ts:246](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L246) + +If `false`, failed queries will not retry by default. +If `true`, failed queries will retry infinitely. +If set to an integer number, e.g. 3, failed queries will retry until the failed query count meets that number. +If set to a function `(failureCount, error) => boolean` failed queries will retry until the function returns false. + +Defaults to `3` on the client and `0` on the server. + +#### Inherited from + +```ts +OmitKeyof.retry +``` + +*** + +### retryDelay? + +```ts +optional retryDelay: RetryDelayValue; +``` + +Defined in: [packages/query-core/src/types.ts:258](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L258) + +This function receives a `retryAttempt` integer and the actual Error and returns the delay to apply before the +next attempt in milliseconds. + +A function like `attempt => Math.min(attempt > 1 ? 2 ** attempt * 1000 : 1000, 30 * 1000)` applies exponential +backoff. + +A function like `attempt => attempt * 1000` applies linear backoff. + +Defaults to a function that applies exponential backoff, capped at 30 seconds. + +#### Inherited from + +```ts +OmitKeyof.retryDelay +``` + +*** + +### retryOnMount? + +```ts +optional retryOnMount: QueryBooleanOption; +``` + +Defined in: [packages/query-core/src/types.ts:474](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L474) + +If set to `false`, the query will not be retried on mount if it contains an error. +If set to a function, the function will be executed with the query to compute the value. + +Defaults to `true`. + +#### Inherited from + +```ts +OmitKeyof.retryOnMount +``` + +*** + +### select()? + +```ts +optional select: (data) => TData; +``` + +Defined in: [packages/query-core/src/types.ts:500](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L500) + +This option can be used to transform or select a part of the data returned by the query function. It affects +the returned `data` value, but does not affect what gets stored in the query cache. +The `select` function will only run if `data` changed, or if the reference to the `select` function itself +changes. To optimize, memoize the function so its reference stays stable across calls. + +#### Parameters + +##### data + +`TQueryFnData` + +#### Returns + +`TData` + +#### Inherited from + +```ts +OmitKeyof.select +``` + +*** + +### staleTime? + +```ts +optional staleTime: StaleTimeFunction; +``` + +Defined in: [packages/query-core/src/types.ts:407](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L407) + +The time in milliseconds after data is considered stale. +If set to `Infinity`, the data will never be considered stale. +If set to `'static'`, the data will never be considered stale. +If set to a function, the function will be executed with the query to compute a `staleTime`. + +Defaults to `0`. + +#### Inherited from + +```ts +OmitKeyof.staleTime +``` + +*** + +### structuralSharing? + +```ts +optional structuralSharing: boolean | (oldData, newData) => unknown; +``` + +Defined in: [packages/query-core/src/types.ts:330](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L330) + +Set this to `false` to disable structural sharing between query results. +Set this to a function which accepts the old and new data and returns resolved data of the same type to implement custom structural sharing logic. + +Defaults to `true`. + +#### Inherited from + +```ts +OmitKeyof.structuralSharing +``` + +*** + ### subscribed? ```ts optional subscribed: boolean; ``` -Defined in: [preact-query/src/types.ts:64](https://github.com/TanStack/query/blob/main/packages/preact-query/src/types.ts#L64) +Defined in: [packages/preact-query/src/types.ts:64](https://github.com/TanStack/query/blob/main/packages/preact-query/src/types.ts#L64) Set this to `false` to unsubscribe this observer from updates to the query cache. @@ -62,3 +646,26 @@ true ```ts OmitKeyof.subscribed ``` + +*** + +### throwOnError? + +```ts +optional throwOnError: ThrowOnError; +``` + +Defined in: [packages/query-core/src/types.ts:493](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L493) + +Whether errors should be thrown instead of setting the `error` property. +If set to `true` or `suspense` is `true`, all errors will be thrown to the error boundary. +If set to `false` and `suspense` is `false`, errors are returned as state. +If set to a function, it will be passed the error and the query, and it should return a boolean indicating whether to show the error in an error boundary (`true`) or return the error as state (`false`). + +Defaults to `false`. + +#### Inherited from + +```ts +OmitKeyof.throwOnError +``` diff --git a/docs/framework/preact/reference/interfaces/UseSuspenseInfiniteQueryOptions.md b/docs/framework/preact/reference/interfaces/UseSuspenseInfiniteQueryOptions.md index 123b9f4e2b3..a7f55cb0d5b 100644 --- a/docs/framework/preact/reference/interfaces/UseSuspenseInfiniteQueryOptions.md +++ b/docs/framework/preact/reference/interfaces/UseSuspenseInfiniteQueryOptions.md @@ -3,7 +3,7 @@ id: UseSuspenseInfiniteQueryOptions title: UseSuspenseInfiniteQueryOptions --- -Defined in: [preact-query/src/types.ts:279](https://github.com/TanStack/query/blob/main/packages/preact-query/src/types.ts#L279) +Defined in: [packages/preact-query/src/types.ts:279](https://github.com/TanStack/query/blob/main/packages/preact-query/src/types.ts#L279) The options accepted by `useSuspenseInfiniteQuery`. Same as [UseInfiniteQueryOptions](UseInfiniteQueryOptions.md), minus `enabled`, `throwOnError`, and `placeholderData` — Suspense hooks cannot render a "disabled" or "placeholder" state, so @@ -11,7 +11,7 @@ those options don't apply. ## Extends -- `OmitKeyof`\<[`UseInfiniteQueryOptions`](UseInfiniteQueryOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`, `TPageParam`\>, `"queryFn"` \| `"enabled"` \| `"throwOnError"` \| `"placeholderData"`\> +- [`OmitKeyof`](../type-aliases/OmitKeyof.md)\<[`UseInfiniteQueryOptions`](UseInfiniteQueryOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`, `TPageParam`\>, `"queryFn"` \| `"enabled"` \| `"throwOnError"` \| `"placeholderData"`\> ## Type Parameters @@ -23,20 +23,20 @@ The type of a single page, as your `queryFn` resolves it. ### TError -`TError` = `DefaultError` +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) The type of errors your `queryFn` may throw. ### TData -`TData` = `InfiniteData`\<`TQueryFnData`\> +`TData` = [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`\> The type `data` ends up as after `select` runs — defaults to `InfiniteData`, the shape of all fetched pages plus their page params. ### TQueryKey -`TQueryKey` *extends* `QueryKey` = `QueryKey` +`TQueryKey` *extends* [`QueryKey`](../type-aliases/QueryKey.md) = [`QueryKey`](../type-aliases/QueryKey.md) The type of your `queryKey`. @@ -48,26 +48,554 @@ The type of the parameter passed to `queryFn` to fetch a given page. ## Properties +### gcTime? + +```ts +optional gcTime: number; +``` + +Defined in: [packages/query-core/src/types.ts:277](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L277) + +The time in milliseconds that unused/inactive cache data remains in memory. +When a query's cache becomes unused or inactive, that cache data will be garbage collected after this duration. +When different garbage collection times are specified, the longest one will be used. +Setting it to `Infinity` will disable garbage collection. + +Defaults to `5 * 60 * 1000` (5 minutes), or `Infinity` during SSR. + +Note: the maximum allowed time is about 24 days, imposed by `setTimeout`'s 32-bit signed integer delay — see +`timeoutManager.setTimeoutProvider` for a workaround. + +#### Inherited from + +[`QueryOptions`](QueryOptions.md).[`gcTime`](QueryOptions.md#gctime) + +*** + +### getNextPageParam + +```ts +getNextPageParam: GetNextPageParamFunction; +``` + +Defined in: [packages/query-core/src/types.ts:365](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L365) + +This function can be set to automatically get the next cursor for infinite queries. +The result will also be used to determine the value of `hasNextPage`. + +#### Inherited from + +```ts +OmitKeyof.getNextPageParam +``` + +*** + +### getPreviousPageParam? + +```ts +optional getPreviousPageParam: GetPreviousPageParamFunction; +``` + +Defined in: [packages/query-core/src/types.ts:360](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L360) + +This function can be set to automatically get the previous cursor for infinite queries. +The result will also be used to determine the value of `hasPreviousPage`. + +#### Inherited from + +```ts +OmitKeyof.getPreviousPageParam +``` + +*** + +### initialData? + +```ts +optional initialData: + | InfiniteData +| InitialDataFunction>; +``` + +Defined in: [packages/query-core/src/types.ts:317](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L317) + +If set, this value will be used as the initial data for the query cache (as long as the query hasn't been +created or cached yet). +If set to a function, the function will be called **once** during the shared/root query initialization, and be +expected to synchronously return the initial data. +Initial data is considered stale by default unless a `staleTime` has been set. +`initialData` **is persisted** to the cache. + +#### Inherited from + +```ts +OmitKeyof.initialData +``` + +*** + +### initialDataUpdatedAt? + +```ts +optional initialDataUpdatedAt: number | () => number | undefined; +``` + +Defined in: [packages/query-core/src/types.ts:321](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L321) + +If set, this value will be used as the time (in milliseconds) of when the `initialData` itself was last updated. + +#### Inherited from + +```ts +OmitKeyof.initialDataUpdatedAt +``` + +*** + +### initialPageParam + +```ts +initialPageParam: TPageParam; +``` + +Defined in: [packages/query-core/src/types.ts:349](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L349) + +#### Inherited from + +```ts +OmitKeyof.initialPageParam +``` + +*** + +### maxPages? + +```ts +optional maxPages: number; +``` + +Defined in: [packages/query-core/src/types.ts:345](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L345) + +Maximum number of pages to store in the data of an infinite query. + +#### Inherited from + +[`QueryOptions`](QueryOptions.md).[`maxPages`](QueryOptions.md#maxpages) + +*** + +### meta? + +```ts +optional meta: Record; +``` + +Defined in: [packages/query-core/src/types.ts:341](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L341) + +Additional payload to be stored on each query. +Use this property to pass information that can be used in other places. + +#### Inherited from + +[`QueryOptions`](QueryOptions.md).[`meta`](QueryOptions.md#meta) + +*** + +### networkMode? + +```ts +optional networkMode: NetworkMode; +``` + +Defined in: [packages/query-core/src/types.ts:265](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L265) + +Controls whether a query is allowed to run based on the current network connectivity. + +Defaults to `'online'`. + +#### See + +[Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. + +#### Inherited from + +[`QueryOptions`](QueryOptions.md).[`networkMode`](QueryOptions.md#networkmode) + +*** + +### notifyOnChangeProps? + +```ts +optional notifyOnChangeProps: NotifyOnChangeProps; +``` + +Defined in: [packages/query-core/src/types.ts:484](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L484) + +If set, the component will only re-render if any of the listed properties change. +When set to `['data', 'error']`, the component will only re-render when the `data` or `error` properties change. +When set to `'all'`, the component will re-render whenever a query is updated. +When set to a function, the function will be executed to compute the list of properties. + +Defaults to `undefined`, in which case property access is tracked automatically, and the +component only re-renders when one of the tracked properties changes. + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`notifyOnChangeProps`](QueryObserverOptions.md#notifyonchangeprops) + +*** + +### persister? + +```ts +optional persister: QueryPersister, TPageParam>; +``` + +Defined in: [packages/query-core/src/types.ts:290](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L290) + +This option can be used to persist the result of a query to an external storage, bypassing the need to actually +call the `queryFn`. Useful for persisting a query's data across e.g. server/client boundaries. + +#### Inherited from + +```ts +OmitKeyof.persister +``` + +*** + ### queryFn? ```ts optional queryFn: QueryFunction; ``` -Defined in: [preact-query/src/types.ts:293](https://github.com/TanStack/query/blob/main/packages/preact-query/src/types.ts#L293) +Defined in: [packages/preact-query/src/types.ts:293](https://github.com/TanStack/query/blob/main/packages/preact-query/src/types.ts#L293) `skipToken` is not allowed here — Suspense hooks cannot render a "disabled" state, so a query function must always be provided, unless a default query function has been defined. *** +### queryHash? + +```ts +optional queryHash: string; +``` + +Defined in: [packages/query-core/src/types.ts:295](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L295) + +The hashed form of `queryKey`, computed with `queryKeyHashFn` (or the default hashing function otherwise). Used +as the actual cache key internally. + +#### Inherited from + +[`QueryOptions`](QueryOptions.md).[`queryHash`](QueryOptions.md#queryhash) + +*** + +### queryKey + +```ts +queryKey: TQueryKey & object; +``` + +Defined in: [packages/query-core/src/types.ts:304](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L304) + +The query key to use for this query. + +The query key will be hashed into a stable hash. See [Query Keys](https://tanstack.com/query/latest/docs/framework/react/guides/query-keys) +for more information. + +The query will automatically update when this key changes (as long as `enabled` is not set to `false`). + +#### Inherited from + +```ts +OmitKeyof.queryKey +``` + +*** + +### queryKeyHashFn? + +```ts +optional queryKeyHashFn: QueryKeyHashFunction; +``` + +Defined in: [packages/query-core/src/types.ts:308](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L308) + +If specified, this function is used to hash the `queryKey` to a string. + +#### Inherited from + +```ts +OmitKeyof.queryKeyHashFn +``` + +*** + +### refetchInterval? + +```ts +optional refetchInterval: number | false | (query) => number | false | undefined; +``` + +Defined in: [packages/query-core/src/types.ts:414](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L414) + +If set to a number, the query will continuously refetch at this frequency in milliseconds. +If set to a function, the function will be executed with the latest data and query to compute a frequency + +Defaults to `false`. + +#### Inherited from + +```ts +OmitKeyof.refetchInterval +``` + +*** + +### refetchIntervalInBackground? + +```ts +optional refetchIntervalInBackground: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:425](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L425) + +If set to `true`, the query will continue to refetch while their tab/window is in the background. + +Defaults to `false`. + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`refetchIntervalInBackground`](QueryObserverOptions.md#refetchintervalinbackground) + +*** + +### refetchOnMount? + +```ts +optional refetchOnMount: boolean | "always" | (query) => boolean | "always"; +``` + +Defined in: [packages/query-core/src/types.ts:462](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L462) + +If set to `true`, the query will refetch on mount if the data is stale. +If set to `false`, will disable additional instances of a query to trigger background refetch. +If set to `'always'`, the query will always refetch on mount (except when `staleTime: 'static'` is used). +If set to a function, the function will be executed with the latest data and query to compute the value + +Defaults to `true`. + +#### Inherited from + +```ts +OmitKeyof.refetchOnMount +``` + +*** + +### refetchOnReconnect? + +```ts +optional refetchOnReconnect: boolean | "always" | (query) => boolean | "always"; +``` + +Defined in: [packages/query-core/src/types.ts:448](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L448) + +If set to `true`, the query will refetch on reconnect if the data is stale. +If set to `false`, the query will not refetch on reconnect. +If set to `'always'`, the query will always refetch on reconnect (except when `staleTime: 'static'` is used). +If set to a function, the function will be executed with the latest data and query to compute the value. + +Defaults to `true` unless `networkMode` is `'always'`. + +#### Inherited from + +```ts +OmitKeyof.refetchOnReconnect +``` + +*** + +### refetchOnWindowFocus? + +```ts +optional refetchOnWindowFocus: boolean | "always" | (query) => boolean | "always"; +``` + +Defined in: [packages/query-core/src/types.ts:434](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L434) + +If set to `true`, the query will refetch on window focus if the data is stale. +If set to `false`, the query will not refetch on window focus. +If set to `'always'`, the query will always refetch on window focus (except when `staleTime: 'static'` is used). +If set to a function, the function will be executed with the latest data and query to compute the value. + +Defaults to `true`. + +#### Inherited from + +```ts +OmitKeyof.refetchOnWindowFocus +``` + +*** + +### retry? + +```ts +optional retry: RetryValue; +``` + +Defined in: [packages/query-core/src/types.ts:246](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L246) + +If `false`, failed queries will not retry by default. +If `true`, failed queries will retry infinitely. +If set to an integer number, e.g. 3, failed queries will retry until the failed query count meets that number. +If set to a function `(failureCount, error) => boolean` failed queries will retry until the function returns false. + +Defaults to `3` on the client and `0` on the server. + +#### Inherited from + +```ts +OmitKeyof.retry +``` + +*** + +### retryDelay? + +```ts +optional retryDelay: RetryDelayValue; +``` + +Defined in: [packages/query-core/src/types.ts:258](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L258) + +This function receives a `retryAttempt` integer and the actual Error and returns the delay to apply before the +next attempt in milliseconds. + +A function like `attempt => Math.min(attempt > 1 ? 2 ** attempt * 1000 : 1000, 30 * 1000)` applies exponential +backoff. + +A function like `attempt => attempt * 1000` applies linear backoff. + +Defaults to a function that applies exponential backoff, capped at 30 seconds. + +#### Inherited from + +```ts +OmitKeyof.retryDelay +``` + +*** + +### retryOnMount? + +```ts +optional retryOnMount: QueryBooleanOption, TQueryKey>; +``` + +Defined in: [packages/query-core/src/types.ts:474](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L474) + +If set to `false`, the query will not be retried on mount if it contains an error. +If set to a function, the function will be executed with the query to compute the value. + +Defaults to `true`. + +#### Inherited from + +```ts +OmitKeyof.retryOnMount +``` + +*** + +### select()? + +```ts +optional select: (data) => TData; +``` + +Defined in: [packages/query-core/src/types.ts:500](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L500) + +This option can be used to transform or select a part of the data returned by the query function. It affects +the returned `data` value, but does not affect what gets stored in the query cache. +The `select` function will only run if `data` changed, or if the reference to the `select` function itself +changes. To optimize, memoize the function so its reference stays stable across calls. + +#### Parameters + +##### data + +[`InfiniteData`](InfiniteData.md) + +#### Returns + +`TData` + +#### Inherited from + +```ts +OmitKeyof.select +``` + +*** + +### staleTime? + +```ts +optional staleTime: StaleTimeFunction, TQueryKey>; +``` + +Defined in: [packages/query-core/src/types.ts:407](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L407) + +The time in milliseconds after data is considered stale. +If set to `Infinity`, the data will never be considered stale. +If set to `'static'`, the data will never be considered stale. +If set to a function, the function will be executed with the query to compute a `staleTime`. + +Defaults to `0`. + +#### Inherited from + +```ts +OmitKeyof.staleTime +``` + +*** + +### structuralSharing? + +```ts +optional structuralSharing: boolean | (oldData, newData) => unknown; +``` + +Defined in: [packages/query-core/src/types.ts:330](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L330) + +Set this to `false` to disable structural sharing between query results. +Set this to a function which accepts the old and new data and returns resolved data of the same type to implement custom structural sharing logic. + +Defaults to `true`. + +#### Inherited from + +```ts +OmitKeyof.structuralSharing +``` + +*** + ### subscribed? ```ts optional subscribed: boolean; ``` -Defined in: [preact-query/src/types.ts:258](https://github.com/TanStack/query/blob/main/packages/preact-query/src/types.ts#L258) +Defined in: [packages/preact-query/src/types.ts:258](https://github.com/TanStack/query/blob/main/packages/preact-query/src/types.ts#L258) Set this to `false` to unsubscribe this observer from updates to the query cache. diff --git a/docs/framework/preact/reference/interfaces/UseSuspenseQueryOptions.md b/docs/framework/preact/reference/interfaces/UseSuspenseQueryOptions.md index d3534bfb060..8cfbafbb5c6 100644 --- a/docs/framework/preact/reference/interfaces/UseSuspenseQueryOptions.md +++ b/docs/framework/preact/reference/interfaces/UseSuspenseQueryOptions.md @@ -3,7 +3,7 @@ id: UseSuspenseQueryOptions title: UseSuspenseQueryOptions --- -Defined in: [preact-query/src/types.ts:195](https://github.com/TanStack/query/blob/main/packages/preact-query/src/types.ts#L195) +Defined in: [packages/preact-query/src/types.ts:195](https://github.com/TanStack/query/blob/main/packages/preact-query/src/types.ts#L195) The options accepted by `useSuspenseQuery`. Same as [UseQueryOptions](UseQueryOptions.md), minus `enabled`, `throwOnError`, and `placeholderData` — Suspense hooks cannot render a "disabled" or "placeholder" state, so those options @@ -11,7 +11,7 @@ don't apply. ## Extends -- `OmitKeyof`\<[`UseQueryOptions`](UseQueryOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`\>, `"queryFn"` \| `"enabled"` \| `"throwOnError"` \| `"placeholderData"`\> +- [`OmitKeyof`](../type-aliases/OmitKeyof.md)\<[`UseQueryOptions`](UseQueryOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`\>, `"queryFn"` \| `"enabled"` \| `"throwOnError"` \| `"placeholderData"`\> ## Type Parameters @@ -23,7 +23,7 @@ The type your `queryFn` resolves to. ### TError -`TError` = `DefaultError` +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) The type of errors your `queryFn` may throw. @@ -36,32 +36,550 @@ The type `data` ends up as after `select` runs. Defaults to `TQueryFnData` when ### TQueryKey -`TQueryKey` *extends* `QueryKey` = `QueryKey` +`TQueryKey` *extends* [`QueryKey`](../type-aliases/QueryKey.md) = [`QueryKey`](../type-aliases/QueryKey.md) The type of your `queryKey`. ## Properties +### gcTime? + +```ts +optional gcTime: number; +``` + +Defined in: [packages/query-core/src/types.ts:277](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L277) + +The time in milliseconds that unused/inactive cache data remains in memory. +When a query's cache becomes unused or inactive, that cache data will be garbage collected after this duration. +When different garbage collection times are specified, the longest one will be used. +Setting it to `Infinity` will disable garbage collection. + +Defaults to `5 * 60 * 1000` (5 minutes), or `Infinity` during SSR. + +Note: the maximum allowed time is about 24 days, imposed by `setTimeout`'s 32-bit signed integer delay — see +`timeoutManager.setTimeoutProvider` for a workaround. + +#### Inherited from + +[`QueryOptions`](QueryOptions.md).[`gcTime`](QueryOptions.md#gctime) + +*** + +### initialData? + +```ts +optional initialData: + | TQueryFnData +| InitialDataFunction; +``` + +Defined in: [packages/query-core/src/types.ts:317](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L317) + +If set, this value will be used as the initial data for the query cache (as long as the query hasn't been +created or cached yet). +If set to a function, the function will be called **once** during the shared/root query initialization, and be +expected to synchronously return the initial data. +Initial data is considered stale by default unless a `staleTime` has been set. +`initialData` **is persisted** to the cache. + +#### Inherited from + +```ts +OmitKeyof.initialData +``` + +*** + +### initialDataUpdatedAt? + +```ts +optional initialDataUpdatedAt: number | () => number | undefined; +``` + +Defined in: [packages/query-core/src/types.ts:321](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L321) + +If set, this value will be used as the time (in milliseconds) of when the `initialData` itself was last updated. + +#### Inherited from + +```ts +OmitKeyof.initialDataUpdatedAt +``` + +*** + +### maxPages? + +```ts +optional maxPages: number; +``` + +Defined in: [packages/query-core/src/types.ts:345](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L345) + +Maximum number of pages to store in the data of an infinite query. + +#### Inherited from + +[`QueryOptions`](QueryOptions.md).[`maxPages`](QueryOptions.md#maxpages) + +*** + +### meta? + +```ts +optional meta: Record; +``` + +Defined in: [packages/query-core/src/types.ts:341](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L341) + +Additional payload to be stored on each query. +Use this property to pass information that can be used in other places. + +#### Inherited from + +[`QueryOptions`](QueryOptions.md).[`meta`](QueryOptions.md#meta) + +*** + +### networkMode? + +```ts +optional networkMode: NetworkMode; +``` + +Defined in: [packages/query-core/src/types.ts:265](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L265) + +Controls whether a query is allowed to run based on the current network connectivity. + +Defaults to `'online'`. + +#### See + +[Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. + +#### Inherited from + +[`QueryOptions`](QueryOptions.md).[`networkMode`](QueryOptions.md#networkmode) + +*** + +### notifyOnChangeProps? + +```ts +optional notifyOnChangeProps: NotifyOnChangeProps; +``` + +Defined in: [packages/query-core/src/types.ts:484](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L484) + +If set, the component will only re-render if any of the listed properties change. +When set to `['data', 'error']`, the component will only re-render when the `data` or `error` properties change. +When set to `'all'`, the component will re-render whenever a query is updated. +When set to a function, the function will be executed to compute the list of properties. + +Defaults to `undefined`, in which case property access is tracked automatically, and the +component only re-renders when one of the tracked properties changes. + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`notifyOnChangeProps`](QueryObserverOptions.md#notifyonchangeprops) + +*** + +### persister()? + +```ts +optional persister: (queryFn, context, query) => TQueryFnData | Promise; +``` + +Defined in: [packages/query-core/src/types.ts:290](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L290) + +This option can be used to persist the result of a query to an external storage, bypassing the need to actually +call the `queryFn`. Useful for persisting a query's data across e.g. server/client boundaries. + +#### Parameters + +##### queryFn + +[`QueryFunction`](../type-aliases/QueryFunction.md)\<`TQueryFnData`, `NoInfer`\<`TQueryKey`\>, `never`\> + +##### context + +###### client + +[`QueryClient`](../classes/QueryClient.md) + +###### direction? + +`unknown` + +**Deprecated** + +if you want access to the direction, you can add it to the pageParam + +###### meta + +`Record`\<`string`, `unknown`\> \| `undefined` + +###### pageParam? + +`unknown` + +###### queryKey + +`NoInfer`\<`TQueryKey`\> + +###### signal + +`AbortSignal` + +##### query + +[`Query`](../classes/Query.md) + +#### Returns + +`TQueryFnData` \| `Promise`\<`TQueryFnData`\> + +#### Inherited from + +```ts +OmitKeyof.persister +``` + +*** + ### queryFn? ```ts optional queryFn: QueryFunction; ``` -Defined in: [preact-query/src/types.ts:208](https://github.com/TanStack/query/blob/main/packages/preact-query/src/types.ts#L208) +Defined in: [packages/preact-query/src/types.ts:208](https://github.com/TanStack/query/blob/main/packages/preact-query/src/types.ts#L208) `skipToken` is not allowed here — Suspense hooks cannot render a "disabled" state, so a query function must always be provided, unless a default query function has been defined. *** +### queryHash? + +```ts +optional queryHash: string; +``` + +Defined in: [packages/query-core/src/types.ts:295](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L295) + +The hashed form of `queryKey`, computed with `queryKeyHashFn` (or the default hashing function otherwise). Used +as the actual cache key internally. + +#### Inherited from + +[`QueryOptions`](QueryOptions.md).[`queryHash`](QueryOptions.md#queryhash) + +*** + +### queryKey + +```ts +queryKey: TQueryKey & object; +``` + +Defined in: [packages/query-core/src/types.ts:304](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L304) + +The query key to use for this query. + +The query key will be hashed into a stable hash. See [Query Keys](https://tanstack.com/query/latest/docs/framework/react/guides/query-keys) +for more information. + +The query will automatically update when this key changes (as long as `enabled` is not set to `false`). + +#### Inherited from + +```ts +OmitKeyof.queryKey +``` + +*** + +### queryKeyHashFn? + +```ts +optional queryKeyHashFn: QueryKeyHashFunction; +``` + +Defined in: [packages/query-core/src/types.ts:308](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L308) + +If specified, this function is used to hash the `queryKey` to a string. + +#### Inherited from + +```ts +OmitKeyof.queryKeyHashFn +``` + +*** + +### refetchInterval? + +```ts +optional refetchInterval: number | false | (query) => number | false | undefined; +``` + +Defined in: [packages/query-core/src/types.ts:414](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L414) + +If set to a number, the query will continuously refetch at this frequency in milliseconds. +If set to a function, the function will be executed with the latest data and query to compute a frequency + +Defaults to `false`. + +#### Inherited from + +```ts +OmitKeyof.refetchInterval +``` + +*** + +### refetchIntervalInBackground? + +```ts +optional refetchIntervalInBackground: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:425](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L425) + +If set to `true`, the query will continue to refetch while their tab/window is in the background. + +Defaults to `false`. + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`refetchIntervalInBackground`](QueryObserverOptions.md#refetchintervalinbackground) + +*** + +### refetchOnMount? + +```ts +optional refetchOnMount: boolean | "always" | (query) => boolean | "always"; +``` + +Defined in: [packages/query-core/src/types.ts:462](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L462) + +If set to `true`, the query will refetch on mount if the data is stale. +If set to `false`, will disable additional instances of a query to trigger background refetch. +If set to `'always'`, the query will always refetch on mount (except when `staleTime: 'static'` is used). +If set to a function, the function will be executed with the latest data and query to compute the value + +Defaults to `true`. + +#### Inherited from + +```ts +OmitKeyof.refetchOnMount +``` + +*** + +### refetchOnReconnect? + +```ts +optional refetchOnReconnect: boolean | "always" | (query) => boolean | "always"; +``` + +Defined in: [packages/query-core/src/types.ts:448](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L448) + +If set to `true`, the query will refetch on reconnect if the data is stale. +If set to `false`, the query will not refetch on reconnect. +If set to `'always'`, the query will always refetch on reconnect (except when `staleTime: 'static'` is used). +If set to a function, the function will be executed with the latest data and query to compute the value. + +Defaults to `true` unless `networkMode` is `'always'`. + +#### Inherited from + +```ts +OmitKeyof.refetchOnReconnect +``` + +*** + +### refetchOnWindowFocus? + +```ts +optional refetchOnWindowFocus: boolean | "always" | (query) => boolean | "always"; +``` + +Defined in: [packages/query-core/src/types.ts:434](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L434) + +If set to `true`, the query will refetch on window focus if the data is stale. +If set to `false`, the query will not refetch on window focus. +If set to `'always'`, the query will always refetch on window focus (except when `staleTime: 'static'` is used). +If set to a function, the function will be executed with the latest data and query to compute the value. + +Defaults to `true`. + +#### Inherited from + +```ts +OmitKeyof.refetchOnWindowFocus +``` + +*** + +### retry? + +```ts +optional retry: RetryValue; +``` + +Defined in: [packages/query-core/src/types.ts:246](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L246) + +If `false`, failed queries will not retry by default. +If `true`, failed queries will retry infinitely. +If set to an integer number, e.g. 3, failed queries will retry until the failed query count meets that number. +If set to a function `(failureCount, error) => boolean` failed queries will retry until the function returns false. + +Defaults to `3` on the client and `0` on the server. + +#### Inherited from + +```ts +OmitKeyof.retry +``` + +*** + +### retryDelay? + +```ts +optional retryDelay: RetryDelayValue; +``` + +Defined in: [packages/query-core/src/types.ts:258](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L258) + +This function receives a `retryAttempt` integer and the actual Error and returns the delay to apply before the +next attempt in milliseconds. + +A function like `attempt => Math.min(attempt > 1 ? 2 ** attempt * 1000 : 1000, 30 * 1000)` applies exponential +backoff. + +A function like `attempt => attempt * 1000` applies linear backoff. + +Defaults to a function that applies exponential backoff, capped at 30 seconds. + +#### Inherited from + +```ts +OmitKeyof.retryDelay +``` + +*** + +### retryOnMount? + +```ts +optional retryOnMount: QueryBooleanOption; +``` + +Defined in: [packages/query-core/src/types.ts:474](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L474) + +If set to `false`, the query will not be retried on mount if it contains an error. +If set to a function, the function will be executed with the query to compute the value. + +Defaults to `true`. + +#### Inherited from + +```ts +OmitKeyof.retryOnMount +``` + +*** + +### select()? + +```ts +optional select: (data) => TData; +``` + +Defined in: [packages/query-core/src/types.ts:500](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L500) + +This option can be used to transform or select a part of the data returned by the query function. It affects +the returned `data` value, but does not affect what gets stored in the query cache. +The `select` function will only run if `data` changed, or if the reference to the `select` function itself +changes. To optimize, memoize the function so its reference stays stable across calls. + +#### Parameters + +##### data + +`TQueryFnData` + +#### Returns + +`TData` + +#### Inherited from + +```ts +OmitKeyof.select +``` + +*** + +### staleTime? + +```ts +optional staleTime: StaleTimeFunction; +``` + +Defined in: [packages/query-core/src/types.ts:407](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L407) + +The time in milliseconds after data is considered stale. +If set to `Infinity`, the data will never be considered stale. +If set to `'static'`, the data will never be considered stale. +If set to a function, the function will be executed with the query to compute a `staleTime`. + +Defaults to `0`. + +#### Inherited from + +```ts +OmitKeyof.staleTime +``` + +*** + +### structuralSharing? + +```ts +optional structuralSharing: boolean | (oldData, newData) => unknown; +``` + +Defined in: [packages/query-core/src/types.ts:330](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L330) + +Set this to `false` to disable structural sharing between query results. +Set this to a function which accepts the old and new data and returns resolved data of the same type to implement custom structural sharing logic. + +Defaults to `true`. + +#### Inherited from + +```ts +OmitKeyof.structuralSharing +``` + +*** + ### subscribed? ```ts optional subscribed: boolean; ``` -Defined in: [preact-query/src/types.ts:64](https://github.com/TanStack/query/blob/main/packages/preact-query/src/types.ts#L64) +Defined in: [packages/preact-query/src/types.ts:64](https://github.com/TanStack/query/blob/main/packages/preact-query/src/types.ts#L64) Set this to `false` to unsubscribe this observer from updates to the query cache. diff --git a/docs/framework/preact/reference/type-aliases/AnyDataTag.md b/docs/framework/preact/reference/type-aliases/AnyDataTag.md new file mode 100644 index 00000000000..d3d5e33bb3e --- /dev/null +++ b/docs/framework/preact/reference/type-aliases/AnyDataTag.md @@ -0,0 +1,30 @@ +--- +id: AnyDataTag +title: AnyDataTag +--- + +```ts +type AnyDataTag = object; +``` + +Defined in: [packages/query-core/src/types.ts:67](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L67) + +## Properties + +### \[dataTagErrorSymbol\] + +```ts +[dataTagErrorSymbol]: any; +``` + +Defined in: [packages/query-core/src/types.ts:69](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L69) + +*** + +### \[dataTagSymbol\] + +```ts +[dataTagSymbol]: any; +``` + +Defined in: [packages/query-core/src/types.ts:68](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L68) diff --git a/docs/framework/preact/reference/type-aliases/AnyUseBaseQueryOptions.md b/docs/framework/preact/reference/type-aliases/AnyUseBaseQueryOptions.md index a0afa87f3e1..0f9329e5a86 100644 --- a/docs/framework/preact/reference/type-aliases/AnyUseBaseQueryOptions.md +++ b/docs/framework/preact/reference/type-aliases/AnyUseBaseQueryOptions.md @@ -7,7 +7,7 @@ title: AnyUseBaseQueryOptions type AnyUseBaseQueryOptions = UseBaseQueryOptions; ``` -Defined in: [preact-query/src/types.ts:27](https://github.com/TanStack/query/blob/main/packages/preact-query/src/types.ts#L27) +Defined in: [packages/preact-query/src/types.ts:27](https://github.com/TanStack/query/blob/main/packages/preact-query/src/types.ts#L27) [UseBaseQueryOptions](../interfaces/UseBaseQueryOptions.md) with all type parameters set to `any`, useful when the specific types aren't relevant, e.g. when accepting options for any query in a helper function. diff --git a/docs/framework/preact/reference/type-aliases/AnyUseInfiniteQueryOptions.md b/docs/framework/preact/reference/type-aliases/AnyUseInfiniteQueryOptions.md index 64a50dc5b0b..5d76b7c671d 100644 --- a/docs/framework/preact/reference/type-aliases/AnyUseInfiniteQueryOptions.md +++ b/docs/framework/preact/reference/type-aliases/AnyUseInfiniteQueryOptions.md @@ -7,7 +7,7 @@ title: AnyUseInfiniteQueryOptions type AnyUseInfiniteQueryOptions = UseInfiniteQueryOptions; ``` -Defined in: [preact-query/src/types.ts:218](https://github.com/TanStack/query/blob/main/packages/preact-query/src/types.ts#L218) +Defined in: [packages/preact-query/src/types.ts:218](https://github.com/TanStack/query/blob/main/packages/preact-query/src/types.ts#L218) [UseInfiniteQueryOptions](../interfaces/UseInfiniteQueryOptions.md) with all type parameters set to `any`, useful when the specific types aren't relevant, e.g. when accepting options for any query in a helper function. diff --git a/docs/framework/preact/reference/type-aliases/AnyUseMutationOptions.md b/docs/framework/preact/reference/type-aliases/AnyUseMutationOptions.md index d0f9eb8c2e4..7afacd10bc7 100644 --- a/docs/framework/preact/reference/type-aliases/AnyUseMutationOptions.md +++ b/docs/framework/preact/reference/type-aliases/AnyUseMutationOptions.md @@ -7,7 +7,7 @@ title: AnyUseMutationOptions type AnyUseMutationOptions = UseMutationOptions; ``` -Defined in: [preact-query/src/types.ts:400](https://github.com/TanStack/query/blob/main/packages/preact-query/src/types.ts#L400) +Defined in: [packages/preact-query/src/types.ts:400](https://github.com/TanStack/query/blob/main/packages/preact-query/src/types.ts#L400) [UseMutationOptions](../interfaces/UseMutationOptions.md) with all type parameters set to `any`, useful when the specific types aren't relevant, e.g. when accepting options for any mutation in a helper function. diff --git a/docs/framework/preact/reference/type-aliases/AnyUseQueryOptions.md b/docs/framework/preact/reference/type-aliases/AnyUseQueryOptions.md index ebc8ca98c68..bf120153f81 100644 --- a/docs/framework/preact/reference/type-aliases/AnyUseQueryOptions.md +++ b/docs/framework/preact/reference/type-aliases/AnyUseQueryOptions.md @@ -7,7 +7,7 @@ title: AnyUseQueryOptions type AnyUseQueryOptions = UseQueryOptions; ``` -Defined in: [preact-query/src/types.ts:153](https://github.com/TanStack/query/blob/main/packages/preact-query/src/types.ts#L153) +Defined in: [packages/preact-query/src/types.ts:153](https://github.com/TanStack/query/blob/main/packages/preact-query/src/types.ts#L153) [UseQueryOptions](../interfaces/UseQueryOptions.md) with all type parameters set to `any`, useful when the specific types aren't relevant, e.g. when accepting options for any query in a helper function. diff --git a/docs/framework/preact/reference/type-aliases/AnyUseSuspenseInfiniteQueryOptions.md b/docs/framework/preact/reference/type-aliases/AnyUseSuspenseInfiniteQueryOptions.md index 61db42561ae..92b60ec7591 100644 --- a/docs/framework/preact/reference/type-aliases/AnyUseSuspenseInfiniteQueryOptions.md +++ b/docs/framework/preact/reference/type-aliases/AnyUseSuspenseInfiniteQueryOptions.md @@ -7,7 +7,7 @@ title: AnyUseSuspenseInfiniteQueryOptions type AnyUseSuspenseInfiniteQueryOptions = UseSuspenseInfiniteQueryOptions; ``` -Defined in: [preact-query/src/types.ts:265](https://github.com/TanStack/query/blob/main/packages/preact-query/src/types.ts#L265) +Defined in: [packages/preact-query/src/types.ts:265](https://github.com/TanStack/query/blob/main/packages/preact-query/src/types.ts#L265) [UseSuspenseInfiniteQueryOptions](../interfaces/UseSuspenseInfiniteQueryOptions.md) with all type parameters set to `any`, useful when the specific types aren't relevant, e.g. when accepting options for any query in a helper function. diff --git a/docs/framework/preact/reference/type-aliases/AnyUseSuspenseQueryOptions.md b/docs/framework/preact/reference/type-aliases/AnyUseSuspenseQueryOptions.md index 017114a5290..6bf0ce0703b 100644 --- a/docs/framework/preact/reference/type-aliases/AnyUseSuspenseQueryOptions.md +++ b/docs/framework/preact/reference/type-aliases/AnyUseSuspenseQueryOptions.md @@ -7,7 +7,7 @@ title: AnyUseSuspenseQueryOptions type AnyUseSuspenseQueryOptions = UseSuspenseQueryOptions; ``` -Defined in: [preact-query/src/types.ts:178](https://github.com/TanStack/query/blob/main/packages/preact-query/src/types.ts#L178) +Defined in: [packages/preact-query/src/types.ts:178](https://github.com/TanStack/query/blob/main/packages/preact-query/src/types.ts#L178) [UseSuspenseQueryOptions](../interfaces/UseSuspenseQueryOptions.md) with all type parameters set to `any`, useful when the specific types aren't relevant, e.g. when accepting options for any query in a helper function. diff --git a/docs/framework/preact/reference/type-aliases/DataTag.md b/docs/framework/preact/reference/type-aliases/DataTag.md new file mode 100644 index 00000000000..904ca124464 --- /dev/null +++ b/docs/framework/preact/reference/type-aliases/DataTag.md @@ -0,0 +1,24 @@ +--- +id: DataTag +title: DataTag +--- + +```ts +type DataTag = TType extends AnyDataTag ? TType : TType & object; +``` + +Defined in: [packages/query-core/src/types.ts:71](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L71) + +## Type Parameters + +### TType + +`TType` + +### TValue + +`TValue` + +### TError + +`TError` = [`UnsetMarker`](UnsetMarker.md) diff --git a/docs/framework/preact/reference/type-aliases/DefaultError.md b/docs/framework/preact/reference/type-aliases/DefaultError.md new file mode 100644 index 00000000000..da9f615482f --- /dev/null +++ b/docs/framework/preact/reference/type-aliases/DefaultError.md @@ -0,0 +1,10 @@ +--- +id: DefaultError +title: DefaultError +--- + +```ts +type DefaultError = Register extends object ? TError : Error; +``` + +Defined in: [packages/query-core/src/types.ts:45](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L45) diff --git a/docs/framework/preact/reference/type-aliases/DefaultedInfiniteQueryObserverOptions.md b/docs/framework/preact/reference/type-aliases/DefaultedInfiniteQueryObserverOptions.md new file mode 100644 index 00000000000..82c7ddbb886 --- /dev/null +++ b/docs/framework/preact/reference/type-aliases/DefaultedInfiniteQueryObserverOptions.md @@ -0,0 +1,32 @@ +--- +id: DefaultedInfiniteQueryObserverOptions +title: DefaultedInfiniteQueryObserverOptions +--- + +```ts +type DefaultedInfiniteQueryObserverOptions = WithRequired, "throwOnError" | "refetchOnReconnect" | "queryHash">; +``` + +Defined in: [packages/query-core/src/types.ts:557](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L557) + +## Type Parameters + +### TQueryFnData + +`TQueryFnData` = `unknown` + +### TError + +`TError` = [`DefaultError`](DefaultError.md) + +### TData + +`TData` = `TQueryFnData` + +### TQueryKey + +`TQueryKey` *extends* [`QueryKey`](QueryKey.md) = [`QueryKey`](QueryKey.md) + +### TPageParam + +`TPageParam` = `unknown` diff --git a/docs/framework/preact/reference/type-aliases/DefaultedQueryObserverOptions.md b/docs/framework/preact/reference/type-aliases/DefaultedQueryObserverOptions.md new file mode 100644 index 00000000000..7687d8c24f6 --- /dev/null +++ b/docs/framework/preact/reference/type-aliases/DefaultedQueryObserverOptions.md @@ -0,0 +1,32 @@ +--- +id: DefaultedQueryObserverOptions +title: DefaultedQueryObserverOptions +--- + +```ts +type DefaultedQueryObserverOptions = WithRequired, "throwOnError" | "refetchOnReconnect" | "queryHash">; +``` + +Defined in: [packages/query-core/src/types.ts:528](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L528) + +## Type Parameters + +### TQueryFnData + +`TQueryFnData` = `unknown` + +### TError + +`TError` = [`DefaultError`](DefaultError.md) + +### TData + +`TData` = `TQueryFnData` + +### TQueryData + +`TQueryData` = `TQueryFnData` + +### TQueryKey + +`TQueryKey` *extends* [`QueryKey`](QueryKey.md) = [`QueryKey`](QueryKey.md) diff --git a/docs/framework/preact/reference/type-aliases/DefinedInfiniteQueryObserverResult.md b/docs/framework/preact/reference/type-aliases/DefinedInfiniteQueryObserverResult.md new file mode 100644 index 00000000000..38dac7cfe2b --- /dev/null +++ b/docs/framework/preact/reference/type-aliases/DefinedInfiniteQueryObserverResult.md @@ -0,0 +1,22 @@ +--- +id: DefinedInfiniteQueryObserverResult +title: DefinedInfiniteQueryObserverResult +--- + +```ts +type DefinedInfiniteQueryObserverResult = + | InfiniteQueryObserverRefetchErrorResult +| InfiniteQueryObserverSuccessResult; +``` + +Defined in: [packages/query-core/src/types.ts:1148](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1148) + +## Type Parameters + +### TData + +`TData` = `unknown` + +### TError + +`TError` = [`DefaultError`](DefaultError.md) diff --git a/docs/framework/preact/reference/type-aliases/DefinedInitialDataInfiniteOptions.md b/docs/framework/preact/reference/type-aliases/DefinedInitialDataInfiniteOptions.md index 6847a19a143..51b78d85c96 100644 --- a/docs/framework/preact/reference/type-aliases/DefinedInitialDataInfiniteOptions.md +++ b/docs/framework/preact/reference/type-aliases/DefinedInitialDataInfiniteOptions.md @@ -7,7 +7,7 @@ title: DefinedInitialDataInfiniteOptions type DefinedInitialDataInfiniteOptions = UseInfiniteQueryOptions & object; ``` -Defined in: [preact-query/src/infiniteQueryOptions.ts:104](https://github.com/TanStack/query/blob/main/packages/preact-query/src/infiniteQueryOptions.ts#L104) +Defined in: [packages/preact-query/src/infiniteQueryOptions.ts:104](https://github.com/TanStack/query/blob/main/packages/preact-query/src/infiniteQueryOptions.ts#L104) The options accepted by the `infiniteQueryOptions` overload selected when `initialData` is set — `data` is never `undefined`. @@ -39,20 +39,20 @@ The type of a single page, as your `queryFn` resolves it. ### TError -`TError` = `DefaultError` +`TError` = [`DefaultError`](DefaultError.md) The type of errors your `queryFn` may throw. ### TData -`TData` = `InfiniteData`\<`TQueryFnData`\> +`TData` = [`InfiniteData`](../interfaces/InfiniteData.md)\<`TQueryFnData`\> The type `data` ends up as after `select` runs — defaults to `InfiniteData`, the shape of all fetched pages plus their page params. ### TQueryKey -`TQueryKey` *extends* `QueryKey` = `QueryKey` +`TQueryKey` *extends* [`QueryKey`](QueryKey.md) = [`QueryKey`](QueryKey.md) The type of your `queryKey`. diff --git a/docs/framework/preact/reference/type-aliases/DefinedInitialDataOptions.md b/docs/framework/preact/reference/type-aliases/DefinedInitialDataOptions.md index e365ec00646..5187c08ab47 100644 --- a/docs/framework/preact/reference/type-aliases/DefinedInitialDataOptions.md +++ b/docs/framework/preact/reference/type-aliases/DefinedInitialDataOptions.md @@ -7,7 +7,7 @@ title: DefinedInitialDataOptions type DefinedInitialDataOptions = Omit, "queryFn"> & object; ``` -Defined in: [preact-query/src/queryOptions.ts:81](https://github.com/TanStack/query/blob/main/packages/preact-query/src/queryOptions.ts#L81) +Defined in: [packages/preact-query/src/queryOptions.ts:81](https://github.com/TanStack/query/blob/main/packages/preact-query/src/queryOptions.ts#L81) The options accepted by the `queryOptions` overload selected when `initialData` is set — `data` is never `undefined`. @@ -48,7 +48,7 @@ The type your `queryFn` resolves to. ### TError -`TError` = `DefaultError` +`TError` = [`DefaultError`](DefaultError.md) The type of errors your `queryFn` may throw. @@ -60,6 +60,6 @@ The type `data` ends up as after `select` runs. ### TQueryKey -`TQueryKey` *extends* `QueryKey` = `QueryKey` +`TQueryKey` *extends* [`QueryKey`](QueryKey.md) = [`QueryKey`](QueryKey.md) The type of your `queryKey`. diff --git a/docs/framework/preact/reference/type-aliases/DefinedQueryObserverResult.md b/docs/framework/preact/reference/type-aliases/DefinedQueryObserverResult.md new file mode 100644 index 00000000000..ae77ddcc22d --- /dev/null +++ b/docs/framework/preact/reference/type-aliases/DefinedQueryObserverResult.md @@ -0,0 +1,22 @@ +--- +id: DefinedQueryObserverResult +title: DefinedQueryObserverResult +--- + +```ts +type DefinedQueryObserverResult = + | QueryObserverRefetchErrorResult +| QueryObserverSuccessResult; +``` + +Defined in: [packages/query-core/src/types.ts:987](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L987) + +## Type Parameters + +### TData + +`TData` = `unknown` + +### TError + +`TError` = [`DefaultError`](DefaultError.md) diff --git a/docs/framework/preact/reference/type-aliases/DefinedUseInfiniteQueryResult.md b/docs/framework/preact/reference/type-aliases/DefinedUseInfiniteQueryResult.md index 93ed3177ecf..6c97c2285aa 100644 --- a/docs/framework/preact/reference/type-aliases/DefinedUseInfiniteQueryResult.md +++ b/docs/framework/preact/reference/type-aliases/DefinedUseInfiniteQueryResult.md @@ -7,10 +7,10 @@ title: DefinedUseInfiniteQueryResult type DefinedUseInfiniteQueryResult = DefinedInfiniteQueryObserverResult; ``` -Defined in: [preact-query/src/types.ts:376](https://github.com/TanStack/query/blob/main/packages/preact-query/src/types.ts#L376) +Defined in: [packages/preact-query/src/types.ts:376](https://github.com/TanStack/query/blob/main/packages/preact-query/src/types.ts#L376) The result of `useInfiniteQuery` when `initialData` is set — `data` is never `undefined`. Re-exports -DefinedInfiniteQueryObserverResult from `@tanstack/query-core`. +[DefinedInfiniteQueryObserverResult](DefinedInfiniteQueryObserverResult.md) from `@tanstack/query-core`. ## Type Parameters @@ -22,6 +22,6 @@ The type `data` ends up as after `select` runs. ### TError -`TError` = `DefaultError` +`TError` = [`DefaultError`](DefaultError.md) The type of errors your `queryFn` may throw. diff --git a/docs/framework/preact/reference/type-aliases/DefinedUseQueryResult.md b/docs/framework/preact/reference/type-aliases/DefinedUseQueryResult.md index c467e0dca24..4f9f9fdfb25 100644 --- a/docs/framework/preact/reference/type-aliases/DefinedUseQueryResult.md +++ b/docs/framework/preact/reference/type-aliases/DefinedUseQueryResult.md @@ -7,10 +7,10 @@ title: DefinedUseQueryResult type DefinedUseQueryResult = DefinedQueryObserverResult; ``` -Defined in: [preact-query/src/types.ts:352](https://github.com/TanStack/query/blob/main/packages/preact-query/src/types.ts#L352) +Defined in: [packages/preact-query/src/types.ts:352](https://github.com/TanStack/query/blob/main/packages/preact-query/src/types.ts#L352) The result of `useQuery` when `initialData` is set, or of `useSuspenseQuery` before the `isPlaceholderData` -omission — `data` is never `undefined`. Re-exports DefinedQueryObserverResult from +omission — `data` is never `undefined`. Re-exports [DefinedQueryObserverResult](DefinedQueryObserverResult.md) from `@tanstack/query-core`. ## Type Parameters @@ -23,6 +23,6 @@ The type `data` ends up as after `select` runs. ### TError -`TError` = `DefaultError` +`TError` = [`DefaultError`](DefaultError.md) The type of errors your `queryFn` may throw. diff --git a/docs/framework/preact/reference/type-aliases/DistributiveOmit.md b/docs/framework/preact/reference/type-aliases/DistributiveOmit.md new file mode 100644 index 00000000000..33b87a5cd6e --- /dev/null +++ b/docs/framework/preact/reference/type-aliases/DistributiveOmit.md @@ -0,0 +1,20 @@ +--- +id: DistributiveOmit +title: DistributiveOmit +--- + +```ts +type DistributiveOmit = TObject extends any ? Omit : never; +``` + +Defined in: [packages/query-core/src/types.ts:14](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L14) + +## Type Parameters + +### TObject + +`TObject` + +### TKey + +`TKey` *extends* keyof `TObject` diff --git a/docs/framework/preact/reference/type-aliases/EnsureInfiniteQueryDataOptions.md b/docs/framework/preact/reference/type-aliases/EnsureInfiniteQueryDataOptions.md new file mode 100644 index 00000000000..7648331fca2 --- /dev/null +++ b/docs/framework/preact/reference/type-aliases/EnsureInfiniteQueryDataOptions.md @@ -0,0 +1,42 @@ +--- +id: EnsureInfiniteQueryDataOptions +title: EnsureInfiniteQueryDataOptions +--- + +```ts +type EnsureInfiniteQueryDataOptions = FetchInfiniteQueryOptions & object; +``` + +Defined in: [packages/query-core/src/types.ts:631](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L631) + +## Type Declaration + +### ~~revalidateIfStale?~~ + +```ts +optional revalidateIfStale: boolean; +``` + +## Type Parameters + +### TQueryFnData + +`TQueryFnData` = `unknown` + +### TError + +`TError` = [`DefaultError`](DefaultError.md) + +### TData + +`TData` = `TQueryFnData` + +### TQueryKey + +`TQueryKey` *extends* [`QueryKey`](QueryKey.md) = [`QueryKey`](QueryKey.md) + +### TPageParam + +`TPageParam` = `unknown` + +## Deprecated diff --git a/docs/framework/preact/reference/type-aliases/FetchInfiniteQueryOptions.md b/docs/framework/preact/reference/type-aliases/FetchInfiniteQueryOptions.md new file mode 100644 index 00000000000..d00a2455889 --- /dev/null +++ b/docs/framework/preact/reference/type-aliases/FetchInfiniteQueryOptions.md @@ -0,0 +1,34 @@ +--- +id: FetchInfiniteQueryOptions +title: FetchInfiniteQueryOptions +--- + +```ts +type FetchInfiniteQueryOptions = Omit, TQueryKey, TPageParam>, "initialPageParam"> & InitialPageParam & InfiniteQueryPages; +``` + +Defined in: [packages/query-core/src/types.ts:675](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L675) + +## Type Parameters + +### TQueryFnData + +`TQueryFnData` = `unknown` + +### TError + +`TError` = [`DefaultError`](DefaultError.md) + +### TData + +`TData` = `TQueryFnData` + +### TQueryKey + +`TQueryKey` *extends* [`QueryKey`](QueryKey.md) = [`QueryKey`](QueryKey.md) + +### TPageParam + +`TPageParam` = `unknown` + +## Deprecated diff --git a/docs/framework/preact/reference/type-aliases/FetchStatus.md b/docs/framework/preact/reference/type-aliases/FetchStatus.md new file mode 100644 index 00000000000..d50002355ca --- /dev/null +++ b/docs/framework/preact/reference/type-aliases/FetchStatus.md @@ -0,0 +1,10 @@ +--- +id: FetchStatus +title: FetchStatus +--- + +```ts +type FetchStatus = "fetching" | "paused" | "idle"; +``` + +Defined in: [packages/query-core/src/types.ts:762](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L762) diff --git a/docs/framework/preact/reference/type-aliases/GetNextPageParamFunction.md b/docs/framework/preact/reference/type-aliases/GetNextPageParamFunction.md new file mode 100644 index 00000000000..81d1a1544ab --- /dev/null +++ b/docs/framework/preact/reference/type-aliases/GetNextPageParamFunction.md @@ -0,0 +1,42 @@ +--- +id: GetNextPageParamFunction +title: GetNextPageParamFunction +--- + +```ts +type GetNextPageParamFunction = (lastPage, allPages, lastPageParam, allPageParams) => TPageParam | undefined | null; +``` + +Defined in: [packages/query-core/src/types.ts:203](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L203) + +## Type Parameters + +### TPageParam + +`TPageParam` + +### TQueryFnData + +`TQueryFnData` = `unknown` + +## Parameters + +### lastPage + +`TQueryFnData` + +### allPages + +`TQueryFnData`[] + +### lastPageParam + +`TPageParam` + +### allPageParams + +`TPageParam`[] + +## Returns + +`TPageParam` \| `undefined` \| `null` diff --git a/docs/framework/preact/reference/type-aliases/GetPreviousPageParamFunction.md b/docs/framework/preact/reference/type-aliases/GetPreviousPageParamFunction.md new file mode 100644 index 00000000000..5a6d9b93d7e --- /dev/null +++ b/docs/framework/preact/reference/type-aliases/GetPreviousPageParamFunction.md @@ -0,0 +1,42 @@ +--- +id: GetPreviousPageParamFunction +title: GetPreviousPageParamFunction +--- + +```ts +type GetPreviousPageParamFunction = (firstPage, allPages, firstPageParam, allPageParams) => TPageParam | undefined | null; +``` + +Defined in: [packages/query-core/src/types.ts:196](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L196) + +## Type Parameters + +### TPageParam + +`TPageParam` + +### TQueryFnData + +`TQueryFnData` = `unknown` + +## Parameters + +### firstPage + +`TQueryFnData` + +### allPages + +`TQueryFnData`[] + +### firstPageParam + +`TPageParam` + +### allPageParams + +`TPageParam`[] + +## Returns + +`TPageParam` \| `undefined` \| `null` diff --git a/docs/framework/preact/reference/type-aliases/InferDataFromTag.md b/docs/framework/preact/reference/type-aliases/InferDataFromTag.md new file mode 100644 index 00000000000..09a15ca4b1c --- /dev/null +++ b/docs/framework/preact/reference/type-aliases/InferDataFromTag.md @@ -0,0 +1,20 @@ +--- +id: InferDataFromTag +title: InferDataFromTag +--- + +```ts +type InferDataFromTag = TTaggedQueryKey extends DataTag ? TaggedValue : TQueryFnData; +``` + +Defined in: [packages/query-core/src/types.ts:90](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L90) + +## Type Parameters + +### TQueryFnData + +`TQueryFnData` + +### TTaggedQueryKey + +`TTaggedQueryKey` *extends* [`QueryKey`](QueryKey.md) diff --git a/docs/framework/preact/reference/type-aliases/InferErrorFromTag.md b/docs/framework/preact/reference/type-aliases/InferErrorFromTag.md new file mode 100644 index 00000000000..cd94e4b5c3f --- /dev/null +++ b/docs/framework/preact/reference/type-aliases/InferErrorFromTag.md @@ -0,0 +1,20 @@ +--- +id: InferErrorFromTag +title: InferErrorFromTag +--- + +```ts +type InferErrorFromTag = TTaggedQueryKey extends DataTag ? TaggedError extends UnsetMarker ? TError : TaggedError : TError; +``` + +Defined in: [packages/query-core/src/types.ts:95](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L95) + +## Type Parameters + +### TError + +`TError` + +### TTaggedQueryKey + +`TTaggedQueryKey` *extends* [`QueryKey`](QueryKey.md) diff --git a/docs/framework/preact/reference/type-aliases/InfiniteQueryExecuteOptions.md b/docs/framework/preact/reference/type-aliases/InfiniteQueryExecuteOptions.md new file mode 100644 index 00000000000..259c97c96bb --- /dev/null +++ b/docs/framework/preact/reference/type-aliases/InfiniteQueryExecuteOptions.md @@ -0,0 +1,32 @@ +--- +id: InfiniteQueryExecuteOptions +title: InfiniteQueryExecuteOptions +--- + +```ts +type InfiniteQueryExecuteOptions = Omit, TQueryKey, TPageParam>, "initialPageParam"> & InitialPageParam & InfiniteQueryPages; +``` + +Defined in: [packages/query-core/src/types.ts:654](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L654) + +## Type Parameters + +### TQueryFnData + +`TQueryFnData` = `unknown` + +### TError + +`TError` = [`DefaultError`](DefaultError.md) + +### TData + +`TData` = [`InfiniteData`](../interfaces/InfiniteData.md)\<`TQueryFnData`\> + +### TQueryKey + +`TQueryKey` *extends* [`QueryKey`](QueryKey.md) = [`QueryKey`](QueryKey.md) + +### TPageParam + +`TPageParam` = `unknown` diff --git a/docs/framework/preact/reference/type-aliases/InfiniteQueryObserverResult.md b/docs/framework/preact/reference/type-aliases/InfiniteQueryObserverResult.md new file mode 100644 index 00000000000..aa27563b9cd --- /dev/null +++ b/docs/framework/preact/reference/type-aliases/InfiniteQueryObserverResult.md @@ -0,0 +1,25 @@ +--- +id: InfiniteQueryObserverResult +title: InfiniteQueryObserverResult +--- + +```ts +type InfiniteQueryObserverResult = + | DefinedInfiniteQueryObserverResult + | InfiniteQueryObserverLoadingErrorResult + | InfiniteQueryObserverLoadingResult + | InfiniteQueryObserverPendingResult +| InfiniteQueryObserverPlaceholderResult; +``` + +Defined in: [packages/query-core/src/types.ts:1155](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1155) + +## Type Parameters + +### TData + +`TData` = `unknown` + +### TError + +`TError` = [`DefaultError`](DefaultError.md) diff --git a/docs/framework/preact/reference/type-aliases/InitialDataFunction.md b/docs/framework/preact/reference/type-aliases/InitialDataFunction.md new file mode 100644 index 00000000000..6ba4aaabe61 --- /dev/null +++ b/docs/framework/preact/reference/type-aliases/InitialDataFunction.md @@ -0,0 +1,20 @@ +--- +id: InitialDataFunction +title: InitialDataFunction +--- + +```ts +type InitialDataFunction = () => T | undefined; +``` + +Defined in: [packages/query-core/src/types.ts:173](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L173) + +## Type Parameters + +### T + +`T` + +## Returns + +`T` \| `undefined` diff --git a/docs/framework/preact/reference/type-aliases/ManagedTimerId.md b/docs/framework/preact/reference/type-aliases/ManagedTimerId.md new file mode 100644 index 00000000000..d7833e3e4f0 --- /dev/null +++ b/docs/framework/preact/reference/type-aliases/ManagedTimerId.md @@ -0,0 +1,19 @@ +--- +id: ManagedTimerId +title: ManagedTimerId +--- + +```ts +type ManagedTimerId = + | number + | { + [toPrimitive]: () => number; +}; +``` + +Defined in: [packages/query-core/src/timeoutManager.ts:17](https://github.com/TanStack/query/blob/main/packages/query-core/src/timeoutManager.ts#L17) + +Wrapping `setTimeout` is awkward from a typing perspective because platform +typings may extend the return type of `setTimeout`. For example, NodeJS +typings add `NodeJS.Timeout`; but a non-default `timeoutManager` may not be +able to return such a type. diff --git a/docs/framework/preact/reference/type-aliases/MutateFunction.md b/docs/framework/preact/reference/type-aliases/MutateFunction.md new file mode 100644 index 00000000000..e12b7a80291 --- /dev/null +++ b/docs/framework/preact/reference/type-aliases/MutateFunction.md @@ -0,0 +1,38 @@ +--- +id: MutateFunction +title: MutateFunction +--- + +```ts +type MutateFunction = (...rest) => Promise; +``` + +Defined in: [packages/query-core/src/types.ts:1326](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1326) + +## Type Parameters + +### TData + +`TData` = `unknown` + +### TError + +`TError` = [`DefaultError`](DefaultError.md) + +### TVariables + +`TVariables` = `void` + +### TOnMutateResult + +`TOnMutateResult` = `unknown` + +## Parameters + +### rest + +...[`MutateFunctionRest`](MutateFunctionRest.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\> + +## Returns + +`Promise`\<`TData`\> diff --git a/docs/framework/preact/reference/type-aliases/MutateFunctionRest.md b/docs/framework/preact/reference/type-aliases/MutateFunctionRest.md new file mode 100644 index 00000000000..3902f1082f9 --- /dev/null +++ b/docs/framework/preact/reference/type-aliases/MutateFunctionRest.md @@ -0,0 +1,28 @@ +--- +id: MutateFunctionRest +title: MutateFunctionRest +--- + +```ts +type MutateFunctionRest = undefined extends TVariables ? [TVariables, MutateOptions] : [TVariables, MutateOptions]; +``` + +Defined in: [packages/query-core/src/types.ts:1311](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1311) + +## Type Parameters + +### TData + +`TData` = `unknown` + +### TError + +`TError` = [`DefaultError`](DefaultError.md) + +### TVariables + +`TVariables` = `void` + +### TOnMutateResult + +`TOnMutateResult` = `unknown` diff --git a/docs/framework/preact/reference/type-aliases/MutationCacheNotifyEvent.md b/docs/framework/preact/reference/type-aliases/MutationCacheNotifyEvent.md new file mode 100644 index 00000000000..aa5e196bc72 --- /dev/null +++ b/docs/framework/preact/reference/type-aliases/MutationCacheNotifyEvent.md @@ -0,0 +1,20 @@ +--- +id: MutationCacheNotifyEvent +title: MutationCacheNotifyEvent +--- + +```ts +type MutationCacheNotifyEvent = + | NotifyEventMutationAdded + | NotifyEventMutationRemoved + | NotifyEventMutationObserverAdded + | NotifyEventMutationObserverRemoved + | NotifyEventMutationObserverOptionsUpdated + | NotifyEventMutationUpdated; +``` + +Defined in: [packages/query-core/src/mutationCache.ts:98](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationCache.ts#L98) + +The event passed to a `MutationCache` subscriber. Fired whenever a mutation is added or removed +from the cache, its state is updated, or one of its observers is added, removed, or has its +options updated. diff --git a/docs/framework/preact/reference/type-aliases/MutationFunction.md b/docs/framework/preact/reference/type-aliases/MutationFunction.md new file mode 100644 index 00000000000..9bafb3db56b --- /dev/null +++ b/docs/framework/preact/reference/type-aliases/MutationFunction.md @@ -0,0 +1,34 @@ +--- +id: MutationFunction +title: MutationFunction +--- + +```ts +type MutationFunction = (variables, context) => Promise; +``` + +Defined in: [packages/query-core/src/types.ts:1195](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1195) + +## Type Parameters + +### TData + +`TData` = `unknown` + +### TVariables + +`TVariables` = `unknown` + +## Parameters + +### variables + +`TVariables` + +### context + +[`MutationFunctionContext`](MutationFunctionContext.md) + +## Returns + +`Promise`\<`TData`\> diff --git a/docs/framework/preact/reference/type-aliases/MutationFunctionContext.md b/docs/framework/preact/reference/type-aliases/MutationFunctionContext.md new file mode 100644 index 00000000000..0207256c702 --- /dev/null +++ b/docs/framework/preact/reference/type-aliases/MutationFunctionContext.md @@ -0,0 +1,40 @@ +--- +id: MutationFunctionContext +title: MutationFunctionContext +--- + +```ts +type MutationFunctionContext = object; +``` + +Defined in: [packages/query-core/src/types.ts:1189](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1189) + +## Properties + +### client + +```ts +client: QueryClient; +``` + +Defined in: [packages/query-core/src/types.ts:1190](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1190) + +*** + +### meta + +```ts +meta: MutationMeta | undefined; +``` + +Defined in: [packages/query-core/src/types.ts:1191](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1191) + +*** + +### mutationKey? + +```ts +optional mutationKey: MutationKey; +``` + +Defined in: [packages/query-core/src/types.ts:1192](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1192) diff --git a/docs/framework/preact/reference/type-aliases/MutationKey.md b/docs/framework/preact/reference/type-aliases/MutationKey.md new file mode 100644 index 00000000000..9d1d7f0f77b --- /dev/null +++ b/docs/framework/preact/reference/type-aliases/MutationKey.md @@ -0,0 +1,10 @@ +--- +id: MutationKey +title: MutationKey +--- + +```ts +type MutationKey = Register extends object ? TMutationKey extends ReadonlyArray ? TMutationKey : TMutationKey extends unknown[] ? TMutationKey : ReadonlyArray : ReadonlyArray; +``` + +Defined in: [packages/query-core/src/types.ts:1165](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1165) diff --git a/docs/framework/preact/reference/type-aliases/MutationMeta.md b/docs/framework/preact/reference/type-aliases/MutationMeta.md new file mode 100644 index 00000000000..ff1f9b4bf94 --- /dev/null +++ b/docs/framework/preact/reference/type-aliases/MutationMeta.md @@ -0,0 +1,10 @@ +--- +id: MutationMeta +title: MutationMeta +--- + +```ts +type MutationMeta = Register extends object ? TMutationMeta extends Record ? TMutationMeta : Record : Record; +``` + +Defined in: [packages/query-core/src/types.ts:1181](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1181) diff --git a/docs/framework/preact/reference/type-aliases/MutationObserverResult.md b/docs/framework/preact/reference/type-aliases/MutationObserverResult.md new file mode 100644 index 00000000000..c21fc3ac591 --- /dev/null +++ b/docs/framework/preact/reference/type-aliases/MutationObserverResult.md @@ -0,0 +1,32 @@ +--- +id: MutationObserverResult +title: MutationObserverResult +--- + +```ts +type MutationObserverResult = + | MutationObserverIdleResult + | MutationObserverLoadingResult + | MutationObserverErrorResult +| MutationObserverSuccessResult; +``` + +Defined in: [packages/query-core/src/types.ts:1484](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1484) + +## Type Parameters + +### TData + +`TData` = `unknown` + +### TError + +`TError` = [`DefaultError`](DefaultError.md) + +### TVariables + +`TVariables` = `void` + +### TOnMutateResult + +`TOnMutateResult` = `unknown` diff --git a/docs/framework/preact/reference/type-aliases/MutationScope.md b/docs/framework/preact/reference/type-aliases/MutationScope.md new file mode 100644 index 00000000000..1d6a91bd434 --- /dev/null +++ b/docs/framework/preact/reference/type-aliases/MutationScope.md @@ -0,0 +1,20 @@ +--- +id: MutationScope +title: MutationScope +--- + +```ts +type MutationScope = object; +``` + +Defined in: [packages/query-core/src/types.ts:1177](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1177) + +## Properties + +### id + +```ts +id: string; +``` + +Defined in: [packages/query-core/src/types.ts:1178](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1178) diff --git a/docs/framework/preact/reference/type-aliases/MutationStatus.md b/docs/framework/preact/reference/type-aliases/MutationStatus.md new file mode 100644 index 00000000000..cf12d3d3ee3 --- /dev/null +++ b/docs/framework/preact/reference/type-aliases/MutationStatus.md @@ -0,0 +1,10 @@ +--- +id: MutationStatus +title: MutationStatus +--- + +```ts +type MutationStatus = "idle" | "pending" | "success" | "error"; +``` + +Defined in: [packages/query-core/src/types.ts:1175](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1175) diff --git a/docs/framework/preact/reference/type-aliases/NetworkMode.md b/docs/framework/preact/reference/type-aliases/NetworkMode.md new file mode 100644 index 00000000000..94ae0ba76ed --- /dev/null +++ b/docs/framework/preact/reference/type-aliases/NetworkMode.md @@ -0,0 +1,10 @@ +--- +id: NetworkMode +title: NetworkMode +--- + +```ts +type NetworkMode = "online" | "always" | "offlineFirst"; +``` + +Defined in: [packages/query-core/src/types.ts:223](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L223) diff --git a/docs/framework/preact/reference/type-aliases/NonUndefinedGuard.md b/docs/framework/preact/reference/type-aliases/NonUndefinedGuard.md new file mode 100644 index 00000000000..4aaf208013b --- /dev/null +++ b/docs/framework/preact/reference/type-aliases/NonUndefinedGuard.md @@ -0,0 +1,16 @@ +--- +id: NonUndefinedGuard +title: NonUndefinedGuard +--- + +```ts +type NonUndefinedGuard = T extends undefined ? never : T; +``` + +Defined in: [packages/query-core/src/types.ts:12](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L12) + +## Type Parameters + +### T + +`T` diff --git a/docs/framework/preact/reference/type-aliases/NotifyEventType.md b/docs/framework/preact/reference/type-aliases/NotifyEventType.md new file mode 100644 index 00000000000..ffa60b016e3 --- /dev/null +++ b/docs/framework/preact/reference/type-aliases/NotifyEventType.md @@ -0,0 +1,17 @@ +--- +id: NotifyEventType +title: NotifyEventType +--- + +```ts +type NotifyEventType = + | "added" + | "removed" + | "updated" + | "observerAdded" + | "observerRemoved" + | "observerResultsUpdated" + | "observerOptionsUpdated"; +``` + +Defined in: [packages/query-core/src/types.ts:1530](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1530) diff --git a/docs/framework/preact/reference/type-aliases/NotifyOnChangeProps.md b/docs/framework/preact/reference/type-aliases/NotifyOnChangeProps.md new file mode 100644 index 00000000000..7de194fa10b --- /dev/null +++ b/docs/framework/preact/reference/type-aliases/NotifyOnChangeProps.md @@ -0,0 +1,17 @@ +--- +id: NotifyOnChangeProps +title: NotifyOnChangeProps +--- + +```ts +type NotifyOnChangeProps = + | keyof InfiniteQueryObserverResult[] + | "all" + | undefined + | () => + | keyof InfiniteQueryObserverResult[] + | "all" + | undefined; +``` + +Defined in: [packages/query-core/src/types.ts:225](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L225) diff --git a/docs/framework/preact/reference/type-aliases/OmitKeyof.md b/docs/framework/preact/reference/type-aliases/OmitKeyof.md new file mode 100644 index 00000000000..690a7b0a5d2 --- /dev/null +++ b/docs/framework/preact/reference/type-aliases/OmitKeyof.md @@ -0,0 +1,28 @@ +--- +id: OmitKeyof +title: OmitKeyof +--- + +```ts +type OmitKeyof = Omit; +``` + +Defined in: [packages/query-core/src/types.ts:19](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L19) + +## Type Parameters + +### TObject + +`TObject` + +### TKey + +`TKey` *extends* `TStrictly` *extends* `"safely"` ? + \| keyof `TObject` + \| `string` & `Record`\<`never`, `never`\> + \| `number` & `Record`\<`never`, `never`\> + \| `symbol` & `Record`\<`never`, `never`\> : keyof `TObject` + +### TStrictly + +`TStrictly` *extends* `"strictly"` \| `"safely"` = `"strictly"` diff --git a/docs/framework/preact/reference/type-aliases/Override.md b/docs/framework/preact/reference/type-aliases/Override.md new file mode 100644 index 00000000000..8abcecd1e1b --- /dev/null +++ b/docs/framework/preact/reference/type-aliases/Override.md @@ -0,0 +1,20 @@ +--- +id: Override +title: Override +--- + +```ts +type Override = { [AKey in keyof TTargetA]: AKey extends keyof TTargetB ? TTargetB[AKey] : TTargetA[AKey] }; +``` + +Defined in: [packages/query-core/src/types.ts:31](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L31) + +## Type Parameters + +### TTargetA + +`TTargetA` + +### TTargetB + +`TTargetB` diff --git a/docs/framework/preact/reference/type-aliases/PlaceholderDataFunction.md b/docs/framework/preact/reference/type-aliases/PlaceholderDataFunction.md new file mode 100644 index 00000000000..cd40f28b41e --- /dev/null +++ b/docs/framework/preact/reference/type-aliases/PlaceholderDataFunction.md @@ -0,0 +1,42 @@ +--- +id: PlaceholderDataFunction +title: PlaceholderDataFunction +--- + +```ts +type PlaceholderDataFunction = (previousData, previousQuery) => TQueryData | undefined; +``` + +Defined in: [packages/query-core/src/types.ts:177](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L177) + +## Type Parameters + +### TQueryFnData + +`TQueryFnData` = `unknown` + +### TError + +`TError` = [`DefaultError`](DefaultError.md) + +### TQueryData + +`TQueryData` = `TQueryFnData` + +### TQueryKey + +`TQueryKey` *extends* [`QueryKey`](QueryKey.md) = [`QueryKey`](QueryKey.md) + +## Parameters + +### previousData + +`TQueryData` | `undefined` + +### previousQuery + +[`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryData`, `TQueryKey`\> | `undefined` + +## Returns + +`TQueryData` \| `undefined` diff --git a/docs/framework/preact/reference/type-aliases/QueriesOptions.md b/docs/framework/preact/reference/type-aliases/QueriesOptions.md index 3ae066a07d9..e5b2da7823f 100644 --- a/docs/framework/preact/reference/type-aliases/QueriesOptions.md +++ b/docs/framework/preact/reference/type-aliases/QueriesOptions.md @@ -7,7 +7,7 @@ title: QueriesOptions type QueriesOptions = TDepth["length"] extends MAXIMUM_DEPTH ? UseQueryOptionsForUseQueries[] : T extends [] ? [] : T extends [infer Head] ? [...TResults, GetUseQueryOptionsForUseQueries] : T extends [infer Head, ...(infer Tails)] ? QueriesOptions<[...Tails], [...TResults, GetUseQueryOptionsForUseQueries], [...TDepth, 1]> : ReadonlyArray extends T ? T : T extends UseQueryOptionsForUseQueries[] ? UseQueryOptionsForUseQueries[] : UseQueryOptionsForUseQueries[]; ``` -Defined in: [preact-query/src/useQueries.ts:156](https://github.com/TanStack/query/blob/main/packages/preact-query/src/useQueries.ts#L156) +Defined in: [packages/preact-query/src/useQueries.ts:156](https://github.com/TanStack/query/blob/main/packages/preact-query/src/useQueries.ts#L156) The `queries` array accepted by `useQueries`. Recursively unwraps each tuple element so every entry's `queryFn`/`select`/`throwOnError` are inferred individually, up to 20 elements. An opaque array (e.g. diff --git a/docs/framework/preact/reference/type-aliases/QueriesPlaceholderDataFunction.md b/docs/framework/preact/reference/type-aliases/QueriesPlaceholderDataFunction.md new file mode 100644 index 00000000000..5d3fca8c9e0 --- /dev/null +++ b/docs/framework/preact/reference/type-aliases/QueriesPlaceholderDataFunction.md @@ -0,0 +1,30 @@ +--- +id: QueriesPlaceholderDataFunction +title: QueriesPlaceholderDataFunction +--- + +```ts +type QueriesPlaceholderDataFunction = (previousData, previousQuery) => TQueryData | undefined; +``` + +Defined in: [packages/query-core/src/types.ts:187](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L187) + +## Type Parameters + +### TQueryData + +`TQueryData` + +## Parameters + +### previousData + +`undefined` + +### previousQuery + +`undefined` + +## Returns + +`TQueryData` \| `undefined` diff --git a/docs/framework/preact/reference/type-aliases/QueriesResults.md b/docs/framework/preact/reference/type-aliases/QueriesResults.md index cfc82c12955..ab0ce69b005 100644 --- a/docs/framework/preact/reference/type-aliases/QueriesResults.md +++ b/docs/framework/preact/reference/type-aliases/QueriesResults.md @@ -7,7 +7,7 @@ title: QueriesResults type QueriesResults = TDepth["length"] extends MAXIMUM_DEPTH ? UseQueryResult[] : T extends [] ? [] : T extends [infer Head] ? [...TResults, GetUseQueryResult] : T extends [infer Head, ...(infer Tails)] ? QueriesResults<[...Tails], [...TResults, GetUseQueryResult], [...TDepth, 1]> : { [K in keyof T]: GetUseQueryResult }; ``` -Defined in: [preact-query/src/useQueries.ts:207](https://github.com/TanStack/query/blob/main/packages/preact-query/src/useQueries.ts#L207) +Defined in: [packages/preact-query/src/useQueries.ts:207](https://github.com/TanStack/query/blob/main/packages/preact-query/src/useQueries.ts#L207) The result type returned by `useQueries`, when no `combine` is provided. Mirrors [QueriesOptions](QueriesOptions.md): each tuple element's result type is inferred individually, up to 20 elements. A non-tuple array is mapped diff --git a/docs/framework/preact/reference/type-aliases/QueryBooleanOption.md b/docs/framework/preact/reference/type-aliases/QueryBooleanOption.md new file mode 100644 index 00000000000..9759e3ddb42 --- /dev/null +++ b/docs/framework/preact/reference/type-aliases/QueryBooleanOption.md @@ -0,0 +1,28 @@ +--- +id: QueryBooleanOption +title: QueryBooleanOption +--- + +```ts +type QueryBooleanOption = boolean | (query) => boolean; +``` + +Defined in: [packages/query-core/src/types.ts:119](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L119) + +## Type Parameters + +### TQueryFnData + +`TQueryFnData` = `unknown` + +### TError + +`TError` = [`DefaultError`](DefaultError.md) + +### TData + +`TData` = `TQueryFnData` + +### TQueryKey + +`TQueryKey` *extends* [`QueryKey`](QueryKey.md) = [`QueryKey`](QueryKey.md) diff --git a/docs/framework/preact/reference/type-aliases/QueryCacheNotifyEvent.md b/docs/framework/preact/reference/type-aliases/QueryCacheNotifyEvent.md new file mode 100644 index 00000000000..b92c76fb826 --- /dev/null +++ b/docs/framework/preact/reference/type-aliases/QueryCacheNotifyEvent.md @@ -0,0 +1,21 @@ +--- +id: QueryCacheNotifyEvent +title: QueryCacheNotifyEvent +--- + +```ts +type QueryCacheNotifyEvent = + | NotifyEventQueryAdded + | NotifyEventQueryRemoved + | NotifyEventQueryUpdated + | NotifyEventQueryObserverAdded + | NotifyEventQueryObserverRemoved + | NotifyEventQueryObserverResultsUpdated + | NotifyEventQueryObserverOptionsUpdated; +``` + +Defined in: [packages/query-core/src/queryCache.ts:85](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryCache.ts#L85) + +The event passed to a `QueryCache` subscriber. Fired whenever a query is added or removed from +the cache, its state is updated (e.g. via `query.setState` or `queryClient.removeQueries`), or +one of its observers is added, removed, or has its results or options updated. diff --git a/docs/framework/preact/reference/type-aliases/QueryClientProviderProps.md b/docs/framework/preact/reference/type-aliases/QueryClientProviderProps.md index c23626b16f5..ef92581d1bc 100644 --- a/docs/framework/preact/reference/type-aliases/QueryClientProviderProps.md +++ b/docs/framework/preact/reference/type-aliases/QueryClientProviderProps.md @@ -7,7 +7,7 @@ title: QueryClientProviderProps type QueryClientProviderProps = object; ``` -Defined in: [preact-query/src/QueryClientProvider.tsx:38](https://github.com/TanStack/query/blob/main/packages/preact-query/src/QueryClientProvider.tsx#L38) +Defined in: [packages/preact-query/src/QueryClientProvider.tsx:38](https://github.com/TanStack/query/blob/main/packages/preact-query/src/QueryClientProvider.tsx#L38) The props accepted by `QueryClientProvider`. @@ -19,7 +19,7 @@ The props accepted by `QueryClientProvider`. optional children: ComponentChildren; ``` -Defined in: [preact-query/src/QueryClientProvider.tsx:48](https://github.com/TanStack/query/blob/main/packages/preact-query/src/QueryClientProvider.tsx#L48) +Defined in: [packages/preact-query/src/QueryClientProvider.tsx:48](https://github.com/TanStack/query/blob/main/packages/preact-query/src/QueryClientProvider.tsx#L48) The components that get access to the provided `QueryClient`. @@ -31,7 +31,7 @@ The components that get access to the provided `QueryClient`. client: QueryClient; ``` -Defined in: [preact-query/src/QueryClientProvider.tsx:44](https://github.com/TanStack/query/blob/main/packages/preact-query/src/QueryClientProvider.tsx#L44) +Defined in: [packages/preact-query/src/QueryClientProvider.tsx:44](https://github.com/TanStack/query/blob/main/packages/preact-query/src/QueryClientProvider.tsx#L44) **Required** diff --git a/docs/framework/preact/reference/type-aliases/QueryErrorClearResetFunction.md b/docs/framework/preact/reference/type-aliases/QueryErrorClearResetFunction.md index d80f43bf5e8..becc826aed2 100644 --- a/docs/framework/preact/reference/type-aliases/QueryErrorClearResetFunction.md +++ b/docs/framework/preact/reference/type-aliases/QueryErrorClearResetFunction.md @@ -7,7 +7,7 @@ title: QueryErrorClearResetFunction type QueryErrorClearResetFunction = () => void; ``` -Defined in: [preact-query/src/QueryErrorResetBoundary.tsx:20](https://github.com/TanStack/query/blob/main/packages/preact-query/src/QueryErrorResetBoundary.tsx#L20) +Defined in: [packages/preact-query/src/QueryErrorResetBoundary.tsx:20](https://github.com/TanStack/query/blob/main/packages/preact-query/src/QueryErrorResetBoundary.tsx#L20) Clears the reset state, so queries know not to try again until the boundary is reset again. diff --git a/docs/framework/preact/reference/type-aliases/QueryErrorIsResetFunction.md b/docs/framework/preact/reference/type-aliases/QueryErrorIsResetFunction.md index c1cd3ca73e9..3504fae41ec 100644 --- a/docs/framework/preact/reference/type-aliases/QueryErrorIsResetFunction.md +++ b/docs/framework/preact/reference/type-aliases/QueryErrorIsResetFunction.md @@ -7,7 +7,7 @@ title: QueryErrorIsResetFunction type QueryErrorIsResetFunction = () => boolean; ``` -Defined in: [preact-query/src/QueryErrorResetBoundary.tsx:15](https://github.com/TanStack/query/blob/main/packages/preact-query/src/QueryErrorResetBoundary.tsx#L15) +Defined in: [packages/preact-query/src/QueryErrorResetBoundary.tsx:15](https://github.com/TanStack/query/blob/main/packages/preact-query/src/QueryErrorResetBoundary.tsx#L15) Returns whether the boundary has been reset and not yet cleared. diff --git a/docs/framework/preact/reference/type-aliases/QueryErrorResetBoundaryFunction.md b/docs/framework/preact/reference/type-aliases/QueryErrorResetBoundaryFunction.md index 2ed65c16cb7..0ba3184fc42 100644 --- a/docs/framework/preact/reference/type-aliases/QueryErrorResetBoundaryFunction.md +++ b/docs/framework/preact/reference/type-aliases/QueryErrorResetBoundaryFunction.md @@ -7,7 +7,7 @@ title: QueryErrorResetBoundaryFunction type QueryErrorResetBoundaryFunction = (value) => ComponentChildren; ``` -Defined in: [preact-query/src/QueryErrorResetBoundary.tsx:96](https://github.com/TanStack/query/blob/main/packages/preact-query/src/QueryErrorResetBoundary.tsx#L96) +Defined in: [packages/preact-query/src/QueryErrorResetBoundary.tsx:96](https://github.com/TanStack/query/blob/main/packages/preact-query/src/QueryErrorResetBoundary.tsx#L96) A render-prop function usable as `children` on `QueryErrorResetBoundary`. diff --git a/docs/framework/preact/reference/type-aliases/QueryErrorResetFunction.md b/docs/framework/preact/reference/type-aliases/QueryErrorResetFunction.md index 963e0bba8ae..311e79adf6e 100644 --- a/docs/framework/preact/reference/type-aliases/QueryErrorResetFunction.md +++ b/docs/framework/preact/reference/type-aliases/QueryErrorResetFunction.md @@ -7,7 +7,7 @@ title: QueryErrorResetFunction type QueryErrorResetFunction = () => void; ``` -Defined in: [preact-query/src/QueryErrorResetBoundary.tsx:10](https://github.com/TanStack/query/blob/main/packages/preact-query/src/QueryErrorResetBoundary.tsx#L10) +Defined in: [packages/preact-query/src/QueryErrorResetBoundary.tsx:10](https://github.com/TanStack/query/blob/main/packages/preact-query/src/QueryErrorResetBoundary.tsx#L10) Resets any query errors within the boundary, so queries know they can try again. diff --git a/docs/framework/preact/reference/type-aliases/QueryFunction.md b/docs/framework/preact/reference/type-aliases/QueryFunction.md new file mode 100644 index 00000000000..306367388a1 --- /dev/null +++ b/docs/framework/preact/reference/type-aliases/QueryFunction.md @@ -0,0 +1,34 @@ +--- +id: QueryFunction +title: QueryFunction +--- + +```ts +type QueryFunction = (context) => T | Promise; +``` + +Defined in: [packages/query-core/src/types.ts:102](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L102) + +## Type Parameters + +### T + +`T` = `unknown` + +### TQueryKey + +`TQueryKey` *extends* [`QueryKey`](QueryKey.md) = [`QueryKey`](QueryKey.md) + +### TPageParam + +`TPageParam` = `never` + +## Parameters + +### context + +[`QueryFunctionContext`](QueryFunctionContext.md)\<`TQueryKey`, `TPageParam`\> + +## Returns + +`T` \| `Promise`\<`T`\> diff --git a/docs/framework/preact/reference/type-aliases/QueryFunctionContext.md b/docs/framework/preact/reference/type-aliases/QueryFunctionContext.md new file mode 100644 index 00000000000..d2c9fe3e2b2 --- /dev/null +++ b/docs/framework/preact/reference/type-aliases/QueryFunctionContext.md @@ -0,0 +1,20 @@ +--- +id: QueryFunctionContext +title: QueryFunctionContext +--- + +```ts +type QueryFunctionContext = [TPageParam] extends [never] ? object : object; +``` + +Defined in: [packages/query-core/src/types.ts:144](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L144) + +## Type Parameters + +### TQueryKey + +`TQueryKey` *extends* [`QueryKey`](QueryKey.md) = [`QueryKey`](QueryKey.md) + +### TPageParam + +`TPageParam` = `never` diff --git a/docs/framework/preact/reference/type-aliases/QueryKey.md b/docs/framework/preact/reference/type-aliases/QueryKey.md new file mode 100644 index 00000000000..1a3f34cde18 --- /dev/null +++ b/docs/framework/preact/reference/type-aliases/QueryKey.md @@ -0,0 +1,10 @@ +--- +id: QueryKey +title: QueryKey +--- + +```ts +type QueryKey = Register extends object ? TQueryKey extends ReadonlyArray ? TQueryKey : TQueryKey extends unknown[] ? TQueryKey : ReadonlyArray : ReadonlyArray; +``` + +Defined in: [packages/query-core/src/types.ts:51](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L51) diff --git a/docs/framework/preact/reference/type-aliases/QueryKeyHashFunction.md b/docs/framework/preact/reference/type-aliases/QueryKeyHashFunction.md new file mode 100644 index 00000000000..feda96373cc --- /dev/null +++ b/docs/framework/preact/reference/type-aliases/QueryKeyHashFunction.md @@ -0,0 +1,26 @@ +--- +id: QueryKeyHashFunction +title: QueryKeyHashFunction +--- + +```ts +type QueryKeyHashFunction = (queryKey) => string; +``` + +Defined in: [packages/query-core/src/types.ts:192](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L192) + +## Type Parameters + +### TQueryKey + +`TQueryKey` *extends* [`QueryKey`](QueryKey.md) + +## Parameters + +### queryKey + +`TQueryKey` + +## Returns + +`string` diff --git a/docs/framework/preact/reference/type-aliases/QueryKeyWithDataTag.md b/docs/framework/preact/reference/type-aliases/QueryKeyWithDataTag.md new file mode 100644 index 00000000000..6613f74be9e --- /dev/null +++ b/docs/framework/preact/reference/type-aliases/QueryKeyWithDataTag.md @@ -0,0 +1,34 @@ +--- +id: QueryKeyWithDataTag +title: QueryKeyWithDataTag +--- + +```ts +type QueryKeyWithDataTag = object; +``` + +Defined in: [packages/query-core/src/types.ts:82](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L82) + +## Type Parameters + +### TQueryKey + +`TQueryKey` *extends* [`QueryKey`](QueryKey.md) = [`QueryKey`](QueryKey.md) + +### TQueryFnData + +`TQueryFnData` = `unknown` + +### TError + +`TError` = [`DefaultError`](DefaultError.md) + +## Properties + +### queryKey + +```ts +queryKey: DataTag; +``` + +Defined in: [packages/query-core/src/types.ts:87](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L87) diff --git a/docs/framework/preact/reference/type-aliases/QueryMeta.md b/docs/framework/preact/reference/type-aliases/QueryMeta.md new file mode 100644 index 00000000000..c12917b2cce --- /dev/null +++ b/docs/framework/preact/reference/type-aliases/QueryMeta.md @@ -0,0 +1,10 @@ +--- +id: QueryMeta +title: QueryMeta +--- + +```ts +type QueryMeta = Register extends object ? TQueryMeta extends Record ? TQueryMeta : Record : Record; +``` + +Defined in: [packages/query-core/src/types.ts:215](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L215) diff --git a/docs/framework/preact/reference/type-aliases/QueryObserverResult.md b/docs/framework/preact/reference/type-aliases/QueryObserverResult.md new file mode 100644 index 00000000000..5138b635f2c --- /dev/null +++ b/docs/framework/preact/reference/type-aliases/QueryObserverResult.md @@ -0,0 +1,25 @@ +--- +id: QueryObserverResult +title: QueryObserverResult +--- + +```ts +type QueryObserverResult = + | DefinedQueryObserverResult + | QueryObserverLoadingErrorResult + | QueryObserverLoadingResult + | QueryObserverPendingResult +| QueryObserverPlaceholderResult; +``` + +Defined in: [packages/query-core/src/types.ts:994](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L994) + +## Type Parameters + +### TData + +`TData` = `unknown` + +### TError + +`TError` = [`DefaultError`](DefaultError.md) diff --git a/docs/framework/preact/reference/type-aliases/QueryPersister.md b/docs/framework/preact/reference/type-aliases/QueryPersister.md new file mode 100644 index 00000000000..72e80165b0d --- /dev/null +++ b/docs/framework/preact/reference/type-aliases/QueryPersister.md @@ -0,0 +1,24 @@ +--- +id: QueryPersister +title: QueryPersister +--- + +```ts +type QueryPersister = [TPageParam] extends [never] ? (queryFn, context, query) => T | Promise : (queryFn, context, query) => T | Promise; +``` + +Defined in: [packages/query-core/src/types.ts:128](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L128) + +## Type Parameters + +### T + +`T` = `unknown` + +### TQueryKey + +`TQueryKey` *extends* [`QueryKey`](QueryKey.md) = [`QueryKey`](QueryKey.md) + +### TPageParam + +`TPageParam` = `never` diff --git a/docs/framework/preact/reference/type-aliases/QueryStatus.md b/docs/framework/preact/reference/type-aliases/QueryStatus.md new file mode 100644 index 00000000000..bab00f6f423 --- /dev/null +++ b/docs/framework/preact/reference/type-aliases/QueryStatus.md @@ -0,0 +1,10 @@ +--- +id: QueryStatus +title: QueryStatus +--- + +```ts +type QueryStatus = "pending" | "error" | "success"; +``` + +Defined in: [packages/query-core/src/types.ts:761](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L761) diff --git a/docs/framework/preact/reference/type-aliases/SkipToken.md b/docs/framework/preact/reference/type-aliases/SkipToken.md new file mode 100644 index 00000000000..3a5791b982e --- /dev/null +++ b/docs/framework/preact/reference/type-aliases/SkipToken.md @@ -0,0 +1,12 @@ +--- +id: SkipToken +title: SkipToken +--- + +```ts +type SkipToken = typeof skipToken; +``` + +Defined in: [packages/query-core/src/utils.ts:526](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L526) + +The type of the [skipToken](../variables/skipToken.md) sentinel value. diff --git a/docs/framework/preact/reference/type-aliases/StaleTime.md b/docs/framework/preact/reference/type-aliases/StaleTime.md new file mode 100644 index 00000000000..3e7e21608be --- /dev/null +++ b/docs/framework/preact/reference/type-aliases/StaleTime.md @@ -0,0 +1,10 @@ +--- +id: StaleTime +title: StaleTime +--- + +```ts +type StaleTime = number | "static"; +``` + +Defined in: [packages/query-core/src/types.ts:108](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L108) diff --git a/docs/framework/preact/reference/type-aliases/StaleTimeFunction.md b/docs/framework/preact/reference/type-aliases/StaleTimeFunction.md new file mode 100644 index 00000000000..b1c541fa64e --- /dev/null +++ b/docs/framework/preact/reference/type-aliases/StaleTimeFunction.md @@ -0,0 +1,28 @@ +--- +id: StaleTimeFunction +title: StaleTimeFunction +--- + +```ts +type StaleTimeFunction = StaleTime | (query) => StaleTime; +``` + +Defined in: [packages/query-core/src/types.ts:110](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L110) + +## Type Parameters + +### TQueryFnData + +`TQueryFnData` = `unknown` + +### TError + +`TError` = [`DefaultError`](DefaultError.md) + +### TData + +`TData` = `TQueryFnData` + +### TQueryKey + +`TQueryKey` *extends* [`QueryKey`](QueryKey.md) = [`QueryKey`](QueryKey.md) diff --git a/docs/framework/preact/reference/type-aliases/SuspenseQueriesOptions.md b/docs/framework/preact/reference/type-aliases/SuspenseQueriesOptions.md index 270f2e1423c..a61ae66de38 100644 --- a/docs/framework/preact/reference/type-aliases/SuspenseQueriesOptions.md +++ b/docs/framework/preact/reference/type-aliases/SuspenseQueriesOptions.md @@ -7,7 +7,7 @@ title: SuspenseQueriesOptions type SuspenseQueriesOptions = TDepth["length"] extends MAXIMUM_DEPTH ? UseSuspenseQueryOptions[] : T extends [] ? [] : T extends [infer Head] ? [...TResults, GetUseSuspenseQueryOptions] : T extends [infer Head, ...(infer Tails)] ? SuspenseQueriesOptions<[...Tails], [...TResults, GetUseSuspenseQueryOptions], [...TDepth, 1]> : unknown[] extends T ? T : T extends UseSuspenseQueryOptions[] ? UseSuspenseQueryOptions[] : UseSuspenseQueryOptions[]; ``` -Defined in: [preact-query/src/useSuspenseQueries.ts:119](https://github.com/TanStack/query/blob/main/packages/preact-query/src/useSuspenseQueries.ts#L119) +Defined in: [packages/preact-query/src/useSuspenseQueries.ts:119](https://github.com/TanStack/query/blob/main/packages/preact-query/src/useSuspenseQueries.ts#L119) The `queries` array accepted by `useSuspenseQueries`. Recursively unwraps each tuple element so every entry's `queryFn`/`select` are inferred individually, up to 20 elements. An opaque array (e.g. `unknown[]`) diff --git a/docs/framework/preact/reference/type-aliases/SuspenseQueriesResults.md b/docs/framework/preact/reference/type-aliases/SuspenseQueriesResults.md index aa814a6ac9d..747e090ef9e 100644 --- a/docs/framework/preact/reference/type-aliases/SuspenseQueriesResults.md +++ b/docs/framework/preact/reference/type-aliases/SuspenseQueriesResults.md @@ -7,7 +7,7 @@ title: SuspenseQueriesResults type SuspenseQueriesResults = TDepth["length"] extends MAXIMUM_DEPTH ? UseSuspenseQueryResult[] : T extends [] ? [] : T extends [infer Head] ? [...TResults, GetUseSuspenseQueryResult] : T extends [infer Head, ...(infer Tails)] ? SuspenseQueriesResults<[...Tails], [...TResults, GetUseSuspenseQueryResult], [...TDepth, 1]> : { [K in keyof T]: GetUseSuspenseQueryResult }; ``` -Defined in: [preact-query/src/useSuspenseQueries.ts:165](https://github.com/TanStack/query/blob/main/packages/preact-query/src/useSuspenseQueries.ts#L165) +Defined in: [packages/preact-query/src/useSuspenseQueries.ts:165](https://github.com/TanStack/query/blob/main/packages/preact-query/src/useSuspenseQueries.ts#L165) The result type returned by `useSuspenseQueries`, when no `combine` is provided. Mirrors [SuspenseQueriesOptions](SuspenseQueriesOptions.md): each tuple element's result type is inferred individually, up to 20 elements. diff --git a/docs/framework/preact/reference/type-aliases/ThrowOnError.md b/docs/framework/preact/reference/type-aliases/ThrowOnError.md new file mode 100644 index 00000000000..134683388ef --- /dev/null +++ b/docs/framework/preact/reference/type-aliases/ThrowOnError.md @@ -0,0 +1,28 @@ +--- +id: ThrowOnError +title: ThrowOnError +--- + +```ts +type ThrowOnError = boolean | (error, query) => boolean; +``` + +Defined in: [packages/query-core/src/types.ts:368](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L368) + +## Type Parameters + +### TQueryFnData + +`TQueryFnData` + +### TError + +`TError` + +### TQueryData + +`TQueryData` + +### TQueryKey + +`TQueryKey` *extends* [`QueryKey`](QueryKey.md) diff --git a/docs/framework/preact/reference/type-aliases/TimeoutCallback.md b/docs/framework/preact/reference/type-aliases/TimeoutCallback.md new file mode 100644 index 00000000000..773b5fdaeb9 --- /dev/null +++ b/docs/framework/preact/reference/type-aliases/TimeoutCallback.md @@ -0,0 +1,27 @@ +--- +id: TimeoutCallback +title: TimeoutCallback +--- + +```ts +type TimeoutCallback = (_) => void; +``` + +Defined in: [packages/query-core/src/timeoutManager.ts:9](https://github.com/TanStack/query/blob/main/packages/query-core/src/timeoutManager.ts#L9) + +[TimeoutManager](../interfaces/TimeoutManager.md) does not support passing arguments to the callback. + +`(_: void)` is the argument type inferred by TypeScript's default typings for +`setTimeout(cb, number)`. +If we don't accept a single void argument, then +`new Promise(resolve => timeoutManager.setTimeout(resolve, N))` is a type error. + +## Parameters + +### \_ + +`void` + +## Returns + +`void` diff --git a/docs/framework/preact/reference/type-aliases/TimeoutProvider.md b/docs/framework/preact/reference/type-aliases/TimeoutProvider.md new file mode 100644 index 00000000000..3509105bcd1 --- /dev/null +++ b/docs/framework/preact/reference/type-aliases/TimeoutProvider.md @@ -0,0 +1,112 @@ +--- +id: TimeoutProvider +title: TimeoutProvider +--- + +```ts +type TimeoutProvider = object; +``` + +Defined in: [packages/query-core/src/timeoutManager.ts:28](https://github.com/TanStack/query/blob/main/packages/query-core/src/timeoutManager.ts#L28) + +Backend for timer functions. + +Timers are performance-sensitive: short-lived timers (delays under a few seconds) tend to be +latency-sensitive, while long-lived ones may benefit more from coalescing — batching timers +with similar deadlines together — which the default provider (backed by the platform's global +`setTimeout`/`setInterval`) does not do. A custom provider can implement coalescing, and can +also support delays longer than the ~24-day maximum of the global `setTimeout`. + +## Type Parameters + +### TTimerId + +`TTimerId` *extends* [`ManagedTimerId`](ManagedTimerId.md) = [`ManagedTimerId`](ManagedTimerId.md) + +## Properties + +### clearInterval() + +```ts +readonly clearInterval: (intervalId) => void; +``` + +Defined in: [packages/query-core/src/timeoutManager.ts:34](https://github.com/TanStack/query/blob/main/packages/query-core/src/timeoutManager.ts#L34) + +#### Parameters + +##### intervalId + +`TTimerId` | `undefined` + +#### Returns + +`void` + +*** + +### clearTimeout() + +```ts +readonly clearTimeout: (timeoutId) => void; +``` + +Defined in: [packages/query-core/src/timeoutManager.ts:31](https://github.com/TanStack/query/blob/main/packages/query-core/src/timeoutManager.ts#L31) + +#### Parameters + +##### timeoutId + +`TTimerId` | `undefined` + +#### Returns + +`void` + +*** + +### setInterval() + +```ts +readonly setInterval: (callback, delay) => TTimerId; +``` + +Defined in: [packages/query-core/src/timeoutManager.ts:33](https://github.com/TanStack/query/blob/main/packages/query-core/src/timeoutManager.ts#L33) + +#### Parameters + +##### callback + +[`TimeoutCallback`](TimeoutCallback.md) + +##### delay + +`number` + +#### Returns + +`TTimerId` + +*** + +### setTimeout() + +```ts +readonly setTimeout: (callback, delay) => TTimerId; +``` + +Defined in: [packages/query-core/src/timeoutManager.ts:30](https://github.com/TanStack/query/blob/main/packages/query-core/src/timeoutManager.ts#L30) + +#### Parameters + +##### callback + +[`TimeoutCallback`](TimeoutCallback.md) + +##### delay + +`number` + +#### Returns + +`TTimerId` diff --git a/docs/framework/preact/reference/type-aliases/UndefinedInitialDataInfiniteOptions.md b/docs/framework/preact/reference/type-aliases/UndefinedInitialDataInfiniteOptions.md index 361e6c306e4..a2245f65836 100644 --- a/docs/framework/preact/reference/type-aliases/UndefinedInitialDataInfiniteOptions.md +++ b/docs/framework/preact/reference/type-aliases/UndefinedInitialDataInfiniteOptions.md @@ -7,7 +7,7 @@ title: UndefinedInitialDataInfiniteOptions type UndefinedInitialDataInfiniteOptions = UseInfiniteQueryOptions & object; ``` -Defined in: [preact-query/src/infiniteQueryOptions.ts:25](https://github.com/TanStack/query/blob/main/packages/preact-query/src/infiniteQueryOptions.ts#L25) +Defined in: [packages/preact-query/src/infiniteQueryOptions.ts:25](https://github.com/TanStack/query/blob/main/packages/preact-query/src/infiniteQueryOptions.ts#L25) The options accepted by the `infiniteQueryOptions` overload selected when no `initialData` is set — `data` may be `undefined` while the query is `pending`. @@ -38,20 +38,20 @@ The type of a single page, as your `queryFn` resolves it. ### TError -`TError` = `DefaultError` +`TError` = [`DefaultError`](DefaultError.md) The type of errors your `queryFn` may throw. ### TData -`TData` = `InfiniteData`\<`TQueryFnData`\> +`TData` = [`InfiniteData`](../interfaces/InfiniteData.md)\<`TQueryFnData`\> The type `data` ends up as after `select` runs — defaults to `InfiniteData`, the shape of all fetched pages plus their page params. ### TQueryKey -`TQueryKey` *extends* `QueryKey` = `QueryKey` +`TQueryKey` *extends* [`QueryKey`](QueryKey.md) = [`QueryKey`](QueryKey.md) The type of your `queryKey`. diff --git a/docs/framework/preact/reference/type-aliases/UndefinedInitialDataOptions.md b/docs/framework/preact/reference/type-aliases/UndefinedInitialDataOptions.md index 42d8de427c8..8229e0450c6 100644 --- a/docs/framework/preact/reference/type-aliases/UndefinedInitialDataOptions.md +++ b/docs/framework/preact/reference/type-aliases/UndefinedInitialDataOptions.md @@ -7,7 +7,7 @@ title: UndefinedInitialDataOptions type UndefinedInitialDataOptions = UseQueryOptions & object; ``` -Defined in: [preact-query/src/queryOptions.ts:23](https://github.com/TanStack/query/blob/main/packages/preact-query/src/queryOptions.ts#L23) +Defined in: [packages/preact-query/src/queryOptions.ts:23](https://github.com/TanStack/query/blob/main/packages/preact-query/src/queryOptions.ts#L23) The options accepted by the `queryOptions` overload selected when no `initialData` is set — `data` may be `undefined` while the query is `pending`. @@ -38,7 +38,7 @@ The type your `queryFn` resolves to. ### TError -`TError` = `DefaultError` +`TError` = [`DefaultError`](DefaultError.md) The type of errors your `queryFn` may throw. @@ -50,6 +50,6 @@ The type `data` ends up as after `select` runs. ### TQueryKey -`TQueryKey` *extends* `QueryKey` = `QueryKey` +`TQueryKey` *extends* [`QueryKey`](QueryKey.md) = [`QueryKey`](QueryKey.md) The type of your `queryKey`. diff --git a/docs/framework/preact/reference/type-aliases/UnsetMarker.md b/docs/framework/preact/reference/type-aliases/UnsetMarker.md new file mode 100644 index 00000000000..8b9c14e1907 --- /dev/null +++ b/docs/framework/preact/reference/type-aliases/UnsetMarker.md @@ -0,0 +1,10 @@ +--- +id: UnsetMarker +title: UnsetMarker +--- + +```ts +type UnsetMarker = typeof unsetMarker; +``` + +Defined in: [packages/query-core/src/types.ts:66](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L66) diff --git a/docs/framework/preact/reference/type-aliases/UnusedSkipTokenInfiniteOptions.md b/docs/framework/preact/reference/type-aliases/UnusedSkipTokenInfiniteOptions.md index 67558527046..185d7926afc 100644 --- a/docs/framework/preact/reference/type-aliases/UnusedSkipTokenInfiniteOptions.md +++ b/docs/framework/preact/reference/type-aliases/UnusedSkipTokenInfiniteOptions.md @@ -7,7 +7,7 @@ title: UnusedSkipTokenInfiniteOptions type UnusedSkipTokenInfiniteOptions = OmitKeyof, "queryFn"> & object; ``` -Defined in: [preact-query/src/infiniteQueryOptions.ts:65](https://github.com/TanStack/query/blob/main/packages/preact-query/src/infiniteQueryOptions.ts#L65) +Defined in: [packages/preact-query/src/infiniteQueryOptions.ts:65](https://github.com/TanStack/query/blob/main/packages/preact-query/src/infiniteQueryOptions.ts#L65) The options accepted by the `infiniteQueryOptions` overload selected when no `initialData` is set and `queryFn` is not `skipToken` — same as [UndefinedInitialDataInfiniteOptions](UndefinedInitialDataInfiniteOptions.md), but `queryFn` may not be @@ -36,20 +36,20 @@ The type of a single page, as your `queryFn` resolves it. ### TError -`TError` = `DefaultError` +`TError` = [`DefaultError`](DefaultError.md) The type of errors your `queryFn` may throw. ### TData -`TData` = `InfiniteData`\<`TQueryFnData`\> +`TData` = [`InfiniteData`](../interfaces/InfiniteData.md)\<`TQueryFnData`\> The type `data` ends up as after `select` runs — defaults to `InfiniteData`, the shape of all fetched pages plus their page params. ### TQueryKey -`TQueryKey` *extends* `QueryKey` = `QueryKey` +`TQueryKey` *extends* [`QueryKey`](QueryKey.md) = [`QueryKey`](QueryKey.md) The type of your `queryKey`. diff --git a/docs/framework/preact/reference/type-aliases/UnusedSkipTokenOptions.md b/docs/framework/preact/reference/type-aliases/UnusedSkipTokenOptions.md index a7348d4794b..889574a8381 100644 --- a/docs/framework/preact/reference/type-aliases/UnusedSkipTokenOptions.md +++ b/docs/framework/preact/reference/type-aliases/UnusedSkipTokenOptions.md @@ -7,7 +7,7 @@ title: UnusedSkipTokenOptions type UnusedSkipTokenOptions = OmitKeyof, "queryFn"> & object; ``` -Defined in: [preact-query/src/queryOptions.ts:51](https://github.com/TanStack/query/blob/main/packages/preact-query/src/queryOptions.ts#L51) +Defined in: [packages/preact-query/src/queryOptions.ts:51](https://github.com/TanStack/query/blob/main/packages/preact-query/src/queryOptions.ts#L51) The options accepted by the `queryOptions` overload selected when no `initialData` is set and `queryFn` is not `skipToken` — same as [UndefinedInitialDataOptions](UndefinedInitialDataOptions.md), but `queryFn` may not be `skipToken`. @@ -35,7 +35,7 @@ The type your `queryFn` resolves to. ### TError -`TError` = `DefaultError` +`TError` = [`DefaultError`](DefaultError.md) The type of errors your `queryFn` may throw. @@ -47,6 +47,6 @@ The type `data` ends up as after `select` runs. ### TQueryKey -`TQueryKey` *extends* `QueryKey` = `QueryKey` +`TQueryKey` *extends* [`QueryKey`](QueryKey.md) = [`QueryKey`](QueryKey.md) The type of your `queryKey`. diff --git a/docs/framework/preact/reference/type-aliases/Updater.md b/docs/framework/preact/reference/type-aliases/Updater.md new file mode 100644 index 00000000000..7a0c2f30503 --- /dev/null +++ b/docs/framework/preact/reference/type-aliases/Updater.md @@ -0,0 +1,35 @@ +--- +id: Updater +title: Updater +--- + +```ts +type Updater = TOutput | (input) => TOutput; +``` + +Defined in: [packages/query-core/src/utils.ts:105](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L105) + +Either a plain value of type `TOutput`, or a function that receives `TInput` and returns `TOutput`. +Used for example by `setQueryData`-style updaters, which accept either the new data directly or a +function that computes it from the previous data. See functionalUpdate. + +## Type Parameters + +### TInput + +`TInput` + +### TOutput + +`TOutput` + +## Example + +```ts +queryClient.setQueryData(['posts'], newPosts) + +// Or, using an updater function that receives the current data: +queryClient.setQueryData(['posts'], (oldPosts) => + oldPosts ? [...oldPosts, newPost] : oldPosts, +) +``` diff --git a/docs/framework/preact/reference/type-aliases/UseBaseMutationResult.md b/docs/framework/preact/reference/type-aliases/UseBaseMutationResult.md index 26ff1767535..5a473c0895c 100644 --- a/docs/framework/preact/reference/type-aliases/UseBaseMutationResult.md +++ b/docs/framework/preact/reference/type-aliases/UseBaseMutationResult.md @@ -9,9 +9,9 @@ type UseBaseMutationResult = Overrid }> & object; ``` -Defined in: [preact-query/src/types.ts:470](https://github.com/TanStack/query/blob/main/packages/preact-query/src/types.ts#L470) +Defined in: [packages/preact-query/src/types.ts:470](https://github.com/TanStack/query/blob/main/packages/preact-query/src/types.ts#L470) -The result of `useMutation`. Same as MutationObserverResult from `@tanstack/query-core`, with +The result of `useMutation`. Same as [MutationObserverResult](MutationObserverResult.md) from `@tanstack/query-core`, with `mutate` narrowed to the fire-and-forget [UseMutateFunction](UseMutateFunction.md) signature, plus the added `mutateAsync`. ## Type Declaration @@ -34,7 +34,7 @@ The type your mutation function resolves to. ### TError -`TError` = `DefaultError` +`TError` = [`DefaultError`](DefaultError.md) The type of errors your mutation function may throw. diff --git a/docs/framework/preact/reference/type-aliases/UseBaseQueryResult.md b/docs/framework/preact/reference/type-aliases/UseBaseQueryResult.md index b0f507866a6..ea1c6c715f1 100644 --- a/docs/framework/preact/reference/type-aliases/UseBaseQueryResult.md +++ b/docs/framework/preact/reference/type-aliases/UseBaseQueryResult.md @@ -7,10 +7,10 @@ title: UseBaseQueryResult type UseBaseQueryResult = QueryObserverResult; ``` -Defined in: [preact-query/src/types.ts:313](https://github.com/TanStack/query/blob/main/packages/preact-query/src/types.ts#L313) +Defined in: [packages/preact-query/src/types.ts:313](https://github.com/TanStack/query/blob/main/packages/preact-query/src/types.ts#L313) The result of `useQuery` when `initialData` isn't set — `data` may be `undefined` while the query is -`pending`. Re-exports QueryObserverResult from `@tanstack/query-core`. `useInfiniteQuery` returns +`pending`. Re-exports [QueryObserverResult](QueryObserverResult.md) from `@tanstack/query-core`. `useInfiniteQuery` returns [UseInfiniteQueryResult](UseInfiniteQueryResult.md) instead. ## Type Parameters @@ -23,6 +23,6 @@ The type `data` ends up as after `select` runs. ### TError -`TError` = `DefaultError` +`TError` = [`DefaultError`](DefaultError.md) The type of errors your `queryFn` may throw. diff --git a/docs/framework/preact/reference/type-aliases/UseInfiniteQueryResult.md b/docs/framework/preact/reference/type-aliases/UseInfiniteQueryResult.md index 54dbc0e5546..5440118cb12 100644 --- a/docs/framework/preact/reference/type-aliases/UseInfiniteQueryResult.md +++ b/docs/framework/preact/reference/type-aliases/UseInfiniteQueryResult.md @@ -7,10 +7,10 @@ title: UseInfiniteQueryResult type UseInfiniteQueryResult = InfiniteQueryObserverResult; ``` -Defined in: [preact-query/src/types.ts:364](https://github.com/TanStack/query/blob/main/packages/preact-query/src/types.ts#L364) +Defined in: [packages/preact-query/src/types.ts:364](https://github.com/TanStack/query/blob/main/packages/preact-query/src/types.ts#L364) The result of `useInfiniteQuery` when `initialData` isn't set — `data` may be `undefined` while the query is -`pending`. Re-exports InfiniteQueryObserverResult from `@tanstack/query-core`. +`pending`. Re-exports [InfiniteQueryObserverResult](InfiniteQueryObserverResult.md) from `@tanstack/query-core`. ## Type Parameters @@ -22,6 +22,6 @@ The type `data` ends up as after `select` runs. ### TError -`TError` = `DefaultError` +`TError` = [`DefaultError`](DefaultError.md) The type of errors your `queryFn` may throw. diff --git a/docs/framework/preact/reference/type-aliases/UseMutateAsyncFunction.md b/docs/framework/preact/reference/type-aliases/UseMutateAsyncFunction.md index 5bb4bd25bd8..edcdd01ae2e 100644 --- a/docs/framework/preact/reference/type-aliases/UseMutateAsyncFunction.md +++ b/docs/framework/preact/reference/type-aliases/UseMutateAsyncFunction.md @@ -7,7 +7,7 @@ title: UseMutateAsyncFunction type UseMutateAsyncFunction = MutateFunction; ``` -Defined in: [preact-query/src/types.ts:453](https://github.com/TanStack/query/blob/main/packages/preact-query/src/types.ts#L453) +Defined in: [packages/preact-query/src/types.ts:453](https://github.com/TanStack/query/blob/main/packages/preact-query/src/types.ts#L453) The type of `mutateAsync`, as returned by `useMutation`. Similar to [UseMutateFunction](UseMutateFunction.md), but returns a promise which can be awaited. @@ -22,7 +22,7 @@ The type your mutation function resolves to. ### TError -`TError` = `DefaultError` +`TError` = [`DefaultError`](DefaultError.md) The type of errors your mutation function may throw. diff --git a/docs/framework/preact/reference/type-aliases/UseMutateFunction.md b/docs/framework/preact/reference/type-aliases/UseMutateFunction.md index 9037b6fe893..3cadb2b52de 100644 --- a/docs/framework/preact/reference/type-aliases/UseMutateFunction.md +++ b/docs/framework/preact/reference/type-aliases/UseMutateFunction.md @@ -7,7 +7,7 @@ title: UseMutateFunction type UseMutateFunction = (...args) => void; ``` -Defined in: [preact-query/src/types.ts:432](https://github.com/TanStack/query/blob/main/packages/preact-query/src/types.ts#L432) +Defined in: [packages/preact-query/src/types.ts:432](https://github.com/TanStack/query/blob/main/packages/preact-query/src/types.ts#L432) The type of `mutate`, as returned by `useMutation`. Forwards the variables (and an optional per-call `onSuccess`/`onError`/`onSettled`) to the underlying `mutate` call. Fire-and-forget — errors are surfaced @@ -23,7 +23,7 @@ The type your mutation function resolves to. ### TError -`TError` = `DefaultError` +`TError` = [`DefaultError`](DefaultError.md) The type of errors your mutation function may throw. @@ -44,7 +44,7 @@ their `onMutateResult` parameter — useful for optimistic-update rollback data. ### args -...`Parameters`\<`MutateFunction`\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\>\> +...`Parameters`\<[`MutateFunction`](MutateFunction.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\>\> ## Returns diff --git a/docs/framework/preact/reference/type-aliases/UseMutationResult.md b/docs/framework/preact/reference/type-aliases/UseMutationResult.md index 4c188cdab72..1e0a4631542 100644 --- a/docs/framework/preact/reference/type-aliases/UseMutationResult.md +++ b/docs/framework/preact/reference/type-aliases/UseMutationResult.md @@ -7,7 +7,7 @@ title: UseMutationResult type UseMutationResult = UseBaseMutationResult; ``` -Defined in: [preact-query/src/types.ts:499](https://github.com/TanStack/query/blob/main/packages/preact-query/src/types.ts#L499) +Defined in: [packages/preact-query/src/types.ts:499](https://github.com/TanStack/query/blob/main/packages/preact-query/src/types.ts#L499) The result of `useMutation`. Same as [UseBaseMutationResult](UseBaseMutationResult.md). @@ -21,7 +21,7 @@ The type your mutation function resolves to. ### TError -`TError` = `DefaultError` +`TError` = [`DefaultError`](DefaultError.md) The type of errors your mutation function may throw. diff --git a/docs/framework/preact/reference/type-aliases/UsePrefetchInfiniteQueryOptions.md b/docs/framework/preact/reference/type-aliases/UsePrefetchInfiniteQueryOptions.md index a8e1d3d7814..cd947efe149 100644 --- a/docs/framework/preact/reference/type-aliases/UsePrefetchInfiniteQueryOptions.md +++ b/docs/framework/preact/reference/type-aliases/UsePrefetchInfiniteQueryOptions.md @@ -7,7 +7,7 @@ title: UsePrefetchInfiniteQueryOptions type UsePrefetchInfiniteQueryOptions = DistributiveOmit, "queryFn"> & object; ``` -Defined in: [preact-query/src/types.ts:117](https://github.com/TanStack/query/blob/main/packages/preact-query/src/types.ts#L117) +Defined in: [packages/preact-query/src/types.ts:117](https://github.com/TanStack/query/blob/main/packages/preact-query/src/types.ts#L117) The options accepted by `usePrefetchInfiniteQuery` — everything you can pass to `queryClient.infiniteQuery`, except `queryFn` is required unless a default query function has been defined. @@ -33,7 +33,7 @@ The type of a single page, as your `queryFn` resolves it. ### TError -`TError` = `DefaultError` +`TError` = [`DefaultError`](DefaultError.md) The type of errors your `queryFn` may throw. @@ -47,7 +47,7 @@ elsewhere with `select` applied. ### TQueryKey -`TQueryKey` *extends* `QueryKey` = `QueryKey` +`TQueryKey` *extends* [`QueryKey`](QueryKey.md) = [`QueryKey`](QueryKey.md) The type of your `queryKey`. diff --git a/docs/framework/preact/reference/type-aliases/UsePrefetchQueryOptions.md b/docs/framework/preact/reference/type-aliases/UsePrefetchQueryOptions.md index 43af626af99..205248982af 100644 --- a/docs/framework/preact/reference/type-aliases/UsePrefetchQueryOptions.md +++ b/docs/framework/preact/reference/type-aliases/UsePrefetchQueryOptions.md @@ -7,7 +7,7 @@ title: UsePrefetchQueryOptions type UsePrefetchQueryOptions = DistributiveOmit, "queryFn"> & object; ``` -Defined in: [preact-query/src/types.ts:79](https://github.com/TanStack/query/blob/main/packages/preact-query/src/types.ts#L79) +Defined in: [packages/preact-query/src/types.ts:79](https://github.com/TanStack/query/blob/main/packages/preact-query/src/types.ts#L79) The options accepted by `usePrefetchQuery` — everything you can pass to `queryClient.query`, except `queryFn` is required unless a default query function has been defined. @@ -33,7 +33,7 @@ The type your `queryFn` resolves to. ### TError -`TError` = `DefaultError` +`TError` = [`DefaultError`](DefaultError.md) The type of errors your `queryFn` may throw. @@ -53,6 +53,6 @@ The type of the data actually held in the query cache — the input to `select` ### TQueryKey -`TQueryKey` *extends* `QueryKey` = `QueryKey` +`TQueryKey` *extends* [`QueryKey`](QueryKey.md) = [`QueryKey`](QueryKey.md) The type of your `queryKey`. diff --git a/docs/framework/preact/reference/type-aliases/UseQueryResult.md b/docs/framework/preact/reference/type-aliases/UseQueryResult.md index bea7c541fa0..0efa733923e 100644 --- a/docs/framework/preact/reference/type-aliases/UseQueryResult.md +++ b/docs/framework/preact/reference/type-aliases/UseQueryResult.md @@ -7,7 +7,7 @@ title: UseQueryResult type UseQueryResult = UseBaseQueryResult; ``` -Defined in: [preact-query/src/types.ts:324](https://github.com/TanStack/query/blob/main/packages/preact-query/src/types.ts#L324) +Defined in: [packages/preact-query/src/types.ts:324](https://github.com/TanStack/query/blob/main/packages/preact-query/src/types.ts#L324) The result of `useQuery`. Same as [UseBaseQueryResult](UseBaseQueryResult.md). @@ -21,6 +21,6 @@ The type `data` ends up as after `select` runs. ### TError -`TError` = `DefaultError` +`TError` = [`DefaultError`](DefaultError.md) The type of errors your `queryFn` may throw. diff --git a/docs/framework/preact/reference/type-aliases/UseSuspenseInfiniteQueryResult.md b/docs/framework/preact/reference/type-aliases/UseSuspenseInfiniteQueryResult.md index 15c418f8526..038e3614cc9 100644 --- a/docs/framework/preact/reference/type-aliases/UseSuspenseInfiniteQueryResult.md +++ b/docs/framework/preact/reference/type-aliases/UseSuspenseInfiniteQueryResult.md @@ -7,7 +7,7 @@ title: UseSuspenseInfiniteQueryResult type UseSuspenseInfiniteQueryResult = OmitKeyof, "isPlaceholderData">; ``` -Defined in: [preact-query/src/types.ts:388](https://github.com/TanStack/query/blob/main/packages/preact-query/src/types.ts#L388) +Defined in: [packages/preact-query/src/types.ts:388](https://github.com/TanStack/query/blob/main/packages/preact-query/src/types.ts#L388) The result of `useSuspenseInfiniteQuery`. Same as [DefinedUseInfiniteQueryResult](DefinedUseInfiniteQueryResult.md), minus `isPlaceholderData` — Suspense hooks never render placeholder data. @@ -22,6 +22,6 @@ The type `data` ends up as after `select` runs. ### TError -`TError` = `DefaultError` +`TError` = [`DefaultError`](DefaultError.md) The type of errors your `queryFn` may throw. diff --git a/docs/framework/preact/reference/type-aliases/UseSuspenseQueryResult.md b/docs/framework/preact/reference/type-aliases/UseSuspenseQueryResult.md index a013593070d..697bff07606 100644 --- a/docs/framework/preact/reference/type-aliases/UseSuspenseQueryResult.md +++ b/docs/framework/preact/reference/type-aliases/UseSuspenseQueryResult.md @@ -7,7 +7,7 @@ title: UseSuspenseQueryResult type UseSuspenseQueryResult = DistributiveOmit, "isPlaceholderData">; ``` -Defined in: [preact-query/src/types.ts:336](https://github.com/TanStack/query/blob/main/packages/preact-query/src/types.ts#L336) +Defined in: [packages/preact-query/src/types.ts:336](https://github.com/TanStack/query/blob/main/packages/preact-query/src/types.ts#L336) The result of `useSuspenseQuery`. Same as [DefinedUseQueryResult](DefinedUseQueryResult.md), minus `isPlaceholderData` — always `false` on that type, so this drops the dead field rather than an active state. @@ -22,6 +22,6 @@ The type `data` ends up as after `select` runs. ### TError -`TError` = `DefaultError` +`TError` = [`DefaultError`](DefaultError.md) The type of errors your `queryFn` may throw. diff --git a/docs/framework/preact/reference/type-aliases/WithRequired.md b/docs/framework/preact/reference/type-aliases/WithRequired.md new file mode 100644 index 00000000000..a40a48c865b --- /dev/null +++ b/docs/framework/preact/reference/type-aliases/WithRequired.md @@ -0,0 +1,20 @@ +--- +id: WithRequired +title: WithRequired +--- + +```ts +type WithRequired = TTarget & { [_ in TKey]: {} }; +``` + +Defined in: [packages/query-core/src/types.ts:524](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L524) + +## Type Parameters + +### TTarget + +`TTarget` + +### TKey + +`TKey` *extends* keyof `TTarget` diff --git a/docs/framework/preact/reference/type-aliases/dataTagErrorSymbol.md b/docs/framework/preact/reference/type-aliases/dataTagErrorSymbol.md new file mode 100644 index 00000000000..26148a94d6e --- /dev/null +++ b/docs/framework/preact/reference/type-aliases/dataTagErrorSymbol.md @@ -0,0 +1,10 @@ +--- +id: dataTagErrorSymbol +title: dataTagErrorSymbol +--- + +```ts +type dataTagErrorSymbol = typeof dataTagErrorSymbol; +``` + +Defined in: [packages/query-core/src/types.ts:63](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L63) diff --git a/docs/framework/preact/reference/type-aliases/dataTagSymbol.md b/docs/framework/preact/reference/type-aliases/dataTagSymbol.md new file mode 100644 index 00000000000..0012c108cc5 --- /dev/null +++ b/docs/framework/preact/reference/type-aliases/dataTagSymbol.md @@ -0,0 +1,10 @@ +--- +id: dataTagSymbol +title: dataTagSymbol +--- + +```ts +type dataTagSymbol = typeof dataTagSymbol; +``` + +Defined in: [packages/query-core/src/types.ts:61](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L61) diff --git a/docs/framework/preact/reference/variables/IsRestoringProvider.md b/docs/framework/preact/reference/variables/IsRestoringProvider.md index 42069e45fc2..bc8bb54d50a 100644 --- a/docs/framework/preact/reference/variables/IsRestoringProvider.md +++ b/docs/framework/preact/reference/variables/IsRestoringProvider.md @@ -7,7 +7,7 @@ title: IsRestoringProvider const IsRestoringProvider: Provider = IsRestoringContext.Provider; ``` -Defined in: [preact-query/src/IsRestoringProvider.ts:19](https://github.com/TanStack/query/blob/main/packages/preact-query/src/IsRestoringProvider.ts#L19) +Defined in: [packages/preact-query/src/IsRestoringProvider.ts:19](https://github.com/TanStack/query/blob/main/packages/preact-query/src/IsRestoringProvider.ts#L19) The Provider that `PersistQueryClientProvider` uses to signal whether a persisted client is currently being restored, read by `useIsRestoring`. diff --git a/docs/framework/preact/reference/variables/QueryClientContext.md b/docs/framework/preact/reference/variables/QueryClientContext.md index fa7a465d171..44ef915c669 100644 --- a/docs/framework/preact/reference/variables/QueryClientContext.md +++ b/docs/framework/preact/reference/variables/QueryClientContext.md @@ -7,6 +7,6 @@ title: QueryClientContext const QueryClientContext: Context; ``` -Defined in: [preact-query/src/QueryClientProvider.tsx:9](https://github.com/TanStack/query/blob/main/packages/preact-query/src/QueryClientProvider.tsx#L9) +Defined in: [packages/preact-query/src/QueryClientProvider.tsx:9](https://github.com/TanStack/query/blob/main/packages/preact-query/src/QueryClientProvider.tsx#L9) The context that `useQueryClient` reads from. `QueryClientProvider` is the normal way to set it. diff --git a/docs/framework/preact/reference/variables/dataTagErrorSymbol.md b/docs/framework/preact/reference/variables/dataTagErrorSymbol.md new file mode 100644 index 00000000000..20bab62fb01 --- /dev/null +++ b/docs/framework/preact/reference/variables/dataTagErrorSymbol.md @@ -0,0 +1,10 @@ +--- +id: dataTagErrorSymbol +title: dataTagErrorSymbol +--- + +```ts +const dataTagErrorSymbol: typeof dataTagErrorSymbol; +``` + +Defined in: [packages/query-core/src/types.ts:63](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L63) diff --git a/docs/framework/preact/reference/variables/dataTagSymbol.md b/docs/framework/preact/reference/variables/dataTagSymbol.md new file mode 100644 index 00000000000..83dd68a56e9 --- /dev/null +++ b/docs/framework/preact/reference/variables/dataTagSymbol.md @@ -0,0 +1,10 @@ +--- +id: dataTagSymbol +title: dataTagSymbol +--- + +```ts +const dataTagSymbol: typeof dataTagSymbol; +``` + +Defined in: [packages/query-core/src/types.ts:61](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L61) diff --git a/docs/framework/preact/reference/variables/defaultScheduler.md b/docs/framework/preact/reference/variables/defaultScheduler.md new file mode 100644 index 00000000000..70e14d3f846 --- /dev/null +++ b/docs/framework/preact/reference/variables/defaultScheduler.md @@ -0,0 +1,13 @@ +--- +id: defaultScheduler +title: defaultScheduler +--- + +```ts +const defaultScheduler: ScheduleFunction = systemSetTimeoutZero; +``` + +Defined in: [packages/query-core/src/notifyManager.ts:19](https://github.com/TanStack/query/blob/main/packages/query-core/src/notifyManager.ts#L19) + +Default scheduling function used by the notify manager. +Schedules the callback with the system's `setTimeout(callback, 0)`. diff --git a/docs/framework/preact/reference/variables/environmentManager.md b/docs/framework/preact/reference/variables/environmentManager.md new file mode 100644 index 00000000000..ed333b8747b --- /dev/null +++ b/docs/framework/preact/reference/variables/environmentManager.md @@ -0,0 +1,59 @@ +--- +id: environmentManager +title: environmentManager +--- + +```ts +const environmentManager: object; +``` + +Defined in: [packages/query-core/src/environmentManager.ts:29](https://github.com/TanStack/query/blob/main/packages/query-core/src/environmentManager.ts#L29) + +Manages how TanStack Query detects whether the current runtime should be treated as +server-side, which disables scheduling refetch timers and changes the default `retry` count +and `gcTime`. By default, the detection treats a missing `window` (or the presence of a +`Deno` global) as server. + +Override this for runtimes where that default detection would give the wrong answer — for +example, a Service Worker, where `window` is undefined even though the environment should +behave like a client. + +## Type Declaration + +### isServer() + +```ts +isServer: () => boolean; +``` + +Returns whether the current runtime should be treated as a server environment. + +#### Returns + +`boolean` + +### setIsServer() + +```ts +setIsServer(isServerValue): void; +``` + +Overrides the server check globally. + +#### Parameters + +##### isServerValue + +`IsServerValue` + +#### Returns + +`void` + +## Example + +```ts +import { environmentManager } from '@tanstack/query-core' + +environmentManager.setIsServer(() => false) +``` diff --git a/docs/framework/preact/reference/variables/focusManager.md b/docs/framework/preact/reference/variables/focusManager.md new file mode 100644 index 00000000000..86477849e06 --- /dev/null +++ b/docs/framework/preact/reference/variables/focusManager.md @@ -0,0 +1,12 @@ +--- +id: focusManager +title: focusManager +--- + +```ts +const focusManager: FocusManager; +``` + +Defined in: [packages/query-core/src/focusManager.ts:142](https://github.com/TanStack/query/blob/main/packages/query-core/src/focusManager.ts#L142) + +Singleton instance of [FocusManager](../interfaces/FocusManager.md), used to manage and observe the focus state within TanStack Query. diff --git a/docs/framework/preact/reference/variables/isServer.md b/docs/framework/preact/reference/variables/isServer.md new file mode 100644 index 00000000000..16aa39d1244 --- /dev/null +++ b/docs/framework/preact/reference/variables/isServer.md @@ -0,0 +1,14 @@ +--- +id: isServer +title: isServer +--- + +```ts +const isServer: boolean; +``` + +Defined in: [packages/query-core/src/utils.ts:114](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L114) + +## Deprecated + +use `environmentManager.isServer()` instead. diff --git a/docs/framework/preact/reference/variables/notifyManager.md b/docs/framework/preact/reference/variables/notifyManager.md new file mode 100644 index 00000000000..4bdf3478be0 --- /dev/null +++ b/docs/framework/preact/reference/variables/notifyManager.md @@ -0,0 +1,166 @@ +--- +id: notifyManager +title: notifyManager +--- + +```ts +const notifyManager: object; +``` + +Defined in: [packages/query-core/src/notifyManager.ts:144](https://github.com/TanStack/query/blob/main/packages/query-core/src/notifyManager.ts#L144) + +Handles scheduling and batching callbacks in TanStack Query. + +## Type Declaration + +### batch() + +```ts +readonly batch: (callback) => T; +``` + +Batches all updates scheduled inside the passed callback. +This is mainly used internally to optimize query client updating. +Batches can be nested; the queue is only flushed once the outermost `batch` call finishes. +The return value of `callback` is passed through. + +#### Type Parameters + +##### T + +`T` + +#### Parameters + +##### callback + +() => `T` + +#### Returns + +`T` + +### batchCalls() + +```ts +readonly batchCalls: (callback) => BatchCallsCallback; +``` + +All calls to the wrapped function will be batched. + +#### Type Parameters + +##### T + +`T` *extends* `unknown`[] + +#### Parameters + +##### callback + +`BatchCallsCallback`\<`T`\> + +#### Returns + +`BatchCallsCallback`\<`T`\> + +### schedule() + +```ts +schedule: (callback) => void; +``` + +Schedules a function to be run on the next batch. +By default, the batch is run with a `setTimeout`, but this can be configured via `setScheduler`. + +#### Parameters + +##### callback + +`NotifyCallback` + +#### Returns + +`void` + +### setBatchNotifyFunction() + +```ts +readonly setBatchNotifyFunction: (fn) => void; +``` + +Use this method to set a custom function to batch notifications together into a single tick. +Framework adapters use this to plug in their own batching primitive, so that a single query +update only triggers one re-render instead of one per subscriber. + +#### Parameters + +##### fn + +`BatchNotifyFunction` + +#### Returns + +`void` + +#### Example + +```ts +import { notifyManager } from '@tanstack/query-core' +import { batch } from 'solid-js' + +notifyManager.setBatchNotifyFunction(batch) +``` + +### setNotifyFunction() + +```ts +readonly setNotifyFunction: (fn) => void; +``` + +Use this method to set a custom notify function. +This can be used to for example wrap notifications with `React.act` while running tests. + +#### Parameters + +##### fn + +`NotifyFunction` + +#### Returns + +`void` + +### setScheduler() + +```ts +readonly setScheduler: (fn) => void; +``` + +Configures a custom callback that schedules when the next batch runs. +The default behavior is `setTimeout(callback, 0)`. + +#### Parameters + +##### fn + +`ScheduleFunction` + +#### Returns + +`void` + +#### Example + +```ts +import { notifyManager } from '@tanstack/query-core' + +// Schedule batches in the next microtask +notifyManager.setScheduler(queueMicrotask) + +// Schedule batches before the next frame is rendered +notifyManager.setScheduler(requestAnimationFrame) + +// Schedule batches some time in the future +notifyManager.setScheduler((cb) => setTimeout(cb, 10)) +``` diff --git a/docs/framework/preact/reference/variables/onlineManager.md b/docs/framework/preact/reference/variables/onlineManager.md new file mode 100644 index 00000000000..2eeec5385d8 --- /dev/null +++ b/docs/framework/preact/reference/variables/onlineManager.md @@ -0,0 +1,12 @@ +--- +id: onlineManager +title: onlineManager +--- + +```ts +const onlineManager: OnlineManager; +``` + +Defined in: [packages/query-core/src/onlineManager.ts:117](https://github.com/TanStack/query/blob/main/packages/query-core/src/onlineManager.ts#L117) + +Singleton instance of [OnlineManager](../interfaces/OnlineManager.md), used to manage and observe the online state within TanStack Query. diff --git a/docs/framework/preact/reference/variables/skipToken.md b/docs/framework/preact/reference/variables/skipToken.md new file mode 100644 index 00000000000..a390d0b7b66 --- /dev/null +++ b/docs/framework/preact/reference/variables/skipToken.md @@ -0,0 +1,23 @@ +--- +id: skipToken +title: skipToken +--- + +```ts +const skipToken: typeof skipToken; +``` + +Defined in: [packages/query-core/src/utils.ts:522](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L522) + +Sentinel value that can be passed as a query's `queryFn` to conditionally disable the query (equivalent +to `enabled: false`) while preserving full type inference for the query's data. Unlike `enabled: false`, +a query disabled via `skipToken` cannot be triggered with `refetch`. + +## Example + +```ts +new QueryObserver(queryClient, { + queryKey: ['post', postId], + queryFn: postId != null ? () => fetchPost(postId) : skipToken, +}) +``` diff --git a/docs/framework/preact/reference/variables/timeoutManager.md b/docs/framework/preact/reference/variables/timeoutManager.md new file mode 100644 index 00000000000..1eca1a5f343 --- /dev/null +++ b/docs/framework/preact/reference/variables/timeoutManager.md @@ -0,0 +1,12 @@ +--- +id: timeoutManager +title: timeoutManager +--- + +```ts +const timeoutManager: TimeoutManager; +``` + +Defined in: [packages/query-core/src/timeoutManager.ts:232](https://github.com/TanStack/query/blob/main/packages/query-core/src/timeoutManager.ts#L232) + +Singleton instance of [TimeoutManager](../interfaces/TimeoutManager.md), used throughout TanStack Query to schedule and cancel timers. diff --git a/docs/framework/preact/reference/variables/unsetMarker.md b/docs/framework/preact/reference/variables/unsetMarker.md new file mode 100644 index 00000000000..d19ee65b38e --- /dev/null +++ b/docs/framework/preact/reference/variables/unsetMarker.md @@ -0,0 +1,10 @@ +--- +id: unsetMarker +title: unsetMarker +--- + +```ts +const unsetMarker: typeof unsetMarker; +``` + +Defined in: [packages/query-core/src/types.ts:65](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L65) diff --git a/docs/framework/react/guides/migrating-to-react-query-4.md b/docs/framework/react/guides/migrating-to-react-query-4.md index 0735d8c58b2..0a6cbe5805c 100644 --- a/docs/framework/react/guides/migrating-to-react-query-4.md +++ b/docs/framework/react/guides/migrating-to-react-query-4.md @@ -242,7 +242,7 @@ The filter defaults to `all`, and you can choose to only match `active` or `inac #### refetchActive / refetchInactive -[queryClient.invalidateQueries](../../../reference/QueryClient.md#queryclientinvalidatequeries) had two additional, similar flags: +[queryClient.invalidateQueries](../reference/classes/QueryClient.md#invalidatequeries) had two additional, similar flags: ``` refetchActive: Boolean @@ -427,7 +427,7 @@ React Query defaults to "tracking" query properties, which should give you a nic ### Bailing out of updates with setQueryData -When using the [functional updater form of setQueryData](../../../reference/QueryClient.md#queryclientsetquerydata), you can now bail out of the update by returning `undefined`. This is helpful if `undefined` is given to you as `previousValue`, which means that currently, no cached entry exists and you don't want to / cannot create one, like in the example of toggling a todo: +When using the [functional updater form of setQueryData](../reference/classes/QueryClient.md#setquerydata), you can now bail out of the update by returning `undefined`. This is helpful if `undefined` is given to you as `previousValue`, which means that currently, no cached entry exists and you don't want to / cannot create one, like in the example of toggling a todo: ```tsx queryClient.setQueryData(['todo', id], (previousTodo) => diff --git a/docs/framework/react/guides/mutations.md b/docs/framework/react/guides/mutations.md index c7b71c46f6d..abfececc98f 100644 --- a/docs/framework/react/guides/mutations.md +++ b/docs/framework/react/guides/mutations.md @@ -59,7 +59,7 @@ Beyond those primary states, more information is available depending on the stat In the example above, you also saw that you can pass variables to your mutations function by calling the `mutate` function with a **single variable or object**. -Even with just variables, mutations aren't all that special, but when used with the `onSuccess` option, the [Query Client's `invalidateQueries` method](../../../reference/QueryClient.md#queryclientinvalidatequeries) and the [Query Client's `setQueryData` method](../../../reference/QueryClient.md#queryclientsetquerydata), mutations become a very powerful tool. +Even with just variables, mutations aren't all that special, but when used with the `onSuccess` option, the [Query Client's `invalidateQueries` method](../reference/classes/QueryClient.md#invalidatequeries) and the [Query Client's `setQueryData` method](../reference/classes/QueryClient.md#setquerydata), mutations become a very powerful tool. [//]: # 'Info1' diff --git a/docs/framework/react/guides/network-mode.md b/docs/framework/react/guides/network-mode.md index 6457f6b1458..0e9a7183eb3 100644 --- a/docs/framework/react/guides/network-mode.md +++ b/docs/framework/react/guides/network-mode.md @@ -37,7 +37,7 @@ In those situations, the first fetch might succeed because it comes from an offl ## Devtools -The [TanStack Query Devtools](../devtools.md) will show Queries in a `paused` state if they would be fetching, but there is no network connection. There is also a toggle button to _Mock offline behavior_. Please note that this button will _not_ actually mess with your network connection (you can do that in the browser devtools), but it will set the [OnlineManager](../../../reference/onlineManager.md) in an offline state. +The [TanStack Query Devtools](../devtools.md) will show Queries in a `paused` state if they would be fetching, but there is no network connection. There is also a toggle button to _Mock offline behavior_. Please note that this button will _not_ actually mess with your network connection (you can do that in the browser devtools), but it will set the [OnlineManager](../reference/interfaces/OnlineManager.md) in an offline state. ## Signature diff --git a/docs/framework/react/guides/prefetching.md b/docs/framework/react/guides/prefetching.md index 5b5260838dc..917f2d44097 100644 --- a/docs/framework/react/guides/prefetching.md +++ b/docs/framework/react/guides/prefetching.md @@ -448,7 +448,7 @@ Integration with other routers is also possible, see the [react-router](../examp ## Manually Priming a Query -If you already have the data for your query synchronously available, you don't need to prefetch it. You can just use the [Query Client's `setQueryData` method](../../../reference/QueryClient.md#queryclientsetquerydata) to directly add or update a query's cached result by key. +If you already have the data for your query synchronously available, you don't need to prefetch it. You can just use the [Query Client's `setQueryData` method](../reference/classes/QueryClient.md#setquerydata) to directly add or update a query's cached result by key. [//]: # 'ExampleManualPriming' diff --git a/docs/framework/react/guides/query-functions.md b/docs/framework/react/guides/query-functions.md index e121bab54a2..ab7cf0aada7 100644 --- a/docs/framework/react/guides/query-functions.md +++ b/docs/framework/react/guides/query-functions.md @@ -102,7 +102,7 @@ function fetchTodoList({ queryKey }) { The `QueryFunctionContext` is the object passed to each query function. It consists of: - `queryKey: QueryKey`: [Query Keys](./query-keys.md) -- `client: QueryClient`: [QueryClient](../../../reference/QueryClient.md) +- `client: QueryClient`: [QueryClient](../reference/classes/QueryClient.md) - `signal?: AbortSignal` - [AbortSignal](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal) instance provided by TanStack Query - Can be used for [Query Cancellation](./query-cancellation.md) diff --git a/docs/framework/react/guides/ssr.md b/docs/framework/react/guides/ssr.md index 7a30d8e77a8..95792f21ac9 100644 --- a/docs/framework/react/guides/ssr.md +++ b/docs/framework/react/guides/ssr.md @@ -556,7 +556,7 @@ On the server, `gcTime` defaults to `Infinity` which disables manual garbage col Avoid setting `gcTime` to `0` as it may result in a hydration error. This occurs because the [Hydration Boundary](../reference/functions/HydrationBoundary.md) places necessary data into the cache for rendering, but if the garbage collector removes the data before the rendering completes, issues may arise. If you require a shorter `gcTime`, we recommend setting it to `2 * 1000` to allow sufficient time for the app to reference the data. -To clear the cache after it is not needed and to lower memory consumption, you can add a call to [`queryClient.clear()`](../../../reference/QueryClient.md#queryclientclear) after the request is handled and dehydrated state has been sent to the client. +To clear the cache after it is not needed and to lower memory consumption, you can add a call to [`queryClient.clear()`](../reference/classes/QueryClient.md#clear) after the request is handled and dehydrated state has been sent to the client. Alternatively, you can set a smaller `gcTime`. diff --git a/docs/framework/react/guides/updates-from-mutation-responses.md b/docs/framework/react/guides/updates-from-mutation-responses.md index f3a582805df..4e744d92c70 100644 --- a/docs/framework/react/guides/updates-from-mutation-responses.md +++ b/docs/framework/react/guides/updates-from-mutation-responses.md @@ -3,7 +3,7 @@ id: updates-from-mutation-responses title: Updates from Mutation Responses --- -When dealing with mutations that **update** objects on the server, it's common for the new object to be automatically returned in the response of the mutation. Instead of refetching any queries for that item and wasting a network call for data we already have, we can take advantage of the object returned by the mutation function and update the existing query with the new data immediately using the [Query Client's `setQueryData`](../../../reference/QueryClient.md#queryclientsetquerydata) method: +When dealing with mutations that **update** objects on the server, it's common for the new object to be automatically returned in the response of the mutation. Instead of refetching any queries for that item and wasting a network call for data we already have, we can take advantage of the object returned by the mutation function and update the existing query with the new data immediately using the [Query Client's `setQueryData`](../reference/classes/QueryClient.md#setquerydata) method: [//]: # 'Example' diff --git a/docs/framework/react/plugins/persistQueryClient.md b/docs/framework/react/plugins/persistQueryClient.md index 2dc8a86e187..2597610f356 100644 --- a/docs/framework/react/plugins/persistQueryClient.md +++ b/docs/framework/react/plugins/persistQueryClient.md @@ -21,7 +21,7 @@ It should be set as the same value or higher than persistQueryClient's `maxAge` You can also pass it `Infinity` to disable garbage collection behavior entirely. -Due to a JavaScript limitation, the maximum allowed `gcTime` is about [24 days](https://developer.mozilla.org/en-US/docs/Web/API/setTimeout#maximum_delay_value), although it is possible to work around this limit using [timeoutManager.setTimeoutProvider](../../../reference/timeoutManager.md#timeoutmanagersettimeoutprovider). +Due to a JavaScript limitation, the maximum allowed `gcTime` is about [24 days](https://developer.mozilla.org/en-US/docs/Web/API/setTimeout#maximum_delay_value), although it is possible to work around this limit using [timeoutManager.setTimeoutProvider](../reference/interfaces/TimeoutManager.md#settimeoutprovider). ```tsx const queryClient = new QueryClient({ @@ -217,7 +217,7 @@ ReactDOM.createRoot(rootElement).render( - `onSuccess?: () => Promise | unknown` - optional - will be called when the initial restore is finished - - can be used to [resumePausedMutations](../../../reference/QueryClient.md#queryclientresumepausedmutations) + - can be used to [resumePausedMutations](../reference/classes/QueryClient.md#resumepausedmutations) - if a Promise is returned, it will be awaited; restoring is seen as ongoing until then - `onError?: () => Promise | unknown` - optional diff --git a/docs/framework/react/reference/classes/CancelledError.md b/docs/framework/react/reference/classes/CancelledError.md new file mode 100644 index 00000000000..7fded5da20f --- /dev/null +++ b/docs/framework/react/reference/classes/CancelledError.md @@ -0,0 +1,273 @@ +--- +id: CancelledError +title: CancelledError +--- + +Defined in: [packages/query-core/src/retryer.ts:77](https://github.com/TanStack/query/blob/main/packages/query-core/src/retryer.ts#L77) + +The error thrown by a `Retryer` (and surfaced to `query.promise`/`mutation`) when a fetch is cancelled, e.g. via +`query.cancel()`. `revert`, if `true`, tells the caller to restore the state the query was in before the fetch +started instead of surfacing the error. `silent`, if `true`, tells the caller to suppress this error and instead +resolve with the promise of the fetch that triggered the cancellation. + +## Example + +```ts +query.cancel() + +try { + await query.promise +} catch (error) { + if (error instanceof CancelledError) { + // the fetch was cancelled, e.g. via `query.cancel()` + } +} +``` + +## Extends + +- `Error` + +## Constructors + +### Constructor + +```ts +new CancelledError(options?): CancelledError; +``` + +Defined in: [packages/query-core/src/retryer.ts:80](https://github.com/TanStack/query/blob/main/packages/query-core/src/retryer.ts#L80) + +#### Parameters + +##### options? + +[`CancelOptions`](../interfaces/CancelOptions.md) + +#### Returns + +`CancelledError` + +#### Overrides + +```ts +Error.constructor +``` + +## Properties + +### cause? + +```ts +optional cause: unknown; +``` + +Defined in: node\_modules/.pnpm/typescript@6.0.3/node\_modules/typescript/lib/lib.es2022.error.d.ts:24 + +#### Inherited from + +```ts +Error.cause +``` + +*** + +### message + +```ts +message: string; +``` + +Defined in: node\_modules/.pnpm/typescript@6.0.3/node\_modules/typescript/lib/lib.es5.d.ts:1075 + +#### Inherited from + +```ts +Error.message +``` + +*** + +### name + +```ts +name: string; +``` + +Defined in: node\_modules/.pnpm/typescript@6.0.3/node\_modules/typescript/lib/lib.es5.d.ts:1074 + +#### Inherited from + +```ts +Error.name +``` + +*** + +### revert? + +```ts +optional revert: boolean; +``` + +Defined in: [packages/query-core/src/retryer.ts:78](https://github.com/TanStack/query/blob/main/packages/query-core/src/retryer.ts#L78) + +*** + +### silent? + +```ts +optional silent: boolean; +``` + +Defined in: [packages/query-core/src/retryer.ts:79](https://github.com/TanStack/query/blob/main/packages/query-core/src/retryer.ts#L79) + +*** + +### stack? + +```ts +optional stack: string; +``` + +Defined in: node\_modules/.pnpm/typescript@6.0.3/node\_modules/typescript/lib/lib.es5.d.ts:1076 + +#### Inherited from + +```ts +Error.stack +``` + +*** + +### stackTraceLimit + +```ts +static stackTraceLimit: number; +``` + +Defined in: node\_modules/.pnpm/@types+node@22.19.15/node\_modules/@types/node/globals.d.ts:68 + +The `Error.stackTraceLimit` property specifies the number of stack frames +collected by a stack trace (whether generated by `new Error().stack` or +`Error.captureStackTrace(obj)`). + +The default value is `10` but may be set to any valid JavaScript number. Changes +will affect any stack trace captured _after_ the value has been changed. + +If set to a non-number value, or set to a negative number, stack traces will +not capture any frames. + +#### Inherited from + +```ts +Error.stackTraceLimit +``` + +## Methods + +### captureStackTrace() + +```ts +static captureStackTrace(targetObject, constructorOpt?): void; +``` + +Defined in: node\_modules/.pnpm/@types+node@22.19.15/node\_modules/@types/node/globals.d.ts:52 + +Creates a `.stack` property on `targetObject`, which when accessed returns +a string representing the location in the code at which +`Error.captureStackTrace()` was called. + +```js +const myObject = {}; +Error.captureStackTrace(myObject); +myObject.stack; // Similar to `new Error().stack` +``` + +The first line of the trace will be prefixed with +`${myObject.name}: ${myObject.message}`. + +The optional `constructorOpt` argument accepts a function. If given, all frames +above `constructorOpt`, including `constructorOpt`, will be omitted from the +generated stack trace. + +The `constructorOpt` argument is useful for hiding implementation +details of error generation from the user. For instance: + +```js +function a() { + b(); +} + +function b() { + c(); +} + +function c() { + // Create an error without stack trace to avoid calculating the stack trace twice. + const { stackTraceLimit } = Error; + Error.stackTraceLimit = 0; + const error = new Error(); + Error.stackTraceLimit = stackTraceLimit; + + // Capture the stack trace above function b + Error.captureStackTrace(error, b); // Neither function c, nor b is included in the stack trace + throw error; +} + +a(); +``` + +#### Parameters + +##### targetObject + +`object` + +##### constructorOpt? + +`Function` + +#### Returns + +`void` + +#### Inherited from + +```ts +Error.captureStackTrace +``` + +*** + +### prepareStackTrace() + +```ts +static prepareStackTrace(err, stackTraces): any; +``` + +Defined in: node\_modules/.pnpm/@types+node@22.19.15/node\_modules/@types/node/globals.d.ts:56 + +#### Parameters + +##### err + +`Error` + +##### stackTraces + +`CallSite`[] + +#### Returns + +`any` + +#### See + +https://v8.dev/docs/stack-trace-api#customizing-stack-traces + +#### Inherited from + +```ts +Error.prepareStackTrace +``` diff --git a/docs/framework/react/reference/classes/InfiniteQueryObserver.md b/docs/framework/react/reference/classes/InfiniteQueryObserver.md new file mode 100644 index 00000000000..4ced8b25507 --- /dev/null +++ b/docs/framework/react/reference/classes/InfiniteQueryObserver.md @@ -0,0 +1,668 @@ +--- +id: InfiniteQueryObserver +title: InfiniteQueryObserver +redirect_from: + - reference/InfiniteQueryObserver + - framework/react/reference/InfiniteQueryObserver +--- + +Defined in: [packages/query-core/src/infiniteQueryObserver.ts:41](https://github.com/TanStack/query/blob/main/packages/query-core/src/infiniteQueryObserver.ts#L41) + +An `InfiniteQueryObserver` extends `QueryObserver` to observe and switch +between infinite queries. It augments the base `QueryObserverResult` with +infinite-query-specific fields and methods, such as `hasNextPage` and +`fetchNextPage`, and is the primitive that framework adapters (e.g. +`useInfiniteQuery`) build their hooks on top of. + +## Example + +```ts +const observer = new InfiniteQueryObserver(queryClient, { + queryKey: ['projects'], + queryFn: ({ pageParam }) => fetchProjects(pageParam), + initialPageParam: 0, + getNextPageParam: (lastPage) => lastPage.nextCursor, +}) + +const unsubscribe = observer.subscribe((result) => console.log(result)) +``` + +## Extends + +- [`QueryObserver`](QueryObserver.md)\<`TQueryFnData`, `TError`, `TData`, [`InfiniteData`](../interfaces/InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\> + +## Type Parameters + +### TQueryFnData + +`TQueryFnData` = `unknown` + +### TError + +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) + +### TData + +`TData` = [`InfiniteData`](../interfaces/InfiniteData.md)\<`TQueryFnData`\> + +### TQueryKey + +`TQueryKey` *extends* [`QueryKey`](../type-aliases/QueryKey.md) = [`QueryKey`](../type-aliases/QueryKey.md) + +### TPageParam + +`TPageParam` = `unknown` + +## Constructors + +### Constructor + +```ts +new InfiniteQueryObserver(client, options): InfiniteQueryObserver; +``` + +Defined in: [packages/query-core/src/infiniteQueryObserver.ts:83](https://github.com/TanStack/query/blob/main/packages/query-core/src/infiniteQueryObserver.ts#L83) + +#### Parameters + +##### client + +[`QueryClient`](QueryClient.md) + +##### options + +[`InfiniteQueryObserverOptions`](../interfaces/InfiniteQueryObserverOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`, `TPageParam`\> + +#### Returns + +`InfiniteQueryObserver`\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`, `TPageParam`\> + +#### Overrides + +[`QueryObserver`](QueryObserver.md).[`constructor`](QueryObserver.md#constructor) + +## Properties + +### fetch + +```ts +protected fetch: ReplaceReturnType<(fetchOptions) => Promise>, Promise>>; +``` + +Defined in: [packages/query-core/src/infiniteQueryObserver.ts:72](https://github.com/TanStack/query/blob/main/packages/query-core/src/infiniteQueryObserver.ts#L72) + +#### Overrides + +```ts +QueryObserver.fetch +``` + +*** + +### getCurrentResult + +```ts +getCurrentResult: ReplaceReturnType<() => QueryObserverResult, InfiniteQueryObserverResult>; +``` + +Defined in: [packages/query-core/src/infiniteQueryObserver.ts:60](https://github.com/TanStack/query/blob/main/packages/query-core/src/infiniteQueryObserver.ts#L60) + +Returns the most recently computed `QueryObserverResult` for the +observed query. This is a point-in-time read; to be notified of updates +as they happen, subscribe to the observer instead (its inherited +`subscribe` method). + +#### Example + +```ts +const result = observer.getCurrentResult() +console.log(result.status, result.data) +``` + +#### Overrides + +```ts +QueryObserver.getCurrentResult +``` + +*** + +### listeners + +```ts +protected listeners: Set>; +``` + +Defined in: [packages/query-core/src/subscribable.ts:2](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L2) + +#### Inherited from + +[`QueryObserver`](QueryObserver.md).[`listeners`](QueryObserver.md#listeners) + +*** + +### options + +```ts +options: QueryObserverOptions, TQueryKey>; +``` + +Defined in: [packages/query-core/src/queryObserver.ts:89](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L89) + +#### Inherited from + +[`QueryObserver`](QueryObserver.md).[`options`](QueryObserver.md#options) + +*** + +### subscribe() + +```ts +subscribe: (listener) => () => void; +``` + +Defined in: [packages/query-core/src/infiniteQueryObserver.ts:55](https://github.com/TanStack/query/blob/main/packages/query-core/src/infiniteQueryObserver.ts#L55) + +#### Parameters + +##### listener + +`InfiniteQueryObserverListener` + +#### Returns + +```ts +(): void; +``` + +##### Returns + +`void` + +#### Overrides + +```ts +QueryObserver.subscribe +``` + +## Methods + +### bindMethods() + +```ts +protected bindMethods(): void; +``` + +Defined in: [packages/query-core/src/infiniteQueryObserver.ts:96](https://github.com/TanStack/query/blob/main/packages/query-core/src/infiniteQueryObserver.ts#L96) + +#### Returns + +`void` + +#### Overrides + +[`QueryObserver`](QueryObserver.md).[`bindMethods`](QueryObserver.md#bindmethods) + +*** + +### createResult() + +```ts +protected createResult(query, options): InfiniteQueryObserverResult; +``` + +Defined in: [packages/query-core/src/infiniteQueryObserver.ts:201](https://github.com/TanStack/query/blob/main/packages/query-core/src/infiniteQueryObserver.ts#L201) + +#### Parameters + +##### query + +[`Query`](Query.md)\<`TQueryFnData`, `TError`, [`InfiniteData`](../interfaces/InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\> + +##### options + +[`InfiniteQueryObserverOptions`](../interfaces/InfiniteQueryObserverOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`, `TPageParam`\> + +#### Returns + +[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\> + +#### Overrides + +[`QueryObserver`](QueryObserver.md).[`createResult`](QueryObserver.md#createresult) + +*** + +### destroy() + +```ts +destroy(): void; +``` + +Defined in: [packages/query-core/src/queryObserver.ts:161](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L161) + +Stops observing the current query: clears all listeners, cancels the +stale and refetch-interval timers, and removes this observer from the +query it was observing. + +#### Returns + +`void` + +#### Inherited from + +[`QueryObserver`](QueryObserver.md).[`destroy`](QueryObserver.md#destroy) + +*** + +### fetchNextPage() + +```ts +fetchNextPage(options?): Promise>; +``` + +Defined in: [packages/query-core/src/infiniteQueryObserver.ts:161](https://github.com/TanStack/query/blob/main/packages/query-core/src/infiniteQueryObserver.ts#L161) + +Fetches the next page of the infinite query and returns a promise that +resolves with the resulting `InfiniteQueryObserverResult`. The page +param used for the fetch is determined by `getNextPageParam`, which +receives the current pages/page params and whose result also determines +`hasNextPage`. + +#### Parameters + +##### options? + +[`FetchNextPageOptions`](../interfaces/FetchNextPageOptions.md) + +#### Returns + +`Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> + +#### Example + +```ts +const { hasNextPage } = observer.getCurrentResult() + +if (hasNextPage) { + await observer.fetchNextPage() +} +``` + +#### See + +[InfiniteQueryObserver#fetchPreviousPage](#fetchpreviouspage) + +*** + +### fetchOptimistic() + +```ts +fetchOptimistic(options): Promise>; +``` + +Defined in: [packages/query-core/src/queryObserver.ts:395](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L395) + +Fetches a query defined by the given options without affecting this +observer's own tracked query or result, and returns a promise that +resolves with the `QueryObserverResult` for that fetch. This is useful +for prefetching data that another observer (e.g. a query about to be +navigated to) will need, ahead of time. + +#### Parameters + +##### options + +[`QueryObserverOptions`](../interfaces/QueryObserverOptions.md)\<`TQueryFnData`, `TError`, `TData`, [`InfiniteData`](../interfaces/InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\> + +#### Returns + +`Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> + +#### Example + +```ts +const result = await observer.fetchOptimistic({ + queryKey: ['posts', 2], + queryFn: () => fetchPost(2), +}) +console.log(result.data) +``` + +#### Inherited from + +[`QueryObserver`](QueryObserver.md).[`fetchOptimistic`](QueryObserver.md#fetchoptimistic) + +*** + +### fetchPreviousPage() + +```ts +fetchPreviousPage(options?): Promise>; +``` + +Defined in: [packages/query-core/src/infiniteQueryObserver.ts:190](https://github.com/TanStack/query/blob/main/packages/query-core/src/infiniteQueryObserver.ts#L190) + +Fetches the previous page of the infinite query and returns a promise +that resolves with the resulting `InfiniteQueryObserverResult`. The page +param used for the fetch is determined by `getPreviousPageParam`, which +receives the current pages/page params and whose result also determines +`hasPreviousPage`. + +#### Parameters + +##### options? + +[`FetchPreviousPageOptions`](../interfaces/FetchPreviousPageOptions.md) + +#### Returns + +`Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> + +#### Example + +```ts +const { hasPreviousPage } = observer.getCurrentResult() + +if (hasPreviousPage) { + await observer.fetchPreviousPage() +} +``` + +#### See + +[InfiniteQueryObserver#fetchNextPage](#fetchnextpage) + +*** + +### getCurrentQuery() + +```ts +getCurrentQuery(): Query, TQueryKey>; +``` + +Defined in: [packages/query-core/src/queryObserver.ts:357](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L357) + +Returns the `Query` instance this observer is currently observing. + +#### Returns + +[`Query`](Query.md)\<`TQueryFnData`, `TError`, [`InfiniteData`](../interfaces/InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\> + +#### Inherited from + +[`QueryObserver`](QueryObserver.md).[`getCurrentQuery`](QueryObserver.md#getcurrentquery) + +*** + +### getOptimisticResult() + +```ts +getOptimisticResult(options): InfiniteQueryObserverResult; +``` + +Defined in: [packages/query-core/src/infiniteQueryObserver.ts:127](https://github.com/TanStack/query/blob/main/packages/query-core/src/infiniteQueryObserver.ts#L127) + +The infinite-query counterpart of [QueryObserver#getOptimisticResult](QueryObserver.md#getoptimisticresult), marking the +options as an infinite query before delegating to it. Called by framework adapters (e.g. +`useInfiniteQuery`) ahead of subscribing, to compute the current `InfiniteQueryObserverResult` +synchronously. + +#### Parameters + +##### options + +[`DefaultedInfiniteQueryObserverOptions`](../type-aliases/DefaultedInfiniteQueryObserverOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`, `TPageParam`\> + +#### Returns + +[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\> + +#### Overrides + +[`QueryObserver`](QueryObserver.md).[`getOptimisticResult`](QueryObserver.md#getoptimisticresult) + +*** + +### hasListeners() + +```ts +hasListeners(): boolean; +``` + +Defined in: [packages/query-core/src/subscribable.ts:19](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L19) + +#### Returns + +`boolean` + +#### Inherited from + +[`QueryObserver`](QueryObserver.md).[`hasListeners`](QueryObserver.md#haslisteners) + +*** + +### onSubscribe() + +```ts +protected onSubscribe(): void; +``` + +Defined in: [packages/query-core/src/queryObserver.ts:110](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L110) + +#### Returns + +`void` + +#### Inherited from + +[`QueryObserver`](QueryObserver.md).[`onSubscribe`](QueryObserver.md#onsubscribe) + +*** + +### onUnsubscribe() + +```ts +protected onUnsubscribe(): void; +``` + +Defined in: [packages/query-core/src/queryObserver.ts:124](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L124) + +#### Returns + +`void` + +#### Inherited from + +[`QueryObserver`](QueryObserver.md).[`onUnsubscribe`](QueryObserver.md#onunsubscribe) + +*** + +### refetch() + +```ts +refetch(__namedParameters): Promise>; +``` + +Defined in: [packages/query-core/src/queryObserver.ts:371](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L371) + +Refetches the observed query and returns a promise that resolves with +the resulting `QueryObserverResult`. + +#### Parameters + +##### \_\_namedParameters + +[`RefetchOptions`](../interfaces/RefetchOptions.md) = `{}` + +#### Returns + +`Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> + +#### Example + +```ts +const result = await observer.refetch({ cancelRefetch: false }) +console.log(result.data) +``` + +#### Inherited from + +[`QueryObserver`](QueryObserver.md).[`refetch`](QueryObserver.md#refetch) + +*** + +### setOptions() + +```ts +setOptions(options): void; +``` + +Defined in: [packages/query-core/src/infiniteQueryObserver.ts:108](https://github.com/TanStack/query/blob/main/packages/query-core/src/infiniteQueryObserver.ts#L108) + +Updates the observer's options. Behaves the same as +`QueryObserver.setOptions`, additionally marking the options as +belonging to an infinite query before delegating to the base +implementation. + +#### Parameters + +##### options + +[`InfiniteQueryObserverOptions`](../interfaces/InfiniteQueryObserverOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`, `TPageParam`\> + +#### Returns + +`void` + +#### Overrides + +[`QueryObserver`](QueryObserver.md).[`setOptions`](QueryObserver.md#setoptions) + +*** + +### shouldFetchOnReconnect() + +```ts +shouldFetchOnReconnect(): boolean; +``` + +Defined in: [packages/query-core/src/queryObserver.ts:135](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L135) + +Returns whether the observed query is currently stale and configured +(via the `refetchOnReconnect` option) to refetch when the network +reconnects. + +#### Returns + +`boolean` + +#### Inherited from + +[`QueryObserver`](QueryObserver.md).[`shouldFetchOnReconnect`](QueryObserver.md#shouldfetchonreconnect) + +*** + +### shouldFetchOnWindowFocus() + +```ts +shouldFetchOnWindowFocus(): boolean; +``` + +Defined in: [packages/query-core/src/queryObserver.ts:148](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L148) + +Returns whether the observed query is currently stale and configured +(via the `refetchOnWindowFocus` option) to refetch when the window +regains focus. + +#### Returns + +`boolean` + +#### Inherited from + +[`QueryObserver`](QueryObserver.md).[`shouldFetchOnWindowFocus`](QueryObserver.md#shouldfetchonwindowfocus) + +*** + +### trackProp() + +```ts +trackProp(key): void; +``` + +Defined in: [packages/query-core/src/queryObserver.ts:350](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L350) + +Records that the given `QueryObserverResult` property was read, so a subsequent update only +notifies this observer if a tracked property actually changed. Normally called indirectly via +[QueryObserver#trackResult](QueryObserver.md#trackresult)'s proxy; exposed directly for adapters that track property +access themselves (e.g. through their own reactivity system) instead of via the proxy. + +#### Parameters + +##### key + +`"error"` | `"data"` | `"isError"` | `"isPending"` | `"isLoading"` | `"isLoadingError"` | `"isRefetchError"` | `"isSuccess"` | `"isPlaceholderData"` | `"status"` | `"dataUpdatedAt"` | `"errorUpdatedAt"` | `"failureCount"` | `"failureReason"` | `"errorUpdateCount"` | `"isFetched"` | `"isFetchedAfterMount"` | `"isFetching"` | `"isInitialLoading"` | `"isPaused"` | `"isRefetching"` | `"isStale"` | `"isEnabled"` | `"refetch"` | `"fetchStatus"` + +#### Returns + +`void` + +#### Inherited from + +[`QueryObserver`](QueryObserver.md).[`trackProp`](QueryObserver.md#trackprop) + +*** + +### trackResult() + +```ts +trackResult(result, onPropTracked?): QueryObserverResult; +``` + +Defined in: [packages/query-core/src/queryObserver.ts:331](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L331) + +Wraps a `QueryObserverResult` in a `Proxy` that records which properties are read, via +[QueryObserver#trackProp](QueryObserver.md#trackprop) (and an optional `onPropTracked` callback). Used by framework +adapters when `notifyOnChangeProps` is not set, to implement its default "only re-render on +properties you actually read" behavior. + +#### Parameters + +##### result + +[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\> + +##### onPropTracked? + +(`key`) => `void` + +#### Returns + +[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\> + +#### Inherited from + +[`QueryObserver`](QueryObserver.md).[`trackResult`](QueryObserver.md#trackresult) + +*** + +### updateResult() + +```ts +updateResult(): void; +``` + +Defined in: [packages/query-core/src/queryObserver.ts:735](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L735) + +Recomputes and stores the current result from the current query/options, notifying listeners +if it changed. Framework adapters call this right after subscribing to make sure no query +update was missed in the gap between creating the observer and subscribing to it. + +#### Returns + +`void` + +#### Inherited from + +[`QueryObserver`](QueryObserver.md).[`updateResult`](QueryObserver.md#updateresult) diff --git a/docs/framework/react/reference/classes/Mutation.md b/docs/framework/react/reference/classes/Mutation.md new file mode 100644 index 00000000000..e038a9cd394 --- /dev/null +++ b/docs/framework/react/reference/classes/Mutation.md @@ -0,0 +1,330 @@ +--- +id: Mutation +title: Mutation +--- + +Defined in: [packages/query-core/src/mutation.ts:135](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L135) + +Represents a single mutation attempt. A `Mutation` holds the mutation's +options, state (data/error/status), and the `MutationObserver`s currently +subscribed to it. + +Instances are created and managed internally by `MutationCache`; application +code typically interacts with mutations indirectly through `QueryClient` or +a framework hook like `useMutation`. Direct access to a `Mutation` instance +is possible via `mutationCache.find()`/`getAll()` for inspecting cache state. + +## Example + +```ts +const mutationCache = queryClient.getMutationCache() + +const mutation = mutationCache.find({ mutationKey: ['addPost'] }) +``` + +## Extends + +- `Removable` + +## Type Parameters + +### TData + +`TData` = `unknown` + +### TError + +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) + +### TVariables + +`TVariables` = `unknown` + +### TOnMutateResult + +`TOnMutateResult` = `unknown` + +## Constructors + +### Constructor + +```ts +new Mutation(config): Mutation; +``` + +Defined in: [packages/query-core/src/mutation.ts:152](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L152) + +#### Parameters + +##### config + +`MutationConfig`\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\> + +#### Returns + +`Mutation`\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\> + +#### Overrides + +```ts +Removable.constructor +``` + +## Properties + +### gcTime + +```ts +gcTime: number; +``` + +Defined in: [packages/query-core/src/removable.ts:7](https://github.com/TanStack/query/blob/main/packages/query-core/src/removable.ts#L7) + +#### Inherited from + +```ts +Removable.gcTime +``` + +*** + +### mutationId + +```ts +readonly mutationId: number; +``` + +Defined in: [packages/query-core/src/mutation.ts:143](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L143) + +*** + +### options + +```ts +options: MutationOptions; +``` + +Defined in: [packages/query-core/src/mutation.ts:142](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L142) + +*** + +### state + +```ts +state: MutationState; +``` + +Defined in: [packages/query-core/src/mutation.ts:141](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L141) + +## Accessors + +### meta + +#### Get Signature + +```ts +get meta(): Record | undefined; +``` + +Defined in: [packages/query-core/src/mutation.ts:179](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L179) + +The `meta` object passed in the mutation's options, if any. + +##### Returns + +`Record`\<`string`, `unknown`\> \| `undefined` + +## Methods + +### clearGcTimeout() + +```ts +protected clearGcTimeout(): void; +``` + +Defined in: [packages/query-core/src/removable.ts:32](https://github.com/TanStack/query/blob/main/packages/query-core/src/removable.ts#L32) + +#### Returns + +`void` + +#### Inherited from + +```ts +Removable.clearGcTimeout +``` + +*** + +### continue() + +```ts +continue(): Promise; +``` + +Defined in: [packages/query-core/src/mutation.ts:243](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L243) + +Resumes a mutation that is currently paused or was restored from a +dehydrated, still-`pending` state. + +- If this mutation has an active retryer (it paused mid-attempt, e.g. due + to the network mode or scope-based queuing), its retryer is resumed. +- Otherwise, if the mutation's status is still `pending` (e.g. it was + dehydrated while an attempt was in flight and never got a retryer in + this instance), `execute` is called again with the last known variables. +- Otherwise the mutation has already settled and this resolves immediately + without running anything again. + +#### Returns + +`Promise`\<`unknown`\> + +#### Example + +```ts +// typically driven by reconnect handling, e.g. queryClient.resumePausedMutations() +const mutation = mutationCache.find({ mutationKey: ['addPost'] }) +await mutation?.continue() +``` + +#### See + +[Mutation#execute](#execute) + +*** + +### destroy() + +```ts +destroy(): void; +``` + +Defined in: [packages/query-core/src/removable.ts:10](https://github.com/TanStack/query/blob/main/packages/query-core/src/removable.ts#L10) + +#### Returns + +`void` + +#### Inherited from + +```ts +Removable.destroy +``` + +*** + +### execute() + +```ts +execute(variables): Promise; +``` + +Defined in: [packages/query-core/src/mutation.ts:284](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L284) + +Runs the mutation function for the given variables through a retryer, and +drives the mutation's state and lifecycle callbacks through to settlement. + +If this mutation's state is already `pending` when `execute` is called +(i.e. it was restored, still in-flight, from a dehydrated state), the +`onMutate` step is skipped and a `continue` action is dispatched to +unpause it; otherwise a `pending` action is dispatched first, then the +mutation cache's `onMutate` and the mutation's own `onMutate` option are +awaited in that order, and the resulting context is stored. + +The mutation function is then run (subject to `retry`/`retryDelay`/ +`networkMode`, and to the mutation cache's scope-based serialization). +On success, the cache's `onSuccess`/`onSettled` callbacks run before the +mutation's own `onSuccess`/`onSettled` options, a `success` action is +dispatched, and the resolved data is returned. On failure, the same +cache-then-option ordering is used for `onError`/`onSettled`, but each of +those four callbacks is individually caught so that a throwing callback +cannot mask the original error; an `error` action is then dispatched and +the original error is re-thrown. + +#### Parameters + +##### variables + +`TVariables` + +#### Returns + +`Promise`\<`TData`\> + +#### Example + +```ts +// Called internally by `MutationObserver.mutate` and `Mutation.continue` — +// applications normally trigger mutations through those, not this method. +const data = await mutation.execute(variables) +``` + +#### See + +[Mutation#continue](#continue) + +*** + +### optionalRemove() + +```ts +protected optionalRemove(): void; +``` + +Defined in: [packages/query-core/src/mutation.ts:212](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L212) + +#### Returns + +`void` + +#### Overrides + +```ts +Removable.optionalRemove +``` + +*** + +### scheduleGc() + +```ts +protected scheduleGc(): void; +``` + +Defined in: [packages/query-core/src/removable.ts:14](https://github.com/TanStack/query/blob/main/packages/query-core/src/removable.ts#L14) + +#### Returns + +`void` + +#### Inherited from + +```ts +Removable.scheduleGc +``` + +*** + +### updateGcTime() + +```ts +protected updateGcTime(newGcTime): void; +``` + +Defined in: [packages/query-core/src/removable.ts:24](https://github.com/TanStack/query/blob/main/packages/query-core/src/removable.ts#L24) + +#### Parameters + +##### newGcTime + +`number` | `undefined` + +#### Returns + +`void` + +#### Inherited from + +```ts +Removable.updateGcTime +``` diff --git a/docs/framework/react/reference/classes/MutationCache.md b/docs/framework/react/reference/classes/MutationCache.md new file mode 100644 index 00000000000..039964564e8 --- /dev/null +++ b/docs/framework/react/reference/classes/MutationCache.md @@ -0,0 +1,319 @@ +--- +id: MutationCache +title: MutationCache +redirect_from: + - reference/MutationCache + - framework/react/reference/MutationCache +--- + +Defined in: [packages/query-core/src/mutationCache.ts:124](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationCache.ts#L124) + +The `MutationCache` is the storage for mutations. + +Normally, you will not interact with the `MutationCache` directly and instead use a +`QueryClient`. You can subscribe to it (inherited from `Subscribable`) to be informed of +safe/known updates to the cache, such as mutations being added, removed, or updated. + +## Example + +```ts +const unsubscribe = mutationCache.subscribe((event) => { + console.log(event.type, event.mutation) +}) +``` + +## Extends + +- `Subscribable`\<`MutationCacheListener`\> + +## Constructors + +### Constructor + +```ts +new MutationCache(config): MutationCache; +``` + +Defined in: [packages/query-core/src/mutationCache.ts:129](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationCache.ts#L129) + +#### Parameters + +##### config + +[`MutationCacheConfig`](../interfaces/MutationCacheConfig.md) = `{}` + +#### Returns + +`MutationCache` + +#### Overrides + +```ts +Subscribable.constructor +``` + +## Properties + +### config + +```ts +config: MutationCacheConfig = {}; +``` + +Defined in: [packages/query-core/src/mutationCache.ts:129](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationCache.ts#L129) + +*** + +### listeners + +```ts +protected listeners: Set; +``` + +Defined in: [packages/query-core/src/subscribable.ts:2](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L2) + +#### Inherited from + +```ts +Subscribable.listeners +``` + +## Methods + +### clear() + +```ts +clear(): void; +``` + +Defined in: [packages/query-core/src/mutationCache.ts:236](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationCache.ts#L236) + +Removes all mutations from the cache. + +#### Returns + +`void` + +#### Example + +```ts +const mutationCache = queryClient.getMutationCache() + +mutationCache.clear() +``` + +*** + +### find() + +```ts +find(filters): + | Mutation + | undefined; +``` + +Defined in: [packages/query-core/src/mutationCache.ts:278](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationCache.ts#L278) + +A slightly more advanced method that can be used to get an existing mutation instance from +the cache. If the mutation does not exist, `undefined` is returned. + +This is not typically needed for most applications, but can come in handy when needing more +information about a mutation in rare scenarios. + +#### Type Parameters + +##### TData + +`TData` = `unknown` + +##### TError + +`TError` = `Error` + +##### TVariables + +`TVariables` = `any` + +##### TOnMutateResult + +`TOnMutateResult` = `unknown` + +#### Parameters + +##### filters + +[`MutationFilters`](../interfaces/MutationFilters.md) + +#### Returns + + \| [`Mutation`](Mutation.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\> + \| `undefined` + +#### See + +[MutationCache#findAll](#findall) + +#### Example + +```ts +const mutationCache = queryClient.getMutationCache() + +const mutation = mutationCache.find({ mutationKey: ['addPost'] }) +``` + +*** + +### findAll() + +```ts +findAll(filters): Mutation[]; +``` + +Defined in: [packages/query-core/src/mutationCache.ts:308](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationCache.ts#L308) + +An even more advanced method that can be used to get existing mutation instances from the +cache that match the given filters. If no mutations match, an empty array is returned. + +This is not typically needed for most applications, but can come in handy when needing more +information about mutations in rare scenarios. + +#### Parameters + +##### filters + +[`MutationFilters`](../interfaces/MutationFilters.md) = `{}` + +#### Returns + +[`Mutation`](Mutation.md)\<`unknown`, `Error`, `unknown`, `unknown`\>[] + +#### See + +[MutationCache#find](#find) + +#### Example + +```ts +const mutationCache = queryClient.getMutationCache() + +const mutations = mutationCache.findAll({ mutationKey: ['addPost'] }) +``` + +*** + +### getAll() + +```ts +getAll(): Mutation[]; +``` + +Defined in: [packages/query-core/src/mutationCache.ts:259](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationCache.ts#L259) + +Returns all mutations within the cache. + +This is not typically needed for most applications, but can come in handy when needing more +information about a mutation in rare scenarios. + +#### Returns + +[`Mutation`](Mutation.md)\<`unknown`, `Error`, `unknown`, `unknown`\>[] + +#### Example + +```ts +const mutationCache = queryClient.getMutationCache() + +const mutations = mutationCache.getAll() +``` + +*** + +### hasListeners() + +```ts +hasListeners(): boolean; +``` + +Defined in: [packages/query-core/src/subscribable.ts:19](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L19) + +#### Returns + +`boolean` + +#### Inherited from + +```ts +Subscribable.hasListeners +``` + +*** + +### onSubscribe() + +```ts +protected onSubscribe(): void; +``` + +Defined in: [packages/query-core/src/subscribable.ts:23](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L23) + +#### Returns + +`void` + +#### Inherited from + +```ts +Subscribable.onSubscribe +``` + +*** + +### onUnsubscribe() + +```ts +protected onUnsubscribe(): void; +``` + +Defined in: [packages/query-core/src/subscribable.ts:27](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L27) + +#### Returns + +`void` + +#### Inherited from + +```ts +Subscribable.onUnsubscribe +``` + +*** + +### subscribe() + +```ts +subscribe(listener): () => void; +``` + +Defined in: [packages/query-core/src/subscribable.ts:8](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L8) + +#### Parameters + +##### listener + +`MutationCacheListener` + +#### Returns + +```ts +(): void; +``` + +##### Returns + +`void` + +#### Inherited from + +```ts +Subscribable.subscribe +``` diff --git a/docs/framework/react/reference/classes/MutationObserver.md b/docs/framework/react/reference/classes/MutationObserver.md new file mode 100644 index 00000000000..a121c67b0e8 --- /dev/null +++ b/docs/framework/react/reference/classes/MutationObserver.md @@ -0,0 +1,335 @@ +--- +id: MutationObserver +title: MutationObserver +--- + +Defined in: [packages/query-core/src/mutationObserver.ts:38](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationObserver.ts#L38) + +Observes a single mutation and derives a `MutationObserverResult` from it. +A framework hook like `useMutation` creates one `MutationObserver` per hook +call, keeps it stable across re-renders, calls `setOptions` when the options +passed to the hook change, subscribes to it to re-render on updates, and +reads `getCurrentResult()` for the value to return. Calling `mutate()` +builds a new underlying `Mutation` in the `MutationCache` and executes it. + +## Example + +```ts +const observer = new MutationObserver(queryClient, { + mutationFn: (variables: { title: string }) => addPost(variables), +}) +``` + +## Extends + +- `Subscribable`\<`MutationObserverListener`\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\>\> + +## Type Parameters + +### TData + +`TData` = `unknown` + +### TError + +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) + +### TVariables + +`TVariables` = `void` + +### TOnMutateResult + +`TOnMutateResult` = `unknown` + +## Constructors + +### Constructor + +```ts +new MutationObserver(client, options): MutationObserver; +``` + +Defined in: [packages/query-core/src/mutationObserver.ts:58](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationObserver.ts#L58) + +#### Parameters + +##### client + +[`QueryClient`](QueryClient.md) + +##### options + +[`MutationObserverOptions`](../interfaces/MutationObserverOptions.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\> + +#### Returns + +`MutationObserver`\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\> + +#### Overrides + +```ts +Subscribable< + MutationObserverListener +>.constructor +``` + +## Properties + +### listeners + +```ts +protected listeners: Set>; +``` + +Defined in: [packages/query-core/src/subscribable.ts:2](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L2) + +#### Inherited from + +```ts +Subscribable.listeners +``` + +*** + +### options + +```ts +options: MutationObserverOptions; +``` + +Defined in: [packages/query-core/src/mutationObserver.ts:46](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationObserver.ts#L46) + +## Methods + +### bindMethods() + +```ts +protected bindMethods(): void; +``` + +Defined in: [packages/query-core/src/mutationObserver.ts:75](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationObserver.ts#L75) + +#### Returns + +`void` + +*** + +### getCurrentResult() + +```ts +getCurrentResult(): MutationObserverResult; +``` + +Defined in: [packages/query-core/src/mutationObserver.ts:155](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationObserver.ts#L155) + +Returns the observer's current result, derived from the observed +mutation's state (or the default, `idle` state if no mutation has been +built yet, e.g. before the first `mutate()` call or after `reset()`). + +#### Returns + +[`MutationObserverResult`](../type-aliases/MutationObserverResult.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\> + +*** + +### hasListeners() + +```ts +hasListeners(): boolean; +``` + +Defined in: [packages/query-core/src/subscribable.ts:19](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L19) + +#### Returns + +`boolean` + +#### Inherited from + +```ts +Subscribable.hasListeners +``` + +*** + +### mutate() + +```ts +mutate(variables, options?): Promise; +``` + +Defined in: [packages/query-core/src/mutationObserver.ts:207](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationObserver.ts#L207) + +Builds a new `Mutation` in the `MutationCache` using the observer's +current options, detaches this observer from any previously observed +mutation, attaches it to the new one, and executes it with the given +variables. + +The optional per-call `options` (`onSuccess`/`onError`/`onSettled`) are +invoked once the mutation settles, in addition to any callbacks defined +on the observer's own options. + +#### Parameters + +##### variables + +`TVariables` + +##### options? + +[`MutateOptions`](../interfaces/MutateOptions.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\> + +#### Returns + +`Promise`\<`TData`\> + +#### Example + +```ts +await observer.mutate( + { title: 'New post' }, + { onSuccess: (data) => console.log(data) }, +) +``` + +*** + +### onSubscribe() + +```ts +protected onSubscribe(): void; +``` + +Defined in: [packages/query-core/src/mutationObserver.ts:127](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationObserver.ts#L127) + +#### Returns + +`void` + +#### Overrides + +```ts +Subscribable.onSubscribe +``` + +*** + +### onUnsubscribe() + +```ts +protected onUnsubscribe(): void; +``` + +Defined in: [packages/query-core/src/mutationObserver.ts:135](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationObserver.ts#L135) + +#### Returns + +`void` + +#### Overrides + +```ts +Subscribable.onUnsubscribe +``` + +*** + +### reset() + +```ts +reset(): void; +``` + +Defined in: [packages/query-core/src/mutationObserver.ts:180](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationObserver.ts#L180) + +Detaches the observer from the mutation it is currently observing (if +any) and resets the observed result back to its default, `idle` state. + +This does not cancel an in-flight mutation; the mutation itself keeps +running to completion and its own callbacks still fire, but this +observer stops reflecting its state and a subsequent `mutate()` call +will build a brand new mutation. + +#### Returns + +`void` + +#### Example + +```ts +observer.reset() +``` + +#### See + +[MutationObserver#mutate](#mutate) + +*** + +### setOptions() + +```ts +setOptions(options): void; +``` + +Defined in: [packages/query-core/src/mutationObserver.ts:96](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationObserver.ts#L96) + +Updates the observer's options. + +If the new `mutationKey` differs from the previous one (and both were +defined), the observer is reset, detaching it from the mutation it was +observing. Otherwise, if the currently observed mutation is still +`pending`, its options are updated in place as well. + +#### Parameters + +##### options + +[`MutationObserverOptions`](../interfaces/MutationObserverOptions.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\> + +#### Returns + +`void` + +#### Example + +```ts +observer.setOptions({ + mutationFn: (variables: { title: string }) => addPost(variables), + onSuccess: (data) => console.log(data), +}) +``` + +*** + +### subscribe() + +```ts +subscribe(listener): () => void; +``` + +Defined in: [packages/query-core/src/subscribable.ts:8](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L8) + +#### Parameters + +##### listener + +`MutationObserverListener` + +#### Returns + +```ts +(): void; +``` + +##### Returns + +`void` + +#### Inherited from + +```ts +Subscribable.subscribe +``` diff --git a/docs/framework/react/reference/classes/QueriesObserver.md b/docs/framework/react/reference/classes/QueriesObserver.md new file mode 100644 index 00000000000..4f07d3b3382 --- /dev/null +++ b/docs/framework/react/reference/classes/QueriesObserver.md @@ -0,0 +1,328 @@ +--- +id: QueriesObserver +title: QueriesObserver +redirect_from: + - reference/QueriesObserver + - framework/react/reference/QueriesObserver +--- + +Defined in: [packages/query-core/src/queriesObserver.ts:56](https://github.com/TanStack/query/blob/main/packages/query-core/src/queriesObserver.ts#L56) + +A `QueriesObserver` watches an array of queries at once, exposing them as +a single array of `QueryObserverResult`s (or, when a `combine` option is +given, as a combined value derived from that array). It manages one +internal `QueryObserver` per query, and is the primitive that framework +adapters (e.g. `useQueries`) build their hooks on top of. + +## Example + +```ts +const observer = new QueriesObserver(queryClient, [ + { queryKey: ['post', 1], queryFn: fetchPost }, + { queryKey: ['post', 2], queryFn: fetchPost }, +]) + +const unsubscribe = observer.subscribe((result) => { + console.log(result) +}) +``` + +## Extends + +- `Subscribable`\<`QueriesObserverListener`\> + +## Type Parameters + +### TCombinedResult + +`TCombinedResult` = [`QueryObserverResult`](../type-aliases/QueryObserverResult.md)[] + +## Constructors + +### Constructor + +```ts +new QueriesObserver( + client, + queries, +options?): QueriesObserver; +``` + +Defined in: [packages/query-core/src/queriesObserver.ts:70](https://github.com/TanStack/query/blob/main/packages/query-core/src/queriesObserver.ts#L70) + +#### Parameters + +##### client + +[`QueryClient`](QueryClient.md) + +##### queries + +[`QueryObserverOptions`](../interfaces/QueryObserverOptions.md)\<`any`, `any`, `any`, `any`, `any`, `never`\>[] + +##### options? + +[`QueriesObserverOptions`](../interfaces/QueriesObserverOptions.md)\<`TCombinedResult`\> + +#### Returns + +`QueriesObserver`\<`TCombinedResult`\> + +#### Overrides + +```ts +Subscribable.constructor +``` + +## Properties + +### listeners + +```ts +protected listeners: Set; +``` + +Defined in: [packages/query-core/src/subscribable.ts:2](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L2) + +#### Inherited from + +```ts +Subscribable.listeners +``` + +## Methods + +### destroy() + +```ts +destroy(): void; +``` + +Defined in: [packages/query-core/src/queriesObserver.ts:106](https://github.com/TanStack/query/blob/main/packages/query-core/src/queriesObserver.ts#L106) + +Stops observing all queries: clears all listeners and destroys every +underlying `QueryObserver` this observer manages. + +#### Returns + +`void` + +*** + +### getCurrentResult() + +```ts +getCurrentResult(): QueryObserverResult[]; +``` + +Defined in: [packages/query-core/src/queriesObserver.ts:210](https://github.com/TanStack/query/blob/main/packages/query-core/src/queriesObserver.ts#L210) + +Returns the most recently computed array of `QueryObserverResult`s, one +per observed query, in the same order as the queries passed to the +constructor or `setQueries`. + +#### Returns + +[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)[] + +#### Example + +```ts +const results = observer.getCurrentResult() +const data = results.map((result) => result.data) +``` + +*** + +### getObservers() + +```ts +getObservers(): QueryObserver[]; +``` + +Defined in: [packages/query-core/src/queriesObserver.ts:227](https://github.com/TanStack/query/blob/main/packages/query-core/src/queriesObserver.ts#L227) + +Returns the underlying `QueryObserver` instances this observer manages, +in the same order as the queries passed to the constructor or +`setQueries`. + +#### Returns + +[`QueryObserver`](QueryObserver.md)\<`unknown`, `Error`, `unknown`, `unknown`, readonly `unknown`[]\>[] + +*** + +### getOptimisticResult() + +```ts +getOptimisticResult(queries, combine): [QueryObserverResult[], (r?) => TCombinedResult, () => QueryObserverResult[]]; +``` + +Defined in: [packages/query-core/src/queriesObserver.ts:238](https://github.com/TanStack/query/blob/main/packages/query-core/src/queriesObserver.ts#L238) + +The `QueriesObserver` counterpart of [QueryObserver#getOptimisticResult](QueryObserver.md#getoptimisticresult) — computes +the result for the given (already-defaulted) queries right now, synchronously. Called by +framework adapters (e.g. `useQueries`) ahead of subscribing, returning a tuple of the raw +per-query results, a function to compute the combined result from them, and a function to +wrap the results for property-access tracking. + +#### Parameters + +##### queries + +[`QueryObserverOptions`](../interfaces/QueryObserverOptions.md)\<`unknown`, `Error`, `unknown`, `unknown`, readonly `unknown`[], `never`\>[] + +##### combine + +`CombineFn`\<`TCombinedResult`\> | `undefined` + +#### Returns + +\[[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)[], (`r?`) => `TCombinedResult`, () => [`QueryObserverResult`](../type-aliases/QueryObserverResult.md)[]\] + +*** + +### getQueries() + +```ts +getQueries(): Query[]; +``` + +Defined in: [packages/query-core/src/queriesObserver.ts:218](https://github.com/TanStack/query/blob/main/packages/query-core/src/queriesObserver.ts#L218) + +Returns the underlying `Query` instances currently being observed, in +the same order as the queries passed to the constructor or `setQueries`. + +#### Returns + +[`Query`](Query.md)\<`unknown`, `Error`, `unknown`, readonly `unknown`[]\>[] + +*** + +### hasListeners() + +```ts +hasListeners(): boolean; +``` + +Defined in: [packages/query-core/src/subscribable.ts:19](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L19) + +#### Returns + +`boolean` + +#### Inherited from + +```ts +Subscribable.hasListeners +``` + +*** + +### onSubscribe() + +```ts +protected onSubscribe(): void; +``` + +Defined in: [packages/query-core/src/queriesObserver.ts:86](https://github.com/TanStack/query/blob/main/packages/query-core/src/queriesObserver.ts#L86) + +#### Returns + +`void` + +#### Overrides + +```ts +Subscribable.onSubscribe +``` + +*** + +### onUnsubscribe() + +```ts +protected onUnsubscribe(): void; +``` + +Defined in: [packages/query-core/src/queriesObserver.ts:96](https://github.com/TanStack/query/blob/main/packages/query-core/src/queriesObserver.ts#L96) + +#### Returns + +`void` + +#### Overrides + +```ts +Subscribable.onUnsubscribe +``` + +*** + +### setQueries() + +```ts +setQueries(queries, options?): void; +``` + +Defined in: [packages/query-core/src/queriesObserver.ts:127](https://github.com/TanStack/query/blob/main/packages/query-core/src/queriesObserver.ts#L127) + +Replaces the set of queries being observed. Existing `QueryObserver`s +are reused for queries that match an already-observed query hash; +observers for queries that are no longer present are destroyed, and new +observers are created and subscribed to for newly added queries. + +#### Parameters + +##### queries + +[`QueryObserverOptions`](../interfaces/QueryObserverOptions.md)\<`unknown`, `Error`, `unknown`, `unknown`, readonly `unknown`[], `never`\>[] + +##### options? + +[`QueriesObserverOptions`](../interfaces/QueriesObserverOptions.md)\<`TCombinedResult`\> + +#### Returns + +`void` + +#### Example + +```ts +observer.setQueries([ + { queryKey: ['post', 1], queryFn: fetchPost }, + { queryKey: ['post', 3], queryFn: fetchPost }, +]) +``` + +*** + +### subscribe() + +```ts +subscribe(listener): () => void; +``` + +Defined in: [packages/query-core/src/subscribable.ts:8](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L8) + +#### Parameters + +##### listener + +`QueriesObserverListener` + +#### Returns + +```ts +(): void; +``` + +##### Returns + +`void` + +#### Inherited from + +```ts +Subscribable.subscribe +``` diff --git a/docs/framework/react/reference/classes/Query.md b/docs/framework/react/reference/classes/Query.md new file mode 100644 index 00000000000..bc15461e541 --- /dev/null +++ b/docs/framework/react/reference/classes/Query.md @@ -0,0 +1,585 @@ +--- +id: Query +title: Query +--- + +Defined in: [packages/query-core/src/query.ts:225](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L225) + +Represents a single cached query. A `Query` holds the query's key, options, +state (data/error/status), and the observers currently subscribed to it. + +Instances are created and managed internally by `QueryCache`; application +code typically interacts with queries indirectly through `QueryClient` or +a framework hook like `useQuery`. Direct access to a `Query` instance is +possible via `queryCache.find()`/`findAll()` for inspecting cache state. + +## Example + +```ts +const queryCache = queryClient.getQueryCache() +const query = queryCache.find({ queryKey: ['posts'] }) + +if (query) { + console.log(query.state.dataUpdatedAt) +} +``` + +## Extends + +- `Removable` + +## Type Parameters + +### TQueryFnData + +`TQueryFnData` = `unknown` + +### TError + +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) + +### TData + +`TData` = `TQueryFnData` + +### TQueryKey + +`TQueryKey` *extends* [`QueryKey`](../type-aliases/QueryKey.md) = [`QueryKey`](../type-aliases/QueryKey.md) + +## Constructors + +### Constructor + +```ts +new Query(config): Query; +``` + +Defined in: [packages/query-core/src/query.ts:246](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L246) + +#### Parameters + +##### config + +`QueryConfig`\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`\> + +#### Returns + +`Query`\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`\> + +#### Overrides + +```ts +Removable.constructor +``` + +## Properties + +### gcTime + +```ts +gcTime: number; +``` + +Defined in: [packages/query-core/src/removable.ts:7](https://github.com/TanStack/query/blob/main/packages/query-core/src/removable.ts#L7) + +#### Inherited from + +```ts +Removable.gcTime +``` + +*** + +### observers + +```ts +observers: QueryObserver[]; +``` + +Defined in: [packages/query-core/src/query.ts:242](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L242) + +*** + +### options + +```ts +options: QueryOptions; +``` + +Defined in: [packages/query-core/src/query.ts:233](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L233) + +*** + +### queryHash + +```ts +queryHash: string; +``` + +Defined in: [packages/query-core/src/query.ts:232](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L232) + +*** + +### queryKey + +```ts +queryKey: TQueryKey; +``` + +Defined in: [packages/query-core/src/query.ts:231](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L231) + +*** + +### state + +```ts +state: QueryState; +``` + +Defined in: [packages/query-core/src/query.ts:234](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L234) + +## Accessors + +### meta + +#### Get Signature + +```ts +get meta(): Record | undefined; +``` + +Defined in: [packages/query-core/src/query.ts:264](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L264) + +The `meta` object passed in the query's options, if any. + +##### Returns + +`Record`\<`string`, `unknown`\> \| `undefined` + +*** + +### promise + +#### Get Signature + +```ts +get promise(): Promise | undefined; +``` + +Defined in: [packages/query-core/src/query.ts:277](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L277) + +The promise for the currently in-flight fetch, if the query is fetching. +`undefined` when the query is not fetching. + +##### Returns + +`Promise`\<`TData`\> \| `undefined` + +## Methods + +### cancel() + +```ts +cancel(options?): Promise; +``` + +Defined in: [packages/query-core/src/query.ts:348](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L348) + +Cancels the query's currently in-flight fetch, if any. +- Returns a promise that resolves once the cancellation has settled. +- If no fetch is in progress, resolves immediately. + +#### Parameters + +##### options? + +[`CancelOptions`](../interfaces/CancelOptions.md) + +#### Returns + +`Promise`\<`void`\> + +#### Example + +```ts +await query.cancel() +``` + +*** + +### clearGcTimeout() + +```ts +protected clearGcTimeout(): void; +``` + +Defined in: [packages/query-core/src/removable.ts:32](https://github.com/TanStack/query/blob/main/packages/query-core/src/removable.ts#L32) + +#### Returns + +`void` + +#### Inherited from + +```ts +Removable.clearGcTimeout +``` + +*** + +### destroy() + +```ts +destroy(): void; +``` + +Defined in: [packages/query-core/src/query.ts:361](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L361) + +Clears the query's garbage collection timeout and silently cancels any +in-flight fetch. Called by `QueryCache` when the query is removed from +the cache. + +#### Returns + +`void` + +#### See + +[Query#cancel](#cancel) + +#### Overrides + +```ts +Removable.destroy +``` + +*** + +### fetch() + +```ts +fetch(options?, fetchOptions?): Promise; +``` + +Defined in: [packages/query-core/src/query.ts:590](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L590) + +Fetches the query, i.e. runs its `queryFn` (through any configured +retryer/behavior) and updates the query's state with the result. +- If a fetch is already in flight, returns its promise instead of + starting a new one, unless `fetchOptions.cancelRefetch` is set and the + query already has data, in which case the current fetch is silently + cancelled first. +- If `options` is passed, it replaces the query's current options + before fetching. + +#### Parameters + +##### options? + +[`QueryOptions`](../interfaces/QueryOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`, `never`\> + +##### fetchOptions? + +`FetchOptions`\<`TQueryFnData`\> + +#### Returns + +`Promise`\<`TData`\> + +*** + +### getObserversCount() + +```ts +getObserversCount(): number; +``` + +Defined in: [packages/query-core/src/query.ts:560](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L560) + +Returns the number of observers currently subscribed to this query. + +#### Returns + +`number` + +#### Example + +```ts +if (query.getObserversCount() === 0) { + // no component is currently watching this query +} +``` + +*** + +### invalidate() + +```ts +invalidate(): void; +``` + +Defined in: [packages/query-core/src/query.ts:574](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L574) + +Marks the query as invalidated, unless it is already invalidated. This +updates `state.isInvalidated` and notifies observers, but does not by +itself trigger a refetch. + +#### Returns + +`void` + +#### Example + +```ts +query.invalidate() +``` + +*** + +### isActive() + +```ts +isActive(): boolean; +``` + +Defined in: [packages/query-core/src/query.ts:386](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L386) + +Returns `true` if the query has at least one observer for which `enabled` +does not resolve to `false`. + +#### Returns + +`boolean` + +*** + +### isDisabled() + +```ts +isDisabled(): boolean; +``` + +Defined in: [packages/query-core/src/query.ts:400](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L400) + +Returns `true` if the query is disabled, meaning it will not fetch +automatically. +- If the query has observers, it is disabled when none of them are active + (see `isActive`). +- If the query has no observers, it is disabled when its `queryFn` is + `skipToken` or it has never been fetched. + +#### Returns + +`boolean` + +*** + +### isFetched() + +```ts +isFetched(): boolean; +``` + +Defined in: [packages/query-core/src/query.ts:412](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L412) + +Returns `true` if the query has been fetched, i.e. it has resolved with +either data or an error at least once. + +#### Returns + +`boolean` + +*** + +### isStale() + +```ts +isStale(): boolean; +``` + +Defined in: [packages/query-core/src/query.ts:447](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L447) + +Returns `true` if the query is stale. +- If the query has observers, defers to whether any observer's current + result reports `isStale` (which accounts for each observer's own + `staleTime` and `enabled` state). +- If the query has no observers, it is considered stale when it has no + data or has been invalidated. + +#### Returns + +`boolean` + +#### See + +[Query#isStaleByTime](#isstalebytime) + +#### Example + +```ts +if (query.isStale()) { + // refetch or otherwise treat the cached data as outdated +} +``` + +*** + +### isStaleByTime() + +```ts +isStaleByTime(staleTime): boolean; +``` + +Defined in: [packages/query-core/src/query.ts:473](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L473) + +Returns `true` if the query's data is stale relative to the given +`staleTime` (defaults to `0`). +- A query with no data is always stale. +- `staleTime: 'static'` is never stale. +- An invalidated query is always stale. +- Otherwise, staleness is based on elapsed time since `dataUpdatedAt`. + +#### Parameters + +##### staleTime + +[`StaleTime`](../type-aliases/StaleTime.md) = `0` + +#### Returns + +`boolean` + +#### See + +[Query#isStale](#isstale) + +#### Example + +```ts +const isStale = query.isStaleByTime(1000 * 60) +``` + +*** + +### isStatic() + +```ts +isStatic(): boolean; +``` + +Defined in: [packages/query-core/src/query.ts:420](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L420) + +Returns `true` if the query has at least one observer configured with +`staleTime: 'static'`, meaning it is treated as never stale. + +#### Returns + +`boolean` + +*** + +### optionalRemove() + +```ts +protected optionalRemove(): void; +``` + +Defined in: [packages/query-core/src/query.ts:305](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L305) + +#### Returns + +`void` + +#### Overrides + +```ts +Removable.optionalRemove +``` + +*** + +### reset() + +```ts +reset(): void; +``` + +Defined in: [packages/query-core/src/query.ts:377](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L377) + +Resets the query back to its initial state (the state it had when it was +first created, e.g. any `initialData`), destroying it first to cancel any +in-flight fetch. + +#### Returns + +`void` + +*** + +### scheduleGc() + +```ts +protected scheduleGc(): void; +``` + +Defined in: [packages/query-core/src/removable.ts:14](https://github.com/TanStack/query/blob/main/packages/query-core/src/removable.ts#L14) + +#### Returns + +`void` + +#### Inherited from + +```ts +Removable.scheduleGc +``` + +*** + +### setState() + +```ts +setState(state): void; +``` + +Defined in: [packages/query-core/src/query.ts:334](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L334) + +Merges the given partial state directly into this query's state, notifying observers. Used +by persistence and broadcast plugins to restore a state snapshot, and by devtools to let a +user manually trigger a loading/error state or edit the cached data. + +#### Parameters + +##### state + +`Partial`\<[`QueryState`](../interfaces/QueryState.md)\<`TData`, `TError`\>\> + +#### Returns + +`void` + +*** + +### updateGcTime() + +```ts +protected updateGcTime(newGcTime): void; +``` + +Defined in: [packages/query-core/src/removable.ts:24](https://github.com/TanStack/query/blob/main/packages/query-core/src/removable.ts#L24) + +#### Parameters + +##### newGcTime + +`number` | `undefined` + +#### Returns + +`void` + +#### Inherited from + +```ts +Removable.updateGcTime +``` diff --git a/docs/framework/react/reference/classes/QueryCache.md b/docs/framework/react/reference/classes/QueryCache.md new file mode 100644 index 00000000000..2db75a8c01b --- /dev/null +++ b/docs/framework/react/reference/classes/QueryCache.md @@ -0,0 +1,474 @@ +--- +id: QueryCache +title: QueryCache +redirect_from: + - reference/QueryCache + - framework/react/reference/QueryCache +--- + +Defined in: [packages/query-core/src/queryCache.ts:123](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryCache.ts#L123) + +The `QueryCache` is the storage mechanism for TanStack Query. It stores all the data, meta +information, and state of the queries it contains. + +Normally, you will not interact with the `QueryCache` directly and instead use a `QueryClient` +for a specific cache. You can subscribe to it (inherited from `Subscribable`) to be informed of +safe/known updates to the cache, such as queries being added, removed, or updated — updates made +outside of the cache's own tracked mechanisms (e.g. mutating a query's state object directly) do +not notify subscribers. + +## Example + +```ts +const unsubscribe = queryCache.subscribe((event) => { + console.log(event.type, event.query) +}) +``` + +## Extends + +- `Subscribable`\<`QueryCacheListener`\> + +## Constructors + +### Constructor + +```ts +new QueryCache(config): QueryCache; +``` + +Defined in: [packages/query-core/src/queryCache.ts:126](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryCache.ts#L126) + +#### Parameters + +##### config + +[`QueryCacheConfig`](../interfaces/QueryCacheConfig.md) = `{}` + +#### Returns + +`QueryCache` + +#### Overrides + +```ts +Subscribable.constructor +``` + +## Properties + +### config + +```ts +config: QueryCacheConfig = {}; +``` + +Defined in: [packages/query-core/src/queryCache.ts:126](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryCache.ts#L126) + +*** + +### listeners + +```ts +protected listeners: Set; +``` + +Defined in: [packages/query-core/src/subscribable.ts:2](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L2) + +#### Inherited from + +```ts +Subscribable.listeners +``` + +## Methods + +### build() + +```ts +build( + client, + options, +state?): Query; +``` + +Defined in: [packages/query-core/src/queryCache.ts:147](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryCache.ts#L147) + +Returns the existing `Query` instance for the given options' `queryKey`/`queryHash`, or +builds and adds a new one to the cache if none exists yet. Used by framework adapters and +plugins (e.g. broadcast/persistence) that need to get-or-create a `Query` directly, bypassing +the reactive `QueryObserver` machinery. + +#### Type Parameters + +##### TQueryFnData + +`TQueryFnData` = `unknown` + +##### TError + +`TError` = `Error` + +##### TData + +`TData` = `TQueryFnData` + +##### TQueryKey + +`TQueryKey` *extends* readonly `unknown`[] = readonly `unknown`[] + +#### Parameters + +##### client + +[`QueryClient`](QueryClient.md) + +##### options + +[`WithRequired`](../type-aliases/WithRequired.md)\<[`QueryOptions`](../interfaces/QueryOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`, `never`\>, `"queryKey"`\> + +##### state? + +[`QueryState`](../interfaces/QueryState.md)\<`TData`, `TError`\> + +#### Returns + +[`Query`](Query.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`\> + +#### Example + +```ts +const queryCache = queryClient.getQueryCache() + +const query = queryCache.build(queryClient, { + queryKey: ['posts'], + queryFn: fetchPosts, +}) +``` + +*** + +### clear() + +```ts +clear(): void; +``` + +Defined in: [packages/query-core/src/queryCache.ts:232](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryCache.ts#L232) + +Removes all queries from the cache. + +#### Returns + +`void` + +#### Example + +```ts +const queryCache = queryClient.getQueryCache() + +queryCache.clear() +``` + +*** + +### find() + +```ts +find(filters): + | Query + | undefined; +``` + +Defined in: [packages/query-core/src/queryCache.ts:299](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryCache.ts#L299) + +A slightly more advanced method that can be used to get an existing query instance from the +cache. This instance not only contains all the state for the query, but all of the instances, +and underlying guts of the query as well. If the query does not exist, `undefined` is +returned. + +This is not typically needed for most applications, but can come in handy when needing more +information about a query in rare scenarios (e.g. looking at `query.state.dataUpdatedAt` to +decide whether a query is fresh enough to be used as an initial value). + +#### Type Parameters + +##### TQueryFnData + +`TQueryFnData` = `unknown` + +##### TError + +`TError` = `Error` + +##### TData + +`TData` = `TQueryFnData` + +#### Parameters + +##### filters + +[`WithRequired`](../type-aliases/WithRequired.md)\<[`QueryFilters`](../interfaces/QueryFilters.md)\, `"queryKey"`\> + +#### Returns + + \| [`Query`](Query.md)\<`TQueryFnData`, `TError`, `TData`, readonly `unknown`[]\> + \| `undefined` + +#### See + +[QueryCache#findAll](#findall) + +#### Example + +```ts +const queryCache = queryClient.getQueryCache() + +const query = queryCache.find({ queryKey: ['posts'] }) +``` + +*** + +### findAll() + +```ts +findAll(filters): Query[]; +``` + +Defined in: [packages/query-core/src/queryCache.ts:324](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryCache.ts#L324) + +An even more advanced method that can be used to get existing query instances from the cache +that partially match a query key. If no queries match, an empty array is returned. + +This is not typically needed for most applications, but can come in handy when needing more +information about queries in rare scenarios. + +#### Parameters + +##### filters + +[`QueryFilters`](../interfaces/QueryFilters.md)\<`any`\> = `{}` + +#### Returns + +[`Query`](Query.md)\<`unknown`, `Error`, `unknown`, readonly `unknown`[]\>[] + +#### See + +[QueryCache#find](#find) + +#### Example + +```ts +const queryCache = queryClient.getQueryCache() + +const queries = queryCache.findAll({ queryKey: ['posts'] }) +``` + +*** + +### get() + +```ts +get(queryHash): + | Query + | undefined; +``` + +Defined in: [packages/query-core/src/queryCache.ts:254](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryCache.ts#L254) + +Returns the `Query` instance stored under the given `queryHash`, or `undefined` if none +exists. Unlike [QueryCache#find](#find), this looks up by the already-computed hash rather +than by `QueryFilters`. Used by plugins (e.g. broadcast/hydration) that already have a hash +to look up directly. + +#### Type Parameters + +##### TQueryFnData + +`TQueryFnData` = `unknown` + +##### TError + +`TError` = `Error` + +##### TData + +`TData` = `TQueryFnData` + +##### TQueryKey + +`TQueryKey` *extends* readonly `unknown`[] = readonly `unknown`[] + +#### Parameters + +##### queryHash + +`string` + +#### Returns + + \| [`Query`](Query.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`\> + \| `undefined` + +#### Example + +```ts +const queryCache = queryClient.getQueryCache() +const queryHash = hashKey(['posts']) + +const query = queryCache.get(queryHash) +``` + +*** + +### getAll() + +```ts +getAll(): Query[]; +``` + +Defined in: [packages/query-core/src/queryCache.ts:277](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryCache.ts#L277) + +Returns all queries within the cache. + +#### Returns + +[`Query`](Query.md)\<`unknown`, `Error`, `unknown`, readonly `unknown`[]\>[] + +#### Example + +```ts +const queryCache = queryClient.getQueryCache() + +const queries = queryCache.getAll() +``` + +*** + +### hasListeners() + +```ts +hasListeners(): boolean; +``` + +Defined in: [packages/query-core/src/subscribable.ts:19](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L19) + +#### Returns + +`boolean` + +#### Inherited from + +```ts +Subscribable.hasListeners +``` + +*** + +### onSubscribe() + +```ts +protected onSubscribe(): void; +``` + +Defined in: [packages/query-core/src/subscribable.ts:23](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L23) + +#### Returns + +`void` + +#### Inherited from + +```ts +Subscribable.onSubscribe +``` + +*** + +### onUnsubscribe() + +```ts +protected onUnsubscribe(): void; +``` + +Defined in: [packages/query-core/src/subscribable.ts:27](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L27) + +#### Returns + +`void` + +#### Inherited from + +```ts +Subscribable.onUnsubscribe +``` + +*** + +### remove() + +```ts +remove(query): void; +``` + +Defined in: [packages/query-core/src/queryCache.ts:208](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryCache.ts#L208) + +Destroys the given `Query` and removes it from the cache, notifying subscribers with a +`'removed'` event. A no-op if the query is no longer the one currently stored under its hash +(e.g. it was already replaced). Used by plugins (e.g. the broadcast client) that mirror +removals across `QueryCache` instances. + +#### Parameters + +##### query + +[`Query`](Query.md)\<`any`, `any`, `any`, `any`\> + +#### Returns + +`void` + +#### Example + +```ts +const queryCache = queryClient.getQueryCache() +const query = queryCache.find({ queryKey: ['posts'] }) + +if (query) { + queryCache.remove(query) +} +``` + +*** + +### subscribe() + +```ts +subscribe(listener): () => void; +``` + +Defined in: [packages/query-core/src/subscribable.ts:8](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L8) + +#### Parameters + +##### listener + +`QueryCacheListener` + +#### Returns + +```ts +(): void; +``` + +##### Returns + +`void` + +#### Inherited from + +```ts +Subscribable.subscribe +``` diff --git a/docs/framework/react/reference/classes/QueryClient.md b/docs/framework/react/reference/classes/QueryClient.md new file mode 100644 index 00000000000..a713a69deab --- /dev/null +++ b/docs/framework/react/reference/classes/QueryClient.md @@ -0,0 +1,1469 @@ +--- +id: QueryClient +title: QueryClient +redirect_from: + - reference/QueryClient + - framework/react/reference/QueryClient +--- + +Defined in: [packages/query-core/src/queryClient.ts:79](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L79) + +`QueryClient` is used to interact with a cache of queries and mutations. It owns a +`QueryCache` and a `MutationCache` (creating default ones if none are passed in) and holds +the default options that are applied to queries and mutations created through it. + +## Example + +```ts +const queryClient = new QueryClient({ + defaultOptions: { + queries: { + staleTime: Infinity, + }, + }, +}) + +await queryClient.query({ queryKey: ['posts'], queryFn: fetchPosts }) +``` + +## Constructors + +### Constructor + +```ts +new QueryClient(config): QueryClient; +``` + +Defined in: [packages/query-core/src/queryClient.ts:89](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L89) + +#### Parameters + +##### config + +[`QueryClientConfig`](../interfaces/QueryClientConfig.md) = `{}` + +#### Returns + +`QueryClient` + +## Methods + +### cancelQueries() + +```ts +cancelQueries(filters?, cancelOptions?): Promise; +``` + +Defined in: [packages/query-core/src/queryClient.ts:432](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L432) + +Cancels outgoing fetches for queries matching the given filters. Most useful when performing +optimistic updates, since any outgoing refetch that resolves afterwards would otherwise +overwrite the optimistic update. By default (`revert: true`), a cancelled query's data is +reverted to its state before the outgoing fetch started. + +The returned promise never rejects, even if individual cancellations fail. + +#### Type Parameters + +##### TTaggedQueryKey + +`TTaggedQueryKey` *extends* readonly `unknown`[] = readonly `unknown`[] + +#### Parameters + +##### filters? + +[`QueryFilters`](../interfaces/QueryFilters.md)\<`TTaggedQueryKey`\> + +##### cancelOptions? + +[`CancelOptions`](../interfaces/CancelOptions.md) = `{}` + +#### Returns + +`Promise`\<`void`\> + +#### Example + +```ts +await queryClient.cancelQueries({ queryKey: ['posts'], exact: true }) +``` + +*** + +### clear() + +```ts +clear(): void; +``` + +Defined in: [packages/query-core/src/queryClient.ts:1083](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L1083) + +Clears both the query cache and the mutation cache this client is connected to. + +#### Returns + +`void` + +#### Example + +```ts +import { QueryClient } from '@tanstack/query-core' + +const queryClient = new QueryClient() +queryClient.clear() +``` + +*** + +### defaultMutationOptions() + +```ts +defaultMutationOptions(options?): T; +``` + +Defined in: [packages/query-core/src/queryClient.ts:1057](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L1057) + +The mutation counterpart of [QueryClient#defaultQueryOptions](#defaultqueryoptions). Called by framework +adapters (e.g. inside `useMutation`) to merge `queryClient.setMutationDefaults` for the +given `mutationKey`, then the client's `defaultOptions.mutations`, then the caller's options +on top. A no-op if the options are already defaulted (`_defaulted: true`). + +#### Type Parameters + +##### T + +`T` *extends* [`MutationOptions`](../interfaces/MutationOptions.md)\<`any`, `any`, `any`, `any`\> + +#### Parameters + +##### options? + +`T` + +#### Returns + +`T` + +*** + +### defaultQueryOptions() + +```ts +defaultQueryOptions(options): DefaultedQueryObserverOptions; +``` + +Defined in: [packages/query-core/src/queryClient.ts:970](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L970) + +Called by framework adapters (e.g. inside `useQuery`) to resolve the options passed by the +caller into their final, defaulted form: merging `queryClient.setQueryDefaults` for the +given `queryKey`, then the client's own `defaultOptions.queries`, then the caller's options +on top. A no-op if the options are already defaulted (`_defaulted: true`). + +#### Type Parameters + +##### TQueryFnData + +`TQueryFnData` = `unknown` + +##### TError + +`TError` = `Error` + +##### TData + +`TData` = `TQueryFnData` + +##### TQueryData + +`TQueryData` = `TQueryFnData` + +##### TQueryKey + +`TQueryKey` *extends* readonly `unknown`[] = readonly `unknown`[] + +##### TPageParam + +`TPageParam` = `never` + +#### Parameters + +##### options + +[`QueryObserverOptions`](../interfaces/QueryObserverOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryData`, `TQueryKey`, `TPageParam`\> | [`DefaultedQueryObserverOptions`](../type-aliases/DefaultedQueryObserverOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryData`, `TQueryKey`\> + +#### Returns + +[`DefaultedQueryObserverOptions`](../type-aliases/DefaultedQueryObserverOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryData`, `TQueryKey`\> + +*** + +### ~~ensureInfiniteQueryData()~~ + +```ts +ensureInfiniteQueryData(options): Promise>; +``` + +Defined in: [packages/query-core/src/queryClient.ts:735](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L735) + +#### Type Parameters + +##### TQueryFnData + +`TQueryFnData` + +##### TError + +`TError` = `Error` + +##### TData + +`TData` = `TQueryFnData` + +##### TQueryKey + +`TQueryKey` *extends* readonly `unknown`[] = readonly `unknown`[] + +##### TPageParam + +`TPageParam` = `unknown` + +#### Parameters + +##### options + +[`EnsureInfiniteQueryDataOptions`](../type-aliases/EnsureInfiniteQueryDataOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`, `TPageParam`\> + +#### Returns + +`Promise`\<[`InfiniteData`](../interfaces/InfiniteData.md)\<`TData`, `TPageParam`\>\> + +#### Deprecated + +Use queryClient.infiniteQuery({ ...options, staleTime: 'static' }) instead. This method will be removed in the next major version. + +*** + +### ~~ensureQueryData()~~ + +```ts +ensureQueryData(options): Promise; +``` + +Defined in: [packages/query-core/src/queryClient.ts:197](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L197) + +#### Type Parameters + +##### TQueryFnData + +`TQueryFnData` + +##### TError + +`TError` = `Error` + +##### TData + +`TData` = `TQueryFnData` + +##### TQueryKey + +`TQueryKey` *extends* readonly `unknown`[] = readonly `unknown`[] + +#### Parameters + +##### options + +[`EnsureQueryDataOptions`](../interfaces/EnsureQueryDataOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`\> + +#### Returns + +`Promise`\<`TData`\> + +#### Deprecated + +Use queryClient.query({ ...options, staleTime: 'static' }) instead. This method will be removed in the next major version. + +*** + +### ~~fetchInfiniteQuery()~~ + +```ts +fetchInfiniteQuery(options): Promise>; +``` + +Defined in: [packages/query-core/src/queryClient.ts:692](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L692) + +#### Type Parameters + +##### TQueryFnData + +`TQueryFnData` + +##### TError + +`TError` = `Error` + +##### TData + +`TData` = `TQueryFnData` + +##### TQueryKey + +`TQueryKey` *extends* readonly `unknown`[] = readonly `unknown`[] + +##### TPageParam + +`TPageParam` = `unknown` + +#### Parameters + +##### options + +[`FetchInfiniteQueryOptions`](../type-aliases/FetchInfiniteQueryOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`, `TPageParam`\> + +#### Returns + +`Promise`\<[`InfiniteData`](../interfaces/InfiniteData.md)\<`TData`, `TPageParam`\>\> + +#### Deprecated + +Use queryClient.infiniteQuery(options) instead. This method will be removed in the next major version. + +*** + +### ~~fetchQuery()~~ + +```ts +fetchQuery(options): Promise; +``` + +Defined in: [packages/query-core/src/queryClient.ts:600](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L600) + +#### Type Parameters + +##### TQueryFnData + +`TQueryFnData` + +##### TError + +`TError` = `Error` + +##### TData + +`TData` = `TQueryFnData` + +##### TQueryKey + +`TQueryKey` *extends* readonly `unknown`[] = readonly `unknown`[] + +##### TPageParam + +`TPageParam` = `never` + +#### Parameters + +##### options + +[`FetchQueryOptions`](../interfaces/FetchQueryOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`, `TPageParam`\> + +#### Returns + +`Promise`\<`TData`\> + +#### Deprecated + +Use queryClient.query(options) instead. This method will be removed in the next major version. + +*** + +### getDefaultOptions() + +```ts +getDefaultOptions(): DefaultOptions; +``` + +Defined in: [packages/query-core/src/queryClient.ts:818](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L818) + +Returns the default options that were set when creating the client, or via +[QueryClient#setDefaultOptions](#setdefaultoptions). + +#### Returns + +[`DefaultOptions`](../interfaces/DefaultOptions.md) + +#### Example + +```ts +import { QueryClient } from '@tanstack/query-core' + +const queryClient = new QueryClient() +const defaultOptions = queryClient.getDefaultOptions() +``` + +*** + +### getMutationCache() + +```ts +getMutationCache(): MutationCache; +``` + +Defined in: [packages/query-core/src/queryClient.ts:802](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L802) + +Returns the mutation cache this client is connected to. + +#### Returns + +[`MutationCache`](MutationCache.md) + +#### Example + +```ts +import { QueryClient } from '@tanstack/query-core' + +const queryClient = new QueryClient() +const mutationCache = queryClient.getMutationCache() +const mutations = mutationCache.findAll({ status: 'pending' }) +``` + +*** + +### getMutationDefaults() + +```ts +getMutationDefaults(mutationKey): OmitKeyof, "mutationKey">; +``` + +Defined in: [packages/query-core/src/queryClient.ts:945](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L945) + +Returns the default options registered for mutations whose mutation key partially matches +the given `mutationKey`, via [QueryClient#setMutationDefaults](#setmutationdefaults). If multiple registered +defaults match, they are merged together in registration order. + +#### Parameters + +##### mutationKey + +readonly `unknown`[] + +#### Returns + +[`OmitKeyof`](../type-aliases/OmitKeyof.md)\<[`MutationObserverOptions`](../interfaces/MutationObserverOptions.md)\<`any`, `any`, `any`, `any`\>, `"mutationKey"`\> + +#### Example + +```ts +const defaultOptions = queryClient.getMutationDefaults(['addPost']) +``` + +*** + +### getQueriesData() + +```ts +getQueriesData(filters): [readonly unknown[], TQueryFnData | undefined][]; +``` + +Defined in: [packages/query-core/src/queryClient.ts:240](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L240) + +Imperative (non-reactive) way to retrieve the cached data of multiple queries at once. +Only queries matching the given filters are returned; if none match, an empty array is +returned. + +Because the matched queries can hold data of different shapes (e.g. a broad filter can match +queries with unrelated data types), the `TQueryFnData` generic defaults to `unknown` rather +than being inferred. Passing a more specific type is a convenience for call sites that know +every matched query holds the same shape — it is not checked against the actual cache +contents. + +#### Type Parameters + +##### TQueryFnData + +`TQueryFnData` = `unknown` + +##### TQueryFilters + +`TQueryFilters` *extends* [`QueryFilters`](../interfaces/QueryFilters.md)\<`any`\> = [`QueryFilters`](../interfaces/QueryFilters.md)\ + +#### Parameters + +##### filters + +`TQueryFilters` + +#### Returns + +\[readonly `unknown`[], `TQueryFnData` \| `undefined`\][] + +#### See + +[QueryClient#getQueryData](#getquerydata) + +#### Example + +```ts +const data = queryClient.getQueriesData({ queryKey: ['posts'] }) +``` + +*** + +### getQueryCache() + +```ts +getQueryCache(): QueryCache; +``` + +Defined in: [packages/query-core/src/queryClient.ts:786](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L786) + +Returns the query cache this client is connected to. + +#### Returns + +[`QueryCache`](QueryCache.md) + +#### Example + +```ts +import { QueryClient } from '@tanstack/query-core' + +const queryClient = new QueryClient() +const queryCache = queryClient.getQueryCache() +const queries = queryCache.findAll({ queryKey: ['posts'] }) +``` + +*** + +### getQueryData() + +```ts +getQueryData(queryKey): TInferredQueryFnData | undefined; +``` + +Defined in: [packages/query-core/src/queryClient.ts:183](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L183) + +Imperative (non-reactive) way to retrieve data for a QueryKey. +Should only be used in callbacks or functions where reading the latest data is necessary, e.g. for optimistic updates. + +Hint: Do not use this function inside a component, because it won't receive updates. +Use `useQuery` to create a `QueryObserver` that subscribes to changes. + +#### Type Parameters + +##### TQueryFnData + +`TQueryFnData` = `unknown` + +##### TTaggedQueryKey + +`TTaggedQueryKey` *extends* readonly `unknown`[] = readonly `unknown`[] + +##### TInferredQueryFnData + +`TInferredQueryFnData` = [`InferDataFromTag`](../type-aliases/InferDataFromTag.md)\<`TQueryFnData`, `TTaggedQueryKey`\> + +#### Parameters + +##### queryKey + +`TTaggedQueryKey` + +#### Returns + +`TInferredQueryFnData` \| `undefined` + +#### See + +[QueryClient#getQueriesData](#getqueriesdata) + +*** + +### getQueryDefaults() + +```ts +getQueryDefaults(queryKey): OmitKeyof, "queryKey">; +``` + +Defined in: [packages/query-core/src/queryClient.ts:888](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L888) + +Returns the default options registered for queries whose query key partially matches the +given `queryKey`, via [QueryClient#setQueryDefaults](#setquerydefaults). If multiple registered defaults +match, they are merged together in registration order. + +#### Parameters + +##### queryKey + +readonly `unknown`[] + +#### Returns + +[`OmitKeyof`](../type-aliases/OmitKeyof.md)\<[`QueryObserverOptions`](../interfaces/QueryObserverOptions.md)\<`any`, `any`, `any`, `any`, `any`\>, `"queryKey"`\> + +#### Example + +```ts +const defaultOptions = queryClient.getQueryDefaults(['posts']) +``` + +*** + +### getQueryState() + +```ts +getQueryState(queryKey): + | QueryState + | undefined; +``` + +Defined in: [packages/query-core/src/queryClient.ts:350](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L350) + +Imperative (non-reactive) way to retrieve an existing query's state. If the query does not +exist, `undefined` is returned. + +#### Type Parameters + +##### TQueryFnData + +`TQueryFnData` = `unknown` + +##### TError + +`TError` = `Error` + +##### TTaggedQueryKey + +`TTaggedQueryKey` *extends* readonly `unknown`[] = readonly `unknown`[] + +##### TInferredQueryFnData + +`TInferredQueryFnData` = [`InferDataFromTag`](../type-aliases/InferDataFromTag.md)\<`TQueryFnData`, `TTaggedQueryKey`\> + +##### TInferredError + +`TInferredError` = [`InferErrorFromTag`](../type-aliases/InferErrorFromTag.md)\<`TError`, `TTaggedQueryKey`\> + +#### Parameters + +##### queryKey + +`TTaggedQueryKey` + +#### Returns + + \| [`QueryState`](../interfaces/QueryState.md)\<`TInferredQueryFnData`, `TInferredError`\> + \| `undefined` + +#### Example + +```ts +const state = queryClient.getQueryState(['posts']) +console.log(state?.dataUpdatedAt) +``` + +*** + +### infiniteQuery() + +```ts +infiniteQuery(options): Promise[] ? InfiniteData : TData>; +``` + +Defined in: [packages/query-core/src/queryClient.ts:666](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L666) + +Asynchronous method to fetch and cache an infinite query, resolving with an +[InfiniteData](../interfaces/InfiniteData.md) object or throwing with the error. + +Behaves like [QueryClient#query](#query), accepting the same options (minus +`initialPageParam`), plus the required `initialPageParam`, and an optional `pages` / +`getNextPageParam` pair used to refetch a fixed number of pages from the start. + +This method replaces the deprecated `fetchInfiniteQuery`, and — combined with +`{ staleTime: 'static' }` — the deprecated `ensureInfiniteQueryData`. + +#### Type Parameters + +##### TQueryFnData + +`TQueryFnData` + +##### TError + +`TError` = `Error` + +##### TData + +`TData` = [`InfiniteData`](../interfaces/InfiniteData.md)\<`TQueryFnData`, `unknown`\> + +##### TQueryKey + +`TQueryKey` *extends* readonly `unknown`[] = readonly `unknown`[] + +##### TPageParam + +`TPageParam` = `unknown` + +#### Parameters + +##### options + +[`InfiniteQueryExecuteOptions`](../type-aliases/InfiniteQueryExecuteOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`, `TPageParam`\> + +#### Returns + +`Promise`\<`TData`[] *extends* [`InfiniteData`](../interfaces/InfiniteData.md)\<`TQueryFnData`, `unknown`\>[] ? [`InfiniteData`](../interfaces/InfiniteData.md)\<`TQueryFnData`, `TPageParam`\> : `TData`\> + +#### Example + +```ts +try { + const data = await queryClient.infiniteQuery({ queryKey, queryFn, initialPageParam: 0 }) + console.log(data.pages) +} catch (error) { + console.log(error) +} +``` + +*** + +### invalidateQueries() + +```ts +invalidateQueries(filters?, options?): Promise; +``` + +Defined in: [packages/query-core/src/queryClient.ts:460](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L460) + +Marks queries matching the given filters as invalidated. Unlike +[QueryClient#removeQueries](#removequeries), invalidated queries stay in the cache. + +Unless `filters.refetchType` is `'none'`, matching queries are then refetched via +[QueryClient#refetchQueries](#refetchqueries), using `filters.refetchType` if set, otherwise +`filters.type`, otherwise `'active'`. + +#### Type Parameters + +##### TTaggedQueryKey + +`TTaggedQueryKey` *extends* readonly `unknown`[] = readonly `unknown`[] + +#### Parameters + +##### filters? + +[`InvalidateQueryFilters`](../interfaces/InvalidateQueryFilters.md)\<`TTaggedQueryKey`\> + +##### options? + +[`InvalidateOptions`](../interfaces/InvalidateOptions.md) = `{}` + +#### Returns + +`Promise`\<`void`\> + +#### Example + +```ts +await queryClient.invalidateQueries({ queryKey: ['posts'], refetchType: 'active' }) +``` + +*** + +### isFetching() + +```ts +isFetching(filters?): number; +``` + +Defined in: [packages/query-core/src/queryClient.ts:150](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L150) + +Returns the number of queries in the cache that are currently fetching, optionally +matching a set of filters. This includes background-fetching, loading new pages, and +loading more infinite query results. + +#### Type Parameters + +##### TQueryFilters + +`TQueryFilters` *extends* [`QueryFilters`](../interfaces/QueryFilters.md)\<`any`\> = [`QueryFilters`](../interfaces/QueryFilters.md)\ + +#### Parameters + +##### filters? + +`TQueryFilters` + +#### Returns + +`number` + +#### Example + +```ts +if (queryClient.isFetching()) { + console.log('At least one query is fetching!') +} +``` + +*** + +### isMutating() + +```ts +isMutating(filters?): number; +``` + +Defined in: [packages/query-core/src/queryClient.ts:168](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L168) + +Returns the number of mutations in the cache that are currently pending, optionally +matching a set of filters. + +#### Type Parameters + +##### TMutationFilters + +`TMutationFilters` *extends* [`MutationFilters`](../interfaces/MutationFilters.md)\<`any`, `any`, `unknown`, `unknown`\> = [`MutationFilters`](../interfaces/MutationFilters.md)\<`unknown`, `Error`, `unknown`, `unknown`\> + +#### Parameters + +##### filters? + +`TMutationFilters` + +#### Returns + +`number` + +#### Example + +```ts +if (queryClient.isMutating()) { + console.log('At least one mutation is pending!') +} +``` + +*** + +### mount() + +```ts +mount(): void; +``` + +Defined in: [packages/query-core/src/queryClient.ts:104](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L104) + +Called by a framework adapter's `QueryClientProvider`-equivalent when it mounts, to start +listening for focus/online events and resume paused mutations. Ref-counted via an internal +mount count, so nested or multiple providers sharing the same `QueryClient` don't tear down +the shared listeners until the last one unmounts. + +#### Returns + +`void` + +*** + +### ~~prefetchInfiniteQuery()~~ + +```ts +prefetchInfiniteQuery(options): Promise; +``` + +Defined in: [packages/query-core/src/queryClient.ts:714](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L714) + +#### Type Parameters + +##### TQueryFnData + +`TQueryFnData` + +##### TError + +`TError` = `Error` + +##### TData + +`TData` = `TQueryFnData` + +##### TQueryKey + +`TQueryKey` *extends* readonly `unknown`[] = readonly `unknown`[] + +##### TPageParam + +`TPageParam` = `unknown` + +#### Parameters + +##### options + +[`FetchInfiniteQueryOptions`](../type-aliases/FetchInfiniteQueryOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`, `TPageParam`\> + +#### Returns + +`Promise`\<`void`\> + +#### Deprecated + +Use queryClient.infiniteQuery(options) instead. You can swallow errors with `.catch(noop)`. This method will be removed in the next major version. + +*** + +### ~~prefetchQuery()~~ + +```ts +prefetchQuery(options): Promise; +``` + +Defined in: [packages/query-core/src/queryClient.ts:634](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L634) + +#### Type Parameters + +##### TQueryFnData + +`TQueryFnData` = `unknown` + +##### TError + +`TError` = `Error` + +##### TData + +`TData` = `TQueryFnData` + +##### TQueryKey + +`TQueryKey` *extends* readonly `unknown`[] = readonly `unknown`[] + +#### Parameters + +##### options + +[`FetchQueryOptions`](../interfaces/FetchQueryOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`\> + +#### Returns + +`Promise`\<`void`\> + +#### Deprecated + +Use queryClient.query(options) instead. You can swallow errors with `.catch(noop)`. This method will be removed in the next major version. + +*** + +### query() + +```ts +query(options): Promise; +``` + +Defined in: [packages/query-core/src/queryClient.ts:554](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L554) + +Asynchronous method to fetch and cache a query, resolving with the data or throwing with +the error. + +If the query already exists in the cache and its data is not stale (per the given +`staleTime`), the cached data is returned without fetching. Otherwise, the query is fetched +and the promise resolves once the fetch settles. If a `select` function is provided, it is +applied to the data in both cases (cached or freshly fetched) before it is returned. + +Unlike a reactive observer, retries are disabled by default here (`retry: false`) unless +explicitly configured, since there is no component to catch a thrown error and retry through +re-render. + +The accepted options are `QueryObserverOptions` minus the fields that only make sense for a +reactive observer — `enabled`, `refetchInterval`, `refetchIntervalInBackground`, +`refetchOnWindowFocus`, `refetchOnReconnect`, `refetchOnMount`, `retryOnMount`, +`notifyOnChangeProps`, `throwOnError`, `suspense`, and `placeholderData` are not part of this +method's options. + +This method replaces the deprecated `fetchQuery`, and — combined with +`{ staleTime: 'static' }` — the deprecated `ensureQueryData`. + +#### Type Parameters + +##### TQueryFnData + +`TQueryFnData` + +##### TError + +`TError` = `Error` + +##### TData + +`TData` = `TQueryFnData` + +##### TQueryData + +`TQueryData` = `TQueryFnData` + +##### TQueryKey + +`TQueryKey` *extends* readonly `unknown`[] = readonly `unknown`[] + +##### TPageParam + +`TPageParam` = `never` + +#### Parameters + +##### options + +[`QueryExecuteOptions`](../interfaces/QueryExecuteOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryData`, `TQueryKey`, `TPageParam`\> + +#### Returns + +`Promise`\<`TData`\> + +#### Example + +```ts +try { + const data = await queryClient.query({ queryKey, queryFn, staleTime: 10000 }) +} catch (error) { + console.log(error) +} +``` + +*** + +### refetchQueries() + +```ts +refetchQueries(filters?, options?): Promise; +``` + +Defined in: [packages/query-core/src/queryClient.ts:497](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L497) + +Refetches queries matching the given filters, regardless of whether they are stale. Without +filters, every query in the cache is refetched. Queries that are disabled, or static (only +have observers with a static `staleTime`), are never refetched. + +By default (`cancelRefetch: true`), a currently running fetch is cancelled before the new +one starts. The returned promise resolves once all matching queries have settled; it does +not reject on individual query failures unless `throwOnError` is set. + +#### Type Parameters + +##### TTaggedQueryKey + +`TTaggedQueryKey` *extends* readonly `unknown`[] = readonly `unknown`[] + +#### Parameters + +##### filters? + +[`RefetchQueryFilters`](../interfaces/RefetchQueryFilters.md)\<`TTaggedQueryKey`\> + +##### options? + +[`RefetchOptions`](../interfaces/RefetchOptions.md) = `{}` + +#### Returns + +`Promise`\<`void`\> + +#### Example + +```ts +// refetch all active queries partially matching a query key: +await queryClient.refetchQueries({ queryKey: ['posts'], type: 'active' }) +``` + +*** + +### removeQueries() + +```ts +removeQueries(filters?): void; +``` + +Defined in: [packages/query-core/src/queryClient.ts:376](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L376) + +Removes queries from the cache that match the given filters. Unlike +[QueryClient#invalidateQueries](#invalidatequeries) or [QueryClient#refetchQueries](#refetchqueries), this removes +matching queries from the cache instead of refetching them. Without filters, every query in +the cache is removed. + +#### Type Parameters + +##### TTaggedQueryKey + +`TTaggedQueryKey` *extends* readonly `unknown`[] = readonly `unknown`[] + +#### Parameters + +##### filters? + +[`QueryFilters`](../interfaces/QueryFilters.md)\<`TTaggedQueryKey`\> + +#### Returns + +`void` + +#### Example + +```ts +queryClient.removeQueries({ queryKey: ['posts'], exact: true }) +``` + +*** + +### resetQueries() + +```ts +resetQueries(filters?, options?): Promise; +``` + +Defined in: [packages/query-core/src/queryClient.ts:397](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L397) + +Resets queries matching the given filters back to their initial state (e.g. any +`initialData`), notifying subscribers rather than removing them. Active queries among the +matched set are then refetched, and the returned promise resolves once that refetch settles. + +#### Type Parameters + +##### TTaggedQueryKey + +`TTaggedQueryKey` *extends* readonly `unknown`[] = readonly `unknown`[] + +#### Parameters + +##### filters? + +[`QueryFilters`](../interfaces/QueryFilters.md)\<`TTaggedQueryKey`\> + +##### options? + +[`ResetOptions`](../interfaces/ResetOptions.md) + +#### Returns + +`Promise`\<`void`\> + +#### Example + +```ts +await queryClient.resetQueries({ queryKey: ['posts'], exact: true }) +``` + +*** + +### resumePausedMutations() + +```ts +resumePausedMutations(): Promise; +``` + +Defined in: [packages/query-core/src/queryClient.ts:767](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L767) + +Resumes mutations that were paused because there was no network connection. Does nothing +(resolving immediately) if the client is currently offline. + +#### Returns + +`Promise`\<`unknown`\> + +#### Example + +```ts +import { QueryClient } from '@tanstack/query-core' + +const queryClient = new QueryClient() +await queryClient.resumePausedMutations() +``` + +*** + +### setDefaultOptions() + +```ts +setDefaultOptions(options): void; +``` + +Defined in: [packages/query-core/src/queryClient.ts:839](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L839) + +Dynamically sets the default options for this client, overwriting any previously defined +default options. + +#### Parameters + +##### options + +[`DefaultOptions`](../interfaces/DefaultOptions.md) + +#### Returns + +`void` + +#### See + +[QueryClient#getDefaultOptions](#getdefaultoptions) + +#### Example + +```ts +import { QueryClient } from '@tanstack/query-core' + +const queryClient = new QueryClient() +queryClient.setDefaultOptions({ + queries: { + staleTime: Infinity, + }, +}) +``` + +*** + +### setMutationDefaults() + +```ts +setMutationDefaults(mutationKey, options): void; +``` + +Defined in: [packages/query-core/src/queryClient.ts:917](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L917) + +Sets default options for mutations whose mutation key partially matches the given +`mutationKey`. As with [QueryClient#setQueryDefaults](#setquerydefaults), the order of registration +matters when several registered defaults match the same mutation key. + +#### Type Parameters + +##### TData + +`TData` = `unknown` + +##### TError + +`TError` = `Error` + +##### TVariables + +`TVariables` = `void` + +##### TOnMutateResult + +`TOnMutateResult` = `unknown` + +#### Parameters + +##### mutationKey + +readonly `unknown`[] + +##### options + +[`OmitKeyof`](../type-aliases/OmitKeyof.md)\<[`MutationObserverOptions`](../interfaces/MutationObserverOptions.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\>, `"mutationKey"`\> + +#### Returns + +`void` + +#### See + +[QueryClient#getMutationDefaults](#getmutationdefaults) + +#### Example + +```ts +queryClient.setMutationDefaults(['addPost'], { mutationFn: addPost }) +``` + +*** + +### setQueriesData() + +```ts +setQueriesData( + filters, + updater, + options?): [readonly unknown[], TQueryFnData | undefined][]; +``` + +Defined in: [packages/query-core/src/queryClient.ts:319](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L319) + +Synchronous way to immediately update the cached data of multiple queries at once, using +filters or partial query key matching. Only queries that already exist and match the given +filters are updated; no new cache entries are created. Internally this calls +[QueryClient#setQueryData](#setquerydata) for each matching query. + +#### Type Parameters + +##### TQueryFnData + +`TQueryFnData` + +##### TQueryFilters + +`TQueryFilters` *extends* [`QueryFilters`](../interfaces/QueryFilters.md)\<`any`\> = [`QueryFilters`](../interfaces/QueryFilters.md)\ + +#### Parameters + +##### filters + +`TQueryFilters` + +##### updater + +[`Updater`](../type-aliases/Updater.md)\<`NoInfer`\<`TQueryFnData`\> \| `undefined`, `NoInfer`\<`TQueryFnData`\> \| `undefined`\> + +##### options? + +[`SetDataOptions`](../interfaces/SetDataOptions.md) + +#### Returns + +\[readonly `unknown`[], `TQueryFnData` \| `undefined`\][] + +#### Example + +```ts +queryClient.setQueriesData({ queryKey: ['posts'] }, (oldPosts) => + oldPosts ? oldPosts.filter((post) => post.id !== deletedId) : oldPosts, +) +``` + +*** + +### setQueryData() + +```ts +setQueryData( + queryKey, + updater, + options?): NoInfer | undefined; +``` + +Defined in: [packages/query-core/src/queryClient.ts:271](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L271) + +Synchronous way to immediately update a query's cached data. If the updater (or the value +passed) resolves to `undefined`, the cache is left untouched and no query is created; +otherwise, if the query does not exist yet, it will be created. To update multiple queries +at once by partially matching query keys, use [QueryClient#setQueriesData](#setqueriesdata) instead. + +Updates must be performed immutably: do not mutate `oldData`, or data previously retrieved +via [QueryClient#getQueryData](#getquerydata), in place. + +#### Type Parameters + +##### TQueryFnData + +`TQueryFnData` = `unknown` + +##### TTaggedQueryKey + +`TTaggedQueryKey` *extends* readonly `unknown`[] = readonly `unknown`[] + +##### TInferredQueryFnData + +`TInferredQueryFnData` = [`InferDataFromTag`](../type-aliases/InferDataFromTag.md)\<`TQueryFnData`, `TTaggedQueryKey`\> + +#### Parameters + +##### queryKey + +`TTaggedQueryKey` + +The query key to set data for. + +##### updater + +[`Updater`](../type-aliases/Updater.md)\<`NoInfer`\<`TInferredQueryFnData`\> \| `undefined`, `NoInfer`\<`TInferredQueryFnData`\> \| `undefined`\> + +Either the new data, or a function that receives the current data (which +may be `undefined`) and returns the new data. + +##### options? + +[`SetDataOptions`](../interfaces/SetDataOptions.md) + +#### Returns + +`NoInfer`\<`TInferredQueryFnData`\> \| `undefined` + +#### Example + +```ts +queryClient.setQueryData(['posts'], newPosts) + +// Or, using an updater function that receives the current data: +queryClient.setQueryData(['posts'], (oldPosts) => [...oldPosts, newPost]) +``` + +*** + +### setQueryDefaults() + +```ts +setQueryDefaults(queryKey, options): void; +``` + +Defined in: [packages/query-core/src/queryClient.ts:858](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L858) + +Sets default options for queries whose query key partially matches the given `queryKey`. + +If several registered query defaults match a given query key, they are merged together in +registration order by [QueryClient#getQueryDefaults](#getquerydefaults), so register defaults from the +most generic key to the least generic one — more specific defaults should be registered +after more generic ones so they take precedence. + +#### Type Parameters + +##### TQueryFnData + +`TQueryFnData` = `unknown` + +##### TError + +`TError` = `Error` + +##### TData + +`TData` = `TQueryFnData` + +##### TQueryData + +`TQueryData` = `TQueryFnData` + +#### Parameters + +##### queryKey + +readonly `unknown`[] + +##### options + +`Partial`\<[`OmitKeyof`](../type-aliases/OmitKeyof.md)\<[`QueryObserverOptions`](../interfaces/QueryObserverOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryData`\>, `"queryKey"`\>\> + +#### Returns + +`void` + +#### Example + +```ts +queryClient.setQueryDefaults(['posts'], { queryFn: fetchPosts }) + +await queryClient.query({ queryKey: ['posts'] }) +``` + +*** + +### unmount() + +```ts +unmount(): void; +``` + +Defined in: [packages/query-core/src/queryClient.ts:127](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L127) + +The inverse of [QueryClient#mount](#mount) — called by a framework adapter's +`QueryClientProvider`-equivalent when it unmounts. Only tears down the focus/online +listeners once the mount count returns to `0`. + +#### Returns + +`void` diff --git a/docs/framework/react/reference/classes/QueryObserver.md b/docs/framework/react/reference/classes/QueryObserver.md new file mode 100644 index 00000000000..938ddc396e6 --- /dev/null +++ b/docs/framework/react/reference/classes/QueryObserver.md @@ -0,0 +1,558 @@ +--- +id: QueryObserver +title: QueryObserver +redirect_from: + - reference/QueryObserver + - framework/react/reference/QueryObserver +--- + +Defined in: [packages/query-core/src/queryObserver.ts:57](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L57) + +A `QueryObserver` watches a single query in the `QueryCache` and computes a +`QueryObserverResult` from its state, recomputing and notifying subscribers +whenever the underlying query (or the observer's options) changes. It is +the primitive that framework adapters (e.g. `useQuery`) build their hooks +on top of, but it can also be used directly to observe and switch between +queries outside of any framework. + +## Example + +```ts +const observer = new QueryObserver(queryClient, { + queryKey: ['posts'], + queryFn: fetchPosts, +}) + +const unsubscribe = observer.subscribe((result) => { + console.log(result.data) +}) +``` + +## Extends + +- `Subscribable`\<`QueryObserverListener`\<`TData`, `TError`\>\> + +## Extended by + +- [`InfiniteQueryObserver`](InfiniteQueryObserver.md) + +## Type Parameters + +### TQueryFnData + +`TQueryFnData` = `unknown` + +### TError + +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) + +### TData + +`TData` = `TQueryFnData` + +### TQueryData + +`TQueryData` = `TQueryFnData` + +### TQueryKey + +`TQueryKey` *extends* [`QueryKey`](../type-aliases/QueryKey.md) = [`QueryKey`](../type-aliases/QueryKey.md) + +## Constructors + +### Constructor + +```ts +new QueryObserver(client, options): QueryObserver; +``` + +Defined in: [packages/query-core/src/queryObserver.ts:87](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L87) + +#### Parameters + +##### client + +[`QueryClient`](QueryClient.md) + +##### options + +[`QueryObserverOptions`](../interfaces/QueryObserverOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryData`, `TQueryKey`\> + +#### Returns + +`QueryObserver`\<`TQueryFnData`, `TError`, `TData`, `TQueryData`, `TQueryKey`\> + +#### Overrides + +```ts +Subscribable>.constructor +``` + +## Properties + +### listeners + +```ts +protected listeners: Set>; +``` + +Defined in: [packages/query-core/src/subscribable.ts:2](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L2) + +#### Inherited from + +```ts +Subscribable.listeners +``` + +*** + +### options + +```ts +options: QueryObserverOptions; +``` + +Defined in: [packages/query-core/src/queryObserver.ts:89](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L89) + +## Methods + +### bindMethods() + +```ts +protected bindMethods(): void; +``` + +Defined in: [packages/query-core/src/queryObserver.ts:106](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L106) + +#### Returns + +`void` + +*** + +### createResult() + +```ts +protected createResult(query, options): QueryObserverResult; +``` + +Defined in: [packages/query-core/src/queryObserver.ts:559](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L559) + +#### Parameters + +##### query + +[`Query`](Query.md)\<`TQueryFnData`, `TError`, `TQueryData`, `TQueryKey`\> + +##### options + +[`QueryObserverOptions`](../interfaces/QueryObserverOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryData`, `TQueryKey`\> + +#### Returns + +[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\> + +*** + +### destroy() + +```ts +destroy(): void; +``` + +Defined in: [packages/query-core/src/queryObserver.ts:161](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L161) + +Stops observing the current query: clears all listeners, cancels the +stale and refetch-interval timers, and removes this observer from the +query it was observing. + +#### Returns + +`void` + +*** + +### fetch() + +```ts +protected fetch(fetchOptions): Promise>; +``` + +Defined in: [packages/query-core/src/queryObserver.ts:448](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L448) + +#### Parameters + +##### fetchOptions + +`ObserverFetchOptions` + +#### Returns + +`Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> + +*** + +### fetchOptimistic() + +```ts +fetchOptimistic(options): Promise>; +``` + +Defined in: [packages/query-core/src/queryObserver.ts:395](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L395) + +Fetches a query defined by the given options without affecting this +observer's own tracked query or result, and returns a promise that +resolves with the `QueryObserverResult` for that fetch. This is useful +for prefetching data that another observer (e.g. a query about to be +navigated to) will need, ahead of time. + +#### Parameters + +##### options + +[`QueryObserverOptions`](../interfaces/QueryObserverOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryData`, `TQueryKey`\> + +#### Returns + +`Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> + +#### Example + +```ts +const result = await observer.fetchOptimistic({ + queryKey: ['posts', 2], + queryFn: () => fetchPost(2), +}) +console.log(result.data) +``` + +*** + +### getCurrentQuery() + +```ts +getCurrentQuery(): Query; +``` + +Defined in: [packages/query-core/src/queryObserver.ts:357](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L357) + +Returns the `Query` instance this observer is currently observing. + +#### Returns + +[`Query`](Query.md)\<`TQueryFnData`, `TError`, `TQueryData`, `TQueryKey`\> + +*** + +### getCurrentResult() + +```ts +getCurrentResult(): QueryObserverResult; +``` + +Defined in: [packages/query-core/src/queryObserver.ts:321](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L321) + +Returns the most recently computed `QueryObserverResult` for the +observed query. This is a point-in-time read; to be notified of updates +as they happen, subscribe to the observer instead (its inherited +`subscribe` method). + +#### Returns + +[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\> + +#### Example + +```ts +const result = observer.getCurrentResult() +console.log(result.status, result.data) +``` + +*** + +### getOptimisticResult() + +```ts +getOptimisticResult(options): QueryObserverResult; +``` + +Defined in: [packages/query-core/src/queryObserver.ts:272](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L272) + +Computes the result the observer would produce for the given (already-defaulted) options +right now, building the underlying `Query` if it doesn't exist yet, without waiting for a +subscription callback. Called by framework adapters on every render (e.g. `useQuery`) so the +returned value is available synchronously, ahead of `setOptions` triggering an actual fetch. + +#### Parameters + +##### options + +[`DefaultedQueryObserverOptions`](../type-aliases/DefaultedQueryObserverOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryData`, `TQueryKey`\> + +#### Returns + +[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\> + +*** + +### hasListeners() + +```ts +hasListeners(): boolean; +``` + +Defined in: [packages/query-core/src/subscribable.ts:19](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L19) + +#### Returns + +`boolean` + +#### Inherited from + +```ts +Subscribable.hasListeners +``` + +*** + +### onSubscribe() + +```ts +protected onSubscribe(): void; +``` + +Defined in: [packages/query-core/src/queryObserver.ts:110](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L110) + +#### Returns + +`void` + +#### Overrides + +```ts +Subscribable.onSubscribe +``` + +*** + +### onUnsubscribe() + +```ts +protected onUnsubscribe(): void; +``` + +Defined in: [packages/query-core/src/queryObserver.ts:124](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L124) + +#### Returns + +`void` + +#### Overrides + +```ts +Subscribable.onUnsubscribe +``` + +*** + +### refetch() + +```ts +refetch(__namedParameters): Promise>; +``` + +Defined in: [packages/query-core/src/queryObserver.ts:371](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L371) + +Refetches the observed query and returns a promise that resolves with +the resulting `QueryObserverResult`. + +#### Parameters + +##### \_\_namedParameters + +[`RefetchOptions`](../interfaces/RefetchOptions.md) = `{}` + +#### Returns + +`Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> + +#### Example + +```ts +const result = await observer.refetch({ cancelRefetch: false }) +console.log(result.data) +``` + +*** + +### setOptions() + +```ts +setOptions(options): void; +``` + +Defined in: [packages/query-core/src/queryObserver.ts:182](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L182) + +Updates the observer's options. This will re-resolve the query being +observed (switching to a different query if the `queryKey` changed), +trigger a fetch if the new options require one and the observer has +subscribers, recompute the current result, and reschedule the stale and +refetch-interval timers as needed. + +#### Parameters + +##### options + +[`QueryObserverOptions`](../interfaces/QueryObserverOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryData`, `TQueryKey`\> + +#### Returns + +`void` + +#### Example + +```ts +observer.setOptions({ queryKey: ['posts', 1], queryFn: () => fetchPost(1) }) +// later: switch to a different query, reusing the same observer +observer.setOptions({ queryKey: ['posts', 2], queryFn: () => fetchPost(2) }) +``` + +*** + +### shouldFetchOnReconnect() + +```ts +shouldFetchOnReconnect(): boolean; +``` + +Defined in: [packages/query-core/src/queryObserver.ts:135](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L135) + +Returns whether the observed query is currently stale and configured +(via the `refetchOnReconnect` option) to refetch when the network +reconnects. + +#### Returns + +`boolean` + +*** + +### shouldFetchOnWindowFocus() + +```ts +shouldFetchOnWindowFocus(): boolean; +``` + +Defined in: [packages/query-core/src/queryObserver.ts:148](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L148) + +Returns whether the observed query is currently stale and configured +(via the `refetchOnWindowFocus` option) to refetch when the window +regains focus. + +#### Returns + +`boolean` + +*** + +### subscribe() + +```ts +subscribe(listener): () => void; +``` + +Defined in: [packages/query-core/src/subscribable.ts:8](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L8) + +#### Parameters + +##### listener + +`QueryObserverListener` + +#### Returns + +```ts +(): void; +``` + +##### Returns + +`void` + +#### Inherited from + +```ts +Subscribable.subscribe +``` + +*** + +### trackProp() + +```ts +trackProp(key): void; +``` + +Defined in: [packages/query-core/src/queryObserver.ts:350](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L350) + +Records that the given `QueryObserverResult` property was read, so a subsequent update only +notifies this observer if a tracked property actually changed. Normally called indirectly via +[QueryObserver#trackResult](#trackresult)'s proxy; exposed directly for adapters that track property +access themselves (e.g. through their own reactivity system) instead of via the proxy. + +#### Parameters + +##### key + +`"error"` | `"data"` | `"isError"` | `"isPending"` | `"isLoading"` | `"isLoadingError"` | `"isRefetchError"` | `"isSuccess"` | `"isPlaceholderData"` | `"status"` | `"dataUpdatedAt"` | `"errorUpdatedAt"` | `"failureCount"` | `"failureReason"` | `"errorUpdateCount"` | `"isFetched"` | `"isFetchedAfterMount"` | `"isFetching"` | `"isInitialLoading"` | `"isPaused"` | `"isRefetching"` | `"isStale"` | `"isEnabled"` | `"refetch"` | `"fetchStatus"` + +#### Returns + +`void` + +*** + +### trackResult() + +```ts +trackResult(result, onPropTracked?): QueryObserverResult; +``` + +Defined in: [packages/query-core/src/queryObserver.ts:331](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L331) + +Wraps a `QueryObserverResult` in a `Proxy` that records which properties are read, via +[QueryObserver#trackProp](#trackprop) (and an optional `onPropTracked` callback). Used by framework +adapters when `notifyOnChangeProps` is not set, to implement its default "only re-render on +properties you actually read" behavior. + +#### Parameters + +##### result + +[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\> + +##### onPropTracked? + +(`key`) => `void` + +#### Returns + +[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\> + +*** + +### updateResult() + +```ts +updateResult(): void; +``` + +Defined in: [packages/query-core/src/queryObserver.ts:735](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L735) + +Recomputes and stores the current result from the current query/options, notifying listeners +if it changed. Framework adapters call this right after subscribing to make sure no query +update was missed in the gap between creating the observer and subscribing to it. + +#### Returns + +`void` diff --git a/docs/framework/react/reference/functions/HydrationBoundary.md b/docs/framework/react/reference/functions/HydrationBoundary.md index e00f10b5ba1..43ceb13dde8 100644 --- a/docs/framework/react/reference/functions/HydrationBoundary.md +++ b/docs/framework/react/reference/functions/HydrationBoundary.md @@ -7,7 +7,7 @@ title: HydrationBoundary function HydrationBoundary(__namedParameters): ReactElement>; ``` -Defined in: [react-query/src/HydrationBoundary.tsx:86](https://github.com/TanStack/query/blob/main/packages/react-query/src/HydrationBoundary.tsx#L86) +Defined in: [packages/react-query/src/HydrationBoundary.tsx:86](https://github.com/TanStack/query/blob/main/packages/react-query/src/HydrationBoundary.tsx#L86) `HydrationBoundary` adds a previously dehydrated state into the `queryClient` that would be returned by `useQueryClient()`. If the client already contains data, the new queries will be intelligently merged based on diff --git a/docs/framework/react/reference/functions/QueryClientProvider.md b/docs/framework/react/reference/functions/QueryClientProvider.md index b0bf08337d6..364425d3134 100644 --- a/docs/framework/react/reference/functions/QueryClientProvider.md +++ b/docs/framework/react/reference/functions/QueryClientProvider.md @@ -9,7 +9,7 @@ redirect_from: function QueryClientProvider(__namedParameters): Element; ``` -Defined in: [react-query/src/QueryClientProvider.tsx:70](https://github.com/TanStack/query/blob/main/packages/react-query/src/QueryClientProvider.tsx#L70) +Defined in: [packages/react-query/src/QueryClientProvider.tsx:70](https://github.com/TanStack/query/blob/main/packages/react-query/src/QueryClientProvider.tsx#L70) Use the `QueryClientProvider` component to connect and provide a `QueryClient` to your application. Also calls `client.mount()`/`client.unmount()` as this component mounts/unmounts, which subscribes the client to diff --git a/docs/framework/react/reference/functions/QueryErrorResetBoundary.md b/docs/framework/react/reference/functions/QueryErrorResetBoundary.md index 463925af015..4d9db5e94fb 100644 --- a/docs/framework/react/reference/functions/QueryErrorResetBoundary.md +++ b/docs/framework/react/reference/functions/QueryErrorResetBoundary.md @@ -9,7 +9,7 @@ redirect_from: function QueryErrorResetBoundary(__namedParameters): Element; ``` -Defined in: [react-query/src/QueryErrorResetBoundary.tsx:136](https://github.com/TanStack/query/blob/main/packages/react-query/src/QueryErrorResetBoundary.tsx#L136) +Defined in: [packages/react-query/src/QueryErrorResetBoundary.tsx:136](https://github.com/TanStack/query/blob/main/packages/react-query/src/QueryErrorResetBoundary.tsx#L136) When using `suspense` or `throwOnError` in your queries, you need a way to let queries know that you want to try again when re-rendering after some error occurred. With the `QueryErrorResetBoundary` component you can diff --git a/docs/framework/react/reference/functions/defaultShouldDehydrateMutation.md b/docs/framework/react/reference/functions/defaultShouldDehydrateMutation.md new file mode 100644 index 00000000000..940f8745a5d --- /dev/null +++ b/docs/framework/react/reference/functions/defaultShouldDehydrateMutation.md @@ -0,0 +1,23 @@ +--- +id: defaultShouldDehydrateMutation +title: defaultShouldDehydrateMutation +--- + +```ts +function defaultShouldDehydrateMutation(mutation): boolean; +``` + +Defined in: [packages/query-core/src/hydration.ts:177](https://github.com/TanStack/query/blob/main/packages/query-core/src/hydration.ts#L177) + +The default `shouldDehydrateMutation` predicate used by `dehydrate`. Only dehydrates mutations that are +currently paused (e.g. paused by `networkMode` while offline). + +## Parameters + +### mutation + +[`Mutation`](../classes/Mutation.md) + +## Returns + +`boolean` diff --git a/docs/framework/react/reference/functions/defaultShouldDehydrateQuery.md b/docs/framework/react/reference/functions/defaultShouldDehydrateQuery.md new file mode 100644 index 00000000000..abf19439d8a --- /dev/null +++ b/docs/framework/react/reference/functions/defaultShouldDehydrateQuery.md @@ -0,0 +1,23 @@ +--- +id: defaultShouldDehydrateQuery +title: defaultShouldDehydrateQuery +--- + +```ts +function defaultShouldDehydrateQuery(query): boolean; +``` + +Defined in: [packages/query-core/src/hydration.ts:185](https://github.com/TanStack/query/blob/main/packages/query-core/src/hydration.ts#L185) + +The default `shouldDehydrateQuery` predicate used by `dehydrate`. Only dehydrates queries whose status is +`'success'`. + +## Parameters + +### query + +[`Query`](../classes/Query.md) + +## Returns + +`boolean` diff --git a/docs/framework/react/reference/functions/dehydrate.md b/docs/framework/react/reference/functions/dehydrate.md new file mode 100644 index 00000000000..33cdcd3940d --- /dev/null +++ b/docs/framework/react/reference/functions/dehydrate.md @@ -0,0 +1,43 @@ +--- +id: dehydrate +title: dehydrate +--- + +```ts +function dehydrate(client, options): DehydratedState; +``` + +Defined in: [packages/query-core/src/hydration.ts:207](https://github.com/TanStack/query/blob/main/packages/query-core/src/hydration.ts#L207) + +Dehydrates a `QueryClient`'s cache (queries and mutations) into a plain, serializable `DehydratedState`, +typically to embed in server-rendered markup and later restore into a client-side `QueryClient` via `hydrate`. +Which queries/mutations are included, and how their data/errors are transformed, is controlled by `options`, +falling back to the client's `dehydrate` default options, and finally to `defaultShouldDehydrateQuery` / +`defaultShouldDehydrateMutation`. + +## Parameters + +### client + +[`QueryClient`](../classes/QueryClient.md) + +### options + +[`DehydrateOptions`](../interfaces/DehydrateOptions.md) = `{}` + +## Returns + +[`DehydratedState`](../interfaces/DehydratedState.md) + +## Example + +```ts +const queryClient = new QueryClient() + +await queryClient.prefetchQuery({ + queryKey: ['posts'], + queryFn: getPosts, +}) + +const dehydratedState = dehydrate(queryClient) +``` diff --git a/docs/framework/react/reference/functions/dehydrateQuery.md b/docs/framework/react/reference/functions/dehydrateQuery.md new file mode 100644 index 00000000000..2314f52fd91 --- /dev/null +++ b/docs/framework/react/reference/functions/dehydrateQuery.md @@ -0,0 +1,43 @@ +--- +id: dehydrateQuery +title: dehydrateQuery +--- + +```ts +function dehydrateQuery( + query, + serializeData?, + shouldRedactErrors?): DehydratedQuery; +``` + +Defined in: [packages/query-core/src/hydration.ts:148](https://github.com/TanStack/query/blob/main/packages/query-core/src/hydration.ts#L148) + +Dehydrates a single `Query` into a serializable `DehydratedQuery` snapshot. Note that most query config (e.g. +`queryFn`, `staleTime`) is not dehydrated but instead meant to be configured again when consuming the +de/rehydrated data, typically with `useQuery` on the client. If the query is still `pending`, its in-flight +promise is dehydrated too so it can be resumed on the other side instead of re-fetched. + +## Parameters + +### query + +[`Query`](../classes/Query.md) + +The query to dehydrate. + +### serializeData? + +`TransformerFn` + +Optional transform applied to `query.state.data` before it is included in the snapshot. + +### shouldRedactErrors? + +(`error`) => `boolean` + +Optional predicate; if it returns `false` for the promise's rejection error, that +error is kept as-is instead of being redacted. + +## Returns + +`DehydratedQuery` diff --git a/docs/framework/react/reference/functions/experimental_streamedQuery.md b/docs/framework/react/reference/functions/experimental_streamedQuery.md new file mode 100644 index 00000000000..c535a8664d8 --- /dev/null +++ b/docs/framework/react/reference/functions/experimental_streamedQuery.md @@ -0,0 +1,54 @@ +--- +id: experimental_streamedQuery +title: experimental_streamedQuery +redirect_from: + - reference/streamedQuery +--- + +```ts +function experimental_streamedQuery(streamFn): QueryFunction; +``` + +Defined in: [packages/query-core/src/streamedQuery.ts:75](https://github.com/TanStack/query/blob/main/packages/query-core/src/streamedQuery.ts#L75) + +This is a helper function to create a query function that streams data from an AsyncIterable. +Data will be an Array of all the chunks received. +The query will be in a 'pending' state until the first chunk of data is received, but will go to 'success' after that. +The query will stay in fetchStatus 'fetching' until the stream ends. + +## Type Parameters + +### TQueryFnData + +`TQueryFnData` = `unknown` + +### TData + +`TData` = `TQueryFnData`[] + +### TQueryKey + +`TQueryKey` *extends* readonly `unknown`[] = readonly `unknown`[] + +## Parameters + +### streamFn + +`StreamedQueryParams`\<`TQueryFnData`, `TData`, `TQueryKey`\> + +The function that returns an AsyncIterable to stream data from. + +## Returns + +[`QueryFunction`](../type-aliases/QueryFunction.md)\<`TData`, `TQueryKey`\> + +## Example + +```ts +await queryClient.query({ + queryKey: ['data'], + queryFn: streamedQuery({ + streamFn: fetchDataInChunks, + }), +}) +``` diff --git a/docs/framework/react/reference/functions/hashKey.md b/docs/framework/react/reference/functions/hashKey.md new file mode 100644 index 00000000000..dc774c032ce --- /dev/null +++ b/docs/framework/react/reference/functions/hashKey.md @@ -0,0 +1,30 @@ +--- +id: hashKey +title: hashKey +--- + +```ts +function hashKey(queryKey): string; +``` + +Defined in: [packages/query-core/src/utils.ts:284](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L284) + +Default query & mutation keys hash function. +Hashes the value into a stable hash. + +## Parameters + +### queryKey + +readonly `unknown`[] + +## Returns + +`string` + +## Example + +```ts +// Object keys are sorted, so key order doesn't affect the hash: +hashKey(['todos', { page: 1, filter: 'done' }]) // === '["todos",{"filter":"done","page":1}]' +``` diff --git a/docs/framework/react/reference/functions/hydrate.md b/docs/framework/react/reference/functions/hydrate.md new file mode 100644 index 00000000000..c0093b57457 --- /dev/null +++ b/docs/framework/react/reference/functions/hydrate.md @@ -0,0 +1,49 @@ +--- +id: hydrate +title: hydrate +--- + +```ts +function hydrate( + client, + dehydratedState, + options?): void; +``` + +Defined in: [packages/query-core/src/hydration.ts:264](https://github.com/TanStack/query/blob/main/packages/query-core/src/hydration.ts#L264) + +Restores a `DehydratedState` (as produced by `dehydrate`) into a `QueryClient`'s cache, typically to seed the +client with data already fetched on the server. `mutations` and `queries` are each optional on `dehydratedState`. +Queries not yet in the cache are built from the dehydrated snapshot; queries that already exist are only updated +when the dehydrated data is newer than what's already cached. Newly built queries have their `fetchStatus` reset +to `'idle'` so they don't hydrate stuck in a fetching state. If a dehydrated query still had an in-flight +promise, it is resumed via `query.fetch()` (reusing that promise as `initialPromise`) rather than re-invoking +`queryFn`. + +## Parameters + +### client + +[`QueryClient`](../classes/QueryClient.md) + +### dehydratedState + +`Partial`\<[`DehydratedState`](../interfaces/DehydratedState.md)\> + +### options? + +[`HydrateOptions`](../interfaces/HydrateOptions.md) + +## Returns + +`void` + +## Example + +```ts +// dehydratedState was produced by `dehydrate` on the server +// and sent to the client, e.g. embedded in server-rendered markup. +const queryClient = new QueryClient() + +hydrate(queryClient, dehydratedState) +``` diff --git a/docs/framework/react/reference/functions/infiniteQueryOptions.md b/docs/framework/react/reference/functions/infiniteQueryOptions.md index acd4d4b585a..38532ef5496 100644 --- a/docs/framework/react/reference/functions/infiniteQueryOptions.md +++ b/docs/framework/react/reference/functions/infiniteQueryOptions.md @@ -11,7 +11,7 @@ redirect_from: function infiniteQueryOptions(options): UseInfiniteQueryOptions & object & QueryKeyWithDataTag, TError>; ``` -Defined in: [react-query/src/infiniteQueryOptions.ts:170](https://github.com/TanStack/query/blob/main/packages/react-query/src/infiniteQueryOptions.ts#L170) +Defined in: [packages/react-query/src/infiniteQueryOptions.ts:170](https://github.com/TanStack/query/blob/main/packages/react-query/src/infiniteQueryOptions.ts#L170) You can generally pass everything to `infiniteQueryOptions` that you can also pass to `useInfiniteQuery`. These options can be shared across hooks and imperative APIs such as `queryClient.infiniteQuery`. @@ -31,7 +31,7 @@ This overload is selected when `initialData` is set. #### TData -`TData` = `InfiniteData`\<`TQueryFnData`, `unknown`\> +`TData` = [`InfiniteData`](../interfaces/InfiniteData.md)\<`TQueryFnData`, `unknown`\> #### TQueryKey @@ -97,7 +97,7 @@ function Projects() { function infiniteQueryOptions(options): OmitKeyof, "queryFn"> & object & QueryKeyWithDataTag, TError>; ``` -Defined in: [react-query/src/infiniteQueryOptions.ts:232](https://github.com/TanStack/query/blob/main/packages/react-query/src/infiniteQueryOptions.ts#L232) +Defined in: [packages/react-query/src/infiniteQueryOptions.ts:232](https://github.com/TanStack/query/blob/main/packages/react-query/src/infiniteQueryOptions.ts#L232) You can generally pass everything to `infiniteQueryOptions` that you can also pass to `useInfiniteQuery`. These options can be shared across hooks and imperative APIs such as `queryClient.infiniteQuery`. @@ -115,7 +115,7 @@ These options can be shared across hooks and imperative APIs such as `queryClien #### TData -`TData` = `InfiniteData`\<`TQueryFnData`, `unknown`\> +`TData` = [`InfiniteData`](../interfaces/InfiniteData.md)\<`TQueryFnData`, `unknown`\> #### TQueryKey @@ -180,7 +180,7 @@ function Comments({ postId }: { postId: string }) { function infiniteQueryOptions(options): UseInfiniteQueryOptions & object & QueryKeyWithDataTag, TError>; ``` -Defined in: [react-query/src/infiniteQueryOptions.ts:294](https://github.com/TanStack/query/blob/main/packages/react-query/src/infiniteQueryOptions.ts#L294) +Defined in: [packages/react-query/src/infiniteQueryOptions.ts:294](https://github.com/TanStack/query/blob/main/packages/react-query/src/infiniteQueryOptions.ts#L294) You can generally pass everything to `infiniteQueryOptions` that you can also pass to `useInfiniteQuery`. These options can be shared across hooks and imperative APIs such as `queryClient.infiniteQuery`. @@ -198,7 +198,7 @@ These options can be shared across hooks and imperative APIs such as `queryClien #### TData -`TData` = `InfiniteData`\<`TQueryFnData`, `unknown`\> +`TData` = [`InfiniteData`](../interfaces/InfiniteData.md)\<`TQueryFnData`, `unknown`\> #### TQueryKey diff --git a/docs/framework/react/reference/functions/isCancelledError.md b/docs/framework/react/reference/functions/isCancelledError.md new file mode 100644 index 00000000000..c8f57c4b94d --- /dev/null +++ b/docs/framework/react/reference/functions/isCancelledError.md @@ -0,0 +1,24 @@ +--- +id: isCancelledError +title: isCancelledError +--- + +```ts +function isCancelledError(value): value is CancelledError; +``` + +Defined in: [packages/query-core/src/retryer.ts:90](https://github.com/TanStack/query/blob/main/packages/query-core/src/retryer.ts#L90) + +## Parameters + +### value + +`any` + +## Returns + +`value is CancelledError` + +## Deprecated + +Use instanceof `CancelledError` instead. diff --git a/docs/framework/react/reference/functions/keepPreviousData.md b/docs/framework/react/reference/functions/keepPreviousData.md new file mode 100644 index 00000000000..6a84f4c5970 --- /dev/null +++ b/docs/framework/react/reference/functions/keepPreviousData.md @@ -0,0 +1,40 @@ +--- +id: keepPreviousData +title: keepPreviousData +--- + +```ts +function keepPreviousData(previousData): T | undefined; +``` + +Defined in: [packages/query-core/src/utils.ts:493](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L493) + +Intended to be passed as a query's `placeholderData` option, for example +`placeholderData: keepPreviousData`. Instead of resetting the query's data to `undefined` while a new +query key is fetching, it keeps displaying the previously fetched data until the new data arrives. + +## Type Parameters + +### T + +`T` + +## Parameters + +### previousData + +`T` | `undefined` + +## Returns + +`T` \| `undefined` + +## Example + +```ts +new QueryObserver(queryClient, { + queryKey: ['posts', page], + queryFn: () => fetchPosts(page), + placeholderData: keepPreviousData, +}) +``` diff --git a/docs/framework/react/reference/functions/matchMutation.md b/docs/framework/react/reference/functions/matchMutation.md new file mode 100644 index 00000000000..40210da4cf1 --- /dev/null +++ b/docs/framework/react/reference/functions/matchMutation.md @@ -0,0 +1,38 @@ +--- +id: matchMutation +title: matchMutation +--- + +```ts +function matchMutation(filters, mutation): boolean; +``` + +Defined in: [packages/query-core/src/utils.ts:237](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L237) + +Checks whether a mutation matches the given [MutationFilters](../interfaces/MutationFilters.md). +Every filter that is specified must match; filters that are left unspecified are ignored. +If a `mutationKey` filter is provided but the mutation has no `mutationKey` of its own, it does not match. + +## Parameters + +### filters + +[`MutationFilters`](../interfaces/MutationFilters.md) + +### mutation + +[`Mutation`](../classes/Mutation.md)\<`any`, `any`\> + +## Returns + +`boolean` + +## Example + +```ts +const mutationCache = queryClient.getMutationCache() + +const matchingMutations = mutationCache + .getAll() + .filter((mutation) => matchMutation({ mutationKey: ['addPost'] }, mutation)) +``` diff --git a/docs/framework/react/reference/functions/matchQuery.md b/docs/framework/react/reference/functions/matchQuery.md new file mode 100644 index 00000000000..4c54b2df995 --- /dev/null +++ b/docs/framework/react/reference/functions/matchQuery.md @@ -0,0 +1,37 @@ +--- +id: matchQuery +title: matchQuery +--- + +```ts +function matchQuery(filters, query): boolean; +``` + +Defined in: [packages/query-core/src/utils.ts:175](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L175) + +Checks whether a query matches the given [QueryFilters](../interfaces/QueryFilters.md). +Every filter that is specified must match; filters that are left unspecified are ignored. + +## Parameters + +### filters + +[`QueryFilters`](../interfaces/QueryFilters.md) + +### query + +[`Query`](../classes/Query.md)\<`any`, `any`, `any`, `any`\> + +## Returns + +`boolean` + +## Example + +```ts +const queryCache = queryClient.getQueryCache() + +const matchingQueries = queryCache + .getAll() + .filter((query) => matchQuery({ queryKey: ['posts'] }, query)) +``` diff --git a/docs/framework/react/reference/functions/mutationOptions.md b/docs/framework/react/reference/functions/mutationOptions.md index 6b8908eda41..f9ecd3c747a 100644 --- a/docs/framework/react/reference/functions/mutationOptions.md +++ b/docs/framework/react/reference/functions/mutationOptions.md @@ -11,7 +11,7 @@ redirect_from: function mutationOptions(options): WithRequired, "mutationKey">; ``` -Defined in: [react-query/src/mutationOptions.ts:33](https://github.com/TanStack/query/blob/main/packages/react-query/src/mutationOptions.ts#L33) +Defined in: [packages/react-query/src/mutationOptions.ts:33](https://github.com/TanStack/query/blob/main/packages/react-query/src/mutationOptions.ts#L33) You can generally pass everything to `mutationOptions` that you can also pass to `useMutation`. A `mutationKey` is required on this overload so the mutation can be looked up later, e.g. with @@ -39,14 +39,14 @@ You can generally pass everything to `mutationOptions` that you can also pass to #### options -`WithRequired`\<[`UseMutationOptions`](../interfaces/UseMutationOptions.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\>, `"mutationKey"`\> +[`WithRequired`](../type-aliases/WithRequired.md)\<[`UseMutationOptions`](../interfaces/UseMutationOptions.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\>, `"mutationKey"`\> The mutation options to use, identical to what you'd pass to `useMutation`, with a required `mutationKey`. ### Returns -`WithRequired`\<[`UseMutationOptions`](../interfaces/UseMutationOptions.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\>, `"mutationKey"`\> +[`WithRequired`](../type-aliases/WithRequired.md)\<[`UseMutationOptions`](../interfaces/UseMutationOptions.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\>, `"mutationKey"`\> The same options object, unchanged. @@ -80,7 +80,7 @@ function SavingIndicator() { function mutationOptions(options): Omit, "mutationKey">; ``` -Defined in: [react-query/src/mutationOptions.ts:73](https://github.com/TanStack/query/blob/main/packages/react-query/src/mutationOptions.ts#L73) +Defined in: [packages/react-query/src/mutationOptions.ts:73](https://github.com/TanStack/query/blob/main/packages/react-query/src/mutationOptions.ts#L73) You can generally pass everything to `mutationOptions` that you can also pass to `useMutation`. No `mutationKey` is required on this overload — use this when you don't need to target the mutation via a diff --git a/docs/framework/react/reference/functions/noop.md b/docs/framework/react/reference/functions/noop.md new file mode 100644 index 00000000000..01fb409f4e9 --- /dev/null +++ b/docs/framework/react/reference/functions/noop.md @@ -0,0 +1,32 @@ +--- +id: noop +title: noop +--- + +## Call Signature + +```ts +function noop(): void; +``` + +Defined in: [packages/query-core/src/utils.ts:119](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L119) + +A function that does nothing. + +### Returns + +`void` + +## Call Signature + +```ts +function noop(): undefined; +``` + +Defined in: [packages/query-core/src/utils.ts:120](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L120) + +A function that does nothing. + +### Returns + +`undefined` diff --git a/docs/framework/react/reference/functions/partialMatchKey.md b/docs/framework/react/reference/functions/partialMatchKey.md new file mode 100644 index 00000000000..4db67323e9b --- /dev/null +++ b/docs/framework/react/reference/functions/partialMatchKey.md @@ -0,0 +1,26 @@ +--- +id: partialMatchKey +title: partialMatchKey +--- + +```ts +function partialMatchKey(a, b): boolean; +``` + +Defined in: [packages/query-core/src/utils.ts:300](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L300) + +Checks if key `b` partially matches with key `a`. + +## Parameters + +### a + +readonly `unknown`[] + +### b + +readonly `unknown`[] + +## Returns + +`boolean` diff --git a/docs/framework/react/reference/functions/queryOptions.md b/docs/framework/react/reference/functions/queryOptions.md index 85cd7896c40..ee56b2e62c3 100644 --- a/docs/framework/react/reference/functions/queryOptions.md +++ b/docs/framework/react/reference/functions/queryOptions.md @@ -11,7 +11,7 @@ redirect_from: function queryOptions(options): Omit, "queryFn"> & object & QueryKeyWithDataTag; ``` -Defined in: [react-query/src/queryOptions.ts:142](https://github.com/TanStack/query/blob/main/packages/react-query/src/queryOptions.ts#L142) +Defined in: [packages/react-query/src/queryOptions.ts:142](https://github.com/TanStack/query/blob/main/packages/react-query/src/queryOptions.ts#L142) You can generally pass everything to `queryOptions` that you can also pass to `useQuery`. These options can be shared across hooks and imperative APIs such as `queryClient.query`. `options.queryKey` is required and @@ -87,7 +87,7 @@ function Posts() { function queryOptions(options): OmitKeyof, "queryFn"> & object & QueryKeyWithDataTag; ``` -Defined in: [react-query/src/queryOptions.ts:183](https://github.com/TanStack/query/blob/main/packages/react-query/src/queryOptions.ts#L183) +Defined in: [packages/react-query/src/queryOptions.ts:183](https://github.com/TanStack/query/blob/main/packages/react-query/src/queryOptions.ts#L183) You can generally pass everything to `queryOptions` that you can also pass to `useQuery`. These options can be shared across hooks and imperative APIs such as `queryClient.query`. `options.queryKey` is required and @@ -156,7 +156,7 @@ function Post({ id }: { id: string }) { function queryOptions(options): UseQueryOptions & object & QueryKeyWithDataTag; ``` -Defined in: [react-query/src/queryOptions.ts:247](https://github.com/TanStack/query/blob/main/packages/react-query/src/queryOptions.ts#L247) +Defined in: [packages/react-query/src/queryOptions.ts:247](https://github.com/TanStack/query/blob/main/packages/react-query/src/queryOptions.ts#L247) You can generally pass everything to `queryOptions` that you can also pass to `useQuery`. These options can be shared across hooks and imperative APIs such as `queryClient.query`. `options.queryKey` is required and diff --git a/docs/framework/react/reference/functions/replaceEqualDeep.md b/docs/framework/react/reference/functions/replaceEqualDeep.md new file mode 100644 index 00000000000..6a81c3907fb --- /dev/null +++ b/docs/framework/react/reference/functions/replaceEqualDeep.md @@ -0,0 +1,41 @@ +--- +id: replaceEqualDeep +title: replaceEqualDeep +--- + +```ts +function replaceEqualDeep( + a, + b, + depth?): T; +``` + +Defined in: [packages/query-core/src/utils.ts:339](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L339) + +This function returns `a` if `b` is deeply equal. +If not, it will replace any deeply equal children of `b` with those of `a`. +This can be used for structural sharing between JSON values for example. + +## Type Parameters + +### T + +`T` + +## Parameters + +### a + +`unknown` + +### b + +`T` + +### depth? + +`number` + +## Returns + +`T` diff --git a/docs/framework/react/reference/functions/shouldThrowError.md b/docs/framework/react/reference/functions/shouldThrowError.md new file mode 100644 index 00000000000..1f1e62a8d0e --- /dev/null +++ b/docs/framework/react/reference/functions/shouldThrowError.md @@ -0,0 +1,45 @@ +--- +id: shouldThrowError +title: shouldThrowError +--- + +```ts +function shouldThrowError(throwOnError, params): boolean; +``` + +Defined in: [packages/query-core/src/utils.ts:576](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L576) + +Resolves a `throwOnError` option to a boolean. +If `throwOnError` is a function, it is called with `params` (e.g. the error and, depending on the caller, +additional context such as the query or mutation) and its result is returned, allowing the throwing +behavior to be decided per error. Otherwise, `throwOnError` itself is coerced to a boolean (`undefined` +resolves to `false`). + +## Type Parameters + +### T + +`T` *extends* (...`args`) => `boolean` + +## Parameters + +### throwOnError + +`boolean` | `T` | `undefined` + +### params + +`Parameters`\<`T`\> + +## Returns + +`boolean` + +## Example + +```ts +const throwOnError = + query.state.error && typeof options.throwOnError === 'function' + ? shouldThrowError(options.throwOnError, [query.state.error, query]) + : options.throwOnError +``` diff --git a/docs/framework/react/reference/functions/useInfiniteQuery.md b/docs/framework/react/reference/functions/useInfiniteQuery.md index 7d414644e55..ecddf154e80 100644 --- a/docs/framework/react/reference/functions/useInfiniteQuery.md +++ b/docs/framework/react/reference/functions/useInfiniteQuery.md @@ -11,7 +11,7 @@ redirect_from: function useInfiniteQuery(options, queryClient?): DefinedUseInfiniteQueryResult; ``` -Defined in: [react-query/src/useInfiniteQuery.ts:65](https://github.com/TanStack/query/blob/main/packages/react-query/src/useInfiniteQuery.ts#L65) +Defined in: [packages/react-query/src/useInfiniteQuery.ts:65](https://github.com/TanStack/query/blob/main/packages/react-query/src/useInfiniteQuery.ts#L65) The options for `useInfiniteQuery` are identical to `useQuery`, with the addition of `initialPageParam`, `getNextPageParam`, `getPreviousPageParam`, and `maxPages`. @@ -30,7 +30,7 @@ This overload is selected when `initialData` is set. #### TData -`TData` = `InfiniteData`\<`TQueryFnData`, `unknown`\> +`TData` = [`InfiniteData`](../interfaces/InfiniteData.md)\<`TQueryFnData`, `unknown`\> #### TQueryKey @@ -50,7 +50,7 @@ The [DefinedInitialDataInfiniteOptions](../type-aliases/DefinedInitialDataInfini #### queryClient? -`QueryClient` +[`QueryClient`](../classes/QueryClient.md) Use this to use a custom `QueryClient`. Otherwise, the one from the nearest context will be used. @@ -107,7 +107,7 @@ function Projects() { function useInfiniteQuery(options, queryClient?): UseInfiniteQueryResult; ``` -Defined in: [react-query/src/useInfiniteQuery.ts:191](https://github.com/TanStack/query/blob/main/packages/react-query/src/useInfiniteQuery.ts#L191) +Defined in: [packages/react-query/src/useInfiniteQuery.ts:191](https://github.com/TanStack/query/blob/main/packages/react-query/src/useInfiniteQuery.ts#L191) The options for `useInfiniteQuery` are identical to `useQuery`, with the addition of `initialPageParam`, `getNextPageParam`, `getPreviousPageParam`, and `maxPages`. @@ -124,7 +124,7 @@ The options for `useInfiniteQuery` are identical to `useQuery`, with the additio #### TData -`TData` = `InfiniteData`\<`TQueryFnData`, `unknown`\> +`TData` = [`InfiniteData`](../interfaces/InfiniteData.md)\<`TQueryFnData`, `unknown`\> #### TQueryKey @@ -144,7 +144,7 @@ The [UndefinedInitialDataInfiniteOptions](../type-aliases/UndefinedInitialDataIn #### queryClient? -`QueryClient` +[`QueryClient`](../classes/QueryClient.md) Use this to use a custom `QueryClient`. Otherwise, the one from the nearest context will be used. @@ -267,7 +267,7 @@ function Projects() { function useInfiniteQuery(options, queryClient?): UseInfiniteQueryResult; ``` -Defined in: [react-query/src/useInfiniteQuery.ts:347](https://github.com/TanStack/query/blob/main/packages/react-query/src/useInfiniteQuery.ts#L347) +Defined in: [packages/react-query/src/useInfiniteQuery.ts:347](https://github.com/TanStack/query/blob/main/packages/react-query/src/useInfiniteQuery.ts#L347) The options for `useInfiniteQuery` are identical to `useQuery`, with the addition of `initialPageParam`, `getNextPageParam`, `getPreviousPageParam`, and `maxPages`. @@ -284,7 +284,7 @@ The options for `useInfiniteQuery` are identical to `useQuery`, with the additio #### TData -`TData` = `InfiniteData`\<`TQueryFnData`, `unknown`\> +`TData` = [`InfiniteData`](../interfaces/InfiniteData.md)\<`TQueryFnData`, `unknown`\> #### TQueryKey @@ -304,7 +304,7 @@ The [UseInfiniteQueryOptions](../interfaces/UseInfiniteQueryOptions.md) to use #### queryClient? -`QueryClient` +[`QueryClient`](../classes/QueryClient.md) Use this to use a custom `QueryClient`. Otherwise, the one from the nearest context will be used. diff --git a/docs/framework/react/reference/functions/useIsFetching.md b/docs/framework/react/reference/functions/useIsFetching.md index a272b61e149..6d403597121 100644 --- a/docs/framework/react/reference/functions/useIsFetching.md +++ b/docs/framework/react/reference/functions/useIsFetching.md @@ -9,7 +9,7 @@ redirect_from: function useIsFetching(filters?, queryClient?): number; ``` -Defined in: [react-query/src/useIsFetching.ts:44](https://github.com/TanStack/query/blob/main/packages/react-query/src/useIsFetching.ts#L44) +Defined in: [packages/react-query/src/useIsFetching.ts:44](https://github.com/TanStack/query/blob/main/packages/react-query/src/useIsFetching.ts#L44) The `useIsFetching` hook returns the `number` of the queries that your application is loading or fetching in the background (useful for app-wide loading indicators). @@ -18,13 +18,13 @@ the background (useful for app-wide loading indicators). ### filters? -`QueryFilters`\ +[`QueryFilters`](../interfaces/QueryFilters.md)\ -The QueryFilters to narrow down the matched queries. +The [QueryFilters](../interfaces/QueryFilters.md) to narrow down the matched queries. ### queryClient? -`QueryClient` +[`QueryClient`](../classes/QueryClient.md) Use this to use a custom `QueryClient`. Otherwise, the one from the nearest context will be used. diff --git a/docs/framework/react/reference/functions/useIsMutating.md b/docs/framework/react/reference/functions/useIsMutating.md index 5d45b46b693..a143d32db0a 100644 --- a/docs/framework/react/reference/functions/useIsMutating.md +++ b/docs/framework/react/reference/functions/useIsMutating.md @@ -9,7 +9,7 @@ redirect_from: function useIsMutating(filters?, queryClient?): number; ``` -Defined in: [react-query/src/useMutationState.ts:35](https://github.com/TanStack/query/blob/main/packages/react-query/src/useMutationState.ts#L35) +Defined in: [packages/react-query/src/useMutationState.ts:35](https://github.com/TanStack/query/blob/main/packages/react-query/src/useMutationState.ts#L35) The `useIsMutating` hook returns the `number` of mutations that your application currently has `pending` (useful for app-wide loading indicators). @@ -18,13 +18,13 @@ The `useIsMutating` hook returns the `number` of mutations that your application ### filters? -`MutationFilters`\<`unknown`, `Error`, `unknown`, `unknown`\> +[`MutationFilters`](../interfaces/MutationFilters.md)\<`unknown`, `Error`, `unknown`, `unknown`\> -The MutationFilters to narrow down the matched mutations. +The [MutationFilters](../interfaces/MutationFilters.md) to narrow down the matched mutations. ### queryClient? -`QueryClient` +[`QueryClient`](../classes/QueryClient.md) Use this to use a custom `QueryClient`. Otherwise, the one from the nearest context will be used. diff --git a/docs/framework/react/reference/functions/useIsRestoring.md b/docs/framework/react/reference/functions/useIsRestoring.md index 4d55af9fd93..d2e0c293e45 100644 --- a/docs/framework/react/reference/functions/useIsRestoring.md +++ b/docs/framework/react/reference/functions/useIsRestoring.md @@ -7,7 +7,7 @@ title: useIsRestoring function useIsRestoring(): boolean; ``` -Defined in: [react-query/src/IsRestoringProvider.ts:13](https://github.com/TanStack/query/blob/main/packages/react-query/src/IsRestoringProvider.ts#L13) +Defined in: [packages/react-query/src/IsRestoringProvider.ts:13](https://github.com/TanStack/query/blob/main/packages/react-query/src/IsRestoringProvider.ts#L13) If you are using `PersistQueryClientProvider`, you can also use the `useIsRestoring` hook alongside it to check if a restore is currently in progress. `useQuery` and friends also check this internally to avoid diff --git a/docs/framework/react/reference/functions/useMutation.md b/docs/framework/react/reference/functions/useMutation.md index 8850b296418..4630aa1557e 100644 --- a/docs/framework/react/reference/functions/useMutation.md +++ b/docs/framework/react/reference/functions/useMutation.md @@ -9,7 +9,7 @@ redirect_from: function useMutation(options, queryClient?): UseMutationResult; ``` -Defined in: [react-query/src/useMutation.ts:191](https://github.com/TanStack/query/blob/main/packages/react-query/src/useMutation.ts#L191) +Defined in: [packages/react-query/src/useMutation.ts:191](https://github.com/TanStack/query/blob/main/packages/react-query/src/useMutation.ts#L191) Unlike queries, mutations are typically used to create/update/delete data or perform server side-effects. `useMutation` is the hook for that. @@ -42,7 +42,7 @@ The [UseMutationOptions](../interfaces/UseMutationOptions.md) to use — everyth ### queryClient? -`QueryClient` +[`QueryClient`](../classes/QueryClient.md) Use this to use a custom `QueryClient`. Otherwise, the one from the nearest context will be used. diff --git a/docs/framework/react/reference/functions/useMutationState.md b/docs/framework/react/reference/functions/useMutationState.md index 7e5325c86e6..377c24f5e45 100644 --- a/docs/framework/react/reference/functions/useMutationState.md +++ b/docs/framework/react/reference/functions/useMutationState.md @@ -9,21 +9,21 @@ redirect_from: function useMutationState(options, queryClient?): TResult[]; ``` -Defined in: [react-query/src/useMutationState.ts:157](https://github.com/TanStack/query/blob/main/packages/react-query/src/useMutationState.ts#L157) +Defined in: [packages/react-query/src/useMutationState.ts:157](https://github.com/TanStack/query/blob/main/packages/react-query/src/useMutationState.ts#L157) `useMutationState` is a hook that gives you access to all mutations in the `MutationCache`. You can pass -`filters` (MutationFilters) to narrow down your mutations, and `select` to transform the mutation +`filters` ([MutationFilters](../interfaces/MutationFilters.md)) to narrow down your mutations, and `select` to transform the mutation state. ## Type Parameters ### TResult -`TResult` = `MutationState`\<`unknown`, `Error`, `unknown`, `unknown`\> +`TResult` = [`MutationState`](../interfaces/MutationState.md)\<`unknown`, `Error`, `unknown`, `unknown`\> ### TMutation -`TMutation` *extends* `Mutation`\<`any`, `any`, `any`, `any`\> = `MutationTypeFromResult`\<`TResult`\> +`TMutation` *extends* [`Mutation`](../classes/Mutation.md)\<`any`, `any`, `any`, `any`\> = `MutationTypeFromResult`\<`TResult`\> ## Parameters @@ -36,7 +36,7 @@ mutation state. ### queryClient? -`QueryClient` +[`QueryClient`](../classes/QueryClient.md) Use this to use a custom `QueryClient`. Otherwise, the one from the nearest context will be used. diff --git a/docs/framework/react/reference/functions/usePrefetchInfiniteQuery.md b/docs/framework/react/reference/functions/usePrefetchInfiniteQuery.md index 179f2ab61d1..7bb628ad2c6 100644 --- a/docs/framework/react/reference/functions/usePrefetchInfiniteQuery.md +++ b/docs/framework/react/reference/functions/usePrefetchInfiniteQuery.md @@ -9,7 +9,7 @@ redirect_from: function usePrefetchInfiniteQuery(options, queryClient?): void; ``` -Defined in: [react-query/src/usePrefetchInfiniteQuery.tsx:56](https://github.com/TanStack/query/blob/main/packages/react-query/src/usePrefetchInfiniteQuery.tsx#L56) +Defined in: [packages/react-query/src/usePrefetchInfiniteQuery.tsx:56](https://github.com/TanStack/query/blob/main/packages/react-query/src/usePrefetchInfiniteQuery.tsx#L56) `usePrefetchInfiniteQuery` does not return anything, it should be used just to fire a prefetch during render, before a suspense boundary that wraps a component that uses `useSuspenseInfiniteQuery`. You can pass @@ -37,7 +37,7 @@ already there or already in flight. ### TData -`TData` = `InfiniteData`\<`TQueryFnData`, `unknown`\> +`TData` = [`InfiniteData`](../interfaces/InfiniteData.md)\<`TQueryFnData`, `unknown`\> ### TQueryKey @@ -57,7 +57,7 @@ The [UsePrefetchInfiniteQueryOptions](../type-aliases/UsePrefetchInfiniteQueryOp ### queryClient? -`QueryClient` +[`QueryClient`](../classes/QueryClient.md) Use this to use a custom `QueryClient`. Otherwise, the one from the nearest context will be used. diff --git a/docs/framework/react/reference/functions/usePrefetchQuery.md b/docs/framework/react/reference/functions/usePrefetchQuery.md index e8aa516f8ab..48994793786 100644 --- a/docs/framework/react/reference/functions/usePrefetchQuery.md +++ b/docs/framework/react/reference/functions/usePrefetchQuery.md @@ -9,7 +9,7 @@ redirect_from: function usePrefetchQuery(options, queryClient?): void; ``` -Defined in: [react-query/src/usePrefetchQuery.tsx:42](https://github.com/TanStack/query/blob/main/packages/react-query/src/usePrefetchQuery.tsx#L42) +Defined in: [packages/react-query/src/usePrefetchQuery.tsx:42](https://github.com/TanStack/query/blob/main/packages/react-query/src/usePrefetchQuery.tsx#L42) `usePrefetchQuery` does not return anything, it should be used just to fire a prefetch during render, before a suspense boundary that wraps a component that uses `useSuspenseQuery`. You can pass everything to @@ -52,7 +52,7 @@ The [UsePrefetchQueryOptions](../type-aliases/UsePrefetchQueryOptions.md) to use ### queryClient? -`QueryClient` +[`QueryClient`](../classes/QueryClient.md) Use this to use a custom `QueryClient`. Otherwise, the one from the nearest context will be used. diff --git a/docs/framework/react/reference/functions/useQueries.md b/docs/framework/react/reference/functions/useQueries.md index c026f3f0683..3cca2e98031 100644 --- a/docs/framework/react/reference/functions/useQueries.md +++ b/docs/framework/react/reference/functions/useQueries.md @@ -9,7 +9,7 @@ redirect_from: function useQueries(__namedParameters, queryClient?): TCombinedResult; ``` -Defined in: [react-query/src/useQueries.ts:355](https://github.com/TanStack/query/blob/main/packages/react-query/src/useQueries.ts#L355) +Defined in: [packages/react-query/src/useQueries.ts:355](https://github.com/TanStack/query/blob/main/packages/react-query/src/useQueries.ts#L355) The `useQueries` hook can be used to fetch a variable number of queries. @@ -52,7 +52,7 @@ shared to be as referentially stable as possible. An array with query option objects, mostly identical to `useQuery` — except that `queryClient` and `subscribed` aren't accepted per-query (`subscribed` is a top-level option here instead), and -`placeholderData` accepts a QueriesPlaceholderDataFunction, which is called with `previousData` +`placeholderData` accepts a [QueriesPlaceholderDataFunction](../type-aliases/QueriesPlaceholderDataFunction.md), which is called with `previousData` and `previousQuery` always `undefined`, rather than `useQuery`'s placeholder function. #### subscribed? @@ -69,7 +69,7 @@ true ### queryClient? -`QueryClient` +[`QueryClient`](../classes/QueryClient.md) Use this to provide a custom `QueryClient`. Otherwise, the one from the nearest context will be used. diff --git a/docs/framework/react/reference/functions/useQuery.md b/docs/framework/react/reference/functions/useQuery.md index 010680f644a..d0d3b478b1d 100644 --- a/docs/framework/react/reference/functions/useQuery.md +++ b/docs/framework/react/reference/functions/useQuery.md @@ -11,7 +11,7 @@ redirect_from: function useQuery(options, queryClient?): DefinedUseQueryResult; ``` -Defined in: [react-query/src/useQuery.ts:50](https://github.com/TanStack/query/blob/main/packages/react-query/src/useQuery.ts#L50) +Defined in: [packages/react-query/src/useQuery.ts:50](https://github.com/TanStack/query/blob/main/packages/react-query/src/useQuery.ts#L50) This overload is selected when `initialData` is set, so the resulting `data` is never `undefined`. @@ -43,7 +43,7 @@ The [DefinedInitialDataOptions](../type-aliases/DefinedInitialDataOptions.md) to #### queryClient? -`QueryClient` +[`QueryClient`](../classes/QueryClient.md) Use this to use a custom `QueryClient`. Otherwise, the one from the nearest context will be used. @@ -91,7 +91,7 @@ function Posts() { function useQuery(options, queryClient?): UseQueryResult; ``` -Defined in: [react-query/src/useQuery.ts:117](https://github.com/TanStack/query/blob/main/packages/react-query/src/useQuery.ts#L117) +Defined in: [packages/react-query/src/useQuery.ts:117](https://github.com/TanStack/query/blob/main/packages/react-query/src/useQuery.ts#L117) ### Type Parameters @@ -121,7 +121,7 @@ The [UndefinedInitialDataOptions](../type-aliases/UndefinedInitialDataOptions.md #### queryClient? -`QueryClient` +[`QueryClient`](../classes/QueryClient.md) Use this to use a custom `QueryClient`. Otherwise, the one from the nearest context will be used. @@ -192,7 +192,7 @@ function Posts() { function useQuery(options, queryClient?): UseQueryResult; ``` -Defined in: [react-query/src/useQuery.ts:281](https://github.com/TanStack/query/blob/main/packages/react-query/src/useQuery.ts#L281) +Defined in: [packages/react-query/src/useQuery.ts:281](https://github.com/TanStack/query/blob/main/packages/react-query/src/useQuery.ts#L281) ### Type Parameters @@ -222,7 +222,7 @@ The [UseQueryOptions](../interfaces/UseQueryOptions.md) to use — everything yo #### queryClient? -`QueryClient` +[`QueryClient`](../classes/QueryClient.md) Use this to use a custom `QueryClient`. Otherwise, the one from the nearest context will be used. diff --git a/docs/framework/react/reference/functions/useQueryClient.md b/docs/framework/react/reference/functions/useQueryClient.md index 77368631356..4b60a8ed443 100644 --- a/docs/framework/react/reference/functions/useQueryClient.md +++ b/docs/framework/react/reference/functions/useQueryClient.md @@ -9,7 +9,7 @@ redirect_from: function useQueryClient(queryClient?): QueryClient; ``` -Defined in: [react-query/src/QueryClientProvider.tsx:21](https://github.com/TanStack/query/blob/main/packages/react-query/src/QueryClientProvider.tsx#L21) +Defined in: [packages/react-query/src/QueryClientProvider.tsx:21](https://github.com/TanStack/query/blob/main/packages/react-query/src/QueryClientProvider.tsx#L21) The `useQueryClient` hook returns the current `QueryClient` instance. @@ -17,14 +17,14 @@ The `useQueryClient` hook returns the current `QueryClient` instance. ### queryClient? -`QueryClient` +[`QueryClient`](../classes/QueryClient.md) Use this to use a custom `QueryClient`. Otherwise, the one from the nearest context will be used. ## Returns -`QueryClient` +[`QueryClient`](../classes/QueryClient.md) The current `QueryClient` instance. diff --git a/docs/framework/react/reference/functions/useQueryErrorResetBoundary.md b/docs/framework/react/reference/functions/useQueryErrorResetBoundary.md index 76510277d67..09d1ae66adc 100644 --- a/docs/framework/react/reference/functions/useQueryErrorResetBoundary.md +++ b/docs/framework/react/reference/functions/useQueryErrorResetBoundary.md @@ -9,7 +9,7 @@ redirect_from: function useQueryErrorResetBoundary(): QueryErrorResetBoundaryValue; ``` -Defined in: [react-query/src/QueryErrorResetBoundary.tsx:76](https://github.com/TanStack/query/blob/main/packages/react-query/src/QueryErrorResetBoundary.tsx#L76) +Defined in: [packages/react-query/src/QueryErrorResetBoundary.tsx:76](https://github.com/TanStack/query/blob/main/packages/react-query/src/QueryErrorResetBoundary.tsx#L76) This hook will reset any query errors within the closest `QueryErrorResetBoundary`. If there is no boundary defined it will reset them globally. diff --git a/docs/framework/react/reference/functions/useSuspenseInfiniteQuery.md b/docs/framework/react/reference/functions/useSuspenseInfiniteQuery.md index 7fc7483c0e6..956ff2f6d83 100644 --- a/docs/framework/react/reference/functions/useSuspenseInfiniteQuery.md +++ b/docs/framework/react/reference/functions/useSuspenseInfiniteQuery.md @@ -9,7 +9,7 @@ redirect_from: function useSuspenseInfiniteQuery(options, queryClient?): UseSuspenseInfiniteQueryResult; ``` -Defined in: [react-query/src/useSuspenseInfiniteQuery.ts:104](https://github.com/TanStack/query/blob/main/packages/react-query/src/useSuspenseInfiniteQuery.ts#L104) +Defined in: [packages/react-query/src/useSuspenseInfiniteQuery.ts:104](https://github.com/TanStack/query/blob/main/packages/react-query/src/useSuspenseInfiniteQuery.ts#L104) The options for `useSuspenseInfiniteQuery` are the same as for `useInfiniteQuery`, except for `throwOnError`, `enabled`, and `placeholderData`. @@ -28,7 +28,7 @@ Caveat: cancellation does not work. ### TData -`TData` = `InfiniteData`\<`TQueryFnData`, `unknown`\> +`TData` = [`InfiniteData`](../interfaces/InfiniteData.md)\<`TQueryFnData`, `unknown`\> ### TQueryKey @@ -48,7 +48,7 @@ The [UseSuspenseInfiniteQueryOptions](../interfaces/UseSuspenseInfiniteQueryOpti ### queryClient? -`QueryClient` +[`QueryClient`](../classes/QueryClient.md) Use this to use a custom `QueryClient`. Otherwise, the one from the nearest context will be used. diff --git a/docs/framework/react/reference/functions/useSuspenseQueries.md b/docs/framework/react/reference/functions/useSuspenseQueries.md index 6f58ae559e2..5b185da050b 100644 --- a/docs/framework/react/reference/functions/useSuspenseQueries.md +++ b/docs/framework/react/reference/functions/useSuspenseQueries.md @@ -11,7 +11,7 @@ redirect_from: function useSuspenseQueries(options, queryClient?): TCombinedResult; ``` -Defined in: [react-query/src/useSuspenseQueries.ts:349](https://github.com/TanStack/query/blob/main/packages/react-query/src/useSuspenseQueries.ts#L349) +Defined in: [packages/react-query/src/useSuspenseQueries.ts:349](https://github.com/TanStack/query/blob/main/packages/react-query/src/useSuspenseQueries.ts#L349) The options for `useSuspenseQueries` are the same as for `useQueries`, except that the top-level `subscribed` option isn't supported, and each `query` can't have `throwOnError`, `enabled`, or `placeholderData`. @@ -48,7 +48,7 @@ An array with query option objects identical to `useSuspenseQuery`. #### queryClient? -`QueryClient` +[`QueryClient`](../classes/QueryClient.md) Use this to provide a custom `QueryClient`. Otherwise, the one from the nearest context will be used. @@ -221,7 +221,7 @@ function App() { function useSuspenseQueries(options, queryClient?): TCombinedResult; ``` -Defined in: [react-query/src/useSuspenseQueries.ts:489](https://github.com/TanStack/query/blob/main/packages/react-query/src/useSuspenseQueries.ts#L489) +Defined in: [packages/react-query/src/useSuspenseQueries.ts:489](https://github.com/TanStack/query/blob/main/packages/react-query/src/useSuspenseQueries.ts#L489) The options for `useSuspenseQueries` are the same as for `useQueries`, except that the top-level `subscribed` option isn't supported, and each `query` can't have `throwOnError`, `enabled`, or `placeholderData`. @@ -257,7 +257,7 @@ An array with query option objects identical to `useSuspenseQuery`. #### queryClient? -`QueryClient` +[`QueryClient`](../classes/QueryClient.md) Use this to provide a custom `QueryClient`. Otherwise, the one from the nearest context will be used. diff --git a/docs/framework/react/reference/functions/useSuspenseQuery.md b/docs/framework/react/reference/functions/useSuspenseQuery.md index 1e4c9debb8e..afa0ba0d6bc 100644 --- a/docs/framework/react/reference/functions/useSuspenseQuery.md +++ b/docs/framework/react/reference/functions/useSuspenseQuery.md @@ -9,7 +9,7 @@ redirect_from: function useSuspenseQuery(options, queryClient?): UseSuspenseQueryResult; ``` -Defined in: [react-query/src/useSuspenseQuery.ts:75](https://github.com/TanStack/query/blob/main/packages/react-query/src/useSuspenseQuery.ts#L75) +Defined in: [packages/react-query/src/useSuspenseQuery.ts:75](https://github.com/TanStack/query/blob/main/packages/react-query/src/useSuspenseQuery.ts#L75) The options for `useSuspenseQuery` are the same as for `useQuery`, except for `throwOnError`, `enabled`, and `placeholderData` — and `queryFn` may not be `skipToken`, since Suspense hooks can't render a "disabled" state. @@ -44,7 +44,7 @@ The [UseSuspenseQueryOptions](../interfaces/UseSuspenseQueryOptions.md) to use ### queryClient? -`QueryClient` +[`QueryClient`](../classes/QueryClient.md) Use this to use a custom `QueryClient`. Otherwise, the one from the nearest context will be used. diff --git a/docs/framework/react/reference/index.md b/docs/framework/react/reference/index.md index 29afd251300..a4d49eff695 100644 --- a/docs/framework/react/reference/index.md +++ b/docs/framework/react/reference/index.md @@ -3,10 +3,81 @@ id: "@tanstack/react-query" title: "@tanstack/react-query" --- +## Classes + +- [CancelledError](classes/CancelledError.md) +- [InfiniteQueryObserver](classes/InfiniteQueryObserver.md) +- [Mutation](classes/Mutation.md) +- [MutationCache](classes/MutationCache.md) +- [MutationObserver](classes/MutationObserver.md) +- [QueriesObserver](classes/QueriesObserver.md) +- [Query](classes/Query.md) +- [QueryCache](classes/QueryCache.md) +- [QueryClient](classes/QueryClient.md) +- [QueryObserver](classes/QueryObserver.md) + ## Interfaces +- [CancelOptions](interfaces/CancelOptions.md) +- [DefaultOptions](interfaces/DefaultOptions.md) +- [DehydratedState](interfaces/DehydratedState.md) +- [DehydrateOptions](interfaces/DehydrateOptions.md) +- [~~EnsureQueryDataOptions~~](interfaces/EnsureQueryDataOptions.md) +- [FetchNextPageOptions](interfaces/FetchNextPageOptions.md) +- [FetchPreviousPageOptions](interfaces/FetchPreviousPageOptions.md) +- [~~FetchQueryOptions~~](interfaces/FetchQueryOptions.md) +- [FocusManager](interfaces/FocusManager.md) +- [HydrateOptions](interfaces/HydrateOptions.md) - [HydrationBoundaryProps](interfaces/HydrationBoundaryProps.md) +- [InfiniteData](interfaces/InfiniteData.md) +- [InfiniteQueryObserverBaseResult](interfaces/InfiniteQueryObserverBaseResult.md) +- [InfiniteQueryObserverLoadingErrorResult](interfaces/InfiniteQueryObserverLoadingErrorResult.md) +- [InfiniteQueryObserverLoadingResult](interfaces/InfiniteQueryObserverLoadingResult.md) +- [InfiniteQueryObserverOptions](interfaces/InfiniteQueryObserverOptions.md) +- [InfiniteQueryObserverPendingResult](interfaces/InfiniteQueryObserverPendingResult.md) +- [InfiniteQueryObserverPlaceholderResult](interfaces/InfiniteQueryObserverPlaceholderResult.md) +- [InfiniteQueryObserverRefetchErrorResult](interfaces/InfiniteQueryObserverRefetchErrorResult.md) +- [InfiniteQueryObserverSuccessResult](interfaces/InfiniteQueryObserverSuccessResult.md) +- [InfiniteQueryPageParamsOptions](interfaces/InfiniteQueryPageParamsOptions.md) +- [InitialPageParam](interfaces/InitialPageParam.md) +- [InvalidateOptions](interfaces/InvalidateOptions.md) +- [InvalidateQueryFilters](interfaces/InvalidateQueryFilters.md) +- [MutateOptions](interfaces/MutateOptions.md) +- [MutationCacheConfig](interfaces/MutationCacheConfig.md) +- [MutationFilters](interfaces/MutationFilters.md) +- [MutationObserverBaseResult](interfaces/MutationObserverBaseResult.md) +- [MutationObserverErrorResult](interfaces/MutationObserverErrorResult.md) +- [MutationObserverIdleResult](interfaces/MutationObserverIdleResult.md) +- [MutationObserverLoadingResult](interfaces/MutationObserverLoadingResult.md) +- [MutationObserverOptions](interfaces/MutationObserverOptions.md) +- [MutationObserverSuccessResult](interfaces/MutationObserverSuccessResult.md) +- [MutationOptions](interfaces/MutationOptions.md) +- [MutationState](interfaces/MutationState.md) +- [NotifyEvent](interfaces/NotifyEvent.md) +- [OnlineManager](interfaces/OnlineManager.md) +- [QueriesObserverOptions](interfaces/QueriesObserverOptions.md) +- [QueryCacheConfig](interfaces/QueryCacheConfig.md) +- [QueryClientConfig](interfaces/QueryClientConfig.md) - [QueryErrorResetBoundaryProps](interfaces/QueryErrorResetBoundaryProps.md) +- [QueryExecuteOptions](interfaces/QueryExecuteOptions.md) +- [QueryFilters](interfaces/QueryFilters.md) +- [QueryObserverBaseResult](interfaces/QueryObserverBaseResult.md) +- [QueryObserverLoadingErrorResult](interfaces/QueryObserverLoadingErrorResult.md) +- [QueryObserverLoadingResult](interfaces/QueryObserverLoadingResult.md) +- [QueryObserverOptions](interfaces/QueryObserverOptions.md) +- [QueryObserverPendingResult](interfaces/QueryObserverPendingResult.md) +- [QueryObserverPlaceholderResult](interfaces/QueryObserverPlaceholderResult.md) +- [QueryObserverRefetchErrorResult](interfaces/QueryObserverRefetchErrorResult.md) +- [QueryObserverSuccessResult](interfaces/QueryObserverSuccessResult.md) +- [QueryOptions](interfaces/QueryOptions.md) +- [QueryState](interfaces/QueryState.md) +- [RefetchOptions](interfaces/RefetchOptions.md) +- [RefetchQueryFilters](interfaces/RefetchQueryFilters.md) +- [Register](interfaces/Register.md) +- [ResetOptions](interfaces/ResetOptions.md) +- [ResultOptions](interfaces/ResultOptions.md) +- [SetDataOptions](interfaces/SetDataOptions.md) +- [TimeoutManager](interfaces/TimeoutManager.md) - [UseBaseQueryOptions](interfaces/UseBaseQueryOptions.md) - [UseInfiniteQueryOptions](interfaces/UseInfiniteQueryOptions.md) - [UseMutationOptions](interfaces/UseMutationOptions.md) @@ -16,29 +87,87 @@ title: "@tanstack/react-query" ## Type Aliases +- [AnyDataTag](type-aliases/AnyDataTag.md) - [AnyUseBaseQueryOptions](type-aliases/AnyUseBaseQueryOptions.md) - [AnyUseInfiniteQueryOptions](type-aliases/AnyUseInfiniteQueryOptions.md) - [AnyUseMutationOptions](type-aliases/AnyUseMutationOptions.md) - [AnyUseQueryOptions](type-aliases/AnyUseQueryOptions.md) - [AnyUseSuspenseInfiniteQueryOptions](type-aliases/AnyUseSuspenseInfiniteQueryOptions.md) - [AnyUseSuspenseQueryOptions](type-aliases/AnyUseSuspenseQueryOptions.md) +- [DataTag](type-aliases/DataTag.md) +- [dataTagErrorSymbol](type-aliases/dataTagErrorSymbol.md) +- [dataTagSymbol](type-aliases/dataTagSymbol.md) +- [DefaultedInfiniteQueryObserverOptions](type-aliases/DefaultedInfiniteQueryObserverOptions.md) +- [DefaultedQueryObserverOptions](type-aliases/DefaultedQueryObserverOptions.md) +- [DefaultError](type-aliases/DefaultError.md) +- [DefinedInfiniteQueryObserverResult](type-aliases/DefinedInfiniteQueryObserverResult.md) - [DefinedInitialDataInfiniteOptions](type-aliases/DefinedInitialDataInfiniteOptions.md) - [DefinedInitialDataOptions](type-aliases/DefinedInitialDataOptions.md) +- [DefinedQueryObserverResult](type-aliases/DefinedQueryObserverResult.md) - [DefinedUseInfiniteQueryResult](type-aliases/DefinedUseInfiniteQueryResult.md) - [DefinedUseQueryResult](type-aliases/DefinedUseQueryResult.md) +- [DistributiveOmit](type-aliases/DistributiveOmit.md) +- [~~EnsureInfiniteQueryDataOptions~~](type-aliases/EnsureInfiniteQueryDataOptions.md) +- [~~FetchInfiniteQueryOptions~~](type-aliases/FetchInfiniteQueryOptions.md) +- [FetchStatus](type-aliases/FetchStatus.md) +- [GetNextPageParamFunction](type-aliases/GetNextPageParamFunction.md) +- [GetPreviousPageParamFunction](type-aliases/GetPreviousPageParamFunction.md) +- [InferDataFromTag](type-aliases/InferDataFromTag.md) +- [InferErrorFromTag](type-aliases/InferErrorFromTag.md) +- [InfiniteQueryExecuteOptions](type-aliases/InfiniteQueryExecuteOptions.md) +- [InfiniteQueryObserverResult](type-aliases/InfiniteQueryObserverResult.md) +- [InitialDataFunction](type-aliases/InitialDataFunction.md) +- [ManagedTimerId](type-aliases/ManagedTimerId.md) +- [MutateFunction](type-aliases/MutateFunction.md) +- [MutateFunctionRest](type-aliases/MutateFunctionRest.md) +- [MutationCacheNotifyEvent](type-aliases/MutationCacheNotifyEvent.md) +- [MutationFunction](type-aliases/MutationFunction.md) +- [MutationFunctionContext](type-aliases/MutationFunctionContext.md) +- [MutationKey](type-aliases/MutationKey.md) +- [MutationMeta](type-aliases/MutationMeta.md) +- [MutationObserverResult](type-aliases/MutationObserverResult.md) +- [MutationScope](type-aliases/MutationScope.md) +- [MutationStatus](type-aliases/MutationStatus.md) +- [NetworkMode](type-aliases/NetworkMode.md) +- [NonUndefinedGuard](type-aliases/NonUndefinedGuard.md) +- [NotifyEventType](type-aliases/NotifyEventType.md) +- [NotifyOnChangeProps](type-aliases/NotifyOnChangeProps.md) +- [OmitKeyof](type-aliases/OmitKeyof.md) +- [Override](type-aliases/Override.md) +- [PlaceholderDataFunction](type-aliases/PlaceholderDataFunction.md) - [QueriesOptions](type-aliases/QueriesOptions.md) +- [QueriesPlaceholderDataFunction](type-aliases/QueriesPlaceholderDataFunction.md) - [QueriesResults](type-aliases/QueriesResults.md) +- [QueryBooleanOption](type-aliases/QueryBooleanOption.md) +- [QueryCacheNotifyEvent](type-aliases/QueryCacheNotifyEvent.md) - [QueryClientProviderProps](type-aliases/QueryClientProviderProps.md) - [QueryErrorClearResetFunction](type-aliases/QueryErrorClearResetFunction.md) - [QueryErrorIsResetFunction](type-aliases/QueryErrorIsResetFunction.md) - [QueryErrorResetBoundaryFunction](type-aliases/QueryErrorResetBoundaryFunction.md) - [QueryErrorResetFunction](type-aliases/QueryErrorResetFunction.md) +- [QueryFunction](type-aliases/QueryFunction.md) +- [QueryFunctionContext](type-aliases/QueryFunctionContext.md) +- [QueryKey](type-aliases/QueryKey.md) +- [QueryKeyHashFunction](type-aliases/QueryKeyHashFunction.md) +- [QueryKeyWithDataTag](type-aliases/QueryKeyWithDataTag.md) +- [QueryMeta](type-aliases/QueryMeta.md) +- [QueryObserverResult](type-aliases/QueryObserverResult.md) +- [QueryPersister](type-aliases/QueryPersister.md) +- [QueryStatus](type-aliases/QueryStatus.md) +- [SkipToken](type-aliases/SkipToken.md) +- [StaleTime](type-aliases/StaleTime.md) +- [StaleTimeFunction](type-aliases/StaleTimeFunction.md) - [SuspenseQueriesOptions](type-aliases/SuspenseQueriesOptions.md) - [SuspenseQueriesResults](type-aliases/SuspenseQueriesResults.md) +- [ThrowOnError](type-aliases/ThrowOnError.md) +- [TimeoutCallback](type-aliases/TimeoutCallback.md) +- [TimeoutProvider](type-aliases/TimeoutProvider.md) - [UndefinedInitialDataInfiniteOptions](type-aliases/UndefinedInitialDataInfiniteOptions.md) - [UndefinedInitialDataOptions](type-aliases/UndefinedInitialDataOptions.md) +- [UnsetMarker](type-aliases/UnsetMarker.md) - [UnusedSkipTokenInfiniteOptions](type-aliases/UnusedSkipTokenInfiniteOptions.md) - [UnusedSkipTokenOptions](type-aliases/UnusedSkipTokenOptions.md) +- [Updater](type-aliases/Updater.md) - [UseBaseMutationResult](type-aliases/UseBaseMutationResult.md) - [UseBaseQueryResult](type-aliases/UseBaseQueryResult.md) - [UseInfiniteQueryResult](type-aliases/UseInfiniteQueryResult.md) @@ -50,20 +179,47 @@ title: "@tanstack/react-query" - [UseQueryResult](type-aliases/UseQueryResult.md) - [UseSuspenseInfiniteQueryResult](type-aliases/UseSuspenseInfiniteQueryResult.md) - [UseSuspenseQueryResult](type-aliases/UseSuspenseQueryResult.md) +- [WithRequired](type-aliases/WithRequired.md) ## Variables +- [dataTagErrorSymbol](variables/dataTagErrorSymbol.md) +- [dataTagSymbol](variables/dataTagSymbol.md) +- [defaultScheduler](variables/defaultScheduler.md) +- [environmentManager](variables/environmentManager.md) +- [focusManager](variables/focusManager.md) - [IsRestoringProvider](variables/IsRestoringProvider.md) +- [~~isServer~~](variables/isServer.md) +- [notifyManager](variables/notifyManager.md) +- [onlineManager](variables/onlineManager.md) - [QueryClientContext](variables/QueryClientContext.md) +- [skipToken](variables/skipToken.md) +- [timeoutManager](variables/timeoutManager.md) +- [unsetMarker](variables/unsetMarker.md) ## Functions +- [defaultShouldDehydrateMutation](functions/defaultShouldDehydrateMutation.md) +- [defaultShouldDehydrateQuery](functions/defaultShouldDehydrateQuery.md) +- [dehydrate](functions/dehydrate.md) +- [dehydrateQuery](functions/dehydrateQuery.md) +- [experimental\_streamedQuery](functions/experimental_streamedQuery.md) +- [hashKey](functions/hashKey.md) +- [hydrate](functions/hydrate.md) - [HydrationBoundary](functions/HydrationBoundary.md) - [infiniteQueryOptions](functions/infiniteQueryOptions.md) +- [~~isCancelledError~~](functions/isCancelledError.md) +- [keepPreviousData](functions/keepPreviousData.md) +- [matchMutation](functions/matchMutation.md) +- [matchQuery](functions/matchQuery.md) - [mutationOptions](functions/mutationOptions.md) +- [noop](functions/noop.md) +- [partialMatchKey](functions/partialMatchKey.md) - [QueryClientProvider](functions/QueryClientProvider.md) - [QueryErrorResetBoundary](functions/QueryErrorResetBoundary.md) - [queryOptions](functions/queryOptions.md) +- [replaceEqualDeep](functions/replaceEqualDeep.md) +- [shouldThrowError](functions/shouldThrowError.md) - [useInfiniteQuery](functions/useInfiniteQuery.md) - [useIsFetching](functions/useIsFetching.md) - [useIsMutating](functions/useIsMutating.md) diff --git a/docs/framework/react/reference/interfaces/CancelOptions.md b/docs/framework/react/reference/interfaces/CancelOptions.md new file mode 100644 index 00000000000..b7464c48e50 --- /dev/null +++ b/docs/framework/react/reference/interfaces/CancelOptions.md @@ -0,0 +1,26 @@ +--- +id: CancelOptions +title: CancelOptions +--- + +Defined in: [packages/query-core/src/types.ts:1521](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1521) + +## Properties + +### revert? + +```ts +optional revert: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1522](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1522) + +*** + +### silent? + +```ts +optional silent: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1523](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1523) diff --git a/docs/framework/react/reference/interfaces/DefaultOptions.md b/docs/framework/react/reference/interfaces/DefaultOptions.md new file mode 100644 index 00000000000..e45a56f075f --- /dev/null +++ b/docs/framework/react/reference/interfaces/DefaultOptions.md @@ -0,0 +1,84 @@ +--- +id: DefaultOptions +title: DefaultOptions +--- + +Defined in: [packages/query-core/src/types.ts:1507](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1507) + +## Type Parameters + +### TError + +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) + +## Properties + +### dehydrate? + +```ts +optional dehydrate: DehydrateOptions; +``` + +Defined in: [packages/query-core/src/types.ts:1518](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1518) + +Default options used when dehydrating the client's caches; see [DehydrateOptions](DehydrateOptions.md). + +*** + +### hydrate? + +```ts +optional hydrate: object; +``` + +Defined in: [packages/query-core/src/types.ts:1516](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1516) + +Default options used when hydrating queries; see [HydrateOptions](HydrateOptions.md). + +#### deserializeData? + +```ts +optional deserializeData: TransformerFn; +``` + +Transforms a query's `data` after it is read from the dehydrated state, reversing `serializeData`. + +#### mutations? + +```ts +optional mutations: MutationOptions; +``` + +Default options merged into every mutation restored from the dehydrated state. + +#### queries? + +```ts +optional queries: QueryOptions; +``` + +Default options merged into every query restored from the dehydrated state. + +*** + +### mutations? + +```ts +optional mutations: MutationObserverOptions; +``` + +Defined in: [packages/query-core/src/types.ts:1514](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1514) + +Default options applied to every mutation, unless overridden per-mutation. + +*** + +### queries? + +```ts +optional queries: OmitKeyof, "queryKey" | "suspense", "strictly">; +``` + +Defined in: [packages/query-core/src/types.ts:1509](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1509) + +Default options applied to every query, unless overridden per-query. diff --git a/docs/framework/react/reference/interfaces/DehydrateOptions.md b/docs/framework/react/reference/interfaces/DehydrateOptions.md new file mode 100644 index 00000000000..e862ae88b43 --- /dev/null +++ b/docs/framework/react/reference/interfaces/DehydrateOptions.md @@ -0,0 +1,89 @@ +--- +id: DehydrateOptions +title: DehydrateOptions +--- + +Defined in: [packages/query-core/src/hydration.ts:42](https://github.com/TanStack/query/blob/main/packages/query-core/src/hydration.ts#L42) + +Options for `dehydrate`, controlling which queries/mutations are included in the resulting `DehydratedState` and +how their data/errors are transformed before being serialized (e.g. for embedding in server-rendered markup). + +## Properties + +### serializeData? + +```ts +optional serializeData: TransformerFn; +``` + +Defined in: [packages/query-core/src/hydration.ts:44](https://github.com/TanStack/query/blob/main/packages/query-core/src/hydration.ts#L44) + +Transforms a query's `data` before it is dehydrated. Useful for non-JSON-serializable data. + +*** + +### shouldDehydrateMutation()? + +```ts +optional shouldDehydrateMutation: (mutation) => boolean; +``` + +Defined in: [packages/query-core/src/hydration.ts:46](https://github.com/TanStack/query/blob/main/packages/query-core/src/hydration.ts#L46) + +Predicate to decide whether a given `Mutation` should be dehydrated. Defaults to `defaultShouldDehydrateMutation`. + +#### Parameters + +##### mutation + +[`Mutation`](../classes/Mutation.md) + +#### Returns + +`boolean` + +*** + +### shouldDehydrateQuery()? + +```ts +optional shouldDehydrateQuery: (query) => boolean; +``` + +Defined in: [packages/query-core/src/hydration.ts:48](https://github.com/TanStack/query/blob/main/packages/query-core/src/hydration.ts#L48) + +Predicate to decide whether a given `Query` should be dehydrated. Defaults to `defaultShouldDehydrateQuery`. + +#### Parameters + +##### query + +[`Query`](../classes/Query.md) + +#### Returns + +`boolean` + +*** + +### shouldRedactErrors()? + +```ts +optional shouldRedactErrors: (error) => boolean; +``` + +Defined in: [packages/query-core/src/hydration.ts:54](https://github.com/TanStack/query/blob/main/packages/query-core/src/hydration.ts#L54) + +Predicate to decide whether a query's error should be redacted before dehydration. Errors are redacted +(replaced with a generic `Error('redacted')`) unless this function is provided and returns `false` for the +given error, in which case the original error is kept. + +#### Parameters + +##### error + +`unknown` + +#### Returns + +`boolean` diff --git a/docs/framework/react/reference/interfaces/DehydratedState.md b/docs/framework/react/reference/interfaces/DehydratedState.md new file mode 100644 index 00000000000..be034c9e8fd --- /dev/null +++ b/docs/framework/react/reference/interfaces/DehydratedState.md @@ -0,0 +1,30 @@ +--- +id: DehydratedState +title: DehydratedState +--- + +Defined in: [packages/query-core/src/hydration.ts:94](https://github.com/TanStack/query/blob/main/packages/query-core/src/hydration.ts#L94) + +A serializable snapshot of a `QueryClient`'s cache, as produced by `dehydrate` and consumed by `hydrate`. Typically +transported from server to client (e.g. embedded in server-rendered markup) to seed the client's cache with data +that has already been fetched, avoiding a redundant fetch on the client. + +## Properties + +### mutations + +```ts +mutations: DehydratedMutation[]; +``` + +Defined in: [packages/query-core/src/hydration.ts:95](https://github.com/TanStack/query/blob/main/packages/query-core/src/hydration.ts#L95) + +*** + +### queries + +```ts +queries: DehydratedQuery[]; +``` + +Defined in: [packages/query-core/src/hydration.ts:96](https://github.com/TanStack/query/blob/main/packages/query-core/src/hydration.ts#L96) diff --git a/docs/framework/react/reference/interfaces/EnsureQueryDataOptions.md b/docs/framework/react/reference/interfaces/EnsureQueryDataOptions.md new file mode 100644 index 00000000000..a67082af57e --- /dev/null +++ b/docs/framework/react/reference/interfaces/EnsureQueryDataOptions.md @@ -0,0 +1,350 @@ +--- +id: EnsureQueryDataOptions +title: EnsureQueryDataOptions +--- + +Defined in: [packages/query-core/src/types.ts:614](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L614) + +## Deprecated + +## Extends + +- [`FetchQueryOptions`](FetchQueryOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`, `TPageParam`\> + +## Type Parameters + +### TQueryFnData + +`TQueryFnData` = `unknown` + +### TError + +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) + +### TData + +`TData` = `TQueryFnData` + +### TQueryKey + +`TQueryKey` *extends* [`QueryKey`](../type-aliases/QueryKey.md) = [`QueryKey`](../type-aliases/QueryKey.md) + +### TPageParam + +`TPageParam` = `never` + +## Properties + +### ~~gcTime?~~ + +```ts +optional gcTime: number; +``` + +Defined in: [packages/query-core/src/types.ts:277](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L277) + +The time in milliseconds that unused/inactive cache data remains in memory. +When a query's cache becomes unused or inactive, that cache data will be garbage collected after this duration. +When different garbage collection times are specified, the longest one will be used. +Setting it to `Infinity` will disable garbage collection. + +Defaults to `5 * 60 * 1000` (5 minutes), or `Infinity` during SSR. + +Note: the maximum allowed time is about 24 days, imposed by `setTimeout`'s 32-bit signed integer delay — see +`timeoutManager.setTimeoutProvider` for a workaround. + +#### Inherited from + +[`FetchQueryOptions`](FetchQueryOptions.md).[`gcTime`](FetchQueryOptions.md#gctime) + +*** + +### ~~initialData?~~ + +```ts +optional initialData: + | TData +| InitialDataFunction; +``` + +Defined in: [packages/query-core/src/types.ts:317](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L317) + +If set, this value will be used as the initial data for the query cache (as long as the query hasn't been +created or cached yet). +If set to a function, the function will be called **once** during the shared/root query initialization, and be +expected to synchronously return the initial data. +Initial data is considered stale by default unless a `staleTime` has been set. +`initialData` **is persisted** to the cache. + +#### Inherited from + +[`FetchQueryOptions`](FetchQueryOptions.md).[`initialData`](FetchQueryOptions.md#initialdata) + +*** + +### ~~initialDataUpdatedAt?~~ + +```ts +optional initialDataUpdatedAt: number | () => number | undefined; +``` + +Defined in: [packages/query-core/src/types.ts:321](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L321) + +If set, this value will be used as the time (in milliseconds) of when the `initialData` itself was last updated. + +#### Inherited from + +[`FetchQueryOptions`](FetchQueryOptions.md).[`initialDataUpdatedAt`](FetchQueryOptions.md#initialdataupdatedat) + +*** + +### ~~initialPageParam?~~ + +```ts +optional initialPageParam: undefined; +``` + +Defined in: [packages/query-core/src/types.ts:605](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L605) + +#### Inherited from + +[`FetchQueryOptions`](FetchQueryOptions.md).[`initialPageParam`](FetchQueryOptions.md#initialpageparam) + +*** + +### ~~maxPages?~~ + +```ts +optional maxPages: number; +``` + +Defined in: [packages/query-core/src/types.ts:345](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L345) + +Maximum number of pages to store in the data of an infinite query. + +#### Inherited from + +[`FetchQueryOptions`](FetchQueryOptions.md).[`maxPages`](FetchQueryOptions.md#maxpages) + +*** + +### ~~meta?~~ + +```ts +optional meta: Record; +``` + +Defined in: [packages/query-core/src/types.ts:341](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L341) + +Additional payload to be stored on each query. +Use this property to pass information that can be used in other places. + +#### Inherited from + +[`FetchQueryOptions`](FetchQueryOptions.md).[`meta`](FetchQueryOptions.md#meta) + +*** + +### ~~networkMode?~~ + +```ts +optional networkMode: NetworkMode; +``` + +Defined in: [packages/query-core/src/types.ts:265](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L265) + +Controls whether a query is allowed to run based on the current network connectivity. + +Defaults to `'online'`. + +#### See + +[Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. + +#### Inherited from + +[`FetchQueryOptions`](FetchQueryOptions.md).[`networkMode`](FetchQueryOptions.md#networkmode) + +*** + +### ~~persister?~~ + +```ts +optional persister: QueryPersister, TPageParam>; +``` + +Defined in: [packages/query-core/src/types.ts:290](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L290) + +This option can be used to persist the result of a query to an external storage, bypassing the need to actually +call the `queryFn`. Useful for persisting a query's data across e.g. server/client boundaries. + +#### Inherited from + +[`FetchQueryOptions`](FetchQueryOptions.md).[`persister`](FetchQueryOptions.md#persister) + +*** + +### ~~queryFn?~~ + +```ts +optional queryFn: + | typeof skipToken +| QueryFunction; +``` + +Defined in: [packages/query-core/src/types.ts:285](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L285) + +The function that the query will use to request data. +Required, unless a default query function has been set via `queryClient.setQueryDefaults` or +`queryClient.setDefaultOptions`. +Receives a [QueryFunctionContext](../type-aliases/QueryFunctionContext.md). +Must return a promise that will either resolve data or throw an error. The data cannot be `undefined`. + +#### Inherited from + +[`FetchQueryOptions`](FetchQueryOptions.md).[`queryFn`](FetchQueryOptions.md#queryfn) + +*** + +### ~~queryHash?~~ + +```ts +optional queryHash: string; +``` + +Defined in: [packages/query-core/src/types.ts:295](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L295) + +The hashed form of `queryKey`, computed with `queryKeyHashFn` (or the default hashing function otherwise). Used +as the actual cache key internally. + +#### Inherited from + +[`FetchQueryOptions`](FetchQueryOptions.md).[`queryHash`](FetchQueryOptions.md#queryhash) + +*** + +### ~~queryKey~~ + +```ts +queryKey: TQueryKey & object; +``` + +Defined in: [packages/query-core/src/types.ts:304](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L304) + +The query key to use for this query. + +The query key will be hashed into a stable hash. See [Query Keys](https://tanstack.com/query/latest/docs/framework/react/guides/query-keys) +for more information. + +The query will automatically update when this key changes (as long as `enabled` is not set to `false`). + +#### Inherited from + +[`FetchQueryOptions`](FetchQueryOptions.md).[`queryKey`](FetchQueryOptions.md#querykey) + +*** + +### ~~queryKeyHashFn?~~ + +```ts +optional queryKeyHashFn: QueryKeyHashFunction; +``` + +Defined in: [packages/query-core/src/types.ts:308](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L308) + +If specified, this function is used to hash the `queryKey` to a string. + +#### Inherited from + +[`FetchQueryOptions`](FetchQueryOptions.md).[`queryKeyHashFn`](FetchQueryOptions.md#querykeyhashfn) + +*** + +### ~~retry?~~ + +```ts +optional retry: RetryValue; +``` + +Defined in: [packages/query-core/src/types.ts:246](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L246) + +If `false`, failed queries will not retry by default. +If `true`, failed queries will retry infinitely. +If set to an integer number, e.g. 3, failed queries will retry until the failed query count meets that number. +If set to a function `(failureCount, error) => boolean` failed queries will retry until the function returns false. + +Defaults to `3` on the client and `0` on the server. + +#### Inherited from + +[`FetchQueryOptions`](FetchQueryOptions.md).[`retry`](FetchQueryOptions.md#retry) + +*** + +### ~~retryDelay?~~ + +```ts +optional retryDelay: RetryDelayValue; +``` + +Defined in: [packages/query-core/src/types.ts:258](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L258) + +This function receives a `retryAttempt` integer and the actual Error and returns the delay to apply before the +next attempt in milliseconds. + +A function like `attempt => Math.min(attempt > 1 ? 2 ** attempt * 1000 : 1000, 30 * 1000)` applies exponential +backoff. + +A function like `attempt => attempt * 1000` applies linear backoff. + +Defaults to a function that applies exponential backoff, capped at 30 seconds. + +#### Inherited from + +[`FetchQueryOptions`](FetchQueryOptions.md).[`retryDelay`](FetchQueryOptions.md#retrydelay) + +*** + +### ~~revalidateIfStale?~~ + +```ts +optional revalidateIfStale: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:627](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L627) + +*** + +### ~~staleTime?~~ + +```ts +optional staleTime: StaleTimeFunction; +``` + +Defined in: [packages/query-core/src/types.ts:610](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L610) + +The time in milliseconds after data is considered stale. +If the data is fresh it will be returned from the cache. + +#### Inherited from + +[`FetchQueryOptions`](FetchQueryOptions.md).[`staleTime`](FetchQueryOptions.md#staletime) + +*** + +### ~~structuralSharing?~~ + +```ts +optional structuralSharing: boolean | (oldData, newData) => unknown; +``` + +Defined in: [packages/query-core/src/types.ts:330](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L330) + +Set this to `false` to disable structural sharing between query results. +Set this to a function which accepts the old and new data and returns resolved data of the same type to implement custom structural sharing logic. + +Defaults to `true`. + +#### Inherited from + +[`FetchQueryOptions`](FetchQueryOptions.md).[`structuralSharing`](FetchQueryOptions.md#structuralsharing) diff --git a/docs/framework/react/reference/interfaces/FetchNextPageOptions.md b/docs/framework/react/reference/interfaces/FetchNextPageOptions.md new file mode 100644 index 00000000000..b79cdbe19b3 --- /dev/null +++ b/docs/framework/react/reference/interfaces/FetchNextPageOptions.md @@ -0,0 +1,46 @@ +--- +id: FetchNextPageOptions +title: FetchNextPageOptions +--- + +Defined in: [packages/query-core/src/types.ts:737](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L737) + +## Extends + +- [`ResultOptions`](ResultOptions.md) + +## Properties + +### cancelRefetch? + +```ts +optional cancelRefetch: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:746](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L746) + +If set to `true`, calling `fetchNextPage` repeatedly will invoke `queryFn` every time, +whether the previous invocation has resolved or not. Also, the result from previous invocations will be ignored. + +If set to `false`, calling `fetchNextPage` repeatedly won't have any effect until the first invocation has resolved. + +Defaults to `true`. + +*** + +### throwOnError? + +```ts +optional throwOnError: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:701](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L701) + +If set to `true`, the method throws if any of the underlying query refetch tasks fail. + +Defaults to `false`, in which case failed refetches are swallowed and not surfaced to the +caller. + +#### Inherited from + +[`ResultOptions`](ResultOptions.md).[`throwOnError`](ResultOptions.md#throwonerror) diff --git a/docs/framework/react/reference/interfaces/FetchPreviousPageOptions.md b/docs/framework/react/reference/interfaces/FetchPreviousPageOptions.md new file mode 100644 index 00000000000..fd5a08767b6 --- /dev/null +++ b/docs/framework/react/reference/interfaces/FetchPreviousPageOptions.md @@ -0,0 +1,46 @@ +--- +id: FetchPreviousPageOptions +title: FetchPreviousPageOptions +--- + +Defined in: [packages/query-core/src/types.ts:749](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L749) + +## Extends + +- [`ResultOptions`](ResultOptions.md) + +## Properties + +### cancelRefetch? + +```ts +optional cancelRefetch: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:758](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L758) + +If set to `true`, calling `fetchPreviousPage` repeatedly will invoke `queryFn` every time, +whether the previous invocation has resolved or not. Also, the result from previous invocations will be ignored. + +If set to `false`, calling `fetchPreviousPage` repeatedly won't have any effect until the first invocation has resolved. + +Defaults to `true`. + +*** + +### throwOnError? + +```ts +optional throwOnError: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:701](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L701) + +If set to `true`, the method throws if any of the underlying query refetch tasks fail. + +Defaults to `false`, in which case failed refetches are swallowed and not surfaced to the +caller. + +#### Inherited from + +[`ResultOptions`](ResultOptions.md).[`throwOnError`](ResultOptions.md#throwonerror) diff --git a/docs/framework/react/reference/interfaces/FetchQueryOptions.md b/docs/framework/react/reference/interfaces/FetchQueryOptions.md new file mode 100644 index 00000000000..b00973badc0 --- /dev/null +++ b/docs/framework/react/reference/interfaces/FetchQueryOptions.md @@ -0,0 +1,364 @@ +--- +id: FetchQueryOptions +title: FetchQueryOptions +--- + +Defined in: [packages/query-core/src/types.ts:595](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L595) + +## Deprecated + +## Extends + +- [`WithRequired`](../type-aliases/WithRequired.md)\<[`QueryOptions`](QueryOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`, `TPageParam`\>, `"queryKey"`\> + +## Extended by + +- [`EnsureQueryDataOptions`](EnsureQueryDataOptions.md) + +## Type Parameters + +### TQueryFnData + +`TQueryFnData` = `unknown` + +### TError + +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) + +### TData + +`TData` = `TQueryFnData` + +### TQueryKey + +`TQueryKey` *extends* [`QueryKey`](../type-aliases/QueryKey.md) = [`QueryKey`](../type-aliases/QueryKey.md) + +### TPageParam + +`TPageParam` = `never` + +## Properties + +### ~~gcTime?~~ + +```ts +optional gcTime: number; +``` + +Defined in: [packages/query-core/src/types.ts:277](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L277) + +The time in milliseconds that unused/inactive cache data remains in memory. +When a query's cache becomes unused or inactive, that cache data will be garbage collected after this duration. +When different garbage collection times are specified, the longest one will be used. +Setting it to `Infinity` will disable garbage collection. + +Defaults to `5 * 60 * 1000` (5 minutes), or `Infinity` during SSR. + +Note: the maximum allowed time is about 24 days, imposed by `setTimeout`'s 32-bit signed integer delay — see +`timeoutManager.setTimeoutProvider` for a workaround. + +#### Inherited from + +```ts +WithRequired.gcTime +``` + +*** + +### ~~initialData?~~ + +```ts +optional initialData: + | TData +| InitialDataFunction; +``` + +Defined in: [packages/query-core/src/types.ts:317](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L317) + +If set, this value will be used as the initial data for the query cache (as long as the query hasn't been +created or cached yet). +If set to a function, the function will be called **once** during the shared/root query initialization, and be +expected to synchronously return the initial data. +Initial data is considered stale by default unless a `staleTime` has been set. +`initialData` **is persisted** to the cache. + +#### Inherited from + +```ts +WithRequired.initialData +``` + +*** + +### ~~initialDataUpdatedAt?~~ + +```ts +optional initialDataUpdatedAt: number | () => number | undefined; +``` + +Defined in: [packages/query-core/src/types.ts:321](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L321) + +If set, this value will be used as the time (in milliseconds) of when the `initialData` itself was last updated. + +#### Inherited from + +```ts +WithRequired.initialDataUpdatedAt +``` + +*** + +### ~~initialPageParam?~~ + +```ts +optional initialPageParam: undefined; +``` + +Defined in: [packages/query-core/src/types.ts:605](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L605) + +*** + +### ~~maxPages?~~ + +```ts +optional maxPages: number; +``` + +Defined in: [packages/query-core/src/types.ts:345](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L345) + +Maximum number of pages to store in the data of an infinite query. + +#### Inherited from + +```ts +WithRequired.maxPages +``` + +*** + +### ~~meta?~~ + +```ts +optional meta: Record; +``` + +Defined in: [packages/query-core/src/types.ts:341](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L341) + +Additional payload to be stored on each query. +Use this property to pass information that can be used in other places. + +#### Inherited from + +```ts +WithRequired.meta +``` + +*** + +### ~~networkMode?~~ + +```ts +optional networkMode: NetworkMode; +``` + +Defined in: [packages/query-core/src/types.ts:265](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L265) + +Controls whether a query is allowed to run based on the current network connectivity. + +Defaults to `'online'`. + +#### See + +[Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. + +#### Inherited from + +```ts +WithRequired.networkMode +``` + +*** + +### ~~persister?~~ + +```ts +optional persister: QueryPersister, TPageParam>; +``` + +Defined in: [packages/query-core/src/types.ts:290](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L290) + +This option can be used to persist the result of a query to an external storage, bypassing the need to actually +call the `queryFn`. Useful for persisting a query's data across e.g. server/client boundaries. + +#### Inherited from + +```ts +WithRequired.persister +``` + +*** + +### ~~queryFn?~~ + +```ts +optional queryFn: + | typeof skipToken +| QueryFunction; +``` + +Defined in: [packages/query-core/src/types.ts:285](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L285) + +The function that the query will use to request data. +Required, unless a default query function has been set via `queryClient.setQueryDefaults` or +`queryClient.setDefaultOptions`. +Receives a [QueryFunctionContext](../type-aliases/QueryFunctionContext.md). +Must return a promise that will either resolve data or throw an error. The data cannot be `undefined`. + +#### Inherited from + +```ts +WithRequired.queryFn +``` + +*** + +### ~~queryHash?~~ + +```ts +optional queryHash: string; +``` + +Defined in: [packages/query-core/src/types.ts:295](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L295) + +The hashed form of `queryKey`, computed with `queryKeyHashFn` (or the default hashing function otherwise). Used +as the actual cache key internally. + +#### Inherited from + +```ts +WithRequired.queryHash +``` + +*** + +### ~~queryKey~~ + +```ts +queryKey: TQueryKey & object; +``` + +Defined in: [packages/query-core/src/types.ts:304](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L304) + +The query key to use for this query. + +The query key will be hashed into a stable hash. See [Query Keys](https://tanstack.com/query/latest/docs/framework/react/guides/query-keys) +for more information. + +The query will automatically update when this key changes (as long as `enabled` is not set to `false`). + +#### Inherited from + +```ts +WithRequired.queryKey +``` + +*** + +### ~~queryKeyHashFn?~~ + +```ts +optional queryKeyHashFn: QueryKeyHashFunction; +``` + +Defined in: [packages/query-core/src/types.ts:308](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L308) + +If specified, this function is used to hash the `queryKey` to a string. + +#### Inherited from + +```ts +WithRequired.queryKeyHashFn +``` + +*** + +### ~~retry?~~ + +```ts +optional retry: RetryValue; +``` + +Defined in: [packages/query-core/src/types.ts:246](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L246) + +If `false`, failed queries will not retry by default. +If `true`, failed queries will retry infinitely. +If set to an integer number, e.g. 3, failed queries will retry until the failed query count meets that number. +If set to a function `(failureCount, error) => boolean` failed queries will retry until the function returns false. + +Defaults to `3` on the client and `0` on the server. + +#### Inherited from + +```ts +WithRequired.retry +``` + +*** + +### ~~retryDelay?~~ + +```ts +optional retryDelay: RetryDelayValue; +``` + +Defined in: [packages/query-core/src/types.ts:258](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L258) + +This function receives a `retryAttempt` integer and the actual Error and returns the delay to apply before the +next attempt in milliseconds. + +A function like `attempt => Math.min(attempt > 1 ? 2 ** attempt * 1000 : 1000, 30 * 1000)` applies exponential +backoff. + +A function like `attempt => attempt * 1000` applies linear backoff. + +Defaults to a function that applies exponential backoff, capped at 30 seconds. + +#### Inherited from + +```ts +WithRequired.retryDelay +``` + +*** + +### ~~staleTime?~~ + +```ts +optional staleTime: StaleTimeFunction; +``` + +Defined in: [packages/query-core/src/types.ts:610](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L610) + +The time in milliseconds after data is considered stale. +If the data is fresh it will be returned from the cache. + +*** + +### ~~structuralSharing?~~ + +```ts +optional structuralSharing: boolean | (oldData, newData) => unknown; +``` + +Defined in: [packages/query-core/src/types.ts:330](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L330) + +Set this to `false` to disable structural sharing between query results. +Set this to a function which accepts the old and new data and returns resolved data of the same type to implement custom structural sharing logic. + +Defaults to `true`. + +#### Inherited from + +```ts +WithRequired.structuralSharing +``` diff --git a/docs/framework/react/reference/interfaces/FocusManager.md b/docs/framework/react/reference/interfaces/FocusManager.md new file mode 100644 index 00000000000..a7de707217d --- /dev/null +++ b/docs/framework/react/reference/interfaces/FocusManager.md @@ -0,0 +1,240 @@ +--- +id: FocusManager +title: FocusManager +redirect_from: + - reference/focusManager + - framework/react/reference/focusManager +--- + +Defined in: [packages/query-core/src/focusManager.ts:14](https://github.com/TanStack/query/blob/main/packages/query-core/src/focusManager.ts#L14) + +The `FocusManager` manages the focus state within TanStack Query. + +It can be used to change the default event listeners or to manually change the focus state. + +## Extends + +- `Subscribable`\<`Listener`\> + +## Properties + +### listeners + +```ts +protected listeners: Set; +``` + +Defined in: [packages/query-core/src/subscribable.ts:2](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L2) + +#### Inherited from + +```ts +Subscribable.listeners +``` + +## Methods + +### hasListeners() + +```ts +hasListeners(): boolean; +``` + +Defined in: [packages/query-core/src/subscribable.ts:19](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L19) + +#### Returns + +`boolean` + +#### Inherited from + +```ts +Subscribable.hasListeners +``` + +*** + +### isFocused() + +```ts +isFocused(): boolean; +``` + +Defined in: [packages/query-core/src/focusManager.ts:128](https://github.com/TanStack/query/blob/main/packages/query-core/src/focusManager.ts#L128) + +`isFocused` can be used to get the current focus state. + +#### Returns + +`boolean` + +*** + +### onFocus() + +```ts +onFocus(): void; +``` + +Defined in: [packages/query-core/src/focusManager.ts:118](https://github.com/TanStack/query/blob/main/packages/query-core/src/focusManager.ts#L118) + +`onFocus` notifies all subscribed listeners with the current focus state. + +#### Returns + +`void` + +*** + +### onSubscribe() + +```ts +protected onSubscribe(): void; +``` + +Defined in: [packages/query-core/src/focusManager.ts:39](https://github.com/TanStack/query/blob/main/packages/query-core/src/focusManager.ts#L39) + +#### Returns + +`void` + +#### Overrides + +```ts +Subscribable.onSubscribe +``` + +*** + +### onUnsubscribe() + +```ts +protected onUnsubscribe(): void; +``` + +Defined in: [packages/query-core/src/focusManager.ts:45](https://github.com/TanStack/query/blob/main/packages/query-core/src/focusManager.ts#L45) + +#### Returns + +`void` + +#### Overrides + +```ts +Subscribable.onUnsubscribe +``` + +*** + +### setEventListener() + +```ts +setEventListener(setup): void; +``` + +Defined in: [packages/query-core/src/focusManager.ts:77](https://github.com/TanStack/query/blob/main/packages/query-core/src/focusManager.ts#L77) + +`setEventListener` can be used to set a custom event listener that will +be used to determine the focus state. The provided `setup` function +receives a `setFocused` callback: call it with a `boolean` to manually +set the focus state, or with no arguments to re-evaluate the current +focus state and notify subscribers. + +#### Parameters + +##### setup + +`SetupFn` + +#### Returns + +`void` + +#### Example + +```ts +import { focusManager } from '@tanstack/query-core' + +focusManager.setEventListener((handleFocus) => { + const listener = () => handleFocus() + // Listen to visibilitychange + if (typeof window !== 'undefined' && window.addEventListener) { + window.addEventListener('visibilitychange', listener, false) + } + + return () => { + // Be sure to unsubscribe if a new handler is set + window.removeEventListener('visibilitychange', listener) + } +}) +``` + +*** + +### setFocused() + +```ts +setFocused(focused?): void; +``` + +Defined in: [packages/query-core/src/focusManager.ts:107](https://github.com/TanStack/query/blob/main/packages/query-core/src/focusManager.ts#L107) + +`setFocused` can be used to manually set the focus state. Set `undefined` +to fall back to the default focus check. + +#### Parameters + +##### focused? + +`boolean` + +#### Returns + +`void` + +#### Example + +```ts +import { focusManager } from '@tanstack/query-core' + +// Set focused +focusManager.setFocused(true) + +// Set unfocused +focusManager.setFocused(false) + +// Fallback to the default focus check +focusManager.setFocused(undefined) +``` + +*** + +### subscribe() + +```ts +subscribe(listener): () => void; +``` + +Defined in: [packages/query-core/src/subscribable.ts:8](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L8) + +#### Parameters + +##### listener + +`Listener` + +#### Returns + +```ts +(): void; +``` + +##### Returns + +`void` + +#### Inherited from + +```ts +Subscribable.subscribe +``` diff --git a/docs/framework/react/reference/interfaces/HydrateOptions.md b/docs/framework/react/reference/interfaces/HydrateOptions.md new file mode 100644 index 00000000000..fe8b92317e3 --- /dev/null +++ b/docs/framework/react/reference/interfaces/HydrateOptions.md @@ -0,0 +1,43 @@ +--- +id: HydrateOptions +title: HydrateOptions +--- + +Defined in: [packages/query-core/src/hydration.ts:61](https://github.com/TanStack/query/blob/main/packages/query-core/src/hydration.ts#L61) + +Options for `hydrate`, controlling the default options applied to queries/mutations restored from a +`DehydratedState`, and how to reverse any transformation applied by `DehydrateOptions.serializeData`. + +## Properties + +### defaultOptions? + +```ts +optional defaultOptions: object; +``` + +Defined in: [packages/query-core/src/hydration.ts:62](https://github.com/TanStack/query/blob/main/packages/query-core/src/hydration.ts#L62) + +#### deserializeData? + +```ts +optional deserializeData: TransformerFn; +``` + +Transforms a query's `data` after it is read from the dehydrated state, reversing `serializeData`. + +#### mutations? + +```ts +optional mutations: MutationOptions; +``` + +Default options merged into every mutation restored from the dehydrated state. + +#### queries? + +```ts +optional queries: QueryOptions; +``` + +Default options merged into every query restored from the dehydrated state. diff --git a/docs/framework/react/reference/interfaces/HydrationBoundaryProps.md b/docs/framework/react/reference/interfaces/HydrationBoundaryProps.md index 860db9e12fc..8728b02a751 100644 --- a/docs/framework/react/reference/interfaces/HydrationBoundaryProps.md +++ b/docs/framework/react/reference/interfaces/HydrationBoundaryProps.md @@ -3,7 +3,7 @@ id: HydrationBoundaryProps title: HydrationBoundaryProps --- -Defined in: [react-query/src/HydrationBoundary.tsx:16](https://github.com/TanStack/query/blob/main/packages/react-query/src/HydrationBoundary.tsx#L16) +Defined in: [packages/react-query/src/HydrationBoundary.tsx:16](https://github.com/TanStack/query/blob/main/packages/react-query/src/HydrationBoundary.tsx#L16) The props accepted by `HydrationBoundary`. @@ -15,7 +15,7 @@ The props accepted by `HydrationBoundary`. optional children: ReactNode; ``` -Defined in: [react-query/src/HydrationBoundary.tsx:36](https://github.com/TanStack/query/blob/main/packages/react-query/src/HydrationBoundary.tsx#L36) +Defined in: [packages/react-query/src/HydrationBoundary.tsx:36](https://github.com/TanStack/query/blob/main/packages/react-query/src/HydrationBoundary.tsx#L36) The components to render — always rendered unconditionally, not gated on hydration. New queries are hydrated into the cache during render; for queries that already exist in the cache, only newer dehydrated @@ -30,7 +30,7 @@ lands. optional options: OmitKeyof & object; ``` -Defined in: [react-query/src/HydrationBoundary.tsx:24](https://github.com/TanStack/query/blob/main/packages/react-query/src/HydrationBoundary.tsx#L24) +Defined in: [packages/react-query/src/HydrationBoundary.tsx:24](https://github.com/TanStack/query/blob/main/packages/react-query/src/HydrationBoundary.tsx#L24) Optional. Note: unlike `hydrate`, `mutations` cannot be set here. @@ -40,6 +40,9 @@ Optional. Note: unlike `hydrate`, `mutations` cannot be set here. ```ts optional defaultOptions: OmitKeyof<{ + deserializeData?: TransformerFn; + mutations?: MutationOptions; + queries?: QueryOptions; }, "mutations">; ``` @@ -51,7 +54,7 @@ optional defaultOptions: OmitKeyof<{ optional queryClient: QueryClient; ``` -Defined in: [react-query/src/HydrationBoundary.tsx:40](https://github.com/TanStack/query/blob/main/packages/react-query/src/HydrationBoundary.tsx#L40) +Defined in: [packages/react-query/src/HydrationBoundary.tsx:40](https://github.com/TanStack/query/blob/main/packages/react-query/src/HydrationBoundary.tsx#L40) Use this to use a custom `QueryClient`. Otherwise, the one from the nearest context will be used. @@ -63,6 +66,6 @@ Use this to use a custom `QueryClient`. Otherwise, the one from the nearest cont state: DehydratedState | null | undefined; ``` -Defined in: [react-query/src/HydrationBoundary.tsx:20](https://github.com/TanStack/query/blob/main/packages/react-query/src/HydrationBoundary.tsx#L20) +Defined in: [packages/react-query/src/HydrationBoundary.tsx:20](https://github.com/TanStack/query/blob/main/packages/react-query/src/HydrationBoundary.tsx#L20) The state to hydrate. diff --git a/docs/framework/react/reference/interfaces/InfiniteData.md b/docs/framework/react/reference/interfaces/InfiniteData.md new file mode 100644 index 00000000000..4d7ad595c2d --- /dev/null +++ b/docs/framework/react/reference/interfaces/InfiniteData.md @@ -0,0 +1,36 @@ +--- +id: InfiniteData +title: InfiniteData +--- + +Defined in: [packages/query-core/src/types.ts:210](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L210) + +## Type Parameters + +### TData + +`TData` + +### TPageParam + +`TPageParam` = `unknown` + +## Properties + +### pageParams + +```ts +pageParams: TPageParam[]; +``` + +Defined in: [packages/query-core/src/types.ts:212](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L212) + +*** + +### pages + +```ts +pages: TData[]; +``` + +Defined in: [packages/query-core/src/types.ts:211](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L211) diff --git a/docs/framework/react/reference/interfaces/InfiniteQueryObserverBaseResult.md b/docs/framework/react/reference/interfaces/InfiniteQueryObserverBaseResult.md new file mode 100644 index 00000000000..0aa01962aa5 --- /dev/null +++ b/docs/framework/react/reference/interfaces/InfiniteQueryObserverBaseResult.md @@ -0,0 +1,577 @@ +--- +id: InfiniteQueryObserverBaseResult +title: InfiniteQueryObserverBaseResult +--- + +Defined in: [packages/query-core/src/types.ts:1001](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1001) + +## Extends + +- [`QueryObserverBaseResult`](QueryObserverBaseResult.md)\<`TData`, `TError`\> + +## Extended by + +- [`InfiniteQueryObserverPendingResult`](InfiniteQueryObserverPendingResult.md) +- [`InfiniteQueryObserverLoadingResult`](InfiniteQueryObserverLoadingResult.md) +- [`InfiniteQueryObserverLoadingErrorResult`](InfiniteQueryObserverLoadingErrorResult.md) +- [`InfiniteQueryObserverRefetchErrorResult`](InfiniteQueryObserverRefetchErrorResult.md) +- [`InfiniteQueryObserverSuccessResult`](InfiniteQueryObserverSuccessResult.md) +- [`InfiniteQueryObserverPlaceholderResult`](InfiniteQueryObserverPlaceholderResult.md) + +## Type Parameters + +### TData + +`TData` = `unknown` + +### TError + +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) + +## Properties + +### data + +```ts +data: TData | undefined; +``` + +Defined in: [packages/query-core/src/types.ts:771](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L771) + +The last successfully resolved data for the query. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`data`](QueryObserverBaseResult.md#data) + +*** + +### dataUpdatedAt + +```ts +dataUpdatedAt: number; +``` + +Defined in: [packages/query-core/src/types.ts:775](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L775) + +The timestamp for when the query most recently returned the `status` as `"success"`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`dataUpdatedAt`](QueryObserverBaseResult.md#dataupdatedat) + +*** + +### error + +```ts +error: TError | null; +``` + +Defined in: [packages/query-core/src/types.ts:780](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L780) + +The error object for the query, if an error was thrown. +- Defaults to `null`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`error`](QueryObserverBaseResult.md#error) + +*** + +### errorUpdateCount + +```ts +errorUpdateCount: number; +``` + +Defined in: [packages/query-core/src/types.ts:799](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L799) + +The sum of all errors. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`errorUpdateCount`](QueryObserverBaseResult.md#errorupdatecount) + +*** + +### errorUpdatedAt + +```ts +errorUpdatedAt: number; +``` + +Defined in: [packages/query-core/src/types.ts:784](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L784) + +The timestamp for when the query most recently returned the `status` as `"error"`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`errorUpdatedAt`](QueryObserverBaseResult.md#errorupdatedat) + +*** + +### failureCount + +```ts +failureCount: number; +``` + +Defined in: [packages/query-core/src/types.ts:790](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L790) + +The failure count for the query. +- Incremented every time the query fails. +- Reset to `0` when the query succeeds. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`failureCount`](QueryObserverBaseResult.md#failurecount) + +*** + +### failureReason + +```ts +failureReason: TError | null; +``` + +Defined in: [packages/query-core/src/types.ts:795](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L795) + +The failure reason for the query retry. +- Reset to `null` when the query succeeds. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`failureReason`](QueryObserverBaseResult.md#failurereason) + +*** + +### fetchNextPage() + +```ts +fetchNextPage: (options?) => Promise>; +``` + +Defined in: [packages/query-core/src/types.ts:1008](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1008) + +This function allows you to fetch the next "page" of results. + +#### Parameters + +##### options? + +[`FetchNextPageOptions`](FetchNextPageOptions.md) + +#### Returns + +`Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> + +*** + +### fetchPreviousPage() + +```ts +fetchPreviousPage: (options?) => Promise>; +``` + +Defined in: [packages/query-core/src/types.ts:1014](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1014) + +This function allows you to fetch the previous "page" of results. + +#### Parameters + +##### options? + +[`FetchPreviousPageOptions`](FetchPreviousPageOptions.md) + +#### Returns + +`Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> + +*** + +### fetchStatus + +```ts +fetchStatus: FetchStatus; +``` + +Defined in: [packages/query-core/src/types.ts:889](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L889) + +The fetch status of the query. +- `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. +- `paused`: The query wanted to fetch, but has been `paused`. +- `idle`: The query is not fetching. +- See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`fetchStatus`](QueryObserverBaseResult.md#fetchstatus) + +*** + +### hasNextPage + +```ts +hasNextPage: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1020](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1020) + +Will be `true` if there is a next page to be fetched (known via the `getNextPageParam` option). + +*** + +### hasPreviousPage + +```ts +hasPreviousPage: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1024](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1024) + +Will be `true` if there is a previous page to be fetched (known via the `getPreviousPageParam` option). + +*** + +### isEnabled + +```ts +isEnabled: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:867](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L867) + +`true` if this observer is enabled, `false` otherwise. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isEnabled`](QueryObserverBaseResult.md#isenabled) + +*** + +### isError + +```ts +isError: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:804](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L804) + +A derived boolean from the `status` variable, provided for convenience. +- `true` if the query attempt resulted in an error. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isError`](QueryObserverBaseResult.md#iserror) + +*** + +### isFetched + +```ts +isFetched: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:808](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L808) + +Will be `true` if the query has been fetched. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isFetched`](QueryObserverBaseResult.md#isfetched) + +*** + +### isFetchedAfterMount + +```ts +isFetchedAfterMount: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:813](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L813) + +Will be `true` if the query has been fetched after the component mounted. +- This property can be used to not show any previously cached data. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isFetchedAfterMount`](QueryObserverBaseResult.md#isfetchedaftermount) + +*** + +### isFetching + +```ts +isFetching: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:818](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L818) + +A derived boolean from the `fetchStatus` variable, provided for convenience. +- `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isFetching`](QueryObserverBaseResult.md#isfetching) + +*** + +### isFetchingNextPage + +```ts +isFetchingNextPage: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1032](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1032) + +Will be `true` while fetching the next page with `fetchNextPage`. + +*** + +### isFetchingPreviousPage + +```ts +isFetchingPreviousPage: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1040](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1040) + +Will be `true` while fetching the previous page with `fetchPreviousPage`. + +*** + +### isFetchNextPageError + +```ts +isFetchNextPageError: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1028](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1028) + +Will be `true` if the query failed while fetching the next page. + +*** + +### isFetchPreviousPageError + +```ts +isFetchPreviousPageError: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1036](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1036) + +Will be `true` if the query failed while fetching the previous page. + +*** + +### ~~isInitialLoading~~ + +```ts +isInitialLoading: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:836](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L836) + +#### Deprecated + +`isInitialLoading` is being deprecated in favor of `isLoading` +and will be removed in the next major version. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isInitialLoading`](QueryObserverBaseResult.md#isinitialloading) + +*** + +### isLoading + +```ts +isLoading: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:823](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L823) + +Is `true` whenever the first fetch for a query is in-flight. +- Is the same as `isFetching && isPending`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoading`](QueryObserverBaseResult.md#isloading) + +*** + +### isLoadingError + +```ts +isLoadingError: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:831](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L831) + +Will be `true` if the query failed while fetching for the first time. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoadingError`](QueryObserverBaseResult.md#isloadingerror) + +*** + +### isPaused + +```ts +isPaused: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:841](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L841) + +A derived boolean from the `fetchStatus` variable, provided for convenience. +- The query wanted to fetch, but has been `paused`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPaused`](QueryObserverBaseResult.md#ispaused) + +*** + +### isPending + +```ts +isPending: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:827](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L827) + +Will be `pending` if there's no cached data and no query attempt was finished yet. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPending`](QueryObserverBaseResult.md#ispending) + +*** + +### isPlaceholderData + +```ts +isPlaceholderData: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:845](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L845) + +Will be `true` if the data shown is the placeholder data. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPlaceholderData`](QueryObserverBaseResult.md#isplaceholderdata) + +*** + +### isRefetchError + +```ts +isRefetchError: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:849](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L849) + +Will be `true` if the query failed while refetching. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetchError`](QueryObserverBaseResult.md#isrefetcherror) + +*** + +### isRefetching + +```ts +isRefetching: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:854](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L854) + +Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. +- Is the same as `isFetching && !isPending`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetching`](QueryObserverBaseResult.md#isrefetching) + +*** + +### isStale + +```ts +isStale: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:858](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L858) + +Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isStale`](QueryObserverBaseResult.md#isstale) + +*** + +### isSuccess + +```ts +isSuccess: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:863](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L863) + +A derived boolean from the `status` variable, provided for convenience. +- `true` if the query has received a response with no errors and is ready to display its data. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isSuccess`](QueryObserverBaseResult.md#issuccess) + +*** + +### refetch() + +```ts +refetch: (options?) => Promise>; +``` + +Defined in: [packages/query-core/src/types.ts:871](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L871) + +A function to manually refetch the query. + +#### Parameters + +##### options? + +[`RefetchOptions`](RefetchOptions.md) + +#### Returns + +`Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`refetch`](QueryObserverBaseResult.md#refetch) + +*** + +### status + +```ts +status: QueryStatus; +``` + +Defined in: [packages/query-core/src/types.ts:881](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L881) + +The status of the query. +- Will be: + - `pending` if there's no cached data and no query attempt was finished yet. + - `error` if the query attempt resulted in an error. + - `success` if the query has received a response with no errors and is ready to display its data. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`status`](QueryObserverBaseResult.md#status) diff --git a/docs/framework/react/reference/interfaces/InfiniteQueryObserverLoadingErrorResult.md b/docs/framework/react/reference/interfaces/InfiniteQueryObserverLoadingErrorResult.md new file mode 100644 index 00000000000..f5e3352f27c --- /dev/null +++ b/docs/framework/react/reference/interfaces/InfiniteQueryObserverLoadingErrorResult.md @@ -0,0 +1,600 @@ +--- +id: InfiniteQueryObserverLoadingErrorResult +title: InfiniteQueryObserverLoadingErrorResult +--- + +Defined in: [packages/query-core/src/types.ts:1078](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1078) + +## Extends + +- [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md)\<`TData`, `TError`\> + +## Type Parameters + +### TData + +`TData` = `unknown` + +### TError + +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) + +## Properties + +### data + +```ts +data: undefined; +``` + +Defined in: [packages/query-core/src/types.ts:1082](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1082) + +The last successfully resolved data for the query. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`data`](InfiniteQueryObserverBaseResult.md#data) + +*** + +### dataUpdatedAt + +```ts +dataUpdatedAt: number; +``` + +Defined in: [packages/query-core/src/types.ts:775](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L775) + +The timestamp for when the query most recently returned the `status` as `"success"`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`dataUpdatedAt`](InfiniteQueryObserverBaseResult.md#dataupdatedat) + +*** + +### error + +```ts +error: TError; +``` + +Defined in: [packages/query-core/src/types.ts:1083](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1083) + +The error object for the query, if an error was thrown. +- Defaults to `null`. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`error`](InfiniteQueryObserverBaseResult.md#error) + +*** + +### errorUpdateCount + +```ts +errorUpdateCount: number; +``` + +Defined in: [packages/query-core/src/types.ts:799](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L799) + +The sum of all errors. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`errorUpdateCount`](InfiniteQueryObserverBaseResult.md#errorupdatecount) + +*** + +### errorUpdatedAt + +```ts +errorUpdatedAt: number; +``` + +Defined in: [packages/query-core/src/types.ts:784](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L784) + +The timestamp for when the query most recently returned the `status` as `"error"`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`errorUpdatedAt`](InfiniteQueryObserverBaseResult.md#errorupdatedat) + +*** + +### failureCount + +```ts +failureCount: number; +``` + +Defined in: [packages/query-core/src/types.ts:790](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L790) + +The failure count for the query. +- Incremented every time the query fails. +- Reset to `0` when the query succeeds. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`failureCount`](InfiniteQueryObserverBaseResult.md#failurecount) + +*** + +### failureReason + +```ts +failureReason: TError | null; +``` + +Defined in: [packages/query-core/src/types.ts:795](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L795) + +The failure reason for the query retry. +- Reset to `null` when the query succeeds. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`failureReason`](InfiniteQueryObserverBaseResult.md#failurereason) + +*** + +### fetchNextPage() + +```ts +fetchNextPage: (options?) => Promise>; +``` + +Defined in: [packages/query-core/src/types.ts:1008](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1008) + +This function allows you to fetch the next "page" of results. + +#### Parameters + +##### options? + +[`FetchNextPageOptions`](FetchNextPageOptions.md) + +#### Returns + +`Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`fetchNextPage`](InfiniteQueryObserverBaseResult.md#fetchnextpage) + +*** + +### fetchPreviousPage() + +```ts +fetchPreviousPage: (options?) => Promise>; +``` + +Defined in: [packages/query-core/src/types.ts:1014](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1014) + +This function allows you to fetch the previous "page" of results. + +#### Parameters + +##### options? + +[`FetchPreviousPageOptions`](FetchPreviousPageOptions.md) + +#### Returns + +`Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`fetchPreviousPage`](InfiniteQueryObserverBaseResult.md#fetchpreviouspage) + +*** + +### fetchStatus + +```ts +fetchStatus: FetchStatus; +``` + +Defined in: [packages/query-core/src/types.ts:889](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L889) + +The fetch status of the query. +- `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. +- `paused`: The query wanted to fetch, but has been `paused`. +- `idle`: The query is not fetching. +- See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`fetchStatus`](InfiniteQueryObserverBaseResult.md#fetchstatus) + +*** + +### hasNextPage + +```ts +hasNextPage: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1020](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1020) + +Will be `true` if there is a next page to be fetched (known via the `getNextPageParam` option). + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`hasNextPage`](InfiniteQueryObserverBaseResult.md#hasnextpage) + +*** + +### hasPreviousPage + +```ts +hasPreviousPage: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1024](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1024) + +Will be `true` if there is a previous page to be fetched (known via the `getPreviousPageParam` option). + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`hasPreviousPage`](InfiniteQueryObserverBaseResult.md#haspreviouspage) + +*** + +### isEnabled + +```ts +isEnabled: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:867](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L867) + +`true` if this observer is enabled, `false` otherwise. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isEnabled`](InfiniteQueryObserverBaseResult.md#isenabled) + +*** + +### isError + +```ts +isError: true; +``` + +Defined in: [packages/query-core/src/types.ts:1084](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1084) + +A derived boolean from the `status` variable, provided for convenience. +- `true` if the query attempt resulted in an error. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isError`](InfiniteQueryObserverBaseResult.md#iserror) + +*** + +### isFetched + +```ts +isFetched: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:808](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L808) + +Will be `true` if the query has been fetched. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetched`](InfiniteQueryObserverBaseResult.md#isfetched) + +*** + +### isFetchedAfterMount + +```ts +isFetchedAfterMount: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:813](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L813) + +Will be `true` if the query has been fetched after the component mounted. +- This property can be used to not show any previously cached data. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchedAfterMount`](InfiniteQueryObserverBaseResult.md#isfetchedaftermount) + +*** + +### isFetching + +```ts +isFetching: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:818](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L818) + +A derived boolean from the `fetchStatus` variable, provided for convenience. +- `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetching`](InfiniteQueryObserverBaseResult.md#isfetching) + +*** + +### isFetchingNextPage + +```ts +isFetchingNextPage: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1032](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1032) + +Will be `true` while fetching the next page with `fetchNextPage`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchingNextPage`](InfiniteQueryObserverBaseResult.md#isfetchingnextpage) + +*** + +### isFetchingPreviousPage + +```ts +isFetchingPreviousPage: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1040](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1040) + +Will be `true` while fetching the previous page with `fetchPreviousPage`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchingPreviousPage`](InfiniteQueryObserverBaseResult.md#isfetchingpreviouspage) + +*** + +### isFetchNextPageError + +```ts +isFetchNextPageError: false; +``` + +Defined in: [packages/query-core/src/types.ts:1089](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1089) + +Will be `true` if the query failed while fetching the next page. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchNextPageError`](InfiniteQueryObserverBaseResult.md#isfetchnextpageerror) + +*** + +### isFetchPreviousPageError + +```ts +isFetchPreviousPageError: false; +``` + +Defined in: [packages/query-core/src/types.ts:1090](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1090) + +Will be `true` if the query failed while fetching the previous page. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchPreviousPageError`](InfiniteQueryObserverBaseResult.md#isfetchpreviouspageerror) + +*** + +### ~~isInitialLoading~~ + +```ts +isInitialLoading: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:836](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L836) + +#### Deprecated + +`isInitialLoading` is being deprecated in favor of `isLoading` +and will be removed in the next major version. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isInitialLoading`](InfiniteQueryObserverBaseResult.md#isinitialloading) + +*** + +### isLoading + +```ts +isLoading: false; +``` + +Defined in: [packages/query-core/src/types.ts:1086](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1086) + +Is `true` whenever the first fetch for a query is in-flight. +- Is the same as `isFetching && isPending`. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoading`](InfiniteQueryObserverBaseResult.md#isloading) + +*** + +### isLoadingError + +```ts +isLoadingError: true; +``` + +Defined in: [packages/query-core/src/types.ts:1087](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1087) + +Will be `true` if the query failed while fetching for the first time. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoadingError`](InfiniteQueryObserverBaseResult.md#isloadingerror) + +*** + +### isPaused + +```ts +isPaused: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:841](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L841) + +A derived boolean from the `fetchStatus` variable, provided for convenience. +- The query wanted to fetch, but has been `paused`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPaused`](InfiniteQueryObserverBaseResult.md#ispaused) + +*** + +### isPending + +```ts +isPending: false; +``` + +Defined in: [packages/query-core/src/types.ts:1085](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1085) + +Will be `pending` if there's no cached data and no query attempt was finished yet. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPending`](InfiniteQueryObserverBaseResult.md#ispending) + +*** + +### isPlaceholderData + +```ts +isPlaceholderData: false; +``` + +Defined in: [packages/query-core/src/types.ts:1092](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1092) + +Will be `true` if the data shown is the placeholder data. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPlaceholderData`](InfiniteQueryObserverBaseResult.md#isplaceholderdata) + +*** + +### isRefetchError + +```ts +isRefetchError: false; +``` + +Defined in: [packages/query-core/src/types.ts:1088](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1088) + +Will be `true` if the query failed while refetching. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isRefetchError`](InfiniteQueryObserverBaseResult.md#isrefetcherror) + +*** + +### isRefetching + +```ts +isRefetching: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:854](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L854) + +Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. +- Is the same as `isFetching && !isPending`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isRefetching`](InfiniteQueryObserverBaseResult.md#isrefetching) + +*** + +### isStale + +```ts +isStale: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:858](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L858) + +Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isStale`](InfiniteQueryObserverBaseResult.md#isstale) + +*** + +### isSuccess + +```ts +isSuccess: false; +``` + +Defined in: [packages/query-core/src/types.ts:1091](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1091) + +A derived boolean from the `status` variable, provided for convenience. +- `true` if the query has received a response with no errors and is ready to display its data. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isSuccess`](InfiniteQueryObserverBaseResult.md#issuccess) + +*** + +### refetch() + +```ts +refetch: (options?) => Promise>; +``` + +Defined in: [packages/query-core/src/types.ts:871](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L871) + +A function to manually refetch the query. + +#### Parameters + +##### options? + +[`RefetchOptions`](RefetchOptions.md) + +#### Returns + +`Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`refetch`](InfiniteQueryObserverBaseResult.md#refetch) + +*** + +### status + +```ts +status: "error"; +``` + +Defined in: [packages/query-core/src/types.ts:1093](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1093) + +The status of the query. +- Will be: + - `pending` if there's no cached data and no query attempt was finished yet. + - `error` if the query attempt resulted in an error. + - `success` if the query has received a response with no errors and is ready to display its data. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`status`](InfiniteQueryObserverBaseResult.md#status) diff --git a/docs/framework/react/reference/interfaces/InfiniteQueryObserverLoadingResult.md b/docs/framework/react/reference/interfaces/InfiniteQueryObserverLoadingResult.md new file mode 100644 index 00000000000..b7aa67744c0 --- /dev/null +++ b/docs/framework/react/reference/interfaces/InfiniteQueryObserverLoadingResult.md @@ -0,0 +1,600 @@ +--- +id: InfiniteQueryObserverLoadingResult +title: InfiniteQueryObserverLoadingResult +--- + +Defined in: [packages/query-core/src/types.ts:1060](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1060) + +## Extends + +- [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md)\<`TData`, `TError`\> + +## Type Parameters + +### TData + +`TData` = `unknown` + +### TError + +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) + +## Properties + +### data + +```ts +data: undefined; +``` + +Defined in: [packages/query-core/src/types.ts:1064](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1064) + +The last successfully resolved data for the query. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`data`](InfiniteQueryObserverBaseResult.md#data) + +*** + +### dataUpdatedAt + +```ts +dataUpdatedAt: number; +``` + +Defined in: [packages/query-core/src/types.ts:775](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L775) + +The timestamp for when the query most recently returned the `status` as `"success"`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`dataUpdatedAt`](InfiniteQueryObserverBaseResult.md#dataupdatedat) + +*** + +### error + +```ts +error: null; +``` + +Defined in: [packages/query-core/src/types.ts:1065](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1065) + +The error object for the query, if an error was thrown. +- Defaults to `null`. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`error`](InfiniteQueryObserverBaseResult.md#error) + +*** + +### errorUpdateCount + +```ts +errorUpdateCount: number; +``` + +Defined in: [packages/query-core/src/types.ts:799](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L799) + +The sum of all errors. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`errorUpdateCount`](InfiniteQueryObserverBaseResult.md#errorupdatecount) + +*** + +### errorUpdatedAt + +```ts +errorUpdatedAt: number; +``` + +Defined in: [packages/query-core/src/types.ts:784](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L784) + +The timestamp for when the query most recently returned the `status` as `"error"`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`errorUpdatedAt`](InfiniteQueryObserverBaseResult.md#errorupdatedat) + +*** + +### failureCount + +```ts +failureCount: number; +``` + +Defined in: [packages/query-core/src/types.ts:790](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L790) + +The failure count for the query. +- Incremented every time the query fails. +- Reset to `0` when the query succeeds. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`failureCount`](InfiniteQueryObserverBaseResult.md#failurecount) + +*** + +### failureReason + +```ts +failureReason: TError | null; +``` + +Defined in: [packages/query-core/src/types.ts:795](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L795) + +The failure reason for the query retry. +- Reset to `null` when the query succeeds. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`failureReason`](InfiniteQueryObserverBaseResult.md#failurereason) + +*** + +### fetchNextPage() + +```ts +fetchNextPage: (options?) => Promise>; +``` + +Defined in: [packages/query-core/src/types.ts:1008](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1008) + +This function allows you to fetch the next "page" of results. + +#### Parameters + +##### options? + +[`FetchNextPageOptions`](FetchNextPageOptions.md) + +#### Returns + +`Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`fetchNextPage`](InfiniteQueryObserverBaseResult.md#fetchnextpage) + +*** + +### fetchPreviousPage() + +```ts +fetchPreviousPage: (options?) => Promise>; +``` + +Defined in: [packages/query-core/src/types.ts:1014](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1014) + +This function allows you to fetch the previous "page" of results. + +#### Parameters + +##### options? + +[`FetchPreviousPageOptions`](FetchPreviousPageOptions.md) + +#### Returns + +`Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`fetchPreviousPage`](InfiniteQueryObserverBaseResult.md#fetchpreviouspage) + +*** + +### fetchStatus + +```ts +fetchStatus: FetchStatus; +``` + +Defined in: [packages/query-core/src/types.ts:889](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L889) + +The fetch status of the query. +- `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. +- `paused`: The query wanted to fetch, but has been `paused`. +- `idle`: The query is not fetching. +- See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`fetchStatus`](InfiniteQueryObserverBaseResult.md#fetchstatus) + +*** + +### hasNextPage + +```ts +hasNextPage: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1020](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1020) + +Will be `true` if there is a next page to be fetched (known via the `getNextPageParam` option). + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`hasNextPage`](InfiniteQueryObserverBaseResult.md#hasnextpage) + +*** + +### hasPreviousPage + +```ts +hasPreviousPage: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1024](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1024) + +Will be `true` if there is a previous page to be fetched (known via the `getPreviousPageParam` option). + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`hasPreviousPage`](InfiniteQueryObserverBaseResult.md#haspreviouspage) + +*** + +### isEnabled + +```ts +isEnabled: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:867](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L867) + +`true` if this observer is enabled, `false` otherwise. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isEnabled`](InfiniteQueryObserverBaseResult.md#isenabled) + +*** + +### isError + +```ts +isError: false; +``` + +Defined in: [packages/query-core/src/types.ts:1066](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1066) + +A derived boolean from the `status` variable, provided for convenience. +- `true` if the query attempt resulted in an error. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isError`](InfiniteQueryObserverBaseResult.md#iserror) + +*** + +### isFetched + +```ts +isFetched: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:808](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L808) + +Will be `true` if the query has been fetched. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetched`](InfiniteQueryObserverBaseResult.md#isfetched) + +*** + +### isFetchedAfterMount + +```ts +isFetchedAfterMount: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:813](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L813) + +Will be `true` if the query has been fetched after the component mounted. +- This property can be used to not show any previously cached data. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchedAfterMount`](InfiniteQueryObserverBaseResult.md#isfetchedaftermount) + +*** + +### isFetching + +```ts +isFetching: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:818](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L818) + +A derived boolean from the `fetchStatus` variable, provided for convenience. +- `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetching`](InfiniteQueryObserverBaseResult.md#isfetching) + +*** + +### isFetchingNextPage + +```ts +isFetchingNextPage: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1032](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1032) + +Will be `true` while fetching the next page with `fetchNextPage`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchingNextPage`](InfiniteQueryObserverBaseResult.md#isfetchingnextpage) + +*** + +### isFetchingPreviousPage + +```ts +isFetchingPreviousPage: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1040](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1040) + +Will be `true` while fetching the previous page with `fetchPreviousPage`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchingPreviousPage`](InfiniteQueryObserverBaseResult.md#isfetchingpreviouspage) + +*** + +### isFetchNextPageError + +```ts +isFetchNextPageError: false; +``` + +Defined in: [packages/query-core/src/types.ts:1071](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1071) + +Will be `true` if the query failed while fetching the next page. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchNextPageError`](InfiniteQueryObserverBaseResult.md#isfetchnextpageerror) + +*** + +### isFetchPreviousPageError + +```ts +isFetchPreviousPageError: false; +``` + +Defined in: [packages/query-core/src/types.ts:1072](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1072) + +Will be `true` if the query failed while fetching the previous page. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchPreviousPageError`](InfiniteQueryObserverBaseResult.md#isfetchpreviouspageerror) + +*** + +### ~~isInitialLoading~~ + +```ts +isInitialLoading: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:836](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L836) + +#### Deprecated + +`isInitialLoading` is being deprecated in favor of `isLoading` +and will be removed in the next major version. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isInitialLoading`](InfiniteQueryObserverBaseResult.md#isinitialloading) + +*** + +### isLoading + +```ts +isLoading: true; +``` + +Defined in: [packages/query-core/src/types.ts:1068](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1068) + +Is `true` whenever the first fetch for a query is in-flight. +- Is the same as `isFetching && isPending`. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoading`](InfiniteQueryObserverBaseResult.md#isloading) + +*** + +### isLoadingError + +```ts +isLoadingError: false; +``` + +Defined in: [packages/query-core/src/types.ts:1069](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1069) + +Will be `true` if the query failed while fetching for the first time. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoadingError`](InfiniteQueryObserverBaseResult.md#isloadingerror) + +*** + +### isPaused + +```ts +isPaused: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:841](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L841) + +A derived boolean from the `fetchStatus` variable, provided for convenience. +- The query wanted to fetch, but has been `paused`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPaused`](InfiniteQueryObserverBaseResult.md#ispaused) + +*** + +### isPending + +```ts +isPending: true; +``` + +Defined in: [packages/query-core/src/types.ts:1067](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1067) + +Will be `pending` if there's no cached data and no query attempt was finished yet. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPending`](InfiniteQueryObserverBaseResult.md#ispending) + +*** + +### isPlaceholderData + +```ts +isPlaceholderData: false; +``` + +Defined in: [packages/query-core/src/types.ts:1074](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1074) + +Will be `true` if the data shown is the placeholder data. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPlaceholderData`](InfiniteQueryObserverBaseResult.md#isplaceholderdata) + +*** + +### isRefetchError + +```ts +isRefetchError: false; +``` + +Defined in: [packages/query-core/src/types.ts:1070](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1070) + +Will be `true` if the query failed while refetching. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isRefetchError`](InfiniteQueryObserverBaseResult.md#isrefetcherror) + +*** + +### isRefetching + +```ts +isRefetching: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:854](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L854) + +Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. +- Is the same as `isFetching && !isPending`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isRefetching`](InfiniteQueryObserverBaseResult.md#isrefetching) + +*** + +### isStale + +```ts +isStale: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:858](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L858) + +Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isStale`](InfiniteQueryObserverBaseResult.md#isstale) + +*** + +### isSuccess + +```ts +isSuccess: false; +``` + +Defined in: [packages/query-core/src/types.ts:1073](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1073) + +A derived boolean from the `status` variable, provided for convenience. +- `true` if the query has received a response with no errors and is ready to display its data. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isSuccess`](InfiniteQueryObserverBaseResult.md#issuccess) + +*** + +### refetch() + +```ts +refetch: (options?) => Promise>; +``` + +Defined in: [packages/query-core/src/types.ts:871](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L871) + +A function to manually refetch the query. + +#### Parameters + +##### options? + +[`RefetchOptions`](RefetchOptions.md) + +#### Returns + +`Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`refetch`](InfiniteQueryObserverBaseResult.md#refetch) + +*** + +### status + +```ts +status: "pending"; +``` + +Defined in: [packages/query-core/src/types.ts:1075](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1075) + +The status of the query. +- Will be: + - `pending` if there's no cached data and no query attempt was finished yet. + - `error` if the query attempt resulted in an error. + - `success` if the query has received a response with no errors and is ready to display its data. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`status`](InfiniteQueryObserverBaseResult.md#status) diff --git a/docs/framework/react/reference/interfaces/InfiniteQueryObserverOptions.md b/docs/framework/react/reference/interfaces/InfiniteQueryObserverOptions.md new file mode 100644 index 00000000000..7670bd8e24b --- /dev/null +++ b/docs/framework/react/reference/interfaces/InfiniteQueryObserverOptions.md @@ -0,0 +1,624 @@ +--- +id: InfiniteQueryObserverOptions +title: InfiniteQueryObserverOptions +--- + +Defined in: [packages/query-core/src/types.ts:539](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L539) + +## Extends + +- [`QueryObserverOptions`](QueryObserverOptions.md)\<`TQueryFnData`, `TError`, `TData`, [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`, `TPageParam`\>.[`InfiniteQueryPageParamsOptions`](InfiniteQueryPageParamsOptions.md)\<`TQueryFnData`, `TPageParam`\> + +## Type Parameters + +### TQueryFnData + +`TQueryFnData` = `unknown` + +### TError + +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) + +### TData + +`TData` = `TQueryFnData` + +### TQueryKey + +`TQueryKey` *extends* [`QueryKey`](../type-aliases/QueryKey.md) = [`QueryKey`](../type-aliases/QueryKey.md) + +### TPageParam + +`TPageParam` = `unknown` + +## Properties + +### enabled? + +```ts +optional enabled: QueryBooleanOption, TQueryKey>; +``` + +Defined in: [packages/query-core/src/types.ts:398](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L398) + +Set this to `false` or a function that returns `false` to disable automatic refetching when the query mounts or changes query keys. +To refetch the query, use the `refetch` method returned from the `useQuery` instance. +Accepts a boolean or function that returns a boolean. + +Defaults to `true`. + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`enabled`](QueryObserverOptions.md#enabled) + +*** + +### gcTime? + +```ts +optional gcTime: number; +``` + +Defined in: [packages/query-core/src/types.ts:277](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L277) + +The time in milliseconds that unused/inactive cache data remains in memory. +When a query's cache becomes unused or inactive, that cache data will be garbage collected after this duration. +When different garbage collection times are specified, the longest one will be used. +Setting it to `Infinity` will disable garbage collection. + +Defaults to `5 * 60 * 1000` (5 minutes), or `Infinity` during SSR. + +Note: the maximum allowed time is about 24 days, imposed by `setTimeout`'s 32-bit signed integer delay — see +`timeoutManager.setTimeoutProvider` for a workaround. + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`gcTime`](QueryObserverOptions.md#gctime) + +*** + +### getNextPageParam + +```ts +getNextPageParam: GetNextPageParamFunction; +``` + +Defined in: [packages/query-core/src/types.ts:365](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L365) + +This function can be set to automatically get the next cursor for infinite queries. +The result will also be used to determine the value of `hasNextPage`. + +#### Inherited from + +[`InfiniteQueryPageParamsOptions`](InfiniteQueryPageParamsOptions.md).[`getNextPageParam`](InfiniteQueryPageParamsOptions.md#getnextpageparam) + +*** + +### getPreviousPageParam? + +```ts +optional getPreviousPageParam: GetPreviousPageParamFunction; +``` + +Defined in: [packages/query-core/src/types.ts:360](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L360) + +This function can be set to automatically get the previous cursor for infinite queries. +The result will also be used to determine the value of `hasPreviousPage`. + +#### Inherited from + +[`InfiniteQueryPageParamsOptions`](InfiniteQueryPageParamsOptions.md).[`getPreviousPageParam`](InfiniteQueryPageParamsOptions.md#getpreviouspageparam) + +*** + +### initialData? + +```ts +optional initialData: + | InfiniteData +| InitialDataFunction>; +``` + +Defined in: [packages/query-core/src/types.ts:317](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L317) + +If set, this value will be used as the initial data for the query cache (as long as the query hasn't been +created or cached yet). +If set to a function, the function will be called **once** during the shared/root query initialization, and be +expected to synchronously return the initial data. +Initial data is considered stale by default unless a `staleTime` has been set. +`initialData` **is persisted** to the cache. + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`initialData`](QueryObserverOptions.md#initialdata) + +*** + +### initialDataUpdatedAt? + +```ts +optional initialDataUpdatedAt: number | () => number | undefined; +``` + +Defined in: [packages/query-core/src/types.ts:321](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L321) + +If set, this value will be used as the time (in milliseconds) of when the `initialData` itself was last updated. + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`initialDataUpdatedAt`](QueryObserverOptions.md#initialdataupdatedat) + +*** + +### initialPageParam + +```ts +initialPageParam: TPageParam; +``` + +Defined in: [packages/query-core/src/types.ts:349](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L349) + +#### Inherited from + +[`InfiniteQueryPageParamsOptions`](InfiniteQueryPageParamsOptions.md).[`initialPageParam`](InfiniteQueryPageParamsOptions.md#initialpageparam) + +*** + +### maxPages? + +```ts +optional maxPages: number; +``` + +Defined in: [packages/query-core/src/types.ts:345](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L345) + +Maximum number of pages to store in the data of an infinite query. + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`maxPages`](QueryObserverOptions.md#maxpages) + +*** + +### meta? + +```ts +optional meta: Record; +``` + +Defined in: [packages/query-core/src/types.ts:341](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L341) + +Additional payload to be stored on each query. +Use this property to pass information that can be used in other places. + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`meta`](QueryObserverOptions.md#meta) + +*** + +### networkMode? + +```ts +optional networkMode: NetworkMode; +``` + +Defined in: [packages/query-core/src/types.ts:265](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L265) + +Controls whether a query is allowed to run based on the current network connectivity. + +Defaults to `'online'`. + +#### See + +[Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`networkMode`](QueryObserverOptions.md#networkmode) + +*** + +### notifyOnChangeProps? + +```ts +optional notifyOnChangeProps: NotifyOnChangeProps; +``` + +Defined in: [packages/query-core/src/types.ts:484](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L484) + +If set, the component will only re-render if any of the listed properties change. +When set to `['data', 'error']`, the component will only re-render when the `data` or `error` properties change. +When set to `'all'`, the component will re-render whenever a query is updated. +When set to a function, the function will be executed to compute the list of properties. + +Defaults to `undefined`, in which case property access is tracked automatically, and the +component only re-renders when one of the tracked properties changes. + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`notifyOnChangeProps`](QueryObserverOptions.md#notifyonchangeprops) + +*** + +### persister? + +```ts +optional persister: QueryPersister, TPageParam>; +``` + +Defined in: [packages/query-core/src/types.ts:290](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L290) + +This option can be used to persist the result of a query to an external storage, bypassing the need to actually +call the `queryFn`. Useful for persisting a query's data across e.g. server/client boundaries. + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`persister`](QueryObserverOptions.md#persister) + +*** + +### placeholderData? + +```ts +optional placeholderData: + | InfiniteData +| PlaceholderDataFunction, TError, InfiniteData, TQueryKey>; +``` + +Defined in: [packages/query-core/src/types.ts:511](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L511) + +If set, this value will be used as the placeholder data for this particular query observer while the query is still in the `loading` data and no initialData has been provided. + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`placeholderData`](QueryObserverOptions.md#placeholderdata) + +*** + +### queryFn? + +```ts +optional queryFn: + | typeof skipToken +| QueryFunction; +``` + +Defined in: [packages/query-core/src/types.ts:285](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L285) + +The function that the query will use to request data. +Required, unless a default query function has been set via `queryClient.setQueryDefaults` or +`queryClient.setDefaultOptions`. +Receives a [QueryFunctionContext](../type-aliases/QueryFunctionContext.md). +Must return a promise that will either resolve data or throw an error. The data cannot be `undefined`. + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`queryFn`](QueryObserverOptions.md#queryfn) + +*** + +### queryHash? + +```ts +optional queryHash: string; +``` + +Defined in: [packages/query-core/src/types.ts:295](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L295) + +The hashed form of `queryKey`, computed with `queryKeyHashFn` (or the default hashing function otherwise). Used +as the actual cache key internally. + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`queryHash`](QueryObserverOptions.md#queryhash) + +*** + +### queryKey + +```ts +queryKey: TQueryKey & object; +``` + +Defined in: [packages/query-core/src/types.ts:304](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L304) + +The query key to use for this query. + +The query key will be hashed into a stable hash. See [Query Keys](https://tanstack.com/query/latest/docs/framework/react/guides/query-keys) +for more information. + +The query will automatically update when this key changes (as long as `enabled` is not set to `false`). + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`queryKey`](QueryObserverOptions.md#querykey) + +*** + +### queryKeyHashFn? + +```ts +optional queryKeyHashFn: QueryKeyHashFunction; +``` + +Defined in: [packages/query-core/src/types.ts:308](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L308) + +If specified, this function is used to hash the `queryKey` to a string. + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`queryKeyHashFn`](QueryObserverOptions.md#querykeyhashfn) + +*** + +### refetchInterval? + +```ts +optional refetchInterval: number | false | (query) => number | false | undefined; +``` + +Defined in: [packages/query-core/src/types.ts:414](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L414) + +If set to a number, the query will continuously refetch at this frequency in milliseconds. +If set to a function, the function will be executed with the latest data and query to compute a frequency + +Defaults to `false`. + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`refetchInterval`](QueryObserverOptions.md#refetchinterval) + +*** + +### refetchIntervalInBackground? + +```ts +optional refetchIntervalInBackground: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:425](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L425) + +If set to `true`, the query will continue to refetch while their tab/window is in the background. + +Defaults to `false`. + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`refetchIntervalInBackground`](QueryObserverOptions.md#refetchintervalinbackground) + +*** + +### refetchOnMount? + +```ts +optional refetchOnMount: boolean | "always" | (query) => boolean | "always"; +``` + +Defined in: [packages/query-core/src/types.ts:462](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L462) + +If set to `true`, the query will refetch on mount if the data is stale. +If set to `false`, will disable additional instances of a query to trigger background refetch. +If set to `'always'`, the query will always refetch on mount (except when `staleTime: 'static'` is used). +If set to a function, the function will be executed with the latest data and query to compute the value + +Defaults to `true`. + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`refetchOnMount`](QueryObserverOptions.md#refetchonmount) + +*** + +### refetchOnReconnect? + +```ts +optional refetchOnReconnect: boolean | "always" | (query) => boolean | "always"; +``` + +Defined in: [packages/query-core/src/types.ts:448](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L448) + +If set to `true`, the query will refetch on reconnect if the data is stale. +If set to `false`, the query will not refetch on reconnect. +If set to `'always'`, the query will always refetch on reconnect (except when `staleTime: 'static'` is used). +If set to a function, the function will be executed with the latest data and query to compute the value. + +Defaults to `true` unless `networkMode` is `'always'`. + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`refetchOnReconnect`](QueryObserverOptions.md#refetchonreconnect) + +*** + +### refetchOnWindowFocus? + +```ts +optional refetchOnWindowFocus: boolean | "always" | (query) => boolean | "always"; +``` + +Defined in: [packages/query-core/src/types.ts:434](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L434) + +If set to `true`, the query will refetch on window focus if the data is stale. +If set to `false`, the query will not refetch on window focus. +If set to `'always'`, the query will always refetch on window focus (except when `staleTime: 'static'` is used). +If set to a function, the function will be executed with the latest data and query to compute the value. + +Defaults to `true`. + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`refetchOnWindowFocus`](QueryObserverOptions.md#refetchonwindowfocus) + +*** + +### retry? + +```ts +optional retry: RetryValue; +``` + +Defined in: [packages/query-core/src/types.ts:246](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L246) + +If `false`, failed queries will not retry by default. +If `true`, failed queries will retry infinitely. +If set to an integer number, e.g. 3, failed queries will retry until the failed query count meets that number. +If set to a function `(failureCount, error) => boolean` failed queries will retry until the function returns false. + +Defaults to `3` on the client and `0` on the server. + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`retry`](QueryObserverOptions.md#retry) + +*** + +### retryDelay? + +```ts +optional retryDelay: RetryDelayValue; +``` + +Defined in: [packages/query-core/src/types.ts:258](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L258) + +This function receives a `retryAttempt` integer and the actual Error and returns the delay to apply before the +next attempt in milliseconds. + +A function like `attempt => Math.min(attempt > 1 ? 2 ** attempt * 1000 : 1000, 30 * 1000)` applies exponential +backoff. + +A function like `attempt => attempt * 1000` applies linear backoff. + +Defaults to a function that applies exponential backoff, capped at 30 seconds. + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`retryDelay`](QueryObserverOptions.md#retrydelay) + +*** + +### retryOnMount? + +```ts +optional retryOnMount: QueryBooleanOption, TQueryKey>; +``` + +Defined in: [packages/query-core/src/types.ts:474](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L474) + +If set to `false`, the query will not be retried on mount if it contains an error. +If set to a function, the function will be executed with the query to compute the value. + +Defaults to `true`. + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`retryOnMount`](QueryObserverOptions.md#retryonmount) + +*** + +### select()? + +```ts +optional select: (data) => TData; +``` + +Defined in: [packages/query-core/src/types.ts:500](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L500) + +This option can be used to transform or select a part of the data returned by the query function. It affects +the returned `data` value, but does not affect what gets stored in the query cache. +The `select` function will only run if `data` changed, or if the reference to the `select` function itself +changes. To optimize, memoize the function so its reference stays stable across calls. + +#### Parameters + +##### data + +[`InfiniteData`](InfiniteData.md) + +#### Returns + +`TData` + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`select`](QueryObserverOptions.md#select) + +*** + +### staleTime? + +```ts +optional staleTime: StaleTimeFunction, TQueryKey>; +``` + +Defined in: [packages/query-core/src/types.ts:407](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L407) + +The time in milliseconds after data is considered stale. +If set to `Infinity`, the data will never be considered stale. +If set to `'static'`, the data will never be considered stale. +If set to a function, the function will be executed with the query to compute a `staleTime`. + +Defaults to `0`. + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`staleTime`](QueryObserverOptions.md#staletime) + +*** + +### structuralSharing? + +```ts +optional structuralSharing: boolean | (oldData, newData) => unknown; +``` + +Defined in: [packages/query-core/src/types.ts:330](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L330) + +Set this to `false` to disable structural sharing between query results. +Set this to a function which accepts the old and new data and returns resolved data of the same type to implement custom structural sharing logic. + +Defaults to `true`. + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`structuralSharing`](QueryObserverOptions.md#structuralsharing) + +*** + +### suspense? + +```ts +optional suspense: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:507](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L507) + +If set to `true`, the query will suspend when `status === 'pending'` +and throw errors when `status === 'error'`. + +Defaults to `false`. + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`suspense`](QueryObserverOptions.md#suspense) + +*** + +### throwOnError? + +```ts +optional throwOnError: ThrowOnError, TQueryKey>; +``` + +Defined in: [packages/query-core/src/types.ts:493](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L493) + +Whether errors should be thrown instead of setting the `error` property. +If set to `true` or `suspense` is `true`, all errors will be thrown to the error boundary. +If set to `false` and `suspense` is `false`, errors are returned as state. +If set to a function, it will be passed the error and the query, and it should return a boolean indicating whether to show the error in an error boundary (`true`) or return the error as state (`false`). + +Defaults to `false`. + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`throwOnError`](QueryObserverOptions.md#throwonerror) diff --git a/docs/framework/react/reference/interfaces/InfiniteQueryObserverPendingResult.md b/docs/framework/react/reference/interfaces/InfiniteQueryObserverPendingResult.md new file mode 100644 index 00000000000..a09301ab6c4 --- /dev/null +++ b/docs/framework/react/reference/interfaces/InfiniteQueryObserverPendingResult.md @@ -0,0 +1,600 @@ +--- +id: InfiniteQueryObserverPendingResult +title: InfiniteQueryObserverPendingResult +--- + +Defined in: [packages/query-core/src/types.ts:1043](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1043) + +## Extends + +- [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md)\<`TData`, `TError`\> + +## Type Parameters + +### TData + +`TData` = `unknown` + +### TError + +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) + +## Properties + +### data + +```ts +data: undefined; +``` + +Defined in: [packages/query-core/src/types.ts:1047](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1047) + +The last successfully resolved data for the query. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`data`](InfiniteQueryObserverBaseResult.md#data) + +*** + +### dataUpdatedAt + +```ts +dataUpdatedAt: number; +``` + +Defined in: [packages/query-core/src/types.ts:775](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L775) + +The timestamp for when the query most recently returned the `status` as `"success"`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`dataUpdatedAt`](InfiniteQueryObserverBaseResult.md#dataupdatedat) + +*** + +### error + +```ts +error: null; +``` + +Defined in: [packages/query-core/src/types.ts:1048](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1048) + +The error object for the query, if an error was thrown. +- Defaults to `null`. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`error`](InfiniteQueryObserverBaseResult.md#error) + +*** + +### errorUpdateCount + +```ts +errorUpdateCount: number; +``` + +Defined in: [packages/query-core/src/types.ts:799](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L799) + +The sum of all errors. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`errorUpdateCount`](InfiniteQueryObserverBaseResult.md#errorupdatecount) + +*** + +### errorUpdatedAt + +```ts +errorUpdatedAt: number; +``` + +Defined in: [packages/query-core/src/types.ts:784](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L784) + +The timestamp for when the query most recently returned the `status` as `"error"`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`errorUpdatedAt`](InfiniteQueryObserverBaseResult.md#errorupdatedat) + +*** + +### failureCount + +```ts +failureCount: number; +``` + +Defined in: [packages/query-core/src/types.ts:790](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L790) + +The failure count for the query. +- Incremented every time the query fails. +- Reset to `0` when the query succeeds. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`failureCount`](InfiniteQueryObserverBaseResult.md#failurecount) + +*** + +### failureReason + +```ts +failureReason: TError | null; +``` + +Defined in: [packages/query-core/src/types.ts:795](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L795) + +The failure reason for the query retry. +- Reset to `null` when the query succeeds. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`failureReason`](InfiniteQueryObserverBaseResult.md#failurereason) + +*** + +### fetchNextPage() + +```ts +fetchNextPage: (options?) => Promise>; +``` + +Defined in: [packages/query-core/src/types.ts:1008](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1008) + +This function allows you to fetch the next "page" of results. + +#### Parameters + +##### options? + +[`FetchNextPageOptions`](FetchNextPageOptions.md) + +#### Returns + +`Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`fetchNextPage`](InfiniteQueryObserverBaseResult.md#fetchnextpage) + +*** + +### fetchPreviousPage() + +```ts +fetchPreviousPage: (options?) => Promise>; +``` + +Defined in: [packages/query-core/src/types.ts:1014](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1014) + +This function allows you to fetch the previous "page" of results. + +#### Parameters + +##### options? + +[`FetchPreviousPageOptions`](FetchPreviousPageOptions.md) + +#### Returns + +`Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`fetchPreviousPage`](InfiniteQueryObserverBaseResult.md#fetchpreviouspage) + +*** + +### fetchStatus + +```ts +fetchStatus: FetchStatus; +``` + +Defined in: [packages/query-core/src/types.ts:889](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L889) + +The fetch status of the query. +- `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. +- `paused`: The query wanted to fetch, but has been `paused`. +- `idle`: The query is not fetching. +- See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`fetchStatus`](InfiniteQueryObserverBaseResult.md#fetchstatus) + +*** + +### hasNextPage + +```ts +hasNextPage: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1020](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1020) + +Will be `true` if there is a next page to be fetched (known via the `getNextPageParam` option). + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`hasNextPage`](InfiniteQueryObserverBaseResult.md#hasnextpage) + +*** + +### hasPreviousPage + +```ts +hasPreviousPage: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1024](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1024) + +Will be `true` if there is a previous page to be fetched (known via the `getPreviousPageParam` option). + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`hasPreviousPage`](InfiniteQueryObserverBaseResult.md#haspreviouspage) + +*** + +### isEnabled + +```ts +isEnabled: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:867](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L867) + +`true` if this observer is enabled, `false` otherwise. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isEnabled`](InfiniteQueryObserverBaseResult.md#isenabled) + +*** + +### isError + +```ts +isError: false; +``` + +Defined in: [packages/query-core/src/types.ts:1049](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1049) + +A derived boolean from the `status` variable, provided for convenience. +- `true` if the query attempt resulted in an error. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isError`](InfiniteQueryObserverBaseResult.md#iserror) + +*** + +### isFetched + +```ts +isFetched: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:808](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L808) + +Will be `true` if the query has been fetched. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetched`](InfiniteQueryObserverBaseResult.md#isfetched) + +*** + +### isFetchedAfterMount + +```ts +isFetchedAfterMount: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:813](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L813) + +Will be `true` if the query has been fetched after the component mounted. +- This property can be used to not show any previously cached data. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchedAfterMount`](InfiniteQueryObserverBaseResult.md#isfetchedaftermount) + +*** + +### isFetching + +```ts +isFetching: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:818](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L818) + +A derived boolean from the `fetchStatus` variable, provided for convenience. +- `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetching`](InfiniteQueryObserverBaseResult.md#isfetching) + +*** + +### isFetchingNextPage + +```ts +isFetchingNextPage: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1032](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1032) + +Will be `true` while fetching the next page with `fetchNextPage`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchingNextPage`](InfiniteQueryObserverBaseResult.md#isfetchingnextpage) + +*** + +### isFetchingPreviousPage + +```ts +isFetchingPreviousPage: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1040](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1040) + +Will be `true` while fetching the previous page with `fetchPreviousPage`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchingPreviousPage`](InfiniteQueryObserverBaseResult.md#isfetchingpreviouspage) + +*** + +### isFetchNextPageError + +```ts +isFetchNextPageError: false; +``` + +Defined in: [packages/query-core/src/types.ts:1053](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1053) + +Will be `true` if the query failed while fetching the next page. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchNextPageError`](InfiniteQueryObserverBaseResult.md#isfetchnextpageerror) + +*** + +### isFetchPreviousPageError + +```ts +isFetchPreviousPageError: false; +``` + +Defined in: [packages/query-core/src/types.ts:1054](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1054) + +Will be `true` if the query failed while fetching the previous page. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchPreviousPageError`](InfiniteQueryObserverBaseResult.md#isfetchpreviouspageerror) + +*** + +### ~~isInitialLoading~~ + +```ts +isInitialLoading: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:836](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L836) + +#### Deprecated + +`isInitialLoading` is being deprecated in favor of `isLoading` +and will be removed in the next major version. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isInitialLoading`](InfiniteQueryObserverBaseResult.md#isinitialloading) + +*** + +### isLoading + +```ts +isLoading: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:823](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L823) + +Is `true` whenever the first fetch for a query is in-flight. +- Is the same as `isFetching && isPending`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoading`](InfiniteQueryObserverBaseResult.md#isloading) + +*** + +### isLoadingError + +```ts +isLoadingError: false; +``` + +Defined in: [packages/query-core/src/types.ts:1051](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1051) + +Will be `true` if the query failed while fetching for the first time. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoadingError`](InfiniteQueryObserverBaseResult.md#isloadingerror) + +*** + +### isPaused + +```ts +isPaused: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:841](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L841) + +A derived boolean from the `fetchStatus` variable, provided for convenience. +- The query wanted to fetch, but has been `paused`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPaused`](InfiniteQueryObserverBaseResult.md#ispaused) + +*** + +### isPending + +```ts +isPending: true; +``` + +Defined in: [packages/query-core/src/types.ts:1050](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1050) + +Will be `pending` if there's no cached data and no query attempt was finished yet. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPending`](InfiniteQueryObserverBaseResult.md#ispending) + +*** + +### isPlaceholderData + +```ts +isPlaceholderData: false; +``` + +Defined in: [packages/query-core/src/types.ts:1056](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1056) + +Will be `true` if the data shown is the placeholder data. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPlaceholderData`](InfiniteQueryObserverBaseResult.md#isplaceholderdata) + +*** + +### isRefetchError + +```ts +isRefetchError: false; +``` + +Defined in: [packages/query-core/src/types.ts:1052](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1052) + +Will be `true` if the query failed while refetching. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isRefetchError`](InfiniteQueryObserverBaseResult.md#isrefetcherror) + +*** + +### isRefetching + +```ts +isRefetching: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:854](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L854) + +Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. +- Is the same as `isFetching && !isPending`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isRefetching`](InfiniteQueryObserverBaseResult.md#isrefetching) + +*** + +### isStale + +```ts +isStale: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:858](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L858) + +Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isStale`](InfiniteQueryObserverBaseResult.md#isstale) + +*** + +### isSuccess + +```ts +isSuccess: false; +``` + +Defined in: [packages/query-core/src/types.ts:1055](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1055) + +A derived boolean from the `status` variable, provided for convenience. +- `true` if the query has received a response with no errors and is ready to display its data. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isSuccess`](InfiniteQueryObserverBaseResult.md#issuccess) + +*** + +### refetch() + +```ts +refetch: (options?) => Promise>; +``` + +Defined in: [packages/query-core/src/types.ts:871](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L871) + +A function to manually refetch the query. + +#### Parameters + +##### options? + +[`RefetchOptions`](RefetchOptions.md) + +#### Returns + +`Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`refetch`](InfiniteQueryObserverBaseResult.md#refetch) + +*** + +### status + +```ts +status: "pending"; +``` + +Defined in: [packages/query-core/src/types.ts:1057](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1057) + +The status of the query. +- Will be: + - `pending` if there's no cached data and no query attempt was finished yet. + - `error` if the query attempt resulted in an error. + - `success` if the query has received a response with no errors and is ready to display its data. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`status`](InfiniteQueryObserverBaseResult.md#status) diff --git a/docs/framework/react/reference/interfaces/InfiniteQueryObserverPlaceholderResult.md b/docs/framework/react/reference/interfaces/InfiniteQueryObserverPlaceholderResult.md new file mode 100644 index 00000000000..58193a987d1 --- /dev/null +++ b/docs/framework/react/reference/interfaces/InfiniteQueryObserverPlaceholderResult.md @@ -0,0 +1,600 @@ +--- +id: InfiniteQueryObserverPlaceholderResult +title: InfiniteQueryObserverPlaceholderResult +--- + +Defined in: [packages/query-core/src/types.ts:1130](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1130) + +## Extends + +- [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md)\<`TData`, `TError`\> + +## Type Parameters + +### TData + +`TData` = `unknown` + +### TError + +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) + +## Properties + +### data + +```ts +data: TData; +``` + +Defined in: [packages/query-core/src/types.ts:1134](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1134) + +The last successfully resolved data for the query. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`data`](InfiniteQueryObserverBaseResult.md#data) + +*** + +### dataUpdatedAt + +```ts +dataUpdatedAt: number; +``` + +Defined in: [packages/query-core/src/types.ts:775](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L775) + +The timestamp for when the query most recently returned the `status` as `"success"`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`dataUpdatedAt`](InfiniteQueryObserverBaseResult.md#dataupdatedat) + +*** + +### error + +```ts +error: null; +``` + +Defined in: [packages/query-core/src/types.ts:1136](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1136) + +The error object for the query, if an error was thrown. +- Defaults to `null`. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`error`](InfiniteQueryObserverBaseResult.md#error) + +*** + +### errorUpdateCount + +```ts +errorUpdateCount: number; +``` + +Defined in: [packages/query-core/src/types.ts:799](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L799) + +The sum of all errors. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`errorUpdateCount`](InfiniteQueryObserverBaseResult.md#errorupdatecount) + +*** + +### errorUpdatedAt + +```ts +errorUpdatedAt: number; +``` + +Defined in: [packages/query-core/src/types.ts:784](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L784) + +The timestamp for when the query most recently returned the `status` as `"error"`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`errorUpdatedAt`](InfiniteQueryObserverBaseResult.md#errorupdatedat) + +*** + +### failureCount + +```ts +failureCount: number; +``` + +Defined in: [packages/query-core/src/types.ts:790](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L790) + +The failure count for the query. +- Incremented every time the query fails. +- Reset to `0` when the query succeeds. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`failureCount`](InfiniteQueryObserverBaseResult.md#failurecount) + +*** + +### failureReason + +```ts +failureReason: TError | null; +``` + +Defined in: [packages/query-core/src/types.ts:795](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L795) + +The failure reason for the query retry. +- Reset to `null` when the query succeeds. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`failureReason`](InfiniteQueryObserverBaseResult.md#failurereason) + +*** + +### fetchNextPage() + +```ts +fetchNextPage: (options?) => Promise>; +``` + +Defined in: [packages/query-core/src/types.ts:1008](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1008) + +This function allows you to fetch the next "page" of results. + +#### Parameters + +##### options? + +[`FetchNextPageOptions`](FetchNextPageOptions.md) + +#### Returns + +`Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`fetchNextPage`](InfiniteQueryObserverBaseResult.md#fetchnextpage) + +*** + +### fetchPreviousPage() + +```ts +fetchPreviousPage: (options?) => Promise>; +``` + +Defined in: [packages/query-core/src/types.ts:1014](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1014) + +This function allows you to fetch the previous "page" of results. + +#### Parameters + +##### options? + +[`FetchPreviousPageOptions`](FetchPreviousPageOptions.md) + +#### Returns + +`Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`fetchPreviousPage`](InfiniteQueryObserverBaseResult.md#fetchpreviouspage) + +*** + +### fetchStatus + +```ts +fetchStatus: FetchStatus; +``` + +Defined in: [packages/query-core/src/types.ts:889](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L889) + +The fetch status of the query. +- `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. +- `paused`: The query wanted to fetch, but has been `paused`. +- `idle`: The query is not fetching. +- See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`fetchStatus`](InfiniteQueryObserverBaseResult.md#fetchstatus) + +*** + +### hasNextPage + +```ts +hasNextPage: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1020](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1020) + +Will be `true` if there is a next page to be fetched (known via the `getNextPageParam` option). + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`hasNextPage`](InfiniteQueryObserverBaseResult.md#hasnextpage) + +*** + +### hasPreviousPage + +```ts +hasPreviousPage: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1024](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1024) + +Will be `true` if there is a previous page to be fetched (known via the `getPreviousPageParam` option). + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`hasPreviousPage`](InfiniteQueryObserverBaseResult.md#haspreviouspage) + +*** + +### isEnabled + +```ts +isEnabled: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:867](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L867) + +`true` if this observer is enabled, `false` otherwise. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isEnabled`](InfiniteQueryObserverBaseResult.md#isenabled) + +*** + +### isError + +```ts +isError: false; +``` + +Defined in: [packages/query-core/src/types.ts:1135](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1135) + +A derived boolean from the `status` variable, provided for convenience. +- `true` if the query attempt resulted in an error. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isError`](InfiniteQueryObserverBaseResult.md#iserror) + +*** + +### isFetched + +```ts +isFetched: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:808](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L808) + +Will be `true` if the query has been fetched. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetched`](InfiniteQueryObserverBaseResult.md#isfetched) + +*** + +### isFetchedAfterMount + +```ts +isFetchedAfterMount: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:813](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L813) + +Will be `true` if the query has been fetched after the component mounted. +- This property can be used to not show any previously cached data. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchedAfterMount`](InfiniteQueryObserverBaseResult.md#isfetchedaftermount) + +*** + +### isFetching + +```ts +isFetching: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:818](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L818) + +A derived boolean from the `fetchStatus` variable, provided for convenience. +- `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetching`](InfiniteQueryObserverBaseResult.md#isfetching) + +*** + +### isFetchingNextPage + +```ts +isFetchingNextPage: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1032](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1032) + +Will be `true` while fetching the next page with `fetchNextPage`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchingNextPage`](InfiniteQueryObserverBaseResult.md#isfetchingnextpage) + +*** + +### isFetchingPreviousPage + +```ts +isFetchingPreviousPage: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1040](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1040) + +Will be `true` while fetching the previous page with `fetchPreviousPage`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchingPreviousPage`](InfiniteQueryObserverBaseResult.md#isfetchingpreviouspage) + +*** + +### isFetchNextPageError + +```ts +isFetchNextPageError: false; +``` + +Defined in: [packages/query-core/src/types.ts:1143](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1143) + +Will be `true` if the query failed while fetching the next page. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchNextPageError`](InfiniteQueryObserverBaseResult.md#isfetchnextpageerror) + +*** + +### isFetchPreviousPageError + +```ts +isFetchPreviousPageError: false; +``` + +Defined in: [packages/query-core/src/types.ts:1144](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1144) + +Will be `true` if the query failed while fetching the previous page. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchPreviousPageError`](InfiniteQueryObserverBaseResult.md#isfetchpreviouspageerror) + +*** + +### ~~isInitialLoading~~ + +```ts +isInitialLoading: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:836](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L836) + +#### Deprecated + +`isInitialLoading` is being deprecated in favor of `isLoading` +and will be removed in the next major version. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isInitialLoading`](InfiniteQueryObserverBaseResult.md#isinitialloading) + +*** + +### isLoading + +```ts +isLoading: false; +``` + +Defined in: [packages/query-core/src/types.ts:1138](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1138) + +Is `true` whenever the first fetch for a query is in-flight. +- Is the same as `isFetching && isPending`. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoading`](InfiniteQueryObserverBaseResult.md#isloading) + +*** + +### isLoadingError + +```ts +isLoadingError: false; +``` + +Defined in: [packages/query-core/src/types.ts:1139](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1139) + +Will be `true` if the query failed while fetching for the first time. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoadingError`](InfiniteQueryObserverBaseResult.md#isloadingerror) + +*** + +### isPaused + +```ts +isPaused: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:841](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L841) + +A derived boolean from the `fetchStatus` variable, provided for convenience. +- The query wanted to fetch, but has been `paused`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPaused`](InfiniteQueryObserverBaseResult.md#ispaused) + +*** + +### isPending + +```ts +isPending: false; +``` + +Defined in: [packages/query-core/src/types.ts:1137](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1137) + +Will be `pending` if there's no cached data and no query attempt was finished yet. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPending`](InfiniteQueryObserverBaseResult.md#ispending) + +*** + +### isPlaceholderData + +```ts +isPlaceholderData: true; +``` + +Defined in: [packages/query-core/src/types.ts:1142](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1142) + +Will be `true` if the data shown is the placeholder data. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPlaceholderData`](InfiniteQueryObserverBaseResult.md#isplaceholderdata) + +*** + +### isRefetchError + +```ts +isRefetchError: false; +``` + +Defined in: [packages/query-core/src/types.ts:1140](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1140) + +Will be `true` if the query failed while refetching. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isRefetchError`](InfiniteQueryObserverBaseResult.md#isrefetcherror) + +*** + +### isRefetching + +```ts +isRefetching: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:854](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L854) + +Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. +- Is the same as `isFetching && !isPending`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isRefetching`](InfiniteQueryObserverBaseResult.md#isrefetching) + +*** + +### isStale + +```ts +isStale: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:858](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L858) + +Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isStale`](InfiniteQueryObserverBaseResult.md#isstale) + +*** + +### isSuccess + +```ts +isSuccess: true; +``` + +Defined in: [packages/query-core/src/types.ts:1141](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1141) + +A derived boolean from the `status` variable, provided for convenience. +- `true` if the query has received a response with no errors and is ready to display its data. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isSuccess`](InfiniteQueryObserverBaseResult.md#issuccess) + +*** + +### refetch() + +```ts +refetch: (options?) => Promise>; +``` + +Defined in: [packages/query-core/src/types.ts:871](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L871) + +A function to manually refetch the query. + +#### Parameters + +##### options? + +[`RefetchOptions`](RefetchOptions.md) + +#### Returns + +`Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`refetch`](InfiniteQueryObserverBaseResult.md#refetch) + +*** + +### status + +```ts +status: "success"; +``` + +Defined in: [packages/query-core/src/types.ts:1145](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1145) + +The status of the query. +- Will be: + - `pending` if there's no cached data and no query attempt was finished yet. + - `error` if the query attempt resulted in an error. + - `success` if the query has received a response with no errors and is ready to display its data. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`status`](InfiniteQueryObserverBaseResult.md#status) diff --git a/docs/framework/react/reference/interfaces/InfiniteQueryObserverRefetchErrorResult.md b/docs/framework/react/reference/interfaces/InfiniteQueryObserverRefetchErrorResult.md new file mode 100644 index 00000000000..4ce469bceed --- /dev/null +++ b/docs/framework/react/reference/interfaces/InfiniteQueryObserverRefetchErrorResult.md @@ -0,0 +1,600 @@ +--- +id: InfiniteQueryObserverRefetchErrorResult +title: InfiniteQueryObserverRefetchErrorResult +--- + +Defined in: [packages/query-core/src/types.ts:1096](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1096) + +## Extends + +- [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md)\<`TData`, `TError`\> + +## Type Parameters + +### TData + +`TData` = `unknown` + +### TError + +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) + +## Properties + +### data + +```ts +data: TData; +``` + +Defined in: [packages/query-core/src/types.ts:1100](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1100) + +The last successfully resolved data for the query. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`data`](InfiniteQueryObserverBaseResult.md#data) + +*** + +### dataUpdatedAt + +```ts +dataUpdatedAt: number; +``` + +Defined in: [packages/query-core/src/types.ts:775](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L775) + +The timestamp for when the query most recently returned the `status` as `"success"`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`dataUpdatedAt`](InfiniteQueryObserverBaseResult.md#dataupdatedat) + +*** + +### error + +```ts +error: TError; +``` + +Defined in: [packages/query-core/src/types.ts:1101](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1101) + +The error object for the query, if an error was thrown. +- Defaults to `null`. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`error`](InfiniteQueryObserverBaseResult.md#error) + +*** + +### errorUpdateCount + +```ts +errorUpdateCount: number; +``` + +Defined in: [packages/query-core/src/types.ts:799](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L799) + +The sum of all errors. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`errorUpdateCount`](InfiniteQueryObserverBaseResult.md#errorupdatecount) + +*** + +### errorUpdatedAt + +```ts +errorUpdatedAt: number; +``` + +Defined in: [packages/query-core/src/types.ts:784](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L784) + +The timestamp for when the query most recently returned the `status` as `"error"`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`errorUpdatedAt`](InfiniteQueryObserverBaseResult.md#errorupdatedat) + +*** + +### failureCount + +```ts +failureCount: number; +``` + +Defined in: [packages/query-core/src/types.ts:790](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L790) + +The failure count for the query. +- Incremented every time the query fails. +- Reset to `0` when the query succeeds. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`failureCount`](InfiniteQueryObserverBaseResult.md#failurecount) + +*** + +### failureReason + +```ts +failureReason: TError | null; +``` + +Defined in: [packages/query-core/src/types.ts:795](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L795) + +The failure reason for the query retry. +- Reset to `null` when the query succeeds. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`failureReason`](InfiniteQueryObserverBaseResult.md#failurereason) + +*** + +### fetchNextPage() + +```ts +fetchNextPage: (options?) => Promise>; +``` + +Defined in: [packages/query-core/src/types.ts:1008](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1008) + +This function allows you to fetch the next "page" of results. + +#### Parameters + +##### options? + +[`FetchNextPageOptions`](FetchNextPageOptions.md) + +#### Returns + +`Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`fetchNextPage`](InfiniteQueryObserverBaseResult.md#fetchnextpage) + +*** + +### fetchPreviousPage() + +```ts +fetchPreviousPage: (options?) => Promise>; +``` + +Defined in: [packages/query-core/src/types.ts:1014](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1014) + +This function allows you to fetch the previous "page" of results. + +#### Parameters + +##### options? + +[`FetchPreviousPageOptions`](FetchPreviousPageOptions.md) + +#### Returns + +`Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`fetchPreviousPage`](InfiniteQueryObserverBaseResult.md#fetchpreviouspage) + +*** + +### fetchStatus + +```ts +fetchStatus: FetchStatus; +``` + +Defined in: [packages/query-core/src/types.ts:889](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L889) + +The fetch status of the query. +- `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. +- `paused`: The query wanted to fetch, but has been `paused`. +- `idle`: The query is not fetching. +- See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`fetchStatus`](InfiniteQueryObserverBaseResult.md#fetchstatus) + +*** + +### hasNextPage + +```ts +hasNextPage: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1020](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1020) + +Will be `true` if there is a next page to be fetched (known via the `getNextPageParam` option). + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`hasNextPage`](InfiniteQueryObserverBaseResult.md#hasnextpage) + +*** + +### hasPreviousPage + +```ts +hasPreviousPage: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1024](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1024) + +Will be `true` if there is a previous page to be fetched (known via the `getPreviousPageParam` option). + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`hasPreviousPage`](InfiniteQueryObserverBaseResult.md#haspreviouspage) + +*** + +### isEnabled + +```ts +isEnabled: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:867](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L867) + +`true` if this observer is enabled, `false` otherwise. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isEnabled`](InfiniteQueryObserverBaseResult.md#isenabled) + +*** + +### isError + +```ts +isError: true; +``` + +Defined in: [packages/query-core/src/types.ts:1102](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1102) + +A derived boolean from the `status` variable, provided for convenience. +- `true` if the query attempt resulted in an error. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isError`](InfiniteQueryObserverBaseResult.md#iserror) + +*** + +### isFetched + +```ts +isFetched: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:808](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L808) + +Will be `true` if the query has been fetched. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetched`](InfiniteQueryObserverBaseResult.md#isfetched) + +*** + +### isFetchedAfterMount + +```ts +isFetchedAfterMount: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:813](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L813) + +Will be `true` if the query has been fetched after the component mounted. +- This property can be used to not show any previously cached data. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchedAfterMount`](InfiniteQueryObserverBaseResult.md#isfetchedaftermount) + +*** + +### isFetching + +```ts +isFetching: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:818](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L818) + +A derived boolean from the `fetchStatus` variable, provided for convenience. +- `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetching`](InfiniteQueryObserverBaseResult.md#isfetching) + +*** + +### isFetchingNextPage + +```ts +isFetchingNextPage: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1032](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1032) + +Will be `true` while fetching the next page with `fetchNextPage`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchingNextPage`](InfiniteQueryObserverBaseResult.md#isfetchingnextpage) + +*** + +### isFetchingPreviousPage + +```ts +isFetchingPreviousPage: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1040](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1040) + +Will be `true` while fetching the previous page with `fetchPreviousPage`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchingPreviousPage`](InfiniteQueryObserverBaseResult.md#isfetchingpreviouspage) + +*** + +### isFetchNextPageError + +```ts +isFetchNextPageError: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1028](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1028) + +Will be `true` if the query failed while fetching the next page. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchNextPageError`](InfiniteQueryObserverBaseResult.md#isfetchnextpageerror) + +*** + +### isFetchPreviousPageError + +```ts +isFetchPreviousPageError: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1036](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1036) + +Will be `true` if the query failed while fetching the previous page. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchPreviousPageError`](InfiniteQueryObserverBaseResult.md#isfetchpreviouspageerror) + +*** + +### ~~isInitialLoading~~ + +```ts +isInitialLoading: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:836](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L836) + +#### Deprecated + +`isInitialLoading` is being deprecated in favor of `isLoading` +and will be removed in the next major version. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isInitialLoading`](InfiniteQueryObserverBaseResult.md#isinitialloading) + +*** + +### isLoading + +```ts +isLoading: false; +``` + +Defined in: [packages/query-core/src/types.ts:1104](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1104) + +Is `true` whenever the first fetch for a query is in-flight. +- Is the same as `isFetching && isPending`. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoading`](InfiniteQueryObserverBaseResult.md#isloading) + +*** + +### isLoadingError + +```ts +isLoadingError: false; +``` + +Defined in: [packages/query-core/src/types.ts:1105](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1105) + +Will be `true` if the query failed while fetching for the first time. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoadingError`](InfiniteQueryObserverBaseResult.md#isloadingerror) + +*** + +### isPaused + +```ts +isPaused: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:841](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L841) + +A derived boolean from the `fetchStatus` variable, provided for convenience. +- The query wanted to fetch, but has been `paused`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPaused`](InfiniteQueryObserverBaseResult.md#ispaused) + +*** + +### isPending + +```ts +isPending: false; +``` + +Defined in: [packages/query-core/src/types.ts:1103](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1103) + +Will be `pending` if there's no cached data and no query attempt was finished yet. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPending`](InfiniteQueryObserverBaseResult.md#ispending) + +*** + +### isPlaceholderData + +```ts +isPlaceholderData: false; +``` + +Defined in: [packages/query-core/src/types.ts:1108](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1108) + +Will be `true` if the data shown is the placeholder data. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPlaceholderData`](InfiniteQueryObserverBaseResult.md#isplaceholderdata) + +*** + +### isRefetchError + +```ts +isRefetchError: true; +``` + +Defined in: [packages/query-core/src/types.ts:1106](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1106) + +Will be `true` if the query failed while refetching. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isRefetchError`](InfiniteQueryObserverBaseResult.md#isrefetcherror) + +*** + +### isRefetching + +```ts +isRefetching: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:854](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L854) + +Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. +- Is the same as `isFetching && !isPending`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isRefetching`](InfiniteQueryObserverBaseResult.md#isrefetching) + +*** + +### isStale + +```ts +isStale: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:858](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L858) + +Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isStale`](InfiniteQueryObserverBaseResult.md#isstale) + +*** + +### isSuccess + +```ts +isSuccess: false; +``` + +Defined in: [packages/query-core/src/types.ts:1107](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1107) + +A derived boolean from the `status` variable, provided for convenience. +- `true` if the query has received a response with no errors and is ready to display its data. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isSuccess`](InfiniteQueryObserverBaseResult.md#issuccess) + +*** + +### refetch() + +```ts +refetch: (options?) => Promise>; +``` + +Defined in: [packages/query-core/src/types.ts:871](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L871) + +A function to manually refetch the query. + +#### Parameters + +##### options? + +[`RefetchOptions`](RefetchOptions.md) + +#### Returns + +`Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`refetch`](InfiniteQueryObserverBaseResult.md#refetch) + +*** + +### status + +```ts +status: "error"; +``` + +Defined in: [packages/query-core/src/types.ts:1109](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1109) + +The status of the query. +- Will be: + - `pending` if there's no cached data and no query attempt was finished yet. + - `error` if the query attempt resulted in an error. + - `success` if the query has received a response with no errors and is ready to display its data. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`status`](InfiniteQueryObserverBaseResult.md#status) diff --git a/docs/framework/react/reference/interfaces/InfiniteQueryObserverSuccessResult.md b/docs/framework/react/reference/interfaces/InfiniteQueryObserverSuccessResult.md new file mode 100644 index 00000000000..131f6d01ae7 --- /dev/null +++ b/docs/framework/react/reference/interfaces/InfiniteQueryObserverSuccessResult.md @@ -0,0 +1,600 @@ +--- +id: InfiniteQueryObserverSuccessResult +title: InfiniteQueryObserverSuccessResult +--- + +Defined in: [packages/query-core/src/types.ts:1112](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1112) + +## Extends + +- [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md)\<`TData`, `TError`\> + +## Type Parameters + +### TData + +`TData` = `unknown` + +### TError + +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) + +## Properties + +### data + +```ts +data: TData; +``` + +Defined in: [packages/query-core/src/types.ts:1116](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1116) + +The last successfully resolved data for the query. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`data`](InfiniteQueryObserverBaseResult.md#data) + +*** + +### dataUpdatedAt + +```ts +dataUpdatedAt: number; +``` + +Defined in: [packages/query-core/src/types.ts:775](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L775) + +The timestamp for when the query most recently returned the `status` as `"success"`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`dataUpdatedAt`](InfiniteQueryObserverBaseResult.md#dataupdatedat) + +*** + +### error + +```ts +error: null; +``` + +Defined in: [packages/query-core/src/types.ts:1117](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1117) + +The error object for the query, if an error was thrown. +- Defaults to `null`. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`error`](InfiniteQueryObserverBaseResult.md#error) + +*** + +### errorUpdateCount + +```ts +errorUpdateCount: number; +``` + +Defined in: [packages/query-core/src/types.ts:799](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L799) + +The sum of all errors. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`errorUpdateCount`](InfiniteQueryObserverBaseResult.md#errorupdatecount) + +*** + +### errorUpdatedAt + +```ts +errorUpdatedAt: number; +``` + +Defined in: [packages/query-core/src/types.ts:784](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L784) + +The timestamp for when the query most recently returned the `status` as `"error"`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`errorUpdatedAt`](InfiniteQueryObserverBaseResult.md#errorupdatedat) + +*** + +### failureCount + +```ts +failureCount: number; +``` + +Defined in: [packages/query-core/src/types.ts:790](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L790) + +The failure count for the query. +- Incremented every time the query fails. +- Reset to `0` when the query succeeds. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`failureCount`](InfiniteQueryObserverBaseResult.md#failurecount) + +*** + +### failureReason + +```ts +failureReason: TError | null; +``` + +Defined in: [packages/query-core/src/types.ts:795](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L795) + +The failure reason for the query retry. +- Reset to `null` when the query succeeds. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`failureReason`](InfiniteQueryObserverBaseResult.md#failurereason) + +*** + +### fetchNextPage() + +```ts +fetchNextPage: (options?) => Promise>; +``` + +Defined in: [packages/query-core/src/types.ts:1008](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1008) + +This function allows you to fetch the next "page" of results. + +#### Parameters + +##### options? + +[`FetchNextPageOptions`](FetchNextPageOptions.md) + +#### Returns + +`Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`fetchNextPage`](InfiniteQueryObserverBaseResult.md#fetchnextpage) + +*** + +### fetchPreviousPage() + +```ts +fetchPreviousPage: (options?) => Promise>; +``` + +Defined in: [packages/query-core/src/types.ts:1014](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1014) + +This function allows you to fetch the previous "page" of results. + +#### Parameters + +##### options? + +[`FetchPreviousPageOptions`](FetchPreviousPageOptions.md) + +#### Returns + +`Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`fetchPreviousPage`](InfiniteQueryObserverBaseResult.md#fetchpreviouspage) + +*** + +### fetchStatus + +```ts +fetchStatus: FetchStatus; +``` + +Defined in: [packages/query-core/src/types.ts:889](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L889) + +The fetch status of the query. +- `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. +- `paused`: The query wanted to fetch, but has been `paused`. +- `idle`: The query is not fetching. +- See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`fetchStatus`](InfiniteQueryObserverBaseResult.md#fetchstatus) + +*** + +### hasNextPage + +```ts +hasNextPage: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1020](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1020) + +Will be `true` if there is a next page to be fetched (known via the `getNextPageParam` option). + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`hasNextPage`](InfiniteQueryObserverBaseResult.md#hasnextpage) + +*** + +### hasPreviousPage + +```ts +hasPreviousPage: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1024](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1024) + +Will be `true` if there is a previous page to be fetched (known via the `getPreviousPageParam` option). + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`hasPreviousPage`](InfiniteQueryObserverBaseResult.md#haspreviouspage) + +*** + +### isEnabled + +```ts +isEnabled: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:867](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L867) + +`true` if this observer is enabled, `false` otherwise. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isEnabled`](InfiniteQueryObserverBaseResult.md#isenabled) + +*** + +### isError + +```ts +isError: false; +``` + +Defined in: [packages/query-core/src/types.ts:1118](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1118) + +A derived boolean from the `status` variable, provided for convenience. +- `true` if the query attempt resulted in an error. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isError`](InfiniteQueryObserverBaseResult.md#iserror) + +*** + +### isFetched + +```ts +isFetched: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:808](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L808) + +Will be `true` if the query has been fetched. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetched`](InfiniteQueryObserverBaseResult.md#isfetched) + +*** + +### isFetchedAfterMount + +```ts +isFetchedAfterMount: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:813](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L813) + +Will be `true` if the query has been fetched after the component mounted. +- This property can be used to not show any previously cached data. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchedAfterMount`](InfiniteQueryObserverBaseResult.md#isfetchedaftermount) + +*** + +### isFetching + +```ts +isFetching: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:818](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L818) + +A derived boolean from the `fetchStatus` variable, provided for convenience. +- `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetching`](InfiniteQueryObserverBaseResult.md#isfetching) + +*** + +### isFetchingNextPage + +```ts +isFetchingNextPage: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1032](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1032) + +Will be `true` while fetching the next page with `fetchNextPage`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchingNextPage`](InfiniteQueryObserverBaseResult.md#isfetchingnextpage) + +*** + +### isFetchingPreviousPage + +```ts +isFetchingPreviousPage: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1040](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1040) + +Will be `true` while fetching the previous page with `fetchPreviousPage`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchingPreviousPage`](InfiniteQueryObserverBaseResult.md#isfetchingpreviouspage) + +*** + +### isFetchNextPageError + +```ts +isFetchNextPageError: false; +``` + +Defined in: [packages/query-core/src/types.ts:1123](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1123) + +Will be `true` if the query failed while fetching the next page. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchNextPageError`](InfiniteQueryObserverBaseResult.md#isfetchnextpageerror) + +*** + +### isFetchPreviousPageError + +```ts +isFetchPreviousPageError: false; +``` + +Defined in: [packages/query-core/src/types.ts:1124](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1124) + +Will be `true` if the query failed while fetching the previous page. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchPreviousPageError`](InfiniteQueryObserverBaseResult.md#isfetchpreviouspageerror) + +*** + +### ~~isInitialLoading~~ + +```ts +isInitialLoading: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:836](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L836) + +#### Deprecated + +`isInitialLoading` is being deprecated in favor of `isLoading` +and will be removed in the next major version. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isInitialLoading`](InfiniteQueryObserverBaseResult.md#isinitialloading) + +*** + +### isLoading + +```ts +isLoading: false; +``` + +Defined in: [packages/query-core/src/types.ts:1120](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1120) + +Is `true` whenever the first fetch for a query is in-flight. +- Is the same as `isFetching && isPending`. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoading`](InfiniteQueryObserverBaseResult.md#isloading) + +*** + +### isLoadingError + +```ts +isLoadingError: false; +``` + +Defined in: [packages/query-core/src/types.ts:1121](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1121) + +Will be `true` if the query failed while fetching for the first time. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoadingError`](InfiniteQueryObserverBaseResult.md#isloadingerror) + +*** + +### isPaused + +```ts +isPaused: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:841](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L841) + +A derived boolean from the `fetchStatus` variable, provided for convenience. +- The query wanted to fetch, but has been `paused`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPaused`](InfiniteQueryObserverBaseResult.md#ispaused) + +*** + +### isPending + +```ts +isPending: false; +``` + +Defined in: [packages/query-core/src/types.ts:1119](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1119) + +Will be `pending` if there's no cached data and no query attempt was finished yet. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPending`](InfiniteQueryObserverBaseResult.md#ispending) + +*** + +### isPlaceholderData + +```ts +isPlaceholderData: false; +``` + +Defined in: [packages/query-core/src/types.ts:1126](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1126) + +Will be `true` if the data shown is the placeholder data. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPlaceholderData`](InfiniteQueryObserverBaseResult.md#isplaceholderdata) + +*** + +### isRefetchError + +```ts +isRefetchError: false; +``` + +Defined in: [packages/query-core/src/types.ts:1122](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1122) + +Will be `true` if the query failed while refetching. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isRefetchError`](InfiniteQueryObserverBaseResult.md#isrefetcherror) + +*** + +### isRefetching + +```ts +isRefetching: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:854](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L854) + +Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. +- Is the same as `isFetching && !isPending`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isRefetching`](InfiniteQueryObserverBaseResult.md#isrefetching) + +*** + +### isStale + +```ts +isStale: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:858](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L858) + +Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isStale`](InfiniteQueryObserverBaseResult.md#isstale) + +*** + +### isSuccess + +```ts +isSuccess: true; +``` + +Defined in: [packages/query-core/src/types.ts:1125](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1125) + +A derived boolean from the `status` variable, provided for convenience. +- `true` if the query has received a response with no errors and is ready to display its data. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isSuccess`](InfiniteQueryObserverBaseResult.md#issuccess) + +*** + +### refetch() + +```ts +refetch: (options?) => Promise>; +``` + +Defined in: [packages/query-core/src/types.ts:871](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L871) + +A function to manually refetch the query. + +#### Parameters + +##### options? + +[`RefetchOptions`](RefetchOptions.md) + +#### Returns + +`Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`refetch`](InfiniteQueryObserverBaseResult.md#refetch) + +*** + +### status + +```ts +status: "success"; +``` + +Defined in: [packages/query-core/src/types.ts:1127](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1127) + +The status of the query. +- Will be: + - `pending` if there's no cached data and no query attempt was finished yet. + - `error` if the query attempt resulted in an error. + - `success` if the query has received a response with no errors and is ready to display its data. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`status`](InfiniteQueryObserverBaseResult.md#status) diff --git a/docs/framework/react/reference/interfaces/InfiniteQueryPageParamsOptions.md b/docs/framework/react/reference/interfaces/InfiniteQueryPageParamsOptions.md new file mode 100644 index 00000000000..c091cc15456 --- /dev/null +++ b/docs/framework/react/reference/interfaces/InfiniteQueryPageParamsOptions.md @@ -0,0 +1,64 @@ +--- +id: InfiniteQueryPageParamsOptions +title: InfiniteQueryPageParamsOptions +--- + +Defined in: [packages/query-core/src/types.ts:352](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L352) + +## Extends + +- [`InitialPageParam`](InitialPageParam.md)\<`TPageParam`\> + +## Extended by + +- [`InfiniteQueryObserverOptions`](InfiniteQueryObserverOptions.md) + +## Type Parameters + +### TQueryFnData + +`TQueryFnData` = `unknown` + +### TPageParam + +`TPageParam` = `unknown` + +## Properties + +### getNextPageParam + +```ts +getNextPageParam: GetNextPageParamFunction; +``` + +Defined in: [packages/query-core/src/types.ts:365](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L365) + +This function can be set to automatically get the next cursor for infinite queries. +The result will also be used to determine the value of `hasNextPage`. + +*** + +### getPreviousPageParam? + +```ts +optional getPreviousPageParam: GetPreviousPageParamFunction; +``` + +Defined in: [packages/query-core/src/types.ts:360](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L360) + +This function can be set to automatically get the previous cursor for infinite queries. +The result will also be used to determine the value of `hasPreviousPage`. + +*** + +### initialPageParam + +```ts +initialPageParam: TPageParam; +``` + +Defined in: [packages/query-core/src/types.ts:349](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L349) + +#### Inherited from + +[`InitialPageParam`](InitialPageParam.md).[`initialPageParam`](InitialPageParam.md#initialpageparam) diff --git a/docs/framework/react/reference/interfaces/InitialPageParam.md b/docs/framework/react/reference/interfaces/InitialPageParam.md new file mode 100644 index 00000000000..46d2b219ea4 --- /dev/null +++ b/docs/framework/react/reference/interfaces/InitialPageParam.md @@ -0,0 +1,26 @@ +--- +id: InitialPageParam +title: InitialPageParam +--- + +Defined in: [packages/query-core/src/types.ts:348](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L348) + +## Extended by + +- [`InfiniteQueryPageParamsOptions`](InfiniteQueryPageParamsOptions.md) + +## Type Parameters + +### TPageParam + +`TPageParam` = `unknown` + +## Properties + +### initialPageParam + +```ts +initialPageParam: TPageParam; +``` + +Defined in: [packages/query-core/src/types.ts:349](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L349) diff --git a/docs/framework/react/reference/interfaces/InvalidateOptions.md b/docs/framework/react/reference/interfaces/InvalidateOptions.md new file mode 100644 index 00000000000..8a81428b035 --- /dev/null +++ b/docs/framework/react/reference/interfaces/InvalidateOptions.md @@ -0,0 +1,49 @@ +--- +id: InvalidateOptions +title: InvalidateOptions +--- + +Defined in: [packages/query-core/src/types.ts:734](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L734) + +## Extends + +- [`RefetchOptions`](RefetchOptions.md) + +## Properties + +### cancelRefetch? + +```ts +optional cancelRefetch: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:712](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L712) + +If set to `true`, a currently running request will be cancelled before a new request is made + +If set to `false`, no refetch will be made if there is already a request running. + +Defaults to `true`. + +#### Inherited from + +[`RefetchOptions`](RefetchOptions.md).[`cancelRefetch`](RefetchOptions.md#cancelrefetch) + +*** + +### throwOnError? + +```ts +optional throwOnError: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:701](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L701) + +If set to `true`, the method throws if any of the underlying query refetch tasks fail. + +Defaults to `false`, in which case failed refetches are swallowed and not surfaced to the +caller. + +#### Inherited from + +[`RefetchOptions`](RefetchOptions.md).[`throwOnError`](RefetchOptions.md#throwonerror) diff --git a/docs/framework/react/reference/interfaces/InvalidateQueryFilters.md b/docs/framework/react/reference/interfaces/InvalidateQueryFilters.md new file mode 100644 index 00000000000..569e42a4e1b --- /dev/null +++ b/docs/framework/react/reference/interfaces/InvalidateQueryFilters.md @@ -0,0 +1,145 @@ +--- +id: InvalidateQueryFilters +title: InvalidateQueryFilters +--- + +Defined in: [packages/query-core/src/types.ts:715](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L715) + +Filters used to select queries, for example in `queryClient.getQueriesData` or `queryClient.invalidateQueries`. +All provided filters must match; filters that are left unspecified are ignored. + +## Extends + +- [`QueryFilters`](QueryFilters.md)\<`TQueryKey`\> + +## Type Parameters + +### TQueryKey + +`TQueryKey` *extends* [`QueryKey`](../type-aliases/QueryKey.md) = [`QueryKey`](../type-aliases/QueryKey.md) + +## Properties + +### exact? + +```ts +optional exact: boolean; +``` + +Defined in: [packages/query-core/src/utils.ts:41](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L41) + +Match query key exactly + +#### Inherited from + +[`QueryFilters`](QueryFilters.md).[`exact`](QueryFilters.md#exact) + +*** + +### fetchStatus? + +```ts +optional fetchStatus: FetchStatus; +``` + +Defined in: [packages/query-core/src/utils.ts:57](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L57) + +Include queries matching their fetchStatus + +#### Inherited from + +[`QueryFilters`](QueryFilters.md).[`fetchStatus`](QueryFilters.md#fetchstatus) + +*** + +### predicate()? + +```ts +optional predicate: (query) => boolean; +``` + +Defined in: [packages/query-core/src/utils.ts:45](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L45) + +Include queries matching this predicate function + +#### Parameters + +##### query + +[`Query`](../classes/Query.md) + +#### Returns + +`boolean` + +#### Inherited from + +[`QueryFilters`](QueryFilters.md).[`predicate`](QueryFilters.md#predicate) + +*** + +### queryKey? + +```ts +optional queryKey: TQueryKey | TuplePrefixes; +``` + +Defined in: [packages/query-core/src/utils.ts:49](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L49) + +Include queries matching this query key + +#### Inherited from + +[`QueryFilters`](QueryFilters.md).[`queryKey`](QueryFilters.md#querykey) + +*** + +### refetchType? + +```ts +optional refetchType: QueryTypeFilter | "none"; +``` + +Defined in: [packages/query-core/src/types.ts:727](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L727) + +Controls which of the matched (now-invalidated) queries are refetched in the background. + +Defaults to `'active'`. +- `'active'`: only queries with at least one active observer are refetched. +- `'inactive'`: only queries with no active observer are refetched. +- `'all'`: every matched query is refetched, active or not. +- `'none'`: no query is refetched; matched queries are only marked as invalidated. + +*** + +### stale? + +```ts +optional stale: boolean; +``` + +Defined in: [packages/query-core/src/utils.ts:53](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L53) + +Include or exclude stale queries + +#### Inherited from + +[`QueryFilters`](QueryFilters.md).[`stale`](QueryFilters.md#stale) + +*** + +### type? + +```ts +optional type: QueryTypeFilter; +``` + +Defined in: [packages/query-core/src/utils.ts:37](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L37) + +Filter to active queries, inactive queries or all queries + +Defaults to `'all'`. + +#### Inherited from + +[`QueryFilters`](QueryFilters.md).[`type`](QueryFilters.md#type) diff --git a/docs/framework/react/reference/interfaces/MutateOptions.md b/docs/framework/react/reference/interfaces/MutateOptions.md new file mode 100644 index 00000000000..34e2a4d4d7e --- /dev/null +++ b/docs/framework/react/reference/interfaces/MutateOptions.md @@ -0,0 +1,124 @@ +--- +id: MutateOptions +title: MutateOptions +--- + +Defined in: [packages/query-core/src/types.ts:1284](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1284) + +## Type Parameters + +### TData + +`TData` = `unknown` + +### TError + +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) + +### TVariables + +`TVariables` = `void` + +### TOnMutateResult + +`TOnMutateResult` = `unknown` + +## Properties + +### onError()? + +```ts +optional onError: (error, variables, onMutateResult, context) => void; +``` + +Defined in: [packages/query-core/src/types.ts:1296](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1296) + +#### Parameters + +##### error + +`TError` + +##### variables + +`TVariables` + +##### onMutateResult + +`TOnMutateResult` | `undefined` + +##### context + +[`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md) + +#### Returns + +`void` + +*** + +### onSettled()? + +```ts +optional onSettled: (data, error, variables, onMutateResult, context) => void; +``` + +Defined in: [packages/query-core/src/types.ts:1302](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1302) + +#### Parameters + +##### data + +`TData` | `undefined` + +##### error + +`TError` | `null` + +##### variables + +`TVariables` + +##### onMutateResult + +`TOnMutateResult` | `undefined` + +##### context + +[`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md) + +#### Returns + +`void` + +*** + +### onSuccess()? + +```ts +optional onSuccess: (data, variables, onMutateResult, context) => void; +``` + +Defined in: [packages/query-core/src/types.ts:1290](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1290) + +#### Parameters + +##### data + +`TData` + +##### variables + +`TVariables` + +##### onMutateResult + +`TOnMutateResult` | `undefined` + +##### context + +[`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md) + +#### Returns + +`void` diff --git a/docs/framework/react/reference/interfaces/MutationCacheConfig.md b/docs/framework/react/reference/interfaces/MutationCacheConfig.md new file mode 100644 index 00000000000..c38d2dc26f4 --- /dev/null +++ b/docs/framework/react/reference/interfaces/MutationCacheConfig.md @@ -0,0 +1,161 @@ +--- +id: MutationCacheConfig +title: MutationCacheConfig +--- + +Defined in: [packages/query-core/src/mutationCache.ts:26](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationCache.ts#L26) + +Global callbacks that fire for every mutation handled by a `MutationCache`, regardless of which +component or observer triggered it. They differ from the `defaultOptions` provided to a +`QueryClient` in two ways: `defaultOptions` can be overridden by each mutation, while these +callbacks are always called, and `onMutate` here does not allow returning a result. + +If a callback returns a promise, it will be awaited before the mutation continues. + +## Properties + +### onError()? + +```ts +optional onError: (error, variables, onMutateResult, mutation, context) => unknown; +``` + +Defined in: [packages/query-core/src/mutationCache.ts:28](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationCache.ts#L28) + +Called when any mutation in the cache encounters an error. + +#### Parameters + +##### error + +`Error` + +##### variables + +`unknown` + +##### onMutateResult + +`unknown` + +##### mutation + +[`Mutation`](../classes/Mutation.md)\<`unknown`, `unknown`, `unknown`\> + +##### context + +[`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md) + +#### Returns + +`unknown` + +*** + +### onMutate()? + +```ts +optional onMutate: (variables, mutation, context) => unknown; +``` + +Defined in: [packages/query-core/src/mutationCache.ts:44](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationCache.ts#L44) + +Called before any mutation in the cache executes. + +#### Parameters + +##### variables + +`unknown` + +##### mutation + +[`Mutation`](../classes/Mutation.md)\<`unknown`, `unknown`, `unknown`\> + +##### context + +[`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md) + +#### Returns + +`unknown` + +*** + +### onSettled()? + +```ts +optional onSettled: (data, error, variables, onMutateResult, mutation, context) => unknown; +``` + +Defined in: [packages/query-core/src/mutationCache.ts:50](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationCache.ts#L50) + +Called when any mutation in the cache is settled, either successfully or with an error. + +#### Parameters + +##### data + +`unknown` + +##### error + +`Error` | `null` + +##### variables + +`unknown` + +##### onMutateResult + +`unknown` + +##### mutation + +[`Mutation`](../classes/Mutation.md)\<`unknown`, `unknown`, `unknown`\> + +##### context + +[`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md) + +#### Returns + +`unknown` + +*** + +### onSuccess()? + +```ts +optional onSuccess: (data, variables, onMutateResult, mutation, context) => unknown; +``` + +Defined in: [packages/query-core/src/mutationCache.ts:36](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationCache.ts#L36) + +Called when any mutation in the cache is successful. + +#### Parameters + +##### data + +`unknown` + +##### variables + +`unknown` + +##### onMutateResult + +`unknown` + +##### mutation + +[`Mutation`](../classes/Mutation.md)\<`unknown`, `unknown`, `unknown`\> + +##### context + +[`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md) + +#### Returns + +`unknown` diff --git a/docs/framework/react/reference/interfaces/MutationFilters.md b/docs/framework/react/reference/interfaces/MutationFilters.md new file mode 100644 index 00000000000..fbc0208e8e1 --- /dev/null +++ b/docs/framework/react/reference/interfaces/MutationFilters.md @@ -0,0 +1,85 @@ +--- +id: MutationFilters +title: MutationFilters +--- + +Defined in: [packages/query-core/src/utils.ts:64](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L64) + +Filters used to select mutations, for example in `mutationCache.findAll` or `queryClient.isMutating`. +All provided filters must match; filters that are left unspecified are ignored. + +## Type Parameters + +### TData + +`TData` = `unknown` + +### TError + +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) + +### TVariables + +`TVariables` = `unknown` + +### TOnMutateResult + +`TOnMutateResult` = `unknown` + +## Properties + +### exact? + +```ts +optional exact: boolean; +``` + +Defined in: [packages/query-core/src/utils.ts:73](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L73) + +Match mutation key exactly + +*** + +### mutationKey? + +```ts +optional mutationKey: readonly unknown[]; +``` + +Defined in: [packages/query-core/src/utils.ts:83](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L83) + +Include mutations matching this mutation key + +*** + +### predicate()? + +```ts +optional predicate: (mutation) => boolean; +``` + +Defined in: [packages/query-core/src/utils.ts:77](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L77) + +Include mutations matching this predicate function + +#### Parameters + +##### mutation + +[`Mutation`](../classes/Mutation.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\> + +#### Returns + +`boolean` + +*** + +### status? + +```ts +optional status: MutationStatus; +``` + +Defined in: [packages/query-core/src/utils.ts:87](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L87) + +Filter by mutation status diff --git a/docs/framework/react/reference/interfaces/MutationObserverBaseResult.md b/docs/framework/react/reference/interfaces/MutationObserverBaseResult.md new file mode 100644 index 00000000000..340a38cc9cc --- /dev/null +++ b/docs/framework/react/reference/interfaces/MutationObserverBaseResult.md @@ -0,0 +1,291 @@ +--- +id: MutationObserverBaseResult +title: MutationObserverBaseResult +--- + +Defined in: [packages/query-core/src/types.ts:1335](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1335) + +The raw state stored on a `Mutation` instance. This is the underlying state +that observer results (e.g. `MutationObserverResult`) are derived from. + +## Extends + +- [`MutationState`](MutationState.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\> + +## Extended by + +- [`MutationObserverIdleResult`](MutationObserverIdleResult.md) +- [`MutationObserverLoadingResult`](MutationObserverLoadingResult.md) +- [`MutationObserverErrorResult`](MutationObserverErrorResult.md) +- [`MutationObserverSuccessResult`](MutationObserverSuccessResult.md) + +## Type Parameters + +### TData + +`TData` = `unknown` + +### TError + +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) + +### TVariables + +`TVariables` = `void` + +### TOnMutateResult + +`TOnMutateResult` = `unknown` + +## Properties + +### context + +```ts +context: TOnMutateResult | undefined; +``` + +Defined in: [packages/query-core/src/mutation.ts:40](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L40) + +The value returned by `onMutate`, if defined. Passed to `onSuccess`, +`onError` and `onSettled` as the mutation's context. + +#### Inherited from + +[`MutationState`](MutationState.md).[`context`](MutationState.md#context) + +*** + +### data + +```ts +data: TData | undefined; +``` + +Defined in: [packages/query-core/src/types.ts:1344](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1344) + +The last successfully resolved data for the mutation. + +#### Overrides + +[`MutationState`](MutationState.md).[`data`](MutationState.md#data) + +*** + +### error + +```ts +error: TError | null; +``` + +Defined in: [packages/query-core/src/types.ts:1353](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1353) + +The error object for the mutation, if an error was encountered. +- Defaults to `null`. + +#### Overrides + +[`MutationState`](MutationState.md).[`error`](MutationState.md#error) + +*** + +### failureCount + +```ts +failureCount: number; +``` + +Defined in: [packages/query-core/src/mutation.ts:53](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L53) + +The number of times the mutation function has failed for the current attempt. + +#### Inherited from + +[`MutationState`](MutationState.md).[`failureCount`](MutationState.md#failurecount) + +*** + +### failureReason + +```ts +failureReason: TError | null; +``` + +Defined in: [packages/query-core/src/mutation.ts:57](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L57) + +The reason the current attempt failed, as reported by the retryer. + +#### Inherited from + +[`MutationState`](MutationState.md).[`failureReason`](MutationState.md#failurereason) + +*** + +### isError + +```ts +isError: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1358](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1358) + +A boolean variable derived from `status`. +- `true` if the last mutation attempt resulted in an error. + +*** + +### isIdle + +```ts +isIdle: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1363](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1363) + +A boolean variable derived from `status`. +- `true` if the mutation is in its initial state prior to executing. + +*** + +### isPaused + +```ts +isPaused: boolean; +``` + +Defined in: [packages/query-core/src/mutation.ts:62](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L62) + +Whether the mutation is currently paused (see network mode), or is +waiting for another mutation with the same `scope` to finish. + +#### Inherited from + +[`MutationState`](MutationState.md).[`isPaused`](MutationState.md#ispaused) + +*** + +### isPending + +```ts +isPending: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1368](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1368) + +A boolean variable derived from `status`. +- `true` if the mutation is currently executing. + +*** + +### isSuccess + +```ts +isSuccess: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1373](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1373) + +A boolean variable derived from `status`. +- `true` if the last mutation attempt was successful. + +*** + +### mutate + +```ts +mutate: MutateFunction; +``` + +Defined in: [packages/query-core/src/types.ts:1393](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1393) + +The mutation function you can call with variables to trigger the mutation and optionally hooks on additional callback options. + +#### Param + +The variables object to pass to the `mutationFn`. + +#### Param + +This function will fire when the mutation is successful and will be passed the mutation's result. + +#### Param + +This function will fire if the mutation encounters an error and will be passed the error. + +#### Param + +This function will fire when the mutation is either successfully fetched or encounters an error and be passed either the data or error. + +#### Remarks + +- If you make multiple requests, `onSuccess` will fire only after the latest call you've made. +- All the callback functions (`onSuccess`, `onError`, `onSettled`) are void functions, and the returned value will be ignored. + +*** + +### reset() + +```ts +reset: () => void; +``` + +Defined in: [packages/query-core/src/types.ts:1397](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1397) + +A function to clean the mutation internal state (i.e., it resets the mutation to its initial state). + +#### Returns + +`void` + +*** + +### status + +```ts +status: MutationStatus; +``` + +Defined in: [packages/query-core/src/types.ts:1382](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1382) + +The status of the mutation. +- Will be: + - `idle` initial status prior to the mutation function executing. + - `pending` if the mutation is currently executing. + - `error` if the last mutation attempt resulted in an error. + - `success` if the last mutation attempt was successful. + +#### Overrides + +[`MutationState`](MutationState.md).[`status`](MutationState.md#status) + +*** + +### submittedAt + +```ts +submittedAt: number; +``` + +Defined in: [packages/query-core/src/mutation.ts:74](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L74) + +The timestamp for when the mutation was submitted. + +#### Inherited from + +[`MutationState`](MutationState.md).[`submittedAt`](MutationState.md#submittedat) + +*** + +### variables + +```ts +variables: TVariables | undefined; +``` + +Defined in: [packages/query-core/src/types.ts:1348](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1348) + +The variables object passed to the `mutationFn`. + +#### Overrides + +[`MutationState`](MutationState.md).[`variables`](MutationState.md#variables) diff --git a/docs/framework/react/reference/interfaces/MutationObserverErrorResult.md b/docs/framework/react/reference/interfaces/MutationObserverErrorResult.md new file mode 100644 index 00000000000..72e459a2e0b --- /dev/null +++ b/docs/framework/react/reference/interfaces/MutationObserverErrorResult.md @@ -0,0 +1,308 @@ +--- +id: MutationObserverErrorResult +title: MutationObserverErrorResult +--- + +Defined in: [packages/query-core/src/types.ts:1442](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1442) + +The raw state stored on a `Mutation` instance. This is the underlying state +that observer results (e.g. `MutationObserverResult`) are derived from. + +## Extends + +- [`MutationObserverBaseResult`](MutationObserverBaseResult.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\> + +## Type Parameters + +### TData + +`TData` = `unknown` + +### TError + +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) + +### TVariables + +`TVariables` = `void` + +### TOnMutateResult + +`TOnMutateResult` = `unknown` + +## Properties + +### context + +```ts +context: TOnMutateResult | undefined; +``` + +Defined in: [packages/query-core/src/mutation.ts:40](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L40) + +The value returned by `onMutate`, if defined. Passed to `onSuccess`, +`onError` and `onSettled` as the mutation's context. + +#### Inherited from + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`context`](MutationObserverBaseResult.md#context) + +*** + +### data + +```ts +data: undefined; +``` + +Defined in: [packages/query-core/src/types.ts:1453](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1453) + +The last successfully resolved data for the mutation. + +#### Overrides + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`data`](MutationObserverBaseResult.md#data) + +*** + +### error + +```ts +error: TError; +``` + +Defined in: [packages/query-core/src/types.ts:1454](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1454) + +The error object for the mutation, if an error was encountered. +- Defaults to `null`. + +#### Overrides + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`error`](MutationObserverBaseResult.md#error) + +*** + +### failureCount + +```ts +failureCount: number; +``` + +Defined in: [packages/query-core/src/mutation.ts:53](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L53) + +The number of times the mutation function has failed for the current attempt. + +#### Inherited from + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`failureCount`](MutationObserverBaseResult.md#failurecount) + +*** + +### failureReason + +```ts +failureReason: TError | null; +``` + +Defined in: [packages/query-core/src/mutation.ts:57](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L57) + +The reason the current attempt failed, as reported by the retryer. + +#### Inherited from + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`failureReason`](MutationObserverBaseResult.md#failurereason) + +*** + +### isError + +```ts +isError: true; +``` + +Defined in: [packages/query-core/src/types.ts:1456](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1456) + +A boolean variable derived from `status`. +- `true` if the last mutation attempt resulted in an error. + +#### Overrides + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isError`](MutationObserverBaseResult.md#iserror) + +*** + +### isIdle + +```ts +isIdle: false; +``` + +Defined in: [packages/query-core/src/types.ts:1457](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1457) + +A boolean variable derived from `status`. +- `true` if the mutation is in its initial state prior to executing. + +#### Overrides + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isIdle`](MutationObserverBaseResult.md#isidle) + +*** + +### isPaused + +```ts +isPaused: boolean; +``` + +Defined in: [packages/query-core/src/mutation.ts:62](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L62) + +Whether the mutation is currently paused (see network mode), or is +waiting for another mutation with the same `scope` to finish. + +#### Inherited from + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isPaused`](MutationObserverBaseResult.md#ispaused) + +*** + +### isPending + +```ts +isPending: false; +``` + +Defined in: [packages/query-core/src/types.ts:1458](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1458) + +A boolean variable derived from `status`. +- `true` if the mutation is currently executing. + +#### Overrides + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isPending`](MutationObserverBaseResult.md#ispending) + +*** + +### isSuccess + +```ts +isSuccess: false; +``` + +Defined in: [packages/query-core/src/types.ts:1459](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1459) + +A boolean variable derived from `status`. +- `true` if the last mutation attempt was successful. + +#### Overrides + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isSuccess`](MutationObserverBaseResult.md#issuccess) + +*** + +### mutate + +```ts +mutate: MutateFunction; +``` + +Defined in: [packages/query-core/src/types.ts:1393](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1393) + +The mutation function you can call with variables to trigger the mutation and optionally hooks on additional callback options. + +#### Param + +The variables object to pass to the `mutationFn`. + +#### Param + +This function will fire when the mutation is successful and will be passed the mutation's result. + +#### Param + +This function will fire if the mutation encounters an error and will be passed the error. + +#### Param + +This function will fire when the mutation is either successfully fetched or encounters an error and be passed either the data or error. + +#### Remarks + +- If you make multiple requests, `onSuccess` will fire only after the latest call you've made. +- All the callback functions (`onSuccess`, `onError`, `onSettled`) are void functions, and the returned value will be ignored. + +#### Inherited from + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`mutate`](MutationObserverBaseResult.md#mutate) + +*** + +### reset() + +```ts +reset: () => void; +``` + +Defined in: [packages/query-core/src/types.ts:1397](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1397) + +A function to clean the mutation internal state (i.e., it resets the mutation to its initial state). + +#### Returns + +`void` + +#### Inherited from + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`reset`](MutationObserverBaseResult.md#reset) + +*** + +### status + +```ts +status: "error"; +``` + +Defined in: [packages/query-core/src/types.ts:1460](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1460) + +The status of the mutation. +- Will be: + - `idle` initial status prior to the mutation function executing. + - `pending` if the mutation is currently executing. + - `error` if the last mutation attempt resulted in an error. + - `success` if the last mutation attempt was successful. + +#### Overrides + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`status`](MutationObserverBaseResult.md#status) + +*** + +### submittedAt + +```ts +submittedAt: number; +``` + +Defined in: [packages/query-core/src/mutation.ts:74](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L74) + +The timestamp for when the mutation was submitted. + +#### Inherited from + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`submittedAt`](MutationObserverBaseResult.md#submittedat) + +*** + +### variables + +```ts +variables: TVariables; +``` + +Defined in: [packages/query-core/src/types.ts:1455](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1455) + +The variables object passed to the `mutationFn`. + +#### Overrides + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`variables`](MutationObserverBaseResult.md#variables) diff --git a/docs/framework/react/reference/interfaces/MutationObserverIdleResult.md b/docs/framework/react/reference/interfaces/MutationObserverIdleResult.md new file mode 100644 index 00000000000..cd8d6eb3130 --- /dev/null +++ b/docs/framework/react/reference/interfaces/MutationObserverIdleResult.md @@ -0,0 +1,308 @@ +--- +id: MutationObserverIdleResult +title: MutationObserverIdleResult +--- + +Defined in: [packages/query-core/src/types.ts:1400](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1400) + +The raw state stored on a `Mutation` instance. This is the underlying state +that observer results (e.g. `MutationObserverResult`) are derived from. + +## Extends + +- [`MutationObserverBaseResult`](MutationObserverBaseResult.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\> + +## Type Parameters + +### TData + +`TData` = `unknown` + +### TError + +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) + +### TVariables + +`TVariables` = `void` + +### TOnMutateResult + +`TOnMutateResult` = `unknown` + +## Properties + +### context + +```ts +context: TOnMutateResult | undefined; +``` + +Defined in: [packages/query-core/src/mutation.ts:40](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L40) + +The value returned by `onMutate`, if defined. Passed to `onSuccess`, +`onError` and `onSettled` as the mutation's context. + +#### Inherited from + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`context`](MutationObserverBaseResult.md#context) + +*** + +### data + +```ts +data: undefined; +``` + +Defined in: [packages/query-core/src/types.ts:1411](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1411) + +The last successfully resolved data for the mutation. + +#### Overrides + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`data`](MutationObserverBaseResult.md#data) + +*** + +### error + +```ts +error: null; +``` + +Defined in: [packages/query-core/src/types.ts:1413](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1413) + +The error object for the mutation, if an error was encountered. +- Defaults to `null`. + +#### Overrides + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`error`](MutationObserverBaseResult.md#error) + +*** + +### failureCount + +```ts +failureCount: number; +``` + +Defined in: [packages/query-core/src/mutation.ts:53](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L53) + +The number of times the mutation function has failed for the current attempt. + +#### Inherited from + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`failureCount`](MutationObserverBaseResult.md#failurecount) + +*** + +### failureReason + +```ts +failureReason: TError | null; +``` + +Defined in: [packages/query-core/src/mutation.ts:57](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L57) + +The reason the current attempt failed, as reported by the retryer. + +#### Inherited from + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`failureReason`](MutationObserverBaseResult.md#failurereason) + +*** + +### isError + +```ts +isError: false; +``` + +Defined in: [packages/query-core/src/types.ts:1414](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1414) + +A boolean variable derived from `status`. +- `true` if the last mutation attempt resulted in an error. + +#### Overrides + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isError`](MutationObserverBaseResult.md#iserror) + +*** + +### isIdle + +```ts +isIdle: true; +``` + +Defined in: [packages/query-core/src/types.ts:1415](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1415) + +A boolean variable derived from `status`. +- `true` if the mutation is in its initial state prior to executing. + +#### Overrides + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isIdle`](MutationObserverBaseResult.md#isidle) + +*** + +### isPaused + +```ts +isPaused: boolean; +``` + +Defined in: [packages/query-core/src/mutation.ts:62](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L62) + +Whether the mutation is currently paused (see network mode), or is +waiting for another mutation with the same `scope` to finish. + +#### Inherited from + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isPaused`](MutationObserverBaseResult.md#ispaused) + +*** + +### isPending + +```ts +isPending: false; +``` + +Defined in: [packages/query-core/src/types.ts:1416](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1416) + +A boolean variable derived from `status`. +- `true` if the mutation is currently executing. + +#### Overrides + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isPending`](MutationObserverBaseResult.md#ispending) + +*** + +### isSuccess + +```ts +isSuccess: false; +``` + +Defined in: [packages/query-core/src/types.ts:1417](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1417) + +A boolean variable derived from `status`. +- `true` if the last mutation attempt was successful. + +#### Overrides + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isSuccess`](MutationObserverBaseResult.md#issuccess) + +*** + +### mutate + +```ts +mutate: MutateFunction; +``` + +Defined in: [packages/query-core/src/types.ts:1393](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1393) + +The mutation function you can call with variables to trigger the mutation and optionally hooks on additional callback options. + +#### Param + +The variables object to pass to the `mutationFn`. + +#### Param + +This function will fire when the mutation is successful and will be passed the mutation's result. + +#### Param + +This function will fire if the mutation encounters an error and will be passed the error. + +#### Param + +This function will fire when the mutation is either successfully fetched or encounters an error and be passed either the data or error. + +#### Remarks + +- If you make multiple requests, `onSuccess` will fire only after the latest call you've made. +- All the callback functions (`onSuccess`, `onError`, `onSettled`) are void functions, and the returned value will be ignored. + +#### Inherited from + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`mutate`](MutationObserverBaseResult.md#mutate) + +*** + +### reset() + +```ts +reset: () => void; +``` + +Defined in: [packages/query-core/src/types.ts:1397](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1397) + +A function to clean the mutation internal state (i.e., it resets the mutation to its initial state). + +#### Returns + +`void` + +#### Inherited from + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`reset`](MutationObserverBaseResult.md#reset) + +*** + +### status + +```ts +status: "idle"; +``` + +Defined in: [packages/query-core/src/types.ts:1418](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1418) + +The status of the mutation. +- Will be: + - `idle` initial status prior to the mutation function executing. + - `pending` if the mutation is currently executing. + - `error` if the last mutation attempt resulted in an error. + - `success` if the last mutation attempt was successful. + +#### Overrides + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`status`](MutationObserverBaseResult.md#status) + +*** + +### submittedAt + +```ts +submittedAt: number; +``` + +Defined in: [packages/query-core/src/mutation.ts:74](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L74) + +The timestamp for when the mutation was submitted. + +#### Inherited from + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`submittedAt`](MutationObserverBaseResult.md#submittedat) + +*** + +### variables + +```ts +variables: undefined; +``` + +Defined in: [packages/query-core/src/types.ts:1412](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1412) + +The variables object passed to the `mutationFn`. + +#### Overrides + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`variables`](MutationObserverBaseResult.md#variables) diff --git a/docs/framework/react/reference/interfaces/MutationObserverLoadingResult.md b/docs/framework/react/reference/interfaces/MutationObserverLoadingResult.md new file mode 100644 index 00000000000..9b70a8558e7 --- /dev/null +++ b/docs/framework/react/reference/interfaces/MutationObserverLoadingResult.md @@ -0,0 +1,308 @@ +--- +id: MutationObserverLoadingResult +title: MutationObserverLoadingResult +--- + +Defined in: [packages/query-core/src/types.ts:1421](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1421) + +The raw state stored on a `Mutation` instance. This is the underlying state +that observer results (e.g. `MutationObserverResult`) are derived from. + +## Extends + +- [`MutationObserverBaseResult`](MutationObserverBaseResult.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\> + +## Type Parameters + +### TData + +`TData` = `unknown` + +### TError + +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) + +### TVariables + +`TVariables` = `void` + +### TOnMutateResult + +`TOnMutateResult` = `unknown` + +## Properties + +### context + +```ts +context: TOnMutateResult | undefined; +``` + +Defined in: [packages/query-core/src/mutation.ts:40](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L40) + +The value returned by `onMutate`, if defined. Passed to `onSuccess`, +`onError` and `onSettled` as the mutation's context. + +#### Inherited from + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`context`](MutationObserverBaseResult.md#context) + +*** + +### data + +```ts +data: undefined; +``` + +Defined in: [packages/query-core/src/types.ts:1432](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1432) + +The last successfully resolved data for the mutation. + +#### Overrides + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`data`](MutationObserverBaseResult.md#data) + +*** + +### error + +```ts +error: null; +``` + +Defined in: [packages/query-core/src/types.ts:1434](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1434) + +The error object for the mutation, if an error was encountered. +- Defaults to `null`. + +#### Overrides + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`error`](MutationObserverBaseResult.md#error) + +*** + +### failureCount + +```ts +failureCount: number; +``` + +Defined in: [packages/query-core/src/mutation.ts:53](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L53) + +The number of times the mutation function has failed for the current attempt. + +#### Inherited from + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`failureCount`](MutationObserverBaseResult.md#failurecount) + +*** + +### failureReason + +```ts +failureReason: TError | null; +``` + +Defined in: [packages/query-core/src/mutation.ts:57](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L57) + +The reason the current attempt failed, as reported by the retryer. + +#### Inherited from + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`failureReason`](MutationObserverBaseResult.md#failurereason) + +*** + +### isError + +```ts +isError: false; +``` + +Defined in: [packages/query-core/src/types.ts:1435](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1435) + +A boolean variable derived from `status`. +- `true` if the last mutation attempt resulted in an error. + +#### Overrides + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isError`](MutationObserverBaseResult.md#iserror) + +*** + +### isIdle + +```ts +isIdle: false; +``` + +Defined in: [packages/query-core/src/types.ts:1436](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1436) + +A boolean variable derived from `status`. +- `true` if the mutation is in its initial state prior to executing. + +#### Overrides + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isIdle`](MutationObserverBaseResult.md#isidle) + +*** + +### isPaused + +```ts +isPaused: boolean; +``` + +Defined in: [packages/query-core/src/mutation.ts:62](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L62) + +Whether the mutation is currently paused (see network mode), or is +waiting for another mutation with the same `scope` to finish. + +#### Inherited from + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isPaused`](MutationObserverBaseResult.md#ispaused) + +*** + +### isPending + +```ts +isPending: true; +``` + +Defined in: [packages/query-core/src/types.ts:1437](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1437) + +A boolean variable derived from `status`. +- `true` if the mutation is currently executing. + +#### Overrides + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isPending`](MutationObserverBaseResult.md#ispending) + +*** + +### isSuccess + +```ts +isSuccess: false; +``` + +Defined in: [packages/query-core/src/types.ts:1438](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1438) + +A boolean variable derived from `status`. +- `true` if the last mutation attempt was successful. + +#### Overrides + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isSuccess`](MutationObserverBaseResult.md#issuccess) + +*** + +### mutate + +```ts +mutate: MutateFunction; +``` + +Defined in: [packages/query-core/src/types.ts:1393](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1393) + +The mutation function you can call with variables to trigger the mutation and optionally hooks on additional callback options. + +#### Param + +The variables object to pass to the `mutationFn`. + +#### Param + +This function will fire when the mutation is successful and will be passed the mutation's result. + +#### Param + +This function will fire if the mutation encounters an error and will be passed the error. + +#### Param + +This function will fire when the mutation is either successfully fetched or encounters an error and be passed either the data or error. + +#### Remarks + +- If you make multiple requests, `onSuccess` will fire only after the latest call you've made. +- All the callback functions (`onSuccess`, `onError`, `onSettled`) are void functions, and the returned value will be ignored. + +#### Inherited from + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`mutate`](MutationObserverBaseResult.md#mutate) + +*** + +### reset() + +```ts +reset: () => void; +``` + +Defined in: [packages/query-core/src/types.ts:1397](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1397) + +A function to clean the mutation internal state (i.e., it resets the mutation to its initial state). + +#### Returns + +`void` + +#### Inherited from + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`reset`](MutationObserverBaseResult.md#reset) + +*** + +### status + +```ts +status: "pending"; +``` + +Defined in: [packages/query-core/src/types.ts:1439](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1439) + +The status of the mutation. +- Will be: + - `idle` initial status prior to the mutation function executing. + - `pending` if the mutation is currently executing. + - `error` if the last mutation attempt resulted in an error. + - `success` if the last mutation attempt was successful. + +#### Overrides + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`status`](MutationObserverBaseResult.md#status) + +*** + +### submittedAt + +```ts +submittedAt: number; +``` + +Defined in: [packages/query-core/src/mutation.ts:74](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L74) + +The timestamp for when the mutation was submitted. + +#### Inherited from + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`submittedAt`](MutationObserverBaseResult.md#submittedat) + +*** + +### variables + +```ts +variables: TVariables; +``` + +Defined in: [packages/query-core/src/types.ts:1433](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1433) + +The variables object passed to the `mutationFn`. + +#### Overrides + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`variables`](MutationObserverBaseResult.md#variables) diff --git a/docs/framework/react/reference/interfaces/MutationObserverOptions.md b/docs/framework/react/reference/interfaces/MutationObserverOptions.md new file mode 100644 index 00000000000..5bab2840a6d --- /dev/null +++ b/docs/framework/react/reference/interfaces/MutationObserverOptions.md @@ -0,0 +1,322 @@ +--- +id: MutationObserverOptions +title: MutationObserverOptions +--- + +Defined in: [packages/query-core/src/types.ts:1267](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1267) + +## Extends + +- [`MutationOptions`](MutationOptions.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\> + +## Type Parameters + +### TData + +`TData` = `unknown` + +### TError + +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) + +### TVariables + +`TVariables` = `void` + +### TOnMutateResult + +`TOnMutateResult` = `unknown` + +## Properties + +### gcTime? + +```ts +optional gcTime: number; +``` + +Defined in: [packages/query-core/src/types.ts:1260](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1260) + +The time in milliseconds that an unused/inactive mutation remains in memory before it is +garbage collected. + +Defaults to `5 * 60 * 1000` (5 minutes), or `Infinity` during SSR. + +#### Inherited from + +[`MutationOptions`](MutationOptions.md).[`gcTime`](MutationOptions.md#gctime) + +*** + +### meta? + +```ts +optional meta: Record; +``` + +Defined in: [packages/query-core/src/types.ts:1263](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1263) + +#### Inherited from + +[`MutationOptions`](MutationOptions.md).[`meta`](MutationOptions.md#meta) + +*** + +### mutationFn? + +```ts +optional mutationFn: MutationFunction; +``` + +Defined in: [packages/query-core/src/types.ts:1206](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1206) + +#### Inherited from + +[`MutationOptions`](MutationOptions.md).[`mutationFn`](MutationOptions.md#mutationfn) + +*** + +### mutationKey? + +```ts +optional mutationKey: readonly unknown[]; +``` + +Defined in: [packages/query-core/src/types.ts:1207](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1207) + +#### Inherited from + +[`MutationOptions`](MutationOptions.md).[`mutationKey`](MutationOptions.md#mutationkey) + +*** + +### networkMode? + +```ts +optional networkMode: NetworkMode; +``` + +Defined in: [packages/query-core/src/types.ts:1253](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1253) + +Controls whether a mutation is allowed to run based on the current network connectivity. + +Defaults to `'online'`. + +#### See + +[Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. + +#### Inherited from + +[`MutationOptions`](MutationOptions.md).[`networkMode`](MutationOptions.md#networkmode) + +*** + +### onError()? + +```ts +optional onError: (error, variables, onMutateResult, context) => unknown; +``` + +Defined in: [packages/query-core/src/types.ts:1218](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1218) + +#### Parameters + +##### error + +`TError` + +##### variables + +`TVariables` + +##### onMutateResult + +`TOnMutateResult` | `undefined` + +##### context + +[`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md) + +#### Returns + +`unknown` + +#### Inherited from + +[`MutationOptions`](MutationOptions.md).[`onError`](MutationOptions.md#onerror) + +*** + +### onMutate()? + +```ts +optional onMutate: (variables, context) => TOnMutateResult | Promise; +``` + +Defined in: [packages/query-core/src/types.ts:1208](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1208) + +#### Parameters + +##### variables + +`TVariables` + +##### context + +[`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md) + +#### Returns + +`TOnMutateResult` \| `Promise`\<`TOnMutateResult`\> + +#### Inherited from + +[`MutationOptions`](MutationOptions.md).[`onMutate`](MutationOptions.md#onmutate) + +*** + +### onSettled()? + +```ts +optional onSettled: (data, error, variables, onMutateResult, context) => unknown; +``` + +Defined in: [packages/query-core/src/types.ts:1224](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1224) + +#### Parameters + +##### data + +`TData` | `undefined` + +##### error + +`TError` | `null` + +##### variables + +`TVariables` + +##### onMutateResult + +`TOnMutateResult` | `undefined` + +##### context + +[`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md) + +#### Returns + +`unknown` + +#### Inherited from + +[`MutationOptions`](MutationOptions.md).[`onSettled`](MutationOptions.md#onsettled) + +*** + +### onSuccess()? + +```ts +optional onSuccess: (data, variables, onMutateResult, context) => unknown; +``` + +Defined in: [packages/query-core/src/types.ts:1212](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1212) + +#### Parameters + +##### data + +`TData` + +##### variables + +`TVariables` + +##### onMutateResult + +`TOnMutateResult` + +##### context + +[`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md) + +#### Returns + +`unknown` + +#### Inherited from + +[`MutationOptions`](MutationOptions.md).[`onSuccess`](MutationOptions.md#onsuccess) + +*** + +### retry? + +```ts +optional retry: RetryValue; +``` + +Defined in: [packages/query-core/src/types.ts:1239](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1239) + +If `false`, failed mutations will not retry by default. +If `true`, failed mutations will retry infinitely. +If set to an integer number, e.g. 3, failed mutations will retry until the failed mutation count meets that number. +If set to a function `(failureCount, error) => boolean` failed mutations will retry until the function returns false. + +Defaults to `0`. + +#### Inherited from + +[`MutationOptions`](MutationOptions.md).[`retry`](MutationOptions.md#retry) + +*** + +### retryDelay? + +```ts +optional retryDelay: RetryDelayValue; +``` + +Defined in: [packages/query-core/src/types.ts:1246](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1246) + +This function receives a `retryAttempt` integer and the actual Error and returns the delay to apply before the +next attempt in milliseconds. + +Defaults to a function that applies exponential backoff, capped at 30 seconds. + +#### Inherited from + +[`MutationOptions`](MutationOptions.md).[`retryDelay`](MutationOptions.md#retrydelay) + +*** + +### scope? + +```ts +optional scope: MutationScope; +``` + +Defined in: [packages/query-core/src/types.ts:1264](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1264) + +#### Inherited from + +[`MutationOptions`](MutationOptions.md).[`scope`](MutationOptions.md#scope) + +*** + +### throwOnError? + +```ts +optional throwOnError: boolean | (error) => boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1281](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1281) + +Whether errors should be thrown instead of setting the `error` property. +If set to `true`, all errors will be thrown to the nearest error boundary. +If set to a function, it will be passed the error and should return a boolean indicating whether to throw the +error (`true`) or return it as state (`false`). + +Defaults to `false`. diff --git a/docs/framework/react/reference/interfaces/MutationObserverSuccessResult.md b/docs/framework/react/reference/interfaces/MutationObserverSuccessResult.md new file mode 100644 index 00000000000..e2e03642f82 --- /dev/null +++ b/docs/framework/react/reference/interfaces/MutationObserverSuccessResult.md @@ -0,0 +1,308 @@ +--- +id: MutationObserverSuccessResult +title: MutationObserverSuccessResult +--- + +Defined in: [packages/query-core/src/types.ts:1463](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1463) + +The raw state stored on a `Mutation` instance. This is the underlying state +that observer results (e.g. `MutationObserverResult`) are derived from. + +## Extends + +- [`MutationObserverBaseResult`](MutationObserverBaseResult.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\> + +## Type Parameters + +### TData + +`TData` = `unknown` + +### TError + +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) + +### TVariables + +`TVariables` = `void` + +### TOnMutateResult + +`TOnMutateResult` = `unknown` + +## Properties + +### context + +```ts +context: TOnMutateResult | undefined; +``` + +Defined in: [packages/query-core/src/mutation.ts:40](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L40) + +The value returned by `onMutate`, if defined. Passed to `onSuccess`, +`onError` and `onSettled` as the mutation's context. + +#### Inherited from + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`context`](MutationObserverBaseResult.md#context) + +*** + +### data + +```ts +data: TData; +``` + +Defined in: [packages/query-core/src/types.ts:1474](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1474) + +The last successfully resolved data for the mutation. + +#### Overrides + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`data`](MutationObserverBaseResult.md#data) + +*** + +### error + +```ts +error: null; +``` + +Defined in: [packages/query-core/src/types.ts:1475](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1475) + +The error object for the mutation, if an error was encountered. +- Defaults to `null`. + +#### Overrides + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`error`](MutationObserverBaseResult.md#error) + +*** + +### failureCount + +```ts +failureCount: number; +``` + +Defined in: [packages/query-core/src/mutation.ts:53](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L53) + +The number of times the mutation function has failed for the current attempt. + +#### Inherited from + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`failureCount`](MutationObserverBaseResult.md#failurecount) + +*** + +### failureReason + +```ts +failureReason: TError | null; +``` + +Defined in: [packages/query-core/src/mutation.ts:57](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L57) + +The reason the current attempt failed, as reported by the retryer. + +#### Inherited from + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`failureReason`](MutationObserverBaseResult.md#failurereason) + +*** + +### isError + +```ts +isError: false; +``` + +Defined in: [packages/query-core/src/types.ts:1477](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1477) + +A boolean variable derived from `status`. +- `true` if the last mutation attempt resulted in an error. + +#### Overrides + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isError`](MutationObserverBaseResult.md#iserror) + +*** + +### isIdle + +```ts +isIdle: false; +``` + +Defined in: [packages/query-core/src/types.ts:1478](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1478) + +A boolean variable derived from `status`. +- `true` if the mutation is in its initial state prior to executing. + +#### Overrides + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isIdle`](MutationObserverBaseResult.md#isidle) + +*** + +### isPaused + +```ts +isPaused: boolean; +``` + +Defined in: [packages/query-core/src/mutation.ts:62](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L62) + +Whether the mutation is currently paused (see network mode), or is +waiting for another mutation with the same `scope` to finish. + +#### Inherited from + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isPaused`](MutationObserverBaseResult.md#ispaused) + +*** + +### isPending + +```ts +isPending: false; +``` + +Defined in: [packages/query-core/src/types.ts:1479](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1479) + +A boolean variable derived from `status`. +- `true` if the mutation is currently executing. + +#### Overrides + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isPending`](MutationObserverBaseResult.md#ispending) + +*** + +### isSuccess + +```ts +isSuccess: true; +``` + +Defined in: [packages/query-core/src/types.ts:1480](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1480) + +A boolean variable derived from `status`. +- `true` if the last mutation attempt was successful. + +#### Overrides + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isSuccess`](MutationObserverBaseResult.md#issuccess) + +*** + +### mutate + +```ts +mutate: MutateFunction; +``` + +Defined in: [packages/query-core/src/types.ts:1393](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1393) + +The mutation function you can call with variables to trigger the mutation and optionally hooks on additional callback options. + +#### Param + +The variables object to pass to the `mutationFn`. + +#### Param + +This function will fire when the mutation is successful and will be passed the mutation's result. + +#### Param + +This function will fire if the mutation encounters an error and will be passed the error. + +#### Param + +This function will fire when the mutation is either successfully fetched or encounters an error and be passed either the data or error. + +#### Remarks + +- If you make multiple requests, `onSuccess` will fire only after the latest call you've made. +- All the callback functions (`onSuccess`, `onError`, `onSettled`) are void functions, and the returned value will be ignored. + +#### Inherited from + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`mutate`](MutationObserverBaseResult.md#mutate) + +*** + +### reset() + +```ts +reset: () => void; +``` + +Defined in: [packages/query-core/src/types.ts:1397](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1397) + +A function to clean the mutation internal state (i.e., it resets the mutation to its initial state). + +#### Returns + +`void` + +#### Inherited from + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`reset`](MutationObserverBaseResult.md#reset) + +*** + +### status + +```ts +status: "success"; +``` + +Defined in: [packages/query-core/src/types.ts:1481](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1481) + +The status of the mutation. +- Will be: + - `idle` initial status prior to the mutation function executing. + - `pending` if the mutation is currently executing. + - `error` if the last mutation attempt resulted in an error. + - `success` if the last mutation attempt was successful. + +#### Overrides + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`status`](MutationObserverBaseResult.md#status) + +*** + +### submittedAt + +```ts +submittedAt: number; +``` + +Defined in: [packages/query-core/src/mutation.ts:74](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L74) + +The timestamp for when the mutation was submitted. + +#### Inherited from + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`submittedAt`](MutationObserverBaseResult.md#submittedat) + +*** + +### variables + +```ts +variables: TVariables; +``` + +Defined in: [packages/query-core/src/types.ts:1476](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1476) + +The variables object passed to the `mutationFn`. + +#### Overrides + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`variables`](MutationObserverBaseResult.md#variables) diff --git a/docs/framework/react/reference/interfaces/MutationOptions.md b/docs/framework/react/reference/interfaces/MutationOptions.md new file mode 100644 index 00000000000..5aabeeb0ca4 --- /dev/null +++ b/docs/framework/react/reference/interfaces/MutationOptions.md @@ -0,0 +1,257 @@ +--- +id: MutationOptions +title: MutationOptions +--- + +Defined in: [packages/query-core/src/types.ts:1200](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1200) + +## Extended by + +- [`MutationObserverOptions`](MutationObserverOptions.md) + +## Type Parameters + +### TData + +`TData` = `unknown` + +### TError + +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) + +### TVariables + +`TVariables` = `void` + +### TOnMutateResult + +`TOnMutateResult` = `unknown` + +## Properties + +### gcTime? + +```ts +optional gcTime: number; +``` + +Defined in: [packages/query-core/src/types.ts:1260](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1260) + +The time in milliseconds that an unused/inactive mutation remains in memory before it is +garbage collected. + +Defaults to `5 * 60 * 1000` (5 minutes), or `Infinity` during SSR. + +*** + +### meta? + +```ts +optional meta: Record; +``` + +Defined in: [packages/query-core/src/types.ts:1263](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1263) + +*** + +### mutationFn? + +```ts +optional mutationFn: MutationFunction; +``` + +Defined in: [packages/query-core/src/types.ts:1206](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1206) + +*** + +### mutationKey? + +```ts +optional mutationKey: readonly unknown[]; +``` + +Defined in: [packages/query-core/src/types.ts:1207](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1207) + +*** + +### networkMode? + +```ts +optional networkMode: NetworkMode; +``` + +Defined in: [packages/query-core/src/types.ts:1253](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1253) + +Controls whether a mutation is allowed to run based on the current network connectivity. + +Defaults to `'online'`. + +#### See + +[Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. + +*** + +### onError()? + +```ts +optional onError: (error, variables, onMutateResult, context) => unknown; +``` + +Defined in: [packages/query-core/src/types.ts:1218](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1218) + +#### Parameters + +##### error + +`TError` + +##### variables + +`TVariables` + +##### onMutateResult + +`TOnMutateResult` | `undefined` + +##### context + +[`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md) + +#### Returns + +`unknown` + +*** + +### onMutate()? + +```ts +optional onMutate: (variables, context) => TOnMutateResult | Promise; +``` + +Defined in: [packages/query-core/src/types.ts:1208](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1208) + +#### Parameters + +##### variables + +`TVariables` + +##### context + +[`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md) + +#### Returns + +`TOnMutateResult` \| `Promise`\<`TOnMutateResult`\> + +*** + +### onSettled()? + +```ts +optional onSettled: (data, error, variables, onMutateResult, context) => unknown; +``` + +Defined in: [packages/query-core/src/types.ts:1224](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1224) + +#### Parameters + +##### data + +`TData` | `undefined` + +##### error + +`TError` | `null` + +##### variables + +`TVariables` + +##### onMutateResult + +`TOnMutateResult` | `undefined` + +##### context + +[`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md) + +#### Returns + +`unknown` + +*** + +### onSuccess()? + +```ts +optional onSuccess: (data, variables, onMutateResult, context) => unknown; +``` + +Defined in: [packages/query-core/src/types.ts:1212](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1212) + +#### Parameters + +##### data + +`TData` + +##### variables + +`TVariables` + +##### onMutateResult + +`TOnMutateResult` + +##### context + +[`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md) + +#### Returns + +`unknown` + +*** + +### retry? + +```ts +optional retry: RetryValue; +``` + +Defined in: [packages/query-core/src/types.ts:1239](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1239) + +If `false`, failed mutations will not retry by default. +If `true`, failed mutations will retry infinitely. +If set to an integer number, e.g. 3, failed mutations will retry until the failed mutation count meets that number. +If set to a function `(failureCount, error) => boolean` failed mutations will retry until the function returns false. + +Defaults to `0`. + +*** + +### retryDelay? + +```ts +optional retryDelay: RetryDelayValue; +``` + +Defined in: [packages/query-core/src/types.ts:1246](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1246) + +This function receives a `retryAttempt` integer and the actual Error and returns the delay to apply before the +next attempt in milliseconds. + +Defaults to a function that applies exponential backoff, capped at 30 seconds. + +*** + +### scope? + +```ts +optional scope: MutationScope; +``` + +Defined in: [packages/query-core/src/types.ts:1264](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1264) diff --git a/docs/framework/react/reference/interfaces/MutationState.md b/docs/framework/react/reference/interfaces/MutationState.md new file mode 100644 index 00000000000..bec050ec1d3 --- /dev/null +++ b/docs/framework/react/reference/interfaces/MutationState.md @@ -0,0 +1,142 @@ +--- +id: MutationState +title: MutationState +--- + +Defined in: [packages/query-core/src/mutation.ts:30](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L30) + +The raw state stored on a `Mutation` instance. This is the underlying state +that observer results (e.g. `MutationObserverResult`) are derived from. + +## Extended by + +- [`MutationObserverBaseResult`](MutationObserverBaseResult.md) + +## Type Parameters + +### TData + +`TData` = `unknown` + +### TError + +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) + +### TVariables + +`TVariables` = `unknown` + +### TOnMutateResult + +`TOnMutateResult` = `unknown` + +## Properties + +### context + +```ts +context: TOnMutateResult | undefined; +``` + +Defined in: [packages/query-core/src/mutation.ts:40](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L40) + +The value returned by `onMutate`, if defined. Passed to `onSuccess`, +`onError` and `onSettled` as the mutation's context. + +*** + +### data + +```ts +data: TData | undefined; +``` + +Defined in: [packages/query-core/src/mutation.ts:44](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L44) + +The last successfully resolved data for the mutation. + +*** + +### error + +```ts +error: TError | null; +``` + +Defined in: [packages/query-core/src/mutation.ts:49](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L49) + +The error object for the mutation, if the last attempt resulted in an error. +- Defaults to `null`. + +*** + +### failureCount + +```ts +failureCount: number; +``` + +Defined in: [packages/query-core/src/mutation.ts:53](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L53) + +The number of times the mutation function has failed for the current attempt. + +*** + +### failureReason + +```ts +failureReason: TError | null; +``` + +Defined in: [packages/query-core/src/mutation.ts:57](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L57) + +The reason the current attempt failed, as reported by the retryer. + +*** + +### isPaused + +```ts +isPaused: boolean; +``` + +Defined in: [packages/query-core/src/mutation.ts:62](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L62) + +Whether the mutation is currently paused (see network mode), or is +waiting for another mutation with the same `scope` to finish. + +*** + +### status + +```ts +status: MutationStatus; +``` + +Defined in: [packages/query-core/src/mutation.ts:66](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L66) + +The status of the mutation. + +*** + +### submittedAt + +```ts +submittedAt: number; +``` + +Defined in: [packages/query-core/src/mutation.ts:74](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L74) + +The timestamp for when the mutation was submitted. + +*** + +### variables + +```ts +variables: TVariables | undefined; +``` + +Defined in: [packages/query-core/src/mutation.ts:70](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L70) + +The variables the mutation was last called with. diff --git a/docs/framework/react/reference/interfaces/NotifyEvent.md b/docs/framework/react/reference/interfaces/NotifyEvent.md new file mode 100644 index 00000000000..4f5b023f49a --- /dev/null +++ b/docs/framework/react/reference/interfaces/NotifyEvent.md @@ -0,0 +1,16 @@ +--- +id: NotifyEvent +title: NotifyEvent +--- + +Defined in: [packages/query-core/src/types.ts:1539](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1539) + +## Properties + +### type + +```ts +type: NotifyEventType; +``` + +Defined in: [packages/query-core/src/types.ts:1540](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1540) diff --git a/docs/framework/react/reference/interfaces/OnlineManager.md b/docs/framework/react/reference/interfaces/OnlineManager.md new file mode 100644 index 00000000000..dcb42eefdfa --- /dev/null +++ b/docs/framework/react/reference/interfaces/OnlineManager.md @@ -0,0 +1,217 @@ +--- +id: OnlineManager +title: OnlineManager +redirect_from: + - reference/onlineManager + - framework/react/reference/onlineManager +--- + +Defined in: [packages/query-core/src/onlineManager.ts:15](https://github.com/TanStack/query/blob/main/packages/query-core/src/onlineManager.ts#L15) + +The `OnlineManager` manages the online state within TanStack Query. It can +be used to change the default event listeners or to manually change the +online state. + +By default, the `onlineManager` assumes an active network connection, and +listens to the `online` and `offline` events on the `window` object to +detect changes. + +## Extends + +- `Subscribable`\<`Listener`\> + +## Properties + +### listeners + +```ts +protected listeners: Set; +``` + +Defined in: [packages/query-core/src/subscribable.ts:2](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L2) + +#### Inherited from + +```ts +Subscribable.listeners +``` + +## Methods + +### hasListeners() + +```ts +hasListeners(): boolean; +``` + +Defined in: [packages/query-core/src/subscribable.ts:19](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L19) + +#### Returns + +`boolean` + +#### Inherited from + +```ts +Subscribable.hasListeners +``` + +*** + +### isOnline() + +```ts +isOnline(): boolean; +``` + +Defined in: [packages/query-core/src/onlineManager.ts:109](https://github.com/TanStack/query/blob/main/packages/query-core/src/onlineManager.ts#L109) + +`isOnline` can be used to get the current online state. + +#### Returns + +`boolean` + +*** + +### onSubscribe() + +```ts +protected onSubscribe(): void; +``` + +Defined in: [packages/query-core/src/onlineManager.ts:44](https://github.com/TanStack/query/blob/main/packages/query-core/src/onlineManager.ts#L44) + +#### Returns + +`void` + +#### Overrides + +```ts +Subscribable.onSubscribe +``` + +*** + +### onUnsubscribe() + +```ts +protected onUnsubscribe(): void; +``` + +Defined in: [packages/query-core/src/onlineManager.ts:50](https://github.com/TanStack/query/blob/main/packages/query-core/src/onlineManager.ts#L50) + +#### Returns + +`void` + +#### Overrides + +```ts +Subscribable.onUnsubscribe +``` + +*** + +### setEventListener() + +```ts +setEventListener(setup): void; +``` + +Defined in: [packages/query-core/src/onlineManager.ts:75](https://github.com/TanStack/query/blob/main/packages/query-core/src/onlineManager.ts#L75) + +`setEventListener` can be used to set a custom event listener that will +be used to determine the online state. The provided `setup` function +receives a `setOnline` callback that should be called with a `boolean` +whenever the online state changes. + +#### Parameters + +##### setup + +`SetupFn` + +#### Returns + +`void` + +#### Example + +```ts +import NetInfo from '@react-native-community/netinfo' +import { onlineManager } from '@tanstack/query-core' + +onlineManager.setEventListener((setOnline) => { + return NetInfo.addEventListener((state) => { + setOnline(!!state.isConnected) + }) +}) +``` + +*** + +### setOnline() + +```ts +setOnline(online): void; +``` + +Defined in: [packages/query-core/src/onlineManager.ts:95](https://github.com/TanStack/query/blob/main/packages/query-core/src/onlineManager.ts#L95) + +`setOnline` can be used to manually set the online state. + +#### Parameters + +##### online + +`boolean` + +#### Returns + +`void` + +#### Example + +```ts +import { onlineManager } from '@tanstack/query-core' + +// Set to online +onlineManager.setOnline(true) + +// Set to offline +onlineManager.setOnline(false) +``` + +*** + +### subscribe() + +```ts +subscribe(listener): () => void; +``` + +Defined in: [packages/query-core/src/subscribable.ts:8](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L8) + +#### Parameters + +##### listener + +`Listener` + +#### Returns + +```ts +(): void; +``` + +##### Returns + +`void` + +#### Inherited from + +```ts +Subscribable.subscribe +``` diff --git a/docs/framework/react/reference/interfaces/QueriesObserverOptions.md b/docs/framework/react/reference/interfaces/QueriesObserverOptions.md new file mode 100644 index 00000000000..68e7913885d --- /dev/null +++ b/docs/framework/react/reference/interfaces/QueriesObserverOptions.md @@ -0,0 +1,29 @@ +--- +id: QueriesObserverOptions +title: QueriesObserverOptions +--- + +Defined in: [packages/query-core/src/queriesObserver.ts:23](https://github.com/TanStack/query/blob/main/packages/query-core/src/queriesObserver.ts#L23) + +## Type Parameters + +### TCombinedResult + +`TCombinedResult` = [`QueryObserverResult`](../type-aliases/QueryObserverResult.md)[] + +## Properties + +### combine? + +```ts +optional combine: CombineFn; +``` + +Defined in: [packages/query-core/src/queriesObserver.ts:34](https://github.com/TanStack/query/blob/main/packages/query-core/src/queriesObserver.ts#L34) + +A function that combines the array of `QueryObserverResult`s (one per +observed query) into a single value. The combined value is memoized and +only recomputed when one of the underlying results, the query hashes, or +the `combine` function itself changes. + +Defaults to returning the array of `QueryObserverResult`s unchanged. diff --git a/docs/framework/react/reference/interfaces/QueryCacheConfig.md b/docs/framework/react/reference/interfaces/QueryCacheConfig.md new file mode 100644 index 00000000000..3c6aebe496f --- /dev/null +++ b/docs/framework/react/reference/interfaces/QueryCacheConfig.md @@ -0,0 +1,93 @@ +--- +id: QueryCacheConfig +title: QueryCacheConfig +--- + +Defined in: [packages/query-core/src/queryCache.ts:25](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryCache.ts#L25) + +Global callbacks that fire for every query handled by a `QueryCache`, regardless of which +component or observer triggered it. Unlike `QueryClient`'s `defaultOptions`, which a query can +override, these callbacks are always called. Unlike `MutationCacheConfig`'s callbacks, these +are fire-and-forget: their return value is not awaited before the query settles. + +## Properties + +### onError()? + +```ts +optional onError: (error, query) => void; +``` + +Defined in: [packages/query-core/src/queryCache.ts:27](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryCache.ts#L27) + +Called when any query in the cache encounters an error. + +#### Parameters + +##### error + +`Error` + +##### query + +[`Query`](../classes/Query.md)\<`unknown`, `unknown`, `unknown`\> + +#### Returns + +`void` + +*** + +### onSettled()? + +```ts +optional onSettled: (data, error, query) => void; +``` + +Defined in: [packages/query-core/src/queryCache.ts:34](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryCache.ts#L34) + +Called when any query in the cache is settled, either successfully or with an error. + +#### Parameters + +##### data + +`unknown` + +##### error + +`Error` | `null` + +##### query + +[`Query`](../classes/Query.md)\<`unknown`, `unknown`, `unknown`\> + +#### Returns + +`void` + +*** + +### onSuccess()? + +```ts +optional onSuccess: (data, query) => void; +``` + +Defined in: [packages/query-core/src/queryCache.ts:32](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryCache.ts#L32) + +Called when any query in the cache is successful. + +#### Parameters + +##### data + +`unknown` + +##### query + +[`Query`](../classes/Query.md)\<`unknown`, `unknown`, `unknown`\> + +#### Returns + +`void` diff --git a/docs/framework/react/reference/interfaces/QueryClientConfig.md b/docs/framework/react/reference/interfaces/QueryClientConfig.md new file mode 100644 index 00000000000..070e249491f --- /dev/null +++ b/docs/framework/react/reference/interfaces/QueryClientConfig.md @@ -0,0 +1,43 @@ +--- +id: QueryClientConfig +title: QueryClientConfig +--- + +Defined in: [packages/query-core/src/types.ts:1495](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1495) + +## Properties + +### defaultOptions? + +```ts +optional defaultOptions: DefaultOptions; +``` + +Defined in: [packages/query-core/src/types.ts:1504](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1504) + +Default options for all queries and mutations created through this client. + +*** + +### mutationCache? + +```ts +optional mutationCache: MutationCache; +``` + +Defined in: [packages/query-core/src/types.ts:1502](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1502) + +The mutation cache this client is connected to. A new `MutationCache` is created if not +provided. + +*** + +### queryCache? + +```ts +optional queryCache: QueryCache; +``` + +Defined in: [packages/query-core/src/types.ts:1497](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1497) + +The query cache this client is connected to. A new `QueryCache` is created if not provided. diff --git a/docs/framework/react/reference/interfaces/QueryErrorResetBoundaryProps.md b/docs/framework/react/reference/interfaces/QueryErrorResetBoundaryProps.md index 883b9c00a9f..7ef84ce8907 100644 --- a/docs/framework/react/reference/interfaces/QueryErrorResetBoundaryProps.md +++ b/docs/framework/react/reference/interfaces/QueryErrorResetBoundaryProps.md @@ -3,7 +3,7 @@ id: QueryErrorResetBoundaryProps title: QueryErrorResetBoundaryProps --- -Defined in: [react-query/src/QueryErrorResetBoundary.tsx:94](https://github.com/TanStack/query/blob/main/packages/react-query/src/QueryErrorResetBoundary.tsx#L94) +Defined in: [packages/react-query/src/QueryErrorResetBoundary.tsx:94](https://github.com/TanStack/query/blob/main/packages/react-query/src/QueryErrorResetBoundary.tsx#L94) The props accepted by `QueryErrorResetBoundary`. @@ -17,7 +17,7 @@ children: | QueryErrorResetBoundaryFunction; ``` -Defined in: [react-query/src/QueryErrorResetBoundary.tsx:99](https://github.com/TanStack/query/blob/main/packages/react-query/src/QueryErrorResetBoundary.tsx#L99) +Defined in: [packages/react-query/src/QueryErrorResetBoundary.tsx:99](https://github.com/TanStack/query/blob/main/packages/react-query/src/QueryErrorResetBoundary.tsx#L99) Either a plain node, or a function that receives the boundary's QueryErrorResetBoundaryValue and returns a node. diff --git a/docs/framework/react/reference/interfaces/QueryExecuteOptions.md b/docs/framework/react/reference/interfaces/QueryExecuteOptions.md new file mode 100644 index 00000000000..23d272eb25f --- /dev/null +++ b/docs/framework/react/reference/interfaces/QueryExecuteOptions.md @@ -0,0 +1,382 @@ +--- +id: QueryExecuteOptions +title: QueryExecuteOptions +--- + +Defined in: [packages/query-core/src/types.ts:574](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L574) + +## Extends + +- [`WithRequired`](../type-aliases/WithRequired.md)\<[`QueryOptions`](QueryOptions.md)\<`TQueryFnData`, `TError`, `TQueryData`, `TQueryKey`, `TPageParam`\>, `"queryKey"`\> + +## Type Parameters + +### TQueryFnData + +`TQueryFnData` = `unknown` + +### TError + +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) + +### TData + +`TData` = `TQueryFnData` + +### TQueryData + +`TQueryData` = `TQueryFnData` + +### TQueryKey + +`TQueryKey` *extends* [`QueryKey`](../type-aliases/QueryKey.md) = [`QueryKey`](../type-aliases/QueryKey.md) + +### TPageParam + +`TPageParam` = `never` + +## Properties + +### gcTime? + +```ts +optional gcTime: number; +``` + +Defined in: [packages/query-core/src/types.ts:277](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L277) + +The time in milliseconds that unused/inactive cache data remains in memory. +When a query's cache becomes unused or inactive, that cache data will be garbage collected after this duration. +When different garbage collection times are specified, the longest one will be used. +Setting it to `Infinity` will disable garbage collection. + +Defaults to `5 * 60 * 1000` (5 minutes), or `Infinity` during SSR. + +Note: the maximum allowed time is about 24 days, imposed by `setTimeout`'s 32-bit signed integer delay — see +`timeoutManager.setTimeoutProvider` for a workaround. + +#### Inherited from + +```ts +WithRequired.gcTime +``` + +*** + +### initialData? + +```ts +optional initialData: + | TQueryData +| InitialDataFunction; +``` + +Defined in: [packages/query-core/src/types.ts:317](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L317) + +If set, this value will be used as the initial data for the query cache (as long as the query hasn't been +created or cached yet). +If set to a function, the function will be called **once** during the shared/root query initialization, and be +expected to synchronously return the initial data. +Initial data is considered stale by default unless a `staleTime` has been set. +`initialData` **is persisted** to the cache. + +#### Inherited from + +```ts +WithRequired.initialData +``` + +*** + +### initialDataUpdatedAt? + +```ts +optional initialDataUpdatedAt: number | () => number | undefined; +``` + +Defined in: [packages/query-core/src/types.ts:321](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L321) + +If set, this value will be used as the time (in milliseconds) of when the `initialData` itself was last updated. + +#### Inherited from + +```ts +WithRequired.initialDataUpdatedAt +``` + +*** + +### initialPageParam? + +```ts +optional initialPageParam: undefined; +``` + +Defined in: [packages/query-core/src/types.ts:585](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L585) + +*** + +### maxPages? + +```ts +optional maxPages: number; +``` + +Defined in: [packages/query-core/src/types.ts:345](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L345) + +Maximum number of pages to store in the data of an infinite query. + +#### Inherited from + +```ts +WithRequired.maxPages +``` + +*** + +### meta? + +```ts +optional meta: Record; +``` + +Defined in: [packages/query-core/src/types.ts:341](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L341) + +Additional payload to be stored on each query. +Use this property to pass information that can be used in other places. + +#### Inherited from + +```ts +WithRequired.meta +``` + +*** + +### networkMode? + +```ts +optional networkMode: NetworkMode; +``` + +Defined in: [packages/query-core/src/types.ts:265](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L265) + +Controls whether a query is allowed to run based on the current network connectivity. + +Defaults to `'online'`. + +#### See + +[Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. + +#### Inherited from + +```ts +WithRequired.networkMode +``` + +*** + +### persister? + +```ts +optional persister: QueryPersister, TPageParam>; +``` + +Defined in: [packages/query-core/src/types.ts:290](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L290) + +This option can be used to persist the result of a query to an external storage, bypassing the need to actually +call the `queryFn`. Useful for persisting a query's data across e.g. server/client boundaries. + +#### Inherited from + +```ts +WithRequired.persister +``` + +*** + +### queryFn? + +```ts +optional queryFn: + | typeof skipToken +| QueryFunction; +``` + +Defined in: [packages/query-core/src/types.ts:285](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L285) + +The function that the query will use to request data. +Required, unless a default query function has been set via `queryClient.setQueryDefaults` or +`queryClient.setDefaultOptions`. +Receives a [QueryFunctionContext](../type-aliases/QueryFunctionContext.md). +Must return a promise that will either resolve data or throw an error. The data cannot be `undefined`. + +#### Inherited from + +```ts +WithRequired.queryFn +``` + +*** + +### queryHash? + +```ts +optional queryHash: string; +``` + +Defined in: [packages/query-core/src/types.ts:295](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L295) + +The hashed form of `queryKey`, computed with `queryKeyHashFn` (or the default hashing function otherwise). Used +as the actual cache key internally. + +#### Inherited from + +```ts +WithRequired.queryHash +``` + +*** + +### queryKey + +```ts +queryKey: TQueryKey & object; +``` + +Defined in: [packages/query-core/src/types.ts:304](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L304) + +The query key to use for this query. + +The query key will be hashed into a stable hash. See [Query Keys](https://tanstack.com/query/latest/docs/framework/react/guides/query-keys) +for more information. + +The query will automatically update when this key changes (as long as `enabled` is not set to `false`). + +#### Inherited from + +```ts +WithRequired.queryKey +``` + +*** + +### queryKeyHashFn? + +```ts +optional queryKeyHashFn: QueryKeyHashFunction; +``` + +Defined in: [packages/query-core/src/types.ts:308](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L308) + +If specified, this function is used to hash the `queryKey` to a string. + +#### Inherited from + +```ts +WithRequired.queryKeyHashFn +``` + +*** + +### retry? + +```ts +optional retry: RetryValue; +``` + +Defined in: [packages/query-core/src/types.ts:246](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L246) + +If `false`, failed queries will not retry by default. +If `true`, failed queries will retry infinitely. +If set to an integer number, e.g. 3, failed queries will retry until the failed query count meets that number. +If set to a function `(failureCount, error) => boolean` failed queries will retry until the function returns false. + +Defaults to `3` on the client and `0` on the server. + +#### Inherited from + +```ts +WithRequired.retry +``` + +*** + +### retryDelay? + +```ts +optional retryDelay: RetryDelayValue; +``` + +Defined in: [packages/query-core/src/types.ts:258](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L258) + +This function receives a `retryAttempt` integer and the actual Error and returns the delay to apply before the +next attempt in milliseconds. + +A function like `attempt => Math.min(attempt > 1 ? 2 ** attempt * 1000 : 1000, 30 * 1000)` applies exponential +backoff. + +A function like `attempt => attempt * 1000` applies linear backoff. + +Defaults to a function that applies exponential backoff, capped at 30 seconds. + +#### Inherited from + +```ts +WithRequired.retryDelay +``` + +*** + +### select()? + +```ts +optional select: (data) => TData; +``` + +Defined in: [packages/query-core/src/types.ts:586](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L586) + +#### Parameters + +##### data + +`TQueryData` + +#### Returns + +`TData` + +*** + +### staleTime? + +```ts +optional staleTime: StaleTimeFunction; +``` + +Defined in: [packages/query-core/src/types.ts:591](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L591) + +The time in milliseconds after data is considered stale. +If the data is fresh it will be returned from the cache. + +*** + +### structuralSharing? + +```ts +optional structuralSharing: boolean | (oldData, newData) => unknown; +``` + +Defined in: [packages/query-core/src/types.ts:330](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L330) + +Set this to `false` to disable structural sharing between query results. +Set this to a function which accepts the old and new data and returns resolved data of the same type to implement custom structural sharing logic. + +Defaults to `true`. + +#### Inherited from + +```ts +WithRequired.structuralSharing +``` diff --git a/docs/framework/react/reference/interfaces/QueryFilters.md b/docs/framework/react/reference/interfaces/QueryFilters.md new file mode 100644 index 00000000000..749e4283d0d --- /dev/null +++ b/docs/framework/react/reference/interfaces/QueryFilters.md @@ -0,0 +1,104 @@ +--- +id: QueryFilters +title: QueryFilters +--- + +Defined in: [packages/query-core/src/utils.ts:31](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L31) + +Filters used to select queries, for example in `queryClient.getQueriesData` or `queryClient.invalidateQueries`. +All provided filters must match; filters that are left unspecified are ignored. + +## Extended by + +- [`InvalidateQueryFilters`](InvalidateQueryFilters.md) +- [`RefetchQueryFilters`](RefetchQueryFilters.md) + +## Type Parameters + +### TQueryKey + +`TQueryKey` *extends* [`QueryKey`](../type-aliases/QueryKey.md) = [`QueryKey`](../type-aliases/QueryKey.md) + +## Properties + +### exact? + +```ts +optional exact: boolean; +``` + +Defined in: [packages/query-core/src/utils.ts:41](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L41) + +Match query key exactly + +*** + +### fetchStatus? + +```ts +optional fetchStatus: FetchStatus; +``` + +Defined in: [packages/query-core/src/utils.ts:57](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L57) + +Include queries matching their fetchStatus + +*** + +### predicate()? + +```ts +optional predicate: (query) => boolean; +``` + +Defined in: [packages/query-core/src/utils.ts:45](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L45) + +Include queries matching this predicate function + +#### Parameters + +##### query + +[`Query`](../classes/Query.md) + +#### Returns + +`boolean` + +*** + +### queryKey? + +```ts +optional queryKey: TQueryKey | TuplePrefixes; +``` + +Defined in: [packages/query-core/src/utils.ts:49](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L49) + +Include queries matching this query key + +*** + +### stale? + +```ts +optional stale: boolean; +``` + +Defined in: [packages/query-core/src/utils.ts:53](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L53) + +Include or exclude stale queries + +*** + +### type? + +```ts +optional type: QueryTypeFilter; +``` + +Defined in: [packages/query-core/src/utils.ts:37](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L37) + +Filter to active queries, inactive queries or all queries + +Defaults to `'all'`. diff --git a/docs/framework/react/reference/interfaces/QueryObserverBaseResult.md b/docs/framework/react/reference/interfaces/QueryObserverBaseResult.md new file mode 100644 index 00000000000..ef5fe0ad757 --- /dev/null +++ b/docs/framework/react/reference/interfaces/QueryObserverBaseResult.md @@ -0,0 +1,358 @@ +--- +id: QueryObserverBaseResult +title: QueryObserverBaseResult +--- + +Defined in: [packages/query-core/src/types.ts:764](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L764) + +## Extended by + +- [`QueryObserverPendingResult`](QueryObserverPendingResult.md) +- [`QueryObserverLoadingResult`](QueryObserverLoadingResult.md) +- [`QueryObserverLoadingErrorResult`](QueryObserverLoadingErrorResult.md) +- [`QueryObserverRefetchErrorResult`](QueryObserverRefetchErrorResult.md) +- [`QueryObserverSuccessResult`](QueryObserverSuccessResult.md) +- [`QueryObserverPlaceholderResult`](QueryObserverPlaceholderResult.md) +- [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md) + +## Type Parameters + +### TData + +`TData` = `unknown` + +### TError + +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) + +## Properties + +### data + +```ts +data: TData | undefined; +``` + +Defined in: [packages/query-core/src/types.ts:771](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L771) + +The last successfully resolved data for the query. + +*** + +### dataUpdatedAt + +```ts +dataUpdatedAt: number; +``` + +Defined in: [packages/query-core/src/types.ts:775](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L775) + +The timestamp for when the query most recently returned the `status` as `"success"`. + +*** + +### error + +```ts +error: TError | null; +``` + +Defined in: [packages/query-core/src/types.ts:780](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L780) + +The error object for the query, if an error was thrown. +- Defaults to `null`. + +*** + +### errorUpdateCount + +```ts +errorUpdateCount: number; +``` + +Defined in: [packages/query-core/src/types.ts:799](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L799) + +The sum of all errors. + +*** + +### errorUpdatedAt + +```ts +errorUpdatedAt: number; +``` + +Defined in: [packages/query-core/src/types.ts:784](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L784) + +The timestamp for when the query most recently returned the `status` as `"error"`. + +*** + +### failureCount + +```ts +failureCount: number; +``` + +Defined in: [packages/query-core/src/types.ts:790](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L790) + +The failure count for the query. +- Incremented every time the query fails. +- Reset to `0` when the query succeeds. + +*** + +### failureReason + +```ts +failureReason: TError | null; +``` + +Defined in: [packages/query-core/src/types.ts:795](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L795) + +The failure reason for the query retry. +- Reset to `null` when the query succeeds. + +*** + +### fetchStatus + +```ts +fetchStatus: FetchStatus; +``` + +Defined in: [packages/query-core/src/types.ts:889](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L889) + +The fetch status of the query. +- `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. +- `paused`: The query wanted to fetch, but has been `paused`. +- `idle`: The query is not fetching. +- See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. + +*** + +### isEnabled + +```ts +isEnabled: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:867](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L867) + +`true` if this observer is enabled, `false` otherwise. + +*** + +### isError + +```ts +isError: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:804](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L804) + +A derived boolean from the `status` variable, provided for convenience. +- `true` if the query attempt resulted in an error. + +*** + +### isFetched + +```ts +isFetched: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:808](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L808) + +Will be `true` if the query has been fetched. + +*** + +### isFetchedAfterMount + +```ts +isFetchedAfterMount: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:813](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L813) + +Will be `true` if the query has been fetched after the component mounted. +- This property can be used to not show any previously cached data. + +*** + +### isFetching + +```ts +isFetching: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:818](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L818) + +A derived boolean from the `fetchStatus` variable, provided for convenience. +- `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. + +*** + +### ~~isInitialLoading~~ + +```ts +isInitialLoading: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:836](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L836) + +#### Deprecated + +`isInitialLoading` is being deprecated in favor of `isLoading` +and will be removed in the next major version. + +*** + +### isLoading + +```ts +isLoading: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:823](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L823) + +Is `true` whenever the first fetch for a query is in-flight. +- Is the same as `isFetching && isPending`. + +*** + +### isLoadingError + +```ts +isLoadingError: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:831](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L831) + +Will be `true` if the query failed while fetching for the first time. + +*** + +### isPaused + +```ts +isPaused: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:841](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L841) + +A derived boolean from the `fetchStatus` variable, provided for convenience. +- The query wanted to fetch, but has been `paused`. + +*** + +### isPending + +```ts +isPending: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:827](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L827) + +Will be `pending` if there's no cached data and no query attempt was finished yet. + +*** + +### isPlaceholderData + +```ts +isPlaceholderData: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:845](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L845) + +Will be `true` if the data shown is the placeholder data. + +*** + +### isRefetchError + +```ts +isRefetchError: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:849](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L849) + +Will be `true` if the query failed while refetching. + +*** + +### isRefetching + +```ts +isRefetching: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:854](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L854) + +Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. +- Is the same as `isFetching && !isPending`. + +*** + +### isStale + +```ts +isStale: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:858](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L858) + +Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. + +*** + +### isSuccess + +```ts +isSuccess: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:863](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L863) + +A derived boolean from the `status` variable, provided for convenience. +- `true` if the query has received a response with no errors and is ready to display its data. + +*** + +### refetch() + +```ts +refetch: (options?) => Promise>; +``` + +Defined in: [packages/query-core/src/types.ts:871](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L871) + +A function to manually refetch the query. + +#### Parameters + +##### options? + +[`RefetchOptions`](RefetchOptions.md) + +#### Returns + +`Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> + +*** + +### status + +```ts +status: QueryStatus; +``` + +Defined in: [packages/query-core/src/types.ts:881](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L881) + +The status of the query. +- Will be: + - `pending` if there's no cached data and no query attempt was finished yet. + - `error` if the query attempt resulted in an error. + - `success` if the query has received a response with no errors and is ready to display its data. diff --git a/docs/framework/react/reference/interfaces/QueryObserverLoadingErrorResult.md b/docs/framework/react/reference/interfaces/QueryObserverLoadingErrorResult.md new file mode 100644 index 00000000000..21b39fbffe3 --- /dev/null +++ b/docs/framework/react/reference/interfaces/QueryObserverLoadingErrorResult.md @@ -0,0 +1,452 @@ +--- +id: QueryObserverLoadingErrorResult +title: QueryObserverLoadingErrorResult +--- + +Defined in: [packages/query-core/src/types.ts:923](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L923) + +## Extends + +- [`QueryObserverBaseResult`](QueryObserverBaseResult.md)\<`TData`, `TError`\> + +## Type Parameters + +### TData + +`TData` = `unknown` + +### TError + +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) + +## Properties + +### data + +```ts +data: undefined; +``` + +Defined in: [packages/query-core/src/types.ts:927](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L927) + +The last successfully resolved data for the query. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`data`](QueryObserverBaseResult.md#data) + +*** + +### dataUpdatedAt + +```ts +dataUpdatedAt: number; +``` + +Defined in: [packages/query-core/src/types.ts:775](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L775) + +The timestamp for when the query most recently returned the `status` as `"success"`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`dataUpdatedAt`](QueryObserverBaseResult.md#dataupdatedat) + +*** + +### error + +```ts +error: TError; +``` + +Defined in: [packages/query-core/src/types.ts:928](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L928) + +The error object for the query, if an error was thrown. +- Defaults to `null`. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`error`](QueryObserverBaseResult.md#error) + +*** + +### errorUpdateCount + +```ts +errorUpdateCount: number; +``` + +Defined in: [packages/query-core/src/types.ts:799](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L799) + +The sum of all errors. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`errorUpdateCount`](QueryObserverBaseResult.md#errorupdatecount) + +*** + +### errorUpdatedAt + +```ts +errorUpdatedAt: number; +``` + +Defined in: [packages/query-core/src/types.ts:784](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L784) + +The timestamp for when the query most recently returned the `status` as `"error"`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`errorUpdatedAt`](QueryObserverBaseResult.md#errorupdatedat) + +*** + +### failureCount + +```ts +failureCount: number; +``` + +Defined in: [packages/query-core/src/types.ts:790](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L790) + +The failure count for the query. +- Incremented every time the query fails. +- Reset to `0` when the query succeeds. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`failureCount`](QueryObserverBaseResult.md#failurecount) + +*** + +### failureReason + +```ts +failureReason: TError | null; +``` + +Defined in: [packages/query-core/src/types.ts:795](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L795) + +The failure reason for the query retry. +- Reset to `null` when the query succeeds. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`failureReason`](QueryObserverBaseResult.md#failurereason) + +*** + +### fetchStatus + +```ts +fetchStatus: FetchStatus; +``` + +Defined in: [packages/query-core/src/types.ts:889](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L889) + +The fetch status of the query. +- `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. +- `paused`: The query wanted to fetch, but has been `paused`. +- `idle`: The query is not fetching. +- See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`fetchStatus`](QueryObserverBaseResult.md#fetchstatus) + +*** + +### isEnabled + +```ts +isEnabled: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:867](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L867) + +`true` if this observer is enabled, `false` otherwise. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isEnabled`](QueryObserverBaseResult.md#isenabled) + +*** + +### isError + +```ts +isError: true; +``` + +Defined in: [packages/query-core/src/types.ts:929](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L929) + +A derived boolean from the `status` variable, provided for convenience. +- `true` if the query attempt resulted in an error. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isError`](QueryObserverBaseResult.md#iserror) + +*** + +### isFetched + +```ts +isFetched: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:808](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L808) + +Will be `true` if the query has been fetched. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isFetched`](QueryObserverBaseResult.md#isfetched) + +*** + +### isFetchedAfterMount + +```ts +isFetchedAfterMount: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:813](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L813) + +Will be `true` if the query has been fetched after the component mounted. +- This property can be used to not show any previously cached data. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isFetchedAfterMount`](QueryObserverBaseResult.md#isfetchedaftermount) + +*** + +### isFetching + +```ts +isFetching: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:818](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L818) + +A derived boolean from the `fetchStatus` variable, provided for convenience. +- `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isFetching`](QueryObserverBaseResult.md#isfetching) + +*** + +### ~~isInitialLoading~~ + +```ts +isInitialLoading: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:836](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L836) + +#### Deprecated + +`isInitialLoading` is being deprecated in favor of `isLoading` +and will be removed in the next major version. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isInitialLoading`](QueryObserverBaseResult.md#isinitialloading) + +*** + +### isLoading + +```ts +isLoading: false; +``` + +Defined in: [packages/query-core/src/types.ts:931](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L931) + +Is `true` whenever the first fetch for a query is in-flight. +- Is the same as `isFetching && isPending`. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoading`](QueryObserverBaseResult.md#isloading) + +*** + +### isLoadingError + +```ts +isLoadingError: true; +``` + +Defined in: [packages/query-core/src/types.ts:932](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L932) + +Will be `true` if the query failed while fetching for the first time. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoadingError`](QueryObserverBaseResult.md#isloadingerror) + +*** + +### isPaused + +```ts +isPaused: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:841](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L841) + +A derived boolean from the `fetchStatus` variable, provided for convenience. +- The query wanted to fetch, but has been `paused`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPaused`](QueryObserverBaseResult.md#ispaused) + +*** + +### isPending + +```ts +isPending: false; +``` + +Defined in: [packages/query-core/src/types.ts:930](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L930) + +Will be `pending` if there's no cached data and no query attempt was finished yet. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPending`](QueryObserverBaseResult.md#ispending) + +*** + +### isPlaceholderData + +```ts +isPlaceholderData: false; +``` + +Defined in: [packages/query-core/src/types.ts:935](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L935) + +Will be `true` if the data shown is the placeholder data. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPlaceholderData`](QueryObserverBaseResult.md#isplaceholderdata) + +*** + +### isRefetchError + +```ts +isRefetchError: false; +``` + +Defined in: [packages/query-core/src/types.ts:933](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L933) + +Will be `true` if the query failed while refetching. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetchError`](QueryObserverBaseResult.md#isrefetcherror) + +*** + +### isRefetching + +```ts +isRefetching: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:854](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L854) + +Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. +- Is the same as `isFetching && !isPending`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetching`](QueryObserverBaseResult.md#isrefetching) + +*** + +### isStale + +```ts +isStale: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:858](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L858) + +Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isStale`](QueryObserverBaseResult.md#isstale) + +*** + +### isSuccess + +```ts +isSuccess: false; +``` + +Defined in: [packages/query-core/src/types.ts:934](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L934) + +A derived boolean from the `status` variable, provided for convenience. +- `true` if the query has received a response with no errors and is ready to display its data. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isSuccess`](QueryObserverBaseResult.md#issuccess) + +*** + +### refetch() + +```ts +refetch: (options?) => Promise>; +``` + +Defined in: [packages/query-core/src/types.ts:871](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L871) + +A function to manually refetch the query. + +#### Parameters + +##### options? + +[`RefetchOptions`](RefetchOptions.md) + +#### Returns + +`Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`refetch`](QueryObserverBaseResult.md#refetch) + +*** + +### status + +```ts +status: "error"; +``` + +Defined in: [packages/query-core/src/types.ts:936](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L936) + +The status of the query. +- Will be: + - `pending` if there's no cached data and no query attempt was finished yet. + - `error` if the query attempt resulted in an error. + - `success` if the query has received a response with no errors and is ready to display its data. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`status`](QueryObserverBaseResult.md#status) diff --git a/docs/framework/react/reference/interfaces/QueryObserverLoadingResult.md b/docs/framework/react/reference/interfaces/QueryObserverLoadingResult.md new file mode 100644 index 00000000000..4966390127f --- /dev/null +++ b/docs/framework/react/reference/interfaces/QueryObserverLoadingResult.md @@ -0,0 +1,452 @@ +--- +id: QueryObserverLoadingResult +title: QueryObserverLoadingResult +--- + +Defined in: [packages/query-core/src/types.ts:907](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L907) + +## Extends + +- [`QueryObserverBaseResult`](QueryObserverBaseResult.md)\<`TData`, `TError`\> + +## Type Parameters + +### TData + +`TData` = `unknown` + +### TError + +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) + +## Properties + +### data + +```ts +data: undefined; +``` + +Defined in: [packages/query-core/src/types.ts:911](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L911) + +The last successfully resolved data for the query. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`data`](QueryObserverBaseResult.md#data) + +*** + +### dataUpdatedAt + +```ts +dataUpdatedAt: number; +``` + +Defined in: [packages/query-core/src/types.ts:775](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L775) + +The timestamp for when the query most recently returned the `status` as `"success"`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`dataUpdatedAt`](QueryObserverBaseResult.md#dataupdatedat) + +*** + +### error + +```ts +error: null; +``` + +Defined in: [packages/query-core/src/types.ts:912](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L912) + +The error object for the query, if an error was thrown. +- Defaults to `null`. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`error`](QueryObserverBaseResult.md#error) + +*** + +### errorUpdateCount + +```ts +errorUpdateCount: number; +``` + +Defined in: [packages/query-core/src/types.ts:799](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L799) + +The sum of all errors. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`errorUpdateCount`](QueryObserverBaseResult.md#errorupdatecount) + +*** + +### errorUpdatedAt + +```ts +errorUpdatedAt: number; +``` + +Defined in: [packages/query-core/src/types.ts:784](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L784) + +The timestamp for when the query most recently returned the `status` as `"error"`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`errorUpdatedAt`](QueryObserverBaseResult.md#errorupdatedat) + +*** + +### failureCount + +```ts +failureCount: number; +``` + +Defined in: [packages/query-core/src/types.ts:790](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L790) + +The failure count for the query. +- Incremented every time the query fails. +- Reset to `0` when the query succeeds. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`failureCount`](QueryObserverBaseResult.md#failurecount) + +*** + +### failureReason + +```ts +failureReason: TError | null; +``` + +Defined in: [packages/query-core/src/types.ts:795](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L795) + +The failure reason for the query retry. +- Reset to `null` when the query succeeds. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`failureReason`](QueryObserverBaseResult.md#failurereason) + +*** + +### fetchStatus + +```ts +fetchStatus: FetchStatus; +``` + +Defined in: [packages/query-core/src/types.ts:889](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L889) + +The fetch status of the query. +- `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. +- `paused`: The query wanted to fetch, but has been `paused`. +- `idle`: The query is not fetching. +- See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`fetchStatus`](QueryObserverBaseResult.md#fetchstatus) + +*** + +### isEnabled + +```ts +isEnabled: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:867](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L867) + +`true` if this observer is enabled, `false` otherwise. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isEnabled`](QueryObserverBaseResult.md#isenabled) + +*** + +### isError + +```ts +isError: false; +``` + +Defined in: [packages/query-core/src/types.ts:913](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L913) + +A derived boolean from the `status` variable, provided for convenience. +- `true` if the query attempt resulted in an error. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isError`](QueryObserverBaseResult.md#iserror) + +*** + +### isFetched + +```ts +isFetched: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:808](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L808) + +Will be `true` if the query has been fetched. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isFetched`](QueryObserverBaseResult.md#isfetched) + +*** + +### isFetchedAfterMount + +```ts +isFetchedAfterMount: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:813](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L813) + +Will be `true` if the query has been fetched after the component mounted. +- This property can be used to not show any previously cached data. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isFetchedAfterMount`](QueryObserverBaseResult.md#isfetchedaftermount) + +*** + +### isFetching + +```ts +isFetching: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:818](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L818) + +A derived boolean from the `fetchStatus` variable, provided for convenience. +- `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isFetching`](QueryObserverBaseResult.md#isfetching) + +*** + +### ~~isInitialLoading~~ + +```ts +isInitialLoading: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:836](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L836) + +#### Deprecated + +`isInitialLoading` is being deprecated in favor of `isLoading` +and will be removed in the next major version. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isInitialLoading`](QueryObserverBaseResult.md#isinitialloading) + +*** + +### isLoading + +```ts +isLoading: true; +``` + +Defined in: [packages/query-core/src/types.ts:915](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L915) + +Is `true` whenever the first fetch for a query is in-flight. +- Is the same as `isFetching && isPending`. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoading`](QueryObserverBaseResult.md#isloading) + +*** + +### isLoadingError + +```ts +isLoadingError: false; +``` + +Defined in: [packages/query-core/src/types.ts:916](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L916) + +Will be `true` if the query failed while fetching for the first time. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoadingError`](QueryObserverBaseResult.md#isloadingerror) + +*** + +### isPaused + +```ts +isPaused: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:841](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L841) + +A derived boolean from the `fetchStatus` variable, provided for convenience. +- The query wanted to fetch, but has been `paused`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPaused`](QueryObserverBaseResult.md#ispaused) + +*** + +### isPending + +```ts +isPending: true; +``` + +Defined in: [packages/query-core/src/types.ts:914](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L914) + +Will be `pending` if there's no cached data and no query attempt was finished yet. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPending`](QueryObserverBaseResult.md#ispending) + +*** + +### isPlaceholderData + +```ts +isPlaceholderData: false; +``` + +Defined in: [packages/query-core/src/types.ts:919](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L919) + +Will be `true` if the data shown is the placeholder data. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPlaceholderData`](QueryObserverBaseResult.md#isplaceholderdata) + +*** + +### isRefetchError + +```ts +isRefetchError: false; +``` + +Defined in: [packages/query-core/src/types.ts:917](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L917) + +Will be `true` if the query failed while refetching. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetchError`](QueryObserverBaseResult.md#isrefetcherror) + +*** + +### isRefetching + +```ts +isRefetching: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:854](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L854) + +Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. +- Is the same as `isFetching && !isPending`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetching`](QueryObserverBaseResult.md#isrefetching) + +*** + +### isStale + +```ts +isStale: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:858](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L858) + +Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isStale`](QueryObserverBaseResult.md#isstale) + +*** + +### isSuccess + +```ts +isSuccess: false; +``` + +Defined in: [packages/query-core/src/types.ts:918](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L918) + +A derived boolean from the `status` variable, provided for convenience. +- `true` if the query has received a response with no errors and is ready to display its data. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isSuccess`](QueryObserverBaseResult.md#issuccess) + +*** + +### refetch() + +```ts +refetch: (options?) => Promise>; +``` + +Defined in: [packages/query-core/src/types.ts:871](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L871) + +A function to manually refetch the query. + +#### Parameters + +##### options? + +[`RefetchOptions`](RefetchOptions.md) + +#### Returns + +`Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`refetch`](QueryObserverBaseResult.md#refetch) + +*** + +### status + +```ts +status: "pending"; +``` + +Defined in: [packages/query-core/src/types.ts:920](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L920) + +The status of the query. +- Will be: + - `pending` if there's no cached data and no query attempt was finished yet. + - `error` if the query attempt resulted in an error. + - `success` if the query has received a response with no errors and is ready to display its data. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`status`](QueryObserverBaseResult.md#status) diff --git a/docs/framework/react/reference/interfaces/QueryObserverOptions.md b/docs/framework/react/reference/interfaces/QueryObserverOptions.md new file mode 100644 index 00000000000..c325b42f230 --- /dev/null +++ b/docs/framework/react/reference/interfaces/QueryObserverOptions.md @@ -0,0 +1,561 @@ +--- +id: QueryObserverOptions +title: QueryObserverOptions +--- + +Defined in: [packages/query-core/src/types.ts:380](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L380) + +## Extends + +- [`WithRequired`](../type-aliases/WithRequired.md)\<[`QueryOptions`](QueryOptions.md)\<`TQueryFnData`, `TError`, `TQueryData`, `TQueryKey`, `TPageParam`\>, `"queryKey"`\> + +## Extended by + +- [`InfiniteQueryObserverOptions`](InfiniteQueryObserverOptions.md) +- [`UseBaseQueryOptions`](UseBaseQueryOptions.md) + +## Type Parameters + +### TQueryFnData + +`TQueryFnData` = `unknown` + +### TError + +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) + +### TData + +`TData` = `TQueryFnData` + +### TQueryData + +`TQueryData` = `TQueryFnData` + +### TQueryKey + +`TQueryKey` *extends* [`QueryKey`](../type-aliases/QueryKey.md) = [`QueryKey`](../type-aliases/QueryKey.md) + +### TPageParam + +`TPageParam` = `never` + +## Properties + +### enabled? + +```ts +optional enabled: QueryBooleanOption; +``` + +Defined in: [packages/query-core/src/types.ts:398](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L398) + +Set this to `false` or a function that returns `false` to disable automatic refetching when the query mounts or changes query keys. +To refetch the query, use the `refetch` method returned from the `useQuery` instance. +Accepts a boolean or function that returns a boolean. + +Defaults to `true`. + +*** + +### gcTime? + +```ts +optional gcTime: number; +``` + +Defined in: [packages/query-core/src/types.ts:277](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L277) + +The time in milliseconds that unused/inactive cache data remains in memory. +When a query's cache becomes unused or inactive, that cache data will be garbage collected after this duration. +When different garbage collection times are specified, the longest one will be used. +Setting it to `Infinity` will disable garbage collection. + +Defaults to `5 * 60 * 1000` (5 minutes), or `Infinity` during SSR. + +Note: the maximum allowed time is about 24 days, imposed by `setTimeout`'s 32-bit signed integer delay — see +`timeoutManager.setTimeoutProvider` for a workaround. + +#### Inherited from + +```ts +WithRequired.gcTime +``` + +*** + +### initialData? + +```ts +optional initialData: + | TQueryData +| InitialDataFunction; +``` + +Defined in: [packages/query-core/src/types.ts:317](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L317) + +If set, this value will be used as the initial data for the query cache (as long as the query hasn't been +created or cached yet). +If set to a function, the function will be called **once** during the shared/root query initialization, and be +expected to synchronously return the initial data. +Initial data is considered stale by default unless a `staleTime` has been set. +`initialData` **is persisted** to the cache. + +#### Inherited from + +```ts +WithRequired.initialData +``` + +*** + +### initialDataUpdatedAt? + +```ts +optional initialDataUpdatedAt: number | () => number | undefined; +``` + +Defined in: [packages/query-core/src/types.ts:321](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L321) + +If set, this value will be used as the time (in milliseconds) of when the `initialData` itself was last updated. + +#### Inherited from + +```ts +WithRequired.initialDataUpdatedAt +``` + +*** + +### maxPages? + +```ts +optional maxPages: number; +``` + +Defined in: [packages/query-core/src/types.ts:345](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L345) + +Maximum number of pages to store in the data of an infinite query. + +#### Inherited from + +```ts +WithRequired.maxPages +``` + +*** + +### meta? + +```ts +optional meta: Record; +``` + +Defined in: [packages/query-core/src/types.ts:341](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L341) + +Additional payload to be stored on each query. +Use this property to pass information that can be used in other places. + +#### Inherited from + +```ts +WithRequired.meta +``` + +*** + +### networkMode? + +```ts +optional networkMode: NetworkMode; +``` + +Defined in: [packages/query-core/src/types.ts:265](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L265) + +Controls whether a query is allowed to run based on the current network connectivity. + +Defaults to `'online'`. + +#### See + +[Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. + +#### Inherited from + +```ts +WithRequired.networkMode +``` + +*** + +### notifyOnChangeProps? + +```ts +optional notifyOnChangeProps: NotifyOnChangeProps; +``` + +Defined in: [packages/query-core/src/types.ts:484](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L484) + +If set, the component will only re-render if any of the listed properties change. +When set to `['data', 'error']`, the component will only re-render when the `data` or `error` properties change. +When set to `'all'`, the component will re-render whenever a query is updated. +When set to a function, the function will be executed to compute the list of properties. + +Defaults to `undefined`, in which case property access is tracked automatically, and the +component only re-renders when one of the tracked properties changes. + +*** + +### persister? + +```ts +optional persister: QueryPersister, TPageParam>; +``` + +Defined in: [packages/query-core/src/types.ts:290](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L290) + +This option can be used to persist the result of a query to an external storage, bypassing the need to actually +call the `queryFn`. Useful for persisting a query's data across e.g. server/client boundaries. + +#### Inherited from + +```ts +WithRequired.persister +``` + +*** + +### placeholderData? + +```ts +optional placeholderData: + | NonFunctionGuard +| PlaceholderDataFunction, TError, NonFunctionGuard, TQueryKey>; +``` + +Defined in: [packages/query-core/src/types.ts:511](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L511) + +If set, this value will be used as the placeholder data for this particular query observer while the query is still in the `loading` data and no initialData has been provided. + +*** + +### queryFn? + +```ts +optional queryFn: + | typeof skipToken +| QueryFunction; +``` + +Defined in: [packages/query-core/src/types.ts:285](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L285) + +The function that the query will use to request data. +Required, unless a default query function has been set via `queryClient.setQueryDefaults` or +`queryClient.setDefaultOptions`. +Receives a [QueryFunctionContext](../type-aliases/QueryFunctionContext.md). +Must return a promise that will either resolve data or throw an error. The data cannot be `undefined`. + +#### Inherited from + +```ts +WithRequired.queryFn +``` + +*** + +### queryHash? + +```ts +optional queryHash: string; +``` + +Defined in: [packages/query-core/src/types.ts:295](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L295) + +The hashed form of `queryKey`, computed with `queryKeyHashFn` (or the default hashing function otherwise). Used +as the actual cache key internally. + +#### Inherited from + +```ts +WithRequired.queryHash +``` + +*** + +### queryKey + +```ts +queryKey: TQueryKey & object; +``` + +Defined in: [packages/query-core/src/types.ts:304](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L304) + +The query key to use for this query. + +The query key will be hashed into a stable hash. See [Query Keys](https://tanstack.com/query/latest/docs/framework/react/guides/query-keys) +for more information. + +The query will automatically update when this key changes (as long as `enabled` is not set to `false`). + +#### Inherited from + +```ts +WithRequired.queryKey +``` + +*** + +### queryKeyHashFn? + +```ts +optional queryKeyHashFn: QueryKeyHashFunction; +``` + +Defined in: [packages/query-core/src/types.ts:308](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L308) + +If specified, this function is used to hash the `queryKey` to a string. + +#### Inherited from + +```ts +WithRequired.queryKeyHashFn +``` + +*** + +### refetchInterval? + +```ts +optional refetchInterval: number | false | (query) => number | false | undefined; +``` + +Defined in: [packages/query-core/src/types.ts:414](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L414) + +If set to a number, the query will continuously refetch at this frequency in milliseconds. +If set to a function, the function will be executed with the latest data and query to compute a frequency + +Defaults to `false`. + +*** + +### refetchIntervalInBackground? + +```ts +optional refetchIntervalInBackground: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:425](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L425) + +If set to `true`, the query will continue to refetch while their tab/window is in the background. + +Defaults to `false`. + +*** + +### refetchOnMount? + +```ts +optional refetchOnMount: boolean | "always" | (query) => boolean | "always"; +``` + +Defined in: [packages/query-core/src/types.ts:462](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L462) + +If set to `true`, the query will refetch on mount if the data is stale. +If set to `false`, will disable additional instances of a query to trigger background refetch. +If set to `'always'`, the query will always refetch on mount (except when `staleTime: 'static'` is used). +If set to a function, the function will be executed with the latest data and query to compute the value + +Defaults to `true`. + +*** + +### refetchOnReconnect? + +```ts +optional refetchOnReconnect: boolean | "always" | (query) => boolean | "always"; +``` + +Defined in: [packages/query-core/src/types.ts:448](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L448) + +If set to `true`, the query will refetch on reconnect if the data is stale. +If set to `false`, the query will not refetch on reconnect. +If set to `'always'`, the query will always refetch on reconnect (except when `staleTime: 'static'` is used). +If set to a function, the function will be executed with the latest data and query to compute the value. + +Defaults to `true` unless `networkMode` is `'always'`. + +*** + +### refetchOnWindowFocus? + +```ts +optional refetchOnWindowFocus: boolean | "always" | (query) => boolean | "always"; +``` + +Defined in: [packages/query-core/src/types.ts:434](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L434) + +If set to `true`, the query will refetch on window focus if the data is stale. +If set to `false`, the query will not refetch on window focus. +If set to `'always'`, the query will always refetch on window focus (except when `staleTime: 'static'` is used). +If set to a function, the function will be executed with the latest data and query to compute the value. + +Defaults to `true`. + +*** + +### retry? + +```ts +optional retry: RetryValue; +``` + +Defined in: [packages/query-core/src/types.ts:246](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L246) + +If `false`, failed queries will not retry by default. +If `true`, failed queries will retry infinitely. +If set to an integer number, e.g. 3, failed queries will retry until the failed query count meets that number. +If set to a function `(failureCount, error) => boolean` failed queries will retry until the function returns false. + +Defaults to `3` on the client and `0` on the server. + +#### Inherited from + +```ts +WithRequired.retry +``` + +*** + +### retryDelay? + +```ts +optional retryDelay: RetryDelayValue; +``` + +Defined in: [packages/query-core/src/types.ts:258](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L258) + +This function receives a `retryAttempt` integer and the actual Error and returns the delay to apply before the +next attempt in milliseconds. + +A function like `attempt => Math.min(attempt > 1 ? 2 ** attempt * 1000 : 1000, 30 * 1000)` applies exponential +backoff. + +A function like `attempt => attempt * 1000` applies linear backoff. + +Defaults to a function that applies exponential backoff, capped at 30 seconds. + +#### Inherited from + +```ts +WithRequired.retryDelay +``` + +*** + +### retryOnMount? + +```ts +optional retryOnMount: QueryBooleanOption; +``` + +Defined in: [packages/query-core/src/types.ts:474](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L474) + +If set to `false`, the query will not be retried on mount if it contains an error. +If set to a function, the function will be executed with the query to compute the value. + +Defaults to `true`. + +*** + +### select()? + +```ts +optional select: (data) => TData; +``` + +Defined in: [packages/query-core/src/types.ts:500](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L500) + +This option can be used to transform or select a part of the data returned by the query function. It affects +the returned `data` value, but does not affect what gets stored in the query cache. +The `select` function will only run if `data` changed, or if the reference to the `select` function itself +changes. To optimize, memoize the function so its reference stays stable across calls. + +#### Parameters + +##### data + +`TQueryData` + +#### Returns + +`TData` + +*** + +### staleTime? + +```ts +optional staleTime: StaleTimeFunction; +``` + +Defined in: [packages/query-core/src/types.ts:407](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L407) + +The time in milliseconds after data is considered stale. +If set to `Infinity`, the data will never be considered stale. +If set to `'static'`, the data will never be considered stale. +If set to a function, the function will be executed with the query to compute a `staleTime`. + +Defaults to `0`. + +*** + +### structuralSharing? + +```ts +optional structuralSharing: boolean | (oldData, newData) => unknown; +``` + +Defined in: [packages/query-core/src/types.ts:330](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L330) + +Set this to `false` to disable structural sharing between query results. +Set this to a function which accepts the old and new data and returns resolved data of the same type to implement custom structural sharing logic. + +Defaults to `true`. + +#### Inherited from + +```ts +WithRequired.structuralSharing +``` + +*** + +### suspense? + +```ts +optional suspense: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:507](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L507) + +If set to `true`, the query will suspend when `status === 'pending'` +and throw errors when `status === 'error'`. + +Defaults to `false`. + +*** + +### throwOnError? + +```ts +optional throwOnError: ThrowOnError; +``` + +Defined in: [packages/query-core/src/types.ts:493](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L493) + +Whether errors should be thrown instead of setting the `error` property. +If set to `true` or `suspense` is `true`, all errors will be thrown to the error boundary. +If set to `false` and `suspense` is `false`, errors are returned as state. +If set to a function, it will be passed the error and the query, and it should return a boolean indicating whether to show the error in an error boundary (`true`) or return the error as state (`false`). + +Defaults to `false`. diff --git a/docs/framework/react/reference/interfaces/QueryObserverPendingResult.md b/docs/framework/react/reference/interfaces/QueryObserverPendingResult.md new file mode 100644 index 00000000000..8f00c426b64 --- /dev/null +++ b/docs/framework/react/reference/interfaces/QueryObserverPendingResult.md @@ -0,0 +1,452 @@ +--- +id: QueryObserverPendingResult +title: QueryObserverPendingResult +--- + +Defined in: [packages/query-core/src/types.ts:892](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L892) + +## Extends + +- [`QueryObserverBaseResult`](QueryObserverBaseResult.md)\<`TData`, `TError`\> + +## Type Parameters + +### TData + +`TData` = `unknown` + +### TError + +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) + +## Properties + +### data + +```ts +data: undefined; +``` + +Defined in: [packages/query-core/src/types.ts:896](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L896) + +The last successfully resolved data for the query. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`data`](QueryObserverBaseResult.md#data) + +*** + +### dataUpdatedAt + +```ts +dataUpdatedAt: number; +``` + +Defined in: [packages/query-core/src/types.ts:775](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L775) + +The timestamp for when the query most recently returned the `status` as `"success"`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`dataUpdatedAt`](QueryObserverBaseResult.md#dataupdatedat) + +*** + +### error + +```ts +error: null; +``` + +Defined in: [packages/query-core/src/types.ts:897](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L897) + +The error object for the query, if an error was thrown. +- Defaults to `null`. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`error`](QueryObserverBaseResult.md#error) + +*** + +### errorUpdateCount + +```ts +errorUpdateCount: number; +``` + +Defined in: [packages/query-core/src/types.ts:799](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L799) + +The sum of all errors. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`errorUpdateCount`](QueryObserverBaseResult.md#errorupdatecount) + +*** + +### errorUpdatedAt + +```ts +errorUpdatedAt: number; +``` + +Defined in: [packages/query-core/src/types.ts:784](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L784) + +The timestamp for when the query most recently returned the `status` as `"error"`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`errorUpdatedAt`](QueryObserverBaseResult.md#errorupdatedat) + +*** + +### failureCount + +```ts +failureCount: number; +``` + +Defined in: [packages/query-core/src/types.ts:790](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L790) + +The failure count for the query. +- Incremented every time the query fails. +- Reset to `0` when the query succeeds. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`failureCount`](QueryObserverBaseResult.md#failurecount) + +*** + +### failureReason + +```ts +failureReason: TError | null; +``` + +Defined in: [packages/query-core/src/types.ts:795](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L795) + +The failure reason for the query retry. +- Reset to `null` when the query succeeds. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`failureReason`](QueryObserverBaseResult.md#failurereason) + +*** + +### fetchStatus + +```ts +fetchStatus: FetchStatus; +``` + +Defined in: [packages/query-core/src/types.ts:889](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L889) + +The fetch status of the query. +- `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. +- `paused`: The query wanted to fetch, but has been `paused`. +- `idle`: The query is not fetching. +- See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`fetchStatus`](QueryObserverBaseResult.md#fetchstatus) + +*** + +### isEnabled + +```ts +isEnabled: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:867](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L867) + +`true` if this observer is enabled, `false` otherwise. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isEnabled`](QueryObserverBaseResult.md#isenabled) + +*** + +### isError + +```ts +isError: false; +``` + +Defined in: [packages/query-core/src/types.ts:898](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L898) + +A derived boolean from the `status` variable, provided for convenience. +- `true` if the query attempt resulted in an error. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isError`](QueryObserverBaseResult.md#iserror) + +*** + +### isFetched + +```ts +isFetched: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:808](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L808) + +Will be `true` if the query has been fetched. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isFetched`](QueryObserverBaseResult.md#isfetched) + +*** + +### isFetchedAfterMount + +```ts +isFetchedAfterMount: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:813](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L813) + +Will be `true` if the query has been fetched after the component mounted. +- This property can be used to not show any previously cached data. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isFetchedAfterMount`](QueryObserverBaseResult.md#isfetchedaftermount) + +*** + +### isFetching + +```ts +isFetching: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:818](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L818) + +A derived boolean from the `fetchStatus` variable, provided for convenience. +- `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isFetching`](QueryObserverBaseResult.md#isfetching) + +*** + +### ~~isInitialLoading~~ + +```ts +isInitialLoading: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:836](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L836) + +#### Deprecated + +`isInitialLoading` is being deprecated in favor of `isLoading` +and will be removed in the next major version. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isInitialLoading`](QueryObserverBaseResult.md#isinitialloading) + +*** + +### isLoading + +```ts +isLoading: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:823](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L823) + +Is `true` whenever the first fetch for a query is in-flight. +- Is the same as `isFetching && isPending`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoading`](QueryObserverBaseResult.md#isloading) + +*** + +### isLoadingError + +```ts +isLoadingError: false; +``` + +Defined in: [packages/query-core/src/types.ts:900](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L900) + +Will be `true` if the query failed while fetching for the first time. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoadingError`](QueryObserverBaseResult.md#isloadingerror) + +*** + +### isPaused + +```ts +isPaused: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:841](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L841) + +A derived boolean from the `fetchStatus` variable, provided for convenience. +- The query wanted to fetch, but has been `paused`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPaused`](QueryObserverBaseResult.md#ispaused) + +*** + +### isPending + +```ts +isPending: true; +``` + +Defined in: [packages/query-core/src/types.ts:899](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L899) + +Will be `pending` if there's no cached data and no query attempt was finished yet. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPending`](QueryObserverBaseResult.md#ispending) + +*** + +### isPlaceholderData + +```ts +isPlaceholderData: false; +``` + +Defined in: [packages/query-core/src/types.ts:903](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L903) + +Will be `true` if the data shown is the placeholder data. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPlaceholderData`](QueryObserverBaseResult.md#isplaceholderdata) + +*** + +### isRefetchError + +```ts +isRefetchError: false; +``` + +Defined in: [packages/query-core/src/types.ts:901](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L901) + +Will be `true` if the query failed while refetching. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetchError`](QueryObserverBaseResult.md#isrefetcherror) + +*** + +### isRefetching + +```ts +isRefetching: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:854](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L854) + +Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. +- Is the same as `isFetching && !isPending`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetching`](QueryObserverBaseResult.md#isrefetching) + +*** + +### isStale + +```ts +isStale: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:858](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L858) + +Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isStale`](QueryObserverBaseResult.md#isstale) + +*** + +### isSuccess + +```ts +isSuccess: false; +``` + +Defined in: [packages/query-core/src/types.ts:902](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L902) + +A derived boolean from the `status` variable, provided for convenience. +- `true` if the query has received a response with no errors and is ready to display its data. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isSuccess`](QueryObserverBaseResult.md#issuccess) + +*** + +### refetch() + +```ts +refetch: (options?) => Promise>; +``` + +Defined in: [packages/query-core/src/types.ts:871](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L871) + +A function to manually refetch the query. + +#### Parameters + +##### options? + +[`RefetchOptions`](RefetchOptions.md) + +#### Returns + +`Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`refetch`](QueryObserverBaseResult.md#refetch) + +*** + +### status + +```ts +status: "pending"; +``` + +Defined in: [packages/query-core/src/types.ts:904](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L904) + +The status of the query. +- Will be: + - `pending` if there's no cached data and no query attempt was finished yet. + - `error` if the query attempt resulted in an error. + - `success` if the query has received a response with no errors and is ready to display its data. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`status`](QueryObserverBaseResult.md#status) diff --git a/docs/framework/react/reference/interfaces/QueryObserverPlaceholderResult.md b/docs/framework/react/reference/interfaces/QueryObserverPlaceholderResult.md new file mode 100644 index 00000000000..bbf3da387f9 --- /dev/null +++ b/docs/framework/react/reference/interfaces/QueryObserverPlaceholderResult.md @@ -0,0 +1,452 @@ +--- +id: QueryObserverPlaceholderResult +title: QueryObserverPlaceholderResult +--- + +Defined in: [packages/query-core/src/types.ts:971](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L971) + +## Extends + +- [`QueryObserverBaseResult`](QueryObserverBaseResult.md)\<`TData`, `TError`\> + +## Type Parameters + +### TData + +`TData` = `unknown` + +### TError + +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) + +## Properties + +### data + +```ts +data: TData; +``` + +Defined in: [packages/query-core/src/types.ts:975](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L975) + +The last successfully resolved data for the query. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`data`](QueryObserverBaseResult.md#data) + +*** + +### dataUpdatedAt + +```ts +dataUpdatedAt: number; +``` + +Defined in: [packages/query-core/src/types.ts:775](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L775) + +The timestamp for when the query most recently returned the `status` as `"success"`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`dataUpdatedAt`](QueryObserverBaseResult.md#dataupdatedat) + +*** + +### error + +```ts +error: null; +``` + +Defined in: [packages/query-core/src/types.ts:977](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L977) + +The error object for the query, if an error was thrown. +- Defaults to `null`. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`error`](QueryObserverBaseResult.md#error) + +*** + +### errorUpdateCount + +```ts +errorUpdateCount: number; +``` + +Defined in: [packages/query-core/src/types.ts:799](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L799) + +The sum of all errors. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`errorUpdateCount`](QueryObserverBaseResult.md#errorupdatecount) + +*** + +### errorUpdatedAt + +```ts +errorUpdatedAt: number; +``` + +Defined in: [packages/query-core/src/types.ts:784](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L784) + +The timestamp for when the query most recently returned the `status` as `"error"`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`errorUpdatedAt`](QueryObserverBaseResult.md#errorupdatedat) + +*** + +### failureCount + +```ts +failureCount: number; +``` + +Defined in: [packages/query-core/src/types.ts:790](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L790) + +The failure count for the query. +- Incremented every time the query fails. +- Reset to `0` when the query succeeds. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`failureCount`](QueryObserverBaseResult.md#failurecount) + +*** + +### failureReason + +```ts +failureReason: TError | null; +``` + +Defined in: [packages/query-core/src/types.ts:795](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L795) + +The failure reason for the query retry. +- Reset to `null` when the query succeeds. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`failureReason`](QueryObserverBaseResult.md#failurereason) + +*** + +### fetchStatus + +```ts +fetchStatus: FetchStatus; +``` + +Defined in: [packages/query-core/src/types.ts:889](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L889) + +The fetch status of the query. +- `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. +- `paused`: The query wanted to fetch, but has been `paused`. +- `idle`: The query is not fetching. +- See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`fetchStatus`](QueryObserverBaseResult.md#fetchstatus) + +*** + +### isEnabled + +```ts +isEnabled: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:867](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L867) + +`true` if this observer is enabled, `false` otherwise. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isEnabled`](QueryObserverBaseResult.md#isenabled) + +*** + +### isError + +```ts +isError: false; +``` + +Defined in: [packages/query-core/src/types.ts:976](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L976) + +A derived boolean from the `status` variable, provided for convenience. +- `true` if the query attempt resulted in an error. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isError`](QueryObserverBaseResult.md#iserror) + +*** + +### isFetched + +```ts +isFetched: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:808](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L808) + +Will be `true` if the query has been fetched. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isFetched`](QueryObserverBaseResult.md#isfetched) + +*** + +### isFetchedAfterMount + +```ts +isFetchedAfterMount: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:813](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L813) + +Will be `true` if the query has been fetched after the component mounted. +- This property can be used to not show any previously cached data. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isFetchedAfterMount`](QueryObserverBaseResult.md#isfetchedaftermount) + +*** + +### isFetching + +```ts +isFetching: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:818](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L818) + +A derived boolean from the `fetchStatus` variable, provided for convenience. +- `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isFetching`](QueryObserverBaseResult.md#isfetching) + +*** + +### ~~isInitialLoading~~ + +```ts +isInitialLoading: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:836](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L836) + +#### Deprecated + +`isInitialLoading` is being deprecated in favor of `isLoading` +and will be removed in the next major version. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isInitialLoading`](QueryObserverBaseResult.md#isinitialloading) + +*** + +### isLoading + +```ts +isLoading: false; +``` + +Defined in: [packages/query-core/src/types.ts:979](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L979) + +Is `true` whenever the first fetch for a query is in-flight. +- Is the same as `isFetching && isPending`. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoading`](QueryObserverBaseResult.md#isloading) + +*** + +### isLoadingError + +```ts +isLoadingError: false; +``` + +Defined in: [packages/query-core/src/types.ts:980](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L980) + +Will be `true` if the query failed while fetching for the first time. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoadingError`](QueryObserverBaseResult.md#isloadingerror) + +*** + +### isPaused + +```ts +isPaused: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:841](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L841) + +A derived boolean from the `fetchStatus` variable, provided for convenience. +- The query wanted to fetch, but has been `paused`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPaused`](QueryObserverBaseResult.md#ispaused) + +*** + +### isPending + +```ts +isPending: false; +``` + +Defined in: [packages/query-core/src/types.ts:978](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L978) + +Will be `pending` if there's no cached data and no query attempt was finished yet. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPending`](QueryObserverBaseResult.md#ispending) + +*** + +### isPlaceholderData + +```ts +isPlaceholderData: true; +``` + +Defined in: [packages/query-core/src/types.ts:983](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L983) + +Will be `true` if the data shown is the placeholder data. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPlaceholderData`](QueryObserverBaseResult.md#isplaceholderdata) + +*** + +### isRefetchError + +```ts +isRefetchError: false; +``` + +Defined in: [packages/query-core/src/types.ts:981](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L981) + +Will be `true` if the query failed while refetching. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetchError`](QueryObserverBaseResult.md#isrefetcherror) + +*** + +### isRefetching + +```ts +isRefetching: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:854](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L854) + +Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. +- Is the same as `isFetching && !isPending`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetching`](QueryObserverBaseResult.md#isrefetching) + +*** + +### isStale + +```ts +isStale: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:858](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L858) + +Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isStale`](QueryObserverBaseResult.md#isstale) + +*** + +### isSuccess + +```ts +isSuccess: true; +``` + +Defined in: [packages/query-core/src/types.ts:982](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L982) + +A derived boolean from the `status` variable, provided for convenience. +- `true` if the query has received a response with no errors and is ready to display its data. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isSuccess`](QueryObserverBaseResult.md#issuccess) + +*** + +### refetch() + +```ts +refetch: (options?) => Promise>; +``` + +Defined in: [packages/query-core/src/types.ts:871](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L871) + +A function to manually refetch the query. + +#### Parameters + +##### options? + +[`RefetchOptions`](RefetchOptions.md) + +#### Returns + +`Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`refetch`](QueryObserverBaseResult.md#refetch) + +*** + +### status + +```ts +status: "success"; +``` + +Defined in: [packages/query-core/src/types.ts:984](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L984) + +The status of the query. +- Will be: + - `pending` if there's no cached data and no query attempt was finished yet. + - `error` if the query attempt resulted in an error. + - `success` if the query has received a response with no errors and is ready to display its data. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`status`](QueryObserverBaseResult.md#status) diff --git a/docs/framework/react/reference/interfaces/QueryObserverRefetchErrorResult.md b/docs/framework/react/reference/interfaces/QueryObserverRefetchErrorResult.md new file mode 100644 index 00000000000..345ecab35e1 --- /dev/null +++ b/docs/framework/react/reference/interfaces/QueryObserverRefetchErrorResult.md @@ -0,0 +1,452 @@ +--- +id: QueryObserverRefetchErrorResult +title: QueryObserverRefetchErrorResult +--- + +Defined in: [packages/query-core/src/types.ts:939](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L939) + +## Extends + +- [`QueryObserverBaseResult`](QueryObserverBaseResult.md)\<`TData`, `TError`\> + +## Type Parameters + +### TData + +`TData` = `unknown` + +### TError + +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) + +## Properties + +### data + +```ts +data: TData; +``` + +Defined in: [packages/query-core/src/types.ts:943](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L943) + +The last successfully resolved data for the query. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`data`](QueryObserverBaseResult.md#data) + +*** + +### dataUpdatedAt + +```ts +dataUpdatedAt: number; +``` + +Defined in: [packages/query-core/src/types.ts:775](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L775) + +The timestamp for when the query most recently returned the `status` as `"success"`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`dataUpdatedAt`](QueryObserverBaseResult.md#dataupdatedat) + +*** + +### error + +```ts +error: TError; +``` + +Defined in: [packages/query-core/src/types.ts:944](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L944) + +The error object for the query, if an error was thrown. +- Defaults to `null`. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`error`](QueryObserverBaseResult.md#error) + +*** + +### errorUpdateCount + +```ts +errorUpdateCount: number; +``` + +Defined in: [packages/query-core/src/types.ts:799](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L799) + +The sum of all errors. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`errorUpdateCount`](QueryObserverBaseResult.md#errorupdatecount) + +*** + +### errorUpdatedAt + +```ts +errorUpdatedAt: number; +``` + +Defined in: [packages/query-core/src/types.ts:784](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L784) + +The timestamp for when the query most recently returned the `status` as `"error"`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`errorUpdatedAt`](QueryObserverBaseResult.md#errorupdatedat) + +*** + +### failureCount + +```ts +failureCount: number; +``` + +Defined in: [packages/query-core/src/types.ts:790](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L790) + +The failure count for the query. +- Incremented every time the query fails. +- Reset to `0` when the query succeeds. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`failureCount`](QueryObserverBaseResult.md#failurecount) + +*** + +### failureReason + +```ts +failureReason: TError | null; +``` + +Defined in: [packages/query-core/src/types.ts:795](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L795) + +The failure reason for the query retry. +- Reset to `null` when the query succeeds. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`failureReason`](QueryObserverBaseResult.md#failurereason) + +*** + +### fetchStatus + +```ts +fetchStatus: FetchStatus; +``` + +Defined in: [packages/query-core/src/types.ts:889](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L889) + +The fetch status of the query. +- `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. +- `paused`: The query wanted to fetch, but has been `paused`. +- `idle`: The query is not fetching. +- See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`fetchStatus`](QueryObserverBaseResult.md#fetchstatus) + +*** + +### isEnabled + +```ts +isEnabled: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:867](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L867) + +`true` if this observer is enabled, `false` otherwise. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isEnabled`](QueryObserverBaseResult.md#isenabled) + +*** + +### isError + +```ts +isError: true; +``` + +Defined in: [packages/query-core/src/types.ts:945](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L945) + +A derived boolean from the `status` variable, provided for convenience. +- `true` if the query attempt resulted in an error. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isError`](QueryObserverBaseResult.md#iserror) + +*** + +### isFetched + +```ts +isFetched: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:808](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L808) + +Will be `true` if the query has been fetched. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isFetched`](QueryObserverBaseResult.md#isfetched) + +*** + +### isFetchedAfterMount + +```ts +isFetchedAfterMount: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:813](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L813) + +Will be `true` if the query has been fetched after the component mounted. +- This property can be used to not show any previously cached data. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isFetchedAfterMount`](QueryObserverBaseResult.md#isfetchedaftermount) + +*** + +### isFetching + +```ts +isFetching: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:818](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L818) + +A derived boolean from the `fetchStatus` variable, provided for convenience. +- `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isFetching`](QueryObserverBaseResult.md#isfetching) + +*** + +### ~~isInitialLoading~~ + +```ts +isInitialLoading: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:836](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L836) + +#### Deprecated + +`isInitialLoading` is being deprecated in favor of `isLoading` +and will be removed in the next major version. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isInitialLoading`](QueryObserverBaseResult.md#isinitialloading) + +*** + +### isLoading + +```ts +isLoading: false; +``` + +Defined in: [packages/query-core/src/types.ts:947](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L947) + +Is `true` whenever the first fetch for a query is in-flight. +- Is the same as `isFetching && isPending`. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoading`](QueryObserverBaseResult.md#isloading) + +*** + +### isLoadingError + +```ts +isLoadingError: false; +``` + +Defined in: [packages/query-core/src/types.ts:948](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L948) + +Will be `true` if the query failed while fetching for the first time. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoadingError`](QueryObserverBaseResult.md#isloadingerror) + +*** + +### isPaused + +```ts +isPaused: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:841](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L841) + +A derived boolean from the `fetchStatus` variable, provided for convenience. +- The query wanted to fetch, but has been `paused`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPaused`](QueryObserverBaseResult.md#ispaused) + +*** + +### isPending + +```ts +isPending: false; +``` + +Defined in: [packages/query-core/src/types.ts:946](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L946) + +Will be `pending` if there's no cached data and no query attempt was finished yet. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPending`](QueryObserverBaseResult.md#ispending) + +*** + +### isPlaceholderData + +```ts +isPlaceholderData: false; +``` + +Defined in: [packages/query-core/src/types.ts:951](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L951) + +Will be `true` if the data shown is the placeholder data. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPlaceholderData`](QueryObserverBaseResult.md#isplaceholderdata) + +*** + +### isRefetchError + +```ts +isRefetchError: true; +``` + +Defined in: [packages/query-core/src/types.ts:949](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L949) + +Will be `true` if the query failed while refetching. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetchError`](QueryObserverBaseResult.md#isrefetcherror) + +*** + +### isRefetching + +```ts +isRefetching: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:854](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L854) + +Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. +- Is the same as `isFetching && !isPending`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetching`](QueryObserverBaseResult.md#isrefetching) + +*** + +### isStale + +```ts +isStale: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:858](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L858) + +Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isStale`](QueryObserverBaseResult.md#isstale) + +*** + +### isSuccess + +```ts +isSuccess: false; +``` + +Defined in: [packages/query-core/src/types.ts:950](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L950) + +A derived boolean from the `status` variable, provided for convenience. +- `true` if the query has received a response with no errors and is ready to display its data. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isSuccess`](QueryObserverBaseResult.md#issuccess) + +*** + +### refetch() + +```ts +refetch: (options?) => Promise>; +``` + +Defined in: [packages/query-core/src/types.ts:871](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L871) + +A function to manually refetch the query. + +#### Parameters + +##### options? + +[`RefetchOptions`](RefetchOptions.md) + +#### Returns + +`Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`refetch`](QueryObserverBaseResult.md#refetch) + +*** + +### status + +```ts +status: "error"; +``` + +Defined in: [packages/query-core/src/types.ts:952](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L952) + +The status of the query. +- Will be: + - `pending` if there's no cached data and no query attempt was finished yet. + - `error` if the query attempt resulted in an error. + - `success` if the query has received a response with no errors and is ready to display its data. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`status`](QueryObserverBaseResult.md#status) diff --git a/docs/framework/react/reference/interfaces/QueryObserverSuccessResult.md b/docs/framework/react/reference/interfaces/QueryObserverSuccessResult.md new file mode 100644 index 00000000000..3942655c627 --- /dev/null +++ b/docs/framework/react/reference/interfaces/QueryObserverSuccessResult.md @@ -0,0 +1,452 @@ +--- +id: QueryObserverSuccessResult +title: QueryObserverSuccessResult +--- + +Defined in: [packages/query-core/src/types.ts:955](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L955) + +## Extends + +- [`QueryObserverBaseResult`](QueryObserverBaseResult.md)\<`TData`, `TError`\> + +## Type Parameters + +### TData + +`TData` = `unknown` + +### TError + +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) + +## Properties + +### data + +```ts +data: TData; +``` + +Defined in: [packages/query-core/src/types.ts:959](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L959) + +The last successfully resolved data for the query. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`data`](QueryObserverBaseResult.md#data) + +*** + +### dataUpdatedAt + +```ts +dataUpdatedAt: number; +``` + +Defined in: [packages/query-core/src/types.ts:775](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L775) + +The timestamp for when the query most recently returned the `status` as `"success"`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`dataUpdatedAt`](QueryObserverBaseResult.md#dataupdatedat) + +*** + +### error + +```ts +error: null; +``` + +Defined in: [packages/query-core/src/types.ts:960](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L960) + +The error object for the query, if an error was thrown. +- Defaults to `null`. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`error`](QueryObserverBaseResult.md#error) + +*** + +### errorUpdateCount + +```ts +errorUpdateCount: number; +``` + +Defined in: [packages/query-core/src/types.ts:799](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L799) + +The sum of all errors. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`errorUpdateCount`](QueryObserverBaseResult.md#errorupdatecount) + +*** + +### errorUpdatedAt + +```ts +errorUpdatedAt: number; +``` + +Defined in: [packages/query-core/src/types.ts:784](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L784) + +The timestamp for when the query most recently returned the `status` as `"error"`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`errorUpdatedAt`](QueryObserverBaseResult.md#errorupdatedat) + +*** + +### failureCount + +```ts +failureCount: number; +``` + +Defined in: [packages/query-core/src/types.ts:790](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L790) + +The failure count for the query. +- Incremented every time the query fails. +- Reset to `0` when the query succeeds. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`failureCount`](QueryObserverBaseResult.md#failurecount) + +*** + +### failureReason + +```ts +failureReason: TError | null; +``` + +Defined in: [packages/query-core/src/types.ts:795](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L795) + +The failure reason for the query retry. +- Reset to `null` when the query succeeds. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`failureReason`](QueryObserverBaseResult.md#failurereason) + +*** + +### fetchStatus + +```ts +fetchStatus: FetchStatus; +``` + +Defined in: [packages/query-core/src/types.ts:889](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L889) + +The fetch status of the query. +- `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. +- `paused`: The query wanted to fetch, but has been `paused`. +- `idle`: The query is not fetching. +- See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`fetchStatus`](QueryObserverBaseResult.md#fetchstatus) + +*** + +### isEnabled + +```ts +isEnabled: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:867](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L867) + +`true` if this observer is enabled, `false` otherwise. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isEnabled`](QueryObserverBaseResult.md#isenabled) + +*** + +### isError + +```ts +isError: false; +``` + +Defined in: [packages/query-core/src/types.ts:961](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L961) + +A derived boolean from the `status` variable, provided for convenience. +- `true` if the query attempt resulted in an error. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isError`](QueryObserverBaseResult.md#iserror) + +*** + +### isFetched + +```ts +isFetched: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:808](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L808) + +Will be `true` if the query has been fetched. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isFetched`](QueryObserverBaseResult.md#isfetched) + +*** + +### isFetchedAfterMount + +```ts +isFetchedAfterMount: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:813](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L813) + +Will be `true` if the query has been fetched after the component mounted. +- This property can be used to not show any previously cached data. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isFetchedAfterMount`](QueryObserverBaseResult.md#isfetchedaftermount) + +*** + +### isFetching + +```ts +isFetching: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:818](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L818) + +A derived boolean from the `fetchStatus` variable, provided for convenience. +- `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isFetching`](QueryObserverBaseResult.md#isfetching) + +*** + +### ~~isInitialLoading~~ + +```ts +isInitialLoading: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:836](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L836) + +#### Deprecated + +`isInitialLoading` is being deprecated in favor of `isLoading` +and will be removed in the next major version. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isInitialLoading`](QueryObserverBaseResult.md#isinitialloading) + +*** + +### isLoading + +```ts +isLoading: false; +``` + +Defined in: [packages/query-core/src/types.ts:963](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L963) + +Is `true` whenever the first fetch for a query is in-flight. +- Is the same as `isFetching && isPending`. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoading`](QueryObserverBaseResult.md#isloading) + +*** + +### isLoadingError + +```ts +isLoadingError: false; +``` + +Defined in: [packages/query-core/src/types.ts:964](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L964) + +Will be `true` if the query failed while fetching for the first time. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoadingError`](QueryObserverBaseResult.md#isloadingerror) + +*** + +### isPaused + +```ts +isPaused: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:841](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L841) + +A derived boolean from the `fetchStatus` variable, provided for convenience. +- The query wanted to fetch, but has been `paused`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPaused`](QueryObserverBaseResult.md#ispaused) + +*** + +### isPending + +```ts +isPending: false; +``` + +Defined in: [packages/query-core/src/types.ts:962](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L962) + +Will be `pending` if there's no cached data and no query attempt was finished yet. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPending`](QueryObserverBaseResult.md#ispending) + +*** + +### isPlaceholderData + +```ts +isPlaceholderData: false; +``` + +Defined in: [packages/query-core/src/types.ts:967](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L967) + +Will be `true` if the data shown is the placeholder data. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPlaceholderData`](QueryObserverBaseResult.md#isplaceholderdata) + +*** + +### isRefetchError + +```ts +isRefetchError: false; +``` + +Defined in: [packages/query-core/src/types.ts:965](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L965) + +Will be `true` if the query failed while refetching. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetchError`](QueryObserverBaseResult.md#isrefetcherror) + +*** + +### isRefetching + +```ts +isRefetching: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:854](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L854) + +Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. +- Is the same as `isFetching && !isPending`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetching`](QueryObserverBaseResult.md#isrefetching) + +*** + +### isStale + +```ts +isStale: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:858](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L858) + +Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isStale`](QueryObserverBaseResult.md#isstale) + +*** + +### isSuccess + +```ts +isSuccess: true; +``` + +Defined in: [packages/query-core/src/types.ts:966](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L966) + +A derived boolean from the `status` variable, provided for convenience. +- `true` if the query has received a response with no errors and is ready to display its data. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isSuccess`](QueryObserverBaseResult.md#issuccess) + +*** + +### refetch() + +```ts +refetch: (options?) => Promise>; +``` + +Defined in: [packages/query-core/src/types.ts:871](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L871) + +A function to manually refetch the query. + +#### Parameters + +##### options? + +[`RefetchOptions`](RefetchOptions.md) + +#### Returns + +`Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`refetch`](QueryObserverBaseResult.md#refetch) + +*** + +### status + +```ts +status: "success"; +``` + +Defined in: [packages/query-core/src/types.ts:968](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L968) + +The status of the query. +- Will be: + - `pending` if there's no cached data and no query attempt was finished yet. + - `error` if the query attempt resulted in an error. + - `success` if the query has received a response with no errors and is ready to display its data. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`status`](QueryObserverBaseResult.md#status) diff --git a/docs/framework/react/reference/interfaces/QueryOptions.md b/docs/framework/react/reference/interfaces/QueryOptions.md new file mode 100644 index 00000000000..7e059d3a1d6 --- /dev/null +++ b/docs/framework/react/reference/interfaces/QueryOptions.md @@ -0,0 +1,247 @@ +--- +id: QueryOptions +title: QueryOptions +--- + +Defined in: [packages/query-core/src/types.ts:231](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L231) + +## Type Parameters + +### TQueryFnData + +`TQueryFnData` = `unknown` + +### TError + +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) + +### TData + +`TData` = `TQueryFnData` + +### TQueryKey + +`TQueryKey` *extends* [`QueryKey`](../type-aliases/QueryKey.md) = [`QueryKey`](../type-aliases/QueryKey.md) + +### TPageParam + +`TPageParam` = `never` + +## Properties + +### gcTime? + +```ts +optional gcTime: number; +``` + +Defined in: [packages/query-core/src/types.ts:277](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L277) + +The time in milliseconds that unused/inactive cache data remains in memory. +When a query's cache becomes unused or inactive, that cache data will be garbage collected after this duration. +When different garbage collection times are specified, the longest one will be used. +Setting it to `Infinity` will disable garbage collection. + +Defaults to `5 * 60 * 1000` (5 minutes), or `Infinity` during SSR. + +Note: the maximum allowed time is about 24 days, imposed by `setTimeout`'s 32-bit signed integer delay — see +`timeoutManager.setTimeoutProvider` for a workaround. + +*** + +### initialData? + +```ts +optional initialData: + | TData +| InitialDataFunction; +``` + +Defined in: [packages/query-core/src/types.ts:317](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L317) + +If set, this value will be used as the initial data for the query cache (as long as the query hasn't been +created or cached yet). +If set to a function, the function will be called **once** during the shared/root query initialization, and be +expected to synchronously return the initial data. +Initial data is considered stale by default unless a `staleTime` has been set. +`initialData` **is persisted** to the cache. + +*** + +### initialDataUpdatedAt? + +```ts +optional initialDataUpdatedAt: number | () => number | undefined; +``` + +Defined in: [packages/query-core/src/types.ts:321](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L321) + +If set, this value will be used as the time (in milliseconds) of when the `initialData` itself was last updated. + +*** + +### maxPages? + +```ts +optional maxPages: number; +``` + +Defined in: [packages/query-core/src/types.ts:345](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L345) + +Maximum number of pages to store in the data of an infinite query. + +*** + +### meta? + +```ts +optional meta: Record; +``` + +Defined in: [packages/query-core/src/types.ts:341](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L341) + +Additional payload to be stored on each query. +Use this property to pass information that can be used in other places. + +*** + +### networkMode? + +```ts +optional networkMode: NetworkMode; +``` + +Defined in: [packages/query-core/src/types.ts:265](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L265) + +Controls whether a query is allowed to run based on the current network connectivity. + +Defaults to `'online'`. + +#### See + +[Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. + +*** + +### persister? + +```ts +optional persister: QueryPersister, TPageParam>; +``` + +Defined in: [packages/query-core/src/types.ts:290](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L290) + +This option can be used to persist the result of a query to an external storage, bypassing the need to actually +call the `queryFn`. Useful for persisting a query's data across e.g. server/client boundaries. + +*** + +### queryFn? + +```ts +optional queryFn: + | QueryFunction + | typeof skipToken; +``` + +Defined in: [packages/query-core/src/types.ts:285](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L285) + +The function that the query will use to request data. +Required, unless a default query function has been set via `queryClient.setQueryDefaults` or +`queryClient.setDefaultOptions`. +Receives a [QueryFunctionContext](../type-aliases/QueryFunctionContext.md). +Must return a promise that will either resolve data or throw an error. The data cannot be `undefined`. + +*** + +### queryHash? + +```ts +optional queryHash: string; +``` + +Defined in: [packages/query-core/src/types.ts:295](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L295) + +The hashed form of `queryKey`, computed with `queryKeyHashFn` (or the default hashing function otherwise). Used +as the actual cache key internally. + +*** + +### queryKey? + +```ts +optional queryKey: TQueryKey; +``` + +Defined in: [packages/query-core/src/types.ts:304](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L304) + +The query key to use for this query. + +The query key will be hashed into a stable hash. See [Query Keys](https://tanstack.com/query/latest/docs/framework/react/guides/query-keys) +for more information. + +The query will automatically update when this key changes (as long as `enabled` is not set to `false`). + +*** + +### queryKeyHashFn? + +```ts +optional queryKeyHashFn: QueryKeyHashFunction; +``` + +Defined in: [packages/query-core/src/types.ts:308](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L308) + +If specified, this function is used to hash the `queryKey` to a string. + +*** + +### retry? + +```ts +optional retry: RetryValue; +``` + +Defined in: [packages/query-core/src/types.ts:246](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L246) + +If `false`, failed queries will not retry by default. +If `true`, failed queries will retry infinitely. +If set to an integer number, e.g. 3, failed queries will retry until the failed query count meets that number. +If set to a function `(failureCount, error) => boolean` failed queries will retry until the function returns false. + +Defaults to `3` on the client and `0` on the server. + +*** + +### retryDelay? + +```ts +optional retryDelay: RetryDelayValue; +``` + +Defined in: [packages/query-core/src/types.ts:258](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L258) + +This function receives a `retryAttempt` integer and the actual Error and returns the delay to apply before the +next attempt in milliseconds. + +A function like `attempt => Math.min(attempt > 1 ? 2 ** attempt * 1000 : 1000, 30 * 1000)` applies exponential +backoff. + +A function like `attempt => attempt * 1000` applies linear backoff. + +Defaults to a function that applies exponential backoff, capped at 30 seconds. + +*** + +### structuralSharing? + +```ts +optional structuralSharing: boolean | (oldData, newData) => unknown; +``` + +Defined in: [packages/query-core/src/types.ts:330](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L330) + +Set this to `false` to disable structural sharing between query results. +Set this to a function which accepts the old and new data and returns resolved data of the same type to implement custom structural sharing logic. + +Defaults to `true`. diff --git a/docs/framework/react/reference/interfaces/QueryState.md b/docs/framework/react/reference/interfaces/QueryState.md new file mode 100644 index 00000000000..7dce476d743 --- /dev/null +++ b/docs/framework/react/reference/interfaces/QueryState.md @@ -0,0 +1,175 @@ +--- +id: QueryState +title: QueryState +--- + +Defined in: [packages/query-core/src/query.ts:52](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L52) + +The raw state stored on a `Query` instance. This is the underlying state +that observer results (e.g. `QueryObserverResult`) are derived from. + +## Type Parameters + +### TData + +`TData` = `unknown` + +### TError + +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) + +## Properties + +### data + +```ts +data: TData | undefined; +``` + +Defined in: [packages/query-core/src/query.ts:56](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L56) + +The last successfully resolved data for the query. + +*** + +### dataUpdateCount + +```ts +dataUpdateCount: number; +``` + +Defined in: [packages/query-core/src/query.ts:60](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L60) + +The number of times the query has successfully resolved. + +*** + +### dataUpdatedAt + +```ts +dataUpdatedAt: number; +``` + +Defined in: [packages/query-core/src/query.ts:64](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L64) + +The timestamp for when the query most recently returned the `status` as `"success"`. + +*** + +### error + +```ts +error: TError | null; +``` + +Defined in: [packages/query-core/src/query.ts:69](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L69) + +The error object for the query, if the last attempt resulted in an error. +- Defaults to `null`. + +*** + +### errorUpdateCount + +```ts +errorUpdateCount: number; +``` + +Defined in: [packages/query-core/src/query.ts:73](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L73) + +The sum of all errors, incremented every time the query resolves with an error. + +*** + +### errorUpdatedAt + +```ts +errorUpdatedAt: number; +``` + +Defined in: [packages/query-core/src/query.ts:77](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L77) + +The timestamp for when the query most recently returned the `status` as `"error"`. + +*** + +### fetchFailureCount + +```ts +fetchFailureCount: number; +``` + +Defined in: [packages/query-core/src/query.ts:83](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L83) + +The failure count for the current fetch. +- Incremented every time the fetch fails. +- Reset to `0` when the fetch succeeds. + +*** + +### fetchFailureReason + +```ts +fetchFailureReason: TError | null; +``` + +Defined in: [packages/query-core/src/query.ts:88](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L88) + +The reason the current fetch failed, as reported by the retryer. +- Reset to `null` when the fetch succeeds. + +*** + +### fetchMeta + +```ts +fetchMeta: FetchMeta | null; +``` + +Defined in: [packages/query-core/src/query.ts:93](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L93) + +Metadata passed to the currently in-flight (or most recent) fetch, e.g. the +`fetchMore` direction for infinite queries. + +*** + +### fetchStatus + +```ts +fetchStatus: FetchStatus; +``` + +Defined in: [packages/query-core/src/query.ts:112](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L112) + +The fetch status of the query. +- `fetching`: the `queryFn` is currently executing. +- `paused`: a fetch wanted to run but has been paused (see network mode). +- `idle`: the query is not fetching. + +*** + +### isInvalidated + +```ts +isInvalidated: boolean; +``` + +Defined in: [packages/query-core/src/query.ts:98](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L98) + +Whether the query has been marked as invalidated via `invalidate()`. +- Reset to `false` whenever the query resolves successfully. + +*** + +### status + +```ts +status: QueryStatus; +``` + +Defined in: [packages/query-core/src/query.ts:105](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L105) + +The status of the query. +- `pending` if there's no cached data and no attempt was finished yet. +- `error` if the last attempt resulted in an error. +- `success` if the query has data. diff --git a/docs/framework/react/reference/interfaces/RefetchOptions.md b/docs/framework/react/reference/interfaces/RefetchOptions.md new file mode 100644 index 00000000000..cfcc0498799 --- /dev/null +++ b/docs/framework/react/reference/interfaces/RefetchOptions.md @@ -0,0 +1,50 @@ +--- +id: RefetchOptions +title: RefetchOptions +--- + +Defined in: [packages/query-core/src/types.ts:704](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L704) + +## Extends + +- [`ResultOptions`](ResultOptions.md) + +## Extended by + +- [`InvalidateOptions`](InvalidateOptions.md) +- [`ResetOptions`](ResetOptions.md) + +## Properties + +### cancelRefetch? + +```ts +optional cancelRefetch: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:712](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L712) + +If set to `true`, a currently running request will be cancelled before a new request is made + +If set to `false`, no refetch will be made if there is already a request running. + +Defaults to `true`. + +*** + +### throwOnError? + +```ts +optional throwOnError: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:701](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L701) + +If set to `true`, the method throws if any of the underlying query refetch tasks fail. + +Defaults to `false`, in which case failed refetches are swallowed and not surfaced to the +caller. + +#### Inherited from + +[`ResultOptions`](ResultOptions.md).[`throwOnError`](ResultOptions.md#throwonerror) diff --git a/docs/framework/react/reference/interfaces/RefetchQueryFilters.md b/docs/framework/react/reference/interfaces/RefetchQueryFilters.md new file mode 100644 index 00000000000..c45dfa953f1 --- /dev/null +++ b/docs/framework/react/reference/interfaces/RefetchQueryFilters.md @@ -0,0 +1,127 @@ +--- +id: RefetchQueryFilters +title: RefetchQueryFilters +--- + +Defined in: [packages/query-core/src/types.ts:730](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L730) + +Filters used to select queries, for example in `queryClient.getQueriesData` or `queryClient.invalidateQueries`. +All provided filters must match; filters that are left unspecified are ignored. + +## Extends + +- [`QueryFilters`](QueryFilters.md)\<`TQueryKey`\> + +## Type Parameters + +### TQueryKey + +`TQueryKey` *extends* [`QueryKey`](../type-aliases/QueryKey.md) = [`QueryKey`](../type-aliases/QueryKey.md) + +## Properties + +### exact? + +```ts +optional exact: boolean; +``` + +Defined in: [packages/query-core/src/utils.ts:41](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L41) + +Match query key exactly + +#### Inherited from + +[`QueryFilters`](QueryFilters.md).[`exact`](QueryFilters.md#exact) + +*** + +### fetchStatus? + +```ts +optional fetchStatus: FetchStatus; +``` + +Defined in: [packages/query-core/src/utils.ts:57](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L57) + +Include queries matching their fetchStatus + +#### Inherited from + +[`QueryFilters`](QueryFilters.md).[`fetchStatus`](QueryFilters.md#fetchstatus) + +*** + +### predicate()? + +```ts +optional predicate: (query) => boolean; +``` + +Defined in: [packages/query-core/src/utils.ts:45](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L45) + +Include queries matching this predicate function + +#### Parameters + +##### query + +[`Query`](../classes/Query.md) + +#### Returns + +`boolean` + +#### Inherited from + +[`QueryFilters`](QueryFilters.md).[`predicate`](QueryFilters.md#predicate) + +*** + +### queryKey? + +```ts +optional queryKey: TQueryKey | TuplePrefixes; +``` + +Defined in: [packages/query-core/src/utils.ts:49](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L49) + +Include queries matching this query key + +#### Inherited from + +[`QueryFilters`](QueryFilters.md).[`queryKey`](QueryFilters.md#querykey) + +*** + +### stale? + +```ts +optional stale: boolean; +``` + +Defined in: [packages/query-core/src/utils.ts:53](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L53) + +Include or exclude stale queries + +#### Inherited from + +[`QueryFilters`](QueryFilters.md).[`stale`](QueryFilters.md#stale) + +*** + +### type? + +```ts +optional type: QueryTypeFilter; +``` + +Defined in: [packages/query-core/src/utils.ts:37](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L37) + +Filter to active queries, inactive queries or all queries + +Defaults to `'all'`. + +#### Inherited from + +[`QueryFilters`](QueryFilters.md).[`type`](QueryFilters.md#type) diff --git a/docs/framework/react/reference/interfaces/Register.md b/docs/framework/react/reference/interfaces/Register.md new file mode 100644 index 00000000000..4f442442b48 --- /dev/null +++ b/docs/framework/react/reference/interfaces/Register.md @@ -0,0 +1,6 @@ +--- +id: Register +title: Register +--- + +Defined in: [packages/query-core/src/types.ts:37](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L37) diff --git a/docs/framework/react/reference/interfaces/ResetOptions.md b/docs/framework/react/reference/interfaces/ResetOptions.md new file mode 100644 index 00000000000..9f12324ba27 --- /dev/null +++ b/docs/framework/react/reference/interfaces/ResetOptions.md @@ -0,0 +1,49 @@ +--- +id: ResetOptions +title: ResetOptions +--- + +Defined in: [packages/query-core/src/types.ts:735](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L735) + +## Extends + +- [`RefetchOptions`](RefetchOptions.md) + +## Properties + +### cancelRefetch? + +```ts +optional cancelRefetch: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:712](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L712) + +If set to `true`, a currently running request will be cancelled before a new request is made + +If set to `false`, no refetch will be made if there is already a request running. + +Defaults to `true`. + +#### Inherited from + +[`RefetchOptions`](RefetchOptions.md).[`cancelRefetch`](RefetchOptions.md#cancelrefetch) + +*** + +### throwOnError? + +```ts +optional throwOnError: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:701](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L701) + +If set to `true`, the method throws if any of the underlying query refetch tasks fail. + +Defaults to `false`, in which case failed refetches are swallowed and not surfaced to the +caller. + +#### Inherited from + +[`RefetchOptions`](RefetchOptions.md).[`throwOnError`](RefetchOptions.md#throwonerror) diff --git a/docs/framework/react/reference/interfaces/ResultOptions.md b/docs/framework/react/reference/interfaces/ResultOptions.md new file mode 100644 index 00000000000..42917f20bf0 --- /dev/null +++ b/docs/framework/react/reference/interfaces/ResultOptions.md @@ -0,0 +1,27 @@ +--- +id: ResultOptions +title: ResultOptions +--- + +Defined in: [packages/query-core/src/types.ts:694](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L694) + +## Extended by + +- [`RefetchOptions`](RefetchOptions.md) +- [`FetchNextPageOptions`](FetchNextPageOptions.md) +- [`FetchPreviousPageOptions`](FetchPreviousPageOptions.md) + +## Properties + +### throwOnError? + +```ts +optional throwOnError: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:701](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L701) + +If set to `true`, the method throws if any of the underlying query refetch tasks fail. + +Defaults to `false`, in which case failed refetches are swallowed and not surfaced to the +caller. diff --git a/docs/framework/react/reference/interfaces/SetDataOptions.md b/docs/framework/react/reference/interfaces/SetDataOptions.md new file mode 100644 index 00000000000..bb668fbf162 --- /dev/null +++ b/docs/framework/react/reference/interfaces/SetDataOptions.md @@ -0,0 +1,16 @@ +--- +id: SetDataOptions +title: SetDataOptions +--- + +Defined in: [packages/query-core/src/types.ts:1526](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1526) + +## Properties + +### updatedAt? + +```ts +optional updatedAt: number; +``` + +Defined in: [packages/query-core/src/types.ts:1527](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1527) diff --git a/docs/framework/react/reference/interfaces/TimeoutManager.md b/docs/framework/react/reference/interfaces/TimeoutManager.md new file mode 100644 index 00000000000..d97ee3f4aef --- /dev/null +++ b/docs/framework/react/reference/interfaces/TimeoutManager.md @@ -0,0 +1,248 @@ +--- +id: TimeoutManager +title: TimeoutManager +redirect_from: + - reference/timeoutManager +--- + +Defined in: [packages/query-core/src/timeoutManager.ts:70](https://github.com/TanStack/query/blob/main/packages/query-core/src/timeoutManager.ts#L70) + +Allows customization of how timeouts are created. + +@tanstack/query-core makes liberal use of timeouts to implement `staleTime` +and `gcTime`. The default TimeoutManager provider uses the platform's global +`setTimeout` implementation, which is known to have scalability issues with +thousands of timeouts on the event loop. + +If you hit this limitation, consider providing a custom TimeoutProvider that +coalesces timeouts. + +## Implements + +- `Omit`\<[`TimeoutProvider`](../type-aliases/TimeoutProvider.md), `"name"`\> + +## Methods + +### clearInterval() + +```ts +clearInterval(intervalId): void; +``` + +Defined in: [packages/query-core/src/timeoutManager.ts:224](https://github.com/TanStack/query/blob/main/packages/query-core/src/timeoutManager.ts#L224) + +`clearInterval` can be used to cancel an interval, like the global +`clearInterval` function. It should be called with an interval ID +returned by `setInterval`. + +#### Parameters + +##### intervalId + +[`ManagedTimerId`](../type-aliases/ManagedTimerId.md) | `undefined` + +#### Returns + +`void` + +#### Example + +```ts +import { timeoutManager } from '@tanstack/query-core' + +const intervalId = timeoutManager.setInterval( + () => console.log('ran at:', new Date()), + 1000, +) + +timeoutManager.clearInterval(intervalId) +``` + +#### Implementation of + +[`TimeoutProvider`](../type-aliases/TimeoutProvider.md).[`clearInterval`](../type-aliases/TimeoutProvider.md#clearinterval) + +*** + +### clearTimeout() + +```ts +clearTimeout(timeoutId): void; +``` + +Defined in: [packages/query-core/src/timeoutManager.ts:179](https://github.com/TanStack/query/blob/main/packages/query-core/src/timeoutManager.ts#L179) + +`clearTimeout` cancels a timeout callback scheduled with `setTimeout`, +like the global `clearTimeout` function. It should be called with a +timer ID returned by `setTimeout`. + +#### Parameters + +##### timeoutId + +[`ManagedTimerId`](../type-aliases/ManagedTimerId.md) | `undefined` + +#### Returns + +`void` + +#### Example + +```ts +import { timeoutManager } from '@tanstack/query-core' + +const timeoutId = timeoutManager.setTimeout( + () => console.log('ran at:', new Date()), + 1000, +) + +timeoutManager.clearTimeout(timeoutId) +``` + +#### Implementation of + +[`TimeoutProvider`](../type-aliases/TimeoutProvider.md).[`clearTimeout`](../type-aliases/TimeoutProvider.md#cleartimeout) + +*** + +### setInterval() + +```ts +setInterval(callback, delay): ManagedTimerId; +``` + +Defined in: [packages/query-core/src/timeoutManager.ts:200](https://github.com/TanStack/query/blob/main/packages/query-core/src/timeoutManager.ts#L200) + +`setInterval` schedules a callback to be called approximately every +`delay` milliseconds, like the global `setInterval` function. + +Like `setTimeout`, it returns a timer ID, which may be a number or an +object that can be coerced to a number via `Symbol.toPrimitive`. + +#### Parameters + +##### callback + +[`TimeoutCallback`](../type-aliases/TimeoutCallback.md) + +##### delay + +`number` + +#### Returns + +[`ManagedTimerId`](../type-aliases/ManagedTimerId.md) + +#### Example + +```ts +import { timeoutManager } from '@tanstack/query-core' + +const intervalId = timeoutManager.setInterval( + () => console.log('ran at:', new Date()), + 1000, +) +``` + +#### Implementation of + +[`TimeoutProvider`](../type-aliases/TimeoutProvider.md).[`setInterval`](../type-aliases/TimeoutProvider.md#setinterval) + +*** + +### setTimeout() + +```ts +setTimeout(callback, delay): ManagedTimerId; +``` + +Defined in: [packages/query-core/src/timeoutManager.ts:155](https://github.com/TanStack/query/blob/main/packages/query-core/src/timeoutManager.ts#L155) + +`setTimeout` schedules a callback to run after approximately `delay` +milliseconds, like the global `setTimeout` function. The callback can be +canceled with `clearTimeout`. + +It returns a timer ID, which may be a number or an object that can be +coerced to a number via `Symbol.toPrimitive`. + +#### Parameters + +##### callback + +[`TimeoutCallback`](../type-aliases/TimeoutCallback.md) + +##### delay + +`number` + +#### Returns + +[`ManagedTimerId`](../type-aliases/ManagedTimerId.md) + +#### Example + +```ts +import { timeoutManager } from '@tanstack/query-core' + +const timeoutId = timeoutManager.setTimeout( + () => console.log('ran at:', new Date()), + 1000, +) + +const timeoutIdNumber: number = Number(timeoutId) +``` + +#### Implementation of + +[`TimeoutProvider`](../type-aliases/TimeoutProvider.md).[`setTimeout`](../type-aliases/TimeoutProvider.md#settimeout) + +*** + +### setTimeoutProvider() + +```ts +setTimeoutProvider(provider): void; +``` + +Defined in: [packages/query-core/src/timeoutManager.ts:106](https://github.com/TanStack/query/blob/main/packages/query-core/src/timeoutManager.ts#L106) + +`setTimeoutProvider` can be used to set a custom implementation of the +`setTimeout`, `clearTimeout`, `setInterval`, `clearInterval` functions, +called a `TimeoutProvider`. + +This may be useful if you notice event loop performance issues with +thousands of queries. A custom TimeoutProvider could also support timer +delays longer than the global `setTimeout` maximum delay value of about +24 days. + +It is important to call `setTimeoutProvider` before creating a +QueryClient or queries, so that the same provider is used consistently +for all timers in the application, since different TimeoutProviders +cannot cancel each others' timers. + +#### Type Parameters + +##### TTimerId + +`TTimerId` *extends* [`ManagedTimerId`](../type-aliases/ManagedTimerId.md) + +#### Parameters + +##### provider + +[`TimeoutProvider`](../type-aliases/TimeoutProvider.md)\<`TTimerId`\> + +#### Returns + +`void` + +#### Example + +```ts +import { timeoutManager, QueryClient } from '@tanstack/query-core' +import { CustomTimeoutProvider } from './CustomTimeoutProvider' + +timeoutManager.setTimeoutProvider(new CustomTimeoutProvider()) + +export const queryClient = new QueryClient() +``` diff --git a/docs/framework/react/reference/interfaces/UseBaseQueryOptions.md b/docs/framework/react/reference/interfaces/UseBaseQueryOptions.md index 16f50718bec..5e58f763132 100644 --- a/docs/framework/react/reference/interfaces/UseBaseQueryOptions.md +++ b/docs/framework/react/reference/interfaces/UseBaseQueryOptions.md @@ -3,14 +3,14 @@ id: UseBaseQueryOptions title: UseBaseQueryOptions --- -Defined in: [react-query/src/types.ts:47](https://github.com/TanStack/query/blob/main/packages/react-query/src/types.ts#L47) +Defined in: [packages/react-query/src/types.ts:47](https://github.com/TanStack/query/blob/main/packages/react-query/src/types.ts#L47) -The options shared by `useQuery` and `useSuspenseQuery`. Extends QueryObserverOptions from +The options shared by `useQuery` and `useSuspenseQuery`. Extends [QueryObserverOptions](QueryObserverOptions.md) from `@tanstack/query-core` with the `react-query`-specific `subscribed` option. ## Extends -- `QueryObserverOptions`\<`TQueryFnData`, `TError`, `TData`, `TQueryData`, `TQueryKey`\> +- [`QueryObserverOptions`](QueryObserverOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryData`, `TQueryKey`\> ## Type Parameters @@ -22,7 +22,7 @@ The type your `queryFn` resolves to. ### TError -`TError` = `DefaultError` +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) The type of errors your `queryFn` may throw. @@ -42,19 +42,567 @@ The type of the data actually held in the query cache — the input to `select` ### TQueryKey -`TQueryKey` *extends* `QueryKey` = `QueryKey` +`TQueryKey` *extends* [`QueryKey`](../type-aliases/QueryKey.md) = [`QueryKey`](../type-aliases/QueryKey.md) The type of your `queryKey`. ## Properties +### enabled? + +```ts +optional enabled: QueryBooleanOption; +``` + +Defined in: [packages/query-core/src/types.ts:398](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L398) + +Set this to `false` or a function that returns `false` to disable automatic refetching when the query mounts or changes query keys. +To refetch the query, use the `refetch` method returned from the `useQuery` instance. +Accepts a boolean or function that returns a boolean. + +Defaults to `true`. + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`enabled`](QueryObserverOptions.md#enabled) + +*** + +### gcTime? + +```ts +optional gcTime: number; +``` + +Defined in: [packages/query-core/src/types.ts:277](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L277) + +The time in milliseconds that unused/inactive cache data remains in memory. +When a query's cache becomes unused or inactive, that cache data will be garbage collected after this duration. +When different garbage collection times are specified, the longest one will be used. +Setting it to `Infinity` will disable garbage collection. + +Defaults to `5 * 60 * 1000` (5 minutes), or `Infinity` during SSR. + +Note: the maximum allowed time is about 24 days, imposed by `setTimeout`'s 32-bit signed integer delay — see +`timeoutManager.setTimeoutProvider` for a workaround. + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`gcTime`](QueryObserverOptions.md#gctime) + +*** + +### initialData? + +```ts +optional initialData: + | TQueryData +| InitialDataFunction; +``` + +Defined in: [packages/query-core/src/types.ts:317](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L317) + +If set, this value will be used as the initial data for the query cache (as long as the query hasn't been +created or cached yet). +If set to a function, the function will be called **once** during the shared/root query initialization, and be +expected to synchronously return the initial data. +Initial data is considered stale by default unless a `staleTime` has been set. +`initialData` **is persisted** to the cache. + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`initialData`](QueryObserverOptions.md#initialdata) + +*** + +### initialDataUpdatedAt? + +```ts +optional initialDataUpdatedAt: number | () => number | undefined; +``` + +Defined in: [packages/query-core/src/types.ts:321](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L321) + +If set, this value will be used as the time (in milliseconds) of when the `initialData` itself was last updated. + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`initialDataUpdatedAt`](QueryObserverOptions.md#initialdataupdatedat) + +*** + +### maxPages? + +```ts +optional maxPages: number; +``` + +Defined in: [packages/query-core/src/types.ts:345](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L345) + +Maximum number of pages to store in the data of an infinite query. + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`maxPages`](QueryObserverOptions.md#maxpages) + +*** + +### meta? + +```ts +optional meta: Record; +``` + +Defined in: [packages/query-core/src/types.ts:341](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L341) + +Additional payload to be stored on each query. +Use this property to pass information that can be used in other places. + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`meta`](QueryObserverOptions.md#meta) + +*** + +### networkMode? + +```ts +optional networkMode: NetworkMode; +``` + +Defined in: [packages/query-core/src/types.ts:265](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L265) + +Controls whether a query is allowed to run based on the current network connectivity. + +Defaults to `'online'`. + +#### See + +[Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`networkMode`](QueryObserverOptions.md#networkmode) + +*** + +### notifyOnChangeProps? + +```ts +optional notifyOnChangeProps: NotifyOnChangeProps; +``` + +Defined in: [packages/query-core/src/types.ts:484](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L484) + +If set, the component will only re-render if any of the listed properties change. +When set to `['data', 'error']`, the component will only re-render when the `data` or `error` properties change. +When set to `'all'`, the component will re-render whenever a query is updated. +When set to a function, the function will be executed to compute the list of properties. + +Defaults to `undefined`, in which case property access is tracked automatically, and the +component only re-renders when one of the tracked properties changes. + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`notifyOnChangeProps`](QueryObserverOptions.md#notifyonchangeprops) + +*** + +### persister()? + +```ts +optional persister: (queryFn, context, query) => TQueryFnData | Promise; +``` + +Defined in: [packages/query-core/src/types.ts:290](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L290) + +This option can be used to persist the result of a query to an external storage, bypassing the need to actually +call the `queryFn`. Useful for persisting a query's data across e.g. server/client boundaries. + +#### Parameters + +##### queryFn + +[`QueryFunction`](../type-aliases/QueryFunction.md)\<`TQueryFnData`, `NoInfer`\<`TQueryKey`\>, `never`\> + +##### context + +###### client + +[`QueryClient`](../classes/QueryClient.md) + +###### direction? + +`unknown` + +**Deprecated** + +if you want access to the direction, you can add it to the pageParam + +###### meta + +`Record`\<`string`, `unknown`\> \| `undefined` + +###### pageParam? + +`unknown` + +###### queryKey + +`NoInfer`\<`TQueryKey`\> + +###### signal + +`AbortSignal` + +##### query + +[`Query`](../classes/Query.md) + +#### Returns + +`TQueryFnData` \| `Promise`\<`TQueryFnData`\> + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`persister`](QueryObserverOptions.md#persister) + +*** + +### placeholderData? + +```ts +optional placeholderData: + | NonFunctionGuard +| PlaceholderDataFunction, TError, NonFunctionGuard, TQueryKey>; +``` + +Defined in: [packages/query-core/src/types.ts:511](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L511) + +If set, this value will be used as the placeholder data for this particular query observer while the query is still in the `loading` data and no initialData has been provided. + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`placeholderData`](QueryObserverOptions.md#placeholderdata) + +*** + +### queryFn? + +```ts +optional queryFn: + | typeof skipToken +| QueryFunction; +``` + +Defined in: [packages/query-core/src/types.ts:285](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L285) + +The function that the query will use to request data. +Required, unless a default query function has been set via `queryClient.setQueryDefaults` or +`queryClient.setDefaultOptions`. +Receives a [QueryFunctionContext](../type-aliases/QueryFunctionContext.md). +Must return a promise that will either resolve data or throw an error. The data cannot be `undefined`. + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`queryFn`](QueryObserverOptions.md#queryfn) + +*** + +### queryHash? + +```ts +optional queryHash: string; +``` + +Defined in: [packages/query-core/src/types.ts:295](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L295) + +The hashed form of `queryKey`, computed with `queryKeyHashFn` (or the default hashing function otherwise). Used +as the actual cache key internally. + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`queryHash`](QueryObserverOptions.md#queryhash) + +*** + +### queryKey + +```ts +queryKey: TQueryKey & object; +``` + +Defined in: [packages/query-core/src/types.ts:304](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L304) + +The query key to use for this query. + +The query key will be hashed into a stable hash. See [Query Keys](https://tanstack.com/query/latest/docs/framework/react/guides/query-keys) +for more information. + +The query will automatically update when this key changes (as long as `enabled` is not set to `false`). + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`queryKey`](QueryObserverOptions.md#querykey) + +*** + +### queryKeyHashFn? + +```ts +optional queryKeyHashFn: QueryKeyHashFunction; +``` + +Defined in: [packages/query-core/src/types.ts:308](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L308) + +If specified, this function is used to hash the `queryKey` to a string. + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`queryKeyHashFn`](QueryObserverOptions.md#querykeyhashfn) + +*** + +### refetchInterval? + +```ts +optional refetchInterval: number | false | (query) => number | false | undefined; +``` + +Defined in: [packages/query-core/src/types.ts:414](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L414) + +If set to a number, the query will continuously refetch at this frequency in milliseconds. +If set to a function, the function will be executed with the latest data and query to compute a frequency + +Defaults to `false`. + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`refetchInterval`](QueryObserverOptions.md#refetchinterval) + +*** + +### refetchIntervalInBackground? + +```ts +optional refetchIntervalInBackground: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:425](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L425) + +If set to `true`, the query will continue to refetch while their tab/window is in the background. + +Defaults to `false`. + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`refetchIntervalInBackground`](QueryObserverOptions.md#refetchintervalinbackground) + +*** + +### refetchOnMount? + +```ts +optional refetchOnMount: boolean | "always" | (query) => boolean | "always"; +``` + +Defined in: [packages/query-core/src/types.ts:462](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L462) + +If set to `true`, the query will refetch on mount if the data is stale. +If set to `false`, will disable additional instances of a query to trigger background refetch. +If set to `'always'`, the query will always refetch on mount (except when `staleTime: 'static'` is used). +If set to a function, the function will be executed with the latest data and query to compute the value + +Defaults to `true`. + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`refetchOnMount`](QueryObserverOptions.md#refetchonmount) + +*** + +### refetchOnReconnect? + +```ts +optional refetchOnReconnect: boolean | "always" | (query) => boolean | "always"; +``` + +Defined in: [packages/query-core/src/types.ts:448](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L448) + +If set to `true`, the query will refetch on reconnect if the data is stale. +If set to `false`, the query will not refetch on reconnect. +If set to `'always'`, the query will always refetch on reconnect (except when `staleTime: 'static'` is used). +If set to a function, the function will be executed with the latest data and query to compute the value. + +Defaults to `true` unless `networkMode` is `'always'`. + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`refetchOnReconnect`](QueryObserverOptions.md#refetchonreconnect) + +*** + +### refetchOnWindowFocus? + +```ts +optional refetchOnWindowFocus: boolean | "always" | (query) => boolean | "always"; +``` + +Defined in: [packages/query-core/src/types.ts:434](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L434) + +If set to `true`, the query will refetch on window focus if the data is stale. +If set to `false`, the query will not refetch on window focus. +If set to `'always'`, the query will always refetch on window focus (except when `staleTime: 'static'` is used). +If set to a function, the function will be executed with the latest data and query to compute the value. + +Defaults to `true`. + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`refetchOnWindowFocus`](QueryObserverOptions.md#refetchonwindowfocus) + +*** + +### retry? + +```ts +optional retry: RetryValue; +``` + +Defined in: [packages/query-core/src/types.ts:246](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L246) + +If `false`, failed queries will not retry by default. +If `true`, failed queries will retry infinitely. +If set to an integer number, e.g. 3, failed queries will retry until the failed query count meets that number. +If set to a function `(failureCount, error) => boolean` failed queries will retry until the function returns false. + +Defaults to `3` on the client and `0` on the server. + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`retry`](QueryObserverOptions.md#retry) + +*** + +### retryDelay? + +```ts +optional retryDelay: RetryDelayValue; +``` + +Defined in: [packages/query-core/src/types.ts:258](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L258) + +This function receives a `retryAttempt` integer and the actual Error and returns the delay to apply before the +next attempt in milliseconds. + +A function like `attempt => Math.min(attempt > 1 ? 2 ** attempt * 1000 : 1000, 30 * 1000)` applies exponential +backoff. + +A function like `attempt => attempt * 1000` applies linear backoff. + +Defaults to a function that applies exponential backoff, capped at 30 seconds. + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`retryDelay`](QueryObserverOptions.md#retrydelay) + +*** + +### retryOnMount? + +```ts +optional retryOnMount: QueryBooleanOption; +``` + +Defined in: [packages/query-core/src/types.ts:474](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L474) + +If set to `false`, the query will not be retried on mount if it contains an error. +If set to a function, the function will be executed with the query to compute the value. + +Defaults to `true`. + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`retryOnMount`](QueryObserverOptions.md#retryonmount) + +*** + +### select()? + +```ts +optional select: (data) => TData; +``` + +Defined in: [packages/query-core/src/types.ts:500](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L500) + +This option can be used to transform or select a part of the data returned by the query function. It affects +the returned `data` value, but does not affect what gets stored in the query cache. +The `select` function will only run if `data` changed, or if the reference to the `select` function itself +changes. To optimize, memoize the function so its reference stays stable across calls. + +#### Parameters + +##### data + +`TQueryData` + +#### Returns + +`TData` + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`select`](QueryObserverOptions.md#select) + +*** + +### staleTime? + +```ts +optional staleTime: StaleTimeFunction; +``` + +Defined in: [packages/query-core/src/types.ts:407](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L407) + +The time in milliseconds after data is considered stale. +If set to `Infinity`, the data will never be considered stale. +If set to `'static'`, the data will never be considered stale. +If set to a function, the function will be executed with the query to compute a `staleTime`. + +Defaults to `0`. + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`staleTime`](QueryObserverOptions.md#staletime) + +*** + +### structuralSharing? + +```ts +optional structuralSharing: boolean | (oldData, newData) => unknown; +``` + +Defined in: [packages/query-core/src/types.ts:330](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L330) + +Set this to `false` to disable structural sharing between query results. +Set this to a function which accepts the old and new data and returns resolved data of the same type to implement custom structural sharing logic. + +Defaults to `true`. + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`structuralSharing`](QueryObserverOptions.md#structuralsharing) + +*** + ### subscribed? ```ts optional subscribed: boolean; ``` -Defined in: [react-query/src/types.ts:65](https://github.com/TanStack/query/blob/main/packages/react-query/src/types.ts#L65) +Defined in: [packages/react-query/src/types.ts:65](https://github.com/TanStack/query/blob/main/packages/react-query/src/types.ts#L65) Set this to `false` to unsubscribe this observer from updates to the query cache. @@ -63,3 +611,43 @@ Set this to `false` to unsubscribe this observer from updates to the query cache ```ts true ``` + +*** + +### suspense? + +```ts +optional suspense: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:507](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L507) + +If set to `true`, the query will suspend when `status === 'pending'` +and throw errors when `status === 'error'`. + +Defaults to `false`. + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`suspense`](QueryObserverOptions.md#suspense) + +*** + +### throwOnError? + +```ts +optional throwOnError: ThrowOnError; +``` + +Defined in: [packages/query-core/src/types.ts:493](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L493) + +Whether errors should be thrown instead of setting the `error` property. +If set to `true` or `suspense` is `true`, all errors will be thrown to the error boundary. +If set to `false` and `suspense` is `false`, errors are returned as state. +If set to a function, it will be passed the error and the query, and it should return a boolean indicating whether to show the error in an error boundary (`true`) or return the error as state (`false`). + +Defaults to `false`. + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`throwOnError`](QueryObserverOptions.md#throwonerror) diff --git a/docs/framework/react/reference/interfaces/UseInfiniteQueryOptions.md b/docs/framework/react/reference/interfaces/UseInfiniteQueryOptions.md index 3ce35ff761b..ad9c3a72e3c 100644 --- a/docs/framework/react/reference/interfaces/UseInfiniteQueryOptions.md +++ b/docs/framework/react/reference/interfaces/UseInfiniteQueryOptions.md @@ -3,15 +3,15 @@ id: UseInfiniteQueryOptions title: UseInfiniteQueryOptions --- -Defined in: [react-query/src/types.ts:238](https://github.com/TanStack/query/blob/main/packages/react-query/src/types.ts#L238) +Defined in: [packages/react-query/src/types.ts:238](https://github.com/TanStack/query/blob/main/packages/react-query/src/types.ts#L238) -The options accepted by `useInfiniteQuery`. Extends InfiniteQueryObserverOptions from +The options accepted by `useInfiniteQuery`. Extends [InfiniteQueryObserverOptions](InfiniteQueryObserverOptions.md) from `@tanstack/query-core` with the `react-query`-specific `subscribed` option, minus `suspense` (which `react-query` derives from which hook you call rather than exposing as an option). ## Extends -- `OmitKeyof`\<`InfiniteQueryObserverOptions`\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`, `TPageParam`\>, `"suspense"`\> +- [`OmitKeyof`](../type-aliases/OmitKeyof.md)\<[`InfiniteQueryObserverOptions`](InfiniteQueryObserverOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`, `TPageParam`\>, `"suspense"`\> ## Type Parameters @@ -23,20 +23,20 @@ The type of a single page, as your `queryFn` resolves it. ### TError -`TError` = `DefaultError` +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) The type of errors your `queryFn` may throw. ### TData -`TData` = `InfiniteData`\<`TQueryFnData`\> +`TData` = [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`\> The type `data` ends up as after `select` runs — defaults to `InfiniteData`, the shape of all fetched pages plus their page params. ### TQueryKey -`TQueryKey` *extends* `QueryKey` = `QueryKey` +`TQueryKey` *extends* [`QueryKey`](../type-aliases/QueryKey.md) = [`QueryKey`](../type-aliases/QueryKey.md) The type of your `queryKey`. @@ -48,13 +48,607 @@ The type of the parameter passed to `queryFn` to fetch a given page. ## Properties +### enabled? + +```ts +optional enabled: QueryBooleanOption, TQueryKey>; +``` + +Defined in: [packages/query-core/src/types.ts:398](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L398) + +Set this to `false` or a function that returns `false` to disable automatic refetching when the query mounts or changes query keys. +To refetch the query, use the `refetch` method returned from the `useQuery` instance. +Accepts a boolean or function that returns a boolean. + +Defaults to `true`. + +#### Inherited from + +```ts +OmitKeyof.enabled +``` + +*** + +### gcTime? + +```ts +optional gcTime: number; +``` + +Defined in: [packages/query-core/src/types.ts:277](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L277) + +The time in milliseconds that unused/inactive cache data remains in memory. +When a query's cache becomes unused or inactive, that cache data will be garbage collected after this duration. +When different garbage collection times are specified, the longest one will be used. +Setting it to `Infinity` will disable garbage collection. + +Defaults to `5 * 60 * 1000` (5 minutes), or `Infinity` during SSR. + +Note: the maximum allowed time is about 24 days, imposed by `setTimeout`'s 32-bit signed integer delay — see +`timeoutManager.setTimeoutProvider` for a workaround. + +#### Inherited from + +[`QueryOptions`](QueryOptions.md).[`gcTime`](QueryOptions.md#gctime) + +*** + +### getNextPageParam + +```ts +getNextPageParam: GetNextPageParamFunction; +``` + +Defined in: [packages/query-core/src/types.ts:365](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L365) + +This function can be set to automatically get the next cursor for infinite queries. +The result will also be used to determine the value of `hasNextPage`. + +#### Inherited from + +```ts +OmitKeyof.getNextPageParam +``` + +*** + +### getPreviousPageParam? + +```ts +optional getPreviousPageParam: GetPreviousPageParamFunction; +``` + +Defined in: [packages/query-core/src/types.ts:360](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L360) + +This function can be set to automatically get the previous cursor for infinite queries. +The result will also be used to determine the value of `hasPreviousPage`. + +#### Inherited from + +```ts +OmitKeyof.getPreviousPageParam +``` + +*** + +### initialData? + +```ts +optional initialData: + | InfiniteData +| InitialDataFunction>; +``` + +Defined in: [packages/query-core/src/types.ts:317](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L317) + +If set, this value will be used as the initial data for the query cache (as long as the query hasn't been +created or cached yet). +If set to a function, the function will be called **once** during the shared/root query initialization, and be +expected to synchronously return the initial data. +Initial data is considered stale by default unless a `staleTime` has been set. +`initialData` **is persisted** to the cache. + +#### Inherited from + +```ts +OmitKeyof.initialData +``` + +*** + +### initialDataUpdatedAt? + +```ts +optional initialDataUpdatedAt: number | () => number | undefined; +``` + +Defined in: [packages/query-core/src/types.ts:321](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L321) + +If set, this value will be used as the time (in milliseconds) of when the `initialData` itself was last updated. + +#### Inherited from + +```ts +OmitKeyof.initialDataUpdatedAt +``` + +*** + +### initialPageParam + +```ts +initialPageParam: TPageParam; +``` + +Defined in: [packages/query-core/src/types.ts:349](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L349) + +#### Inherited from + +```ts +OmitKeyof.initialPageParam +``` + +*** + +### maxPages? + +```ts +optional maxPages: number; +``` + +Defined in: [packages/query-core/src/types.ts:345](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L345) + +Maximum number of pages to store in the data of an infinite query. + +#### Inherited from + +[`QueryOptions`](QueryOptions.md).[`maxPages`](QueryOptions.md#maxpages) + +*** + +### meta? + +```ts +optional meta: Record; +``` + +Defined in: [packages/query-core/src/types.ts:341](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L341) + +Additional payload to be stored on each query. +Use this property to pass information that can be used in other places. + +#### Inherited from + +[`QueryOptions`](QueryOptions.md).[`meta`](QueryOptions.md#meta) + +*** + +### networkMode? + +```ts +optional networkMode: NetworkMode; +``` + +Defined in: [packages/query-core/src/types.ts:265](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L265) + +Controls whether a query is allowed to run based on the current network connectivity. + +Defaults to `'online'`. + +#### See + +[Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. + +#### Inherited from + +[`QueryOptions`](QueryOptions.md).[`networkMode`](QueryOptions.md#networkmode) + +*** + +### notifyOnChangeProps? + +```ts +optional notifyOnChangeProps: NotifyOnChangeProps; +``` + +Defined in: [packages/query-core/src/types.ts:484](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L484) + +If set, the component will only re-render if any of the listed properties change. +When set to `['data', 'error']`, the component will only re-render when the `data` or `error` properties change. +When set to `'all'`, the component will re-render whenever a query is updated. +When set to a function, the function will be executed to compute the list of properties. + +Defaults to `undefined`, in which case property access is tracked automatically, and the +component only re-renders when one of the tracked properties changes. + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`notifyOnChangeProps`](QueryObserverOptions.md#notifyonchangeprops) + +*** + +### persister? + +```ts +optional persister: QueryPersister, TPageParam>; +``` + +Defined in: [packages/query-core/src/types.ts:290](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L290) + +This option can be used to persist the result of a query to an external storage, bypassing the need to actually +call the `queryFn`. Useful for persisting a query's data across e.g. server/client boundaries. + +#### Inherited from + +```ts +OmitKeyof.persister +``` + +*** + +### placeholderData? + +```ts +optional placeholderData: + | InfiniteData +| PlaceholderDataFunction, TError, InfiniteData, TQueryKey>; +``` + +Defined in: [packages/query-core/src/types.ts:511](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L511) + +If set, this value will be used as the placeholder data for this particular query observer while the query is still in the `loading` data and no initialData has been provided. + +#### Inherited from + +```ts +OmitKeyof.placeholderData +``` + +*** + +### queryFn? + +```ts +optional queryFn: + | typeof skipToken +| QueryFunction; +``` + +Defined in: [packages/query-core/src/types.ts:285](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L285) + +The function that the query will use to request data. +Required, unless a default query function has been set via `queryClient.setQueryDefaults` or +`queryClient.setDefaultOptions`. +Receives a [QueryFunctionContext](../type-aliases/QueryFunctionContext.md). +Must return a promise that will either resolve data or throw an error. The data cannot be `undefined`. + +#### Inherited from + +```ts +OmitKeyof.queryFn +``` + +*** + +### queryHash? + +```ts +optional queryHash: string; +``` + +Defined in: [packages/query-core/src/types.ts:295](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L295) + +The hashed form of `queryKey`, computed with `queryKeyHashFn` (or the default hashing function otherwise). Used +as the actual cache key internally. + +#### Inherited from + +[`QueryOptions`](QueryOptions.md).[`queryHash`](QueryOptions.md#queryhash) + +*** + +### queryKey + +```ts +queryKey: TQueryKey & object; +``` + +Defined in: [packages/query-core/src/types.ts:304](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L304) + +The query key to use for this query. + +The query key will be hashed into a stable hash. See [Query Keys](https://tanstack.com/query/latest/docs/framework/react/guides/query-keys) +for more information. + +The query will automatically update when this key changes (as long as `enabled` is not set to `false`). + +#### Inherited from + +```ts +OmitKeyof.queryKey +``` + +*** + +### queryKeyHashFn? + +```ts +optional queryKeyHashFn: QueryKeyHashFunction; +``` + +Defined in: [packages/query-core/src/types.ts:308](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L308) + +If specified, this function is used to hash the `queryKey` to a string. + +#### Inherited from + +```ts +OmitKeyof.queryKeyHashFn +``` + +*** + +### refetchInterval? + +```ts +optional refetchInterval: number | false | (query) => number | false | undefined; +``` + +Defined in: [packages/query-core/src/types.ts:414](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L414) + +If set to a number, the query will continuously refetch at this frequency in milliseconds. +If set to a function, the function will be executed with the latest data and query to compute a frequency + +Defaults to `false`. + +#### Inherited from + +```ts +OmitKeyof.refetchInterval +``` + +*** + +### refetchIntervalInBackground? + +```ts +optional refetchIntervalInBackground: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:425](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L425) + +If set to `true`, the query will continue to refetch while their tab/window is in the background. + +Defaults to `false`. + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`refetchIntervalInBackground`](QueryObserverOptions.md#refetchintervalinbackground) + +*** + +### refetchOnMount? + +```ts +optional refetchOnMount: boolean | "always" | (query) => boolean | "always"; +``` + +Defined in: [packages/query-core/src/types.ts:462](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L462) + +If set to `true`, the query will refetch on mount if the data is stale. +If set to `false`, will disable additional instances of a query to trigger background refetch. +If set to `'always'`, the query will always refetch on mount (except when `staleTime: 'static'` is used). +If set to a function, the function will be executed with the latest data and query to compute the value + +Defaults to `true`. + +#### Inherited from + +```ts +OmitKeyof.refetchOnMount +``` + +*** + +### refetchOnReconnect? + +```ts +optional refetchOnReconnect: boolean | "always" | (query) => boolean | "always"; +``` + +Defined in: [packages/query-core/src/types.ts:448](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L448) + +If set to `true`, the query will refetch on reconnect if the data is stale. +If set to `false`, the query will not refetch on reconnect. +If set to `'always'`, the query will always refetch on reconnect (except when `staleTime: 'static'` is used). +If set to a function, the function will be executed with the latest data and query to compute the value. + +Defaults to `true` unless `networkMode` is `'always'`. + +#### Inherited from + +```ts +OmitKeyof.refetchOnReconnect +``` + +*** + +### refetchOnWindowFocus? + +```ts +optional refetchOnWindowFocus: boolean | "always" | (query) => boolean | "always"; +``` + +Defined in: [packages/query-core/src/types.ts:434](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L434) + +If set to `true`, the query will refetch on window focus if the data is stale. +If set to `false`, the query will not refetch on window focus. +If set to `'always'`, the query will always refetch on window focus (except when `staleTime: 'static'` is used). +If set to a function, the function will be executed with the latest data and query to compute the value. + +Defaults to `true`. + +#### Inherited from + +```ts +OmitKeyof.refetchOnWindowFocus +``` + +*** + +### retry? + +```ts +optional retry: RetryValue; +``` + +Defined in: [packages/query-core/src/types.ts:246](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L246) + +If `false`, failed queries will not retry by default. +If `true`, failed queries will retry infinitely. +If set to an integer number, e.g. 3, failed queries will retry until the failed query count meets that number. +If set to a function `(failureCount, error) => boolean` failed queries will retry until the function returns false. + +Defaults to `3` on the client and `0` on the server. + +#### Inherited from + +```ts +OmitKeyof.retry +``` + +*** + +### retryDelay? + +```ts +optional retryDelay: RetryDelayValue; +``` + +Defined in: [packages/query-core/src/types.ts:258](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L258) + +This function receives a `retryAttempt` integer and the actual Error and returns the delay to apply before the +next attempt in milliseconds. + +A function like `attempt => Math.min(attempt > 1 ? 2 ** attempt * 1000 : 1000, 30 * 1000)` applies exponential +backoff. + +A function like `attempt => attempt * 1000` applies linear backoff. + +Defaults to a function that applies exponential backoff, capped at 30 seconds. + +#### Inherited from + +```ts +OmitKeyof.retryDelay +``` + +*** + +### retryOnMount? + +```ts +optional retryOnMount: QueryBooleanOption, TQueryKey>; +``` + +Defined in: [packages/query-core/src/types.ts:474](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L474) + +If set to `false`, the query will not be retried on mount if it contains an error. +If set to a function, the function will be executed with the query to compute the value. + +Defaults to `true`. + +#### Inherited from + +```ts +OmitKeyof.retryOnMount +``` + +*** + +### select()? + +```ts +optional select: (data) => TData; +``` + +Defined in: [packages/query-core/src/types.ts:500](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L500) + +This option can be used to transform or select a part of the data returned by the query function. It affects +the returned `data` value, but does not affect what gets stored in the query cache. +The `select` function will only run if `data` changed, or if the reference to the `select` function itself +changes. To optimize, memoize the function so its reference stays stable across calls. + +#### Parameters + +##### data + +[`InfiniteData`](InfiniteData.md) + +#### Returns + +`TData` + +#### Inherited from + +```ts +OmitKeyof.select +``` + +*** + +### staleTime? + +```ts +optional staleTime: StaleTimeFunction, TQueryKey>; +``` + +Defined in: [packages/query-core/src/types.ts:407](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L407) + +The time in milliseconds after data is considered stale. +If set to `Infinity`, the data will never be considered stale. +If set to `'static'`, the data will never be considered stale. +If set to a function, the function will be executed with the query to compute a `staleTime`. + +Defaults to `0`. + +#### Inherited from + +```ts +OmitKeyof.staleTime +``` + +*** + +### structuralSharing? + +```ts +optional structuralSharing: boolean | (oldData, newData) => unknown; +``` + +Defined in: [packages/query-core/src/types.ts:330](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L330) + +Set this to `false` to disable structural sharing between query results. +Set this to a function which accepts the old and new data and returns resolved data of the same type to implement custom structural sharing logic. + +Defaults to `true`. + +#### Inherited from + +```ts +OmitKeyof.structuralSharing +``` + +*** + ### subscribed? ```ts optional subscribed: boolean; ``` -Defined in: [react-query/src/types.ts:259](https://github.com/TanStack/query/blob/main/packages/react-query/src/types.ts#L259) +Defined in: [packages/react-query/src/types.ts:259](https://github.com/TanStack/query/blob/main/packages/react-query/src/types.ts#L259) Set this to `false` to unsubscribe this observer from updates to the query cache. @@ -63,3 +657,26 @@ Set this to `false` to unsubscribe this observer from updates to the query cache ```ts true ``` + +*** + +### throwOnError? + +```ts +optional throwOnError: ThrowOnError, TQueryKey>; +``` + +Defined in: [packages/query-core/src/types.ts:493](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L493) + +Whether errors should be thrown instead of setting the `error` property. +If set to `true` or `suspense` is `true`, all errors will be thrown to the error boundary. +If set to `false` and `suspense` is `false`, errors are returned as state. +If set to a function, it will be passed the error and the query, and it should return a boolean indicating whether to show the error in an error boundary (`true`) or return the error as state (`false`). + +Defaults to `false`. + +#### Inherited from + +```ts +OmitKeyof.throwOnError +``` diff --git a/docs/framework/react/reference/interfaces/UseMutationOptions.md b/docs/framework/react/reference/interfaces/UseMutationOptions.md index 2ae7e55f6a1..767ba80378f 100644 --- a/docs/framework/react/reference/interfaces/UseMutationOptions.md +++ b/docs/framework/react/reference/interfaces/UseMutationOptions.md @@ -3,14 +3,14 @@ id: UseMutationOptions title: UseMutationOptions --- -Defined in: [react-query/src/types.ts:412](https://github.com/TanStack/query/blob/main/packages/react-query/src/types.ts#L412) +Defined in: [packages/react-query/src/types.ts:412](https://github.com/TanStack/query/blob/main/packages/react-query/src/types.ts#L412) -The options accepted by `useMutation`. Same as MutationObserverOptions from `@tanstack/query-core`, +The options accepted by `useMutation`. Same as [MutationObserverOptions](MutationObserverOptions.md) from `@tanstack/query-core`, minus the internal `_defaulted` flag. ## Extends -- `OmitKeyof`\<`MutationObserverOptions`\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\>, `"_defaulted"`\> +- [`OmitKeyof`](../type-aliases/OmitKeyof.md)\<[`MutationObserverOptions`](MutationObserverOptions.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\>, `"_defaulted"`\> ## Type Parameters @@ -22,7 +22,7 @@ The type your mutation function resolves to. ### TError -`TError` = `DefaultError` +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) The type of errors your mutation function may throw. @@ -38,3 +38,317 @@ The type of the variable passed to `mutate`/`mutateAsync`. The type returned by `onMutate`, passed to `onSuccess`/`onError`/`onSettled` as their `onMutateResult` parameter — useful for optimistic-update rollback data. + +## Properties + +### gcTime? + +```ts +optional gcTime: number; +``` + +Defined in: [packages/query-core/src/types.ts:1260](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1260) + +The time in milliseconds that an unused/inactive mutation remains in memory before it is +garbage collected. + +Defaults to `5 * 60 * 1000` (5 minutes), or `Infinity` during SSR. + +#### Inherited from + +[`MutationOptions`](MutationOptions.md).[`gcTime`](MutationOptions.md#gctime) + +*** + +### meta? + +```ts +optional meta: Record; +``` + +Defined in: [packages/query-core/src/types.ts:1263](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1263) + +#### Inherited from + +[`MutationOptions`](MutationOptions.md).[`meta`](MutationOptions.md#meta) + +*** + +### mutationFn? + +```ts +optional mutationFn: MutationFunction; +``` + +Defined in: [packages/query-core/src/types.ts:1206](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1206) + +#### Inherited from + +```ts +OmitKeyof.mutationFn +``` + +*** + +### mutationKey? + +```ts +optional mutationKey: readonly unknown[]; +``` + +Defined in: [packages/query-core/src/types.ts:1207](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1207) + +#### Inherited from + +[`MutationOptions`](MutationOptions.md).[`mutationKey`](MutationOptions.md#mutationkey) + +*** + +### networkMode? + +```ts +optional networkMode: NetworkMode; +``` + +Defined in: [packages/query-core/src/types.ts:1253](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1253) + +Controls whether a mutation is allowed to run based on the current network connectivity. + +Defaults to `'online'`. + +#### See + +[Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. + +#### Inherited from + +[`MutationOptions`](MutationOptions.md).[`networkMode`](MutationOptions.md#networkmode) + +*** + +### onError()? + +```ts +optional onError: (error, variables, onMutateResult, context) => unknown; +``` + +Defined in: [packages/query-core/src/types.ts:1218](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1218) + +#### Parameters + +##### error + +`TError` + +##### variables + +`TVariables` + +##### onMutateResult + +`TOnMutateResult` | `undefined` + +##### context + +[`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md) + +#### Returns + +`unknown` + +#### Inherited from + +```ts +OmitKeyof.onError +``` + +*** + +### onMutate()? + +```ts +optional onMutate: (variables, context) => TOnMutateResult | Promise; +``` + +Defined in: [packages/query-core/src/types.ts:1208](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1208) + +#### Parameters + +##### variables + +`TVariables` + +##### context + +[`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md) + +#### Returns + +`TOnMutateResult` \| `Promise`\<`TOnMutateResult`\> + +#### Inherited from + +```ts +OmitKeyof.onMutate +``` + +*** + +### onSettled()? + +```ts +optional onSettled: (data, error, variables, onMutateResult, context) => unknown; +``` + +Defined in: [packages/query-core/src/types.ts:1224](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1224) + +#### Parameters + +##### data + +`TData` | `undefined` + +##### error + +`TError` | `null` + +##### variables + +`TVariables` + +##### onMutateResult + +`TOnMutateResult` | `undefined` + +##### context + +[`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md) + +#### Returns + +`unknown` + +#### Inherited from + +```ts +OmitKeyof.onSettled +``` + +*** + +### onSuccess()? + +```ts +optional onSuccess: (data, variables, onMutateResult, context) => unknown; +``` + +Defined in: [packages/query-core/src/types.ts:1212](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1212) + +#### Parameters + +##### data + +`TData` + +##### variables + +`TVariables` + +##### onMutateResult + +`TOnMutateResult` + +##### context + +[`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md) + +#### Returns + +`unknown` + +#### Inherited from + +```ts +OmitKeyof.onSuccess +``` + +*** + +### retry? + +```ts +optional retry: RetryValue; +``` + +Defined in: [packages/query-core/src/types.ts:1239](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1239) + +If `false`, failed mutations will not retry by default. +If `true`, failed mutations will retry infinitely. +If set to an integer number, e.g. 3, failed mutations will retry until the failed mutation count meets that number. +If set to a function `(failureCount, error) => boolean` failed mutations will retry until the function returns false. + +Defaults to `0`. + +#### Inherited from + +```ts +OmitKeyof.retry +``` + +*** + +### retryDelay? + +```ts +optional retryDelay: RetryDelayValue; +``` + +Defined in: [packages/query-core/src/types.ts:1246](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1246) + +This function receives a `retryAttempt` integer and the actual Error and returns the delay to apply before the +next attempt in milliseconds. + +Defaults to a function that applies exponential backoff, capped at 30 seconds. + +#### Inherited from + +```ts +OmitKeyof.retryDelay +``` + +*** + +### scope? + +```ts +optional scope: MutationScope; +``` + +Defined in: [packages/query-core/src/types.ts:1264](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1264) + +#### Inherited from + +[`MutationOptions`](MutationOptions.md).[`scope`](MutationOptions.md#scope) + +*** + +### throwOnError? + +```ts +optional throwOnError: boolean | (error) => boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1281](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1281) + +Whether errors should be thrown instead of setting the `error` property. +If set to `true`, all errors will be thrown to the nearest error boundary. +If set to a function, it will be passed the error and should return a boolean indicating whether to throw the +error (`true`) or return it as state (`false`). + +Defaults to `false`. + +#### Inherited from + +```ts +OmitKeyof.throwOnError +``` diff --git a/docs/framework/react/reference/interfaces/UseQueryOptions.md b/docs/framework/react/reference/interfaces/UseQueryOptions.md index 2099250b292..a5836050308 100644 --- a/docs/framework/react/reference/interfaces/UseQueryOptions.md +++ b/docs/framework/react/reference/interfaces/UseQueryOptions.md @@ -3,14 +3,14 @@ id: UseQueryOptions title: UseQueryOptions --- -Defined in: [react-query/src/types.ts:165](https://github.com/TanStack/query/blob/main/packages/react-query/src/types.ts#L165) +Defined in: [packages/react-query/src/types.ts:165](https://github.com/TanStack/query/blob/main/packages/react-query/src/types.ts#L165) The options accepted by `useQuery`. Same as [UseBaseQueryOptions](UseBaseQueryOptions.md), minus `suspense` (which `react-query` derives from which hook you call rather than exposing as an option). ## Extends -- `OmitKeyof`\<[`UseBaseQueryOptions`](UseBaseQueryOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryFnData`, `TQueryKey`\>, `"suspense"`\> +- [`OmitKeyof`](../type-aliases/OmitKeyof.md)\<[`UseBaseQueryOptions`](UseBaseQueryOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryFnData`, `TQueryKey`\>, `"suspense"`\> ## Type Parameters @@ -22,7 +22,7 @@ The type your `queryFn` resolves to. ### TError -`TError` = `DefaultError` +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) The type of errors your `queryFn` may throw. @@ -35,19 +35,603 @@ The type `data` ends up as after `select` runs. Defaults to `TQueryFnData` when ### TQueryKey -`TQueryKey` *extends* `QueryKey` = `QueryKey` +`TQueryKey` *extends* [`QueryKey`](../type-aliases/QueryKey.md) = [`QueryKey`](../type-aliases/QueryKey.md) The type of your `queryKey`. ## Properties +### enabled? + +```ts +optional enabled: QueryBooleanOption; +``` + +Defined in: [packages/query-core/src/types.ts:398](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L398) + +Set this to `false` or a function that returns `false` to disable automatic refetching when the query mounts or changes query keys. +To refetch the query, use the `refetch` method returned from the `useQuery` instance. +Accepts a boolean or function that returns a boolean. + +Defaults to `true`. + +#### Inherited from + +```ts +OmitKeyof.enabled +``` + +*** + +### gcTime? + +```ts +optional gcTime: number; +``` + +Defined in: [packages/query-core/src/types.ts:277](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L277) + +The time in milliseconds that unused/inactive cache data remains in memory. +When a query's cache becomes unused or inactive, that cache data will be garbage collected after this duration. +When different garbage collection times are specified, the longest one will be used. +Setting it to `Infinity` will disable garbage collection. + +Defaults to `5 * 60 * 1000` (5 minutes), or `Infinity` during SSR. + +Note: the maximum allowed time is about 24 days, imposed by `setTimeout`'s 32-bit signed integer delay — see +`timeoutManager.setTimeoutProvider` for a workaround. + +#### Inherited from + +[`QueryOptions`](QueryOptions.md).[`gcTime`](QueryOptions.md#gctime) + +*** + +### initialData? + +```ts +optional initialData: + | TQueryFnData +| InitialDataFunction; +``` + +Defined in: [packages/query-core/src/types.ts:317](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L317) + +If set, this value will be used as the initial data for the query cache (as long as the query hasn't been +created or cached yet). +If set to a function, the function will be called **once** during the shared/root query initialization, and be +expected to synchronously return the initial data. +Initial data is considered stale by default unless a `staleTime` has been set. +`initialData` **is persisted** to the cache. + +#### Inherited from + +```ts +OmitKeyof.initialData +``` + +*** + +### initialDataUpdatedAt? + +```ts +optional initialDataUpdatedAt: number | () => number | undefined; +``` + +Defined in: [packages/query-core/src/types.ts:321](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L321) + +If set, this value will be used as the time (in milliseconds) of when the `initialData` itself was last updated. + +#### Inherited from + +```ts +OmitKeyof.initialDataUpdatedAt +``` + +*** + +### maxPages? + +```ts +optional maxPages: number; +``` + +Defined in: [packages/query-core/src/types.ts:345](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L345) + +Maximum number of pages to store in the data of an infinite query. + +#### Inherited from + +[`QueryOptions`](QueryOptions.md).[`maxPages`](QueryOptions.md#maxpages) + +*** + +### meta? + +```ts +optional meta: Record; +``` + +Defined in: [packages/query-core/src/types.ts:341](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L341) + +Additional payload to be stored on each query. +Use this property to pass information that can be used in other places. + +#### Inherited from + +[`QueryOptions`](QueryOptions.md).[`meta`](QueryOptions.md#meta) + +*** + +### networkMode? + +```ts +optional networkMode: NetworkMode; +``` + +Defined in: [packages/query-core/src/types.ts:265](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L265) + +Controls whether a query is allowed to run based on the current network connectivity. + +Defaults to `'online'`. + +#### See + +[Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. + +#### Inherited from + +[`QueryOptions`](QueryOptions.md).[`networkMode`](QueryOptions.md#networkmode) + +*** + +### notifyOnChangeProps? + +```ts +optional notifyOnChangeProps: NotifyOnChangeProps; +``` + +Defined in: [packages/query-core/src/types.ts:484](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L484) + +If set, the component will only re-render if any of the listed properties change. +When set to `['data', 'error']`, the component will only re-render when the `data` or `error` properties change. +When set to `'all'`, the component will re-render whenever a query is updated. +When set to a function, the function will be executed to compute the list of properties. + +Defaults to `undefined`, in which case property access is tracked automatically, and the +component only re-renders when one of the tracked properties changes. + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`notifyOnChangeProps`](QueryObserverOptions.md#notifyonchangeprops) + +*** + +### persister()? + +```ts +optional persister: (queryFn, context, query) => TQueryFnData | Promise; +``` + +Defined in: [packages/query-core/src/types.ts:290](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L290) + +This option can be used to persist the result of a query to an external storage, bypassing the need to actually +call the `queryFn`. Useful for persisting a query's data across e.g. server/client boundaries. + +#### Parameters + +##### queryFn + +[`QueryFunction`](../type-aliases/QueryFunction.md)\<`TQueryFnData`, `NoInfer`\<`TQueryKey`\>, `never`\> + +##### context + +###### client + +[`QueryClient`](../classes/QueryClient.md) + +###### direction? + +`unknown` + +**Deprecated** + +if you want access to the direction, you can add it to the pageParam + +###### meta + +`Record`\<`string`, `unknown`\> \| `undefined` + +###### pageParam? + +`unknown` + +###### queryKey + +`NoInfer`\<`TQueryKey`\> + +###### signal + +`AbortSignal` + +##### query + +[`Query`](../classes/Query.md) + +#### Returns + +`TQueryFnData` \| `Promise`\<`TQueryFnData`\> + +#### Inherited from + +```ts +OmitKeyof.persister +``` + +*** + +### placeholderData? + +```ts +optional placeholderData: + | NonFunctionGuard +| PlaceholderDataFunction, TError, NonFunctionGuard, TQueryKey>; +``` + +Defined in: [packages/query-core/src/types.ts:511](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L511) + +If set, this value will be used as the placeholder data for this particular query observer while the query is still in the `loading` data and no initialData has been provided. + +#### Inherited from + +```ts +OmitKeyof.placeholderData +``` + +*** + +### queryFn? + +```ts +optional queryFn: + | typeof skipToken +| QueryFunction; +``` + +Defined in: [packages/query-core/src/types.ts:285](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L285) + +The function that the query will use to request data. +Required, unless a default query function has been set via `queryClient.setQueryDefaults` or +`queryClient.setDefaultOptions`. +Receives a [QueryFunctionContext](../type-aliases/QueryFunctionContext.md). +Must return a promise that will either resolve data or throw an error. The data cannot be `undefined`. + +#### Inherited from + +```ts +OmitKeyof.queryFn +``` + +*** + +### queryHash? + +```ts +optional queryHash: string; +``` + +Defined in: [packages/query-core/src/types.ts:295](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L295) + +The hashed form of `queryKey`, computed with `queryKeyHashFn` (or the default hashing function otherwise). Used +as the actual cache key internally. + +#### Inherited from + +[`QueryOptions`](QueryOptions.md).[`queryHash`](QueryOptions.md#queryhash) + +*** + +### queryKey + +```ts +queryKey: TQueryKey & object; +``` + +Defined in: [packages/query-core/src/types.ts:304](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L304) + +The query key to use for this query. + +The query key will be hashed into a stable hash. See [Query Keys](https://tanstack.com/query/latest/docs/framework/react/guides/query-keys) +for more information. + +The query will automatically update when this key changes (as long as `enabled` is not set to `false`). + +#### Inherited from + +```ts +OmitKeyof.queryKey +``` + +*** + +### queryKeyHashFn? + +```ts +optional queryKeyHashFn: QueryKeyHashFunction; +``` + +Defined in: [packages/query-core/src/types.ts:308](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L308) + +If specified, this function is used to hash the `queryKey` to a string. + +#### Inherited from + +```ts +OmitKeyof.queryKeyHashFn +``` + +*** + +### refetchInterval? + +```ts +optional refetchInterval: number | false | (query) => number | false | undefined; +``` + +Defined in: [packages/query-core/src/types.ts:414](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L414) + +If set to a number, the query will continuously refetch at this frequency in milliseconds. +If set to a function, the function will be executed with the latest data and query to compute a frequency + +Defaults to `false`. + +#### Inherited from + +```ts +OmitKeyof.refetchInterval +``` + +*** + +### refetchIntervalInBackground? + +```ts +optional refetchIntervalInBackground: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:425](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L425) + +If set to `true`, the query will continue to refetch while their tab/window is in the background. + +Defaults to `false`. + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`refetchIntervalInBackground`](QueryObserverOptions.md#refetchintervalinbackground) + +*** + +### refetchOnMount? + +```ts +optional refetchOnMount: boolean | "always" | (query) => boolean | "always"; +``` + +Defined in: [packages/query-core/src/types.ts:462](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L462) + +If set to `true`, the query will refetch on mount if the data is stale. +If set to `false`, will disable additional instances of a query to trigger background refetch. +If set to `'always'`, the query will always refetch on mount (except when `staleTime: 'static'` is used). +If set to a function, the function will be executed with the latest data and query to compute the value + +Defaults to `true`. + +#### Inherited from + +```ts +OmitKeyof.refetchOnMount +``` + +*** + +### refetchOnReconnect? + +```ts +optional refetchOnReconnect: boolean | "always" | (query) => boolean | "always"; +``` + +Defined in: [packages/query-core/src/types.ts:448](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L448) + +If set to `true`, the query will refetch on reconnect if the data is stale. +If set to `false`, the query will not refetch on reconnect. +If set to `'always'`, the query will always refetch on reconnect (except when `staleTime: 'static'` is used). +If set to a function, the function will be executed with the latest data and query to compute the value. + +Defaults to `true` unless `networkMode` is `'always'`. + +#### Inherited from + +```ts +OmitKeyof.refetchOnReconnect +``` + +*** + +### refetchOnWindowFocus? + +```ts +optional refetchOnWindowFocus: boolean | "always" | (query) => boolean | "always"; +``` + +Defined in: [packages/query-core/src/types.ts:434](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L434) + +If set to `true`, the query will refetch on window focus if the data is stale. +If set to `false`, the query will not refetch on window focus. +If set to `'always'`, the query will always refetch on window focus (except when `staleTime: 'static'` is used). +If set to a function, the function will be executed with the latest data and query to compute the value. + +Defaults to `true`. + +#### Inherited from + +```ts +OmitKeyof.refetchOnWindowFocus +``` + +*** + +### retry? + +```ts +optional retry: RetryValue; +``` + +Defined in: [packages/query-core/src/types.ts:246](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L246) + +If `false`, failed queries will not retry by default. +If `true`, failed queries will retry infinitely. +If set to an integer number, e.g. 3, failed queries will retry until the failed query count meets that number. +If set to a function `(failureCount, error) => boolean` failed queries will retry until the function returns false. + +Defaults to `3` on the client and `0` on the server. + +#### Inherited from + +```ts +OmitKeyof.retry +``` + +*** + +### retryDelay? + +```ts +optional retryDelay: RetryDelayValue; +``` + +Defined in: [packages/query-core/src/types.ts:258](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L258) + +This function receives a `retryAttempt` integer and the actual Error and returns the delay to apply before the +next attempt in milliseconds. + +A function like `attempt => Math.min(attempt > 1 ? 2 ** attempt * 1000 : 1000, 30 * 1000)` applies exponential +backoff. + +A function like `attempt => attempt * 1000` applies linear backoff. + +Defaults to a function that applies exponential backoff, capped at 30 seconds. + +#### Inherited from + +```ts +OmitKeyof.retryDelay +``` + +*** + +### retryOnMount? + +```ts +optional retryOnMount: QueryBooleanOption; +``` + +Defined in: [packages/query-core/src/types.ts:474](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L474) + +If set to `false`, the query will not be retried on mount if it contains an error. +If set to a function, the function will be executed with the query to compute the value. + +Defaults to `true`. + +#### Inherited from + +```ts +OmitKeyof.retryOnMount +``` + +*** + +### select()? + +```ts +optional select: (data) => TData; +``` + +Defined in: [packages/query-core/src/types.ts:500](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L500) + +This option can be used to transform or select a part of the data returned by the query function. It affects +the returned `data` value, but does not affect what gets stored in the query cache. +The `select` function will only run if `data` changed, or if the reference to the `select` function itself +changes. To optimize, memoize the function so its reference stays stable across calls. + +#### Parameters + +##### data + +`TQueryFnData` + +#### Returns + +`TData` + +#### Inherited from + +```ts +OmitKeyof.select +``` + +*** + +### staleTime? + +```ts +optional staleTime: StaleTimeFunction; +``` + +Defined in: [packages/query-core/src/types.ts:407](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L407) + +The time in milliseconds after data is considered stale. +If set to `Infinity`, the data will never be considered stale. +If set to `'static'`, the data will never be considered stale. +If set to a function, the function will be executed with the query to compute a `staleTime`. + +Defaults to `0`. + +#### Inherited from + +```ts +OmitKeyof.staleTime +``` + +*** + +### structuralSharing? + +```ts +optional structuralSharing: boolean | (oldData, newData) => unknown; +``` + +Defined in: [packages/query-core/src/types.ts:330](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L330) + +Set this to `false` to disable structural sharing between query results. +Set this to a function which accepts the old and new data and returns resolved data of the same type to implement custom structural sharing logic. + +Defaults to `true`. + +#### Inherited from + +```ts +OmitKeyof.structuralSharing +``` + +*** + ### subscribed? ```ts optional subscribed: boolean; ``` -Defined in: [react-query/src/types.ts:65](https://github.com/TanStack/query/blob/main/packages/react-query/src/types.ts#L65) +Defined in: [packages/react-query/src/types.ts:65](https://github.com/TanStack/query/blob/main/packages/react-query/src/types.ts#L65) Set this to `false` to unsubscribe this observer from updates to the query cache. @@ -62,3 +646,26 @@ true ```ts OmitKeyof.subscribed ``` + +*** + +### throwOnError? + +```ts +optional throwOnError: ThrowOnError; +``` + +Defined in: [packages/query-core/src/types.ts:493](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L493) + +Whether errors should be thrown instead of setting the `error` property. +If set to `true` or `suspense` is `true`, all errors will be thrown to the error boundary. +If set to `false` and `suspense` is `false`, errors are returned as state. +If set to a function, it will be passed the error and the query, and it should return a boolean indicating whether to show the error in an error boundary (`true`) or return the error as state (`false`). + +Defaults to `false`. + +#### Inherited from + +```ts +OmitKeyof.throwOnError +``` diff --git a/docs/framework/react/reference/interfaces/UseSuspenseInfiniteQueryOptions.md b/docs/framework/react/reference/interfaces/UseSuspenseInfiniteQueryOptions.md index c3ea5865ffe..7d62e4dc3ba 100644 --- a/docs/framework/react/reference/interfaces/UseSuspenseInfiniteQueryOptions.md +++ b/docs/framework/react/reference/interfaces/UseSuspenseInfiniteQueryOptions.md @@ -3,7 +3,7 @@ id: UseSuspenseInfiniteQueryOptions title: UseSuspenseInfiniteQueryOptions --- -Defined in: [react-query/src/types.ts:280](https://github.com/TanStack/query/blob/main/packages/react-query/src/types.ts#L280) +Defined in: [packages/react-query/src/types.ts:280](https://github.com/TanStack/query/blob/main/packages/react-query/src/types.ts#L280) The options accepted by `useSuspenseInfiniteQuery`. Same as [UseInfiniteQueryOptions](UseInfiniteQueryOptions.md), minus `enabled`, `throwOnError`, and `placeholderData` — Suspense hooks cannot render a "disabled" or "placeholder" state, so @@ -11,7 +11,7 @@ those options don't apply. ## Extends -- `OmitKeyof`\<[`UseInfiniteQueryOptions`](UseInfiniteQueryOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`, `TPageParam`\>, `"queryFn"` \| `"enabled"` \| `"throwOnError"` \| `"placeholderData"`\> +- [`OmitKeyof`](../type-aliases/OmitKeyof.md)\<[`UseInfiniteQueryOptions`](UseInfiniteQueryOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`, `TPageParam`\>, `"queryFn"` \| `"enabled"` \| `"throwOnError"` \| `"placeholderData"`\> ## Type Parameters @@ -23,20 +23,20 @@ The type of a single page, as your `queryFn` resolves it. ### TError -`TError` = `DefaultError` +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) The type of errors your `queryFn` may throw. ### TData -`TData` = `InfiniteData`\<`TQueryFnData`\> +`TData` = [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`\> The type `data` ends up as after `select` runs — defaults to `InfiniteData`, the shape of all fetched pages plus their page params. ### TQueryKey -`TQueryKey` *extends* `QueryKey` = `QueryKey` +`TQueryKey` *extends* [`QueryKey`](../type-aliases/QueryKey.md) = [`QueryKey`](../type-aliases/QueryKey.md) The type of your `queryKey`. @@ -48,26 +48,554 @@ The type of the parameter passed to `queryFn` to fetch a given page. ## Properties +### gcTime? + +```ts +optional gcTime: number; +``` + +Defined in: [packages/query-core/src/types.ts:277](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L277) + +The time in milliseconds that unused/inactive cache data remains in memory. +When a query's cache becomes unused or inactive, that cache data will be garbage collected after this duration. +When different garbage collection times are specified, the longest one will be used. +Setting it to `Infinity` will disable garbage collection. + +Defaults to `5 * 60 * 1000` (5 minutes), or `Infinity` during SSR. + +Note: the maximum allowed time is about 24 days, imposed by `setTimeout`'s 32-bit signed integer delay — see +`timeoutManager.setTimeoutProvider` for a workaround. + +#### Inherited from + +[`QueryOptions`](QueryOptions.md).[`gcTime`](QueryOptions.md#gctime) + +*** + +### getNextPageParam + +```ts +getNextPageParam: GetNextPageParamFunction; +``` + +Defined in: [packages/query-core/src/types.ts:365](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L365) + +This function can be set to automatically get the next cursor for infinite queries. +The result will also be used to determine the value of `hasNextPage`. + +#### Inherited from + +```ts +OmitKeyof.getNextPageParam +``` + +*** + +### getPreviousPageParam? + +```ts +optional getPreviousPageParam: GetPreviousPageParamFunction; +``` + +Defined in: [packages/query-core/src/types.ts:360](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L360) + +This function can be set to automatically get the previous cursor for infinite queries. +The result will also be used to determine the value of `hasPreviousPage`. + +#### Inherited from + +```ts +OmitKeyof.getPreviousPageParam +``` + +*** + +### initialData? + +```ts +optional initialData: + | InfiniteData +| InitialDataFunction>; +``` + +Defined in: [packages/query-core/src/types.ts:317](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L317) + +If set, this value will be used as the initial data for the query cache (as long as the query hasn't been +created or cached yet). +If set to a function, the function will be called **once** during the shared/root query initialization, and be +expected to synchronously return the initial data. +Initial data is considered stale by default unless a `staleTime` has been set. +`initialData` **is persisted** to the cache. + +#### Inherited from + +```ts +OmitKeyof.initialData +``` + +*** + +### initialDataUpdatedAt? + +```ts +optional initialDataUpdatedAt: number | () => number | undefined; +``` + +Defined in: [packages/query-core/src/types.ts:321](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L321) + +If set, this value will be used as the time (in milliseconds) of when the `initialData` itself was last updated. + +#### Inherited from + +```ts +OmitKeyof.initialDataUpdatedAt +``` + +*** + +### initialPageParam + +```ts +initialPageParam: TPageParam; +``` + +Defined in: [packages/query-core/src/types.ts:349](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L349) + +#### Inherited from + +```ts +OmitKeyof.initialPageParam +``` + +*** + +### maxPages? + +```ts +optional maxPages: number; +``` + +Defined in: [packages/query-core/src/types.ts:345](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L345) + +Maximum number of pages to store in the data of an infinite query. + +#### Inherited from + +[`QueryOptions`](QueryOptions.md).[`maxPages`](QueryOptions.md#maxpages) + +*** + +### meta? + +```ts +optional meta: Record; +``` + +Defined in: [packages/query-core/src/types.ts:341](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L341) + +Additional payload to be stored on each query. +Use this property to pass information that can be used in other places. + +#### Inherited from + +[`QueryOptions`](QueryOptions.md).[`meta`](QueryOptions.md#meta) + +*** + +### networkMode? + +```ts +optional networkMode: NetworkMode; +``` + +Defined in: [packages/query-core/src/types.ts:265](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L265) + +Controls whether a query is allowed to run based on the current network connectivity. + +Defaults to `'online'`. + +#### See + +[Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. + +#### Inherited from + +[`QueryOptions`](QueryOptions.md).[`networkMode`](QueryOptions.md#networkmode) + +*** + +### notifyOnChangeProps? + +```ts +optional notifyOnChangeProps: NotifyOnChangeProps; +``` + +Defined in: [packages/query-core/src/types.ts:484](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L484) + +If set, the component will only re-render if any of the listed properties change. +When set to `['data', 'error']`, the component will only re-render when the `data` or `error` properties change. +When set to `'all'`, the component will re-render whenever a query is updated. +When set to a function, the function will be executed to compute the list of properties. + +Defaults to `undefined`, in which case property access is tracked automatically, and the +component only re-renders when one of the tracked properties changes. + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`notifyOnChangeProps`](QueryObserverOptions.md#notifyonchangeprops) + +*** + +### persister? + +```ts +optional persister: QueryPersister, TPageParam>; +``` + +Defined in: [packages/query-core/src/types.ts:290](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L290) + +This option can be used to persist the result of a query to an external storage, bypassing the need to actually +call the `queryFn`. Useful for persisting a query's data across e.g. server/client boundaries. + +#### Inherited from + +```ts +OmitKeyof.persister +``` + +*** + ### queryFn? ```ts optional queryFn: QueryFunction; ``` -Defined in: [react-query/src/types.ts:294](https://github.com/TanStack/query/blob/main/packages/react-query/src/types.ts#L294) +Defined in: [packages/react-query/src/types.ts:294](https://github.com/TanStack/query/blob/main/packages/react-query/src/types.ts#L294) `skipToken` is not allowed here — Suspense hooks cannot render a "disabled" state, so a query function must always be provided, unless a default query function has been defined. *** +### queryHash? + +```ts +optional queryHash: string; +``` + +Defined in: [packages/query-core/src/types.ts:295](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L295) + +The hashed form of `queryKey`, computed with `queryKeyHashFn` (or the default hashing function otherwise). Used +as the actual cache key internally. + +#### Inherited from + +[`QueryOptions`](QueryOptions.md).[`queryHash`](QueryOptions.md#queryhash) + +*** + +### queryKey + +```ts +queryKey: TQueryKey & object; +``` + +Defined in: [packages/query-core/src/types.ts:304](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L304) + +The query key to use for this query. + +The query key will be hashed into a stable hash. See [Query Keys](https://tanstack.com/query/latest/docs/framework/react/guides/query-keys) +for more information. + +The query will automatically update when this key changes (as long as `enabled` is not set to `false`). + +#### Inherited from + +```ts +OmitKeyof.queryKey +``` + +*** + +### queryKeyHashFn? + +```ts +optional queryKeyHashFn: QueryKeyHashFunction; +``` + +Defined in: [packages/query-core/src/types.ts:308](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L308) + +If specified, this function is used to hash the `queryKey` to a string. + +#### Inherited from + +```ts +OmitKeyof.queryKeyHashFn +``` + +*** + +### refetchInterval? + +```ts +optional refetchInterval: number | false | (query) => number | false | undefined; +``` + +Defined in: [packages/query-core/src/types.ts:414](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L414) + +If set to a number, the query will continuously refetch at this frequency in milliseconds. +If set to a function, the function will be executed with the latest data and query to compute a frequency + +Defaults to `false`. + +#### Inherited from + +```ts +OmitKeyof.refetchInterval +``` + +*** + +### refetchIntervalInBackground? + +```ts +optional refetchIntervalInBackground: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:425](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L425) + +If set to `true`, the query will continue to refetch while their tab/window is in the background. + +Defaults to `false`. + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`refetchIntervalInBackground`](QueryObserverOptions.md#refetchintervalinbackground) + +*** + +### refetchOnMount? + +```ts +optional refetchOnMount: boolean | "always" | (query) => boolean | "always"; +``` + +Defined in: [packages/query-core/src/types.ts:462](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L462) + +If set to `true`, the query will refetch on mount if the data is stale. +If set to `false`, will disable additional instances of a query to trigger background refetch. +If set to `'always'`, the query will always refetch on mount (except when `staleTime: 'static'` is used). +If set to a function, the function will be executed with the latest data and query to compute the value + +Defaults to `true`. + +#### Inherited from + +```ts +OmitKeyof.refetchOnMount +``` + +*** + +### refetchOnReconnect? + +```ts +optional refetchOnReconnect: boolean | "always" | (query) => boolean | "always"; +``` + +Defined in: [packages/query-core/src/types.ts:448](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L448) + +If set to `true`, the query will refetch on reconnect if the data is stale. +If set to `false`, the query will not refetch on reconnect. +If set to `'always'`, the query will always refetch on reconnect (except when `staleTime: 'static'` is used). +If set to a function, the function will be executed with the latest data and query to compute the value. + +Defaults to `true` unless `networkMode` is `'always'`. + +#### Inherited from + +```ts +OmitKeyof.refetchOnReconnect +``` + +*** + +### refetchOnWindowFocus? + +```ts +optional refetchOnWindowFocus: boolean | "always" | (query) => boolean | "always"; +``` + +Defined in: [packages/query-core/src/types.ts:434](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L434) + +If set to `true`, the query will refetch on window focus if the data is stale. +If set to `false`, the query will not refetch on window focus. +If set to `'always'`, the query will always refetch on window focus (except when `staleTime: 'static'` is used). +If set to a function, the function will be executed with the latest data and query to compute the value. + +Defaults to `true`. + +#### Inherited from + +```ts +OmitKeyof.refetchOnWindowFocus +``` + +*** + +### retry? + +```ts +optional retry: RetryValue; +``` + +Defined in: [packages/query-core/src/types.ts:246](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L246) + +If `false`, failed queries will not retry by default. +If `true`, failed queries will retry infinitely. +If set to an integer number, e.g. 3, failed queries will retry until the failed query count meets that number. +If set to a function `(failureCount, error) => boolean` failed queries will retry until the function returns false. + +Defaults to `3` on the client and `0` on the server. + +#### Inherited from + +```ts +OmitKeyof.retry +``` + +*** + +### retryDelay? + +```ts +optional retryDelay: RetryDelayValue; +``` + +Defined in: [packages/query-core/src/types.ts:258](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L258) + +This function receives a `retryAttempt` integer and the actual Error and returns the delay to apply before the +next attempt in milliseconds. + +A function like `attempt => Math.min(attempt > 1 ? 2 ** attempt * 1000 : 1000, 30 * 1000)` applies exponential +backoff. + +A function like `attempt => attempt * 1000` applies linear backoff. + +Defaults to a function that applies exponential backoff, capped at 30 seconds. + +#### Inherited from + +```ts +OmitKeyof.retryDelay +``` + +*** + +### retryOnMount? + +```ts +optional retryOnMount: QueryBooleanOption, TQueryKey>; +``` + +Defined in: [packages/query-core/src/types.ts:474](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L474) + +If set to `false`, the query will not be retried on mount if it contains an error. +If set to a function, the function will be executed with the query to compute the value. + +Defaults to `true`. + +#### Inherited from + +```ts +OmitKeyof.retryOnMount +``` + +*** + +### select()? + +```ts +optional select: (data) => TData; +``` + +Defined in: [packages/query-core/src/types.ts:500](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L500) + +This option can be used to transform or select a part of the data returned by the query function. It affects +the returned `data` value, but does not affect what gets stored in the query cache. +The `select` function will only run if `data` changed, or if the reference to the `select` function itself +changes. To optimize, memoize the function so its reference stays stable across calls. + +#### Parameters + +##### data + +[`InfiniteData`](InfiniteData.md) + +#### Returns + +`TData` + +#### Inherited from + +```ts +OmitKeyof.select +``` + +*** + +### staleTime? + +```ts +optional staleTime: StaleTimeFunction, TQueryKey>; +``` + +Defined in: [packages/query-core/src/types.ts:407](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L407) + +The time in milliseconds after data is considered stale. +If set to `Infinity`, the data will never be considered stale. +If set to `'static'`, the data will never be considered stale. +If set to a function, the function will be executed with the query to compute a `staleTime`. + +Defaults to `0`. + +#### Inherited from + +```ts +OmitKeyof.staleTime +``` + +*** + +### structuralSharing? + +```ts +optional structuralSharing: boolean | (oldData, newData) => unknown; +``` + +Defined in: [packages/query-core/src/types.ts:330](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L330) + +Set this to `false` to disable structural sharing between query results. +Set this to a function which accepts the old and new data and returns resolved data of the same type to implement custom structural sharing logic. + +Defaults to `true`. + +#### Inherited from + +```ts +OmitKeyof.structuralSharing +``` + +*** + ### subscribed? ```ts optional subscribed: boolean; ``` -Defined in: [react-query/src/types.ts:259](https://github.com/TanStack/query/blob/main/packages/react-query/src/types.ts#L259) +Defined in: [packages/react-query/src/types.ts:259](https://github.com/TanStack/query/blob/main/packages/react-query/src/types.ts#L259) Set this to `false` to unsubscribe this observer from updates to the query cache. diff --git a/docs/framework/react/reference/interfaces/UseSuspenseQueryOptions.md b/docs/framework/react/reference/interfaces/UseSuspenseQueryOptions.md index f6177722755..4cd6b24905b 100644 --- a/docs/framework/react/reference/interfaces/UseSuspenseQueryOptions.md +++ b/docs/framework/react/reference/interfaces/UseSuspenseQueryOptions.md @@ -3,7 +3,7 @@ id: UseSuspenseQueryOptions title: UseSuspenseQueryOptions --- -Defined in: [react-query/src/types.ts:196](https://github.com/TanStack/query/blob/main/packages/react-query/src/types.ts#L196) +Defined in: [packages/react-query/src/types.ts:196](https://github.com/TanStack/query/blob/main/packages/react-query/src/types.ts#L196) The options accepted by `useSuspenseQuery`. Same as [UseQueryOptions](UseQueryOptions.md), minus `enabled`, `throwOnError`, and `placeholderData` — Suspense hooks cannot render a "disabled" or "placeholder" state, so those options @@ -11,7 +11,7 @@ don't apply. ## Extends -- `OmitKeyof`\<[`UseQueryOptions`](UseQueryOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`\>, `"queryFn"` \| `"enabled"` \| `"throwOnError"` \| `"placeholderData"`\> +- [`OmitKeyof`](../type-aliases/OmitKeyof.md)\<[`UseQueryOptions`](UseQueryOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`\>, `"queryFn"` \| `"enabled"` \| `"throwOnError"` \| `"placeholderData"`\> ## Type Parameters @@ -23,7 +23,7 @@ The type your `queryFn` resolves to. ### TError -`TError` = `DefaultError` +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) The type of errors your `queryFn` may throw. @@ -36,32 +36,550 @@ The type `data` ends up as after `select` runs. Defaults to `TQueryFnData` when ### TQueryKey -`TQueryKey` *extends* `QueryKey` = `QueryKey` +`TQueryKey` *extends* [`QueryKey`](../type-aliases/QueryKey.md) = [`QueryKey`](../type-aliases/QueryKey.md) The type of your `queryKey`. ## Properties +### gcTime? + +```ts +optional gcTime: number; +``` + +Defined in: [packages/query-core/src/types.ts:277](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L277) + +The time in milliseconds that unused/inactive cache data remains in memory. +When a query's cache becomes unused or inactive, that cache data will be garbage collected after this duration. +When different garbage collection times are specified, the longest one will be used. +Setting it to `Infinity` will disable garbage collection. + +Defaults to `5 * 60 * 1000` (5 minutes), or `Infinity` during SSR. + +Note: the maximum allowed time is about 24 days, imposed by `setTimeout`'s 32-bit signed integer delay — see +`timeoutManager.setTimeoutProvider` for a workaround. + +#### Inherited from + +[`QueryOptions`](QueryOptions.md).[`gcTime`](QueryOptions.md#gctime) + +*** + +### initialData? + +```ts +optional initialData: + | TQueryFnData +| InitialDataFunction; +``` + +Defined in: [packages/query-core/src/types.ts:317](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L317) + +If set, this value will be used as the initial data for the query cache (as long as the query hasn't been +created or cached yet). +If set to a function, the function will be called **once** during the shared/root query initialization, and be +expected to synchronously return the initial data. +Initial data is considered stale by default unless a `staleTime` has been set. +`initialData` **is persisted** to the cache. + +#### Inherited from + +```ts +OmitKeyof.initialData +``` + +*** + +### initialDataUpdatedAt? + +```ts +optional initialDataUpdatedAt: number | () => number | undefined; +``` + +Defined in: [packages/query-core/src/types.ts:321](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L321) + +If set, this value will be used as the time (in milliseconds) of when the `initialData` itself was last updated. + +#### Inherited from + +```ts +OmitKeyof.initialDataUpdatedAt +``` + +*** + +### maxPages? + +```ts +optional maxPages: number; +``` + +Defined in: [packages/query-core/src/types.ts:345](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L345) + +Maximum number of pages to store in the data of an infinite query. + +#### Inherited from + +[`QueryOptions`](QueryOptions.md).[`maxPages`](QueryOptions.md#maxpages) + +*** + +### meta? + +```ts +optional meta: Record; +``` + +Defined in: [packages/query-core/src/types.ts:341](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L341) + +Additional payload to be stored on each query. +Use this property to pass information that can be used in other places. + +#### Inherited from + +[`QueryOptions`](QueryOptions.md).[`meta`](QueryOptions.md#meta) + +*** + +### networkMode? + +```ts +optional networkMode: NetworkMode; +``` + +Defined in: [packages/query-core/src/types.ts:265](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L265) + +Controls whether a query is allowed to run based on the current network connectivity. + +Defaults to `'online'`. + +#### See + +[Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. + +#### Inherited from + +[`QueryOptions`](QueryOptions.md).[`networkMode`](QueryOptions.md#networkmode) + +*** + +### notifyOnChangeProps? + +```ts +optional notifyOnChangeProps: NotifyOnChangeProps; +``` + +Defined in: [packages/query-core/src/types.ts:484](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L484) + +If set, the component will only re-render if any of the listed properties change. +When set to `['data', 'error']`, the component will only re-render when the `data` or `error` properties change. +When set to `'all'`, the component will re-render whenever a query is updated. +When set to a function, the function will be executed to compute the list of properties. + +Defaults to `undefined`, in which case property access is tracked automatically, and the +component only re-renders when one of the tracked properties changes. + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`notifyOnChangeProps`](QueryObserverOptions.md#notifyonchangeprops) + +*** + +### persister()? + +```ts +optional persister: (queryFn, context, query) => TQueryFnData | Promise; +``` + +Defined in: [packages/query-core/src/types.ts:290](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L290) + +This option can be used to persist the result of a query to an external storage, bypassing the need to actually +call the `queryFn`. Useful for persisting a query's data across e.g. server/client boundaries. + +#### Parameters + +##### queryFn + +[`QueryFunction`](../type-aliases/QueryFunction.md)\<`TQueryFnData`, `NoInfer`\<`TQueryKey`\>, `never`\> + +##### context + +###### client + +[`QueryClient`](../classes/QueryClient.md) + +###### direction? + +`unknown` + +**Deprecated** + +if you want access to the direction, you can add it to the pageParam + +###### meta + +`Record`\<`string`, `unknown`\> \| `undefined` + +###### pageParam? + +`unknown` + +###### queryKey + +`NoInfer`\<`TQueryKey`\> + +###### signal + +`AbortSignal` + +##### query + +[`Query`](../classes/Query.md) + +#### Returns + +`TQueryFnData` \| `Promise`\<`TQueryFnData`\> + +#### Inherited from + +```ts +OmitKeyof.persister +``` + +*** + ### queryFn? ```ts optional queryFn: QueryFunction; ``` -Defined in: [react-query/src/types.ts:209](https://github.com/TanStack/query/blob/main/packages/react-query/src/types.ts#L209) +Defined in: [packages/react-query/src/types.ts:209](https://github.com/TanStack/query/blob/main/packages/react-query/src/types.ts#L209) `skipToken` is not allowed here — Suspense hooks cannot render a "disabled" state, so a query function must always be provided, unless a default query function has been defined. *** +### queryHash? + +```ts +optional queryHash: string; +``` + +Defined in: [packages/query-core/src/types.ts:295](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L295) + +The hashed form of `queryKey`, computed with `queryKeyHashFn` (or the default hashing function otherwise). Used +as the actual cache key internally. + +#### Inherited from + +[`QueryOptions`](QueryOptions.md).[`queryHash`](QueryOptions.md#queryhash) + +*** + +### queryKey + +```ts +queryKey: TQueryKey & object; +``` + +Defined in: [packages/query-core/src/types.ts:304](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L304) + +The query key to use for this query. + +The query key will be hashed into a stable hash. See [Query Keys](https://tanstack.com/query/latest/docs/framework/react/guides/query-keys) +for more information. + +The query will automatically update when this key changes (as long as `enabled` is not set to `false`). + +#### Inherited from + +```ts +OmitKeyof.queryKey +``` + +*** + +### queryKeyHashFn? + +```ts +optional queryKeyHashFn: QueryKeyHashFunction; +``` + +Defined in: [packages/query-core/src/types.ts:308](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L308) + +If specified, this function is used to hash the `queryKey` to a string. + +#### Inherited from + +```ts +OmitKeyof.queryKeyHashFn +``` + +*** + +### refetchInterval? + +```ts +optional refetchInterval: number | false | (query) => number | false | undefined; +``` + +Defined in: [packages/query-core/src/types.ts:414](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L414) + +If set to a number, the query will continuously refetch at this frequency in milliseconds. +If set to a function, the function will be executed with the latest data and query to compute a frequency + +Defaults to `false`. + +#### Inherited from + +```ts +OmitKeyof.refetchInterval +``` + +*** + +### refetchIntervalInBackground? + +```ts +optional refetchIntervalInBackground: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:425](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L425) + +If set to `true`, the query will continue to refetch while their tab/window is in the background. + +Defaults to `false`. + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`refetchIntervalInBackground`](QueryObserverOptions.md#refetchintervalinbackground) + +*** + +### refetchOnMount? + +```ts +optional refetchOnMount: boolean | "always" | (query) => boolean | "always"; +``` + +Defined in: [packages/query-core/src/types.ts:462](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L462) + +If set to `true`, the query will refetch on mount if the data is stale. +If set to `false`, will disable additional instances of a query to trigger background refetch. +If set to `'always'`, the query will always refetch on mount (except when `staleTime: 'static'` is used). +If set to a function, the function will be executed with the latest data and query to compute the value + +Defaults to `true`. + +#### Inherited from + +```ts +OmitKeyof.refetchOnMount +``` + +*** + +### refetchOnReconnect? + +```ts +optional refetchOnReconnect: boolean | "always" | (query) => boolean | "always"; +``` + +Defined in: [packages/query-core/src/types.ts:448](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L448) + +If set to `true`, the query will refetch on reconnect if the data is stale. +If set to `false`, the query will not refetch on reconnect. +If set to `'always'`, the query will always refetch on reconnect (except when `staleTime: 'static'` is used). +If set to a function, the function will be executed with the latest data and query to compute the value. + +Defaults to `true` unless `networkMode` is `'always'`. + +#### Inherited from + +```ts +OmitKeyof.refetchOnReconnect +``` + +*** + +### refetchOnWindowFocus? + +```ts +optional refetchOnWindowFocus: boolean | "always" | (query) => boolean | "always"; +``` + +Defined in: [packages/query-core/src/types.ts:434](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L434) + +If set to `true`, the query will refetch on window focus if the data is stale. +If set to `false`, the query will not refetch on window focus. +If set to `'always'`, the query will always refetch on window focus (except when `staleTime: 'static'` is used). +If set to a function, the function will be executed with the latest data and query to compute the value. + +Defaults to `true`. + +#### Inherited from + +```ts +OmitKeyof.refetchOnWindowFocus +``` + +*** + +### retry? + +```ts +optional retry: RetryValue; +``` + +Defined in: [packages/query-core/src/types.ts:246](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L246) + +If `false`, failed queries will not retry by default. +If `true`, failed queries will retry infinitely. +If set to an integer number, e.g. 3, failed queries will retry until the failed query count meets that number. +If set to a function `(failureCount, error) => boolean` failed queries will retry until the function returns false. + +Defaults to `3` on the client and `0` on the server. + +#### Inherited from + +```ts +OmitKeyof.retry +``` + +*** + +### retryDelay? + +```ts +optional retryDelay: RetryDelayValue; +``` + +Defined in: [packages/query-core/src/types.ts:258](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L258) + +This function receives a `retryAttempt` integer and the actual Error and returns the delay to apply before the +next attempt in milliseconds. + +A function like `attempt => Math.min(attempt > 1 ? 2 ** attempt * 1000 : 1000, 30 * 1000)` applies exponential +backoff. + +A function like `attempt => attempt * 1000` applies linear backoff. + +Defaults to a function that applies exponential backoff, capped at 30 seconds. + +#### Inherited from + +```ts +OmitKeyof.retryDelay +``` + +*** + +### retryOnMount? + +```ts +optional retryOnMount: QueryBooleanOption; +``` + +Defined in: [packages/query-core/src/types.ts:474](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L474) + +If set to `false`, the query will not be retried on mount if it contains an error. +If set to a function, the function will be executed with the query to compute the value. + +Defaults to `true`. + +#### Inherited from + +```ts +OmitKeyof.retryOnMount +``` + +*** + +### select()? + +```ts +optional select: (data) => TData; +``` + +Defined in: [packages/query-core/src/types.ts:500](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L500) + +This option can be used to transform or select a part of the data returned by the query function. It affects +the returned `data` value, but does not affect what gets stored in the query cache. +The `select` function will only run if `data` changed, or if the reference to the `select` function itself +changes. To optimize, memoize the function so its reference stays stable across calls. + +#### Parameters + +##### data + +`TQueryFnData` + +#### Returns + +`TData` + +#### Inherited from + +```ts +OmitKeyof.select +``` + +*** + +### staleTime? + +```ts +optional staleTime: StaleTimeFunction; +``` + +Defined in: [packages/query-core/src/types.ts:407](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L407) + +The time in milliseconds after data is considered stale. +If set to `Infinity`, the data will never be considered stale. +If set to `'static'`, the data will never be considered stale. +If set to a function, the function will be executed with the query to compute a `staleTime`. + +Defaults to `0`. + +#### Inherited from + +```ts +OmitKeyof.staleTime +``` + +*** + +### structuralSharing? + +```ts +optional structuralSharing: boolean | (oldData, newData) => unknown; +``` + +Defined in: [packages/query-core/src/types.ts:330](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L330) + +Set this to `false` to disable structural sharing between query results. +Set this to a function which accepts the old and new data and returns resolved data of the same type to implement custom structural sharing logic. + +Defaults to `true`. + +#### Inherited from + +```ts +OmitKeyof.structuralSharing +``` + +*** + ### subscribed? ```ts optional subscribed: boolean; ``` -Defined in: [react-query/src/types.ts:65](https://github.com/TanStack/query/blob/main/packages/react-query/src/types.ts#L65) +Defined in: [packages/react-query/src/types.ts:65](https://github.com/TanStack/query/blob/main/packages/react-query/src/types.ts#L65) Set this to `false` to unsubscribe this observer from updates to the query cache. diff --git a/docs/framework/react/reference/type-aliases/AnyDataTag.md b/docs/framework/react/reference/type-aliases/AnyDataTag.md new file mode 100644 index 00000000000..d3d5e33bb3e --- /dev/null +++ b/docs/framework/react/reference/type-aliases/AnyDataTag.md @@ -0,0 +1,30 @@ +--- +id: AnyDataTag +title: AnyDataTag +--- + +```ts +type AnyDataTag = object; +``` + +Defined in: [packages/query-core/src/types.ts:67](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L67) + +## Properties + +### \[dataTagErrorSymbol\] + +```ts +[dataTagErrorSymbol]: any; +``` + +Defined in: [packages/query-core/src/types.ts:69](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L69) + +*** + +### \[dataTagSymbol\] + +```ts +[dataTagSymbol]: any; +``` + +Defined in: [packages/query-core/src/types.ts:68](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L68) diff --git a/docs/framework/react/reference/type-aliases/AnyUseBaseQueryOptions.md b/docs/framework/react/reference/type-aliases/AnyUseBaseQueryOptions.md index 947988618e0..441d01063ea 100644 --- a/docs/framework/react/reference/type-aliases/AnyUseBaseQueryOptions.md +++ b/docs/framework/react/reference/type-aliases/AnyUseBaseQueryOptions.md @@ -7,7 +7,7 @@ title: AnyUseBaseQueryOptions type AnyUseBaseQueryOptions = UseBaseQueryOptions; ``` -Defined in: [react-query/src/types.ts:28](https://github.com/TanStack/query/blob/main/packages/react-query/src/types.ts#L28) +Defined in: [packages/react-query/src/types.ts:28](https://github.com/TanStack/query/blob/main/packages/react-query/src/types.ts#L28) [UseBaseQueryOptions](../interfaces/UseBaseQueryOptions.md) with all type parameters set to `any`, useful when the specific types aren't relevant, e.g. when accepting options for any query in a helper function. diff --git a/docs/framework/react/reference/type-aliases/AnyUseInfiniteQueryOptions.md b/docs/framework/react/reference/type-aliases/AnyUseInfiniteQueryOptions.md index a38ab02f8cb..33a9039dac7 100644 --- a/docs/framework/react/reference/type-aliases/AnyUseInfiniteQueryOptions.md +++ b/docs/framework/react/reference/type-aliases/AnyUseInfiniteQueryOptions.md @@ -7,7 +7,7 @@ title: AnyUseInfiniteQueryOptions type AnyUseInfiniteQueryOptions = UseInfiniteQueryOptions; ``` -Defined in: [react-query/src/types.ts:219](https://github.com/TanStack/query/blob/main/packages/react-query/src/types.ts#L219) +Defined in: [packages/react-query/src/types.ts:219](https://github.com/TanStack/query/blob/main/packages/react-query/src/types.ts#L219) [UseInfiniteQueryOptions](../interfaces/UseInfiniteQueryOptions.md) with all type parameters set to `any`, useful when the specific types aren't relevant, e.g. when accepting options for any query in a helper function. diff --git a/docs/framework/react/reference/type-aliases/AnyUseMutationOptions.md b/docs/framework/react/reference/type-aliases/AnyUseMutationOptions.md index facf8ea370d..77e6c303e94 100644 --- a/docs/framework/react/reference/type-aliases/AnyUseMutationOptions.md +++ b/docs/framework/react/reference/type-aliases/AnyUseMutationOptions.md @@ -7,7 +7,7 @@ title: AnyUseMutationOptions type AnyUseMutationOptions = UseMutationOptions; ``` -Defined in: [react-query/src/types.ts:401](https://github.com/TanStack/query/blob/main/packages/react-query/src/types.ts#L401) +Defined in: [packages/react-query/src/types.ts:401](https://github.com/TanStack/query/blob/main/packages/react-query/src/types.ts#L401) [UseMutationOptions](../interfaces/UseMutationOptions.md) with all type parameters set to `any`, useful when the specific types aren't relevant, e.g. when accepting options for any mutation in a helper function. diff --git a/docs/framework/react/reference/type-aliases/AnyUseQueryOptions.md b/docs/framework/react/reference/type-aliases/AnyUseQueryOptions.md index fcfc898f6ed..d444460854b 100644 --- a/docs/framework/react/reference/type-aliases/AnyUseQueryOptions.md +++ b/docs/framework/react/reference/type-aliases/AnyUseQueryOptions.md @@ -7,7 +7,7 @@ title: AnyUseQueryOptions type AnyUseQueryOptions = UseQueryOptions; ``` -Defined in: [react-query/src/types.ts:154](https://github.com/TanStack/query/blob/main/packages/react-query/src/types.ts#L154) +Defined in: [packages/react-query/src/types.ts:154](https://github.com/TanStack/query/blob/main/packages/react-query/src/types.ts#L154) [UseQueryOptions](../interfaces/UseQueryOptions.md) with all type parameters set to `any`, useful when the specific types aren't relevant, e.g. when accepting options for any query in a helper function. diff --git a/docs/framework/react/reference/type-aliases/AnyUseSuspenseInfiniteQueryOptions.md b/docs/framework/react/reference/type-aliases/AnyUseSuspenseInfiniteQueryOptions.md index ea3a18b2716..04dc4684b00 100644 --- a/docs/framework/react/reference/type-aliases/AnyUseSuspenseInfiniteQueryOptions.md +++ b/docs/framework/react/reference/type-aliases/AnyUseSuspenseInfiniteQueryOptions.md @@ -7,7 +7,7 @@ title: AnyUseSuspenseInfiniteQueryOptions type AnyUseSuspenseInfiniteQueryOptions = UseSuspenseInfiniteQueryOptions; ``` -Defined in: [react-query/src/types.ts:266](https://github.com/TanStack/query/blob/main/packages/react-query/src/types.ts#L266) +Defined in: [packages/react-query/src/types.ts:266](https://github.com/TanStack/query/blob/main/packages/react-query/src/types.ts#L266) [UseSuspenseInfiniteQueryOptions](../interfaces/UseSuspenseInfiniteQueryOptions.md) with all type parameters set to `any`, useful when the specific types aren't relevant, e.g. when accepting options for any query in a helper function. diff --git a/docs/framework/react/reference/type-aliases/AnyUseSuspenseQueryOptions.md b/docs/framework/react/reference/type-aliases/AnyUseSuspenseQueryOptions.md index 150a2781b62..b8e59f8f692 100644 --- a/docs/framework/react/reference/type-aliases/AnyUseSuspenseQueryOptions.md +++ b/docs/framework/react/reference/type-aliases/AnyUseSuspenseQueryOptions.md @@ -7,7 +7,7 @@ title: AnyUseSuspenseQueryOptions type AnyUseSuspenseQueryOptions = UseSuspenseQueryOptions; ``` -Defined in: [react-query/src/types.ts:179](https://github.com/TanStack/query/blob/main/packages/react-query/src/types.ts#L179) +Defined in: [packages/react-query/src/types.ts:179](https://github.com/TanStack/query/blob/main/packages/react-query/src/types.ts#L179) [UseSuspenseQueryOptions](../interfaces/UseSuspenseQueryOptions.md) with all type parameters set to `any`, useful when the specific types aren't relevant, e.g. when accepting options for any query in a helper function. diff --git a/docs/framework/react/reference/type-aliases/DataTag.md b/docs/framework/react/reference/type-aliases/DataTag.md new file mode 100644 index 00000000000..904ca124464 --- /dev/null +++ b/docs/framework/react/reference/type-aliases/DataTag.md @@ -0,0 +1,24 @@ +--- +id: DataTag +title: DataTag +--- + +```ts +type DataTag = TType extends AnyDataTag ? TType : TType & object; +``` + +Defined in: [packages/query-core/src/types.ts:71](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L71) + +## Type Parameters + +### TType + +`TType` + +### TValue + +`TValue` + +### TError + +`TError` = [`UnsetMarker`](UnsetMarker.md) diff --git a/docs/framework/react/reference/type-aliases/DefaultError.md b/docs/framework/react/reference/type-aliases/DefaultError.md new file mode 100644 index 00000000000..da9f615482f --- /dev/null +++ b/docs/framework/react/reference/type-aliases/DefaultError.md @@ -0,0 +1,10 @@ +--- +id: DefaultError +title: DefaultError +--- + +```ts +type DefaultError = Register extends object ? TError : Error; +``` + +Defined in: [packages/query-core/src/types.ts:45](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L45) diff --git a/docs/framework/react/reference/type-aliases/DefaultedInfiniteQueryObserverOptions.md b/docs/framework/react/reference/type-aliases/DefaultedInfiniteQueryObserverOptions.md new file mode 100644 index 00000000000..82c7ddbb886 --- /dev/null +++ b/docs/framework/react/reference/type-aliases/DefaultedInfiniteQueryObserverOptions.md @@ -0,0 +1,32 @@ +--- +id: DefaultedInfiniteQueryObserverOptions +title: DefaultedInfiniteQueryObserverOptions +--- + +```ts +type DefaultedInfiniteQueryObserverOptions = WithRequired, "throwOnError" | "refetchOnReconnect" | "queryHash">; +``` + +Defined in: [packages/query-core/src/types.ts:557](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L557) + +## Type Parameters + +### TQueryFnData + +`TQueryFnData` = `unknown` + +### TError + +`TError` = [`DefaultError`](DefaultError.md) + +### TData + +`TData` = `TQueryFnData` + +### TQueryKey + +`TQueryKey` *extends* [`QueryKey`](QueryKey.md) = [`QueryKey`](QueryKey.md) + +### TPageParam + +`TPageParam` = `unknown` diff --git a/docs/framework/react/reference/type-aliases/DefaultedQueryObserverOptions.md b/docs/framework/react/reference/type-aliases/DefaultedQueryObserverOptions.md new file mode 100644 index 00000000000..7687d8c24f6 --- /dev/null +++ b/docs/framework/react/reference/type-aliases/DefaultedQueryObserverOptions.md @@ -0,0 +1,32 @@ +--- +id: DefaultedQueryObserverOptions +title: DefaultedQueryObserverOptions +--- + +```ts +type DefaultedQueryObserverOptions = WithRequired, "throwOnError" | "refetchOnReconnect" | "queryHash">; +``` + +Defined in: [packages/query-core/src/types.ts:528](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L528) + +## Type Parameters + +### TQueryFnData + +`TQueryFnData` = `unknown` + +### TError + +`TError` = [`DefaultError`](DefaultError.md) + +### TData + +`TData` = `TQueryFnData` + +### TQueryData + +`TQueryData` = `TQueryFnData` + +### TQueryKey + +`TQueryKey` *extends* [`QueryKey`](QueryKey.md) = [`QueryKey`](QueryKey.md) diff --git a/docs/framework/react/reference/type-aliases/DefinedInfiniteQueryObserverResult.md b/docs/framework/react/reference/type-aliases/DefinedInfiniteQueryObserverResult.md new file mode 100644 index 00000000000..38dac7cfe2b --- /dev/null +++ b/docs/framework/react/reference/type-aliases/DefinedInfiniteQueryObserverResult.md @@ -0,0 +1,22 @@ +--- +id: DefinedInfiniteQueryObserverResult +title: DefinedInfiniteQueryObserverResult +--- + +```ts +type DefinedInfiniteQueryObserverResult = + | InfiniteQueryObserverRefetchErrorResult +| InfiniteQueryObserverSuccessResult; +``` + +Defined in: [packages/query-core/src/types.ts:1148](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1148) + +## Type Parameters + +### TData + +`TData` = `unknown` + +### TError + +`TError` = [`DefaultError`](DefaultError.md) diff --git a/docs/framework/react/reference/type-aliases/DefinedInitialDataInfiniteOptions.md b/docs/framework/react/reference/type-aliases/DefinedInitialDataInfiniteOptions.md index 1721394a2ec..9a70bff735c 100644 --- a/docs/framework/react/reference/type-aliases/DefinedInitialDataInfiniteOptions.md +++ b/docs/framework/react/reference/type-aliases/DefinedInitialDataInfiniteOptions.md @@ -7,7 +7,7 @@ title: DefinedInitialDataInfiniteOptions type DefinedInitialDataInfiniteOptions = UseInfiniteQueryOptions & object; ``` -Defined in: [react-query/src/infiniteQueryOptions.ts:103](https://github.com/TanStack/query/blob/main/packages/react-query/src/infiniteQueryOptions.ts#L103) +Defined in: [packages/react-query/src/infiniteQueryOptions.ts:103](https://github.com/TanStack/query/blob/main/packages/react-query/src/infiniteQueryOptions.ts#L103) The options accepted by the `infiniteQueryOptions` overload selected when `initialData` is set — `data` is never `undefined`. @@ -39,20 +39,20 @@ The type of a single page, as your `queryFn` resolves it. ### TError -`TError` = `DefaultError` +`TError` = [`DefaultError`](DefaultError.md) The type of errors your `queryFn` may throw. ### TData -`TData` = `InfiniteData`\<`TQueryFnData`\> +`TData` = [`InfiniteData`](../interfaces/InfiniteData.md)\<`TQueryFnData`\> The type `data` ends up as after `select` runs — defaults to `InfiniteData`, the shape of all fetched pages plus their page params. ### TQueryKey -`TQueryKey` *extends* `QueryKey` = `QueryKey` +`TQueryKey` *extends* [`QueryKey`](QueryKey.md) = [`QueryKey`](QueryKey.md) The type of your `queryKey`. diff --git a/docs/framework/react/reference/type-aliases/DefinedInitialDataOptions.md b/docs/framework/react/reference/type-aliases/DefinedInitialDataOptions.md index 1807607291b..ada7a76611f 100644 --- a/docs/framework/react/reference/type-aliases/DefinedInitialDataOptions.md +++ b/docs/framework/react/reference/type-aliases/DefinedInitialDataOptions.md @@ -7,7 +7,7 @@ title: DefinedInitialDataOptions type DefinedInitialDataOptions = Omit, "queryFn"> & object; ``` -Defined in: [react-query/src/queryOptions.ts:80](https://github.com/TanStack/query/blob/main/packages/react-query/src/queryOptions.ts#L80) +Defined in: [packages/react-query/src/queryOptions.ts:80](https://github.com/TanStack/query/blob/main/packages/react-query/src/queryOptions.ts#L80) The options accepted by the `queryOptions` overload selected when `initialData` is set — `data` is never `undefined`. @@ -48,7 +48,7 @@ The type your `queryFn` resolves to. ### TError -`TError` = `DefaultError` +`TError` = [`DefaultError`](DefaultError.md) The type of errors your `queryFn` may throw. @@ -60,6 +60,6 @@ The type `data` ends up as after `select` runs. ### TQueryKey -`TQueryKey` *extends* `QueryKey` = `QueryKey` +`TQueryKey` *extends* [`QueryKey`](QueryKey.md) = [`QueryKey`](QueryKey.md) The type of your `queryKey`. diff --git a/docs/framework/react/reference/type-aliases/DefinedQueryObserverResult.md b/docs/framework/react/reference/type-aliases/DefinedQueryObserverResult.md new file mode 100644 index 00000000000..ae77ddcc22d --- /dev/null +++ b/docs/framework/react/reference/type-aliases/DefinedQueryObserverResult.md @@ -0,0 +1,22 @@ +--- +id: DefinedQueryObserverResult +title: DefinedQueryObserverResult +--- + +```ts +type DefinedQueryObserverResult = + | QueryObserverRefetchErrorResult +| QueryObserverSuccessResult; +``` + +Defined in: [packages/query-core/src/types.ts:987](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L987) + +## Type Parameters + +### TData + +`TData` = `unknown` + +### TError + +`TError` = [`DefaultError`](DefaultError.md) diff --git a/docs/framework/react/reference/type-aliases/DefinedUseInfiniteQueryResult.md b/docs/framework/react/reference/type-aliases/DefinedUseInfiniteQueryResult.md index ee49de8a33a..f1d410e9c1b 100644 --- a/docs/framework/react/reference/type-aliases/DefinedUseInfiniteQueryResult.md +++ b/docs/framework/react/reference/type-aliases/DefinedUseInfiniteQueryResult.md @@ -7,10 +7,10 @@ title: DefinedUseInfiniteQueryResult type DefinedUseInfiniteQueryResult = DefinedInfiniteQueryObserverResult; ``` -Defined in: [react-query/src/types.ts:377](https://github.com/TanStack/query/blob/main/packages/react-query/src/types.ts#L377) +Defined in: [packages/react-query/src/types.ts:377](https://github.com/TanStack/query/blob/main/packages/react-query/src/types.ts#L377) The result of `useInfiniteQuery` when `initialData` is set — `data` is never `undefined`. Re-exports -DefinedInfiniteQueryObserverResult from `@tanstack/query-core`. +[DefinedInfiniteQueryObserverResult](DefinedInfiniteQueryObserverResult.md) from `@tanstack/query-core`. ## Type Parameters @@ -22,6 +22,6 @@ The type `data` ends up as after `select` runs. ### TError -`TError` = `DefaultError` +`TError` = [`DefaultError`](DefaultError.md) The type of errors your `queryFn` may throw. diff --git a/docs/framework/react/reference/type-aliases/DefinedUseQueryResult.md b/docs/framework/react/reference/type-aliases/DefinedUseQueryResult.md index 724b88fb8dd..5340c35d628 100644 --- a/docs/framework/react/reference/type-aliases/DefinedUseQueryResult.md +++ b/docs/framework/react/reference/type-aliases/DefinedUseQueryResult.md @@ -7,10 +7,10 @@ title: DefinedUseQueryResult type DefinedUseQueryResult = DefinedQueryObserverResult; ``` -Defined in: [react-query/src/types.ts:353](https://github.com/TanStack/query/blob/main/packages/react-query/src/types.ts#L353) +Defined in: [packages/react-query/src/types.ts:353](https://github.com/TanStack/query/blob/main/packages/react-query/src/types.ts#L353) The result of `useQuery` when `initialData` is set, or of `useSuspenseQuery` before the `isPlaceholderData` -omission — `data` is never `undefined`. Re-exports DefinedQueryObserverResult from +omission — `data` is never `undefined`. Re-exports [DefinedQueryObserverResult](DefinedQueryObserverResult.md) from `@tanstack/query-core`. ## Type Parameters @@ -23,6 +23,6 @@ The type `data` ends up as after `select` runs. ### TError -`TError` = `DefaultError` +`TError` = [`DefaultError`](DefaultError.md) The type of errors your `queryFn` may throw. diff --git a/docs/framework/react/reference/type-aliases/DistributiveOmit.md b/docs/framework/react/reference/type-aliases/DistributiveOmit.md new file mode 100644 index 00000000000..33b87a5cd6e --- /dev/null +++ b/docs/framework/react/reference/type-aliases/DistributiveOmit.md @@ -0,0 +1,20 @@ +--- +id: DistributiveOmit +title: DistributiveOmit +--- + +```ts +type DistributiveOmit = TObject extends any ? Omit : never; +``` + +Defined in: [packages/query-core/src/types.ts:14](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L14) + +## Type Parameters + +### TObject + +`TObject` + +### TKey + +`TKey` *extends* keyof `TObject` diff --git a/docs/framework/react/reference/type-aliases/EnsureInfiniteQueryDataOptions.md b/docs/framework/react/reference/type-aliases/EnsureInfiniteQueryDataOptions.md new file mode 100644 index 00000000000..7648331fca2 --- /dev/null +++ b/docs/framework/react/reference/type-aliases/EnsureInfiniteQueryDataOptions.md @@ -0,0 +1,42 @@ +--- +id: EnsureInfiniteQueryDataOptions +title: EnsureInfiniteQueryDataOptions +--- + +```ts +type EnsureInfiniteQueryDataOptions = FetchInfiniteQueryOptions & object; +``` + +Defined in: [packages/query-core/src/types.ts:631](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L631) + +## Type Declaration + +### ~~revalidateIfStale?~~ + +```ts +optional revalidateIfStale: boolean; +``` + +## Type Parameters + +### TQueryFnData + +`TQueryFnData` = `unknown` + +### TError + +`TError` = [`DefaultError`](DefaultError.md) + +### TData + +`TData` = `TQueryFnData` + +### TQueryKey + +`TQueryKey` *extends* [`QueryKey`](QueryKey.md) = [`QueryKey`](QueryKey.md) + +### TPageParam + +`TPageParam` = `unknown` + +## Deprecated diff --git a/docs/framework/react/reference/type-aliases/FetchInfiniteQueryOptions.md b/docs/framework/react/reference/type-aliases/FetchInfiniteQueryOptions.md new file mode 100644 index 00000000000..d00a2455889 --- /dev/null +++ b/docs/framework/react/reference/type-aliases/FetchInfiniteQueryOptions.md @@ -0,0 +1,34 @@ +--- +id: FetchInfiniteQueryOptions +title: FetchInfiniteQueryOptions +--- + +```ts +type FetchInfiniteQueryOptions = Omit, TQueryKey, TPageParam>, "initialPageParam"> & InitialPageParam & InfiniteQueryPages; +``` + +Defined in: [packages/query-core/src/types.ts:675](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L675) + +## Type Parameters + +### TQueryFnData + +`TQueryFnData` = `unknown` + +### TError + +`TError` = [`DefaultError`](DefaultError.md) + +### TData + +`TData` = `TQueryFnData` + +### TQueryKey + +`TQueryKey` *extends* [`QueryKey`](QueryKey.md) = [`QueryKey`](QueryKey.md) + +### TPageParam + +`TPageParam` = `unknown` + +## Deprecated diff --git a/docs/framework/react/reference/type-aliases/FetchStatus.md b/docs/framework/react/reference/type-aliases/FetchStatus.md new file mode 100644 index 00000000000..d50002355ca --- /dev/null +++ b/docs/framework/react/reference/type-aliases/FetchStatus.md @@ -0,0 +1,10 @@ +--- +id: FetchStatus +title: FetchStatus +--- + +```ts +type FetchStatus = "fetching" | "paused" | "idle"; +``` + +Defined in: [packages/query-core/src/types.ts:762](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L762) diff --git a/docs/framework/react/reference/type-aliases/GetNextPageParamFunction.md b/docs/framework/react/reference/type-aliases/GetNextPageParamFunction.md new file mode 100644 index 00000000000..81d1a1544ab --- /dev/null +++ b/docs/framework/react/reference/type-aliases/GetNextPageParamFunction.md @@ -0,0 +1,42 @@ +--- +id: GetNextPageParamFunction +title: GetNextPageParamFunction +--- + +```ts +type GetNextPageParamFunction = (lastPage, allPages, lastPageParam, allPageParams) => TPageParam | undefined | null; +``` + +Defined in: [packages/query-core/src/types.ts:203](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L203) + +## Type Parameters + +### TPageParam + +`TPageParam` + +### TQueryFnData + +`TQueryFnData` = `unknown` + +## Parameters + +### lastPage + +`TQueryFnData` + +### allPages + +`TQueryFnData`[] + +### lastPageParam + +`TPageParam` + +### allPageParams + +`TPageParam`[] + +## Returns + +`TPageParam` \| `undefined` \| `null` diff --git a/docs/framework/react/reference/type-aliases/GetPreviousPageParamFunction.md b/docs/framework/react/reference/type-aliases/GetPreviousPageParamFunction.md new file mode 100644 index 00000000000..5a6d9b93d7e --- /dev/null +++ b/docs/framework/react/reference/type-aliases/GetPreviousPageParamFunction.md @@ -0,0 +1,42 @@ +--- +id: GetPreviousPageParamFunction +title: GetPreviousPageParamFunction +--- + +```ts +type GetPreviousPageParamFunction = (firstPage, allPages, firstPageParam, allPageParams) => TPageParam | undefined | null; +``` + +Defined in: [packages/query-core/src/types.ts:196](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L196) + +## Type Parameters + +### TPageParam + +`TPageParam` + +### TQueryFnData + +`TQueryFnData` = `unknown` + +## Parameters + +### firstPage + +`TQueryFnData` + +### allPages + +`TQueryFnData`[] + +### firstPageParam + +`TPageParam` + +### allPageParams + +`TPageParam`[] + +## Returns + +`TPageParam` \| `undefined` \| `null` diff --git a/docs/framework/react/reference/type-aliases/InferDataFromTag.md b/docs/framework/react/reference/type-aliases/InferDataFromTag.md new file mode 100644 index 00000000000..09a15ca4b1c --- /dev/null +++ b/docs/framework/react/reference/type-aliases/InferDataFromTag.md @@ -0,0 +1,20 @@ +--- +id: InferDataFromTag +title: InferDataFromTag +--- + +```ts +type InferDataFromTag = TTaggedQueryKey extends DataTag ? TaggedValue : TQueryFnData; +``` + +Defined in: [packages/query-core/src/types.ts:90](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L90) + +## Type Parameters + +### TQueryFnData + +`TQueryFnData` + +### TTaggedQueryKey + +`TTaggedQueryKey` *extends* [`QueryKey`](QueryKey.md) diff --git a/docs/framework/react/reference/type-aliases/InferErrorFromTag.md b/docs/framework/react/reference/type-aliases/InferErrorFromTag.md new file mode 100644 index 00000000000..cd94e4b5c3f --- /dev/null +++ b/docs/framework/react/reference/type-aliases/InferErrorFromTag.md @@ -0,0 +1,20 @@ +--- +id: InferErrorFromTag +title: InferErrorFromTag +--- + +```ts +type InferErrorFromTag = TTaggedQueryKey extends DataTag ? TaggedError extends UnsetMarker ? TError : TaggedError : TError; +``` + +Defined in: [packages/query-core/src/types.ts:95](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L95) + +## Type Parameters + +### TError + +`TError` + +### TTaggedQueryKey + +`TTaggedQueryKey` *extends* [`QueryKey`](QueryKey.md) diff --git a/docs/framework/react/reference/type-aliases/InfiniteQueryExecuteOptions.md b/docs/framework/react/reference/type-aliases/InfiniteQueryExecuteOptions.md new file mode 100644 index 00000000000..259c97c96bb --- /dev/null +++ b/docs/framework/react/reference/type-aliases/InfiniteQueryExecuteOptions.md @@ -0,0 +1,32 @@ +--- +id: InfiniteQueryExecuteOptions +title: InfiniteQueryExecuteOptions +--- + +```ts +type InfiniteQueryExecuteOptions = Omit, TQueryKey, TPageParam>, "initialPageParam"> & InitialPageParam & InfiniteQueryPages; +``` + +Defined in: [packages/query-core/src/types.ts:654](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L654) + +## Type Parameters + +### TQueryFnData + +`TQueryFnData` = `unknown` + +### TError + +`TError` = [`DefaultError`](DefaultError.md) + +### TData + +`TData` = [`InfiniteData`](../interfaces/InfiniteData.md)\<`TQueryFnData`\> + +### TQueryKey + +`TQueryKey` *extends* [`QueryKey`](QueryKey.md) = [`QueryKey`](QueryKey.md) + +### TPageParam + +`TPageParam` = `unknown` diff --git a/docs/framework/react/reference/type-aliases/InfiniteQueryObserverResult.md b/docs/framework/react/reference/type-aliases/InfiniteQueryObserverResult.md new file mode 100644 index 00000000000..aa27563b9cd --- /dev/null +++ b/docs/framework/react/reference/type-aliases/InfiniteQueryObserverResult.md @@ -0,0 +1,25 @@ +--- +id: InfiniteQueryObserverResult +title: InfiniteQueryObserverResult +--- + +```ts +type InfiniteQueryObserverResult = + | DefinedInfiniteQueryObserverResult + | InfiniteQueryObserverLoadingErrorResult + | InfiniteQueryObserverLoadingResult + | InfiniteQueryObserverPendingResult +| InfiniteQueryObserverPlaceholderResult; +``` + +Defined in: [packages/query-core/src/types.ts:1155](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1155) + +## Type Parameters + +### TData + +`TData` = `unknown` + +### TError + +`TError` = [`DefaultError`](DefaultError.md) diff --git a/docs/framework/react/reference/type-aliases/InitialDataFunction.md b/docs/framework/react/reference/type-aliases/InitialDataFunction.md new file mode 100644 index 00000000000..6ba4aaabe61 --- /dev/null +++ b/docs/framework/react/reference/type-aliases/InitialDataFunction.md @@ -0,0 +1,20 @@ +--- +id: InitialDataFunction +title: InitialDataFunction +--- + +```ts +type InitialDataFunction = () => T | undefined; +``` + +Defined in: [packages/query-core/src/types.ts:173](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L173) + +## Type Parameters + +### T + +`T` + +## Returns + +`T` \| `undefined` diff --git a/docs/framework/react/reference/type-aliases/ManagedTimerId.md b/docs/framework/react/reference/type-aliases/ManagedTimerId.md new file mode 100644 index 00000000000..d7833e3e4f0 --- /dev/null +++ b/docs/framework/react/reference/type-aliases/ManagedTimerId.md @@ -0,0 +1,19 @@ +--- +id: ManagedTimerId +title: ManagedTimerId +--- + +```ts +type ManagedTimerId = + | number + | { + [toPrimitive]: () => number; +}; +``` + +Defined in: [packages/query-core/src/timeoutManager.ts:17](https://github.com/TanStack/query/blob/main/packages/query-core/src/timeoutManager.ts#L17) + +Wrapping `setTimeout` is awkward from a typing perspective because platform +typings may extend the return type of `setTimeout`. For example, NodeJS +typings add `NodeJS.Timeout`; but a non-default `timeoutManager` may not be +able to return such a type. diff --git a/docs/framework/react/reference/type-aliases/MutateFunction.md b/docs/framework/react/reference/type-aliases/MutateFunction.md new file mode 100644 index 00000000000..e12b7a80291 --- /dev/null +++ b/docs/framework/react/reference/type-aliases/MutateFunction.md @@ -0,0 +1,38 @@ +--- +id: MutateFunction +title: MutateFunction +--- + +```ts +type MutateFunction = (...rest) => Promise; +``` + +Defined in: [packages/query-core/src/types.ts:1326](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1326) + +## Type Parameters + +### TData + +`TData` = `unknown` + +### TError + +`TError` = [`DefaultError`](DefaultError.md) + +### TVariables + +`TVariables` = `void` + +### TOnMutateResult + +`TOnMutateResult` = `unknown` + +## Parameters + +### rest + +...[`MutateFunctionRest`](MutateFunctionRest.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\> + +## Returns + +`Promise`\<`TData`\> diff --git a/docs/framework/react/reference/type-aliases/MutateFunctionRest.md b/docs/framework/react/reference/type-aliases/MutateFunctionRest.md new file mode 100644 index 00000000000..3902f1082f9 --- /dev/null +++ b/docs/framework/react/reference/type-aliases/MutateFunctionRest.md @@ -0,0 +1,28 @@ +--- +id: MutateFunctionRest +title: MutateFunctionRest +--- + +```ts +type MutateFunctionRest = undefined extends TVariables ? [TVariables, MutateOptions] : [TVariables, MutateOptions]; +``` + +Defined in: [packages/query-core/src/types.ts:1311](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1311) + +## Type Parameters + +### TData + +`TData` = `unknown` + +### TError + +`TError` = [`DefaultError`](DefaultError.md) + +### TVariables + +`TVariables` = `void` + +### TOnMutateResult + +`TOnMutateResult` = `unknown` diff --git a/docs/framework/react/reference/type-aliases/MutationCacheNotifyEvent.md b/docs/framework/react/reference/type-aliases/MutationCacheNotifyEvent.md new file mode 100644 index 00000000000..aa5e196bc72 --- /dev/null +++ b/docs/framework/react/reference/type-aliases/MutationCacheNotifyEvent.md @@ -0,0 +1,20 @@ +--- +id: MutationCacheNotifyEvent +title: MutationCacheNotifyEvent +--- + +```ts +type MutationCacheNotifyEvent = + | NotifyEventMutationAdded + | NotifyEventMutationRemoved + | NotifyEventMutationObserverAdded + | NotifyEventMutationObserverRemoved + | NotifyEventMutationObserverOptionsUpdated + | NotifyEventMutationUpdated; +``` + +Defined in: [packages/query-core/src/mutationCache.ts:98](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationCache.ts#L98) + +The event passed to a `MutationCache` subscriber. Fired whenever a mutation is added or removed +from the cache, its state is updated, or one of its observers is added, removed, or has its +options updated. diff --git a/docs/framework/react/reference/type-aliases/MutationFunction.md b/docs/framework/react/reference/type-aliases/MutationFunction.md new file mode 100644 index 00000000000..9bafb3db56b --- /dev/null +++ b/docs/framework/react/reference/type-aliases/MutationFunction.md @@ -0,0 +1,34 @@ +--- +id: MutationFunction +title: MutationFunction +--- + +```ts +type MutationFunction = (variables, context) => Promise; +``` + +Defined in: [packages/query-core/src/types.ts:1195](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1195) + +## Type Parameters + +### TData + +`TData` = `unknown` + +### TVariables + +`TVariables` = `unknown` + +## Parameters + +### variables + +`TVariables` + +### context + +[`MutationFunctionContext`](MutationFunctionContext.md) + +## Returns + +`Promise`\<`TData`\> diff --git a/docs/framework/react/reference/type-aliases/MutationFunctionContext.md b/docs/framework/react/reference/type-aliases/MutationFunctionContext.md new file mode 100644 index 00000000000..0207256c702 --- /dev/null +++ b/docs/framework/react/reference/type-aliases/MutationFunctionContext.md @@ -0,0 +1,40 @@ +--- +id: MutationFunctionContext +title: MutationFunctionContext +--- + +```ts +type MutationFunctionContext = object; +``` + +Defined in: [packages/query-core/src/types.ts:1189](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1189) + +## Properties + +### client + +```ts +client: QueryClient; +``` + +Defined in: [packages/query-core/src/types.ts:1190](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1190) + +*** + +### meta + +```ts +meta: MutationMeta | undefined; +``` + +Defined in: [packages/query-core/src/types.ts:1191](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1191) + +*** + +### mutationKey? + +```ts +optional mutationKey: MutationKey; +``` + +Defined in: [packages/query-core/src/types.ts:1192](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1192) diff --git a/docs/framework/react/reference/type-aliases/MutationKey.md b/docs/framework/react/reference/type-aliases/MutationKey.md new file mode 100644 index 00000000000..9d1d7f0f77b --- /dev/null +++ b/docs/framework/react/reference/type-aliases/MutationKey.md @@ -0,0 +1,10 @@ +--- +id: MutationKey +title: MutationKey +--- + +```ts +type MutationKey = Register extends object ? TMutationKey extends ReadonlyArray ? TMutationKey : TMutationKey extends unknown[] ? TMutationKey : ReadonlyArray : ReadonlyArray; +``` + +Defined in: [packages/query-core/src/types.ts:1165](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1165) diff --git a/docs/framework/react/reference/type-aliases/MutationMeta.md b/docs/framework/react/reference/type-aliases/MutationMeta.md new file mode 100644 index 00000000000..ff1f9b4bf94 --- /dev/null +++ b/docs/framework/react/reference/type-aliases/MutationMeta.md @@ -0,0 +1,10 @@ +--- +id: MutationMeta +title: MutationMeta +--- + +```ts +type MutationMeta = Register extends object ? TMutationMeta extends Record ? TMutationMeta : Record : Record; +``` + +Defined in: [packages/query-core/src/types.ts:1181](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1181) diff --git a/docs/framework/react/reference/type-aliases/MutationObserverResult.md b/docs/framework/react/reference/type-aliases/MutationObserverResult.md new file mode 100644 index 00000000000..c21fc3ac591 --- /dev/null +++ b/docs/framework/react/reference/type-aliases/MutationObserverResult.md @@ -0,0 +1,32 @@ +--- +id: MutationObserverResult +title: MutationObserverResult +--- + +```ts +type MutationObserverResult = + | MutationObserverIdleResult + | MutationObserverLoadingResult + | MutationObserverErrorResult +| MutationObserverSuccessResult; +``` + +Defined in: [packages/query-core/src/types.ts:1484](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1484) + +## Type Parameters + +### TData + +`TData` = `unknown` + +### TError + +`TError` = [`DefaultError`](DefaultError.md) + +### TVariables + +`TVariables` = `void` + +### TOnMutateResult + +`TOnMutateResult` = `unknown` diff --git a/docs/framework/react/reference/type-aliases/MutationScope.md b/docs/framework/react/reference/type-aliases/MutationScope.md new file mode 100644 index 00000000000..1d6a91bd434 --- /dev/null +++ b/docs/framework/react/reference/type-aliases/MutationScope.md @@ -0,0 +1,20 @@ +--- +id: MutationScope +title: MutationScope +--- + +```ts +type MutationScope = object; +``` + +Defined in: [packages/query-core/src/types.ts:1177](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1177) + +## Properties + +### id + +```ts +id: string; +``` + +Defined in: [packages/query-core/src/types.ts:1178](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1178) diff --git a/docs/framework/react/reference/type-aliases/MutationStatus.md b/docs/framework/react/reference/type-aliases/MutationStatus.md new file mode 100644 index 00000000000..cf12d3d3ee3 --- /dev/null +++ b/docs/framework/react/reference/type-aliases/MutationStatus.md @@ -0,0 +1,10 @@ +--- +id: MutationStatus +title: MutationStatus +--- + +```ts +type MutationStatus = "idle" | "pending" | "success" | "error"; +``` + +Defined in: [packages/query-core/src/types.ts:1175](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1175) diff --git a/docs/framework/react/reference/type-aliases/NetworkMode.md b/docs/framework/react/reference/type-aliases/NetworkMode.md new file mode 100644 index 00000000000..94ae0ba76ed --- /dev/null +++ b/docs/framework/react/reference/type-aliases/NetworkMode.md @@ -0,0 +1,10 @@ +--- +id: NetworkMode +title: NetworkMode +--- + +```ts +type NetworkMode = "online" | "always" | "offlineFirst"; +``` + +Defined in: [packages/query-core/src/types.ts:223](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L223) diff --git a/docs/framework/react/reference/type-aliases/NonUndefinedGuard.md b/docs/framework/react/reference/type-aliases/NonUndefinedGuard.md new file mode 100644 index 00000000000..4aaf208013b --- /dev/null +++ b/docs/framework/react/reference/type-aliases/NonUndefinedGuard.md @@ -0,0 +1,16 @@ +--- +id: NonUndefinedGuard +title: NonUndefinedGuard +--- + +```ts +type NonUndefinedGuard = T extends undefined ? never : T; +``` + +Defined in: [packages/query-core/src/types.ts:12](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L12) + +## Type Parameters + +### T + +`T` diff --git a/docs/framework/react/reference/type-aliases/NotifyEventType.md b/docs/framework/react/reference/type-aliases/NotifyEventType.md new file mode 100644 index 00000000000..ffa60b016e3 --- /dev/null +++ b/docs/framework/react/reference/type-aliases/NotifyEventType.md @@ -0,0 +1,17 @@ +--- +id: NotifyEventType +title: NotifyEventType +--- + +```ts +type NotifyEventType = + | "added" + | "removed" + | "updated" + | "observerAdded" + | "observerRemoved" + | "observerResultsUpdated" + | "observerOptionsUpdated"; +``` + +Defined in: [packages/query-core/src/types.ts:1530](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1530) diff --git a/docs/framework/react/reference/type-aliases/NotifyOnChangeProps.md b/docs/framework/react/reference/type-aliases/NotifyOnChangeProps.md new file mode 100644 index 00000000000..7de194fa10b --- /dev/null +++ b/docs/framework/react/reference/type-aliases/NotifyOnChangeProps.md @@ -0,0 +1,17 @@ +--- +id: NotifyOnChangeProps +title: NotifyOnChangeProps +--- + +```ts +type NotifyOnChangeProps = + | keyof InfiniteQueryObserverResult[] + | "all" + | undefined + | () => + | keyof InfiniteQueryObserverResult[] + | "all" + | undefined; +``` + +Defined in: [packages/query-core/src/types.ts:225](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L225) diff --git a/docs/framework/react/reference/type-aliases/OmitKeyof.md b/docs/framework/react/reference/type-aliases/OmitKeyof.md new file mode 100644 index 00000000000..690a7b0a5d2 --- /dev/null +++ b/docs/framework/react/reference/type-aliases/OmitKeyof.md @@ -0,0 +1,28 @@ +--- +id: OmitKeyof +title: OmitKeyof +--- + +```ts +type OmitKeyof = Omit; +``` + +Defined in: [packages/query-core/src/types.ts:19](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L19) + +## Type Parameters + +### TObject + +`TObject` + +### TKey + +`TKey` *extends* `TStrictly` *extends* `"safely"` ? + \| keyof `TObject` + \| `string` & `Record`\<`never`, `never`\> + \| `number` & `Record`\<`never`, `never`\> + \| `symbol` & `Record`\<`never`, `never`\> : keyof `TObject` + +### TStrictly + +`TStrictly` *extends* `"strictly"` \| `"safely"` = `"strictly"` diff --git a/docs/framework/react/reference/type-aliases/Override.md b/docs/framework/react/reference/type-aliases/Override.md new file mode 100644 index 00000000000..8abcecd1e1b --- /dev/null +++ b/docs/framework/react/reference/type-aliases/Override.md @@ -0,0 +1,20 @@ +--- +id: Override +title: Override +--- + +```ts +type Override = { [AKey in keyof TTargetA]: AKey extends keyof TTargetB ? TTargetB[AKey] : TTargetA[AKey] }; +``` + +Defined in: [packages/query-core/src/types.ts:31](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L31) + +## Type Parameters + +### TTargetA + +`TTargetA` + +### TTargetB + +`TTargetB` diff --git a/docs/framework/react/reference/type-aliases/PlaceholderDataFunction.md b/docs/framework/react/reference/type-aliases/PlaceholderDataFunction.md new file mode 100644 index 00000000000..cd40f28b41e --- /dev/null +++ b/docs/framework/react/reference/type-aliases/PlaceholderDataFunction.md @@ -0,0 +1,42 @@ +--- +id: PlaceholderDataFunction +title: PlaceholderDataFunction +--- + +```ts +type PlaceholderDataFunction = (previousData, previousQuery) => TQueryData | undefined; +``` + +Defined in: [packages/query-core/src/types.ts:177](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L177) + +## Type Parameters + +### TQueryFnData + +`TQueryFnData` = `unknown` + +### TError + +`TError` = [`DefaultError`](DefaultError.md) + +### TQueryData + +`TQueryData` = `TQueryFnData` + +### TQueryKey + +`TQueryKey` *extends* [`QueryKey`](QueryKey.md) = [`QueryKey`](QueryKey.md) + +## Parameters + +### previousData + +`TQueryData` | `undefined` + +### previousQuery + +[`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryData`, `TQueryKey`\> | `undefined` + +## Returns + +`TQueryData` \| `undefined` diff --git a/docs/framework/react/reference/type-aliases/QueriesOptions.md b/docs/framework/react/reference/type-aliases/QueriesOptions.md index 9ab4be62e37..1f98b59bdb9 100644 --- a/docs/framework/react/reference/type-aliases/QueriesOptions.md +++ b/docs/framework/react/reference/type-aliases/QueriesOptions.md @@ -7,7 +7,7 @@ title: QueriesOptions type QueriesOptions = TDepth["length"] extends MAXIMUM_DEPTH ? UseQueryOptionsForUseQueries[] : T extends [] ? [] : T extends [infer Head] ? [...TResults, GetUseQueryOptionsForUseQueries] : T extends [infer Head, ...(infer Tails)] ? QueriesOptions<[...Tails], [...TResults, GetUseQueryOptionsForUseQueries], [...TDepth, 1]> : ReadonlyArray extends T ? T : T extends UseQueryOptionsForUseQueries[] ? UseQueryOptionsForUseQueries[] : UseQueryOptionsForUseQueries[]; ``` -Defined in: [react-query/src/useQueries.ts:156](https://github.com/TanStack/query/blob/main/packages/react-query/src/useQueries.ts#L156) +Defined in: [packages/react-query/src/useQueries.ts:156](https://github.com/TanStack/query/blob/main/packages/react-query/src/useQueries.ts#L156) The `queries` array accepted by `useQueries`. Recursively unwraps each tuple element so every entry's `queryFn`/`select`/`throwOnError` are inferred individually, up to 20 elements. An opaque array (e.g. diff --git a/docs/framework/react/reference/type-aliases/QueriesPlaceholderDataFunction.md b/docs/framework/react/reference/type-aliases/QueriesPlaceholderDataFunction.md new file mode 100644 index 00000000000..5d3fca8c9e0 --- /dev/null +++ b/docs/framework/react/reference/type-aliases/QueriesPlaceholderDataFunction.md @@ -0,0 +1,30 @@ +--- +id: QueriesPlaceholderDataFunction +title: QueriesPlaceholderDataFunction +--- + +```ts +type QueriesPlaceholderDataFunction = (previousData, previousQuery) => TQueryData | undefined; +``` + +Defined in: [packages/query-core/src/types.ts:187](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L187) + +## Type Parameters + +### TQueryData + +`TQueryData` + +## Parameters + +### previousData + +`undefined` + +### previousQuery + +`undefined` + +## Returns + +`TQueryData` \| `undefined` diff --git a/docs/framework/react/reference/type-aliases/QueriesResults.md b/docs/framework/react/reference/type-aliases/QueriesResults.md index c560ce906d6..4742d4045bc 100644 --- a/docs/framework/react/reference/type-aliases/QueriesResults.md +++ b/docs/framework/react/reference/type-aliases/QueriesResults.md @@ -7,7 +7,7 @@ title: QueriesResults type QueriesResults = TDepth["length"] extends MAXIMUM_DEPTH ? UseQueryResult[] : T extends [] ? [] : T extends [infer Head] ? [...TResults, GetUseQueryResult] : T extends [infer Head, ...(infer Tails)] ? QueriesResults<[...Tails], [...TResults, GetUseQueryResult], [...TDepth, 1]> : { [K in keyof T]: GetUseQueryResult }; ``` -Defined in: [react-query/src/useQueries.ts:207](https://github.com/TanStack/query/blob/main/packages/react-query/src/useQueries.ts#L207) +Defined in: [packages/react-query/src/useQueries.ts:207](https://github.com/TanStack/query/blob/main/packages/react-query/src/useQueries.ts#L207) The result type returned by `useQueries`, when no `combine` is provided. Mirrors [QueriesOptions](QueriesOptions.md): each tuple element's result type is inferred individually, up to 20 elements. A non-tuple array is mapped diff --git a/docs/framework/react/reference/type-aliases/QueryBooleanOption.md b/docs/framework/react/reference/type-aliases/QueryBooleanOption.md new file mode 100644 index 00000000000..9759e3ddb42 --- /dev/null +++ b/docs/framework/react/reference/type-aliases/QueryBooleanOption.md @@ -0,0 +1,28 @@ +--- +id: QueryBooleanOption +title: QueryBooleanOption +--- + +```ts +type QueryBooleanOption = boolean | (query) => boolean; +``` + +Defined in: [packages/query-core/src/types.ts:119](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L119) + +## Type Parameters + +### TQueryFnData + +`TQueryFnData` = `unknown` + +### TError + +`TError` = [`DefaultError`](DefaultError.md) + +### TData + +`TData` = `TQueryFnData` + +### TQueryKey + +`TQueryKey` *extends* [`QueryKey`](QueryKey.md) = [`QueryKey`](QueryKey.md) diff --git a/docs/framework/react/reference/type-aliases/QueryCacheNotifyEvent.md b/docs/framework/react/reference/type-aliases/QueryCacheNotifyEvent.md new file mode 100644 index 00000000000..b92c76fb826 --- /dev/null +++ b/docs/framework/react/reference/type-aliases/QueryCacheNotifyEvent.md @@ -0,0 +1,21 @@ +--- +id: QueryCacheNotifyEvent +title: QueryCacheNotifyEvent +--- + +```ts +type QueryCacheNotifyEvent = + | NotifyEventQueryAdded + | NotifyEventQueryRemoved + | NotifyEventQueryUpdated + | NotifyEventQueryObserverAdded + | NotifyEventQueryObserverRemoved + | NotifyEventQueryObserverResultsUpdated + | NotifyEventQueryObserverOptionsUpdated; +``` + +Defined in: [packages/query-core/src/queryCache.ts:85](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryCache.ts#L85) + +The event passed to a `QueryCache` subscriber. Fired whenever a query is added or removed from +the cache, its state is updated (e.g. via `query.setState` or `queryClient.removeQueries`), or +one of its observers is added, removed, or has its results or options updated. diff --git a/docs/framework/react/reference/type-aliases/QueryClientProviderProps.md b/docs/framework/react/reference/type-aliases/QueryClientProviderProps.md index dc1ee2d8bd3..7de9414379d 100644 --- a/docs/framework/react/reference/type-aliases/QueryClientProviderProps.md +++ b/docs/framework/react/reference/type-aliases/QueryClientProviderProps.md @@ -7,7 +7,7 @@ title: QueryClientProviderProps type QueryClientProviderProps = object; ``` -Defined in: [react-query/src/QueryClientProvider.tsx:38](https://github.com/TanStack/query/blob/main/packages/react-query/src/QueryClientProvider.tsx#L38) +Defined in: [packages/react-query/src/QueryClientProvider.tsx:38](https://github.com/TanStack/query/blob/main/packages/react-query/src/QueryClientProvider.tsx#L38) The props accepted by `QueryClientProvider`. @@ -19,7 +19,7 @@ The props accepted by `QueryClientProvider`. optional children: React.ReactNode; ``` -Defined in: [react-query/src/QueryClientProvider.tsx:48](https://github.com/TanStack/query/blob/main/packages/react-query/src/QueryClientProvider.tsx#L48) +Defined in: [packages/react-query/src/QueryClientProvider.tsx:48](https://github.com/TanStack/query/blob/main/packages/react-query/src/QueryClientProvider.tsx#L48) The components that get access to the provided `QueryClient`. @@ -31,7 +31,7 @@ The components that get access to the provided `QueryClient`. client: QueryClient; ``` -Defined in: [react-query/src/QueryClientProvider.tsx:44](https://github.com/TanStack/query/blob/main/packages/react-query/src/QueryClientProvider.tsx#L44) +Defined in: [packages/react-query/src/QueryClientProvider.tsx:44](https://github.com/TanStack/query/blob/main/packages/react-query/src/QueryClientProvider.tsx#L44) **Required** diff --git a/docs/framework/react/reference/type-aliases/QueryErrorClearResetFunction.md b/docs/framework/react/reference/type-aliases/QueryErrorClearResetFunction.md index 73be345b630..7a8071145d0 100644 --- a/docs/framework/react/reference/type-aliases/QueryErrorClearResetFunction.md +++ b/docs/framework/react/reference/type-aliases/QueryErrorClearResetFunction.md @@ -7,7 +7,7 @@ title: QueryErrorClearResetFunction type QueryErrorClearResetFunction = () => void; ``` -Defined in: [react-query/src/QueryErrorResetBoundary.tsx:7](https://github.com/TanStack/query/blob/main/packages/react-query/src/QueryErrorResetBoundary.tsx#L7) +Defined in: [packages/react-query/src/QueryErrorResetBoundary.tsx:7](https://github.com/TanStack/query/blob/main/packages/react-query/src/QueryErrorResetBoundary.tsx#L7) ## Returns diff --git a/docs/framework/react/reference/type-aliases/QueryErrorIsResetFunction.md b/docs/framework/react/reference/type-aliases/QueryErrorIsResetFunction.md index 049ead420e7..038a72d7b04 100644 --- a/docs/framework/react/reference/type-aliases/QueryErrorIsResetFunction.md +++ b/docs/framework/react/reference/type-aliases/QueryErrorIsResetFunction.md @@ -7,7 +7,7 @@ title: QueryErrorIsResetFunction type QueryErrorIsResetFunction = () => boolean; ``` -Defined in: [react-query/src/QueryErrorResetBoundary.tsx:6](https://github.com/TanStack/query/blob/main/packages/react-query/src/QueryErrorResetBoundary.tsx#L6) +Defined in: [packages/react-query/src/QueryErrorResetBoundary.tsx:6](https://github.com/TanStack/query/blob/main/packages/react-query/src/QueryErrorResetBoundary.tsx#L6) ## Returns diff --git a/docs/framework/react/reference/type-aliases/QueryErrorResetBoundaryFunction.md b/docs/framework/react/reference/type-aliases/QueryErrorResetBoundaryFunction.md index df4218127f2..9b2ee994a57 100644 --- a/docs/framework/react/reference/type-aliases/QueryErrorResetBoundaryFunction.md +++ b/docs/framework/react/reference/type-aliases/QueryErrorResetBoundaryFunction.md @@ -7,7 +7,7 @@ title: QueryErrorResetBoundaryFunction type QueryErrorResetBoundaryFunction = (value) => React.ReactNode; ``` -Defined in: [react-query/src/QueryErrorResetBoundary.tsx:87](https://github.com/TanStack/query/blob/main/packages/react-query/src/QueryErrorResetBoundary.tsx#L87) +Defined in: [packages/react-query/src/QueryErrorResetBoundary.tsx:87](https://github.com/TanStack/query/blob/main/packages/react-query/src/QueryErrorResetBoundary.tsx#L87) A render-prop function usable as `children` on `QueryErrorResetBoundary`. diff --git a/docs/framework/react/reference/type-aliases/QueryErrorResetFunction.md b/docs/framework/react/reference/type-aliases/QueryErrorResetFunction.md index a4bbfd436ec..fe60d7b0ac7 100644 --- a/docs/framework/react/reference/type-aliases/QueryErrorResetFunction.md +++ b/docs/framework/react/reference/type-aliases/QueryErrorResetFunction.md @@ -7,7 +7,7 @@ title: QueryErrorResetFunction type QueryErrorResetFunction = () => void; ``` -Defined in: [react-query/src/QueryErrorResetBoundary.tsx:5](https://github.com/TanStack/query/blob/main/packages/react-query/src/QueryErrorResetBoundary.tsx#L5) +Defined in: [packages/react-query/src/QueryErrorResetBoundary.tsx:5](https://github.com/TanStack/query/blob/main/packages/react-query/src/QueryErrorResetBoundary.tsx#L5) ## Returns diff --git a/docs/framework/react/reference/type-aliases/QueryFunction.md b/docs/framework/react/reference/type-aliases/QueryFunction.md new file mode 100644 index 00000000000..306367388a1 --- /dev/null +++ b/docs/framework/react/reference/type-aliases/QueryFunction.md @@ -0,0 +1,34 @@ +--- +id: QueryFunction +title: QueryFunction +--- + +```ts +type QueryFunction = (context) => T | Promise; +``` + +Defined in: [packages/query-core/src/types.ts:102](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L102) + +## Type Parameters + +### T + +`T` = `unknown` + +### TQueryKey + +`TQueryKey` *extends* [`QueryKey`](QueryKey.md) = [`QueryKey`](QueryKey.md) + +### TPageParam + +`TPageParam` = `never` + +## Parameters + +### context + +[`QueryFunctionContext`](QueryFunctionContext.md)\<`TQueryKey`, `TPageParam`\> + +## Returns + +`T` \| `Promise`\<`T`\> diff --git a/docs/framework/react/reference/type-aliases/QueryFunctionContext.md b/docs/framework/react/reference/type-aliases/QueryFunctionContext.md new file mode 100644 index 00000000000..d2c9fe3e2b2 --- /dev/null +++ b/docs/framework/react/reference/type-aliases/QueryFunctionContext.md @@ -0,0 +1,20 @@ +--- +id: QueryFunctionContext +title: QueryFunctionContext +--- + +```ts +type QueryFunctionContext = [TPageParam] extends [never] ? object : object; +``` + +Defined in: [packages/query-core/src/types.ts:144](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L144) + +## Type Parameters + +### TQueryKey + +`TQueryKey` *extends* [`QueryKey`](QueryKey.md) = [`QueryKey`](QueryKey.md) + +### TPageParam + +`TPageParam` = `never` diff --git a/docs/framework/react/reference/type-aliases/QueryKey.md b/docs/framework/react/reference/type-aliases/QueryKey.md new file mode 100644 index 00000000000..1a3f34cde18 --- /dev/null +++ b/docs/framework/react/reference/type-aliases/QueryKey.md @@ -0,0 +1,10 @@ +--- +id: QueryKey +title: QueryKey +--- + +```ts +type QueryKey = Register extends object ? TQueryKey extends ReadonlyArray ? TQueryKey : TQueryKey extends unknown[] ? TQueryKey : ReadonlyArray : ReadonlyArray; +``` + +Defined in: [packages/query-core/src/types.ts:51](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L51) diff --git a/docs/framework/react/reference/type-aliases/QueryKeyHashFunction.md b/docs/framework/react/reference/type-aliases/QueryKeyHashFunction.md new file mode 100644 index 00000000000..feda96373cc --- /dev/null +++ b/docs/framework/react/reference/type-aliases/QueryKeyHashFunction.md @@ -0,0 +1,26 @@ +--- +id: QueryKeyHashFunction +title: QueryKeyHashFunction +--- + +```ts +type QueryKeyHashFunction = (queryKey) => string; +``` + +Defined in: [packages/query-core/src/types.ts:192](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L192) + +## Type Parameters + +### TQueryKey + +`TQueryKey` *extends* [`QueryKey`](QueryKey.md) + +## Parameters + +### queryKey + +`TQueryKey` + +## Returns + +`string` diff --git a/docs/framework/react/reference/type-aliases/QueryKeyWithDataTag.md b/docs/framework/react/reference/type-aliases/QueryKeyWithDataTag.md new file mode 100644 index 00000000000..6613f74be9e --- /dev/null +++ b/docs/framework/react/reference/type-aliases/QueryKeyWithDataTag.md @@ -0,0 +1,34 @@ +--- +id: QueryKeyWithDataTag +title: QueryKeyWithDataTag +--- + +```ts +type QueryKeyWithDataTag = object; +``` + +Defined in: [packages/query-core/src/types.ts:82](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L82) + +## Type Parameters + +### TQueryKey + +`TQueryKey` *extends* [`QueryKey`](QueryKey.md) = [`QueryKey`](QueryKey.md) + +### TQueryFnData + +`TQueryFnData` = `unknown` + +### TError + +`TError` = [`DefaultError`](DefaultError.md) + +## Properties + +### queryKey + +```ts +queryKey: DataTag; +``` + +Defined in: [packages/query-core/src/types.ts:87](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L87) diff --git a/docs/framework/react/reference/type-aliases/QueryMeta.md b/docs/framework/react/reference/type-aliases/QueryMeta.md new file mode 100644 index 00000000000..c12917b2cce --- /dev/null +++ b/docs/framework/react/reference/type-aliases/QueryMeta.md @@ -0,0 +1,10 @@ +--- +id: QueryMeta +title: QueryMeta +--- + +```ts +type QueryMeta = Register extends object ? TQueryMeta extends Record ? TQueryMeta : Record : Record; +``` + +Defined in: [packages/query-core/src/types.ts:215](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L215) diff --git a/docs/framework/react/reference/type-aliases/QueryObserverResult.md b/docs/framework/react/reference/type-aliases/QueryObserverResult.md new file mode 100644 index 00000000000..5138b635f2c --- /dev/null +++ b/docs/framework/react/reference/type-aliases/QueryObserverResult.md @@ -0,0 +1,25 @@ +--- +id: QueryObserverResult +title: QueryObserverResult +--- + +```ts +type QueryObserverResult = + | DefinedQueryObserverResult + | QueryObserverLoadingErrorResult + | QueryObserverLoadingResult + | QueryObserverPendingResult +| QueryObserverPlaceholderResult; +``` + +Defined in: [packages/query-core/src/types.ts:994](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L994) + +## Type Parameters + +### TData + +`TData` = `unknown` + +### TError + +`TError` = [`DefaultError`](DefaultError.md) diff --git a/docs/framework/react/reference/type-aliases/QueryPersister.md b/docs/framework/react/reference/type-aliases/QueryPersister.md new file mode 100644 index 00000000000..72e80165b0d --- /dev/null +++ b/docs/framework/react/reference/type-aliases/QueryPersister.md @@ -0,0 +1,24 @@ +--- +id: QueryPersister +title: QueryPersister +--- + +```ts +type QueryPersister = [TPageParam] extends [never] ? (queryFn, context, query) => T | Promise : (queryFn, context, query) => T | Promise; +``` + +Defined in: [packages/query-core/src/types.ts:128](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L128) + +## Type Parameters + +### T + +`T` = `unknown` + +### TQueryKey + +`TQueryKey` *extends* [`QueryKey`](QueryKey.md) = [`QueryKey`](QueryKey.md) + +### TPageParam + +`TPageParam` = `never` diff --git a/docs/framework/react/reference/type-aliases/QueryStatus.md b/docs/framework/react/reference/type-aliases/QueryStatus.md new file mode 100644 index 00000000000..bab00f6f423 --- /dev/null +++ b/docs/framework/react/reference/type-aliases/QueryStatus.md @@ -0,0 +1,10 @@ +--- +id: QueryStatus +title: QueryStatus +--- + +```ts +type QueryStatus = "pending" | "error" | "success"; +``` + +Defined in: [packages/query-core/src/types.ts:761](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L761) diff --git a/docs/framework/react/reference/type-aliases/SkipToken.md b/docs/framework/react/reference/type-aliases/SkipToken.md new file mode 100644 index 00000000000..3a5791b982e --- /dev/null +++ b/docs/framework/react/reference/type-aliases/SkipToken.md @@ -0,0 +1,12 @@ +--- +id: SkipToken +title: SkipToken +--- + +```ts +type SkipToken = typeof skipToken; +``` + +Defined in: [packages/query-core/src/utils.ts:526](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L526) + +The type of the [skipToken](../variables/skipToken.md) sentinel value. diff --git a/docs/framework/react/reference/type-aliases/StaleTime.md b/docs/framework/react/reference/type-aliases/StaleTime.md new file mode 100644 index 00000000000..3e7e21608be --- /dev/null +++ b/docs/framework/react/reference/type-aliases/StaleTime.md @@ -0,0 +1,10 @@ +--- +id: StaleTime +title: StaleTime +--- + +```ts +type StaleTime = number | "static"; +``` + +Defined in: [packages/query-core/src/types.ts:108](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L108) diff --git a/docs/framework/react/reference/type-aliases/StaleTimeFunction.md b/docs/framework/react/reference/type-aliases/StaleTimeFunction.md new file mode 100644 index 00000000000..b1c541fa64e --- /dev/null +++ b/docs/framework/react/reference/type-aliases/StaleTimeFunction.md @@ -0,0 +1,28 @@ +--- +id: StaleTimeFunction +title: StaleTimeFunction +--- + +```ts +type StaleTimeFunction = StaleTime | (query) => StaleTime; +``` + +Defined in: [packages/query-core/src/types.ts:110](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L110) + +## Type Parameters + +### TQueryFnData + +`TQueryFnData` = `unknown` + +### TError + +`TError` = [`DefaultError`](DefaultError.md) + +### TData + +`TData` = `TQueryFnData` + +### TQueryKey + +`TQueryKey` *extends* [`QueryKey`](QueryKey.md) = [`QueryKey`](QueryKey.md) diff --git a/docs/framework/react/reference/type-aliases/SuspenseQueriesOptions.md b/docs/framework/react/reference/type-aliases/SuspenseQueriesOptions.md index 213540b5449..e63aa2563b8 100644 --- a/docs/framework/react/reference/type-aliases/SuspenseQueriesOptions.md +++ b/docs/framework/react/reference/type-aliases/SuspenseQueriesOptions.md @@ -7,7 +7,7 @@ title: SuspenseQueriesOptions type SuspenseQueriesOptions = TDepth["length"] extends MAXIMUM_DEPTH ? UseSuspenseQueryOptions[] : T extends [] ? [] : T extends [infer Head] ? [...TResults, GetUseSuspenseQueryOptions] : T extends [infer Head, ...(infer Tails)] ? SuspenseQueriesOptions<[...Tails], [...TResults, GetUseSuspenseQueryOptions], [...TDepth, 1]> : unknown[] extends T ? T : T extends UseSuspenseQueryOptions[] ? UseSuspenseQueryOptions[] : UseSuspenseQueryOptions[]; ``` -Defined in: [react-query/src/useSuspenseQueries.ts:119](https://github.com/TanStack/query/blob/main/packages/react-query/src/useSuspenseQueries.ts#L119) +Defined in: [packages/react-query/src/useSuspenseQueries.ts:119](https://github.com/TanStack/query/blob/main/packages/react-query/src/useSuspenseQueries.ts#L119) The `queries` array accepted by `useSuspenseQueries`. Recursively unwraps each tuple element so every entry's `queryFn`/`select` are inferred individually, up to 20 elements. An opaque array (e.g. `unknown[]`) diff --git a/docs/framework/react/reference/type-aliases/SuspenseQueriesResults.md b/docs/framework/react/reference/type-aliases/SuspenseQueriesResults.md index 0db1c6f054e..f1c2d32eca0 100644 --- a/docs/framework/react/reference/type-aliases/SuspenseQueriesResults.md +++ b/docs/framework/react/reference/type-aliases/SuspenseQueriesResults.md @@ -7,7 +7,7 @@ title: SuspenseQueriesResults type SuspenseQueriesResults = TDepth["length"] extends MAXIMUM_DEPTH ? UseSuspenseQueryResult[] : T extends [] ? [] : T extends [infer Head] ? [...TResults, GetUseSuspenseQueryResult] : T extends [infer Head, ...(infer Tails)] ? SuspenseQueriesResults<[...Tails], [...TResults, GetUseSuspenseQueryResult], [...TDepth, 1]> : { [K in keyof T]: GetUseSuspenseQueryResult }; ``` -Defined in: [react-query/src/useSuspenseQueries.ts:165](https://github.com/TanStack/query/blob/main/packages/react-query/src/useSuspenseQueries.ts#L165) +Defined in: [packages/react-query/src/useSuspenseQueries.ts:165](https://github.com/TanStack/query/blob/main/packages/react-query/src/useSuspenseQueries.ts#L165) The result type returned by `useSuspenseQueries`, when no `combine` is provided. Mirrors [SuspenseQueriesOptions](SuspenseQueriesOptions.md): each tuple element's result type is inferred individually, up to 20 elements. diff --git a/docs/framework/react/reference/type-aliases/ThrowOnError.md b/docs/framework/react/reference/type-aliases/ThrowOnError.md new file mode 100644 index 00000000000..134683388ef --- /dev/null +++ b/docs/framework/react/reference/type-aliases/ThrowOnError.md @@ -0,0 +1,28 @@ +--- +id: ThrowOnError +title: ThrowOnError +--- + +```ts +type ThrowOnError = boolean | (error, query) => boolean; +``` + +Defined in: [packages/query-core/src/types.ts:368](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L368) + +## Type Parameters + +### TQueryFnData + +`TQueryFnData` + +### TError + +`TError` + +### TQueryData + +`TQueryData` + +### TQueryKey + +`TQueryKey` *extends* [`QueryKey`](QueryKey.md) diff --git a/docs/framework/react/reference/type-aliases/TimeoutCallback.md b/docs/framework/react/reference/type-aliases/TimeoutCallback.md new file mode 100644 index 00000000000..773b5fdaeb9 --- /dev/null +++ b/docs/framework/react/reference/type-aliases/TimeoutCallback.md @@ -0,0 +1,27 @@ +--- +id: TimeoutCallback +title: TimeoutCallback +--- + +```ts +type TimeoutCallback = (_) => void; +``` + +Defined in: [packages/query-core/src/timeoutManager.ts:9](https://github.com/TanStack/query/blob/main/packages/query-core/src/timeoutManager.ts#L9) + +[TimeoutManager](../interfaces/TimeoutManager.md) does not support passing arguments to the callback. + +`(_: void)` is the argument type inferred by TypeScript's default typings for +`setTimeout(cb, number)`. +If we don't accept a single void argument, then +`new Promise(resolve => timeoutManager.setTimeout(resolve, N))` is a type error. + +## Parameters + +### \_ + +`void` + +## Returns + +`void` diff --git a/docs/framework/react/reference/type-aliases/TimeoutProvider.md b/docs/framework/react/reference/type-aliases/TimeoutProvider.md new file mode 100644 index 00000000000..3509105bcd1 --- /dev/null +++ b/docs/framework/react/reference/type-aliases/TimeoutProvider.md @@ -0,0 +1,112 @@ +--- +id: TimeoutProvider +title: TimeoutProvider +--- + +```ts +type TimeoutProvider = object; +``` + +Defined in: [packages/query-core/src/timeoutManager.ts:28](https://github.com/TanStack/query/blob/main/packages/query-core/src/timeoutManager.ts#L28) + +Backend for timer functions. + +Timers are performance-sensitive: short-lived timers (delays under a few seconds) tend to be +latency-sensitive, while long-lived ones may benefit more from coalescing — batching timers +with similar deadlines together — which the default provider (backed by the platform's global +`setTimeout`/`setInterval`) does not do. A custom provider can implement coalescing, and can +also support delays longer than the ~24-day maximum of the global `setTimeout`. + +## Type Parameters + +### TTimerId + +`TTimerId` *extends* [`ManagedTimerId`](ManagedTimerId.md) = [`ManagedTimerId`](ManagedTimerId.md) + +## Properties + +### clearInterval() + +```ts +readonly clearInterval: (intervalId) => void; +``` + +Defined in: [packages/query-core/src/timeoutManager.ts:34](https://github.com/TanStack/query/blob/main/packages/query-core/src/timeoutManager.ts#L34) + +#### Parameters + +##### intervalId + +`TTimerId` | `undefined` + +#### Returns + +`void` + +*** + +### clearTimeout() + +```ts +readonly clearTimeout: (timeoutId) => void; +``` + +Defined in: [packages/query-core/src/timeoutManager.ts:31](https://github.com/TanStack/query/blob/main/packages/query-core/src/timeoutManager.ts#L31) + +#### Parameters + +##### timeoutId + +`TTimerId` | `undefined` + +#### Returns + +`void` + +*** + +### setInterval() + +```ts +readonly setInterval: (callback, delay) => TTimerId; +``` + +Defined in: [packages/query-core/src/timeoutManager.ts:33](https://github.com/TanStack/query/blob/main/packages/query-core/src/timeoutManager.ts#L33) + +#### Parameters + +##### callback + +[`TimeoutCallback`](TimeoutCallback.md) + +##### delay + +`number` + +#### Returns + +`TTimerId` + +*** + +### setTimeout() + +```ts +readonly setTimeout: (callback, delay) => TTimerId; +``` + +Defined in: [packages/query-core/src/timeoutManager.ts:30](https://github.com/TanStack/query/blob/main/packages/query-core/src/timeoutManager.ts#L30) + +#### Parameters + +##### callback + +[`TimeoutCallback`](TimeoutCallback.md) + +##### delay + +`number` + +#### Returns + +`TTimerId` diff --git a/docs/framework/react/reference/type-aliases/UndefinedInitialDataInfiniteOptions.md b/docs/framework/react/reference/type-aliases/UndefinedInitialDataInfiniteOptions.md index a59e75eeb93..de486a2b72d 100644 --- a/docs/framework/react/reference/type-aliases/UndefinedInitialDataInfiniteOptions.md +++ b/docs/framework/react/reference/type-aliases/UndefinedInitialDataInfiniteOptions.md @@ -7,7 +7,7 @@ title: UndefinedInitialDataInfiniteOptions type UndefinedInitialDataInfiniteOptions = UseInfiniteQueryOptions & object; ``` -Defined in: [react-query/src/infiniteQueryOptions.ts:24](https://github.com/TanStack/query/blob/main/packages/react-query/src/infiniteQueryOptions.ts#L24) +Defined in: [packages/react-query/src/infiniteQueryOptions.ts:24](https://github.com/TanStack/query/blob/main/packages/react-query/src/infiniteQueryOptions.ts#L24) The options accepted by the `infiniteQueryOptions` overload selected when no `initialData` is set — `data` may be `undefined` while the query is `pending`. @@ -38,20 +38,20 @@ The type of a single page, as your `queryFn` resolves it. ### TError -`TError` = `DefaultError` +`TError` = [`DefaultError`](DefaultError.md) The type of errors your `queryFn` may throw. ### TData -`TData` = `InfiniteData`\<`TQueryFnData`\> +`TData` = [`InfiniteData`](../interfaces/InfiniteData.md)\<`TQueryFnData`\> The type `data` ends up as after `select` runs — defaults to `InfiniteData`, the shape of all fetched pages plus their page params. ### TQueryKey -`TQueryKey` *extends* `QueryKey` = `QueryKey` +`TQueryKey` *extends* [`QueryKey`](QueryKey.md) = [`QueryKey`](QueryKey.md) The type of your `queryKey`. diff --git a/docs/framework/react/reference/type-aliases/UndefinedInitialDataOptions.md b/docs/framework/react/reference/type-aliases/UndefinedInitialDataOptions.md index cfabb5cd25d..bf9de58ac2d 100644 --- a/docs/framework/react/reference/type-aliases/UndefinedInitialDataOptions.md +++ b/docs/framework/react/reference/type-aliases/UndefinedInitialDataOptions.md @@ -7,7 +7,7 @@ title: UndefinedInitialDataOptions type UndefinedInitialDataOptions = UseQueryOptions & object; ``` -Defined in: [react-query/src/queryOptions.ts:22](https://github.com/TanStack/query/blob/main/packages/react-query/src/queryOptions.ts#L22) +Defined in: [packages/react-query/src/queryOptions.ts:22](https://github.com/TanStack/query/blob/main/packages/react-query/src/queryOptions.ts#L22) The options accepted by the `queryOptions` overload selected when no `initialData` is set — `data` may be `undefined` while the query is `pending`. @@ -38,7 +38,7 @@ The type your `queryFn` resolves to. ### TError -`TError` = `DefaultError` +`TError` = [`DefaultError`](DefaultError.md) The type of errors your `queryFn` may throw. @@ -50,6 +50,6 @@ The type `data` ends up as after `select` runs. ### TQueryKey -`TQueryKey` *extends* `QueryKey` = `QueryKey` +`TQueryKey` *extends* [`QueryKey`](QueryKey.md) = [`QueryKey`](QueryKey.md) The type of your `queryKey`. diff --git a/docs/framework/react/reference/type-aliases/UnsetMarker.md b/docs/framework/react/reference/type-aliases/UnsetMarker.md new file mode 100644 index 00000000000..8b9c14e1907 --- /dev/null +++ b/docs/framework/react/reference/type-aliases/UnsetMarker.md @@ -0,0 +1,10 @@ +--- +id: UnsetMarker +title: UnsetMarker +--- + +```ts +type UnsetMarker = typeof unsetMarker; +``` + +Defined in: [packages/query-core/src/types.ts:66](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L66) diff --git a/docs/framework/react/reference/type-aliases/UnusedSkipTokenInfiniteOptions.md b/docs/framework/react/reference/type-aliases/UnusedSkipTokenInfiniteOptions.md index 180225a81bf..1d098ea74fc 100644 --- a/docs/framework/react/reference/type-aliases/UnusedSkipTokenInfiniteOptions.md +++ b/docs/framework/react/reference/type-aliases/UnusedSkipTokenInfiniteOptions.md @@ -7,7 +7,7 @@ title: UnusedSkipTokenInfiniteOptions type UnusedSkipTokenInfiniteOptions = OmitKeyof, "queryFn"> & object; ``` -Defined in: [react-query/src/infiniteQueryOptions.ts:64](https://github.com/TanStack/query/blob/main/packages/react-query/src/infiniteQueryOptions.ts#L64) +Defined in: [packages/react-query/src/infiniteQueryOptions.ts:64](https://github.com/TanStack/query/blob/main/packages/react-query/src/infiniteQueryOptions.ts#L64) The options accepted by the `infiniteQueryOptions` overload selected when no `initialData` is set and `queryFn` is not `skipToken` — same as [UndefinedInitialDataInfiniteOptions](UndefinedInitialDataInfiniteOptions.md), but `queryFn` may not be @@ -36,20 +36,20 @@ The type of a single page, as your `queryFn` resolves it. ### TError -`TError` = `DefaultError` +`TError` = [`DefaultError`](DefaultError.md) The type of errors your `queryFn` may throw. ### TData -`TData` = `InfiniteData`\<`TQueryFnData`\> +`TData` = [`InfiniteData`](../interfaces/InfiniteData.md)\<`TQueryFnData`\> The type `data` ends up as after `select` runs — defaults to `InfiniteData`, the shape of all fetched pages plus their page params. ### TQueryKey -`TQueryKey` *extends* `QueryKey` = `QueryKey` +`TQueryKey` *extends* [`QueryKey`](QueryKey.md) = [`QueryKey`](QueryKey.md) The type of your `queryKey`. diff --git a/docs/framework/react/reference/type-aliases/UnusedSkipTokenOptions.md b/docs/framework/react/reference/type-aliases/UnusedSkipTokenOptions.md index dee4b40d41a..0a7365b2ffa 100644 --- a/docs/framework/react/reference/type-aliases/UnusedSkipTokenOptions.md +++ b/docs/framework/react/reference/type-aliases/UnusedSkipTokenOptions.md @@ -7,7 +7,7 @@ title: UnusedSkipTokenOptions type UnusedSkipTokenOptions = OmitKeyof, "queryFn"> & object; ``` -Defined in: [react-query/src/queryOptions.ts:50](https://github.com/TanStack/query/blob/main/packages/react-query/src/queryOptions.ts#L50) +Defined in: [packages/react-query/src/queryOptions.ts:50](https://github.com/TanStack/query/blob/main/packages/react-query/src/queryOptions.ts#L50) The options accepted by the `queryOptions` overload selected when no `initialData` is set and `queryFn` is not `skipToken` — same as [UndefinedInitialDataOptions](UndefinedInitialDataOptions.md), but `queryFn` may not be `skipToken`. @@ -35,7 +35,7 @@ The type your `queryFn` resolves to. ### TError -`TError` = `DefaultError` +`TError` = [`DefaultError`](DefaultError.md) The type of errors your `queryFn` may throw. @@ -47,6 +47,6 @@ The type `data` ends up as after `select` runs. ### TQueryKey -`TQueryKey` *extends* `QueryKey` = `QueryKey` +`TQueryKey` *extends* [`QueryKey`](QueryKey.md) = [`QueryKey`](QueryKey.md) The type of your `queryKey`. diff --git a/docs/framework/react/reference/type-aliases/Updater.md b/docs/framework/react/reference/type-aliases/Updater.md new file mode 100644 index 00000000000..7a0c2f30503 --- /dev/null +++ b/docs/framework/react/reference/type-aliases/Updater.md @@ -0,0 +1,35 @@ +--- +id: Updater +title: Updater +--- + +```ts +type Updater = TOutput | (input) => TOutput; +``` + +Defined in: [packages/query-core/src/utils.ts:105](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L105) + +Either a plain value of type `TOutput`, or a function that receives `TInput` and returns `TOutput`. +Used for example by `setQueryData`-style updaters, which accept either the new data directly or a +function that computes it from the previous data. See functionalUpdate. + +## Type Parameters + +### TInput + +`TInput` + +### TOutput + +`TOutput` + +## Example + +```ts +queryClient.setQueryData(['posts'], newPosts) + +// Or, using an updater function that receives the current data: +queryClient.setQueryData(['posts'], (oldPosts) => + oldPosts ? [...oldPosts, newPost] : oldPosts, +) +``` diff --git a/docs/framework/react/reference/type-aliases/UseBaseMutationResult.md b/docs/framework/react/reference/type-aliases/UseBaseMutationResult.md index f6c7190284c..86d821ea070 100644 --- a/docs/framework/react/reference/type-aliases/UseBaseMutationResult.md +++ b/docs/framework/react/reference/type-aliases/UseBaseMutationResult.md @@ -9,9 +9,9 @@ type UseBaseMutationResult = Overrid }> & object; ``` -Defined in: [react-query/src/types.ts:471](https://github.com/TanStack/query/blob/main/packages/react-query/src/types.ts#L471) +Defined in: [packages/react-query/src/types.ts:471](https://github.com/TanStack/query/blob/main/packages/react-query/src/types.ts#L471) -The result of `useMutation`. Same as MutationObserverResult from `@tanstack/query-core`, with +The result of `useMutation`. Same as [MutationObserverResult](MutationObserverResult.md) from `@tanstack/query-core`, with `mutate` narrowed to the fire-and-forget [UseMutateFunction](UseMutateFunction.md) signature, plus the added `mutateAsync`. ## Type Declaration @@ -34,7 +34,7 @@ The type your mutation function resolves to. ### TError -`TError` = `DefaultError` +`TError` = [`DefaultError`](DefaultError.md) The type of errors your mutation function may throw. diff --git a/docs/framework/react/reference/type-aliases/UseBaseQueryResult.md b/docs/framework/react/reference/type-aliases/UseBaseQueryResult.md index fd2e94e6bef..dc4dbd8b812 100644 --- a/docs/framework/react/reference/type-aliases/UseBaseQueryResult.md +++ b/docs/framework/react/reference/type-aliases/UseBaseQueryResult.md @@ -7,10 +7,10 @@ title: UseBaseQueryResult type UseBaseQueryResult = QueryObserverResult; ``` -Defined in: [react-query/src/types.ts:314](https://github.com/TanStack/query/blob/main/packages/react-query/src/types.ts#L314) +Defined in: [packages/react-query/src/types.ts:314](https://github.com/TanStack/query/blob/main/packages/react-query/src/types.ts#L314) The result of `useQuery` when `initialData` isn't set — `data` may be `undefined` while the query is -`pending`. Re-exports QueryObserverResult from `@tanstack/query-core`. `useInfiniteQuery` returns +`pending`. Re-exports [QueryObserverResult](QueryObserverResult.md) from `@tanstack/query-core`. `useInfiniteQuery` returns [UseInfiniteQueryResult](UseInfiniteQueryResult.md) instead. ## Type Parameters @@ -23,6 +23,6 @@ The type `data` ends up as after `select` runs. ### TError -`TError` = `DefaultError` +`TError` = [`DefaultError`](DefaultError.md) The type of errors your `queryFn` may throw. diff --git a/docs/framework/react/reference/type-aliases/UseInfiniteQueryResult.md b/docs/framework/react/reference/type-aliases/UseInfiniteQueryResult.md index 019bf84cd3c..53e06124b7b 100644 --- a/docs/framework/react/reference/type-aliases/UseInfiniteQueryResult.md +++ b/docs/framework/react/reference/type-aliases/UseInfiniteQueryResult.md @@ -7,10 +7,10 @@ title: UseInfiniteQueryResult type UseInfiniteQueryResult = InfiniteQueryObserverResult; ``` -Defined in: [react-query/src/types.ts:365](https://github.com/TanStack/query/blob/main/packages/react-query/src/types.ts#L365) +Defined in: [packages/react-query/src/types.ts:365](https://github.com/TanStack/query/blob/main/packages/react-query/src/types.ts#L365) The result of `useInfiniteQuery` when `initialData` isn't set — `data` may be `undefined` while the query is -`pending`. Re-exports InfiniteQueryObserverResult from `@tanstack/query-core`. +`pending`. Re-exports [InfiniteQueryObserverResult](InfiniteQueryObserverResult.md) from `@tanstack/query-core`. ## Type Parameters @@ -22,6 +22,6 @@ The type `data` ends up as after `select` runs. ### TError -`TError` = `DefaultError` +`TError` = [`DefaultError`](DefaultError.md) The type of errors your `queryFn` may throw. diff --git a/docs/framework/react/reference/type-aliases/UseMutateAsyncFunction.md b/docs/framework/react/reference/type-aliases/UseMutateAsyncFunction.md index b190e9e9c5d..3cedcd5ea1f 100644 --- a/docs/framework/react/reference/type-aliases/UseMutateAsyncFunction.md +++ b/docs/framework/react/reference/type-aliases/UseMutateAsyncFunction.md @@ -7,7 +7,7 @@ title: UseMutateAsyncFunction type UseMutateAsyncFunction = MutateFunction; ``` -Defined in: [react-query/src/types.ts:454](https://github.com/TanStack/query/blob/main/packages/react-query/src/types.ts#L454) +Defined in: [packages/react-query/src/types.ts:454](https://github.com/TanStack/query/blob/main/packages/react-query/src/types.ts#L454) The type of `mutateAsync`, as returned by `useMutation`. Similar to [UseMutateFunction](UseMutateFunction.md), but returns a promise which can be awaited. @@ -22,7 +22,7 @@ The type your mutation function resolves to. ### TError -`TError` = `DefaultError` +`TError` = [`DefaultError`](DefaultError.md) The type of errors your mutation function may throw. diff --git a/docs/framework/react/reference/type-aliases/UseMutateFunction.md b/docs/framework/react/reference/type-aliases/UseMutateFunction.md index 09312afba8f..ede87618a20 100644 --- a/docs/framework/react/reference/type-aliases/UseMutateFunction.md +++ b/docs/framework/react/reference/type-aliases/UseMutateFunction.md @@ -7,7 +7,7 @@ title: UseMutateFunction type UseMutateFunction = (...args) => void; ``` -Defined in: [react-query/src/types.ts:433](https://github.com/TanStack/query/blob/main/packages/react-query/src/types.ts#L433) +Defined in: [packages/react-query/src/types.ts:433](https://github.com/TanStack/query/blob/main/packages/react-query/src/types.ts#L433) The type of `mutate`, as returned by `useMutation`. Forwards the variables (and an optional per-call `onSuccess`/`onError`/`onSettled`) to the underlying `mutate` call. Fire-and-forget — errors are surfaced @@ -23,7 +23,7 @@ The type your mutation function resolves to. ### TError -`TError` = `DefaultError` +`TError` = [`DefaultError`](DefaultError.md) The type of errors your mutation function may throw. @@ -44,7 +44,7 @@ their `onMutateResult` parameter — useful for optimistic-update rollback data. ### args -...`Parameters`\<`MutateFunction`\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\>\> +...`Parameters`\<[`MutateFunction`](MutateFunction.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\>\> ## Returns diff --git a/docs/framework/react/reference/type-aliases/UseMutationResult.md b/docs/framework/react/reference/type-aliases/UseMutationResult.md index 6fcc1df853b..5eed68d0161 100644 --- a/docs/framework/react/reference/type-aliases/UseMutationResult.md +++ b/docs/framework/react/reference/type-aliases/UseMutationResult.md @@ -7,7 +7,7 @@ title: UseMutationResult type UseMutationResult = UseBaseMutationResult; ``` -Defined in: [react-query/src/types.ts:500](https://github.com/TanStack/query/blob/main/packages/react-query/src/types.ts#L500) +Defined in: [packages/react-query/src/types.ts:500](https://github.com/TanStack/query/blob/main/packages/react-query/src/types.ts#L500) The result of `useMutation`. Same as [UseBaseMutationResult](UseBaseMutationResult.md). @@ -21,7 +21,7 @@ The type your mutation function resolves to. ### TError -`TError` = `DefaultError` +`TError` = [`DefaultError`](DefaultError.md) The type of errors your mutation function may throw. diff --git a/docs/framework/react/reference/type-aliases/UsePrefetchInfiniteQueryOptions.md b/docs/framework/react/reference/type-aliases/UsePrefetchInfiniteQueryOptions.md index f2dc79b0825..cddee068a8d 100644 --- a/docs/framework/react/reference/type-aliases/UsePrefetchInfiniteQueryOptions.md +++ b/docs/framework/react/reference/type-aliases/UsePrefetchInfiniteQueryOptions.md @@ -7,7 +7,7 @@ title: UsePrefetchInfiniteQueryOptions type UsePrefetchInfiniteQueryOptions = DistributiveOmit, "queryFn"> & object; ``` -Defined in: [react-query/src/types.ts:118](https://github.com/TanStack/query/blob/main/packages/react-query/src/types.ts#L118) +Defined in: [packages/react-query/src/types.ts:118](https://github.com/TanStack/query/blob/main/packages/react-query/src/types.ts#L118) The options accepted by `usePrefetchInfiniteQuery` — everything you can pass to `queryClient.infiniteQuery`, except `queryFn` is required unless a default query function has been defined. @@ -33,13 +33,13 @@ The type of a single page, as your `queryFn` resolves it. ### TError -`TError` = `DefaultError` +`TError` = [`DefaultError`](DefaultError.md) The type of errors your `queryFn` may throw. ### TData -`TData` = `InfiniteData`\<`TQueryFnData`\> +`TData` = [`InfiniteData`](../interfaces/InfiniteData.md)\<`TQueryFnData`\> The type `data` ends up as after `select` runs. Defaults to `InfiniteData`, the shape of all fetched pages plus their page params — a prefetch never reads `data` back out, so this @@ -47,7 +47,7 @@ parameter only matters if you reuse these options elsewhere with `select` applie ### TQueryKey -`TQueryKey` *extends* `QueryKey` = `QueryKey` +`TQueryKey` *extends* [`QueryKey`](QueryKey.md) = [`QueryKey`](QueryKey.md) The type of your `queryKey`. diff --git a/docs/framework/react/reference/type-aliases/UsePrefetchQueryOptions.md b/docs/framework/react/reference/type-aliases/UsePrefetchQueryOptions.md index 2e8ce8ab558..ccf272bb395 100644 --- a/docs/framework/react/reference/type-aliases/UsePrefetchQueryOptions.md +++ b/docs/framework/react/reference/type-aliases/UsePrefetchQueryOptions.md @@ -7,7 +7,7 @@ title: UsePrefetchQueryOptions type UsePrefetchQueryOptions = DistributiveOmit, "queryFn"> & object; ``` -Defined in: [react-query/src/types.ts:80](https://github.com/TanStack/query/blob/main/packages/react-query/src/types.ts#L80) +Defined in: [packages/react-query/src/types.ts:80](https://github.com/TanStack/query/blob/main/packages/react-query/src/types.ts#L80) The options accepted by `usePrefetchQuery` — everything you can pass to `queryClient.query`, except `queryFn` is required unless a default query function has been defined. @@ -33,7 +33,7 @@ The type your `queryFn` resolves to. ### TError -`TError` = `DefaultError` +`TError` = [`DefaultError`](DefaultError.md) The type of errors your `queryFn` may throw. @@ -53,6 +53,6 @@ The type of the data actually held in the query cache — the input to `select` ### TQueryKey -`TQueryKey` *extends* `QueryKey` = `QueryKey` +`TQueryKey` *extends* [`QueryKey`](QueryKey.md) = [`QueryKey`](QueryKey.md) The type of your `queryKey`. diff --git a/docs/framework/react/reference/type-aliases/UseQueryResult.md b/docs/framework/react/reference/type-aliases/UseQueryResult.md index b64fffaf328..c557f59e842 100644 --- a/docs/framework/react/reference/type-aliases/UseQueryResult.md +++ b/docs/framework/react/reference/type-aliases/UseQueryResult.md @@ -7,7 +7,7 @@ title: UseQueryResult type UseQueryResult = UseBaseQueryResult; ``` -Defined in: [react-query/src/types.ts:325](https://github.com/TanStack/query/blob/main/packages/react-query/src/types.ts#L325) +Defined in: [packages/react-query/src/types.ts:325](https://github.com/TanStack/query/blob/main/packages/react-query/src/types.ts#L325) The result of `useQuery`. Same as [UseBaseQueryResult](UseBaseQueryResult.md). @@ -21,6 +21,6 @@ The type `data` ends up as after `select` runs. ### TError -`TError` = `DefaultError` +`TError` = [`DefaultError`](DefaultError.md) The type of errors your `queryFn` may throw. diff --git a/docs/framework/react/reference/type-aliases/UseSuspenseInfiniteQueryResult.md b/docs/framework/react/reference/type-aliases/UseSuspenseInfiniteQueryResult.md index d44b2182610..eda0d8b290e 100644 --- a/docs/framework/react/reference/type-aliases/UseSuspenseInfiniteQueryResult.md +++ b/docs/framework/react/reference/type-aliases/UseSuspenseInfiniteQueryResult.md @@ -7,7 +7,7 @@ title: UseSuspenseInfiniteQueryResult type UseSuspenseInfiniteQueryResult = OmitKeyof, "isPlaceholderData">; ``` -Defined in: [react-query/src/types.ts:389](https://github.com/TanStack/query/blob/main/packages/react-query/src/types.ts#L389) +Defined in: [packages/react-query/src/types.ts:389](https://github.com/TanStack/query/blob/main/packages/react-query/src/types.ts#L389) The result of `useSuspenseInfiniteQuery`. Same as [DefinedUseInfiniteQueryResult](DefinedUseInfiniteQueryResult.md), minus `isPlaceholderData` — Suspense hooks never render placeholder data. @@ -22,6 +22,6 @@ The type `data` ends up as after `select` runs. ### TError -`TError` = `DefaultError` +`TError` = [`DefaultError`](DefaultError.md) The type of errors your `queryFn` may throw. diff --git a/docs/framework/react/reference/type-aliases/UseSuspenseQueryResult.md b/docs/framework/react/reference/type-aliases/UseSuspenseQueryResult.md index fde2040cab7..d3e04a8a059 100644 --- a/docs/framework/react/reference/type-aliases/UseSuspenseQueryResult.md +++ b/docs/framework/react/reference/type-aliases/UseSuspenseQueryResult.md @@ -7,7 +7,7 @@ title: UseSuspenseQueryResult type UseSuspenseQueryResult = DistributiveOmit, "isPlaceholderData">; ``` -Defined in: [react-query/src/types.ts:337](https://github.com/TanStack/query/blob/main/packages/react-query/src/types.ts#L337) +Defined in: [packages/react-query/src/types.ts:337](https://github.com/TanStack/query/blob/main/packages/react-query/src/types.ts#L337) The result of `useSuspenseQuery`. Same as [DefinedUseQueryResult](DefinedUseQueryResult.md), minus `isPlaceholderData` — always `false` on that type, so this drops the dead field rather than an active state. @@ -22,6 +22,6 @@ The type `data` ends up as after `select` runs. ### TError -`TError` = `DefaultError` +`TError` = [`DefaultError`](DefaultError.md) The type of errors your `queryFn` may throw. diff --git a/docs/framework/react/reference/type-aliases/WithRequired.md b/docs/framework/react/reference/type-aliases/WithRequired.md new file mode 100644 index 00000000000..a40a48c865b --- /dev/null +++ b/docs/framework/react/reference/type-aliases/WithRequired.md @@ -0,0 +1,20 @@ +--- +id: WithRequired +title: WithRequired +--- + +```ts +type WithRequired = TTarget & { [_ in TKey]: {} }; +``` + +Defined in: [packages/query-core/src/types.ts:524](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L524) + +## Type Parameters + +### TTarget + +`TTarget` + +### TKey + +`TKey` *extends* keyof `TTarget` diff --git a/docs/framework/react/reference/type-aliases/dataTagErrorSymbol.md b/docs/framework/react/reference/type-aliases/dataTagErrorSymbol.md new file mode 100644 index 00000000000..26148a94d6e --- /dev/null +++ b/docs/framework/react/reference/type-aliases/dataTagErrorSymbol.md @@ -0,0 +1,10 @@ +--- +id: dataTagErrorSymbol +title: dataTagErrorSymbol +--- + +```ts +type dataTagErrorSymbol = typeof dataTagErrorSymbol; +``` + +Defined in: [packages/query-core/src/types.ts:63](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L63) diff --git a/docs/framework/react/reference/type-aliases/dataTagSymbol.md b/docs/framework/react/reference/type-aliases/dataTagSymbol.md new file mode 100644 index 00000000000..0012c108cc5 --- /dev/null +++ b/docs/framework/react/reference/type-aliases/dataTagSymbol.md @@ -0,0 +1,10 @@ +--- +id: dataTagSymbol +title: dataTagSymbol +--- + +```ts +type dataTagSymbol = typeof dataTagSymbol; +``` + +Defined in: [packages/query-core/src/types.ts:61](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L61) diff --git a/docs/framework/react/reference/variables/IsRestoringProvider.md b/docs/framework/react/reference/variables/IsRestoringProvider.md index e320fdaefe0..e639f1db7c2 100644 --- a/docs/framework/react/reference/variables/IsRestoringProvider.md +++ b/docs/framework/react/reference/variables/IsRestoringProvider.md @@ -7,7 +7,7 @@ title: IsRestoringProvider const IsRestoringProvider: Provider = IsRestoringContext.Provider; ``` -Defined in: [react-query/src/IsRestoringProvider.ts:19](https://github.com/TanStack/query/blob/main/packages/react-query/src/IsRestoringProvider.ts#L19) +Defined in: [packages/react-query/src/IsRestoringProvider.ts:19](https://github.com/TanStack/query/blob/main/packages/react-query/src/IsRestoringProvider.ts#L19) The Provider that `PersistQueryClientProvider` uses to signal whether a persisted client is currently being restored, read by `useIsRestoring`. diff --git a/docs/framework/react/reference/variables/QueryClientContext.md b/docs/framework/react/reference/variables/QueryClientContext.md index 20619cd18df..96c30a4f250 100644 --- a/docs/framework/react/reference/variables/QueryClientContext.md +++ b/docs/framework/react/reference/variables/QueryClientContext.md @@ -7,6 +7,6 @@ title: QueryClientContext const QueryClientContext: Context; ``` -Defined in: [react-query/src/QueryClientProvider.tsx:9](https://github.com/TanStack/query/blob/main/packages/react-query/src/QueryClientProvider.tsx#L9) +Defined in: [packages/react-query/src/QueryClientProvider.tsx:9](https://github.com/TanStack/query/blob/main/packages/react-query/src/QueryClientProvider.tsx#L9) The context that `useQueryClient` reads from. `QueryClientProvider` is the normal way to set it. diff --git a/docs/framework/react/reference/variables/dataTagErrorSymbol.md b/docs/framework/react/reference/variables/dataTagErrorSymbol.md new file mode 100644 index 00000000000..20bab62fb01 --- /dev/null +++ b/docs/framework/react/reference/variables/dataTagErrorSymbol.md @@ -0,0 +1,10 @@ +--- +id: dataTagErrorSymbol +title: dataTagErrorSymbol +--- + +```ts +const dataTagErrorSymbol: typeof dataTagErrorSymbol; +``` + +Defined in: [packages/query-core/src/types.ts:63](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L63) diff --git a/docs/framework/react/reference/variables/dataTagSymbol.md b/docs/framework/react/reference/variables/dataTagSymbol.md new file mode 100644 index 00000000000..83dd68a56e9 --- /dev/null +++ b/docs/framework/react/reference/variables/dataTagSymbol.md @@ -0,0 +1,10 @@ +--- +id: dataTagSymbol +title: dataTagSymbol +--- + +```ts +const dataTagSymbol: typeof dataTagSymbol; +``` + +Defined in: [packages/query-core/src/types.ts:61](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L61) diff --git a/docs/framework/react/reference/variables/defaultScheduler.md b/docs/framework/react/reference/variables/defaultScheduler.md new file mode 100644 index 00000000000..70e14d3f846 --- /dev/null +++ b/docs/framework/react/reference/variables/defaultScheduler.md @@ -0,0 +1,13 @@ +--- +id: defaultScheduler +title: defaultScheduler +--- + +```ts +const defaultScheduler: ScheduleFunction = systemSetTimeoutZero; +``` + +Defined in: [packages/query-core/src/notifyManager.ts:19](https://github.com/TanStack/query/blob/main/packages/query-core/src/notifyManager.ts#L19) + +Default scheduling function used by the notify manager. +Schedules the callback with the system's `setTimeout(callback, 0)`. diff --git a/docs/framework/react/reference/variables/environmentManager.md b/docs/framework/react/reference/variables/environmentManager.md new file mode 100644 index 00000000000..c1e4abc429a --- /dev/null +++ b/docs/framework/react/reference/variables/environmentManager.md @@ -0,0 +1,61 @@ +--- +id: environmentManager +title: environmentManager +redirect_from: + - reference/environmentManager +--- + +```ts +const environmentManager: object; +``` + +Defined in: [packages/query-core/src/environmentManager.ts:29](https://github.com/TanStack/query/blob/main/packages/query-core/src/environmentManager.ts#L29) + +Manages how TanStack Query detects whether the current runtime should be treated as +server-side, which disables scheduling refetch timers and changes the default `retry` count +and `gcTime`. By default, the detection treats a missing `window` (or the presence of a +`Deno` global) as server. + +Override this for runtimes where that default detection would give the wrong answer — for +example, a Service Worker, where `window` is undefined even though the environment should +behave like a client. + +## Type Declaration + +### isServer() + +```ts +isServer: () => boolean; +``` + +Returns whether the current runtime should be treated as a server environment. + +#### Returns + +`boolean` + +### setIsServer() + +```ts +setIsServer(isServerValue): void; +``` + +Overrides the server check globally. + +#### Parameters + +##### isServerValue + +`IsServerValue` + +#### Returns + +`void` + +## Example + +```ts +import { environmentManager } from '@tanstack/query-core' + +environmentManager.setIsServer(() => false) +``` diff --git a/docs/framework/react/reference/variables/focusManager.md b/docs/framework/react/reference/variables/focusManager.md new file mode 100644 index 00000000000..86477849e06 --- /dev/null +++ b/docs/framework/react/reference/variables/focusManager.md @@ -0,0 +1,12 @@ +--- +id: focusManager +title: focusManager +--- + +```ts +const focusManager: FocusManager; +``` + +Defined in: [packages/query-core/src/focusManager.ts:142](https://github.com/TanStack/query/blob/main/packages/query-core/src/focusManager.ts#L142) + +Singleton instance of [FocusManager](../interfaces/FocusManager.md), used to manage and observe the focus state within TanStack Query. diff --git a/docs/framework/react/reference/variables/isServer.md b/docs/framework/react/reference/variables/isServer.md new file mode 100644 index 00000000000..16aa39d1244 --- /dev/null +++ b/docs/framework/react/reference/variables/isServer.md @@ -0,0 +1,14 @@ +--- +id: isServer +title: isServer +--- + +```ts +const isServer: boolean; +``` + +Defined in: [packages/query-core/src/utils.ts:114](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L114) + +## Deprecated + +use `environmentManager.isServer()` instead. diff --git a/docs/framework/react/reference/variables/notifyManager.md b/docs/framework/react/reference/variables/notifyManager.md new file mode 100644 index 00000000000..b5da92573e1 --- /dev/null +++ b/docs/framework/react/reference/variables/notifyManager.md @@ -0,0 +1,169 @@ +--- +id: notifyManager +title: notifyManager +redirect_from: + - reference/notifyManager + - framework/react/reference/notifyManager +--- + +```ts +const notifyManager: object; +``` + +Defined in: [packages/query-core/src/notifyManager.ts:144](https://github.com/TanStack/query/blob/main/packages/query-core/src/notifyManager.ts#L144) + +Handles scheduling and batching callbacks in TanStack Query. + +## Type Declaration + +### batch() + +```ts +readonly batch: (callback) => T; +``` + +Batches all updates scheduled inside the passed callback. +This is mainly used internally to optimize query client updating. +Batches can be nested; the queue is only flushed once the outermost `batch` call finishes. +The return value of `callback` is passed through. + +#### Type Parameters + +##### T + +`T` + +#### Parameters + +##### callback + +() => `T` + +#### Returns + +`T` + +### batchCalls() + +```ts +readonly batchCalls: (callback) => BatchCallsCallback; +``` + +All calls to the wrapped function will be batched. + +#### Type Parameters + +##### T + +`T` *extends* `unknown`[] + +#### Parameters + +##### callback + +`BatchCallsCallback`\<`T`\> + +#### Returns + +`BatchCallsCallback`\<`T`\> + +### schedule() + +```ts +schedule: (callback) => void; +``` + +Schedules a function to be run on the next batch. +By default, the batch is run with a `setTimeout`, but this can be configured via `setScheduler`. + +#### Parameters + +##### callback + +`NotifyCallback` + +#### Returns + +`void` + +### setBatchNotifyFunction() + +```ts +readonly setBatchNotifyFunction: (fn) => void; +``` + +Use this method to set a custom function to batch notifications together into a single tick. +Framework adapters use this to plug in their own batching primitive, so that a single query +update only triggers one re-render instead of one per subscriber. + +#### Parameters + +##### fn + +`BatchNotifyFunction` + +#### Returns + +`void` + +#### Example + +```ts +import { notifyManager } from '@tanstack/query-core' +import { batch } from 'solid-js' + +notifyManager.setBatchNotifyFunction(batch) +``` + +### setNotifyFunction() + +```ts +readonly setNotifyFunction: (fn) => void; +``` + +Use this method to set a custom notify function. +This can be used to for example wrap notifications with `React.act` while running tests. + +#### Parameters + +##### fn + +`NotifyFunction` + +#### Returns + +`void` + +### setScheduler() + +```ts +readonly setScheduler: (fn) => void; +``` + +Configures a custom callback that schedules when the next batch runs. +The default behavior is `setTimeout(callback, 0)`. + +#### Parameters + +##### fn + +`ScheduleFunction` + +#### Returns + +`void` + +#### Example + +```ts +import { notifyManager } from '@tanstack/query-core' + +// Schedule batches in the next microtask +notifyManager.setScheduler(queueMicrotask) + +// Schedule batches before the next frame is rendered +notifyManager.setScheduler(requestAnimationFrame) + +// Schedule batches some time in the future +notifyManager.setScheduler((cb) => setTimeout(cb, 10)) +``` diff --git a/docs/framework/react/reference/variables/onlineManager.md b/docs/framework/react/reference/variables/onlineManager.md new file mode 100644 index 00000000000..2eeec5385d8 --- /dev/null +++ b/docs/framework/react/reference/variables/onlineManager.md @@ -0,0 +1,12 @@ +--- +id: onlineManager +title: onlineManager +--- + +```ts +const onlineManager: OnlineManager; +``` + +Defined in: [packages/query-core/src/onlineManager.ts:117](https://github.com/TanStack/query/blob/main/packages/query-core/src/onlineManager.ts#L117) + +Singleton instance of [OnlineManager](../interfaces/OnlineManager.md), used to manage and observe the online state within TanStack Query. diff --git a/docs/framework/react/reference/variables/skipToken.md b/docs/framework/react/reference/variables/skipToken.md new file mode 100644 index 00000000000..a390d0b7b66 --- /dev/null +++ b/docs/framework/react/reference/variables/skipToken.md @@ -0,0 +1,23 @@ +--- +id: skipToken +title: skipToken +--- + +```ts +const skipToken: typeof skipToken; +``` + +Defined in: [packages/query-core/src/utils.ts:522](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L522) + +Sentinel value that can be passed as a query's `queryFn` to conditionally disable the query (equivalent +to `enabled: false`) while preserving full type inference for the query's data. Unlike `enabled: false`, +a query disabled via `skipToken` cannot be triggered with `refetch`. + +## Example + +```ts +new QueryObserver(queryClient, { + queryKey: ['post', postId], + queryFn: postId != null ? () => fetchPost(postId) : skipToken, +}) +``` diff --git a/docs/framework/react/reference/variables/timeoutManager.md b/docs/framework/react/reference/variables/timeoutManager.md new file mode 100644 index 00000000000..1eca1a5f343 --- /dev/null +++ b/docs/framework/react/reference/variables/timeoutManager.md @@ -0,0 +1,12 @@ +--- +id: timeoutManager +title: timeoutManager +--- + +```ts +const timeoutManager: TimeoutManager; +``` + +Defined in: [packages/query-core/src/timeoutManager.ts:232](https://github.com/TanStack/query/blob/main/packages/query-core/src/timeoutManager.ts#L232) + +Singleton instance of [TimeoutManager](../interfaces/TimeoutManager.md), used throughout TanStack Query to schedule and cancel timers. diff --git a/docs/framework/react/reference/variables/unsetMarker.md b/docs/framework/react/reference/variables/unsetMarker.md new file mode 100644 index 00000000000..d19ee65b38e --- /dev/null +++ b/docs/framework/react/reference/variables/unsetMarker.md @@ -0,0 +1,10 @@ +--- +id: unsetMarker +title: unsetMarker +--- + +```ts +const unsetMarker: typeof unsetMarker; +``` + +Defined in: [packages/query-core/src/types.ts:65](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L65) diff --git a/docs/framework/solid/reference/classes/CancelledError.md b/docs/framework/solid/reference/classes/CancelledError.md new file mode 100644 index 00000000000..7fded5da20f --- /dev/null +++ b/docs/framework/solid/reference/classes/CancelledError.md @@ -0,0 +1,273 @@ +--- +id: CancelledError +title: CancelledError +--- + +Defined in: [packages/query-core/src/retryer.ts:77](https://github.com/TanStack/query/blob/main/packages/query-core/src/retryer.ts#L77) + +The error thrown by a `Retryer` (and surfaced to `query.promise`/`mutation`) when a fetch is cancelled, e.g. via +`query.cancel()`. `revert`, if `true`, tells the caller to restore the state the query was in before the fetch +started instead of surfacing the error. `silent`, if `true`, tells the caller to suppress this error and instead +resolve with the promise of the fetch that triggered the cancellation. + +## Example + +```ts +query.cancel() + +try { + await query.promise +} catch (error) { + if (error instanceof CancelledError) { + // the fetch was cancelled, e.g. via `query.cancel()` + } +} +``` + +## Extends + +- `Error` + +## Constructors + +### Constructor + +```ts +new CancelledError(options?): CancelledError; +``` + +Defined in: [packages/query-core/src/retryer.ts:80](https://github.com/TanStack/query/blob/main/packages/query-core/src/retryer.ts#L80) + +#### Parameters + +##### options? + +[`CancelOptions`](../interfaces/CancelOptions.md) + +#### Returns + +`CancelledError` + +#### Overrides + +```ts +Error.constructor +``` + +## Properties + +### cause? + +```ts +optional cause: unknown; +``` + +Defined in: node\_modules/.pnpm/typescript@6.0.3/node\_modules/typescript/lib/lib.es2022.error.d.ts:24 + +#### Inherited from + +```ts +Error.cause +``` + +*** + +### message + +```ts +message: string; +``` + +Defined in: node\_modules/.pnpm/typescript@6.0.3/node\_modules/typescript/lib/lib.es5.d.ts:1075 + +#### Inherited from + +```ts +Error.message +``` + +*** + +### name + +```ts +name: string; +``` + +Defined in: node\_modules/.pnpm/typescript@6.0.3/node\_modules/typescript/lib/lib.es5.d.ts:1074 + +#### Inherited from + +```ts +Error.name +``` + +*** + +### revert? + +```ts +optional revert: boolean; +``` + +Defined in: [packages/query-core/src/retryer.ts:78](https://github.com/TanStack/query/blob/main/packages/query-core/src/retryer.ts#L78) + +*** + +### silent? + +```ts +optional silent: boolean; +``` + +Defined in: [packages/query-core/src/retryer.ts:79](https://github.com/TanStack/query/blob/main/packages/query-core/src/retryer.ts#L79) + +*** + +### stack? + +```ts +optional stack: string; +``` + +Defined in: node\_modules/.pnpm/typescript@6.0.3/node\_modules/typescript/lib/lib.es5.d.ts:1076 + +#### Inherited from + +```ts +Error.stack +``` + +*** + +### stackTraceLimit + +```ts +static stackTraceLimit: number; +``` + +Defined in: node\_modules/.pnpm/@types+node@22.19.15/node\_modules/@types/node/globals.d.ts:68 + +The `Error.stackTraceLimit` property specifies the number of stack frames +collected by a stack trace (whether generated by `new Error().stack` or +`Error.captureStackTrace(obj)`). + +The default value is `10` but may be set to any valid JavaScript number. Changes +will affect any stack trace captured _after_ the value has been changed. + +If set to a non-number value, or set to a negative number, stack traces will +not capture any frames. + +#### Inherited from + +```ts +Error.stackTraceLimit +``` + +## Methods + +### captureStackTrace() + +```ts +static captureStackTrace(targetObject, constructorOpt?): void; +``` + +Defined in: node\_modules/.pnpm/@types+node@22.19.15/node\_modules/@types/node/globals.d.ts:52 + +Creates a `.stack` property on `targetObject`, which when accessed returns +a string representing the location in the code at which +`Error.captureStackTrace()` was called. + +```js +const myObject = {}; +Error.captureStackTrace(myObject); +myObject.stack; // Similar to `new Error().stack` +``` + +The first line of the trace will be prefixed with +`${myObject.name}: ${myObject.message}`. + +The optional `constructorOpt` argument accepts a function. If given, all frames +above `constructorOpt`, including `constructorOpt`, will be omitted from the +generated stack trace. + +The `constructorOpt` argument is useful for hiding implementation +details of error generation from the user. For instance: + +```js +function a() { + b(); +} + +function b() { + c(); +} + +function c() { + // Create an error without stack trace to avoid calculating the stack trace twice. + const { stackTraceLimit } = Error; + Error.stackTraceLimit = 0; + const error = new Error(); + Error.stackTraceLimit = stackTraceLimit; + + // Capture the stack trace above function b + Error.captureStackTrace(error, b); // Neither function c, nor b is included in the stack trace + throw error; +} + +a(); +``` + +#### Parameters + +##### targetObject + +`object` + +##### constructorOpt? + +`Function` + +#### Returns + +`void` + +#### Inherited from + +```ts +Error.captureStackTrace +``` + +*** + +### prepareStackTrace() + +```ts +static prepareStackTrace(err, stackTraces): any; +``` + +Defined in: node\_modules/.pnpm/@types+node@22.19.15/node\_modules/@types/node/globals.d.ts:56 + +#### Parameters + +##### err + +`Error` + +##### stackTraces + +`CallSite`[] + +#### Returns + +`any` + +#### See + +https://v8.dev/docs/stack-trace-api#customizing-stack-traces + +#### Inherited from + +```ts +Error.prepareStackTrace +``` diff --git a/docs/framework/solid/reference/classes/InfiniteQueryObserver.md b/docs/framework/solid/reference/classes/InfiniteQueryObserver.md new file mode 100644 index 00000000000..ddcdefbc07f --- /dev/null +++ b/docs/framework/solid/reference/classes/InfiniteQueryObserver.md @@ -0,0 +1,665 @@ +--- +id: InfiniteQueryObserver +title: InfiniteQueryObserver +--- + +Defined in: [packages/query-core/src/infiniteQueryObserver.ts:41](https://github.com/TanStack/query/blob/main/packages/query-core/src/infiniteQueryObserver.ts#L41) + +An `InfiniteQueryObserver` extends `QueryObserver` to observe and switch +between infinite queries. It augments the base `QueryObserverResult` with +infinite-query-specific fields and methods, such as `hasNextPage` and +`fetchNextPage`, and is the primitive that framework adapters (e.g. +`useInfiniteQuery`) build their hooks on top of. + +## Example + +```ts +const observer = new InfiniteQueryObserver(queryClient, { + queryKey: ['projects'], + queryFn: ({ pageParam }) => fetchProjects(pageParam), + initialPageParam: 0, + getNextPageParam: (lastPage) => lastPage.nextCursor, +}) + +const unsubscribe = observer.subscribe((result) => console.log(result)) +``` + +## Extends + +- [`QueryObserver`](QueryObserver.md)\<`TQueryFnData`, `TError`, `TData`, [`InfiniteData`](../interfaces/InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\> + +## Type Parameters + +### TQueryFnData + +`TQueryFnData` = `unknown` + +### TError + +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) + +### TData + +`TData` = [`InfiniteData`](../interfaces/InfiniteData.md)\<`TQueryFnData`\> + +### TQueryKey + +`TQueryKey` *extends* [`QueryKey`](../type-aliases/QueryKey.md) = [`QueryKey`](../type-aliases/QueryKey.md) + +### TPageParam + +`TPageParam` = `unknown` + +## Constructors + +### Constructor + +```ts +new InfiniteQueryObserver(client, options): InfiniteQueryObserver; +``` + +Defined in: [packages/query-core/src/infiniteQueryObserver.ts:83](https://github.com/TanStack/query/blob/main/packages/query-core/src/infiniteQueryObserver.ts#L83) + +#### Parameters + +##### client + +`QueryClient` + +##### options + +`InfiniteQueryObserverOptions`\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`, `TPageParam`\> + +#### Returns + +`InfiniteQueryObserver`\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`, `TPageParam`\> + +#### Overrides + +[`QueryObserver`](QueryObserver.md).[`constructor`](QueryObserver.md#constructor) + +## Properties + +### fetch + +```ts +protected fetch: ReplaceReturnType<(fetchOptions) => Promise>, Promise>>; +``` + +Defined in: [packages/query-core/src/infiniteQueryObserver.ts:72](https://github.com/TanStack/query/blob/main/packages/query-core/src/infiniteQueryObserver.ts#L72) + +#### Overrides + +```ts +QueryObserver.fetch +``` + +*** + +### getCurrentResult + +```ts +getCurrentResult: ReplaceReturnType<() => QueryObserverResult, InfiniteQueryObserverResult>; +``` + +Defined in: [packages/query-core/src/infiniteQueryObserver.ts:60](https://github.com/TanStack/query/blob/main/packages/query-core/src/infiniteQueryObserver.ts#L60) + +Returns the most recently computed `QueryObserverResult` for the +observed query. This is a point-in-time read; to be notified of updates +as they happen, subscribe to the observer instead (its inherited +`subscribe` method). + +#### Example + +```ts +const result = observer.getCurrentResult() +console.log(result.status, result.data) +``` + +#### Overrides + +```ts +QueryObserver.getCurrentResult +``` + +*** + +### listeners + +```ts +protected listeners: Set>; +``` + +Defined in: [packages/query-core/src/subscribable.ts:2](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L2) + +#### Inherited from + +[`QueryObserver`](QueryObserver.md).[`listeners`](QueryObserver.md#listeners) + +*** + +### options + +```ts +options: QueryObserverOptions, TQueryKey>; +``` + +Defined in: [packages/query-core/src/queryObserver.ts:89](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L89) + +#### Inherited from + +[`QueryObserver`](QueryObserver.md).[`options`](QueryObserver.md#options) + +*** + +### subscribe() + +```ts +subscribe: (listener) => () => void; +``` + +Defined in: [packages/query-core/src/infiniteQueryObserver.ts:55](https://github.com/TanStack/query/blob/main/packages/query-core/src/infiniteQueryObserver.ts#L55) + +#### Parameters + +##### listener + +`InfiniteQueryObserverListener` + +#### Returns + +```ts +(): void; +``` + +##### Returns + +`void` + +#### Overrides + +```ts +QueryObserver.subscribe +``` + +## Methods + +### bindMethods() + +```ts +protected bindMethods(): void; +``` + +Defined in: [packages/query-core/src/infiniteQueryObserver.ts:96](https://github.com/TanStack/query/blob/main/packages/query-core/src/infiniteQueryObserver.ts#L96) + +#### Returns + +`void` + +#### Overrides + +[`QueryObserver`](QueryObserver.md).[`bindMethods`](QueryObserver.md#bindmethods) + +*** + +### createResult() + +```ts +protected createResult(query, options): InfiniteQueryObserverResult; +``` + +Defined in: [packages/query-core/src/infiniteQueryObserver.ts:201](https://github.com/TanStack/query/blob/main/packages/query-core/src/infiniteQueryObserver.ts#L201) + +#### Parameters + +##### query + +[`Query`](Query.md)\<`TQueryFnData`, `TError`, [`InfiniteData`](../interfaces/InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\> + +##### options + +`InfiniteQueryObserverOptions`\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`, `TPageParam`\> + +#### Returns + +[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\> + +#### Overrides + +[`QueryObserver`](QueryObserver.md).[`createResult`](QueryObserver.md#createresult) + +*** + +### destroy() + +```ts +destroy(): void; +``` + +Defined in: [packages/query-core/src/queryObserver.ts:161](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L161) + +Stops observing the current query: clears all listeners, cancels the +stale and refetch-interval timers, and removes this observer from the +query it was observing. + +#### Returns + +`void` + +#### Inherited from + +[`QueryObserver`](QueryObserver.md).[`destroy`](QueryObserver.md#destroy) + +*** + +### fetchNextPage() + +```ts +fetchNextPage(options?): Promise>; +``` + +Defined in: [packages/query-core/src/infiniteQueryObserver.ts:161](https://github.com/TanStack/query/blob/main/packages/query-core/src/infiniteQueryObserver.ts#L161) + +Fetches the next page of the infinite query and returns a promise that +resolves with the resulting `InfiniteQueryObserverResult`. The page +param used for the fetch is determined by `getNextPageParam`, which +receives the current pages/page params and whose result also determines +`hasNextPage`. + +#### Parameters + +##### options? + +[`FetchNextPageOptions`](../interfaces/FetchNextPageOptions.md) + +#### Returns + +`Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> + +#### Example + +```ts +const { hasNextPage } = observer.getCurrentResult() + +if (hasNextPage) { + await observer.fetchNextPage() +} +``` + +#### See + +[InfiniteQueryObserver#fetchPreviousPage](#fetchpreviouspage) + +*** + +### fetchOptimistic() + +```ts +fetchOptimistic(options): Promise>; +``` + +Defined in: [packages/query-core/src/queryObserver.ts:395](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L395) + +Fetches a query defined by the given options without affecting this +observer's own tracked query or result, and returns a promise that +resolves with the `QueryObserverResult` for that fetch. This is useful +for prefetching data that another observer (e.g. a query about to be +navigated to) will need, ahead of time. + +#### Parameters + +##### options + +`QueryObserverOptions`\<`TQueryFnData`, `TError`, `TData`, [`InfiniteData`](../interfaces/InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\> + +#### Returns + +`Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> + +#### Example + +```ts +const result = await observer.fetchOptimistic({ + queryKey: ['posts', 2], + queryFn: () => fetchPost(2), +}) +console.log(result.data) +``` + +#### Inherited from + +[`QueryObserver`](QueryObserver.md).[`fetchOptimistic`](QueryObserver.md#fetchoptimistic) + +*** + +### fetchPreviousPage() + +```ts +fetchPreviousPage(options?): Promise>; +``` + +Defined in: [packages/query-core/src/infiniteQueryObserver.ts:190](https://github.com/TanStack/query/blob/main/packages/query-core/src/infiniteQueryObserver.ts#L190) + +Fetches the previous page of the infinite query and returns a promise +that resolves with the resulting `InfiniteQueryObserverResult`. The page +param used for the fetch is determined by `getPreviousPageParam`, which +receives the current pages/page params and whose result also determines +`hasPreviousPage`. + +#### Parameters + +##### options? + +[`FetchPreviousPageOptions`](../interfaces/FetchPreviousPageOptions.md) + +#### Returns + +`Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> + +#### Example + +```ts +const { hasPreviousPage } = observer.getCurrentResult() + +if (hasPreviousPage) { + await observer.fetchPreviousPage() +} +``` + +#### See + +[InfiniteQueryObserver#fetchNextPage](#fetchnextpage) + +*** + +### getCurrentQuery() + +```ts +getCurrentQuery(): Query, TQueryKey>; +``` + +Defined in: [packages/query-core/src/queryObserver.ts:357](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L357) + +Returns the `Query` instance this observer is currently observing. + +#### Returns + +[`Query`](Query.md)\<`TQueryFnData`, `TError`, [`InfiniteData`](../interfaces/InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\> + +#### Inherited from + +[`QueryObserver`](QueryObserver.md).[`getCurrentQuery`](QueryObserver.md#getcurrentquery) + +*** + +### getOptimisticResult() + +```ts +getOptimisticResult(options): InfiniteQueryObserverResult; +``` + +Defined in: [packages/query-core/src/infiniteQueryObserver.ts:127](https://github.com/TanStack/query/blob/main/packages/query-core/src/infiniteQueryObserver.ts#L127) + +The infinite-query counterpart of [QueryObserver#getOptimisticResult](QueryObserver.md#getoptimisticresult), marking the +options as an infinite query before delegating to it. Called by framework adapters (e.g. +`useInfiniteQuery`) ahead of subscribing, to compute the current `InfiniteQueryObserverResult` +synchronously. + +#### Parameters + +##### options + +[`DefaultedInfiniteQueryObserverOptions`](../type-aliases/DefaultedInfiniteQueryObserverOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`, `TPageParam`\> + +#### Returns + +[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\> + +#### Overrides + +[`QueryObserver`](QueryObserver.md).[`getOptimisticResult`](QueryObserver.md#getoptimisticresult) + +*** + +### hasListeners() + +```ts +hasListeners(): boolean; +``` + +Defined in: [packages/query-core/src/subscribable.ts:19](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L19) + +#### Returns + +`boolean` + +#### Inherited from + +[`QueryObserver`](QueryObserver.md).[`hasListeners`](QueryObserver.md#haslisteners) + +*** + +### onSubscribe() + +```ts +protected onSubscribe(): void; +``` + +Defined in: [packages/query-core/src/queryObserver.ts:110](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L110) + +#### Returns + +`void` + +#### Inherited from + +[`QueryObserver`](QueryObserver.md).[`onSubscribe`](QueryObserver.md#onsubscribe) + +*** + +### onUnsubscribe() + +```ts +protected onUnsubscribe(): void; +``` + +Defined in: [packages/query-core/src/queryObserver.ts:124](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L124) + +#### Returns + +`void` + +#### Inherited from + +[`QueryObserver`](QueryObserver.md).[`onUnsubscribe`](QueryObserver.md#onunsubscribe) + +*** + +### refetch() + +```ts +refetch(__namedParameters): Promise>; +``` + +Defined in: [packages/query-core/src/queryObserver.ts:371](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L371) + +Refetches the observed query and returns a promise that resolves with +the resulting `QueryObserverResult`. + +#### Parameters + +##### \_\_namedParameters + +[`RefetchOptions`](../interfaces/RefetchOptions.md) = `{}` + +#### Returns + +`Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> + +#### Example + +```ts +const result = await observer.refetch({ cancelRefetch: false }) +console.log(result.data) +``` + +#### Inherited from + +[`QueryObserver`](QueryObserver.md).[`refetch`](QueryObserver.md#refetch) + +*** + +### setOptions() + +```ts +setOptions(options): void; +``` + +Defined in: [packages/query-core/src/infiniteQueryObserver.ts:108](https://github.com/TanStack/query/blob/main/packages/query-core/src/infiniteQueryObserver.ts#L108) + +Updates the observer's options. Behaves the same as +`QueryObserver.setOptions`, additionally marking the options as +belonging to an infinite query before delegating to the base +implementation. + +#### Parameters + +##### options + +`InfiniteQueryObserverOptions`\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`, `TPageParam`\> + +#### Returns + +`void` + +#### Overrides + +[`QueryObserver`](QueryObserver.md).[`setOptions`](QueryObserver.md#setoptions) + +*** + +### shouldFetchOnReconnect() + +```ts +shouldFetchOnReconnect(): boolean; +``` + +Defined in: [packages/query-core/src/queryObserver.ts:135](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L135) + +Returns whether the observed query is currently stale and configured +(via the `refetchOnReconnect` option) to refetch when the network +reconnects. + +#### Returns + +`boolean` + +#### Inherited from + +[`QueryObserver`](QueryObserver.md).[`shouldFetchOnReconnect`](QueryObserver.md#shouldfetchonreconnect) + +*** + +### shouldFetchOnWindowFocus() + +```ts +shouldFetchOnWindowFocus(): boolean; +``` + +Defined in: [packages/query-core/src/queryObserver.ts:148](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L148) + +Returns whether the observed query is currently stale and configured +(via the `refetchOnWindowFocus` option) to refetch when the window +regains focus. + +#### Returns + +`boolean` + +#### Inherited from + +[`QueryObserver`](QueryObserver.md).[`shouldFetchOnWindowFocus`](QueryObserver.md#shouldfetchonwindowfocus) + +*** + +### trackProp() + +```ts +trackProp(key): void; +``` + +Defined in: [packages/query-core/src/queryObserver.ts:350](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L350) + +Records that the given `QueryObserverResult` property was read, so a subsequent update only +notifies this observer if a tracked property actually changed. Normally called indirectly via +[QueryObserver#trackResult](QueryObserver.md#trackresult)'s proxy; exposed directly for adapters that track property +access themselves (e.g. through their own reactivity system) instead of via the proxy. + +#### Parameters + +##### key + +`"error"` | `"data"` | `"isError"` | `"isPending"` | `"isLoading"` | `"isLoadingError"` | `"isRefetchError"` | `"isSuccess"` | `"isPlaceholderData"` | `"status"` | `"dataUpdatedAt"` | `"errorUpdatedAt"` | `"failureCount"` | `"failureReason"` | `"errorUpdateCount"` | `"isFetched"` | `"isFetchedAfterMount"` | `"isFetching"` | `"isInitialLoading"` | `"isPaused"` | `"isRefetching"` | `"isStale"` | `"isEnabled"` | `"refetch"` | `"fetchStatus"` + +#### Returns + +`void` + +#### Inherited from + +[`QueryObserver`](QueryObserver.md).[`trackProp`](QueryObserver.md#trackprop) + +*** + +### trackResult() + +```ts +trackResult(result, onPropTracked?): QueryObserverResult; +``` + +Defined in: [packages/query-core/src/queryObserver.ts:331](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L331) + +Wraps a `QueryObserverResult` in a `Proxy` that records which properties are read, via +[QueryObserver#trackProp](QueryObserver.md#trackprop) (and an optional `onPropTracked` callback). Used by framework +adapters when `notifyOnChangeProps` is not set, to implement its default "only re-render on +properties you actually read" behavior. + +#### Parameters + +##### result + +[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\> + +##### onPropTracked? + +(`key`) => `void` + +#### Returns + +[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\> + +#### Inherited from + +[`QueryObserver`](QueryObserver.md).[`trackResult`](QueryObserver.md#trackresult) + +*** + +### updateResult() + +```ts +updateResult(): void; +``` + +Defined in: [packages/query-core/src/queryObserver.ts:735](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L735) + +Recomputes and stores the current result from the current query/options, notifying listeners +if it changed. Framework adapters call this right after subscribing to make sure no query +update was missed in the gap between creating the observer and subscribing to it. + +#### Returns + +`void` + +#### Inherited from + +[`QueryObserver`](QueryObserver.md).[`updateResult`](QueryObserver.md#updateresult) diff --git a/docs/framework/solid/reference/classes/Mutation.md b/docs/framework/solid/reference/classes/Mutation.md new file mode 100644 index 00000000000..e038a9cd394 --- /dev/null +++ b/docs/framework/solid/reference/classes/Mutation.md @@ -0,0 +1,330 @@ +--- +id: Mutation +title: Mutation +--- + +Defined in: [packages/query-core/src/mutation.ts:135](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L135) + +Represents a single mutation attempt. A `Mutation` holds the mutation's +options, state (data/error/status), and the `MutationObserver`s currently +subscribed to it. + +Instances are created and managed internally by `MutationCache`; application +code typically interacts with mutations indirectly through `QueryClient` or +a framework hook like `useMutation`. Direct access to a `Mutation` instance +is possible via `mutationCache.find()`/`getAll()` for inspecting cache state. + +## Example + +```ts +const mutationCache = queryClient.getMutationCache() + +const mutation = mutationCache.find({ mutationKey: ['addPost'] }) +``` + +## Extends + +- `Removable` + +## Type Parameters + +### TData + +`TData` = `unknown` + +### TError + +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) + +### TVariables + +`TVariables` = `unknown` + +### TOnMutateResult + +`TOnMutateResult` = `unknown` + +## Constructors + +### Constructor + +```ts +new Mutation(config): Mutation; +``` + +Defined in: [packages/query-core/src/mutation.ts:152](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L152) + +#### Parameters + +##### config + +`MutationConfig`\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\> + +#### Returns + +`Mutation`\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\> + +#### Overrides + +```ts +Removable.constructor +``` + +## Properties + +### gcTime + +```ts +gcTime: number; +``` + +Defined in: [packages/query-core/src/removable.ts:7](https://github.com/TanStack/query/blob/main/packages/query-core/src/removable.ts#L7) + +#### Inherited from + +```ts +Removable.gcTime +``` + +*** + +### mutationId + +```ts +readonly mutationId: number; +``` + +Defined in: [packages/query-core/src/mutation.ts:143](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L143) + +*** + +### options + +```ts +options: MutationOptions; +``` + +Defined in: [packages/query-core/src/mutation.ts:142](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L142) + +*** + +### state + +```ts +state: MutationState; +``` + +Defined in: [packages/query-core/src/mutation.ts:141](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L141) + +## Accessors + +### meta + +#### Get Signature + +```ts +get meta(): Record | undefined; +``` + +Defined in: [packages/query-core/src/mutation.ts:179](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L179) + +The `meta` object passed in the mutation's options, if any. + +##### Returns + +`Record`\<`string`, `unknown`\> \| `undefined` + +## Methods + +### clearGcTimeout() + +```ts +protected clearGcTimeout(): void; +``` + +Defined in: [packages/query-core/src/removable.ts:32](https://github.com/TanStack/query/blob/main/packages/query-core/src/removable.ts#L32) + +#### Returns + +`void` + +#### Inherited from + +```ts +Removable.clearGcTimeout +``` + +*** + +### continue() + +```ts +continue(): Promise; +``` + +Defined in: [packages/query-core/src/mutation.ts:243](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L243) + +Resumes a mutation that is currently paused or was restored from a +dehydrated, still-`pending` state. + +- If this mutation has an active retryer (it paused mid-attempt, e.g. due + to the network mode or scope-based queuing), its retryer is resumed. +- Otherwise, if the mutation's status is still `pending` (e.g. it was + dehydrated while an attempt was in flight and never got a retryer in + this instance), `execute` is called again with the last known variables. +- Otherwise the mutation has already settled and this resolves immediately + without running anything again. + +#### Returns + +`Promise`\<`unknown`\> + +#### Example + +```ts +// typically driven by reconnect handling, e.g. queryClient.resumePausedMutations() +const mutation = mutationCache.find({ mutationKey: ['addPost'] }) +await mutation?.continue() +``` + +#### See + +[Mutation#execute](#execute) + +*** + +### destroy() + +```ts +destroy(): void; +``` + +Defined in: [packages/query-core/src/removable.ts:10](https://github.com/TanStack/query/blob/main/packages/query-core/src/removable.ts#L10) + +#### Returns + +`void` + +#### Inherited from + +```ts +Removable.destroy +``` + +*** + +### execute() + +```ts +execute(variables): Promise; +``` + +Defined in: [packages/query-core/src/mutation.ts:284](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L284) + +Runs the mutation function for the given variables through a retryer, and +drives the mutation's state and lifecycle callbacks through to settlement. + +If this mutation's state is already `pending` when `execute` is called +(i.e. it was restored, still in-flight, from a dehydrated state), the +`onMutate` step is skipped and a `continue` action is dispatched to +unpause it; otherwise a `pending` action is dispatched first, then the +mutation cache's `onMutate` and the mutation's own `onMutate` option are +awaited in that order, and the resulting context is stored. + +The mutation function is then run (subject to `retry`/`retryDelay`/ +`networkMode`, and to the mutation cache's scope-based serialization). +On success, the cache's `onSuccess`/`onSettled` callbacks run before the +mutation's own `onSuccess`/`onSettled` options, a `success` action is +dispatched, and the resolved data is returned. On failure, the same +cache-then-option ordering is used for `onError`/`onSettled`, but each of +those four callbacks is individually caught so that a throwing callback +cannot mask the original error; an `error` action is then dispatched and +the original error is re-thrown. + +#### Parameters + +##### variables + +`TVariables` + +#### Returns + +`Promise`\<`TData`\> + +#### Example + +```ts +// Called internally by `MutationObserver.mutate` and `Mutation.continue` — +// applications normally trigger mutations through those, not this method. +const data = await mutation.execute(variables) +``` + +#### See + +[Mutation#continue](#continue) + +*** + +### optionalRemove() + +```ts +protected optionalRemove(): void; +``` + +Defined in: [packages/query-core/src/mutation.ts:212](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L212) + +#### Returns + +`void` + +#### Overrides + +```ts +Removable.optionalRemove +``` + +*** + +### scheduleGc() + +```ts +protected scheduleGc(): void; +``` + +Defined in: [packages/query-core/src/removable.ts:14](https://github.com/TanStack/query/blob/main/packages/query-core/src/removable.ts#L14) + +#### Returns + +`void` + +#### Inherited from + +```ts +Removable.scheduleGc +``` + +*** + +### updateGcTime() + +```ts +protected updateGcTime(newGcTime): void; +``` + +Defined in: [packages/query-core/src/removable.ts:24](https://github.com/TanStack/query/blob/main/packages/query-core/src/removable.ts#L24) + +#### Parameters + +##### newGcTime + +`number` | `undefined` + +#### Returns + +`void` + +#### Inherited from + +```ts +Removable.updateGcTime +``` diff --git a/docs/framework/solid/reference/classes/MutationCache.md b/docs/framework/solid/reference/classes/MutationCache.md new file mode 100644 index 00000000000..5a172b4cb9b --- /dev/null +++ b/docs/framework/solid/reference/classes/MutationCache.md @@ -0,0 +1,316 @@ +--- +id: MutationCache +title: MutationCache +--- + +Defined in: [packages/query-core/src/mutationCache.ts:124](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationCache.ts#L124) + +The `MutationCache` is the storage for mutations. + +Normally, you will not interact with the `MutationCache` directly and instead use a +`QueryClient`. You can subscribe to it (inherited from `Subscribable`) to be informed of +safe/known updates to the cache, such as mutations being added, removed, or updated. + +## Example + +```ts +const unsubscribe = mutationCache.subscribe((event) => { + console.log(event.type, event.mutation) +}) +``` + +## Extends + +- `Subscribable`\<`MutationCacheListener`\> + +## Constructors + +### Constructor + +```ts +new MutationCache(config): MutationCache; +``` + +Defined in: [packages/query-core/src/mutationCache.ts:129](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationCache.ts#L129) + +#### Parameters + +##### config + +[`MutationCacheConfig`](../interfaces/MutationCacheConfig.md) = `{}` + +#### Returns + +`MutationCache` + +#### Overrides + +```ts +Subscribable.constructor +``` + +## Properties + +### config + +```ts +config: MutationCacheConfig = {}; +``` + +Defined in: [packages/query-core/src/mutationCache.ts:129](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationCache.ts#L129) + +*** + +### listeners + +```ts +protected listeners: Set; +``` + +Defined in: [packages/query-core/src/subscribable.ts:2](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L2) + +#### Inherited from + +```ts +Subscribable.listeners +``` + +## Methods + +### clear() + +```ts +clear(): void; +``` + +Defined in: [packages/query-core/src/mutationCache.ts:236](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationCache.ts#L236) + +Removes all mutations from the cache. + +#### Returns + +`void` + +#### Example + +```ts +const mutationCache = queryClient.getMutationCache() + +mutationCache.clear() +``` + +*** + +### find() + +```ts +find(filters): + | Mutation + | undefined; +``` + +Defined in: [packages/query-core/src/mutationCache.ts:278](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationCache.ts#L278) + +A slightly more advanced method that can be used to get an existing mutation instance from +the cache. If the mutation does not exist, `undefined` is returned. + +This is not typically needed for most applications, but can come in handy when needing more +information about a mutation in rare scenarios. + +#### Type Parameters + +##### TData + +`TData` = `unknown` + +##### TError + +`TError` = `Error` + +##### TVariables + +`TVariables` = `any` + +##### TOnMutateResult + +`TOnMutateResult` = `unknown` + +#### Parameters + +##### filters + +[`MutationFilters`](../interfaces/MutationFilters.md) + +#### Returns + + \| [`Mutation`](Mutation.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\> + \| `undefined` + +#### See + +[MutationCache#findAll](#findall) + +#### Example + +```ts +const mutationCache = queryClient.getMutationCache() + +const mutation = mutationCache.find({ mutationKey: ['addPost'] }) +``` + +*** + +### findAll() + +```ts +findAll(filters): Mutation[]; +``` + +Defined in: [packages/query-core/src/mutationCache.ts:308](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationCache.ts#L308) + +An even more advanced method that can be used to get existing mutation instances from the +cache that match the given filters. If no mutations match, an empty array is returned. + +This is not typically needed for most applications, but can come in handy when needing more +information about mutations in rare scenarios. + +#### Parameters + +##### filters + +[`MutationFilters`](../interfaces/MutationFilters.md) = `{}` + +#### Returns + +[`Mutation`](Mutation.md)\<`unknown`, `Error`, `unknown`, `unknown`\>[] + +#### See + +[MutationCache#find](#find) + +#### Example + +```ts +const mutationCache = queryClient.getMutationCache() + +const mutations = mutationCache.findAll({ mutationKey: ['addPost'] }) +``` + +*** + +### getAll() + +```ts +getAll(): Mutation[]; +``` + +Defined in: [packages/query-core/src/mutationCache.ts:259](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationCache.ts#L259) + +Returns all mutations within the cache. + +This is not typically needed for most applications, but can come in handy when needing more +information about a mutation in rare scenarios. + +#### Returns + +[`Mutation`](Mutation.md)\<`unknown`, `Error`, `unknown`, `unknown`\>[] + +#### Example + +```ts +const mutationCache = queryClient.getMutationCache() + +const mutations = mutationCache.getAll() +``` + +*** + +### hasListeners() + +```ts +hasListeners(): boolean; +``` + +Defined in: [packages/query-core/src/subscribable.ts:19](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L19) + +#### Returns + +`boolean` + +#### Inherited from + +```ts +Subscribable.hasListeners +``` + +*** + +### onSubscribe() + +```ts +protected onSubscribe(): void; +``` + +Defined in: [packages/query-core/src/subscribable.ts:23](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L23) + +#### Returns + +`void` + +#### Inherited from + +```ts +Subscribable.onSubscribe +``` + +*** + +### onUnsubscribe() + +```ts +protected onUnsubscribe(): void; +``` + +Defined in: [packages/query-core/src/subscribable.ts:27](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L27) + +#### Returns + +`void` + +#### Inherited from + +```ts +Subscribable.onUnsubscribe +``` + +*** + +### subscribe() + +```ts +subscribe(listener): () => void; +``` + +Defined in: [packages/query-core/src/subscribable.ts:8](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L8) + +#### Parameters + +##### listener + +`MutationCacheListener` + +#### Returns + +```ts +(): void; +``` + +##### Returns + +`void` + +#### Inherited from + +```ts +Subscribable.subscribe +``` diff --git a/docs/framework/solid/reference/classes/MutationObserver.md b/docs/framework/solid/reference/classes/MutationObserver.md new file mode 100644 index 00000000000..b6c88ef3463 --- /dev/null +++ b/docs/framework/solid/reference/classes/MutationObserver.md @@ -0,0 +1,335 @@ +--- +id: MutationObserver +title: MutationObserver +--- + +Defined in: [packages/query-core/src/mutationObserver.ts:38](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationObserver.ts#L38) + +Observes a single mutation and derives a `MutationObserverResult` from it. +A framework hook like `useMutation` creates one `MutationObserver` per hook +call, keeps it stable across re-renders, calls `setOptions` when the options +passed to the hook change, subscribes to it to re-render on updates, and +reads `getCurrentResult()` for the value to return. Calling `mutate()` +builds a new underlying `Mutation` in the `MutationCache` and executes it. + +## Example + +```ts +const observer = new MutationObserver(queryClient, { + mutationFn: (variables: { title: string }) => addPost(variables), +}) +``` + +## Extends + +- `Subscribable`\<`MutationObserverListener`\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\>\> + +## Type Parameters + +### TData + +`TData` = `unknown` + +### TError + +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) + +### TVariables + +`TVariables` = `void` + +### TOnMutateResult + +`TOnMutateResult` = `unknown` + +## Constructors + +### Constructor + +```ts +new MutationObserver(client, options): MutationObserver; +``` + +Defined in: [packages/query-core/src/mutationObserver.ts:58](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationObserver.ts#L58) + +#### Parameters + +##### client + +`QueryClient` + +##### options + +[`MutationObserverOptions`](../interfaces/MutationObserverOptions.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\> + +#### Returns + +`MutationObserver`\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\> + +#### Overrides + +```ts +Subscribable< + MutationObserverListener +>.constructor +``` + +## Properties + +### listeners + +```ts +protected listeners: Set>; +``` + +Defined in: [packages/query-core/src/subscribable.ts:2](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L2) + +#### Inherited from + +```ts +Subscribable.listeners +``` + +*** + +### options + +```ts +options: MutationObserverOptions; +``` + +Defined in: [packages/query-core/src/mutationObserver.ts:46](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationObserver.ts#L46) + +## Methods + +### bindMethods() + +```ts +protected bindMethods(): void; +``` + +Defined in: [packages/query-core/src/mutationObserver.ts:75](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationObserver.ts#L75) + +#### Returns + +`void` + +*** + +### getCurrentResult() + +```ts +getCurrentResult(): MutationObserverResult; +``` + +Defined in: [packages/query-core/src/mutationObserver.ts:155](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationObserver.ts#L155) + +Returns the observer's current result, derived from the observed +mutation's state (or the default, `idle` state if no mutation has been +built yet, e.g. before the first `mutate()` call or after `reset()`). + +#### Returns + +[`MutationObserverResult`](../type-aliases/MutationObserverResult.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\> + +*** + +### hasListeners() + +```ts +hasListeners(): boolean; +``` + +Defined in: [packages/query-core/src/subscribable.ts:19](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L19) + +#### Returns + +`boolean` + +#### Inherited from + +```ts +Subscribable.hasListeners +``` + +*** + +### mutate() + +```ts +mutate(variables, options?): Promise; +``` + +Defined in: [packages/query-core/src/mutationObserver.ts:207](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationObserver.ts#L207) + +Builds a new `Mutation` in the `MutationCache` using the observer's +current options, detaches this observer from any previously observed +mutation, attaches it to the new one, and executes it with the given +variables. + +The optional per-call `options` (`onSuccess`/`onError`/`onSettled`) are +invoked once the mutation settles, in addition to any callbacks defined +on the observer's own options. + +#### Parameters + +##### variables + +`TVariables` + +##### options? + +[`MutateOptions`](../interfaces/MutateOptions.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\> + +#### Returns + +`Promise`\<`TData`\> + +#### Example + +```ts +await observer.mutate( + { title: 'New post' }, + { onSuccess: (data) => console.log(data) }, +) +``` + +*** + +### onSubscribe() + +```ts +protected onSubscribe(): void; +``` + +Defined in: [packages/query-core/src/mutationObserver.ts:127](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationObserver.ts#L127) + +#### Returns + +`void` + +#### Overrides + +```ts +Subscribable.onSubscribe +``` + +*** + +### onUnsubscribe() + +```ts +protected onUnsubscribe(): void; +``` + +Defined in: [packages/query-core/src/mutationObserver.ts:135](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationObserver.ts#L135) + +#### Returns + +`void` + +#### Overrides + +```ts +Subscribable.onUnsubscribe +``` + +*** + +### reset() + +```ts +reset(): void; +``` + +Defined in: [packages/query-core/src/mutationObserver.ts:180](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationObserver.ts#L180) + +Detaches the observer from the mutation it is currently observing (if +any) and resets the observed result back to its default, `idle` state. + +This does not cancel an in-flight mutation; the mutation itself keeps +running to completion and its own callbacks still fire, but this +observer stops reflecting its state and a subsequent `mutate()` call +will build a brand new mutation. + +#### Returns + +`void` + +#### Example + +```ts +observer.reset() +``` + +#### See + +[MutationObserver#mutate](#mutate) + +*** + +### setOptions() + +```ts +setOptions(options): void; +``` + +Defined in: [packages/query-core/src/mutationObserver.ts:96](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationObserver.ts#L96) + +Updates the observer's options. + +If the new `mutationKey` differs from the previous one (and both were +defined), the observer is reset, detaching it from the mutation it was +observing. Otherwise, if the currently observed mutation is still +`pending`, its options are updated in place as well. + +#### Parameters + +##### options + +[`MutationObserverOptions`](../interfaces/MutationObserverOptions.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\> + +#### Returns + +`void` + +#### Example + +```ts +observer.setOptions({ + mutationFn: (variables: { title: string }) => addPost(variables), + onSuccess: (data) => console.log(data), +}) +``` + +*** + +### subscribe() + +```ts +subscribe(listener): () => void; +``` + +Defined in: [packages/query-core/src/subscribable.ts:8](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L8) + +#### Parameters + +##### listener + +`MutationObserverListener` + +#### Returns + +```ts +(): void; +``` + +##### Returns + +`void` + +#### Inherited from + +```ts +Subscribable.subscribe +``` diff --git a/docs/framework/solid/reference/classes/QueriesObserver.md b/docs/framework/solid/reference/classes/QueriesObserver.md new file mode 100644 index 00000000000..7f0839a42fb --- /dev/null +++ b/docs/framework/solid/reference/classes/QueriesObserver.md @@ -0,0 +1,325 @@ +--- +id: QueriesObserver +title: QueriesObserver +--- + +Defined in: [packages/query-core/src/queriesObserver.ts:56](https://github.com/TanStack/query/blob/main/packages/query-core/src/queriesObserver.ts#L56) + +A `QueriesObserver` watches an array of queries at once, exposing them as +a single array of `QueryObserverResult`s (or, when a `combine` option is +given, as a combined value derived from that array). It manages one +internal `QueryObserver` per query, and is the primitive that framework +adapters (e.g. `useQueries`) build their hooks on top of. + +## Example + +```ts +const observer = new QueriesObserver(queryClient, [ + { queryKey: ['post', 1], queryFn: fetchPost }, + { queryKey: ['post', 2], queryFn: fetchPost }, +]) + +const unsubscribe = observer.subscribe((result) => { + console.log(result) +}) +``` + +## Extends + +- `Subscribable`\<`QueriesObserverListener`\> + +## Type Parameters + +### TCombinedResult + +`TCombinedResult` = [`QueryObserverResult`](../type-aliases/QueryObserverResult.md)[] + +## Constructors + +### Constructor + +```ts +new QueriesObserver( + client, + queries, +options?): QueriesObserver; +``` + +Defined in: [packages/query-core/src/queriesObserver.ts:70](https://github.com/TanStack/query/blob/main/packages/query-core/src/queriesObserver.ts#L70) + +#### Parameters + +##### client + +`QueryClient` + +##### queries + +`QueryObserverOptions`\<`any`, `any`, `any`, `any`, `any`, `never`\>[] + +##### options? + +[`QueriesObserverOptions`](../interfaces/QueriesObserverOptions.md)\<`TCombinedResult`\> + +#### Returns + +`QueriesObserver`\<`TCombinedResult`\> + +#### Overrides + +```ts +Subscribable.constructor +``` + +## Properties + +### listeners + +```ts +protected listeners: Set; +``` + +Defined in: [packages/query-core/src/subscribable.ts:2](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L2) + +#### Inherited from + +```ts +Subscribable.listeners +``` + +## Methods + +### destroy() + +```ts +destroy(): void; +``` + +Defined in: [packages/query-core/src/queriesObserver.ts:106](https://github.com/TanStack/query/blob/main/packages/query-core/src/queriesObserver.ts#L106) + +Stops observing all queries: clears all listeners and destroys every +underlying `QueryObserver` this observer manages. + +#### Returns + +`void` + +*** + +### getCurrentResult() + +```ts +getCurrentResult(): QueryObserverResult[]; +``` + +Defined in: [packages/query-core/src/queriesObserver.ts:210](https://github.com/TanStack/query/blob/main/packages/query-core/src/queriesObserver.ts#L210) + +Returns the most recently computed array of `QueryObserverResult`s, one +per observed query, in the same order as the queries passed to the +constructor or `setQueries`. + +#### Returns + +[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)[] + +#### Example + +```ts +const results = observer.getCurrentResult() +const data = results.map((result) => result.data) +``` + +*** + +### getObservers() + +```ts +getObservers(): QueryObserver[]; +``` + +Defined in: [packages/query-core/src/queriesObserver.ts:227](https://github.com/TanStack/query/blob/main/packages/query-core/src/queriesObserver.ts#L227) + +Returns the underlying `QueryObserver` instances this observer manages, +in the same order as the queries passed to the constructor or +`setQueries`. + +#### Returns + +[`QueryObserver`](QueryObserver.md)\<`unknown`, `Error`, `unknown`, `unknown`, readonly `unknown`[]\>[] + +*** + +### getOptimisticResult() + +```ts +getOptimisticResult(queries, combine): [QueryObserverResult[], (r?) => TCombinedResult, () => QueryObserverResult[]]; +``` + +Defined in: [packages/query-core/src/queriesObserver.ts:238](https://github.com/TanStack/query/blob/main/packages/query-core/src/queriesObserver.ts#L238) + +The `QueriesObserver` counterpart of [QueryObserver#getOptimisticResult](QueryObserver.md#getoptimisticresult) — computes +the result for the given (already-defaulted) queries right now, synchronously. Called by +framework adapters (e.g. `useQueries`) ahead of subscribing, returning a tuple of the raw +per-query results, a function to compute the combined result from them, and a function to +wrap the results for property-access tracking. + +#### Parameters + +##### queries + +`QueryObserverOptions`\<`unknown`, `Error`, `unknown`, `unknown`, readonly `unknown`[], `never`\>[] + +##### combine + +`CombineFn`\<`TCombinedResult`\> | `undefined` + +#### Returns + +\[[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)[], (`r?`) => `TCombinedResult`, () => [`QueryObserverResult`](../type-aliases/QueryObserverResult.md)[]\] + +*** + +### getQueries() + +```ts +getQueries(): Query[]; +``` + +Defined in: [packages/query-core/src/queriesObserver.ts:218](https://github.com/TanStack/query/blob/main/packages/query-core/src/queriesObserver.ts#L218) + +Returns the underlying `Query` instances currently being observed, in +the same order as the queries passed to the constructor or `setQueries`. + +#### Returns + +[`Query`](Query.md)\<`unknown`, `Error`, `unknown`, readonly `unknown`[]\>[] + +*** + +### hasListeners() + +```ts +hasListeners(): boolean; +``` + +Defined in: [packages/query-core/src/subscribable.ts:19](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L19) + +#### Returns + +`boolean` + +#### Inherited from + +```ts +Subscribable.hasListeners +``` + +*** + +### onSubscribe() + +```ts +protected onSubscribe(): void; +``` + +Defined in: [packages/query-core/src/queriesObserver.ts:86](https://github.com/TanStack/query/blob/main/packages/query-core/src/queriesObserver.ts#L86) + +#### Returns + +`void` + +#### Overrides + +```ts +Subscribable.onSubscribe +``` + +*** + +### onUnsubscribe() + +```ts +protected onUnsubscribe(): void; +``` + +Defined in: [packages/query-core/src/queriesObserver.ts:96](https://github.com/TanStack/query/blob/main/packages/query-core/src/queriesObserver.ts#L96) + +#### Returns + +`void` + +#### Overrides + +```ts +Subscribable.onUnsubscribe +``` + +*** + +### setQueries() + +```ts +setQueries(queries, options?): void; +``` + +Defined in: [packages/query-core/src/queriesObserver.ts:127](https://github.com/TanStack/query/blob/main/packages/query-core/src/queriesObserver.ts#L127) + +Replaces the set of queries being observed. Existing `QueryObserver`s +are reused for queries that match an already-observed query hash; +observers for queries that are no longer present are destroyed, and new +observers are created and subscribed to for newly added queries. + +#### Parameters + +##### queries + +`QueryObserverOptions`\<`unknown`, `Error`, `unknown`, `unknown`, readonly `unknown`[], `never`\>[] + +##### options? + +[`QueriesObserverOptions`](../interfaces/QueriesObserverOptions.md)\<`TCombinedResult`\> + +#### Returns + +`void` + +#### Example + +```ts +observer.setQueries([ + { queryKey: ['post', 1], queryFn: fetchPost }, + { queryKey: ['post', 3], queryFn: fetchPost }, +]) +``` + +*** + +### subscribe() + +```ts +subscribe(listener): () => void; +``` + +Defined in: [packages/query-core/src/subscribable.ts:8](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L8) + +#### Parameters + +##### listener + +`QueriesObserverListener` + +#### Returns + +```ts +(): void; +``` + +##### Returns + +`void` + +#### Inherited from + +```ts +Subscribable.subscribe +``` diff --git a/docs/framework/solid/reference/classes/Query.md b/docs/framework/solid/reference/classes/Query.md new file mode 100644 index 00000000000..273d24bdbe8 --- /dev/null +++ b/docs/framework/solid/reference/classes/Query.md @@ -0,0 +1,585 @@ +--- +id: Query +title: Query +--- + +Defined in: [packages/query-core/src/query.ts:225](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L225) + +Represents a single cached query. A `Query` holds the query's key, options, +state (data/error/status), and the observers currently subscribed to it. + +Instances are created and managed internally by `QueryCache`; application +code typically interacts with queries indirectly through `QueryClient` or +a framework hook like `useQuery`. Direct access to a `Query` instance is +possible via `queryCache.find()`/`findAll()` for inspecting cache state. + +## Example + +```ts +const queryCache = queryClient.getQueryCache() +const query = queryCache.find({ queryKey: ['posts'] }) + +if (query) { + console.log(query.state.dataUpdatedAt) +} +``` + +## Extends + +- `Removable` + +## Type Parameters + +### TQueryFnData + +`TQueryFnData` = `unknown` + +### TError + +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) + +### TData + +`TData` = `TQueryFnData` + +### TQueryKey + +`TQueryKey` *extends* [`QueryKey`](../type-aliases/QueryKey.md) = [`QueryKey`](../type-aliases/QueryKey.md) + +## Constructors + +### Constructor + +```ts +new Query(config): Query; +``` + +Defined in: [packages/query-core/src/query.ts:246](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L246) + +#### Parameters + +##### config + +`QueryConfig`\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`\> + +#### Returns + +`Query`\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`\> + +#### Overrides + +```ts +Removable.constructor +``` + +## Properties + +### gcTime + +```ts +gcTime: number; +``` + +Defined in: [packages/query-core/src/removable.ts:7](https://github.com/TanStack/query/blob/main/packages/query-core/src/removable.ts#L7) + +#### Inherited from + +```ts +Removable.gcTime +``` + +*** + +### observers + +```ts +observers: QueryObserver[]; +``` + +Defined in: [packages/query-core/src/query.ts:242](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L242) + +*** + +### options + +```ts +options: QueryOptions; +``` + +Defined in: [packages/query-core/src/query.ts:233](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L233) + +*** + +### queryHash + +```ts +queryHash: string; +``` + +Defined in: [packages/query-core/src/query.ts:232](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L232) + +*** + +### queryKey + +```ts +queryKey: TQueryKey; +``` + +Defined in: [packages/query-core/src/query.ts:231](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L231) + +*** + +### state + +```ts +state: QueryState; +``` + +Defined in: [packages/query-core/src/query.ts:234](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L234) + +## Accessors + +### meta + +#### Get Signature + +```ts +get meta(): Record | undefined; +``` + +Defined in: [packages/query-core/src/query.ts:264](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L264) + +The `meta` object passed in the query's options, if any. + +##### Returns + +`Record`\<`string`, `unknown`\> \| `undefined` + +*** + +### promise + +#### Get Signature + +```ts +get promise(): Promise | undefined; +``` + +Defined in: [packages/query-core/src/query.ts:277](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L277) + +The promise for the currently in-flight fetch, if the query is fetching. +`undefined` when the query is not fetching. + +##### Returns + +`Promise`\<`TData`\> \| `undefined` + +## Methods + +### cancel() + +```ts +cancel(options?): Promise; +``` + +Defined in: [packages/query-core/src/query.ts:348](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L348) + +Cancels the query's currently in-flight fetch, if any. +- Returns a promise that resolves once the cancellation has settled. +- If no fetch is in progress, resolves immediately. + +#### Parameters + +##### options? + +[`CancelOptions`](../interfaces/CancelOptions.md) + +#### Returns + +`Promise`\<`void`\> + +#### Example + +```ts +await query.cancel() +``` + +*** + +### clearGcTimeout() + +```ts +protected clearGcTimeout(): void; +``` + +Defined in: [packages/query-core/src/removable.ts:32](https://github.com/TanStack/query/blob/main/packages/query-core/src/removable.ts#L32) + +#### Returns + +`void` + +#### Inherited from + +```ts +Removable.clearGcTimeout +``` + +*** + +### destroy() + +```ts +destroy(): void; +``` + +Defined in: [packages/query-core/src/query.ts:361](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L361) + +Clears the query's garbage collection timeout and silently cancels any +in-flight fetch. Called by `QueryCache` when the query is removed from +the cache. + +#### Returns + +`void` + +#### See + +[Query#cancel](#cancel) + +#### Overrides + +```ts +Removable.destroy +``` + +*** + +### fetch() + +```ts +fetch(options?, fetchOptions?): Promise; +``` + +Defined in: [packages/query-core/src/query.ts:590](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L590) + +Fetches the query, i.e. runs its `queryFn` (through any configured +retryer/behavior) and updates the query's state with the result. +- If a fetch is already in flight, returns its promise instead of + starting a new one, unless `fetchOptions.cancelRefetch` is set and the + query already has data, in which case the current fetch is silently + cancelled first. +- If `options` is passed, it replaces the query's current options + before fetching. + +#### Parameters + +##### options? + +`QueryOptions`\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`, `never`\> + +##### fetchOptions? + +`FetchOptions`\<`TQueryFnData`\> + +#### Returns + +`Promise`\<`TData`\> + +*** + +### getObserversCount() + +```ts +getObserversCount(): number; +``` + +Defined in: [packages/query-core/src/query.ts:560](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L560) + +Returns the number of observers currently subscribed to this query. + +#### Returns + +`number` + +#### Example + +```ts +if (query.getObserversCount() === 0) { + // no component is currently watching this query +} +``` + +*** + +### invalidate() + +```ts +invalidate(): void; +``` + +Defined in: [packages/query-core/src/query.ts:574](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L574) + +Marks the query as invalidated, unless it is already invalidated. This +updates `state.isInvalidated` and notifies observers, but does not by +itself trigger a refetch. + +#### Returns + +`void` + +#### Example + +```ts +query.invalidate() +``` + +*** + +### isActive() + +```ts +isActive(): boolean; +``` + +Defined in: [packages/query-core/src/query.ts:386](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L386) + +Returns `true` if the query has at least one observer for which `enabled` +does not resolve to `false`. + +#### Returns + +`boolean` + +*** + +### isDisabled() + +```ts +isDisabled(): boolean; +``` + +Defined in: [packages/query-core/src/query.ts:400](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L400) + +Returns `true` if the query is disabled, meaning it will not fetch +automatically. +- If the query has observers, it is disabled when none of them are active + (see `isActive`). +- If the query has no observers, it is disabled when its `queryFn` is + `skipToken` or it has never been fetched. + +#### Returns + +`boolean` + +*** + +### isFetched() + +```ts +isFetched(): boolean; +``` + +Defined in: [packages/query-core/src/query.ts:412](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L412) + +Returns `true` if the query has been fetched, i.e. it has resolved with +either data or an error at least once. + +#### Returns + +`boolean` + +*** + +### isStale() + +```ts +isStale(): boolean; +``` + +Defined in: [packages/query-core/src/query.ts:447](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L447) + +Returns `true` if the query is stale. +- If the query has observers, defers to whether any observer's current + result reports `isStale` (which accounts for each observer's own + `staleTime` and `enabled` state). +- If the query has no observers, it is considered stale when it has no + data or has been invalidated. + +#### Returns + +`boolean` + +#### See + +[Query#isStaleByTime](#isstalebytime) + +#### Example + +```ts +if (query.isStale()) { + // refetch or otherwise treat the cached data as outdated +} +``` + +*** + +### isStaleByTime() + +```ts +isStaleByTime(staleTime): boolean; +``` + +Defined in: [packages/query-core/src/query.ts:473](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L473) + +Returns `true` if the query's data is stale relative to the given +`staleTime` (defaults to `0`). +- A query with no data is always stale. +- `staleTime: 'static'` is never stale. +- An invalidated query is always stale. +- Otherwise, staleness is based on elapsed time since `dataUpdatedAt`. + +#### Parameters + +##### staleTime + +[`StaleTime`](../type-aliases/StaleTime.md) = `0` + +#### Returns + +`boolean` + +#### See + +[Query#isStale](#isstale) + +#### Example + +```ts +const isStale = query.isStaleByTime(1000 * 60) +``` + +*** + +### isStatic() + +```ts +isStatic(): boolean; +``` + +Defined in: [packages/query-core/src/query.ts:420](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L420) + +Returns `true` if the query has at least one observer configured with +`staleTime: 'static'`, meaning it is treated as never stale. + +#### Returns + +`boolean` + +*** + +### optionalRemove() + +```ts +protected optionalRemove(): void; +``` + +Defined in: [packages/query-core/src/query.ts:305](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L305) + +#### Returns + +`void` + +#### Overrides + +```ts +Removable.optionalRemove +``` + +*** + +### reset() + +```ts +reset(): void; +``` + +Defined in: [packages/query-core/src/query.ts:377](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L377) + +Resets the query back to its initial state (the state it had when it was +first created, e.g. any `initialData`), destroying it first to cancel any +in-flight fetch. + +#### Returns + +`void` + +*** + +### scheduleGc() + +```ts +protected scheduleGc(): void; +``` + +Defined in: [packages/query-core/src/removable.ts:14](https://github.com/TanStack/query/blob/main/packages/query-core/src/removable.ts#L14) + +#### Returns + +`void` + +#### Inherited from + +```ts +Removable.scheduleGc +``` + +*** + +### setState() + +```ts +setState(state): void; +``` + +Defined in: [packages/query-core/src/query.ts:334](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L334) + +Merges the given partial state directly into this query's state, notifying observers. Used +by persistence and broadcast plugins to restore a state snapshot, and by devtools to let a +user manually trigger a loading/error state or edit the cached data. + +#### Parameters + +##### state + +`Partial`\<[`QueryState`](../interfaces/QueryState.md)\<`TData`, `TError`\>\> + +#### Returns + +`void` + +*** + +### updateGcTime() + +```ts +protected updateGcTime(newGcTime): void; +``` + +Defined in: [packages/query-core/src/removable.ts:24](https://github.com/TanStack/query/blob/main/packages/query-core/src/removable.ts#L24) + +#### Parameters + +##### newGcTime + +`number` | `undefined` + +#### Returns + +`void` + +#### Inherited from + +```ts +Removable.updateGcTime +``` diff --git a/docs/framework/solid/reference/classes/QueryCache.md b/docs/framework/solid/reference/classes/QueryCache.md new file mode 100644 index 00000000000..0a9f44f0efc --- /dev/null +++ b/docs/framework/solid/reference/classes/QueryCache.md @@ -0,0 +1,471 @@ +--- +id: QueryCache +title: QueryCache +--- + +Defined in: [packages/query-core/src/queryCache.ts:123](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryCache.ts#L123) + +The `QueryCache` is the storage mechanism for TanStack Query. It stores all the data, meta +information, and state of the queries it contains. + +Normally, you will not interact with the `QueryCache` directly and instead use a `QueryClient` +for a specific cache. You can subscribe to it (inherited from `Subscribable`) to be informed of +safe/known updates to the cache, such as queries being added, removed, or updated — updates made +outside of the cache's own tracked mechanisms (e.g. mutating a query's state object directly) do +not notify subscribers. + +## Example + +```ts +const unsubscribe = queryCache.subscribe((event) => { + console.log(event.type, event.query) +}) +``` + +## Extends + +- `Subscribable`\<`QueryCacheListener`\> + +## Constructors + +### Constructor + +```ts +new QueryCache(config): QueryCache; +``` + +Defined in: [packages/query-core/src/queryCache.ts:126](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryCache.ts#L126) + +#### Parameters + +##### config + +[`QueryCacheConfig`](../interfaces/QueryCacheConfig.md) = `{}` + +#### Returns + +`QueryCache` + +#### Overrides + +```ts +Subscribable.constructor +``` + +## Properties + +### config + +```ts +config: QueryCacheConfig = {}; +``` + +Defined in: [packages/query-core/src/queryCache.ts:126](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryCache.ts#L126) + +*** + +### listeners + +```ts +protected listeners: Set; +``` + +Defined in: [packages/query-core/src/subscribable.ts:2](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L2) + +#### Inherited from + +```ts +Subscribable.listeners +``` + +## Methods + +### build() + +```ts +build( + client, + options, +state?): Query; +``` + +Defined in: [packages/query-core/src/queryCache.ts:147](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryCache.ts#L147) + +Returns the existing `Query` instance for the given options' `queryKey`/`queryHash`, or +builds and adds a new one to the cache if none exists yet. Used by framework adapters and +plugins (e.g. broadcast/persistence) that need to get-or-create a `Query` directly, bypassing +the reactive `QueryObserver` machinery. + +#### Type Parameters + +##### TQueryFnData + +`TQueryFnData` = `unknown` + +##### TError + +`TError` = `Error` + +##### TData + +`TData` = `TQueryFnData` + +##### TQueryKey + +`TQueryKey` *extends* readonly `unknown`[] = readonly `unknown`[] + +#### Parameters + +##### client + +`QueryClient` + +##### options + +[`WithRequired`](../type-aliases/WithRequired.md)\<`QueryOptions`\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`, `never`\>, `"queryKey"`\> + +##### state? + +[`QueryState`](../interfaces/QueryState.md)\<`TData`, `TError`\> + +#### Returns + +[`Query`](Query.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`\> + +#### Example + +```ts +const queryCache = queryClient.getQueryCache() + +const query = queryCache.build(queryClient, { + queryKey: ['posts'], + queryFn: fetchPosts, +}) +``` + +*** + +### clear() + +```ts +clear(): void; +``` + +Defined in: [packages/query-core/src/queryCache.ts:232](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryCache.ts#L232) + +Removes all queries from the cache. + +#### Returns + +`void` + +#### Example + +```ts +const queryCache = queryClient.getQueryCache() + +queryCache.clear() +``` + +*** + +### find() + +```ts +find(filters): + | Query + | undefined; +``` + +Defined in: [packages/query-core/src/queryCache.ts:299](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryCache.ts#L299) + +A slightly more advanced method that can be used to get an existing query instance from the +cache. This instance not only contains all the state for the query, but all of the instances, +and underlying guts of the query as well. If the query does not exist, `undefined` is +returned. + +This is not typically needed for most applications, but can come in handy when needing more +information about a query in rare scenarios (e.g. looking at `query.state.dataUpdatedAt` to +decide whether a query is fresh enough to be used as an initial value). + +#### Type Parameters + +##### TQueryFnData + +`TQueryFnData` = `unknown` + +##### TError + +`TError` = `Error` + +##### TData + +`TData` = `TQueryFnData` + +#### Parameters + +##### filters + +[`WithRequired`](../type-aliases/WithRequired.md)\<[`QueryFilters`](../interfaces/QueryFilters.md)\, `"queryKey"`\> + +#### Returns + + \| [`Query`](Query.md)\<`TQueryFnData`, `TError`, `TData`, readonly `unknown`[]\> + \| `undefined` + +#### See + +[QueryCache#findAll](#findall) + +#### Example + +```ts +const queryCache = queryClient.getQueryCache() + +const query = queryCache.find({ queryKey: ['posts'] }) +``` + +*** + +### findAll() + +```ts +findAll(filters): Query[]; +``` + +Defined in: [packages/query-core/src/queryCache.ts:324](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryCache.ts#L324) + +An even more advanced method that can be used to get existing query instances from the cache +that partially match a query key. If no queries match, an empty array is returned. + +This is not typically needed for most applications, but can come in handy when needing more +information about queries in rare scenarios. + +#### Parameters + +##### filters + +[`QueryFilters`](../interfaces/QueryFilters.md)\<`any`\> = `{}` + +#### Returns + +[`Query`](Query.md)\<`unknown`, `Error`, `unknown`, readonly `unknown`[]\>[] + +#### See + +[QueryCache#find](#find) + +#### Example + +```ts +const queryCache = queryClient.getQueryCache() + +const queries = queryCache.findAll({ queryKey: ['posts'] }) +``` + +*** + +### get() + +```ts +get(queryHash): + | Query + | undefined; +``` + +Defined in: [packages/query-core/src/queryCache.ts:254](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryCache.ts#L254) + +Returns the `Query` instance stored under the given `queryHash`, or `undefined` if none +exists. Unlike [QueryCache#find](#find), this looks up by the already-computed hash rather +than by `QueryFilters`. Used by plugins (e.g. broadcast/hydration) that already have a hash +to look up directly. + +#### Type Parameters + +##### TQueryFnData + +`TQueryFnData` = `unknown` + +##### TError + +`TError` = `Error` + +##### TData + +`TData` = `TQueryFnData` + +##### TQueryKey + +`TQueryKey` *extends* readonly `unknown`[] = readonly `unknown`[] + +#### Parameters + +##### queryHash + +`string` + +#### Returns + + \| [`Query`](Query.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`\> + \| `undefined` + +#### Example + +```ts +const queryCache = queryClient.getQueryCache() +const queryHash = hashKey(['posts']) + +const query = queryCache.get(queryHash) +``` + +*** + +### getAll() + +```ts +getAll(): Query[]; +``` + +Defined in: [packages/query-core/src/queryCache.ts:277](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryCache.ts#L277) + +Returns all queries within the cache. + +#### Returns + +[`Query`](Query.md)\<`unknown`, `Error`, `unknown`, readonly `unknown`[]\>[] + +#### Example + +```ts +const queryCache = queryClient.getQueryCache() + +const queries = queryCache.getAll() +``` + +*** + +### hasListeners() + +```ts +hasListeners(): boolean; +``` + +Defined in: [packages/query-core/src/subscribable.ts:19](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L19) + +#### Returns + +`boolean` + +#### Inherited from + +```ts +Subscribable.hasListeners +``` + +*** + +### onSubscribe() + +```ts +protected onSubscribe(): void; +``` + +Defined in: [packages/query-core/src/subscribable.ts:23](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L23) + +#### Returns + +`void` + +#### Inherited from + +```ts +Subscribable.onSubscribe +``` + +*** + +### onUnsubscribe() + +```ts +protected onUnsubscribe(): void; +``` + +Defined in: [packages/query-core/src/subscribable.ts:27](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L27) + +#### Returns + +`void` + +#### Inherited from + +```ts +Subscribable.onUnsubscribe +``` + +*** + +### remove() + +```ts +remove(query): void; +``` + +Defined in: [packages/query-core/src/queryCache.ts:208](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryCache.ts#L208) + +Destroys the given `Query` and removes it from the cache, notifying subscribers with a +`'removed'` event. A no-op if the query is no longer the one currently stored under its hash +(e.g. it was already replaced). Used by plugins (e.g. the broadcast client) that mirror +removals across `QueryCache` instances. + +#### Parameters + +##### query + +[`Query`](Query.md)\<`any`, `any`, `any`, `any`\> + +#### Returns + +`void` + +#### Example + +```ts +const queryCache = queryClient.getQueryCache() +const query = queryCache.find({ queryKey: ['posts'] }) + +if (query) { + queryCache.remove(query) +} +``` + +*** + +### subscribe() + +```ts +subscribe(listener): () => void; +``` + +Defined in: [packages/query-core/src/subscribable.ts:8](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L8) + +#### Parameters + +##### listener + +`QueryCacheListener` + +#### Returns + +```ts +(): void; +``` + +##### Returns + +`void` + +#### Inherited from + +```ts +Subscribable.subscribe +``` diff --git a/docs/framework/solid/reference/classes/QueryClient.md b/docs/framework/solid/reference/classes/QueryClient.md index b46ac5ef938..0b7fdf05b86 100644 --- a/docs/framework/solid/reference/classes/QueryClient.md +++ b/docs/framework/solid/reference/classes/QueryClient.md @@ -3,7 +3,7 @@ id: QueryClient title: QueryClient --- -Defined in: [QueryClient.ts:113](https://github.com/TanStack/query/blob/main/packages/solid-query/src/QueryClient.ts#L113) +Defined in: [packages/solid-query/src/QueryClient.ts:113](https://github.com/TanStack/query/blob/main/packages/solid-query/src/QueryClient.ts#L113) The core `@tanstack/query-core` `QueryClient`, typed so its `defaultOptions.queries` accepts Solid's `reconcile` option. @@ -20,7 +20,7 @@ The core `@tanstack/query-core` `QueryClient`, typed so its `defaultOptions.quer new QueryClient(config): QueryClient; ``` -Defined in: [QueryClient.ts:114](https://github.com/TanStack/query/blob/main/packages/solid-query/src/QueryClient.ts#L114) +Defined in: [packages/solid-query/src/QueryClient.ts:114](https://github.com/TanStack/query/blob/main/packages/solid-query/src/QueryClient.ts#L114) #### Parameters @@ -37,3 +37,1629 @@ Defined in: [QueryClient.ts:114](https://github.com/TanStack/query/blob/main/pac ```ts QueryCoreClient.constructor ``` + +## Methods + +### cancelQueries() + +```ts +cancelQueries(filters?, cancelOptions?): Promise; +``` + +Defined in: [packages/query-core/src/queryClient.ts:432](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L432) + +Cancels outgoing fetches for queries matching the given filters. Most useful when performing +optimistic updates, since any outgoing refetch that resolves afterwards would otherwise +overwrite the optimistic update. By default (`revert: true`), a cancelled query's data is +reverted to its state before the outgoing fetch started. + +The returned promise never rejects, even if individual cancellations fail. + +#### Type Parameters + +##### TTaggedQueryKey + +`TTaggedQueryKey` *extends* readonly `unknown`[] = readonly `unknown`[] + +#### Parameters + +##### filters? + +[`QueryFilters`](../interfaces/QueryFilters.md)\<`TTaggedQueryKey`\> + +##### cancelOptions? + +[`CancelOptions`](../interfaces/CancelOptions.md) = `{}` + +#### Returns + +`Promise`\<`void`\> + +#### Example + +```ts +await queryClient.cancelQueries({ queryKey: ['posts'], exact: true }) +``` + +#### Inherited from + +```ts +QueryCoreClient.cancelQueries +``` + +*** + +### clear() + +```ts +clear(): void; +``` + +Defined in: [packages/query-core/src/queryClient.ts:1083](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L1083) + +Clears both the query cache and the mutation cache this client is connected to. + +#### Returns + +`void` + +#### Example + +```ts +import { QueryClient } from '@tanstack/query-core' + +const queryClient = new QueryClient() +queryClient.clear() +``` + +#### Inherited from + +```ts +QueryCoreClient.clear +``` + +*** + +### defaultMutationOptions() + +```ts +defaultMutationOptions(options?): T; +``` + +Defined in: [packages/query-core/src/queryClient.ts:1057](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L1057) + +The mutation counterpart of [QueryClient#defaultQueryOptions](#defaultqueryoptions). Called by framework +adapters (e.g. inside `useMutation`) to merge `queryClient.setMutationDefaults` for the +given `mutationKey`, then the client's `defaultOptions.mutations`, then the caller's options +on top. A no-op if the options are already defaulted (`_defaulted: true`). + +#### Type Parameters + +##### T + +`T` *extends* `MutationOptions`\<`any`, `any`, `any`, `any`\> + +#### Parameters + +##### options? + +`T` + +#### Returns + +`T` + +#### Inherited from + +```ts +QueryCoreClient.defaultMutationOptions +``` + +*** + +### defaultQueryOptions() + +```ts +defaultQueryOptions(options): DefaultedQueryObserverOptions; +``` + +Defined in: [packages/query-core/src/queryClient.ts:970](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L970) + +Called by framework adapters (e.g. inside `useQuery`) to resolve the options passed by the +caller into their final, defaulted form: merging `queryClient.setQueryDefaults` for the +given `queryKey`, then the client's own `defaultOptions.queries`, then the caller's options +on top. A no-op if the options are already defaulted (`_defaulted: true`). + +#### Type Parameters + +##### TQueryFnData + +`TQueryFnData` = `unknown` + +##### TError + +`TError` = `Error` + +##### TData + +`TData` = `TQueryFnData` + +##### TQueryData + +`TQueryData` = `TQueryFnData` + +##### TQueryKey + +`TQueryKey` *extends* readonly `unknown`[] = readonly `unknown`[] + +##### TPageParam + +`TPageParam` = `never` + +#### Parameters + +##### options + +`QueryObserverOptions`\<`TQueryFnData`, `TError`, `TData`, `TQueryData`, `TQueryKey`, `TPageParam`\> | [`DefaultedQueryObserverOptions`](../type-aliases/DefaultedQueryObserverOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryData`, `TQueryKey`\> + +#### Returns + +[`DefaultedQueryObserverOptions`](../type-aliases/DefaultedQueryObserverOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryData`, `TQueryKey`\> + +#### Inherited from + +```ts +QueryCoreClient.defaultQueryOptions +``` + +*** + +### ~~ensureInfiniteQueryData()~~ + +```ts +ensureInfiniteQueryData(options): Promise>; +``` + +Defined in: [packages/query-core/src/queryClient.ts:735](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L735) + +#### Type Parameters + +##### TQueryFnData + +`TQueryFnData` + +##### TError + +`TError` = `Error` + +##### TData + +`TData` = `TQueryFnData` + +##### TQueryKey + +`TQueryKey` *extends* readonly `unknown`[] = readonly `unknown`[] + +##### TPageParam + +`TPageParam` = `unknown` + +#### Parameters + +##### options + +[`EnsureInfiniteQueryDataOptions`](../type-aliases/EnsureInfiniteQueryDataOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`, `TPageParam`\> + +#### Returns + +`Promise`\<[`InfiniteData`](../interfaces/InfiniteData.md)\<`TData`, `TPageParam`\>\> + +#### Deprecated + +Use queryClient.infiniteQuery({ ...options, staleTime: 'static' }) instead. This method will be removed in the next major version. + +#### Inherited from + +```ts +QueryCoreClient.ensureInfiniteQueryData +``` + +*** + +### ~~ensureQueryData()~~ + +```ts +ensureQueryData(options): Promise; +``` + +Defined in: [packages/query-core/src/queryClient.ts:197](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L197) + +#### Type Parameters + +##### TQueryFnData + +`TQueryFnData` + +##### TError + +`TError` = `Error` + +##### TData + +`TData` = `TQueryFnData` + +##### TQueryKey + +`TQueryKey` *extends* readonly `unknown`[] = readonly `unknown`[] + +#### Parameters + +##### options + +[`EnsureQueryDataOptions`](../interfaces/EnsureQueryDataOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`\> + +#### Returns + +`Promise`\<`TData`\> + +#### Deprecated + +Use queryClient.query({ ...options, staleTime: 'static' }) instead. This method will be removed in the next major version. + +#### Inherited from + +```ts +QueryCoreClient.ensureQueryData +``` + +*** + +### ~~fetchInfiniteQuery()~~ + +```ts +fetchInfiniteQuery(options): Promise>; +``` + +Defined in: [packages/query-core/src/queryClient.ts:692](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L692) + +#### Type Parameters + +##### TQueryFnData + +`TQueryFnData` + +##### TError + +`TError` = `Error` + +##### TData + +`TData` = `TQueryFnData` + +##### TQueryKey + +`TQueryKey` *extends* readonly `unknown`[] = readonly `unknown`[] + +##### TPageParam + +`TPageParam` = `unknown` + +#### Parameters + +##### options + +[`FetchInfiniteQueryOptions`](../type-aliases/FetchInfiniteQueryOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`, `TPageParam`\> + +#### Returns + +`Promise`\<[`InfiniteData`](../interfaces/InfiniteData.md)\<`TData`, `TPageParam`\>\> + +#### Deprecated + +Use queryClient.infiniteQuery(options) instead. This method will be removed in the next major version. + +#### Inherited from + +```ts +QueryCoreClient.fetchInfiniteQuery +``` + +*** + +### ~~fetchQuery()~~ + +```ts +fetchQuery(options): Promise; +``` + +Defined in: [packages/query-core/src/queryClient.ts:600](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L600) + +#### Type Parameters + +##### TQueryFnData + +`TQueryFnData` + +##### TError + +`TError` = `Error` + +##### TData + +`TData` = `TQueryFnData` + +##### TQueryKey + +`TQueryKey` *extends* readonly `unknown`[] = readonly `unknown`[] + +##### TPageParam + +`TPageParam` = `never` + +#### Parameters + +##### options + +[`FetchQueryOptions`](../interfaces/FetchQueryOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`, `TPageParam`\> + +#### Returns + +`Promise`\<`TData`\> + +#### Deprecated + +Use queryClient.query(options) instead. This method will be removed in the next major version. + +#### Inherited from + +```ts +QueryCoreClient.fetchQuery +``` + +*** + +### getDefaultOptions() + +```ts +getDefaultOptions(): DefaultOptions; +``` + +Defined in: [packages/query-core/src/queryClient.ts:818](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L818) + +Returns the default options that were set when creating the client, or via +[QueryClient#setDefaultOptions](#setdefaultoptions). + +#### Returns + +`DefaultOptions` + +#### Example + +```ts +import { QueryClient } from '@tanstack/query-core' + +const queryClient = new QueryClient() +const defaultOptions = queryClient.getDefaultOptions() +``` + +#### Inherited from + +```ts +QueryCoreClient.getDefaultOptions +``` + +*** + +### getMutationCache() + +```ts +getMutationCache(): MutationCache; +``` + +Defined in: [packages/query-core/src/queryClient.ts:802](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L802) + +Returns the mutation cache this client is connected to. + +#### Returns + +[`MutationCache`](MutationCache.md) + +#### Example + +```ts +import { QueryClient } from '@tanstack/query-core' + +const queryClient = new QueryClient() +const mutationCache = queryClient.getMutationCache() +const mutations = mutationCache.findAll({ status: 'pending' }) +``` + +#### Inherited from + +```ts +QueryCoreClient.getMutationCache +``` + +*** + +### getMutationDefaults() + +```ts +getMutationDefaults(mutationKey): OmitKeyof, "mutationKey">; +``` + +Defined in: [packages/query-core/src/queryClient.ts:945](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L945) + +Returns the default options registered for mutations whose mutation key partially matches +the given `mutationKey`, via [QueryClient#setMutationDefaults](#setmutationdefaults). If multiple registered +defaults match, they are merged together in registration order. + +#### Parameters + +##### mutationKey + +readonly `unknown`[] + +#### Returns + +[`OmitKeyof`](../type-aliases/OmitKeyof.md)\<[`MutationObserverOptions`](../interfaces/MutationObserverOptions.md)\<`any`, `any`, `any`, `any`\>, `"mutationKey"`\> + +#### Example + +```ts +const defaultOptions = queryClient.getMutationDefaults(['addPost']) +``` + +#### Inherited from + +```ts +QueryCoreClient.getMutationDefaults +``` + +*** + +### getQueriesData() + +```ts +getQueriesData(filters): [readonly unknown[], TQueryFnData | undefined][]; +``` + +Defined in: [packages/query-core/src/queryClient.ts:240](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L240) + +Imperative (non-reactive) way to retrieve the cached data of multiple queries at once. +Only queries matching the given filters are returned; if none match, an empty array is +returned. + +Because the matched queries can hold data of different shapes (e.g. a broad filter can match +queries with unrelated data types), the `TQueryFnData` generic defaults to `unknown` rather +than being inferred. Passing a more specific type is a convenience for call sites that know +every matched query holds the same shape — it is not checked against the actual cache +contents. + +#### Type Parameters + +##### TQueryFnData + +`TQueryFnData` = `unknown` + +##### TQueryFilters + +`TQueryFilters` *extends* [`QueryFilters`](../interfaces/QueryFilters.md)\<`any`\> = [`QueryFilters`](../interfaces/QueryFilters.md)\ + +#### Parameters + +##### filters + +`TQueryFilters` + +#### Returns + +\[readonly `unknown`[], `TQueryFnData` \| `undefined`\][] + +#### See + +[QueryClient#getQueryData](#getquerydata) + +#### Example + +```ts +const data = queryClient.getQueriesData({ queryKey: ['posts'] }) +``` + +#### Inherited from + +```ts +QueryCoreClient.getQueriesData +``` + +*** + +### getQueryCache() + +```ts +getQueryCache(): QueryCache; +``` + +Defined in: [packages/query-core/src/queryClient.ts:786](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L786) + +Returns the query cache this client is connected to. + +#### Returns + +[`QueryCache`](QueryCache.md) + +#### Example + +```ts +import { QueryClient } from '@tanstack/query-core' + +const queryClient = new QueryClient() +const queryCache = queryClient.getQueryCache() +const queries = queryCache.findAll({ queryKey: ['posts'] }) +``` + +#### Inherited from + +```ts +QueryCoreClient.getQueryCache +``` + +*** + +### getQueryData() + +```ts +getQueryData(queryKey): TInferredQueryFnData | undefined; +``` + +Defined in: [packages/query-core/src/queryClient.ts:183](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L183) + +Imperative (non-reactive) way to retrieve data for a QueryKey. +Should only be used in callbacks or functions where reading the latest data is necessary, e.g. for optimistic updates. + +Hint: Do not use this function inside a component, because it won't receive updates. +Use `useQuery` to create a `QueryObserver` that subscribes to changes. + +#### Type Parameters + +##### TQueryFnData + +`TQueryFnData` = `unknown` + +##### TTaggedQueryKey + +`TTaggedQueryKey` *extends* readonly `unknown`[] = readonly `unknown`[] + +##### TInferredQueryFnData + +`TInferredQueryFnData` = [`InferDataFromTag`](../type-aliases/InferDataFromTag.md)\<`TQueryFnData`, `TTaggedQueryKey`\> + +#### Parameters + +##### queryKey + +`TTaggedQueryKey` + +#### Returns + +`TInferredQueryFnData` \| `undefined` + +#### See + +[QueryClient#getQueriesData](#getqueriesdata) + +#### Inherited from + +```ts +QueryCoreClient.getQueryData +``` + +*** + +### getQueryDefaults() + +```ts +getQueryDefaults(queryKey): OmitKeyof, "queryKey">; +``` + +Defined in: [packages/query-core/src/queryClient.ts:888](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L888) + +Returns the default options registered for queries whose query key partially matches the +given `queryKey`, via [QueryClient#setQueryDefaults](#setquerydefaults). If multiple registered defaults +match, they are merged together in registration order. + +#### Parameters + +##### queryKey + +readonly `unknown`[] + +#### Returns + +[`OmitKeyof`](../type-aliases/OmitKeyof.md)\<`QueryObserverOptions`\<`any`, `any`, `any`, `any`, `any`\>, `"queryKey"`\> + +#### Example + +```ts +const defaultOptions = queryClient.getQueryDefaults(['posts']) +``` + +#### Inherited from + +```ts +QueryCoreClient.getQueryDefaults +``` + +*** + +### getQueryState() + +```ts +getQueryState(queryKey): + | QueryState + | undefined; +``` + +Defined in: [packages/query-core/src/queryClient.ts:350](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L350) + +Imperative (non-reactive) way to retrieve an existing query's state. If the query does not +exist, `undefined` is returned. + +#### Type Parameters + +##### TQueryFnData + +`TQueryFnData` = `unknown` + +##### TError + +`TError` = `Error` + +##### TTaggedQueryKey + +`TTaggedQueryKey` *extends* readonly `unknown`[] = readonly `unknown`[] + +##### TInferredQueryFnData + +`TInferredQueryFnData` = [`InferDataFromTag`](../type-aliases/InferDataFromTag.md)\<`TQueryFnData`, `TTaggedQueryKey`\> + +##### TInferredError + +`TInferredError` = [`InferErrorFromTag`](../type-aliases/InferErrorFromTag.md)\<`TError`, `TTaggedQueryKey`\> + +#### Parameters + +##### queryKey + +`TTaggedQueryKey` + +#### Returns + + \| [`QueryState`](../interfaces/QueryState.md)\<`TInferredQueryFnData`, `TInferredError`\> + \| `undefined` + +#### Example + +```ts +const state = queryClient.getQueryState(['posts']) +console.log(state?.dataUpdatedAt) +``` + +#### Inherited from + +```ts +QueryCoreClient.getQueryState +``` + +*** + +### infiniteQuery() + +```ts +infiniteQuery(options): Promise[] ? InfiniteData : TData>; +``` + +Defined in: [packages/query-core/src/queryClient.ts:666](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L666) + +Asynchronous method to fetch and cache an infinite query, resolving with an +[InfiniteData](../interfaces/InfiniteData.md) object or throwing with the error. + +Behaves like [QueryClient#query](#query), accepting the same options (minus +`initialPageParam`), plus the required `initialPageParam`, and an optional `pages` / +`getNextPageParam` pair used to refetch a fixed number of pages from the start. + +This method replaces the deprecated `fetchInfiniteQuery`, and — combined with +`{ staleTime: 'static' }` — the deprecated `ensureInfiniteQueryData`. + +#### Type Parameters + +##### TQueryFnData + +`TQueryFnData` + +##### TError + +`TError` = `Error` + +##### TData + +`TData` = [`InfiniteData`](../interfaces/InfiniteData.md)\<`TQueryFnData`, `unknown`\> + +##### TQueryKey + +`TQueryKey` *extends* readonly `unknown`[] = readonly `unknown`[] + +##### TPageParam + +`TPageParam` = `unknown` + +#### Parameters + +##### options + +[`InfiniteQueryExecuteOptions`](../type-aliases/InfiniteQueryExecuteOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`, `TPageParam`\> + +#### Returns + +`Promise`\<`TData`[] *extends* [`InfiniteData`](../interfaces/InfiniteData.md)\<`TQueryFnData`, `unknown`\>[] ? [`InfiniteData`](../interfaces/InfiniteData.md)\<`TQueryFnData`, `TPageParam`\> : `TData`\> + +#### Example + +```ts +try { + const data = await queryClient.infiniteQuery({ queryKey, queryFn, initialPageParam: 0 }) + console.log(data.pages) +} catch (error) { + console.log(error) +} +``` + +#### Inherited from + +```ts +QueryCoreClient.infiniteQuery +``` + +*** + +### invalidateQueries() + +```ts +invalidateQueries(filters?, options?): Promise; +``` + +Defined in: [packages/query-core/src/queryClient.ts:460](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L460) + +Marks queries matching the given filters as invalidated. Unlike +[QueryClient#removeQueries](#removequeries), invalidated queries stay in the cache. + +Unless `filters.refetchType` is `'none'`, matching queries are then refetched via +[QueryClient#refetchQueries](#refetchqueries), using `filters.refetchType` if set, otherwise +`filters.type`, otherwise `'active'`. + +#### Type Parameters + +##### TTaggedQueryKey + +`TTaggedQueryKey` *extends* readonly `unknown`[] = readonly `unknown`[] + +#### Parameters + +##### filters? + +[`InvalidateQueryFilters`](../interfaces/InvalidateQueryFilters.md)\<`TTaggedQueryKey`\> + +##### options? + +[`InvalidateOptions`](../interfaces/InvalidateOptions.md) = `{}` + +#### Returns + +`Promise`\<`void`\> + +#### Example + +```ts +await queryClient.invalidateQueries({ queryKey: ['posts'], refetchType: 'active' }) +``` + +#### Inherited from + +```ts +QueryCoreClient.invalidateQueries +``` + +*** + +### isFetching() + +```ts +isFetching(filters?): number; +``` + +Defined in: [packages/query-core/src/queryClient.ts:150](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L150) + +Returns the number of queries in the cache that are currently fetching, optionally +matching a set of filters. This includes background-fetching, loading new pages, and +loading more infinite query results. + +#### Type Parameters + +##### TQueryFilters + +`TQueryFilters` *extends* [`QueryFilters`](../interfaces/QueryFilters.md)\<`any`\> = [`QueryFilters`](../interfaces/QueryFilters.md)\ + +#### Parameters + +##### filters? + +`TQueryFilters` + +#### Returns + +`number` + +#### Example + +```ts +if (queryClient.isFetching()) { + console.log('At least one query is fetching!') +} +``` + +#### Inherited from + +```ts +QueryCoreClient.isFetching +``` + +*** + +### isMutating() + +```ts +isMutating(filters?): number; +``` + +Defined in: [packages/query-core/src/queryClient.ts:168](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L168) + +Returns the number of mutations in the cache that are currently pending, optionally +matching a set of filters. + +#### Type Parameters + +##### TMutationFilters + +`TMutationFilters` *extends* [`MutationFilters`](../interfaces/MutationFilters.md)\<`any`, `any`, `unknown`, `unknown`\> = [`MutationFilters`](../interfaces/MutationFilters.md)\<`unknown`, `Error`, `unknown`, `unknown`\> + +#### Parameters + +##### filters? + +`TMutationFilters` + +#### Returns + +`number` + +#### Example + +```ts +if (queryClient.isMutating()) { + console.log('At least one mutation is pending!') +} +``` + +#### Inherited from + +```ts +QueryCoreClient.isMutating +``` + +*** + +### mount() + +```ts +mount(): void; +``` + +Defined in: [packages/query-core/src/queryClient.ts:104](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L104) + +Called by a framework adapter's `QueryClientProvider`-equivalent when it mounts, to start +listening for focus/online events and resume paused mutations. Ref-counted via an internal +mount count, so nested or multiple providers sharing the same `QueryClient` don't tear down +the shared listeners until the last one unmounts. + +#### Returns + +`void` + +#### Inherited from + +```ts +QueryCoreClient.mount +``` + +*** + +### ~~prefetchInfiniteQuery()~~ + +```ts +prefetchInfiniteQuery(options): Promise; +``` + +Defined in: [packages/query-core/src/queryClient.ts:714](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L714) + +#### Type Parameters + +##### TQueryFnData + +`TQueryFnData` + +##### TError + +`TError` = `Error` + +##### TData + +`TData` = `TQueryFnData` + +##### TQueryKey + +`TQueryKey` *extends* readonly `unknown`[] = readonly `unknown`[] + +##### TPageParam + +`TPageParam` = `unknown` + +#### Parameters + +##### options + +[`FetchInfiniteQueryOptions`](../type-aliases/FetchInfiniteQueryOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`, `TPageParam`\> + +#### Returns + +`Promise`\<`void`\> + +#### Deprecated + +Use queryClient.infiniteQuery(options) instead. You can swallow errors with `.catch(noop)`. This method will be removed in the next major version. + +#### Inherited from + +```ts +QueryCoreClient.prefetchInfiniteQuery +``` + +*** + +### ~~prefetchQuery()~~ + +```ts +prefetchQuery(options): Promise; +``` + +Defined in: [packages/query-core/src/queryClient.ts:634](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L634) + +#### Type Parameters + +##### TQueryFnData + +`TQueryFnData` = `unknown` + +##### TError + +`TError` = `Error` + +##### TData + +`TData` = `TQueryFnData` + +##### TQueryKey + +`TQueryKey` *extends* readonly `unknown`[] = readonly `unknown`[] + +#### Parameters + +##### options + +[`FetchQueryOptions`](../interfaces/FetchQueryOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`\> + +#### Returns + +`Promise`\<`void`\> + +#### Deprecated + +Use queryClient.query(options) instead. You can swallow errors with `.catch(noop)`. This method will be removed in the next major version. + +#### Inherited from + +```ts +QueryCoreClient.prefetchQuery +``` + +*** + +### query() + +```ts +query(options): Promise; +``` + +Defined in: [packages/query-core/src/queryClient.ts:554](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L554) + +Asynchronous method to fetch and cache a query, resolving with the data or throwing with +the error. + +If the query already exists in the cache and its data is not stale (per the given +`staleTime`), the cached data is returned without fetching. Otherwise, the query is fetched +and the promise resolves once the fetch settles. If a `select` function is provided, it is +applied to the data in both cases (cached or freshly fetched) before it is returned. + +Unlike a reactive observer, retries are disabled by default here (`retry: false`) unless +explicitly configured, since there is no component to catch a thrown error and retry through +re-render. + +The accepted options are `QueryObserverOptions` minus the fields that only make sense for a +reactive observer — `enabled`, `refetchInterval`, `refetchIntervalInBackground`, +`refetchOnWindowFocus`, `refetchOnReconnect`, `refetchOnMount`, `retryOnMount`, +`notifyOnChangeProps`, `throwOnError`, `suspense`, and `placeholderData` are not part of this +method's options. + +This method replaces the deprecated `fetchQuery`, and — combined with +`{ staleTime: 'static' }` — the deprecated `ensureQueryData`. + +#### Type Parameters + +##### TQueryFnData + +`TQueryFnData` + +##### TError + +`TError` = `Error` + +##### TData + +`TData` = `TQueryFnData` + +##### TQueryData + +`TQueryData` = `TQueryFnData` + +##### TQueryKey + +`TQueryKey` *extends* readonly `unknown`[] = readonly `unknown`[] + +##### TPageParam + +`TPageParam` = `never` + +#### Parameters + +##### options + +[`QueryExecuteOptions`](../interfaces/QueryExecuteOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryData`, `TQueryKey`, `TPageParam`\> + +#### Returns + +`Promise`\<`TData`\> + +#### Example + +```ts +try { + const data = await queryClient.query({ queryKey, queryFn, staleTime: 10000 }) +} catch (error) { + console.log(error) +} +``` + +#### Inherited from + +```ts +QueryCoreClient.query +``` + +*** + +### refetchQueries() + +```ts +refetchQueries(filters?, options?): Promise; +``` + +Defined in: [packages/query-core/src/queryClient.ts:497](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L497) + +Refetches queries matching the given filters, regardless of whether they are stale. Without +filters, every query in the cache is refetched. Queries that are disabled, or static (only +have observers with a static `staleTime`), are never refetched. + +By default (`cancelRefetch: true`), a currently running fetch is cancelled before the new +one starts. The returned promise resolves once all matching queries have settled; it does +not reject on individual query failures unless `throwOnError` is set. + +#### Type Parameters + +##### TTaggedQueryKey + +`TTaggedQueryKey` *extends* readonly `unknown`[] = readonly `unknown`[] + +#### Parameters + +##### filters? + +[`RefetchQueryFilters`](../interfaces/RefetchQueryFilters.md)\<`TTaggedQueryKey`\> + +##### options? + +[`RefetchOptions`](../interfaces/RefetchOptions.md) = `{}` + +#### Returns + +`Promise`\<`void`\> + +#### Example + +```ts +// refetch all active queries partially matching a query key: +await queryClient.refetchQueries({ queryKey: ['posts'], type: 'active' }) +``` + +#### Inherited from + +```ts +QueryCoreClient.refetchQueries +``` + +*** + +### removeQueries() + +```ts +removeQueries(filters?): void; +``` + +Defined in: [packages/query-core/src/queryClient.ts:376](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L376) + +Removes queries from the cache that match the given filters. Unlike +[QueryClient#invalidateQueries](#invalidatequeries) or [QueryClient#refetchQueries](#refetchqueries), this removes +matching queries from the cache instead of refetching them. Without filters, every query in +the cache is removed. + +#### Type Parameters + +##### TTaggedQueryKey + +`TTaggedQueryKey` *extends* readonly `unknown`[] = readonly `unknown`[] + +#### Parameters + +##### filters? + +[`QueryFilters`](../interfaces/QueryFilters.md)\<`TTaggedQueryKey`\> + +#### Returns + +`void` + +#### Example + +```ts +queryClient.removeQueries({ queryKey: ['posts'], exact: true }) +``` + +#### Inherited from + +```ts +QueryCoreClient.removeQueries +``` + +*** + +### resetQueries() + +```ts +resetQueries(filters?, options?): Promise; +``` + +Defined in: [packages/query-core/src/queryClient.ts:397](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L397) + +Resets queries matching the given filters back to their initial state (e.g. any +`initialData`), notifying subscribers rather than removing them. Active queries among the +matched set are then refetched, and the returned promise resolves once that refetch settles. + +#### Type Parameters + +##### TTaggedQueryKey + +`TTaggedQueryKey` *extends* readonly `unknown`[] = readonly `unknown`[] + +#### Parameters + +##### filters? + +[`QueryFilters`](../interfaces/QueryFilters.md)\<`TTaggedQueryKey`\> + +##### options? + +[`ResetOptions`](../interfaces/ResetOptions.md) + +#### Returns + +`Promise`\<`void`\> + +#### Example + +```ts +await queryClient.resetQueries({ queryKey: ['posts'], exact: true }) +``` + +#### Inherited from + +```ts +QueryCoreClient.resetQueries +``` + +*** + +### resumePausedMutations() + +```ts +resumePausedMutations(): Promise; +``` + +Defined in: [packages/query-core/src/queryClient.ts:767](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L767) + +Resumes mutations that were paused because there was no network connection. Does nothing +(resolving immediately) if the client is currently offline. + +#### Returns + +`Promise`\<`unknown`\> + +#### Example + +```ts +import { QueryClient } from '@tanstack/query-core' + +const queryClient = new QueryClient() +await queryClient.resumePausedMutations() +``` + +#### Inherited from + +```ts +QueryCoreClient.resumePausedMutations +``` + +*** + +### setDefaultOptions() + +```ts +setDefaultOptions(options): void; +``` + +Defined in: [packages/query-core/src/queryClient.ts:839](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L839) + +Dynamically sets the default options for this client, overwriting any previously defined +default options. + +#### Parameters + +##### options + +`DefaultOptions` + +#### Returns + +`void` + +#### See + +[QueryClient#getDefaultOptions](#getdefaultoptions) + +#### Example + +```ts +import { QueryClient } from '@tanstack/query-core' + +const queryClient = new QueryClient() +queryClient.setDefaultOptions({ + queries: { + staleTime: Infinity, + }, +}) +``` + +#### Inherited from + +```ts +QueryCoreClient.setDefaultOptions +``` + +*** + +### setMutationDefaults() + +```ts +setMutationDefaults(mutationKey, options): void; +``` + +Defined in: [packages/query-core/src/queryClient.ts:917](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L917) + +Sets default options for mutations whose mutation key partially matches the given +`mutationKey`. As with [QueryClient#setQueryDefaults](#setquerydefaults), the order of registration +matters when several registered defaults match the same mutation key. + +#### Type Parameters + +##### TData + +`TData` = `unknown` + +##### TError + +`TError` = `Error` + +##### TVariables + +`TVariables` = `void` + +##### TOnMutateResult + +`TOnMutateResult` = `unknown` + +#### Parameters + +##### mutationKey + +readonly `unknown`[] + +##### options + +[`OmitKeyof`](../type-aliases/OmitKeyof.md)\<[`MutationObserverOptions`](../interfaces/MutationObserverOptions.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\>, `"mutationKey"`\> + +#### Returns + +`void` + +#### See + +[QueryClient#getMutationDefaults](#getmutationdefaults) + +#### Example + +```ts +queryClient.setMutationDefaults(['addPost'], { mutationFn: addPost }) +``` + +#### Inherited from + +```ts +QueryCoreClient.setMutationDefaults +``` + +*** + +### setQueriesData() + +```ts +setQueriesData( + filters, + updater, + options?): [readonly unknown[], TQueryFnData | undefined][]; +``` + +Defined in: [packages/query-core/src/queryClient.ts:319](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L319) + +Synchronous way to immediately update the cached data of multiple queries at once, using +filters or partial query key matching. Only queries that already exist and match the given +filters are updated; no new cache entries are created. Internally this calls +[QueryClient#setQueryData](#setquerydata) for each matching query. + +#### Type Parameters + +##### TQueryFnData + +`TQueryFnData` + +##### TQueryFilters + +`TQueryFilters` *extends* [`QueryFilters`](../interfaces/QueryFilters.md)\<`any`\> = [`QueryFilters`](../interfaces/QueryFilters.md)\ + +#### Parameters + +##### filters + +`TQueryFilters` + +##### updater + +[`Updater`](../type-aliases/Updater.md)\<`NoInfer`\<`TQueryFnData`\> \| `undefined`, `NoInfer`\<`TQueryFnData`\> \| `undefined`\> + +##### options? + +[`SetDataOptions`](../interfaces/SetDataOptions.md) + +#### Returns + +\[readonly `unknown`[], `TQueryFnData` \| `undefined`\][] + +#### Example + +```ts +queryClient.setQueriesData({ queryKey: ['posts'] }, (oldPosts) => + oldPosts ? oldPosts.filter((post) => post.id !== deletedId) : oldPosts, +) +``` + +#### Inherited from + +```ts +QueryCoreClient.setQueriesData +``` + +*** + +### setQueryData() + +```ts +setQueryData( + queryKey, + updater, + options?): NoInfer | undefined; +``` + +Defined in: [packages/query-core/src/queryClient.ts:271](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L271) + +Synchronous way to immediately update a query's cached data. If the updater (or the value +passed) resolves to `undefined`, the cache is left untouched and no query is created; +otherwise, if the query does not exist yet, it will be created. To update multiple queries +at once by partially matching query keys, use [QueryClient#setQueriesData](#setqueriesdata) instead. + +Updates must be performed immutably: do not mutate `oldData`, or data previously retrieved +via [QueryClient#getQueryData](#getquerydata), in place. + +#### Type Parameters + +##### TQueryFnData + +`TQueryFnData` = `unknown` + +##### TTaggedQueryKey + +`TTaggedQueryKey` *extends* readonly `unknown`[] = readonly `unknown`[] + +##### TInferredQueryFnData + +`TInferredQueryFnData` = [`InferDataFromTag`](../type-aliases/InferDataFromTag.md)\<`TQueryFnData`, `TTaggedQueryKey`\> + +#### Parameters + +##### queryKey + +`TTaggedQueryKey` + +The query key to set data for. + +##### updater + +[`Updater`](../type-aliases/Updater.md)\<`NoInfer`\<`TInferredQueryFnData`\> \| `undefined`, `NoInfer`\<`TInferredQueryFnData`\> \| `undefined`\> + +Either the new data, or a function that receives the current data (which +may be `undefined`) and returns the new data. + +##### options? + +[`SetDataOptions`](../interfaces/SetDataOptions.md) + +#### Returns + +`NoInfer`\<`TInferredQueryFnData`\> \| `undefined` + +#### Example + +```ts +queryClient.setQueryData(['posts'], newPosts) + +// Or, using an updater function that receives the current data: +queryClient.setQueryData(['posts'], (oldPosts) => [...oldPosts, newPost]) +``` + +#### Inherited from + +```ts +QueryCoreClient.setQueryData +``` + +*** + +### setQueryDefaults() + +```ts +setQueryDefaults(queryKey, options): void; +``` + +Defined in: [packages/query-core/src/queryClient.ts:858](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L858) + +Sets default options for queries whose query key partially matches the given `queryKey`. + +If several registered query defaults match a given query key, they are merged together in +registration order by [QueryClient#getQueryDefaults](#getquerydefaults), so register defaults from the +most generic key to the least generic one — more specific defaults should be registered +after more generic ones so they take precedence. + +#### Type Parameters + +##### TQueryFnData + +`TQueryFnData` = `unknown` + +##### TError + +`TError` = `Error` + +##### TData + +`TData` = `TQueryFnData` + +##### TQueryData + +`TQueryData` = `TQueryFnData` + +#### Parameters + +##### queryKey + +readonly `unknown`[] + +##### options + +`Partial`\<[`OmitKeyof`](../type-aliases/OmitKeyof.md)\<`QueryObserverOptions`\<`TQueryFnData`, `TError`, `TData`, `TQueryData`\>, `"queryKey"`\>\> + +#### Returns + +`void` + +#### Example + +```ts +queryClient.setQueryDefaults(['posts'], { queryFn: fetchPosts }) + +await queryClient.query({ queryKey: ['posts'] }) +``` + +#### Inherited from + +```ts +QueryCoreClient.setQueryDefaults +``` + +*** + +### unmount() + +```ts +unmount(): void; +``` + +Defined in: [packages/query-core/src/queryClient.ts:127](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L127) + +The inverse of [QueryClient#mount](#mount) — called by a framework adapter's +`QueryClientProvider`-equivalent when it unmounts. Only tears down the focus/online +listeners once the mount count returns to `0`. + +#### Returns + +`void` + +#### Inherited from + +```ts +QueryCoreClient.unmount +``` diff --git a/docs/framework/solid/reference/classes/QueryObserver.md b/docs/framework/solid/reference/classes/QueryObserver.md new file mode 100644 index 00000000000..e572756606d --- /dev/null +++ b/docs/framework/solid/reference/classes/QueryObserver.md @@ -0,0 +1,555 @@ +--- +id: QueryObserver +title: QueryObserver +--- + +Defined in: [packages/query-core/src/queryObserver.ts:57](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L57) + +A `QueryObserver` watches a single query in the `QueryCache` and computes a +`QueryObserverResult` from its state, recomputing and notifying subscribers +whenever the underlying query (or the observer's options) changes. It is +the primitive that framework adapters (e.g. `useQuery`) build their hooks +on top of, but it can also be used directly to observe and switch between +queries outside of any framework. + +## Example + +```ts +const observer = new QueryObserver(queryClient, { + queryKey: ['posts'], + queryFn: fetchPosts, +}) + +const unsubscribe = observer.subscribe((result) => { + console.log(result.data) +}) +``` + +## Extends + +- `Subscribable`\<`QueryObserverListener`\<`TData`, `TError`\>\> + +## Extended by + +- [`InfiniteQueryObserver`](InfiniteQueryObserver.md) + +## Type Parameters + +### TQueryFnData + +`TQueryFnData` = `unknown` + +### TError + +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) + +### TData + +`TData` = `TQueryFnData` + +### TQueryData + +`TQueryData` = `TQueryFnData` + +### TQueryKey + +`TQueryKey` *extends* [`QueryKey`](../type-aliases/QueryKey.md) = [`QueryKey`](../type-aliases/QueryKey.md) + +## Constructors + +### Constructor + +```ts +new QueryObserver(client, options): QueryObserver; +``` + +Defined in: [packages/query-core/src/queryObserver.ts:87](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L87) + +#### Parameters + +##### client + +`QueryClient` + +##### options + +`QueryObserverOptions`\<`TQueryFnData`, `TError`, `TData`, `TQueryData`, `TQueryKey`\> + +#### Returns + +`QueryObserver`\<`TQueryFnData`, `TError`, `TData`, `TQueryData`, `TQueryKey`\> + +#### Overrides + +```ts +Subscribable>.constructor +``` + +## Properties + +### listeners + +```ts +protected listeners: Set>; +``` + +Defined in: [packages/query-core/src/subscribable.ts:2](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L2) + +#### Inherited from + +```ts +Subscribable.listeners +``` + +*** + +### options + +```ts +options: QueryObserverOptions; +``` + +Defined in: [packages/query-core/src/queryObserver.ts:89](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L89) + +## Methods + +### bindMethods() + +```ts +protected bindMethods(): void; +``` + +Defined in: [packages/query-core/src/queryObserver.ts:106](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L106) + +#### Returns + +`void` + +*** + +### createResult() + +```ts +protected createResult(query, options): QueryObserverResult; +``` + +Defined in: [packages/query-core/src/queryObserver.ts:559](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L559) + +#### Parameters + +##### query + +[`Query`](Query.md)\<`TQueryFnData`, `TError`, `TQueryData`, `TQueryKey`\> + +##### options + +`QueryObserverOptions`\<`TQueryFnData`, `TError`, `TData`, `TQueryData`, `TQueryKey`\> + +#### Returns + +[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\> + +*** + +### destroy() + +```ts +destroy(): void; +``` + +Defined in: [packages/query-core/src/queryObserver.ts:161](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L161) + +Stops observing the current query: clears all listeners, cancels the +stale and refetch-interval timers, and removes this observer from the +query it was observing. + +#### Returns + +`void` + +*** + +### fetch() + +```ts +protected fetch(fetchOptions): Promise>; +``` + +Defined in: [packages/query-core/src/queryObserver.ts:448](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L448) + +#### Parameters + +##### fetchOptions + +`ObserverFetchOptions` + +#### Returns + +`Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> + +*** + +### fetchOptimistic() + +```ts +fetchOptimistic(options): Promise>; +``` + +Defined in: [packages/query-core/src/queryObserver.ts:395](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L395) + +Fetches a query defined by the given options without affecting this +observer's own tracked query or result, and returns a promise that +resolves with the `QueryObserverResult` for that fetch. This is useful +for prefetching data that another observer (e.g. a query about to be +navigated to) will need, ahead of time. + +#### Parameters + +##### options + +`QueryObserverOptions`\<`TQueryFnData`, `TError`, `TData`, `TQueryData`, `TQueryKey`\> + +#### Returns + +`Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> + +#### Example + +```ts +const result = await observer.fetchOptimistic({ + queryKey: ['posts', 2], + queryFn: () => fetchPost(2), +}) +console.log(result.data) +``` + +*** + +### getCurrentQuery() + +```ts +getCurrentQuery(): Query; +``` + +Defined in: [packages/query-core/src/queryObserver.ts:357](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L357) + +Returns the `Query` instance this observer is currently observing. + +#### Returns + +[`Query`](Query.md)\<`TQueryFnData`, `TError`, `TQueryData`, `TQueryKey`\> + +*** + +### getCurrentResult() + +```ts +getCurrentResult(): QueryObserverResult; +``` + +Defined in: [packages/query-core/src/queryObserver.ts:321](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L321) + +Returns the most recently computed `QueryObserverResult` for the +observed query. This is a point-in-time read; to be notified of updates +as they happen, subscribe to the observer instead (its inherited +`subscribe` method). + +#### Returns + +[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\> + +#### Example + +```ts +const result = observer.getCurrentResult() +console.log(result.status, result.data) +``` + +*** + +### getOptimisticResult() + +```ts +getOptimisticResult(options): QueryObserverResult; +``` + +Defined in: [packages/query-core/src/queryObserver.ts:272](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L272) + +Computes the result the observer would produce for the given (already-defaulted) options +right now, building the underlying `Query` if it doesn't exist yet, without waiting for a +subscription callback. Called by framework adapters on every render (e.g. `useQuery`) so the +returned value is available synchronously, ahead of `setOptions` triggering an actual fetch. + +#### Parameters + +##### options + +[`DefaultedQueryObserverOptions`](../type-aliases/DefaultedQueryObserverOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryData`, `TQueryKey`\> + +#### Returns + +[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\> + +*** + +### hasListeners() + +```ts +hasListeners(): boolean; +``` + +Defined in: [packages/query-core/src/subscribable.ts:19](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L19) + +#### Returns + +`boolean` + +#### Inherited from + +```ts +Subscribable.hasListeners +``` + +*** + +### onSubscribe() + +```ts +protected onSubscribe(): void; +``` + +Defined in: [packages/query-core/src/queryObserver.ts:110](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L110) + +#### Returns + +`void` + +#### Overrides + +```ts +Subscribable.onSubscribe +``` + +*** + +### onUnsubscribe() + +```ts +protected onUnsubscribe(): void; +``` + +Defined in: [packages/query-core/src/queryObserver.ts:124](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L124) + +#### Returns + +`void` + +#### Overrides + +```ts +Subscribable.onUnsubscribe +``` + +*** + +### refetch() + +```ts +refetch(__namedParameters): Promise>; +``` + +Defined in: [packages/query-core/src/queryObserver.ts:371](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L371) + +Refetches the observed query and returns a promise that resolves with +the resulting `QueryObserverResult`. + +#### Parameters + +##### \_\_namedParameters + +[`RefetchOptions`](../interfaces/RefetchOptions.md) = `{}` + +#### Returns + +`Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> + +#### Example + +```ts +const result = await observer.refetch({ cancelRefetch: false }) +console.log(result.data) +``` + +*** + +### setOptions() + +```ts +setOptions(options): void; +``` + +Defined in: [packages/query-core/src/queryObserver.ts:182](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L182) + +Updates the observer's options. This will re-resolve the query being +observed (switching to a different query if the `queryKey` changed), +trigger a fetch if the new options require one and the observer has +subscribers, recompute the current result, and reschedule the stale and +refetch-interval timers as needed. + +#### Parameters + +##### options + +`QueryObserverOptions`\<`TQueryFnData`, `TError`, `TData`, `TQueryData`, `TQueryKey`\> + +#### Returns + +`void` + +#### Example + +```ts +observer.setOptions({ queryKey: ['posts', 1], queryFn: () => fetchPost(1) }) +// later: switch to a different query, reusing the same observer +observer.setOptions({ queryKey: ['posts', 2], queryFn: () => fetchPost(2) }) +``` + +*** + +### shouldFetchOnReconnect() + +```ts +shouldFetchOnReconnect(): boolean; +``` + +Defined in: [packages/query-core/src/queryObserver.ts:135](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L135) + +Returns whether the observed query is currently stale and configured +(via the `refetchOnReconnect` option) to refetch when the network +reconnects. + +#### Returns + +`boolean` + +*** + +### shouldFetchOnWindowFocus() + +```ts +shouldFetchOnWindowFocus(): boolean; +``` + +Defined in: [packages/query-core/src/queryObserver.ts:148](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L148) + +Returns whether the observed query is currently stale and configured +(via the `refetchOnWindowFocus` option) to refetch when the window +regains focus. + +#### Returns + +`boolean` + +*** + +### subscribe() + +```ts +subscribe(listener): () => void; +``` + +Defined in: [packages/query-core/src/subscribable.ts:8](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L8) + +#### Parameters + +##### listener + +`QueryObserverListener` + +#### Returns + +```ts +(): void; +``` + +##### Returns + +`void` + +#### Inherited from + +```ts +Subscribable.subscribe +``` + +*** + +### trackProp() + +```ts +trackProp(key): void; +``` + +Defined in: [packages/query-core/src/queryObserver.ts:350](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L350) + +Records that the given `QueryObserverResult` property was read, so a subsequent update only +notifies this observer if a tracked property actually changed. Normally called indirectly via +[QueryObserver#trackResult](#trackresult)'s proxy; exposed directly for adapters that track property +access themselves (e.g. through their own reactivity system) instead of via the proxy. + +#### Parameters + +##### key + +`"error"` | `"data"` | `"isError"` | `"isPending"` | `"isLoading"` | `"isLoadingError"` | `"isRefetchError"` | `"isSuccess"` | `"isPlaceholderData"` | `"status"` | `"dataUpdatedAt"` | `"errorUpdatedAt"` | `"failureCount"` | `"failureReason"` | `"errorUpdateCount"` | `"isFetched"` | `"isFetchedAfterMount"` | `"isFetching"` | `"isInitialLoading"` | `"isPaused"` | `"isRefetching"` | `"isStale"` | `"isEnabled"` | `"refetch"` | `"fetchStatus"` + +#### Returns + +`void` + +*** + +### trackResult() + +```ts +trackResult(result, onPropTracked?): QueryObserverResult; +``` + +Defined in: [packages/query-core/src/queryObserver.ts:331](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L331) + +Wraps a `QueryObserverResult` in a `Proxy` that records which properties are read, via +[QueryObserver#trackProp](#trackprop) (and an optional `onPropTracked` callback). Used by framework +adapters when `notifyOnChangeProps` is not set, to implement its default "only re-render on +properties you actually read" behavior. + +#### Parameters + +##### result + +[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\> + +##### onPropTracked? + +(`key`) => `void` + +#### Returns + +[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\> + +*** + +### updateResult() + +```ts +updateResult(): void; +``` + +Defined in: [packages/query-core/src/queryObserver.ts:735](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L735) + +Recomputes and stores the current result from the current query/options, notifying listeners +if it changed. Framework adapters call this right after subscribing to make sure no query +update was missed in the gap between creating the observer and subscribing to it. + +#### Returns + +`void` diff --git a/docs/framework/solid/reference/functions/QueryClientProvider.md b/docs/framework/solid/reference/functions/QueryClientProvider.md index d0262e5304a..d849b88f87f 100644 --- a/docs/framework/solid/reference/functions/QueryClientProvider.md +++ b/docs/framework/solid/reference/functions/QueryClientProvider.md @@ -7,7 +7,7 @@ title: QueryClientProvider function QueryClientProvider(props): Element; ``` -Defined in: [QueryClientProvider.tsx:95](https://github.com/TanStack/query/blob/main/packages/solid-query/src/QueryClientProvider.tsx#L95) +Defined in: [packages/solid-query/src/QueryClientProvider.tsx:95](https://github.com/TanStack/query/blob/main/packages/solid-query/src/QueryClientProvider.tsx#L95) Use the `QueryClientProvider` component to connect and provide a `QueryClient` to your application. Also calls `client.mount()`/`client.unmount()` as this component mounts/unmounts, which subscribes the client to diff --git a/docs/framework/solid/reference/functions/defaultShouldDehydrateMutation.md b/docs/framework/solid/reference/functions/defaultShouldDehydrateMutation.md new file mode 100644 index 00000000000..940f8745a5d --- /dev/null +++ b/docs/framework/solid/reference/functions/defaultShouldDehydrateMutation.md @@ -0,0 +1,23 @@ +--- +id: defaultShouldDehydrateMutation +title: defaultShouldDehydrateMutation +--- + +```ts +function defaultShouldDehydrateMutation(mutation): boolean; +``` + +Defined in: [packages/query-core/src/hydration.ts:177](https://github.com/TanStack/query/blob/main/packages/query-core/src/hydration.ts#L177) + +The default `shouldDehydrateMutation` predicate used by `dehydrate`. Only dehydrates mutations that are +currently paused (e.g. paused by `networkMode` while offline). + +## Parameters + +### mutation + +[`Mutation`](../classes/Mutation.md) + +## Returns + +`boolean` diff --git a/docs/framework/solid/reference/functions/defaultShouldDehydrateQuery.md b/docs/framework/solid/reference/functions/defaultShouldDehydrateQuery.md new file mode 100644 index 00000000000..abf19439d8a --- /dev/null +++ b/docs/framework/solid/reference/functions/defaultShouldDehydrateQuery.md @@ -0,0 +1,23 @@ +--- +id: defaultShouldDehydrateQuery +title: defaultShouldDehydrateQuery +--- + +```ts +function defaultShouldDehydrateQuery(query): boolean; +``` + +Defined in: [packages/query-core/src/hydration.ts:185](https://github.com/TanStack/query/blob/main/packages/query-core/src/hydration.ts#L185) + +The default `shouldDehydrateQuery` predicate used by `dehydrate`. Only dehydrates queries whose status is +`'success'`. + +## Parameters + +### query + +[`Query`](../classes/Query.md) + +## Returns + +`boolean` diff --git a/docs/framework/solid/reference/functions/dehydrate.md b/docs/framework/solid/reference/functions/dehydrate.md new file mode 100644 index 00000000000..816469e6119 --- /dev/null +++ b/docs/framework/solid/reference/functions/dehydrate.md @@ -0,0 +1,43 @@ +--- +id: dehydrate +title: dehydrate +--- + +```ts +function dehydrate(client, options): DehydratedState; +``` + +Defined in: [packages/query-core/src/hydration.ts:207](https://github.com/TanStack/query/blob/main/packages/query-core/src/hydration.ts#L207) + +Dehydrates a `QueryClient`'s cache (queries and mutations) into a plain, serializable `DehydratedState`, +typically to embed in server-rendered markup and later restore into a client-side `QueryClient` via `hydrate`. +Which queries/mutations are included, and how their data/errors are transformed, is controlled by `options`, +falling back to the client's `dehydrate` default options, and finally to `defaultShouldDehydrateQuery` / +`defaultShouldDehydrateMutation`. + +## Parameters + +### client + +`QueryClient` + +### options + +[`DehydrateOptions`](../interfaces/DehydrateOptions.md) = `{}` + +## Returns + +[`DehydratedState`](../interfaces/DehydratedState.md) + +## Example + +```ts +const queryClient = new QueryClient() + +await queryClient.prefetchQuery({ + queryKey: ['posts'], + queryFn: getPosts, +}) + +const dehydratedState = dehydrate(queryClient) +``` diff --git a/docs/framework/solid/reference/functions/dehydrateQuery.md b/docs/framework/solid/reference/functions/dehydrateQuery.md new file mode 100644 index 00000000000..2314f52fd91 --- /dev/null +++ b/docs/framework/solid/reference/functions/dehydrateQuery.md @@ -0,0 +1,43 @@ +--- +id: dehydrateQuery +title: dehydrateQuery +--- + +```ts +function dehydrateQuery( + query, + serializeData?, + shouldRedactErrors?): DehydratedQuery; +``` + +Defined in: [packages/query-core/src/hydration.ts:148](https://github.com/TanStack/query/blob/main/packages/query-core/src/hydration.ts#L148) + +Dehydrates a single `Query` into a serializable `DehydratedQuery` snapshot. Note that most query config (e.g. +`queryFn`, `staleTime`) is not dehydrated but instead meant to be configured again when consuming the +de/rehydrated data, typically with `useQuery` on the client. If the query is still `pending`, its in-flight +promise is dehydrated too so it can be resumed on the other side instead of re-fetched. + +## Parameters + +### query + +[`Query`](../classes/Query.md) + +The query to dehydrate. + +### serializeData? + +`TransformerFn` + +Optional transform applied to `query.state.data` before it is included in the snapshot. + +### shouldRedactErrors? + +(`error`) => `boolean` + +Optional predicate; if it returns `false` for the promise's rejection error, that +error is kept as-is instead of being redacted. + +## Returns + +`DehydratedQuery` diff --git a/docs/framework/solid/reference/functions/experimental_streamedQuery.md b/docs/framework/solid/reference/functions/experimental_streamedQuery.md new file mode 100644 index 00000000000..4c490322d60 --- /dev/null +++ b/docs/framework/solid/reference/functions/experimental_streamedQuery.md @@ -0,0 +1,52 @@ +--- +id: experimental_streamedQuery +title: experimental_streamedQuery +--- + +```ts +function experimental_streamedQuery(streamFn): QueryFunction; +``` + +Defined in: [packages/query-core/src/streamedQuery.ts:75](https://github.com/TanStack/query/blob/main/packages/query-core/src/streamedQuery.ts#L75) + +This is a helper function to create a query function that streams data from an AsyncIterable. +Data will be an Array of all the chunks received. +The query will be in a 'pending' state until the first chunk of data is received, but will go to 'success' after that. +The query will stay in fetchStatus 'fetching' until the stream ends. + +## Type Parameters + +### TQueryFnData + +`TQueryFnData` = `unknown` + +### TData + +`TData` = `TQueryFnData`[] + +### TQueryKey + +`TQueryKey` *extends* readonly `unknown`[] = readonly `unknown`[] + +## Parameters + +### streamFn + +`StreamedQueryParams`\<`TQueryFnData`, `TData`, `TQueryKey`\> + +The function that returns an AsyncIterable to stream data from. + +## Returns + +[`QueryFunction`](../type-aliases/QueryFunction.md)\<`TData`, `TQueryKey`\> + +## Example + +```ts +await queryClient.query({ + queryKey: ['data'], + queryFn: streamedQuery({ + streamFn: fetchDataInChunks, + }), +}) +``` diff --git a/docs/framework/solid/reference/functions/hashKey.md b/docs/framework/solid/reference/functions/hashKey.md new file mode 100644 index 00000000000..dc774c032ce --- /dev/null +++ b/docs/framework/solid/reference/functions/hashKey.md @@ -0,0 +1,30 @@ +--- +id: hashKey +title: hashKey +--- + +```ts +function hashKey(queryKey): string; +``` + +Defined in: [packages/query-core/src/utils.ts:284](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L284) + +Default query & mutation keys hash function. +Hashes the value into a stable hash. + +## Parameters + +### queryKey + +readonly `unknown`[] + +## Returns + +`string` + +## Example + +```ts +// Object keys are sorted, so key order doesn't affect the hash: +hashKey(['todos', { page: 1, filter: 'done' }]) // === '["todos",{"filter":"done","page":1}]' +``` diff --git a/docs/framework/solid/reference/functions/hydrate.md b/docs/framework/solid/reference/functions/hydrate.md new file mode 100644 index 00000000000..0283d46b709 --- /dev/null +++ b/docs/framework/solid/reference/functions/hydrate.md @@ -0,0 +1,49 @@ +--- +id: hydrate +title: hydrate +--- + +```ts +function hydrate( + client, + dehydratedState, + options?): void; +``` + +Defined in: [packages/query-core/src/hydration.ts:264](https://github.com/TanStack/query/blob/main/packages/query-core/src/hydration.ts#L264) + +Restores a `DehydratedState` (as produced by `dehydrate`) into a `QueryClient`'s cache, typically to seed the +client with data already fetched on the server. `mutations` and `queries` are each optional on `dehydratedState`. +Queries not yet in the cache are built from the dehydrated snapshot; queries that already exist are only updated +when the dehydrated data is newer than what's already cached. Newly built queries have their `fetchStatus` reset +to `'idle'` so they don't hydrate stuck in a fetching state. If a dehydrated query still had an in-flight +promise, it is resumed via `query.fetch()` (reusing that promise as `initialPromise`) rather than re-invoking +`queryFn`. + +## Parameters + +### client + +`QueryClient` + +### dehydratedState + +`Partial`\<[`DehydratedState`](../interfaces/DehydratedState.md)\> + +### options? + +[`HydrateOptions`](../interfaces/HydrateOptions.md) + +## Returns + +`void` + +## Example + +```ts +// dehydratedState was produced by `dehydrate` on the server +// and sent to the client, e.g. embedded in server-rendered markup. +const queryClient = new QueryClient() + +hydrate(queryClient, dehydratedState) +``` diff --git a/docs/framework/solid/reference/functions/infiniteQueryOptions.md b/docs/framework/solid/reference/functions/infiniteQueryOptions.md index c2082f957d1..6104be4928c 100644 --- a/docs/framework/solid/reference/functions/infiniteQueryOptions.md +++ b/docs/framework/solid/reference/functions/infiniteQueryOptions.md @@ -11,7 +11,7 @@ redirect_from: function infiniteQueryOptions(options): InfiniteQueryOptions & object & QueryKeyWithDataTag, TError>; ``` -Defined in: [infiniteQueryOptions.ts:105](https://github.com/TanStack/query/blob/main/packages/solid-query/src/infiniteQueryOptions.ts#L105) +Defined in: [packages/solid-query/src/infiniteQueryOptions.ts:105](https://github.com/TanStack/query/blob/main/packages/solid-query/src/infiniteQueryOptions.ts#L105) You can generally pass everything to `infiniteQueryOptions` that you can also pass to `useInfiniteQuery`. These options can be shared across hooks and imperative APIs such as `queryClient.infiniteQuery`. @@ -31,7 +31,7 @@ This overload is selected when `initialData` is set. #### TData -`TData` = `InfiniteData`\<`TQueryFnData`, `unknown`\> +`TData` = [`InfiniteData`](../interfaces/InfiniteData.md)\<`TQueryFnData`, `unknown`\> #### TQueryKey @@ -51,7 +51,7 @@ The [DefinedInitialDataInfiniteOptions](../type-aliases/DefinedInitialDataInfini ### Returns -[`InfiniteQueryOptions`](../interfaces/InfiniteQueryOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`, `TPageParam`\> & `object` & `QueryKeyWithDataTag`\<`TQueryKey`, `InfiniteData`\<`TQueryFnData`, `unknown`\>, `TError`\> +[`InfiniteQueryOptions`](../interfaces/InfiniteQueryOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`, `TPageParam`\> & `object` & [`QueryKeyWithDataTag`](../type-aliases/QueryKeyWithDataTag.md)\<`TQueryKey`, [`InfiniteData`](../interfaces/InfiniteData.md)\<`TQueryFnData`, `unknown`\>, `TError`\> The same options object, typed so that `queryKey` carries the inferred data type. @@ -97,7 +97,7 @@ function Projects() { function infiniteQueryOptions(options): InfiniteQueryOptions & object & QueryKeyWithDataTag, TError>; ``` -Defined in: [infiniteQueryOptions.ts:174](https://github.com/TanStack/query/blob/main/packages/solid-query/src/infiniteQueryOptions.ts#L174) +Defined in: [packages/solid-query/src/infiniteQueryOptions.ts:174](https://github.com/TanStack/query/blob/main/packages/solid-query/src/infiniteQueryOptions.ts#L174) You can generally pass everything to `infiniteQueryOptions` that you can also pass to `useInfiniteQuery`. These options can be shared across hooks and imperative APIs such as `queryClient.infiniteQuery`. @@ -115,7 +115,7 @@ These options can be shared across hooks and imperative APIs such as `queryClien #### TData -`TData` = `InfiniteData`\<`TQueryFnData`, `unknown`\> +`TData` = [`InfiniteData`](../interfaces/InfiniteData.md)\<`TQueryFnData`, `unknown`\> #### TQueryKey @@ -135,7 +135,7 @@ The [UndefinedInitialDataInfiniteOptions](../type-aliases/UndefinedInitialDataIn ### Returns -[`InfiniteQueryOptions`](../interfaces/InfiniteQueryOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`, `TPageParam`\> & `object` & `QueryKeyWithDataTag`\<`TQueryKey`, `InfiniteData`\<`TQueryFnData`, `unknown`\>, `TError`\> +[`InfiniteQueryOptions`](../interfaces/InfiniteQueryOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`, `TPageParam`\> & `object` & [`QueryKeyWithDataTag`](../type-aliases/QueryKeyWithDataTag.md)\<`TQueryKey`, [`InfiniteData`](../interfaces/InfiniteData.md)\<`TQueryFnData`, `unknown`\>, `TError`\> The same options object, typed so that `queryKey` carries the inferred data type. diff --git a/docs/framework/solid/reference/functions/isCancelledError.md b/docs/framework/solid/reference/functions/isCancelledError.md new file mode 100644 index 00000000000..c8f57c4b94d --- /dev/null +++ b/docs/framework/solid/reference/functions/isCancelledError.md @@ -0,0 +1,24 @@ +--- +id: isCancelledError +title: isCancelledError +--- + +```ts +function isCancelledError(value): value is CancelledError; +``` + +Defined in: [packages/query-core/src/retryer.ts:90](https://github.com/TanStack/query/blob/main/packages/query-core/src/retryer.ts#L90) + +## Parameters + +### value + +`any` + +## Returns + +`value is CancelledError` + +## Deprecated + +Use instanceof `CancelledError` instead. diff --git a/docs/framework/solid/reference/functions/keepPreviousData.md b/docs/framework/solid/reference/functions/keepPreviousData.md new file mode 100644 index 00000000000..6a84f4c5970 --- /dev/null +++ b/docs/framework/solid/reference/functions/keepPreviousData.md @@ -0,0 +1,40 @@ +--- +id: keepPreviousData +title: keepPreviousData +--- + +```ts +function keepPreviousData(previousData): T | undefined; +``` + +Defined in: [packages/query-core/src/utils.ts:493](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L493) + +Intended to be passed as a query's `placeholderData` option, for example +`placeholderData: keepPreviousData`. Instead of resetting the query's data to `undefined` while a new +query key is fetching, it keeps displaying the previously fetched data until the new data arrives. + +## Type Parameters + +### T + +`T` + +## Parameters + +### previousData + +`T` | `undefined` + +## Returns + +`T` \| `undefined` + +## Example + +```ts +new QueryObserver(queryClient, { + queryKey: ['posts', page], + queryFn: () => fetchPosts(page), + placeholderData: keepPreviousData, +}) +``` diff --git a/docs/framework/solid/reference/functions/matchMutation.md b/docs/framework/solid/reference/functions/matchMutation.md new file mode 100644 index 00000000000..40210da4cf1 --- /dev/null +++ b/docs/framework/solid/reference/functions/matchMutation.md @@ -0,0 +1,38 @@ +--- +id: matchMutation +title: matchMutation +--- + +```ts +function matchMutation(filters, mutation): boolean; +``` + +Defined in: [packages/query-core/src/utils.ts:237](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L237) + +Checks whether a mutation matches the given [MutationFilters](../interfaces/MutationFilters.md). +Every filter that is specified must match; filters that are left unspecified are ignored. +If a `mutationKey` filter is provided but the mutation has no `mutationKey` of its own, it does not match. + +## Parameters + +### filters + +[`MutationFilters`](../interfaces/MutationFilters.md) + +### mutation + +[`Mutation`](../classes/Mutation.md)\<`any`, `any`\> + +## Returns + +`boolean` + +## Example + +```ts +const mutationCache = queryClient.getMutationCache() + +const matchingMutations = mutationCache + .getAll() + .filter((mutation) => matchMutation({ mutationKey: ['addPost'] }, mutation)) +``` diff --git a/docs/framework/solid/reference/functions/matchQuery.md b/docs/framework/solid/reference/functions/matchQuery.md new file mode 100644 index 00000000000..4c54b2df995 --- /dev/null +++ b/docs/framework/solid/reference/functions/matchQuery.md @@ -0,0 +1,37 @@ +--- +id: matchQuery +title: matchQuery +--- + +```ts +function matchQuery(filters, query): boolean; +``` + +Defined in: [packages/query-core/src/utils.ts:175](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L175) + +Checks whether a query matches the given [QueryFilters](../interfaces/QueryFilters.md). +Every filter that is specified must match; filters that are left unspecified are ignored. + +## Parameters + +### filters + +[`QueryFilters`](../interfaces/QueryFilters.md) + +### query + +[`Query`](../classes/Query.md)\<`any`, `any`, `any`, `any`\> + +## Returns + +`boolean` + +## Example + +```ts +const queryCache = queryClient.getQueryCache() + +const matchingQueries = queryCache + .getAll() + .filter((query) => matchQuery({ queryKey: ['posts'] }, query)) +``` diff --git a/docs/framework/solid/reference/functions/mutationOptions.md b/docs/framework/solid/reference/functions/mutationOptions.md index a766fabe9b2..a378539e67b 100644 --- a/docs/framework/solid/reference/functions/mutationOptions.md +++ b/docs/framework/solid/reference/functions/mutationOptions.md @@ -11,7 +11,7 @@ redirect_from: function mutationOptions(options): WithRequired, "mutationKey">; ``` -Defined in: [mutationOptions.ts:33](https://github.com/TanStack/query/blob/main/packages/solid-query/src/mutationOptions.ts#L33) +Defined in: [packages/solid-query/src/mutationOptions.ts:33](https://github.com/TanStack/query/blob/main/packages/solid-query/src/mutationOptions.ts#L33) You can generally pass everything to `mutationOptions` that you can also pass to `useMutation`. A `mutationKey` is required on this overload so the mutation can be looked up later, e.g. with @@ -39,14 +39,14 @@ You can generally pass everything to `mutationOptions` that you can also pass to #### options -`WithRequired`\<[`MutationOptions`](../interfaces/MutationOptions.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\>, `"mutationKey"`\> +[`WithRequired`](../type-aliases/WithRequired.md)\<[`MutationOptions`](../interfaces/MutationOptions.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\>, `"mutationKey"`\> The mutation options to use, identical to what you'd pass to `useMutation`, with a required `mutationKey`. ### Returns -`WithRequired`\<[`MutationOptions`](../interfaces/MutationOptions.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\>, `"mutationKey"`\> +[`WithRequired`](../type-aliases/WithRequired.md)\<[`MutationOptions`](../interfaces/MutationOptions.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\>, `"mutationKey"`\> The same options object, unchanged. @@ -80,7 +80,7 @@ function SavingIndicator() { function mutationOptions(options): Omit, "mutationKey">; ``` -Defined in: [mutationOptions.ts:73](https://github.com/TanStack/query/blob/main/packages/solid-query/src/mutationOptions.ts#L73) +Defined in: [packages/solid-query/src/mutationOptions.ts:73](https://github.com/TanStack/query/blob/main/packages/solid-query/src/mutationOptions.ts#L73) You can generally pass everything to `mutationOptions` that you can also pass to `useMutation`. No `mutationKey` is required on this overload — use this when you don't need to target the mutation via a diff --git a/docs/framework/solid/reference/functions/noop.md b/docs/framework/solid/reference/functions/noop.md new file mode 100644 index 00000000000..01fb409f4e9 --- /dev/null +++ b/docs/framework/solid/reference/functions/noop.md @@ -0,0 +1,32 @@ +--- +id: noop +title: noop +--- + +## Call Signature + +```ts +function noop(): void; +``` + +Defined in: [packages/query-core/src/utils.ts:119](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L119) + +A function that does nothing. + +### Returns + +`void` + +## Call Signature + +```ts +function noop(): undefined; +``` + +Defined in: [packages/query-core/src/utils.ts:120](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L120) + +A function that does nothing. + +### Returns + +`undefined` diff --git a/docs/framework/solid/reference/functions/partialMatchKey.md b/docs/framework/solid/reference/functions/partialMatchKey.md new file mode 100644 index 00000000000..4db67323e9b --- /dev/null +++ b/docs/framework/solid/reference/functions/partialMatchKey.md @@ -0,0 +1,26 @@ +--- +id: partialMatchKey +title: partialMatchKey +--- + +```ts +function partialMatchKey(a, b): boolean; +``` + +Defined in: [packages/query-core/src/utils.ts:300](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L300) + +Checks if key `b` partially matches with key `a`. + +## Parameters + +### a + +readonly `unknown`[] + +### b + +readonly `unknown`[] + +## Returns + +`boolean` diff --git a/docs/framework/solid/reference/functions/queryOptions.md b/docs/framework/solid/reference/functions/queryOptions.md index 10447972e7a..ca783a42fd0 100644 --- a/docs/framework/solid/reference/functions/queryOptions.md +++ b/docs/framework/solid/reference/functions/queryOptions.md @@ -11,7 +11,7 @@ redirect_from: function queryOptions(options): QueryOptions & object & QueryKeyWithDataTag; ``` -Defined in: [queryOptions.ts:89](https://github.com/TanStack/query/blob/main/packages/solid-query/src/queryOptions.ts#L89) +Defined in: [packages/solid-query/src/queryOptions.ts:89](https://github.com/TanStack/query/blob/main/packages/solid-query/src/queryOptions.ts#L89) You can generally pass everything to `queryOptions` that you can also pass to `useQuery`. These options can be shared across hooks and imperative APIs such as `queryClient.query`. `options.queryKey` is required and @@ -47,7 +47,7 @@ The [DefinedInitialDataOptions](../type-aliases/DefinedInitialDataOptions.md) to ### Returns -[`QueryOptions`](../interfaces/QueryOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`\> & `object` & `QueryKeyWithDataTag`\<`TQueryKey`, `TQueryFnData`, `TError`\> +[`QueryOptions`](../interfaces/QueryOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`\> & `object` & [`QueryKeyWithDataTag`](../type-aliases/QueryKeyWithDataTag.md)\<`TQueryKey`, `TQueryFnData`, `TError`\> The same options object, typed so that `queryKey` carries the inferred data type. @@ -89,7 +89,7 @@ function Posts() { function queryOptions(options): QueryOptions & object & QueryKeyWithDataTag; ``` -Defined in: [queryOptions.ts:139](https://github.com/TanStack/query/blob/main/packages/solid-query/src/queryOptions.ts#L139) +Defined in: [packages/solid-query/src/queryOptions.ts:139](https://github.com/TanStack/query/blob/main/packages/solid-query/src/queryOptions.ts#L139) You can generally pass everything to `queryOptions` that you can also pass to `useQuery`. These options can be shared across hooks and imperative APIs such as `queryClient.query`. `options.queryKey` is required and @@ -123,7 +123,7 @@ The [UndefinedInitialDataOptions](../type-aliases/UndefinedInitialDataOptions.md ### Returns -[`QueryOptions`](../interfaces/QueryOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`\> & `object` & `QueryKeyWithDataTag`\<`TQueryKey`, `TQueryFnData`, `TError`\> +[`QueryOptions`](../interfaces/QueryOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`\> & `object` & [`QueryKeyWithDataTag`](../type-aliases/QueryKeyWithDataTag.md)\<`TQueryKey`, `TQueryFnData`, `TError`\> The same options object, typed so that `queryKey` carries the inferred data type. diff --git a/docs/framework/solid/reference/functions/replaceEqualDeep.md b/docs/framework/solid/reference/functions/replaceEqualDeep.md new file mode 100644 index 00000000000..6a81c3907fb --- /dev/null +++ b/docs/framework/solid/reference/functions/replaceEqualDeep.md @@ -0,0 +1,41 @@ +--- +id: replaceEqualDeep +title: replaceEqualDeep +--- + +```ts +function replaceEqualDeep( + a, + b, + depth?): T; +``` + +Defined in: [packages/query-core/src/utils.ts:339](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L339) + +This function returns `a` if `b` is deeply equal. +If not, it will replace any deeply equal children of `b` with those of `a`. +This can be used for structural sharing between JSON values for example. + +## Type Parameters + +### T + +`T` + +## Parameters + +### a + +`unknown` + +### b + +`T` + +### depth? + +`number` + +## Returns + +`T` diff --git a/docs/framework/solid/reference/functions/shouldThrowError.md b/docs/framework/solid/reference/functions/shouldThrowError.md new file mode 100644 index 00000000000..1f1e62a8d0e --- /dev/null +++ b/docs/framework/solid/reference/functions/shouldThrowError.md @@ -0,0 +1,45 @@ +--- +id: shouldThrowError +title: shouldThrowError +--- + +```ts +function shouldThrowError(throwOnError, params): boolean; +``` + +Defined in: [packages/query-core/src/utils.ts:576](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L576) + +Resolves a `throwOnError` option to a boolean. +If `throwOnError` is a function, it is called with `params` (e.g. the error and, depending on the caller, +additional context such as the query or mutation) and its result is returned, allowing the throwing +behavior to be decided per error. Otherwise, `throwOnError` itself is coerced to a boolean (`undefined` +resolves to `false`). + +## Type Parameters + +### T + +`T` *extends* (...`args`) => `boolean` + +## Parameters + +### throwOnError + +`boolean` | `T` | `undefined` + +### params + +`Parameters`\<`T`\> + +## Returns + +`boolean` + +## Example + +```ts +const throwOnError = + query.state.error && typeof options.throwOnError === 'function' + ? shouldThrowError(options.throwOnError, [query.state.error, query]) + : options.throwOnError +``` diff --git a/docs/framework/solid/reference/functions/useInfiniteQuery.md b/docs/framework/solid/reference/functions/useInfiniteQuery.md index bf7f9687992..7fb3ab2654a 100644 --- a/docs/framework/solid/reference/functions/useInfiniteQuery.md +++ b/docs/framework/solid/reference/functions/useInfiniteQuery.md @@ -11,7 +11,7 @@ redirect_from: function useInfiniteQuery(options, queryClient?): DefinedUseInfiniteQueryResult; ``` -Defined in: [useInfiniteQuery.ts:70](https://github.com/TanStack/query/blob/main/packages/solid-query/src/useInfiniteQuery.ts#L70) +Defined in: [packages/solid-query/src/useInfiniteQuery.ts:70](https://github.com/TanStack/query/blob/main/packages/solid-query/src/useInfiniteQuery.ts#L70) The options for `useInfiniteQuery` are identical to `useQuery`, with the addition of `initialPageParam`, `getNextPageParam`, `getPreviousPageParam`, and `maxPages`. @@ -30,7 +30,7 @@ This overload is selected when `initialData` is set. #### TData -`TData` = `InfiniteData`\<`TQueryFnData`, `unknown`\> +`TData` = [`InfiniteData`](../interfaces/InfiniteData.md)\<`TQueryFnData`, `unknown`\> #### TQueryKey @@ -111,7 +111,7 @@ function Projects() { function useInfiniteQuery(options, queryClient?): UseInfiniteQueryResult; ``` -Defined in: [useInfiniteQuery.ts:189](https://github.com/TanStack/query/blob/main/packages/solid-query/src/useInfiniteQuery.ts#L189) +Defined in: [packages/solid-query/src/useInfiniteQuery.ts:189](https://github.com/TanStack/query/blob/main/packages/solid-query/src/useInfiniteQuery.ts#L189) The options for `useInfiniteQuery` are identical to `useQuery`, with the addition of `initialPageParam`, `getNextPageParam`, `getPreviousPageParam`, and `maxPages`. @@ -128,7 +128,7 @@ The options for `useInfiniteQuery` are identical to `useQuery`, with the additio #### TData -`TData` = `InfiniteData`\<`TQueryFnData`, `unknown`\> +`TData` = [`InfiniteData`](../interfaces/InfiniteData.md)\<`TQueryFnData`, `unknown`\> #### TQueryKey diff --git a/docs/framework/solid/reference/functions/useIsFetching.md b/docs/framework/solid/reference/functions/useIsFetching.md index 26aa2be7f6f..0e2005f6078 100644 --- a/docs/framework/solid/reference/functions/useIsFetching.md +++ b/docs/framework/solid/reference/functions/useIsFetching.md @@ -9,7 +9,7 @@ redirect_from: function useIsFetching(filters?, queryClient?): Accessor; ``` -Defined in: [useIsFetching.ts:29](https://github.com/TanStack/query/blob/main/packages/solid-query/src/useIsFetching.ts#L29) +Defined in: [packages/solid-query/src/useIsFetching.ts:29](https://github.com/TanStack/query/blob/main/packages/solid-query/src/useIsFetching.ts#L29) The `useIsFetching` hook returns the `number` of the queries that your application is loading or fetching in the background (useful for app-wide loading indicators). @@ -18,9 +18,9 @@ in the background (useful for app-wide loading indicators). ### filters? -`Accessor`\<`QueryFilters`\\> +`Accessor`\<[`QueryFilters`](../interfaces/QueryFilters.md)\\> -An accessor returning the QueryFilters to narrow down the matched queries. +An accessor returning the [QueryFilters](../interfaces/QueryFilters.md) to narrow down the matched queries. ### queryClient? diff --git a/docs/framework/solid/reference/functions/useIsMutating.md b/docs/framework/solid/reference/functions/useIsMutating.md index 041fb1b93e4..5885712474d 100644 --- a/docs/framework/solid/reference/functions/useIsMutating.md +++ b/docs/framework/solid/reference/functions/useIsMutating.md @@ -9,7 +9,7 @@ redirect_from: function useIsMutating(filters?, queryClient?): Accessor; ``` -Defined in: [useIsMutating.ts:28](https://github.com/TanStack/query/blob/main/packages/solid-query/src/useIsMutating.ts#L28) +Defined in: [packages/solid-query/src/useIsMutating.ts:28](https://github.com/TanStack/query/blob/main/packages/solid-query/src/useIsMutating.ts#L28) The `useIsMutating` hook returns the `number` of mutations that your application currently has `pending` (useful for app-wide loading indicators). @@ -18,9 +18,9 @@ The `useIsMutating` hook returns the `number` of mutations that your application ### filters? -`Accessor`\<`MutationFilters`\<`unknown`, `Error`, `unknown`, `unknown`\>\> +`Accessor`\<[`MutationFilters`](../interfaces/MutationFilters.md)\<`unknown`, `Error`, `unknown`, `unknown`\>\> -An accessor returning the MutationFilters to narrow down the matched mutations. +An accessor returning the [MutationFilters](../interfaces/MutationFilters.md) to narrow down the matched mutations. ### queryClient? diff --git a/docs/framework/solid/reference/functions/useIsRestoring.md b/docs/framework/solid/reference/functions/useIsRestoring.md index ee789d94aab..1cd2ab60ad3 100644 --- a/docs/framework/solid/reference/functions/useIsRestoring.md +++ b/docs/framework/solid/reference/functions/useIsRestoring.md @@ -7,7 +7,7 @@ title: useIsRestoring function useIsRestoring(): Accessor; ``` -Defined in: [isRestoring.ts:13](https://github.com/TanStack/query/blob/main/packages/solid-query/src/isRestoring.ts#L13) +Defined in: [packages/solid-query/src/isRestoring.ts:13](https://github.com/TanStack/query/blob/main/packages/solid-query/src/isRestoring.ts#L13) If you are using `PersistQueryClientProvider`, you can also use the `useIsRestoring` hook alongside it to check if a restore is currently in progress. `useQuery` and friends also check this internally to avoid diff --git a/docs/framework/solid/reference/functions/useMutation.md b/docs/framework/solid/reference/functions/useMutation.md index 472cb852825..2594a8a03c5 100644 --- a/docs/framework/solid/reference/functions/useMutation.md +++ b/docs/framework/solid/reference/functions/useMutation.md @@ -9,7 +9,7 @@ redirect_from: function useMutation(options, queryClient?): UseMutationResult; ``` -Defined in: [useMutation.ts:173](https://github.com/TanStack/query/blob/main/packages/solid-query/src/useMutation.ts#L173) +Defined in: [packages/solid-query/src/useMutation.ts:173](https://github.com/TanStack/query/blob/main/packages/solid-query/src/useMutation.ts#L173) ## Type Parameters diff --git a/docs/framework/solid/reference/functions/useMutationState.md b/docs/framework/solid/reference/functions/useMutationState.md index f6fa24851c8..266ee912360 100644 --- a/docs/framework/solid/reference/functions/useMutationState.md +++ b/docs/framework/solid/reference/functions/useMutationState.md @@ -9,21 +9,21 @@ redirect_from: function useMutationState(options, queryClient?): Accessor; ``` -Defined in: [useMutationState.ts:124](https://github.com/TanStack/query/blob/main/packages/solid-query/src/useMutationState.ts#L124) +Defined in: [packages/solid-query/src/useMutationState.ts:124](https://github.com/TanStack/query/blob/main/packages/solid-query/src/useMutationState.ts#L124) `useMutationState` is a hook that gives you access to all mutations in the `MutationCache`. You can pass -`filters` (MutationFilters) to narrow down your mutations, and `select` to transform the mutation +`filters` ([MutationFilters](../interfaces/MutationFilters.md)) to narrow down your mutations, and `select` to transform the mutation state. ## Type Parameters ### TResult -`TResult` = `MutationState`\<`unknown`, `Error`, `unknown`, `unknown`\> +`TResult` = [`MutationState`](../interfaces/MutationState.md)\<`unknown`, `Error`, `unknown`, `unknown`\> ### TMutation -`TMutation` *extends* `Mutation`\<`any`, `any`, `any`, `any`\> = `MutationTypeFromResult`\<`TResult`\> +`TMutation` *extends* [`Mutation`](../classes/Mutation.md)\<`any`, `any`, `any`, `any`\> = `MutationTypeFromResult`\<`TResult`\> ## Parameters diff --git a/docs/framework/solid/reference/functions/useQueries.md b/docs/framework/solid/reference/functions/useQueries.md index a8f163d5bab..949fb4c72c5 100644 --- a/docs/framework/solid/reference/functions/useQueries.md +++ b/docs/framework/solid/reference/functions/useQueries.md @@ -9,7 +9,7 @@ redirect_from: function useQueries(queriesOptions, queryClient?): TCombinedResult; ``` -Defined in: [useQueries.ts:274](https://github.com/TanStack/query/blob/main/packages/solid-query/src/useQueries.ts#L274) +Defined in: [packages/solid-query/src/useQueries.ts:274](https://github.com/TanStack/query/blob/main/packages/solid-query/src/useQueries.ts#L274) The `useQueries` hook can be used to fetch a variable number of queries. @@ -38,31 +38,31 @@ previously rendered queries, because the number of queries can differ between re `TCombinedResult` *extends* \| \[\] \| \[ - \| `QueryObserverRefetchErrorResult`\<`unknown`, `Error`\> - \| `QueryObserverSuccessResult`\<`unknown`, `Error`\> - \| `QueryObserverLoadingErrorResult`\<`unknown`, `Error`\> - \| `QueryObserverLoadingResult`\<`unknown`, `Error`\> - \| `QueryObserverPendingResult`\<`unknown`, `Error`\> - \| `QueryObserverPlaceholderResult`\<`unknown`, `Error`\> - \| `QueryObserverRefetchErrorResult`\<`unknown`, `unknown`\> - \| `QueryObserverSuccessResult`\<`unknown`, `unknown`\> - \| `QueryObserverLoadingErrorResult`\<`unknown`, `unknown`\> - \| `QueryObserverLoadingResult`\<`unknown`, `unknown`\> - \| `QueryObserverPendingResult`\<`unknown`, `unknown`\> - \| `QueryObserverPlaceholderResult`\<`unknown`, `unknown`\>\] + \| [`QueryObserverRefetchErrorResult`](../interfaces/QueryObserverRefetchErrorResult.md)\<`unknown`, `Error`\> + \| [`QueryObserverSuccessResult`](../interfaces/QueryObserverSuccessResult.md)\<`unknown`, `Error`\> + \| [`QueryObserverLoadingErrorResult`](../interfaces/QueryObserverLoadingErrorResult.md)\<`unknown`, `Error`\> + \| [`QueryObserverLoadingResult`](../interfaces/QueryObserverLoadingResult.md)\<`unknown`, `Error`\> + \| [`QueryObserverPendingResult`](../interfaces/QueryObserverPendingResult.md)\<`unknown`, `Error`\> + \| [`QueryObserverPlaceholderResult`](../interfaces/QueryObserverPlaceholderResult.md)\<`unknown`, `Error`\> + \| [`QueryObserverRefetchErrorResult`](../interfaces/QueryObserverRefetchErrorResult.md)\<`unknown`, `unknown`\> + \| [`QueryObserverSuccessResult`](../interfaces/QueryObserverSuccessResult.md)\<`unknown`, `unknown`\> + \| [`QueryObserverLoadingErrorResult`](../interfaces/QueryObserverLoadingErrorResult.md)\<`unknown`, `unknown`\> + \| [`QueryObserverLoadingResult`](../interfaces/QueryObserverLoadingResult.md)\<`unknown`, `unknown`\> + \| [`QueryObserverPendingResult`](../interfaces/QueryObserverPendingResult.md)\<`unknown`, `unknown`\> + \| [`QueryObserverPlaceholderResult`](../interfaces/QueryObserverPlaceholderResult.md)\<`unknown`, `unknown`\>\] \| ( - \| `QueryObserverRefetchErrorResult`\<`unknown`, `Error`\> - \| `QueryObserverSuccessResult`\<`unknown`, `Error`\> - \| `QueryObserverLoadingErrorResult`\<`unknown`, `Error`\> - \| `QueryObserverLoadingResult`\<`unknown`, `Error`\> - \| `QueryObserverPendingResult`\<`unknown`, `Error`\> - \| `QueryObserverPlaceholderResult`\<`unknown`, `Error`\> - \| `QueryObserverRefetchErrorResult`\<`unknown`, `unknown`\> - \| `QueryObserverSuccessResult`\<`unknown`, `unknown`\> - \| `QueryObserverLoadingErrorResult`\<`unknown`, `unknown`\> - \| `QueryObserverLoadingResult`\<`unknown`, `unknown`\> - \| `QueryObserverPendingResult`\<`unknown`, `unknown`\> - \| `QueryObserverPlaceholderResult`\<`unknown`, `unknown`\>)[] = `T` *extends* \[\] ? \[\] : `T` *extends* \[`Head`\] ? \[`GetResults`\<`Head`\>\] : `T` *extends* \[`Head`, `...Tail[]`\] ? \[`...Tail[]`\] *extends* \[\] ? \[\] : \[`...Tail[]`\] *extends* \[`Head`\] ? \[`GetResults`\<`Head`\>, `GetResults`\<`Head`\>\] : \[`...Tail[]`\] *extends* \[`Head`, `...Tail[]`\] ? \[`...Tail[]`\] *extends* \[\] ? \[\] : \[`...Tail[]`\] *extends* \[`Head`\] ? \[`GetResults`\<`Head`\>, `GetResults`\<`Head`\>, `GetResults`\<`Head`\>\] : \[`...Tail[]`\] *extends* \[`Head`, `...Tail[]`\] ? \[`...(...)[]`\] *extends* \[\] ? \[\] : ... *extends* ... ? ... : ... : \[`...{ [K in (...)]: (...) }[]`\] : \[...\{ \[K in string \| number \| symbol\]: GetResults\\]\> \}\[\]\] : \{ \[K in string \| number \| symbol\]: GetResults\\]\> \} + \| [`QueryObserverRefetchErrorResult`](../interfaces/QueryObserverRefetchErrorResult.md)\<`unknown`, `Error`\> + \| [`QueryObserverSuccessResult`](../interfaces/QueryObserverSuccessResult.md)\<`unknown`, `Error`\> + \| [`QueryObserverLoadingErrorResult`](../interfaces/QueryObserverLoadingErrorResult.md)\<`unknown`, `Error`\> + \| [`QueryObserverLoadingResult`](../interfaces/QueryObserverLoadingResult.md)\<`unknown`, `Error`\> + \| [`QueryObserverPendingResult`](../interfaces/QueryObserverPendingResult.md)\<`unknown`, `Error`\> + \| [`QueryObserverPlaceholderResult`](../interfaces/QueryObserverPlaceholderResult.md)\<`unknown`, `Error`\> + \| [`QueryObserverRefetchErrorResult`](../interfaces/QueryObserverRefetchErrorResult.md)\<`unknown`, `unknown`\> + \| [`QueryObserverSuccessResult`](../interfaces/QueryObserverSuccessResult.md)\<`unknown`, `unknown`\> + \| [`QueryObserverLoadingErrorResult`](../interfaces/QueryObserverLoadingErrorResult.md)\<`unknown`, `unknown`\> + \| [`QueryObserverLoadingResult`](../interfaces/QueryObserverLoadingResult.md)\<`unknown`, `unknown`\> + \| [`QueryObserverPendingResult`](../interfaces/QueryObserverPendingResult.md)\<`unknown`, `unknown`\> + \| [`QueryObserverPlaceholderResult`](../interfaces/QueryObserverPlaceholderResult.md)\<`unknown`, `unknown`\>)[] = `T` *extends* \[\] ? \[\] : `T` *extends* \[`Head`\] ? \[`GetResults`\<`Head`\>\] : `T` *extends* \[`Head`, `...Tail[]`\] ? \[`...Tail[]`\] *extends* \[\] ? \[\] : \[`...Tail[]`\] *extends* \[`Head`\] ? \[`GetResults`\<`Head`\>, `GetResults`\<`Head`\>\] : \[`...Tail[]`\] *extends* \[`Head`, `...Tail[]`\] ? \[`...Tail[]`\] *extends* \[\] ? \[\] : \[`...Tail[]`\] *extends* \[`Head`\] ? \[`GetResults`\<`Head`\>, `GetResults`\<`Head`\>, `GetResults`\<`Head`\>\] : \[`...Tail[]`\] *extends* \[`Head`, `...Tail[]`\] ? \[`...(...)[]`\] *extends* \[\] ? \[\] : ... *extends* ... ? ... : ... : \[`...{ [K in (...)]: (...) }[]`\] : \[...\{ \[K in string \| number \| symbol\]: GetResults\\]\> \}\[\]\] : \{ \[K in string \| number \| symbol\]: GetResults\\]\> \} ## Parameters diff --git a/docs/framework/solid/reference/functions/useQuery.md b/docs/framework/solid/reference/functions/useQuery.md index c92dfc92424..e4b3f8b0e49 100644 --- a/docs/framework/solid/reference/functions/useQuery.md +++ b/docs/framework/solid/reference/functions/useQuery.md @@ -11,7 +11,7 @@ redirect_from: function useQuery(options, queryClient?): UseQueryResult; ``` -Defined in: [useQuery.ts:178](https://github.com/TanStack/query/blob/main/packages/solid-query/src/useQuery.ts#L178) +Defined in: [packages/solid-query/src/useQuery.ts:178](https://github.com/TanStack/query/blob/main/packages/solid-query/src/useQuery.ts#L178) ### Type Parameters @@ -212,7 +212,7 @@ function Posts() { function useQuery(options, queryClient?): DefinedUseQueryResult; ``` -Defined in: [useQuery.ts:226](https://github.com/TanStack/query/blob/main/packages/solid-query/src/useQuery.ts#L226) +Defined in: [packages/solid-query/src/useQuery.ts:226](https://github.com/TanStack/query/blob/main/packages/solid-query/src/useQuery.ts#L226) This overload is selected when `initialData` is set, so the resulting `data` is never `undefined`. diff --git a/docs/framework/solid/reference/functions/useQueryClient.md b/docs/framework/solid/reference/functions/useQueryClient.md index 08f58f974bc..7aa8ddbe675 100644 --- a/docs/framework/solid/reference/functions/useQueryClient.md +++ b/docs/framework/solid/reference/functions/useQueryClient.md @@ -7,7 +7,7 @@ title: useQueryClient function useQueryClient(queryClient?): QueryClient; ``` -Defined in: [QueryClientProvider.tsx:28](https://github.com/TanStack/query/blob/main/packages/solid-query/src/QueryClientProvider.tsx#L28) +Defined in: [packages/solid-query/src/QueryClientProvider.tsx:28](https://github.com/TanStack/query/blob/main/packages/solid-query/src/QueryClientProvider.tsx#L28) The `useQueryClient` hook returns the current `QueryClient` instance. diff --git a/docs/framework/solid/reference/index.md b/docs/framework/solid/reference/index.md index 72ac491bd8e..6bac666e791 100644 --- a/docs/framework/solid/reference/index.md +++ b/docs/framework/solid/reference/index.md @@ -5,29 +5,148 @@ title: "@tanstack/solid-query" ## Classes +- [CancelledError](classes/CancelledError.md) +- [InfiniteQueryObserver](classes/InfiniteQueryObserver.md) +- [Mutation](classes/Mutation.md) +- [MutationCache](classes/MutationCache.md) +- [MutationObserver](classes/MutationObserver.md) +- [QueriesObserver](classes/QueriesObserver.md) +- [Query](classes/Query.md) +- [QueryCache](classes/QueryCache.md) - [QueryClient](classes/QueryClient.md) +- [QueryObserver](classes/QueryObserver.md) ## Interfaces +- [CancelOptions](interfaces/CancelOptions.md) - [DefaultOptions](interfaces/DefaultOptions.md) +- [DehydratedState](interfaces/DehydratedState.md) +- [DehydrateOptions](interfaces/DehydrateOptions.md) +- [~~EnsureQueryDataOptions~~](interfaces/EnsureQueryDataOptions.md) +- [FetchNextPageOptions](interfaces/FetchNextPageOptions.md) +- [FetchPreviousPageOptions](interfaces/FetchPreviousPageOptions.md) +- [~~FetchQueryOptions~~](interfaces/FetchQueryOptions.md) +- [FocusManager](interfaces/FocusManager.md) +- [HydrateOptions](interfaces/HydrateOptions.md) +- [InfiniteData](interfaces/InfiniteData.md) +- [InfiniteQueryObserverBaseResult](interfaces/InfiniteQueryObserverBaseResult.md) +- [InfiniteQueryObserverLoadingErrorResult](interfaces/InfiniteQueryObserverLoadingErrorResult.md) +- [InfiniteQueryObserverLoadingResult](interfaces/InfiniteQueryObserverLoadingResult.md) - [InfiniteQueryObserverOptions](interfaces/InfiniteQueryObserverOptions.md) +- [InfiniteQueryObserverPendingResult](interfaces/InfiniteQueryObserverPendingResult.md) +- [InfiniteQueryObserverPlaceholderResult](interfaces/InfiniteQueryObserverPlaceholderResult.md) +- [InfiniteQueryObserverRefetchErrorResult](interfaces/InfiniteQueryObserverRefetchErrorResult.md) +- [InfiniteQueryObserverSuccessResult](interfaces/InfiniteQueryObserverSuccessResult.md) - [InfiniteQueryOptions](interfaces/InfiniteQueryOptions.md) +- [InfiniteQueryPageParamsOptions](interfaces/InfiniteQueryPageParamsOptions.md) +- [InitialPageParam](interfaces/InitialPageParam.md) +- [InvalidateOptions](interfaces/InvalidateOptions.md) +- [InvalidateQueryFilters](interfaces/InvalidateQueryFilters.md) +- [MutateOptions](interfaces/MutateOptions.md) +- [MutationCacheConfig](interfaces/MutationCacheConfig.md) +- [MutationFilters](interfaces/MutationFilters.md) +- [MutationObserverBaseResult](interfaces/MutationObserverBaseResult.md) +- [MutationObserverErrorResult](interfaces/MutationObserverErrorResult.md) +- [MutationObserverIdleResult](interfaces/MutationObserverIdleResult.md) +- [MutationObserverLoadingResult](interfaces/MutationObserverLoadingResult.md) +- [MutationObserverOptions](interfaces/MutationObserverOptions.md) +- [MutationObserverSuccessResult](interfaces/MutationObserverSuccessResult.md) - [MutationOptions](interfaces/MutationOptions.md) +- [MutationState](interfaces/MutationState.md) +- [NotifyEvent](interfaces/NotifyEvent.md) +- [OnlineManager](interfaces/OnlineManager.md) +- [QueriesObserverOptions](interfaces/QueriesObserverOptions.md) +- [QueryCacheConfig](interfaces/QueryCacheConfig.md) - [QueryClientConfig](interfaces/QueryClientConfig.md) +- [QueryExecuteOptions](interfaces/QueryExecuteOptions.md) +- [QueryFilters](interfaces/QueryFilters.md) +- [QueryObserverBaseResult](interfaces/QueryObserverBaseResult.md) +- [QueryObserverLoadingErrorResult](interfaces/QueryObserverLoadingErrorResult.md) +- [QueryObserverLoadingResult](interfaces/QueryObserverLoadingResult.md) - [QueryObserverOptions](interfaces/QueryObserverOptions.md) +- [QueryObserverPendingResult](interfaces/QueryObserverPendingResult.md) +- [QueryObserverPlaceholderResult](interfaces/QueryObserverPlaceholderResult.md) +- [QueryObserverRefetchErrorResult](interfaces/QueryObserverRefetchErrorResult.md) +- [QueryObserverSuccessResult](interfaces/QueryObserverSuccessResult.md) - [QueryOptions](interfaces/QueryOptions.md) +- [QueryState](interfaces/QueryState.md) +- [RefetchOptions](interfaces/RefetchOptions.md) +- [RefetchQueryFilters](interfaces/RefetchQueryFilters.md) +- [Register](interfaces/Register.md) +- [ResetOptions](interfaces/ResetOptions.md) +- [ResultOptions](interfaces/ResultOptions.md) +- [SetDataOptions](interfaces/SetDataOptions.md) +- [TimeoutManager](interfaces/TimeoutManager.md) - [UseBaseQueryOptions](interfaces/UseBaseQueryOptions.md) ## Type Aliases +- [AnyDataTag](type-aliases/AnyDataTag.md) +- [DataTag](type-aliases/DataTag.md) +- [dataTagErrorSymbol](type-aliases/dataTagErrorSymbol.md) +- [dataTagSymbol](type-aliases/dataTagSymbol.md) +- [DefaultedInfiniteQueryObserverOptions](type-aliases/DefaultedInfiniteQueryObserverOptions.md) +- [DefaultedQueryObserverOptions](type-aliases/DefaultedQueryObserverOptions.md) +- [DefaultError](type-aliases/DefaultError.md) +- [DefinedInfiniteQueryObserverResult](type-aliases/DefinedInfiniteQueryObserverResult.md) - [DefinedInitialDataInfiniteOptions](type-aliases/DefinedInitialDataInfiniteOptions.md) - [DefinedInitialDataOptions](type-aliases/DefinedInitialDataOptions.md) +- [DefinedQueryObserverResult](type-aliases/DefinedQueryObserverResult.md) - [DefinedUseBaseQueryResult](type-aliases/DefinedUseBaseQueryResult.md) - [DefinedUseInfiniteQueryResult](type-aliases/DefinedUseInfiniteQueryResult.md) - [DefinedUseQueryResult](type-aliases/DefinedUseQueryResult.md) +- [DistributiveOmit](type-aliases/DistributiveOmit.md) +- [~~EnsureInfiniteQueryDataOptions~~](type-aliases/EnsureInfiniteQueryDataOptions.md) +- [~~FetchInfiniteQueryOptions~~](type-aliases/FetchInfiniteQueryOptions.md) +- [FetchStatus](type-aliases/FetchStatus.md) +- [GetNextPageParamFunction](type-aliases/GetNextPageParamFunction.md) +- [GetPreviousPageParamFunction](type-aliases/GetPreviousPageParamFunction.md) +- [InferDataFromTag](type-aliases/InferDataFromTag.md) +- [InferErrorFromTag](type-aliases/InferErrorFromTag.md) +- [InfiniteQueryExecuteOptions](type-aliases/InfiniteQueryExecuteOptions.md) +- [InfiniteQueryObserverResult](type-aliases/InfiniteQueryObserverResult.md) +- [InitialDataFunction](type-aliases/InitialDataFunction.md) +- [ManagedTimerId](type-aliases/ManagedTimerId.md) +- [MutateFunction](type-aliases/MutateFunction.md) +- [MutateFunctionRest](type-aliases/MutateFunctionRest.md) +- [MutationCacheNotifyEvent](type-aliases/MutationCacheNotifyEvent.md) +- [MutationFunction](type-aliases/MutationFunction.md) +- [MutationFunctionContext](type-aliases/MutationFunctionContext.md) +- [MutationKey](type-aliases/MutationKey.md) +- [MutationMeta](type-aliases/MutationMeta.md) +- [MutationObserverResult](type-aliases/MutationObserverResult.md) +- [MutationScope](type-aliases/MutationScope.md) +- [MutationStatus](type-aliases/MutationStatus.md) +- [NetworkMode](type-aliases/NetworkMode.md) +- [NonUndefinedGuard](type-aliases/NonUndefinedGuard.md) +- [NotifyEventType](type-aliases/NotifyEventType.md) +- [NotifyOnChangeProps](type-aliases/NotifyOnChangeProps.md) +- [OmitKeyof](type-aliases/OmitKeyof.md) +- [Override](type-aliases/Override.md) +- [PlaceholderDataFunction](type-aliases/PlaceholderDataFunction.md) +- [QueriesPlaceholderDataFunction](type-aliases/QueriesPlaceholderDataFunction.md) +- [QueryBooleanOption](type-aliases/QueryBooleanOption.md) +- [QueryCacheNotifyEvent](type-aliases/QueryCacheNotifyEvent.md) - [QueryClientProviderProps](type-aliases/QueryClientProviderProps.md) +- [QueryFunction](type-aliases/QueryFunction.md) +- [QueryFunctionContext](type-aliases/QueryFunctionContext.md) +- [QueryKey](type-aliases/QueryKey.md) +- [QueryKeyHashFunction](type-aliases/QueryKeyHashFunction.md) +- [QueryKeyWithDataTag](type-aliases/QueryKeyWithDataTag.md) +- [QueryMeta](type-aliases/QueryMeta.md) +- [QueryObserverResult](type-aliases/QueryObserverResult.md) +- [QueryPersister](type-aliases/QueryPersister.md) +- [QueryStatus](type-aliases/QueryStatus.md) +- [SkipToken](type-aliases/SkipToken.md) +- [StaleTime](type-aliases/StaleTime.md) +- [StaleTimeFunction](type-aliases/StaleTimeFunction.md) +- [ThrowOnError](type-aliases/ThrowOnError.md) +- [TimeoutCallback](type-aliases/TimeoutCallback.md) +- [TimeoutProvider](type-aliases/TimeoutProvider.md) - [UndefinedInitialDataInfiniteOptions](type-aliases/UndefinedInitialDataInfiniteOptions.md) - [UndefinedInitialDataOptions](type-aliases/UndefinedInitialDataOptions.md) +- [UnsetMarker](type-aliases/UnsetMarker.md) +- [Updater](type-aliases/Updater.md) - [UseBaseMutationResult](type-aliases/UseBaseMutationResult.md) - [UseBaseQueryResult](type-aliases/UseBaseQueryResult.md) - [UseInfiniteQueryOptions](type-aliases/UseInfiniteQueryOptions.md) @@ -38,6 +157,7 @@ title: "@tanstack/solid-query" - [UseMutationResult](type-aliases/UseMutationResult.md) - [UseQueryOptions](type-aliases/UseQueryOptions.md) - [UseQueryResult](type-aliases/UseQueryResult.md) +- [WithRequired](type-aliases/WithRequired.md) ## Variables @@ -45,15 +165,41 @@ title: "@tanstack/solid-query" - [createMutation](variables/createMutation.md) - [createQueries](variables/createQueries.md) - [createQuery](variables/createQuery.md) +- [dataTagErrorSymbol](variables/dataTagErrorSymbol.md) +- [dataTagSymbol](variables/dataTagSymbol.md) +- [defaultScheduler](variables/defaultScheduler.md) +- [environmentManager](variables/environmentManager.md) +- [focusManager](variables/focusManager.md) - [IsRestoringProvider](variables/IsRestoringProvider.md) +- [~~isServer~~](variables/isServer.md) +- [notifyManager](variables/notifyManager.md) +- [onlineManager](variables/onlineManager.md) - [QueryClientContext](variables/QueryClientContext.md) +- [skipToken](variables/skipToken.md) +- [timeoutManager](variables/timeoutManager.md) +- [unsetMarker](variables/unsetMarker.md) ## Functions +- [defaultShouldDehydrateMutation](functions/defaultShouldDehydrateMutation.md) +- [defaultShouldDehydrateQuery](functions/defaultShouldDehydrateQuery.md) +- [dehydrate](functions/dehydrate.md) +- [dehydrateQuery](functions/dehydrateQuery.md) +- [experimental\_streamedQuery](functions/experimental_streamedQuery.md) +- [hashKey](functions/hashKey.md) +- [hydrate](functions/hydrate.md) - [infiniteQueryOptions](functions/infiniteQueryOptions.md) +- [~~isCancelledError~~](functions/isCancelledError.md) +- [keepPreviousData](functions/keepPreviousData.md) +- [matchMutation](functions/matchMutation.md) +- [matchQuery](functions/matchQuery.md) - [mutationOptions](functions/mutationOptions.md) +- [noop](functions/noop.md) +- [partialMatchKey](functions/partialMatchKey.md) - [QueryClientProvider](functions/QueryClientProvider.md) - [queryOptions](functions/queryOptions.md) +- [replaceEqualDeep](functions/replaceEqualDeep.md) +- [shouldThrowError](functions/shouldThrowError.md) - [useInfiniteQuery](functions/useInfiniteQuery.md) - [useIsFetching](functions/useIsFetching.md) - [useIsMutating](functions/useIsMutating.md) diff --git a/docs/framework/solid/reference/interfaces/CancelOptions.md b/docs/framework/solid/reference/interfaces/CancelOptions.md new file mode 100644 index 00000000000..b7464c48e50 --- /dev/null +++ b/docs/framework/solid/reference/interfaces/CancelOptions.md @@ -0,0 +1,26 @@ +--- +id: CancelOptions +title: CancelOptions +--- + +Defined in: [packages/query-core/src/types.ts:1521](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1521) + +## Properties + +### revert? + +```ts +optional revert: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1522](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1522) + +*** + +### silent? + +```ts +optional silent: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1523](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1523) diff --git a/docs/framework/solid/reference/interfaces/DefaultOptions.md b/docs/framework/solid/reference/interfaces/DefaultOptions.md index 50e7ba42e2d..8f49e18d70a 100644 --- a/docs/framework/solid/reference/interfaces/DefaultOptions.md +++ b/docs/framework/solid/reference/interfaces/DefaultOptions.md @@ -3,7 +3,7 @@ id: DefaultOptions title: DefaultOptions --- -Defined in: [QueryClient.ts:96](https://github.com/TanStack/query/blob/main/packages/solid-query/src/QueryClient.ts#L96) +Defined in: [packages/solid-query/src/QueryClient.ts:96](https://github.com/TanStack/query/blob/main/packages/solid-query/src/QueryClient.ts#L96) The default options a `QueryClient` applies to every query, with Solid's `reconcile` option added to `queries`. @@ -16,19 +16,99 @@ The default options a `QueryClient` applies to every query, with Solid's `reconc ### TError -`TError` = `DefaultError` +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) The default type of errors thrown by queries and mutations using this `QueryClient`. ## Properties +### dehydrate? + +```ts +optional dehydrate: DehydrateOptions; +``` + +Defined in: [packages/query-core/src/types.ts:1518](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1518) + +Default options used when dehydrating the client's caches; see [DehydrateOptions](DehydrateOptions.md). + +#### Inherited from + +```ts +CoreDefaultOptions.dehydrate +``` + +*** + +### hydrate? + +```ts +optional hydrate: object; +``` + +Defined in: [packages/query-core/src/types.ts:1516](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1516) + +Default options used when hydrating queries; see [HydrateOptions](HydrateOptions.md). + +#### deserializeData? + +```ts +optional deserializeData: TransformerFn; +``` + +Transforms a query's `data` after it is read from the dehydrated state, reversing `serializeData`. + +#### mutations? + +```ts +optional mutations: MutationOptions; +``` + +Default options merged into every mutation restored from the dehydrated state. + +#### queries? + +```ts +optional queries: QueryOptions; +``` + +Default options merged into every query restored from the dehydrated state. + +#### Inherited from + +```ts +CoreDefaultOptions.hydrate +``` + +*** + +### mutations? + +```ts +optional mutations: MutationObserverOptions; +``` + +Defined in: [packages/query-core/src/types.ts:1514](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1514) + +Default options applied to every mutation, unless overridden per-mutation. + +#### Inherited from + +```ts +CoreDefaultOptions.mutations +``` + +*** + ### queries? ```ts optional queries: OmitKeyof, "queryKey">; ``` -Defined in: [QueryClient.ts:99](https://github.com/TanStack/query/blob/main/packages/solid-query/src/QueryClient.ts#L99) +Defined in: [packages/solid-query/src/QueryClient.ts:99](https://github.com/TanStack/query/blob/main/packages/solid-query/src/QueryClient.ts#L99) + +Default options applied to every query, unless overridden per-query. #### Overrides diff --git a/docs/framework/solid/reference/interfaces/DehydrateOptions.md b/docs/framework/solid/reference/interfaces/DehydrateOptions.md new file mode 100644 index 00000000000..e862ae88b43 --- /dev/null +++ b/docs/framework/solid/reference/interfaces/DehydrateOptions.md @@ -0,0 +1,89 @@ +--- +id: DehydrateOptions +title: DehydrateOptions +--- + +Defined in: [packages/query-core/src/hydration.ts:42](https://github.com/TanStack/query/blob/main/packages/query-core/src/hydration.ts#L42) + +Options for `dehydrate`, controlling which queries/mutations are included in the resulting `DehydratedState` and +how their data/errors are transformed before being serialized (e.g. for embedding in server-rendered markup). + +## Properties + +### serializeData? + +```ts +optional serializeData: TransformerFn; +``` + +Defined in: [packages/query-core/src/hydration.ts:44](https://github.com/TanStack/query/blob/main/packages/query-core/src/hydration.ts#L44) + +Transforms a query's `data` before it is dehydrated. Useful for non-JSON-serializable data. + +*** + +### shouldDehydrateMutation()? + +```ts +optional shouldDehydrateMutation: (mutation) => boolean; +``` + +Defined in: [packages/query-core/src/hydration.ts:46](https://github.com/TanStack/query/blob/main/packages/query-core/src/hydration.ts#L46) + +Predicate to decide whether a given `Mutation` should be dehydrated. Defaults to `defaultShouldDehydrateMutation`. + +#### Parameters + +##### mutation + +[`Mutation`](../classes/Mutation.md) + +#### Returns + +`boolean` + +*** + +### shouldDehydrateQuery()? + +```ts +optional shouldDehydrateQuery: (query) => boolean; +``` + +Defined in: [packages/query-core/src/hydration.ts:48](https://github.com/TanStack/query/blob/main/packages/query-core/src/hydration.ts#L48) + +Predicate to decide whether a given `Query` should be dehydrated. Defaults to `defaultShouldDehydrateQuery`. + +#### Parameters + +##### query + +[`Query`](../classes/Query.md) + +#### Returns + +`boolean` + +*** + +### shouldRedactErrors()? + +```ts +optional shouldRedactErrors: (error) => boolean; +``` + +Defined in: [packages/query-core/src/hydration.ts:54](https://github.com/TanStack/query/blob/main/packages/query-core/src/hydration.ts#L54) + +Predicate to decide whether a query's error should be redacted before dehydration. Errors are redacted +(replaced with a generic `Error('redacted')`) unless this function is provided and returns `false` for the +given error, in which case the original error is kept. + +#### Parameters + +##### error + +`unknown` + +#### Returns + +`boolean` diff --git a/docs/framework/solid/reference/interfaces/DehydratedState.md b/docs/framework/solid/reference/interfaces/DehydratedState.md new file mode 100644 index 00000000000..be034c9e8fd --- /dev/null +++ b/docs/framework/solid/reference/interfaces/DehydratedState.md @@ -0,0 +1,30 @@ +--- +id: DehydratedState +title: DehydratedState +--- + +Defined in: [packages/query-core/src/hydration.ts:94](https://github.com/TanStack/query/blob/main/packages/query-core/src/hydration.ts#L94) + +A serializable snapshot of a `QueryClient`'s cache, as produced by `dehydrate` and consumed by `hydrate`. Typically +transported from server to client (e.g. embedded in server-rendered markup) to seed the client's cache with data +that has already been fetched, avoiding a redundant fetch on the client. + +## Properties + +### mutations + +```ts +mutations: DehydratedMutation[]; +``` + +Defined in: [packages/query-core/src/hydration.ts:95](https://github.com/TanStack/query/blob/main/packages/query-core/src/hydration.ts#L95) + +*** + +### queries + +```ts +queries: DehydratedQuery[]; +``` + +Defined in: [packages/query-core/src/hydration.ts:96](https://github.com/TanStack/query/blob/main/packages/query-core/src/hydration.ts#L96) diff --git a/docs/framework/solid/reference/interfaces/EnsureQueryDataOptions.md b/docs/framework/solid/reference/interfaces/EnsureQueryDataOptions.md new file mode 100644 index 00000000000..a67082af57e --- /dev/null +++ b/docs/framework/solid/reference/interfaces/EnsureQueryDataOptions.md @@ -0,0 +1,350 @@ +--- +id: EnsureQueryDataOptions +title: EnsureQueryDataOptions +--- + +Defined in: [packages/query-core/src/types.ts:614](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L614) + +## Deprecated + +## Extends + +- [`FetchQueryOptions`](FetchQueryOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`, `TPageParam`\> + +## Type Parameters + +### TQueryFnData + +`TQueryFnData` = `unknown` + +### TError + +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) + +### TData + +`TData` = `TQueryFnData` + +### TQueryKey + +`TQueryKey` *extends* [`QueryKey`](../type-aliases/QueryKey.md) = [`QueryKey`](../type-aliases/QueryKey.md) + +### TPageParam + +`TPageParam` = `never` + +## Properties + +### ~~gcTime?~~ + +```ts +optional gcTime: number; +``` + +Defined in: [packages/query-core/src/types.ts:277](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L277) + +The time in milliseconds that unused/inactive cache data remains in memory. +When a query's cache becomes unused or inactive, that cache data will be garbage collected after this duration. +When different garbage collection times are specified, the longest one will be used. +Setting it to `Infinity` will disable garbage collection. + +Defaults to `5 * 60 * 1000` (5 minutes), or `Infinity` during SSR. + +Note: the maximum allowed time is about 24 days, imposed by `setTimeout`'s 32-bit signed integer delay — see +`timeoutManager.setTimeoutProvider` for a workaround. + +#### Inherited from + +[`FetchQueryOptions`](FetchQueryOptions.md).[`gcTime`](FetchQueryOptions.md#gctime) + +*** + +### ~~initialData?~~ + +```ts +optional initialData: + | TData +| InitialDataFunction; +``` + +Defined in: [packages/query-core/src/types.ts:317](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L317) + +If set, this value will be used as the initial data for the query cache (as long as the query hasn't been +created or cached yet). +If set to a function, the function will be called **once** during the shared/root query initialization, and be +expected to synchronously return the initial data. +Initial data is considered stale by default unless a `staleTime` has been set. +`initialData` **is persisted** to the cache. + +#### Inherited from + +[`FetchQueryOptions`](FetchQueryOptions.md).[`initialData`](FetchQueryOptions.md#initialdata) + +*** + +### ~~initialDataUpdatedAt?~~ + +```ts +optional initialDataUpdatedAt: number | () => number | undefined; +``` + +Defined in: [packages/query-core/src/types.ts:321](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L321) + +If set, this value will be used as the time (in milliseconds) of when the `initialData` itself was last updated. + +#### Inherited from + +[`FetchQueryOptions`](FetchQueryOptions.md).[`initialDataUpdatedAt`](FetchQueryOptions.md#initialdataupdatedat) + +*** + +### ~~initialPageParam?~~ + +```ts +optional initialPageParam: undefined; +``` + +Defined in: [packages/query-core/src/types.ts:605](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L605) + +#### Inherited from + +[`FetchQueryOptions`](FetchQueryOptions.md).[`initialPageParam`](FetchQueryOptions.md#initialpageparam) + +*** + +### ~~maxPages?~~ + +```ts +optional maxPages: number; +``` + +Defined in: [packages/query-core/src/types.ts:345](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L345) + +Maximum number of pages to store in the data of an infinite query. + +#### Inherited from + +[`FetchQueryOptions`](FetchQueryOptions.md).[`maxPages`](FetchQueryOptions.md#maxpages) + +*** + +### ~~meta?~~ + +```ts +optional meta: Record; +``` + +Defined in: [packages/query-core/src/types.ts:341](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L341) + +Additional payload to be stored on each query. +Use this property to pass information that can be used in other places. + +#### Inherited from + +[`FetchQueryOptions`](FetchQueryOptions.md).[`meta`](FetchQueryOptions.md#meta) + +*** + +### ~~networkMode?~~ + +```ts +optional networkMode: NetworkMode; +``` + +Defined in: [packages/query-core/src/types.ts:265](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L265) + +Controls whether a query is allowed to run based on the current network connectivity. + +Defaults to `'online'`. + +#### See + +[Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. + +#### Inherited from + +[`FetchQueryOptions`](FetchQueryOptions.md).[`networkMode`](FetchQueryOptions.md#networkmode) + +*** + +### ~~persister?~~ + +```ts +optional persister: QueryPersister, TPageParam>; +``` + +Defined in: [packages/query-core/src/types.ts:290](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L290) + +This option can be used to persist the result of a query to an external storage, bypassing the need to actually +call the `queryFn`. Useful for persisting a query's data across e.g. server/client boundaries. + +#### Inherited from + +[`FetchQueryOptions`](FetchQueryOptions.md).[`persister`](FetchQueryOptions.md#persister) + +*** + +### ~~queryFn?~~ + +```ts +optional queryFn: + | typeof skipToken +| QueryFunction; +``` + +Defined in: [packages/query-core/src/types.ts:285](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L285) + +The function that the query will use to request data. +Required, unless a default query function has been set via `queryClient.setQueryDefaults` or +`queryClient.setDefaultOptions`. +Receives a [QueryFunctionContext](../type-aliases/QueryFunctionContext.md). +Must return a promise that will either resolve data or throw an error. The data cannot be `undefined`. + +#### Inherited from + +[`FetchQueryOptions`](FetchQueryOptions.md).[`queryFn`](FetchQueryOptions.md#queryfn) + +*** + +### ~~queryHash?~~ + +```ts +optional queryHash: string; +``` + +Defined in: [packages/query-core/src/types.ts:295](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L295) + +The hashed form of `queryKey`, computed with `queryKeyHashFn` (or the default hashing function otherwise). Used +as the actual cache key internally. + +#### Inherited from + +[`FetchQueryOptions`](FetchQueryOptions.md).[`queryHash`](FetchQueryOptions.md#queryhash) + +*** + +### ~~queryKey~~ + +```ts +queryKey: TQueryKey & object; +``` + +Defined in: [packages/query-core/src/types.ts:304](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L304) + +The query key to use for this query. + +The query key will be hashed into a stable hash. See [Query Keys](https://tanstack.com/query/latest/docs/framework/react/guides/query-keys) +for more information. + +The query will automatically update when this key changes (as long as `enabled` is not set to `false`). + +#### Inherited from + +[`FetchQueryOptions`](FetchQueryOptions.md).[`queryKey`](FetchQueryOptions.md#querykey) + +*** + +### ~~queryKeyHashFn?~~ + +```ts +optional queryKeyHashFn: QueryKeyHashFunction; +``` + +Defined in: [packages/query-core/src/types.ts:308](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L308) + +If specified, this function is used to hash the `queryKey` to a string. + +#### Inherited from + +[`FetchQueryOptions`](FetchQueryOptions.md).[`queryKeyHashFn`](FetchQueryOptions.md#querykeyhashfn) + +*** + +### ~~retry?~~ + +```ts +optional retry: RetryValue; +``` + +Defined in: [packages/query-core/src/types.ts:246](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L246) + +If `false`, failed queries will not retry by default. +If `true`, failed queries will retry infinitely. +If set to an integer number, e.g. 3, failed queries will retry until the failed query count meets that number. +If set to a function `(failureCount, error) => boolean` failed queries will retry until the function returns false. + +Defaults to `3` on the client and `0` on the server. + +#### Inherited from + +[`FetchQueryOptions`](FetchQueryOptions.md).[`retry`](FetchQueryOptions.md#retry) + +*** + +### ~~retryDelay?~~ + +```ts +optional retryDelay: RetryDelayValue; +``` + +Defined in: [packages/query-core/src/types.ts:258](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L258) + +This function receives a `retryAttempt` integer and the actual Error and returns the delay to apply before the +next attempt in milliseconds. + +A function like `attempt => Math.min(attempt > 1 ? 2 ** attempt * 1000 : 1000, 30 * 1000)` applies exponential +backoff. + +A function like `attempt => attempt * 1000` applies linear backoff. + +Defaults to a function that applies exponential backoff, capped at 30 seconds. + +#### Inherited from + +[`FetchQueryOptions`](FetchQueryOptions.md).[`retryDelay`](FetchQueryOptions.md#retrydelay) + +*** + +### ~~revalidateIfStale?~~ + +```ts +optional revalidateIfStale: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:627](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L627) + +*** + +### ~~staleTime?~~ + +```ts +optional staleTime: StaleTimeFunction; +``` + +Defined in: [packages/query-core/src/types.ts:610](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L610) + +The time in milliseconds after data is considered stale. +If the data is fresh it will be returned from the cache. + +#### Inherited from + +[`FetchQueryOptions`](FetchQueryOptions.md).[`staleTime`](FetchQueryOptions.md#staletime) + +*** + +### ~~structuralSharing?~~ + +```ts +optional structuralSharing: boolean | (oldData, newData) => unknown; +``` + +Defined in: [packages/query-core/src/types.ts:330](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L330) + +Set this to `false` to disable structural sharing between query results. +Set this to a function which accepts the old and new data and returns resolved data of the same type to implement custom structural sharing logic. + +Defaults to `true`. + +#### Inherited from + +[`FetchQueryOptions`](FetchQueryOptions.md).[`structuralSharing`](FetchQueryOptions.md#structuralsharing) diff --git a/docs/framework/solid/reference/interfaces/FetchNextPageOptions.md b/docs/framework/solid/reference/interfaces/FetchNextPageOptions.md new file mode 100644 index 00000000000..b79cdbe19b3 --- /dev/null +++ b/docs/framework/solid/reference/interfaces/FetchNextPageOptions.md @@ -0,0 +1,46 @@ +--- +id: FetchNextPageOptions +title: FetchNextPageOptions +--- + +Defined in: [packages/query-core/src/types.ts:737](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L737) + +## Extends + +- [`ResultOptions`](ResultOptions.md) + +## Properties + +### cancelRefetch? + +```ts +optional cancelRefetch: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:746](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L746) + +If set to `true`, calling `fetchNextPage` repeatedly will invoke `queryFn` every time, +whether the previous invocation has resolved or not. Also, the result from previous invocations will be ignored. + +If set to `false`, calling `fetchNextPage` repeatedly won't have any effect until the first invocation has resolved. + +Defaults to `true`. + +*** + +### throwOnError? + +```ts +optional throwOnError: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:701](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L701) + +If set to `true`, the method throws if any of the underlying query refetch tasks fail. + +Defaults to `false`, in which case failed refetches are swallowed and not surfaced to the +caller. + +#### Inherited from + +[`ResultOptions`](ResultOptions.md).[`throwOnError`](ResultOptions.md#throwonerror) diff --git a/docs/framework/solid/reference/interfaces/FetchPreviousPageOptions.md b/docs/framework/solid/reference/interfaces/FetchPreviousPageOptions.md new file mode 100644 index 00000000000..fd5a08767b6 --- /dev/null +++ b/docs/framework/solid/reference/interfaces/FetchPreviousPageOptions.md @@ -0,0 +1,46 @@ +--- +id: FetchPreviousPageOptions +title: FetchPreviousPageOptions +--- + +Defined in: [packages/query-core/src/types.ts:749](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L749) + +## Extends + +- [`ResultOptions`](ResultOptions.md) + +## Properties + +### cancelRefetch? + +```ts +optional cancelRefetch: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:758](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L758) + +If set to `true`, calling `fetchPreviousPage` repeatedly will invoke `queryFn` every time, +whether the previous invocation has resolved or not. Also, the result from previous invocations will be ignored. + +If set to `false`, calling `fetchPreviousPage` repeatedly won't have any effect until the first invocation has resolved. + +Defaults to `true`. + +*** + +### throwOnError? + +```ts +optional throwOnError: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:701](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L701) + +If set to `true`, the method throws if any of the underlying query refetch tasks fail. + +Defaults to `false`, in which case failed refetches are swallowed and not surfaced to the +caller. + +#### Inherited from + +[`ResultOptions`](ResultOptions.md).[`throwOnError`](ResultOptions.md#throwonerror) diff --git a/docs/framework/solid/reference/interfaces/FetchQueryOptions.md b/docs/framework/solid/reference/interfaces/FetchQueryOptions.md new file mode 100644 index 00000000000..1b8582adba7 --- /dev/null +++ b/docs/framework/solid/reference/interfaces/FetchQueryOptions.md @@ -0,0 +1,364 @@ +--- +id: FetchQueryOptions +title: FetchQueryOptions +--- + +Defined in: [packages/query-core/src/types.ts:595](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L595) + +## Deprecated + +## Extends + +- [`WithRequired`](../type-aliases/WithRequired.md)\<`QueryOptions`\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`, `TPageParam`\>, `"queryKey"`\> + +## Extended by + +- [`EnsureQueryDataOptions`](EnsureQueryDataOptions.md) + +## Type Parameters + +### TQueryFnData + +`TQueryFnData` = `unknown` + +### TError + +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) + +### TData + +`TData` = `TQueryFnData` + +### TQueryKey + +`TQueryKey` *extends* [`QueryKey`](../type-aliases/QueryKey.md) = [`QueryKey`](../type-aliases/QueryKey.md) + +### TPageParam + +`TPageParam` = `never` + +## Properties + +### ~~gcTime?~~ + +```ts +optional gcTime: number; +``` + +Defined in: [packages/query-core/src/types.ts:277](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L277) + +The time in milliseconds that unused/inactive cache data remains in memory. +When a query's cache becomes unused or inactive, that cache data will be garbage collected after this duration. +When different garbage collection times are specified, the longest one will be used. +Setting it to `Infinity` will disable garbage collection. + +Defaults to `5 * 60 * 1000` (5 minutes), or `Infinity` during SSR. + +Note: the maximum allowed time is about 24 days, imposed by `setTimeout`'s 32-bit signed integer delay — see +`timeoutManager.setTimeoutProvider` for a workaround. + +#### Inherited from + +```ts +WithRequired.gcTime +``` + +*** + +### ~~initialData?~~ + +```ts +optional initialData: + | TData +| InitialDataFunction; +``` + +Defined in: [packages/query-core/src/types.ts:317](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L317) + +If set, this value will be used as the initial data for the query cache (as long as the query hasn't been +created or cached yet). +If set to a function, the function will be called **once** during the shared/root query initialization, and be +expected to synchronously return the initial data. +Initial data is considered stale by default unless a `staleTime` has been set. +`initialData` **is persisted** to the cache. + +#### Inherited from + +```ts +WithRequired.initialData +``` + +*** + +### ~~initialDataUpdatedAt?~~ + +```ts +optional initialDataUpdatedAt: number | () => number | undefined; +``` + +Defined in: [packages/query-core/src/types.ts:321](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L321) + +If set, this value will be used as the time (in milliseconds) of when the `initialData` itself was last updated. + +#### Inherited from + +```ts +WithRequired.initialDataUpdatedAt +``` + +*** + +### ~~initialPageParam?~~ + +```ts +optional initialPageParam: undefined; +``` + +Defined in: [packages/query-core/src/types.ts:605](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L605) + +*** + +### ~~maxPages?~~ + +```ts +optional maxPages: number; +``` + +Defined in: [packages/query-core/src/types.ts:345](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L345) + +Maximum number of pages to store in the data of an infinite query. + +#### Inherited from + +```ts +WithRequired.maxPages +``` + +*** + +### ~~meta?~~ + +```ts +optional meta: Record; +``` + +Defined in: [packages/query-core/src/types.ts:341](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L341) + +Additional payload to be stored on each query. +Use this property to pass information that can be used in other places. + +#### Inherited from + +```ts +WithRequired.meta +``` + +*** + +### ~~networkMode?~~ + +```ts +optional networkMode: NetworkMode; +``` + +Defined in: [packages/query-core/src/types.ts:265](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L265) + +Controls whether a query is allowed to run based on the current network connectivity. + +Defaults to `'online'`. + +#### See + +[Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. + +#### Inherited from + +```ts +WithRequired.networkMode +``` + +*** + +### ~~persister?~~ + +```ts +optional persister: QueryPersister, TPageParam>; +``` + +Defined in: [packages/query-core/src/types.ts:290](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L290) + +This option can be used to persist the result of a query to an external storage, bypassing the need to actually +call the `queryFn`. Useful for persisting a query's data across e.g. server/client boundaries. + +#### Inherited from + +```ts +WithRequired.persister +``` + +*** + +### ~~queryFn?~~ + +```ts +optional queryFn: + | typeof skipToken +| QueryFunction; +``` + +Defined in: [packages/query-core/src/types.ts:285](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L285) + +The function that the query will use to request data. +Required, unless a default query function has been set via `queryClient.setQueryDefaults` or +`queryClient.setDefaultOptions`. +Receives a [QueryFunctionContext](../type-aliases/QueryFunctionContext.md). +Must return a promise that will either resolve data or throw an error. The data cannot be `undefined`. + +#### Inherited from + +```ts +WithRequired.queryFn +``` + +*** + +### ~~queryHash?~~ + +```ts +optional queryHash: string; +``` + +Defined in: [packages/query-core/src/types.ts:295](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L295) + +The hashed form of `queryKey`, computed with `queryKeyHashFn` (or the default hashing function otherwise). Used +as the actual cache key internally. + +#### Inherited from + +```ts +WithRequired.queryHash +``` + +*** + +### ~~queryKey~~ + +```ts +queryKey: TQueryKey & object; +``` + +Defined in: [packages/query-core/src/types.ts:304](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L304) + +The query key to use for this query. + +The query key will be hashed into a stable hash. See [Query Keys](https://tanstack.com/query/latest/docs/framework/react/guides/query-keys) +for more information. + +The query will automatically update when this key changes (as long as `enabled` is not set to `false`). + +#### Inherited from + +```ts +WithRequired.queryKey +``` + +*** + +### ~~queryKeyHashFn?~~ + +```ts +optional queryKeyHashFn: QueryKeyHashFunction; +``` + +Defined in: [packages/query-core/src/types.ts:308](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L308) + +If specified, this function is used to hash the `queryKey` to a string. + +#### Inherited from + +```ts +WithRequired.queryKeyHashFn +``` + +*** + +### ~~retry?~~ + +```ts +optional retry: RetryValue; +``` + +Defined in: [packages/query-core/src/types.ts:246](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L246) + +If `false`, failed queries will not retry by default. +If `true`, failed queries will retry infinitely. +If set to an integer number, e.g. 3, failed queries will retry until the failed query count meets that number. +If set to a function `(failureCount, error) => boolean` failed queries will retry until the function returns false. + +Defaults to `3` on the client and `0` on the server. + +#### Inherited from + +```ts +WithRequired.retry +``` + +*** + +### ~~retryDelay?~~ + +```ts +optional retryDelay: RetryDelayValue; +``` + +Defined in: [packages/query-core/src/types.ts:258](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L258) + +This function receives a `retryAttempt` integer and the actual Error and returns the delay to apply before the +next attempt in milliseconds. + +A function like `attempt => Math.min(attempt > 1 ? 2 ** attempt * 1000 : 1000, 30 * 1000)` applies exponential +backoff. + +A function like `attempt => attempt * 1000` applies linear backoff. + +Defaults to a function that applies exponential backoff, capped at 30 seconds. + +#### Inherited from + +```ts +WithRequired.retryDelay +``` + +*** + +### ~~staleTime?~~ + +```ts +optional staleTime: StaleTimeFunction; +``` + +Defined in: [packages/query-core/src/types.ts:610](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L610) + +The time in milliseconds after data is considered stale. +If the data is fresh it will be returned from the cache. + +*** + +### ~~structuralSharing?~~ + +```ts +optional structuralSharing: boolean | (oldData, newData) => unknown; +``` + +Defined in: [packages/query-core/src/types.ts:330](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L330) + +Set this to `false` to disable structural sharing between query results. +Set this to a function which accepts the old and new data and returns resolved data of the same type to implement custom structural sharing logic. + +Defaults to `true`. + +#### Inherited from + +```ts +WithRequired.structuralSharing +``` diff --git a/docs/framework/solid/reference/interfaces/FocusManager.md b/docs/framework/solid/reference/interfaces/FocusManager.md new file mode 100644 index 00000000000..1ab81dc6357 --- /dev/null +++ b/docs/framework/solid/reference/interfaces/FocusManager.md @@ -0,0 +1,237 @@ +--- +id: FocusManager +title: FocusManager +--- + +Defined in: [packages/query-core/src/focusManager.ts:14](https://github.com/TanStack/query/blob/main/packages/query-core/src/focusManager.ts#L14) + +The `FocusManager` manages the focus state within TanStack Query. + +It can be used to change the default event listeners or to manually change the focus state. + +## Extends + +- `Subscribable`\<`Listener`\> + +## Properties + +### listeners + +```ts +protected listeners: Set; +``` + +Defined in: [packages/query-core/src/subscribable.ts:2](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L2) + +#### Inherited from + +```ts +Subscribable.listeners +``` + +## Methods + +### hasListeners() + +```ts +hasListeners(): boolean; +``` + +Defined in: [packages/query-core/src/subscribable.ts:19](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L19) + +#### Returns + +`boolean` + +#### Inherited from + +```ts +Subscribable.hasListeners +``` + +*** + +### isFocused() + +```ts +isFocused(): boolean; +``` + +Defined in: [packages/query-core/src/focusManager.ts:128](https://github.com/TanStack/query/blob/main/packages/query-core/src/focusManager.ts#L128) + +`isFocused` can be used to get the current focus state. + +#### Returns + +`boolean` + +*** + +### onFocus() + +```ts +onFocus(): void; +``` + +Defined in: [packages/query-core/src/focusManager.ts:118](https://github.com/TanStack/query/blob/main/packages/query-core/src/focusManager.ts#L118) + +`onFocus` notifies all subscribed listeners with the current focus state. + +#### Returns + +`void` + +*** + +### onSubscribe() + +```ts +protected onSubscribe(): void; +``` + +Defined in: [packages/query-core/src/focusManager.ts:39](https://github.com/TanStack/query/blob/main/packages/query-core/src/focusManager.ts#L39) + +#### Returns + +`void` + +#### Overrides + +```ts +Subscribable.onSubscribe +``` + +*** + +### onUnsubscribe() + +```ts +protected onUnsubscribe(): void; +``` + +Defined in: [packages/query-core/src/focusManager.ts:45](https://github.com/TanStack/query/blob/main/packages/query-core/src/focusManager.ts#L45) + +#### Returns + +`void` + +#### Overrides + +```ts +Subscribable.onUnsubscribe +``` + +*** + +### setEventListener() + +```ts +setEventListener(setup): void; +``` + +Defined in: [packages/query-core/src/focusManager.ts:77](https://github.com/TanStack/query/blob/main/packages/query-core/src/focusManager.ts#L77) + +`setEventListener` can be used to set a custom event listener that will +be used to determine the focus state. The provided `setup` function +receives a `setFocused` callback: call it with a `boolean` to manually +set the focus state, or with no arguments to re-evaluate the current +focus state and notify subscribers. + +#### Parameters + +##### setup + +`SetupFn` + +#### Returns + +`void` + +#### Example + +```ts +import { focusManager } from '@tanstack/query-core' + +focusManager.setEventListener((handleFocus) => { + const listener = () => handleFocus() + // Listen to visibilitychange + if (typeof window !== 'undefined' && window.addEventListener) { + window.addEventListener('visibilitychange', listener, false) + } + + return () => { + // Be sure to unsubscribe if a new handler is set + window.removeEventListener('visibilitychange', listener) + } +}) +``` + +*** + +### setFocused() + +```ts +setFocused(focused?): void; +``` + +Defined in: [packages/query-core/src/focusManager.ts:107](https://github.com/TanStack/query/blob/main/packages/query-core/src/focusManager.ts#L107) + +`setFocused` can be used to manually set the focus state. Set `undefined` +to fall back to the default focus check. + +#### Parameters + +##### focused? + +`boolean` + +#### Returns + +`void` + +#### Example + +```ts +import { focusManager } from '@tanstack/query-core' + +// Set focused +focusManager.setFocused(true) + +// Set unfocused +focusManager.setFocused(false) + +// Fallback to the default focus check +focusManager.setFocused(undefined) +``` + +*** + +### subscribe() + +```ts +subscribe(listener): () => void; +``` + +Defined in: [packages/query-core/src/subscribable.ts:8](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L8) + +#### Parameters + +##### listener + +`Listener` + +#### Returns + +```ts +(): void; +``` + +##### Returns + +`void` + +#### Inherited from + +```ts +Subscribable.subscribe +``` diff --git a/docs/framework/solid/reference/interfaces/HydrateOptions.md b/docs/framework/solid/reference/interfaces/HydrateOptions.md new file mode 100644 index 00000000000..fe8b92317e3 --- /dev/null +++ b/docs/framework/solid/reference/interfaces/HydrateOptions.md @@ -0,0 +1,43 @@ +--- +id: HydrateOptions +title: HydrateOptions +--- + +Defined in: [packages/query-core/src/hydration.ts:61](https://github.com/TanStack/query/blob/main/packages/query-core/src/hydration.ts#L61) + +Options for `hydrate`, controlling the default options applied to queries/mutations restored from a +`DehydratedState`, and how to reverse any transformation applied by `DehydrateOptions.serializeData`. + +## Properties + +### defaultOptions? + +```ts +optional defaultOptions: object; +``` + +Defined in: [packages/query-core/src/hydration.ts:62](https://github.com/TanStack/query/blob/main/packages/query-core/src/hydration.ts#L62) + +#### deserializeData? + +```ts +optional deserializeData: TransformerFn; +``` + +Transforms a query's `data` after it is read from the dehydrated state, reversing `serializeData`. + +#### mutations? + +```ts +optional mutations: MutationOptions; +``` + +Default options merged into every mutation restored from the dehydrated state. + +#### queries? + +```ts +optional queries: QueryOptions; +``` + +Default options merged into every query restored from the dehydrated state. diff --git a/docs/framework/solid/reference/interfaces/InfiniteData.md b/docs/framework/solid/reference/interfaces/InfiniteData.md new file mode 100644 index 00000000000..4d7ad595c2d --- /dev/null +++ b/docs/framework/solid/reference/interfaces/InfiniteData.md @@ -0,0 +1,36 @@ +--- +id: InfiniteData +title: InfiniteData +--- + +Defined in: [packages/query-core/src/types.ts:210](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L210) + +## Type Parameters + +### TData + +`TData` + +### TPageParam + +`TPageParam` = `unknown` + +## Properties + +### pageParams + +```ts +pageParams: TPageParam[]; +``` + +Defined in: [packages/query-core/src/types.ts:212](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L212) + +*** + +### pages + +```ts +pages: TData[]; +``` + +Defined in: [packages/query-core/src/types.ts:211](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L211) diff --git a/docs/framework/solid/reference/interfaces/InfiniteQueryObserverBaseResult.md b/docs/framework/solid/reference/interfaces/InfiniteQueryObserverBaseResult.md new file mode 100644 index 00000000000..0aa01962aa5 --- /dev/null +++ b/docs/framework/solid/reference/interfaces/InfiniteQueryObserverBaseResult.md @@ -0,0 +1,577 @@ +--- +id: InfiniteQueryObserverBaseResult +title: InfiniteQueryObserverBaseResult +--- + +Defined in: [packages/query-core/src/types.ts:1001](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1001) + +## Extends + +- [`QueryObserverBaseResult`](QueryObserverBaseResult.md)\<`TData`, `TError`\> + +## Extended by + +- [`InfiniteQueryObserverPendingResult`](InfiniteQueryObserverPendingResult.md) +- [`InfiniteQueryObserverLoadingResult`](InfiniteQueryObserverLoadingResult.md) +- [`InfiniteQueryObserverLoadingErrorResult`](InfiniteQueryObserverLoadingErrorResult.md) +- [`InfiniteQueryObserverRefetchErrorResult`](InfiniteQueryObserverRefetchErrorResult.md) +- [`InfiniteQueryObserverSuccessResult`](InfiniteQueryObserverSuccessResult.md) +- [`InfiniteQueryObserverPlaceholderResult`](InfiniteQueryObserverPlaceholderResult.md) + +## Type Parameters + +### TData + +`TData` = `unknown` + +### TError + +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) + +## Properties + +### data + +```ts +data: TData | undefined; +``` + +Defined in: [packages/query-core/src/types.ts:771](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L771) + +The last successfully resolved data for the query. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`data`](QueryObserverBaseResult.md#data) + +*** + +### dataUpdatedAt + +```ts +dataUpdatedAt: number; +``` + +Defined in: [packages/query-core/src/types.ts:775](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L775) + +The timestamp for when the query most recently returned the `status` as `"success"`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`dataUpdatedAt`](QueryObserverBaseResult.md#dataupdatedat) + +*** + +### error + +```ts +error: TError | null; +``` + +Defined in: [packages/query-core/src/types.ts:780](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L780) + +The error object for the query, if an error was thrown. +- Defaults to `null`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`error`](QueryObserverBaseResult.md#error) + +*** + +### errorUpdateCount + +```ts +errorUpdateCount: number; +``` + +Defined in: [packages/query-core/src/types.ts:799](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L799) + +The sum of all errors. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`errorUpdateCount`](QueryObserverBaseResult.md#errorupdatecount) + +*** + +### errorUpdatedAt + +```ts +errorUpdatedAt: number; +``` + +Defined in: [packages/query-core/src/types.ts:784](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L784) + +The timestamp for when the query most recently returned the `status` as `"error"`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`errorUpdatedAt`](QueryObserverBaseResult.md#errorupdatedat) + +*** + +### failureCount + +```ts +failureCount: number; +``` + +Defined in: [packages/query-core/src/types.ts:790](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L790) + +The failure count for the query. +- Incremented every time the query fails. +- Reset to `0` when the query succeeds. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`failureCount`](QueryObserverBaseResult.md#failurecount) + +*** + +### failureReason + +```ts +failureReason: TError | null; +``` + +Defined in: [packages/query-core/src/types.ts:795](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L795) + +The failure reason for the query retry. +- Reset to `null` when the query succeeds. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`failureReason`](QueryObserverBaseResult.md#failurereason) + +*** + +### fetchNextPage() + +```ts +fetchNextPage: (options?) => Promise>; +``` + +Defined in: [packages/query-core/src/types.ts:1008](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1008) + +This function allows you to fetch the next "page" of results. + +#### Parameters + +##### options? + +[`FetchNextPageOptions`](FetchNextPageOptions.md) + +#### Returns + +`Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> + +*** + +### fetchPreviousPage() + +```ts +fetchPreviousPage: (options?) => Promise>; +``` + +Defined in: [packages/query-core/src/types.ts:1014](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1014) + +This function allows you to fetch the previous "page" of results. + +#### Parameters + +##### options? + +[`FetchPreviousPageOptions`](FetchPreviousPageOptions.md) + +#### Returns + +`Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> + +*** + +### fetchStatus + +```ts +fetchStatus: FetchStatus; +``` + +Defined in: [packages/query-core/src/types.ts:889](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L889) + +The fetch status of the query. +- `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. +- `paused`: The query wanted to fetch, but has been `paused`. +- `idle`: The query is not fetching. +- See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`fetchStatus`](QueryObserverBaseResult.md#fetchstatus) + +*** + +### hasNextPage + +```ts +hasNextPage: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1020](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1020) + +Will be `true` if there is a next page to be fetched (known via the `getNextPageParam` option). + +*** + +### hasPreviousPage + +```ts +hasPreviousPage: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1024](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1024) + +Will be `true` if there is a previous page to be fetched (known via the `getPreviousPageParam` option). + +*** + +### isEnabled + +```ts +isEnabled: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:867](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L867) + +`true` if this observer is enabled, `false` otherwise. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isEnabled`](QueryObserverBaseResult.md#isenabled) + +*** + +### isError + +```ts +isError: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:804](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L804) + +A derived boolean from the `status` variable, provided for convenience. +- `true` if the query attempt resulted in an error. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isError`](QueryObserverBaseResult.md#iserror) + +*** + +### isFetched + +```ts +isFetched: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:808](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L808) + +Will be `true` if the query has been fetched. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isFetched`](QueryObserverBaseResult.md#isfetched) + +*** + +### isFetchedAfterMount + +```ts +isFetchedAfterMount: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:813](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L813) + +Will be `true` if the query has been fetched after the component mounted. +- This property can be used to not show any previously cached data. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isFetchedAfterMount`](QueryObserverBaseResult.md#isfetchedaftermount) + +*** + +### isFetching + +```ts +isFetching: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:818](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L818) + +A derived boolean from the `fetchStatus` variable, provided for convenience. +- `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isFetching`](QueryObserverBaseResult.md#isfetching) + +*** + +### isFetchingNextPage + +```ts +isFetchingNextPage: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1032](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1032) + +Will be `true` while fetching the next page with `fetchNextPage`. + +*** + +### isFetchingPreviousPage + +```ts +isFetchingPreviousPage: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1040](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1040) + +Will be `true` while fetching the previous page with `fetchPreviousPage`. + +*** + +### isFetchNextPageError + +```ts +isFetchNextPageError: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1028](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1028) + +Will be `true` if the query failed while fetching the next page. + +*** + +### isFetchPreviousPageError + +```ts +isFetchPreviousPageError: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1036](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1036) + +Will be `true` if the query failed while fetching the previous page. + +*** + +### ~~isInitialLoading~~ + +```ts +isInitialLoading: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:836](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L836) + +#### Deprecated + +`isInitialLoading` is being deprecated in favor of `isLoading` +and will be removed in the next major version. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isInitialLoading`](QueryObserverBaseResult.md#isinitialloading) + +*** + +### isLoading + +```ts +isLoading: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:823](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L823) + +Is `true` whenever the first fetch for a query is in-flight. +- Is the same as `isFetching && isPending`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoading`](QueryObserverBaseResult.md#isloading) + +*** + +### isLoadingError + +```ts +isLoadingError: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:831](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L831) + +Will be `true` if the query failed while fetching for the first time. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoadingError`](QueryObserverBaseResult.md#isloadingerror) + +*** + +### isPaused + +```ts +isPaused: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:841](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L841) + +A derived boolean from the `fetchStatus` variable, provided for convenience. +- The query wanted to fetch, but has been `paused`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPaused`](QueryObserverBaseResult.md#ispaused) + +*** + +### isPending + +```ts +isPending: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:827](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L827) + +Will be `pending` if there's no cached data and no query attempt was finished yet. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPending`](QueryObserverBaseResult.md#ispending) + +*** + +### isPlaceholderData + +```ts +isPlaceholderData: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:845](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L845) + +Will be `true` if the data shown is the placeholder data. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPlaceholderData`](QueryObserverBaseResult.md#isplaceholderdata) + +*** + +### isRefetchError + +```ts +isRefetchError: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:849](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L849) + +Will be `true` if the query failed while refetching. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetchError`](QueryObserverBaseResult.md#isrefetcherror) + +*** + +### isRefetching + +```ts +isRefetching: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:854](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L854) + +Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. +- Is the same as `isFetching && !isPending`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetching`](QueryObserverBaseResult.md#isrefetching) + +*** + +### isStale + +```ts +isStale: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:858](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L858) + +Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isStale`](QueryObserverBaseResult.md#isstale) + +*** + +### isSuccess + +```ts +isSuccess: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:863](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L863) + +A derived boolean from the `status` variable, provided for convenience. +- `true` if the query has received a response with no errors and is ready to display its data. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isSuccess`](QueryObserverBaseResult.md#issuccess) + +*** + +### refetch() + +```ts +refetch: (options?) => Promise>; +``` + +Defined in: [packages/query-core/src/types.ts:871](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L871) + +A function to manually refetch the query. + +#### Parameters + +##### options? + +[`RefetchOptions`](RefetchOptions.md) + +#### Returns + +`Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`refetch`](QueryObserverBaseResult.md#refetch) + +*** + +### status + +```ts +status: QueryStatus; +``` + +Defined in: [packages/query-core/src/types.ts:881](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L881) + +The status of the query. +- Will be: + - `pending` if there's no cached data and no query attempt was finished yet. + - `error` if the query attempt resulted in an error. + - `success` if the query has received a response with no errors and is ready to display its data. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`status`](QueryObserverBaseResult.md#status) diff --git a/docs/framework/solid/reference/interfaces/InfiniteQueryObserverLoadingErrorResult.md b/docs/framework/solid/reference/interfaces/InfiniteQueryObserverLoadingErrorResult.md new file mode 100644 index 00000000000..f5e3352f27c --- /dev/null +++ b/docs/framework/solid/reference/interfaces/InfiniteQueryObserverLoadingErrorResult.md @@ -0,0 +1,600 @@ +--- +id: InfiniteQueryObserverLoadingErrorResult +title: InfiniteQueryObserverLoadingErrorResult +--- + +Defined in: [packages/query-core/src/types.ts:1078](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1078) + +## Extends + +- [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md)\<`TData`, `TError`\> + +## Type Parameters + +### TData + +`TData` = `unknown` + +### TError + +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) + +## Properties + +### data + +```ts +data: undefined; +``` + +Defined in: [packages/query-core/src/types.ts:1082](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1082) + +The last successfully resolved data for the query. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`data`](InfiniteQueryObserverBaseResult.md#data) + +*** + +### dataUpdatedAt + +```ts +dataUpdatedAt: number; +``` + +Defined in: [packages/query-core/src/types.ts:775](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L775) + +The timestamp for when the query most recently returned the `status` as `"success"`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`dataUpdatedAt`](InfiniteQueryObserverBaseResult.md#dataupdatedat) + +*** + +### error + +```ts +error: TError; +``` + +Defined in: [packages/query-core/src/types.ts:1083](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1083) + +The error object for the query, if an error was thrown. +- Defaults to `null`. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`error`](InfiniteQueryObserverBaseResult.md#error) + +*** + +### errorUpdateCount + +```ts +errorUpdateCount: number; +``` + +Defined in: [packages/query-core/src/types.ts:799](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L799) + +The sum of all errors. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`errorUpdateCount`](InfiniteQueryObserverBaseResult.md#errorupdatecount) + +*** + +### errorUpdatedAt + +```ts +errorUpdatedAt: number; +``` + +Defined in: [packages/query-core/src/types.ts:784](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L784) + +The timestamp for when the query most recently returned the `status` as `"error"`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`errorUpdatedAt`](InfiniteQueryObserverBaseResult.md#errorupdatedat) + +*** + +### failureCount + +```ts +failureCount: number; +``` + +Defined in: [packages/query-core/src/types.ts:790](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L790) + +The failure count for the query. +- Incremented every time the query fails. +- Reset to `0` when the query succeeds. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`failureCount`](InfiniteQueryObserverBaseResult.md#failurecount) + +*** + +### failureReason + +```ts +failureReason: TError | null; +``` + +Defined in: [packages/query-core/src/types.ts:795](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L795) + +The failure reason for the query retry. +- Reset to `null` when the query succeeds. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`failureReason`](InfiniteQueryObserverBaseResult.md#failurereason) + +*** + +### fetchNextPage() + +```ts +fetchNextPage: (options?) => Promise>; +``` + +Defined in: [packages/query-core/src/types.ts:1008](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1008) + +This function allows you to fetch the next "page" of results. + +#### Parameters + +##### options? + +[`FetchNextPageOptions`](FetchNextPageOptions.md) + +#### Returns + +`Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`fetchNextPage`](InfiniteQueryObserverBaseResult.md#fetchnextpage) + +*** + +### fetchPreviousPage() + +```ts +fetchPreviousPage: (options?) => Promise>; +``` + +Defined in: [packages/query-core/src/types.ts:1014](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1014) + +This function allows you to fetch the previous "page" of results. + +#### Parameters + +##### options? + +[`FetchPreviousPageOptions`](FetchPreviousPageOptions.md) + +#### Returns + +`Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`fetchPreviousPage`](InfiniteQueryObserverBaseResult.md#fetchpreviouspage) + +*** + +### fetchStatus + +```ts +fetchStatus: FetchStatus; +``` + +Defined in: [packages/query-core/src/types.ts:889](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L889) + +The fetch status of the query. +- `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. +- `paused`: The query wanted to fetch, but has been `paused`. +- `idle`: The query is not fetching. +- See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`fetchStatus`](InfiniteQueryObserverBaseResult.md#fetchstatus) + +*** + +### hasNextPage + +```ts +hasNextPage: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1020](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1020) + +Will be `true` if there is a next page to be fetched (known via the `getNextPageParam` option). + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`hasNextPage`](InfiniteQueryObserverBaseResult.md#hasnextpage) + +*** + +### hasPreviousPage + +```ts +hasPreviousPage: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1024](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1024) + +Will be `true` if there is a previous page to be fetched (known via the `getPreviousPageParam` option). + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`hasPreviousPage`](InfiniteQueryObserverBaseResult.md#haspreviouspage) + +*** + +### isEnabled + +```ts +isEnabled: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:867](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L867) + +`true` if this observer is enabled, `false` otherwise. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isEnabled`](InfiniteQueryObserverBaseResult.md#isenabled) + +*** + +### isError + +```ts +isError: true; +``` + +Defined in: [packages/query-core/src/types.ts:1084](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1084) + +A derived boolean from the `status` variable, provided for convenience. +- `true` if the query attempt resulted in an error. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isError`](InfiniteQueryObserverBaseResult.md#iserror) + +*** + +### isFetched + +```ts +isFetched: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:808](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L808) + +Will be `true` if the query has been fetched. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetched`](InfiniteQueryObserverBaseResult.md#isfetched) + +*** + +### isFetchedAfterMount + +```ts +isFetchedAfterMount: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:813](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L813) + +Will be `true` if the query has been fetched after the component mounted. +- This property can be used to not show any previously cached data. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchedAfterMount`](InfiniteQueryObserverBaseResult.md#isfetchedaftermount) + +*** + +### isFetching + +```ts +isFetching: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:818](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L818) + +A derived boolean from the `fetchStatus` variable, provided for convenience. +- `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetching`](InfiniteQueryObserverBaseResult.md#isfetching) + +*** + +### isFetchingNextPage + +```ts +isFetchingNextPage: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1032](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1032) + +Will be `true` while fetching the next page with `fetchNextPage`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchingNextPage`](InfiniteQueryObserverBaseResult.md#isfetchingnextpage) + +*** + +### isFetchingPreviousPage + +```ts +isFetchingPreviousPage: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1040](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1040) + +Will be `true` while fetching the previous page with `fetchPreviousPage`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchingPreviousPage`](InfiniteQueryObserverBaseResult.md#isfetchingpreviouspage) + +*** + +### isFetchNextPageError + +```ts +isFetchNextPageError: false; +``` + +Defined in: [packages/query-core/src/types.ts:1089](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1089) + +Will be `true` if the query failed while fetching the next page. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchNextPageError`](InfiniteQueryObserverBaseResult.md#isfetchnextpageerror) + +*** + +### isFetchPreviousPageError + +```ts +isFetchPreviousPageError: false; +``` + +Defined in: [packages/query-core/src/types.ts:1090](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1090) + +Will be `true` if the query failed while fetching the previous page. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchPreviousPageError`](InfiniteQueryObserverBaseResult.md#isfetchpreviouspageerror) + +*** + +### ~~isInitialLoading~~ + +```ts +isInitialLoading: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:836](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L836) + +#### Deprecated + +`isInitialLoading` is being deprecated in favor of `isLoading` +and will be removed in the next major version. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isInitialLoading`](InfiniteQueryObserverBaseResult.md#isinitialloading) + +*** + +### isLoading + +```ts +isLoading: false; +``` + +Defined in: [packages/query-core/src/types.ts:1086](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1086) + +Is `true` whenever the first fetch for a query is in-flight. +- Is the same as `isFetching && isPending`. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoading`](InfiniteQueryObserverBaseResult.md#isloading) + +*** + +### isLoadingError + +```ts +isLoadingError: true; +``` + +Defined in: [packages/query-core/src/types.ts:1087](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1087) + +Will be `true` if the query failed while fetching for the first time. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoadingError`](InfiniteQueryObserverBaseResult.md#isloadingerror) + +*** + +### isPaused + +```ts +isPaused: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:841](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L841) + +A derived boolean from the `fetchStatus` variable, provided for convenience. +- The query wanted to fetch, but has been `paused`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPaused`](InfiniteQueryObserverBaseResult.md#ispaused) + +*** + +### isPending + +```ts +isPending: false; +``` + +Defined in: [packages/query-core/src/types.ts:1085](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1085) + +Will be `pending` if there's no cached data and no query attempt was finished yet. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPending`](InfiniteQueryObserverBaseResult.md#ispending) + +*** + +### isPlaceholderData + +```ts +isPlaceholderData: false; +``` + +Defined in: [packages/query-core/src/types.ts:1092](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1092) + +Will be `true` if the data shown is the placeholder data. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPlaceholderData`](InfiniteQueryObserverBaseResult.md#isplaceholderdata) + +*** + +### isRefetchError + +```ts +isRefetchError: false; +``` + +Defined in: [packages/query-core/src/types.ts:1088](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1088) + +Will be `true` if the query failed while refetching. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isRefetchError`](InfiniteQueryObserverBaseResult.md#isrefetcherror) + +*** + +### isRefetching + +```ts +isRefetching: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:854](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L854) + +Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. +- Is the same as `isFetching && !isPending`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isRefetching`](InfiniteQueryObserverBaseResult.md#isrefetching) + +*** + +### isStale + +```ts +isStale: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:858](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L858) + +Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isStale`](InfiniteQueryObserverBaseResult.md#isstale) + +*** + +### isSuccess + +```ts +isSuccess: false; +``` + +Defined in: [packages/query-core/src/types.ts:1091](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1091) + +A derived boolean from the `status` variable, provided for convenience. +- `true` if the query has received a response with no errors and is ready to display its data. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isSuccess`](InfiniteQueryObserverBaseResult.md#issuccess) + +*** + +### refetch() + +```ts +refetch: (options?) => Promise>; +``` + +Defined in: [packages/query-core/src/types.ts:871](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L871) + +A function to manually refetch the query. + +#### Parameters + +##### options? + +[`RefetchOptions`](RefetchOptions.md) + +#### Returns + +`Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`refetch`](InfiniteQueryObserverBaseResult.md#refetch) + +*** + +### status + +```ts +status: "error"; +``` + +Defined in: [packages/query-core/src/types.ts:1093](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1093) + +The status of the query. +- Will be: + - `pending` if there's no cached data and no query attempt was finished yet. + - `error` if the query attempt resulted in an error. + - `success` if the query has received a response with no errors and is ready to display its data. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`status`](InfiniteQueryObserverBaseResult.md#status) diff --git a/docs/framework/solid/reference/interfaces/InfiniteQueryObserverLoadingResult.md b/docs/framework/solid/reference/interfaces/InfiniteQueryObserverLoadingResult.md new file mode 100644 index 00000000000..b7aa67744c0 --- /dev/null +++ b/docs/framework/solid/reference/interfaces/InfiniteQueryObserverLoadingResult.md @@ -0,0 +1,600 @@ +--- +id: InfiniteQueryObserverLoadingResult +title: InfiniteQueryObserverLoadingResult +--- + +Defined in: [packages/query-core/src/types.ts:1060](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1060) + +## Extends + +- [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md)\<`TData`, `TError`\> + +## Type Parameters + +### TData + +`TData` = `unknown` + +### TError + +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) + +## Properties + +### data + +```ts +data: undefined; +``` + +Defined in: [packages/query-core/src/types.ts:1064](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1064) + +The last successfully resolved data for the query. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`data`](InfiniteQueryObserverBaseResult.md#data) + +*** + +### dataUpdatedAt + +```ts +dataUpdatedAt: number; +``` + +Defined in: [packages/query-core/src/types.ts:775](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L775) + +The timestamp for when the query most recently returned the `status` as `"success"`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`dataUpdatedAt`](InfiniteQueryObserverBaseResult.md#dataupdatedat) + +*** + +### error + +```ts +error: null; +``` + +Defined in: [packages/query-core/src/types.ts:1065](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1065) + +The error object for the query, if an error was thrown. +- Defaults to `null`. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`error`](InfiniteQueryObserverBaseResult.md#error) + +*** + +### errorUpdateCount + +```ts +errorUpdateCount: number; +``` + +Defined in: [packages/query-core/src/types.ts:799](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L799) + +The sum of all errors. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`errorUpdateCount`](InfiniteQueryObserverBaseResult.md#errorupdatecount) + +*** + +### errorUpdatedAt + +```ts +errorUpdatedAt: number; +``` + +Defined in: [packages/query-core/src/types.ts:784](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L784) + +The timestamp for when the query most recently returned the `status` as `"error"`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`errorUpdatedAt`](InfiniteQueryObserverBaseResult.md#errorupdatedat) + +*** + +### failureCount + +```ts +failureCount: number; +``` + +Defined in: [packages/query-core/src/types.ts:790](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L790) + +The failure count for the query. +- Incremented every time the query fails. +- Reset to `0` when the query succeeds. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`failureCount`](InfiniteQueryObserverBaseResult.md#failurecount) + +*** + +### failureReason + +```ts +failureReason: TError | null; +``` + +Defined in: [packages/query-core/src/types.ts:795](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L795) + +The failure reason for the query retry. +- Reset to `null` when the query succeeds. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`failureReason`](InfiniteQueryObserverBaseResult.md#failurereason) + +*** + +### fetchNextPage() + +```ts +fetchNextPage: (options?) => Promise>; +``` + +Defined in: [packages/query-core/src/types.ts:1008](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1008) + +This function allows you to fetch the next "page" of results. + +#### Parameters + +##### options? + +[`FetchNextPageOptions`](FetchNextPageOptions.md) + +#### Returns + +`Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`fetchNextPage`](InfiniteQueryObserverBaseResult.md#fetchnextpage) + +*** + +### fetchPreviousPage() + +```ts +fetchPreviousPage: (options?) => Promise>; +``` + +Defined in: [packages/query-core/src/types.ts:1014](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1014) + +This function allows you to fetch the previous "page" of results. + +#### Parameters + +##### options? + +[`FetchPreviousPageOptions`](FetchPreviousPageOptions.md) + +#### Returns + +`Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`fetchPreviousPage`](InfiniteQueryObserverBaseResult.md#fetchpreviouspage) + +*** + +### fetchStatus + +```ts +fetchStatus: FetchStatus; +``` + +Defined in: [packages/query-core/src/types.ts:889](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L889) + +The fetch status of the query. +- `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. +- `paused`: The query wanted to fetch, but has been `paused`. +- `idle`: The query is not fetching. +- See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`fetchStatus`](InfiniteQueryObserverBaseResult.md#fetchstatus) + +*** + +### hasNextPage + +```ts +hasNextPage: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1020](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1020) + +Will be `true` if there is a next page to be fetched (known via the `getNextPageParam` option). + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`hasNextPage`](InfiniteQueryObserverBaseResult.md#hasnextpage) + +*** + +### hasPreviousPage + +```ts +hasPreviousPage: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1024](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1024) + +Will be `true` if there is a previous page to be fetched (known via the `getPreviousPageParam` option). + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`hasPreviousPage`](InfiniteQueryObserverBaseResult.md#haspreviouspage) + +*** + +### isEnabled + +```ts +isEnabled: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:867](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L867) + +`true` if this observer is enabled, `false` otherwise. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isEnabled`](InfiniteQueryObserverBaseResult.md#isenabled) + +*** + +### isError + +```ts +isError: false; +``` + +Defined in: [packages/query-core/src/types.ts:1066](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1066) + +A derived boolean from the `status` variable, provided for convenience. +- `true` if the query attempt resulted in an error. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isError`](InfiniteQueryObserverBaseResult.md#iserror) + +*** + +### isFetched + +```ts +isFetched: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:808](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L808) + +Will be `true` if the query has been fetched. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetched`](InfiniteQueryObserverBaseResult.md#isfetched) + +*** + +### isFetchedAfterMount + +```ts +isFetchedAfterMount: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:813](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L813) + +Will be `true` if the query has been fetched after the component mounted. +- This property can be used to not show any previously cached data. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchedAfterMount`](InfiniteQueryObserverBaseResult.md#isfetchedaftermount) + +*** + +### isFetching + +```ts +isFetching: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:818](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L818) + +A derived boolean from the `fetchStatus` variable, provided for convenience. +- `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetching`](InfiniteQueryObserverBaseResult.md#isfetching) + +*** + +### isFetchingNextPage + +```ts +isFetchingNextPage: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1032](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1032) + +Will be `true` while fetching the next page with `fetchNextPage`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchingNextPage`](InfiniteQueryObserverBaseResult.md#isfetchingnextpage) + +*** + +### isFetchingPreviousPage + +```ts +isFetchingPreviousPage: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1040](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1040) + +Will be `true` while fetching the previous page with `fetchPreviousPage`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchingPreviousPage`](InfiniteQueryObserverBaseResult.md#isfetchingpreviouspage) + +*** + +### isFetchNextPageError + +```ts +isFetchNextPageError: false; +``` + +Defined in: [packages/query-core/src/types.ts:1071](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1071) + +Will be `true` if the query failed while fetching the next page. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchNextPageError`](InfiniteQueryObserverBaseResult.md#isfetchnextpageerror) + +*** + +### isFetchPreviousPageError + +```ts +isFetchPreviousPageError: false; +``` + +Defined in: [packages/query-core/src/types.ts:1072](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1072) + +Will be `true` if the query failed while fetching the previous page. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchPreviousPageError`](InfiniteQueryObserverBaseResult.md#isfetchpreviouspageerror) + +*** + +### ~~isInitialLoading~~ + +```ts +isInitialLoading: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:836](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L836) + +#### Deprecated + +`isInitialLoading` is being deprecated in favor of `isLoading` +and will be removed in the next major version. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isInitialLoading`](InfiniteQueryObserverBaseResult.md#isinitialloading) + +*** + +### isLoading + +```ts +isLoading: true; +``` + +Defined in: [packages/query-core/src/types.ts:1068](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1068) + +Is `true` whenever the first fetch for a query is in-flight. +- Is the same as `isFetching && isPending`. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoading`](InfiniteQueryObserverBaseResult.md#isloading) + +*** + +### isLoadingError + +```ts +isLoadingError: false; +``` + +Defined in: [packages/query-core/src/types.ts:1069](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1069) + +Will be `true` if the query failed while fetching for the first time. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoadingError`](InfiniteQueryObserverBaseResult.md#isloadingerror) + +*** + +### isPaused + +```ts +isPaused: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:841](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L841) + +A derived boolean from the `fetchStatus` variable, provided for convenience. +- The query wanted to fetch, but has been `paused`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPaused`](InfiniteQueryObserverBaseResult.md#ispaused) + +*** + +### isPending + +```ts +isPending: true; +``` + +Defined in: [packages/query-core/src/types.ts:1067](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1067) + +Will be `pending` if there's no cached data and no query attempt was finished yet. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPending`](InfiniteQueryObserverBaseResult.md#ispending) + +*** + +### isPlaceholderData + +```ts +isPlaceholderData: false; +``` + +Defined in: [packages/query-core/src/types.ts:1074](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1074) + +Will be `true` if the data shown is the placeholder data. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPlaceholderData`](InfiniteQueryObserverBaseResult.md#isplaceholderdata) + +*** + +### isRefetchError + +```ts +isRefetchError: false; +``` + +Defined in: [packages/query-core/src/types.ts:1070](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1070) + +Will be `true` if the query failed while refetching. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isRefetchError`](InfiniteQueryObserverBaseResult.md#isrefetcherror) + +*** + +### isRefetching + +```ts +isRefetching: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:854](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L854) + +Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. +- Is the same as `isFetching && !isPending`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isRefetching`](InfiniteQueryObserverBaseResult.md#isrefetching) + +*** + +### isStale + +```ts +isStale: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:858](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L858) + +Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isStale`](InfiniteQueryObserverBaseResult.md#isstale) + +*** + +### isSuccess + +```ts +isSuccess: false; +``` + +Defined in: [packages/query-core/src/types.ts:1073](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1073) + +A derived boolean from the `status` variable, provided for convenience. +- `true` if the query has received a response with no errors and is ready to display its data. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isSuccess`](InfiniteQueryObserverBaseResult.md#issuccess) + +*** + +### refetch() + +```ts +refetch: (options?) => Promise>; +``` + +Defined in: [packages/query-core/src/types.ts:871](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L871) + +A function to manually refetch the query. + +#### Parameters + +##### options? + +[`RefetchOptions`](RefetchOptions.md) + +#### Returns + +`Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`refetch`](InfiniteQueryObserverBaseResult.md#refetch) + +*** + +### status + +```ts +status: "pending"; +``` + +Defined in: [packages/query-core/src/types.ts:1075](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1075) + +The status of the query. +- Will be: + - `pending` if there's no cached data and no query attempt was finished yet. + - `error` if the query attempt resulted in an error. + - `success` if the query has received a response with no errors and is ready to display its data. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`status`](InfiniteQueryObserverBaseResult.md#status) diff --git a/docs/framework/solid/reference/interfaces/InfiniteQueryObserverOptions.md b/docs/framework/solid/reference/interfaces/InfiniteQueryObserverOptions.md index dfd2f69f412..5fe9870e1dd 100644 --- a/docs/framework/solid/reference/interfaces/InfiniteQueryObserverOptions.md +++ b/docs/framework/solid/reference/interfaces/InfiniteQueryObserverOptions.md @@ -3,13 +3,13 @@ id: InfiniteQueryObserverOptions title: InfiniteQueryObserverOptions --- -Defined in: [QueryClient.ts:62](https://github.com/TanStack/query/blob/main/packages/solid-query/src/QueryClient.ts#L62) +Defined in: [packages/solid-query/src/QueryClient.ts:62](https://github.com/TanStack/query/blob/main/packages/solid-query/src/QueryClient.ts#L62) The core `InfiniteQueryObserverOptions`, with Solid's `reconcile` option added. ## Extends -- `OmitKeyof`\<`QueryCoreInfiniteQueryObserverOptions`\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`, `TPageParam`\>, `"structuralSharing"`\> +- [`OmitKeyof`](../type-aliases/OmitKeyof.md)\<`QueryCoreInfiniteQueryObserverOptions`\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`, `TPageParam`\>, `"structuralSharing"`\> ## Type Parameters @@ -21,7 +21,7 @@ The type of a single page, as your `queryFn` resolves it. ### TError -`TError` = `DefaultError` +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) The type of errors your `queryFn` may throw. @@ -33,7 +33,7 @@ The type `data` ends up as after `select` runs. ### TQueryKey -`TQueryKey` *extends* `QueryKey` = `QueryKey` +`TQueryKey` *extends* [`QueryKey`](../type-aliases/QueryKey.md) = [`QueryKey`](../type-aliases/QueryKey.md) The type of your `queryKey`. @@ -45,15 +45,636 @@ The type of the parameter passed to `queryFn` to fetch a given page. ## Properties +### enabled? + +```ts +optional enabled: QueryBooleanOption, TQueryKey>; +``` + +Defined in: [packages/query-core/src/types.ts:398](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L398) + +Set this to `false` or a function that returns `false` to disable automatic refetching when the query mounts or changes query keys. +To refetch the query, use the `refetch` method returned from the `useQuery` instance. +Accepts a boolean or function that returns a boolean. + +Defaults to `true`. + +#### Inherited from + +```ts +OmitKeyof.enabled +``` + +*** + +### gcTime? + +```ts +optional gcTime: number; +``` + +Defined in: [packages/query-core/src/types.ts:277](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L277) + +The time in milliseconds that unused/inactive cache data remains in memory. +When a query's cache becomes unused or inactive, that cache data will be garbage collected after this duration. +When different garbage collection times are specified, the longest one will be used. +Setting it to `Infinity` will disable garbage collection. + +Defaults to `5 * 60 * 1000` (5 minutes), or `Infinity` during SSR. + +Note: the maximum allowed time is about 24 days, imposed by `setTimeout`'s 32-bit signed integer delay — see +`timeoutManager.setTimeoutProvider` for a workaround. + +#### Inherited from + +[`QueryExecuteOptions`](QueryExecuteOptions.md).[`gcTime`](QueryExecuteOptions.md#gctime) + +*** + +### getNextPageParam + +```ts +getNextPageParam: GetNextPageParamFunction; +``` + +Defined in: [packages/query-core/src/types.ts:365](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L365) + +This function can be set to automatically get the next cursor for infinite queries. +The result will also be used to determine the value of `hasNextPage`. + +#### Inherited from + +```ts +OmitKeyof.getNextPageParam +``` + +*** + +### getPreviousPageParam? + +```ts +optional getPreviousPageParam: GetPreviousPageParamFunction; +``` + +Defined in: [packages/query-core/src/types.ts:360](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L360) + +This function can be set to automatically get the previous cursor for infinite queries. +The result will also be used to determine the value of `hasPreviousPage`. + +#### Inherited from + +```ts +OmitKeyof.getPreviousPageParam +``` + +*** + +### initialData? + +```ts +optional initialData: + | InfiniteData +| InitialDataFunction>; +``` + +Defined in: [packages/query-core/src/types.ts:317](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L317) + +If set, this value will be used as the initial data for the query cache (as long as the query hasn't been +created or cached yet). +If set to a function, the function will be called **once** during the shared/root query initialization, and be +expected to synchronously return the initial data. +Initial data is considered stale by default unless a `staleTime` has been set. +`initialData` **is persisted** to the cache. + +#### Inherited from + +```ts +OmitKeyof.initialData +``` + +*** + +### initialDataUpdatedAt? + +```ts +optional initialDataUpdatedAt: number | () => number | undefined; +``` + +Defined in: [packages/query-core/src/types.ts:321](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L321) + +If set, this value will be used as the time (in milliseconds) of when the `initialData` itself was last updated. + +#### Inherited from + +```ts +OmitKeyof.initialDataUpdatedAt +``` + +*** + +### initialPageParam + +```ts +initialPageParam: TPageParam; +``` + +Defined in: [packages/query-core/src/types.ts:349](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L349) + +#### Inherited from + +```ts +OmitKeyof.initialPageParam +``` + +*** + +### maxPages? + +```ts +optional maxPages: number; +``` + +Defined in: [packages/query-core/src/types.ts:345](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L345) + +Maximum number of pages to store in the data of an infinite query. + +#### Inherited from + +[`QueryExecuteOptions`](QueryExecuteOptions.md).[`maxPages`](QueryExecuteOptions.md#maxpages) + +*** + +### meta? + +```ts +optional meta: Record; +``` + +Defined in: [packages/query-core/src/types.ts:341](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L341) + +Additional payload to be stored on each query. +Use this property to pass information that can be used in other places. + +#### Inherited from + +[`QueryExecuteOptions`](QueryExecuteOptions.md).[`meta`](QueryExecuteOptions.md#meta) + +*** + +### networkMode? + +```ts +optional networkMode: NetworkMode; +``` + +Defined in: [packages/query-core/src/types.ts:265](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L265) + +Controls whether a query is allowed to run based on the current network connectivity. + +Defaults to `'online'`. + +#### See + +[Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. + +#### Inherited from + +[`QueryExecuteOptions`](QueryExecuteOptions.md).[`networkMode`](QueryExecuteOptions.md#networkmode) + +*** + +### notifyOnChangeProps? + +```ts +optional notifyOnChangeProps: NotifyOnChangeProps; +``` + +Defined in: [packages/query-core/src/types.ts:484](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L484) + +If set, the component will only re-render if any of the listed properties change. +When set to `['data', 'error']`, the component will only re-render when the `data` or `error` properties change. +When set to `'all'`, the component will re-render whenever a query is updated. +When set to a function, the function will be executed to compute the list of properties. + +Defaults to `undefined`, in which case property access is tracked automatically, and the +component only re-renders when one of the tracked properties changes. + +#### Inherited from + +```ts +OmitKeyof.notifyOnChangeProps +``` + +*** + +### persister? + +```ts +optional persister: QueryPersister, TPageParam>; +``` + +Defined in: [packages/query-core/src/types.ts:290](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L290) + +This option can be used to persist the result of a query to an external storage, bypassing the need to actually +call the `queryFn`. Useful for persisting a query's data across e.g. server/client boundaries. + +#### Inherited from + +```ts +OmitKeyof.persister +``` + +*** + +### placeholderData? + +```ts +optional placeholderData: + | InfiniteData +| PlaceholderDataFunction, TError, InfiniteData, TQueryKey>; +``` + +Defined in: [packages/query-core/src/types.ts:511](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L511) + +If set, this value will be used as the placeholder data for this particular query observer while the query is still in the `loading` data and no initialData has been provided. + +#### Inherited from + +```ts +OmitKeyof.placeholderData +``` + +*** + +### queryFn? + +```ts +optional queryFn: + | typeof skipToken +| QueryFunction; +``` + +Defined in: [packages/query-core/src/types.ts:285](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L285) + +The function that the query will use to request data. +Required, unless a default query function has been set via `queryClient.setQueryDefaults` or +`queryClient.setDefaultOptions`. +Receives a [QueryFunctionContext](../type-aliases/QueryFunctionContext.md). +Must return a promise that will either resolve data or throw an error. The data cannot be `undefined`. + +#### Inherited from + +```ts +OmitKeyof.queryFn +``` + +*** + +### queryHash? + +```ts +optional queryHash: string; +``` + +Defined in: [packages/query-core/src/types.ts:295](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L295) + +The hashed form of `queryKey`, computed with `queryKeyHashFn` (or the default hashing function otherwise). Used +as the actual cache key internally. + +#### Inherited from + +[`QueryExecuteOptions`](QueryExecuteOptions.md).[`queryHash`](QueryExecuteOptions.md#queryhash) + +*** + +### queryKey + +```ts +queryKey: TQueryKey & object; +``` + +Defined in: [packages/query-core/src/types.ts:304](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L304) + +The query key to use for this query. + +The query key will be hashed into a stable hash. See [Query Keys](https://tanstack.com/query/latest/docs/framework/react/guides/query-keys) +for more information. + +The query will automatically update when this key changes (as long as `enabled` is not set to `false`). + +#### Inherited from + +```ts +OmitKeyof.queryKey +``` + +*** + +### queryKeyHashFn? + +```ts +optional queryKeyHashFn: QueryKeyHashFunction; +``` + +Defined in: [packages/query-core/src/types.ts:308](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L308) + +If specified, this function is used to hash the `queryKey` to a string. + +#### Inherited from + +```ts +OmitKeyof.queryKeyHashFn +``` + +*** + ### reconcile? ```ts optional reconcile: string | false | (oldData, newData) => TData; ``` -Defined in: [QueryClient.ts:84](https://github.com/TanStack/query/blob/main/packages/solid-query/src/QueryClient.ts#L84) +Defined in: [packages/solid-query/src/QueryClient.ts:84](https://github.com/TanStack/query/blob/main/packages/solid-query/src/QueryClient.ts#L84) Set this to a reconciliation key to enable reconciliation between query results. Set this to `false` to disable reconciliation between query results. Set this to a function which accepts the old and new data and returns resolved data of the same type to implement custom reconciliation logic. Defaults reconciliation to false. + +*** + +### refetchInterval? + +```ts +optional refetchInterval: number | false | (query) => number | false | undefined; +``` + +Defined in: [packages/query-core/src/types.ts:414](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L414) + +If set to a number, the query will continuously refetch at this frequency in milliseconds. +If set to a function, the function will be executed with the latest data and query to compute a frequency + +Defaults to `false`. + +#### Inherited from + +```ts +OmitKeyof.refetchInterval +``` + +*** + +### refetchIntervalInBackground? + +```ts +optional refetchIntervalInBackground: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:425](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L425) + +If set to `true`, the query will continue to refetch while their tab/window is in the background. + +Defaults to `false`. + +#### Inherited from + +```ts +OmitKeyof.refetchIntervalInBackground +``` + +*** + +### refetchOnMount? + +```ts +optional refetchOnMount: boolean | "always" | (query) => boolean | "always"; +``` + +Defined in: [packages/query-core/src/types.ts:462](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L462) + +If set to `true`, the query will refetch on mount if the data is stale. +If set to `false`, will disable additional instances of a query to trigger background refetch. +If set to `'always'`, the query will always refetch on mount (except when `staleTime: 'static'` is used). +If set to a function, the function will be executed with the latest data and query to compute the value + +Defaults to `true`. + +#### Inherited from + +```ts +OmitKeyof.refetchOnMount +``` + +*** + +### refetchOnReconnect? + +```ts +optional refetchOnReconnect: boolean | "always" | (query) => boolean | "always"; +``` + +Defined in: [packages/query-core/src/types.ts:448](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L448) + +If set to `true`, the query will refetch on reconnect if the data is stale. +If set to `false`, the query will not refetch on reconnect. +If set to `'always'`, the query will always refetch on reconnect (except when `staleTime: 'static'` is used). +If set to a function, the function will be executed with the latest data and query to compute the value. + +Defaults to `true` unless `networkMode` is `'always'`. + +#### Inherited from + +```ts +OmitKeyof.refetchOnReconnect +``` + +*** + +### refetchOnWindowFocus? + +```ts +optional refetchOnWindowFocus: boolean | "always" | (query) => boolean | "always"; +``` + +Defined in: [packages/query-core/src/types.ts:434](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L434) + +If set to `true`, the query will refetch on window focus if the data is stale. +If set to `false`, the query will not refetch on window focus. +If set to `'always'`, the query will always refetch on window focus (except when `staleTime: 'static'` is used). +If set to a function, the function will be executed with the latest data and query to compute the value. + +Defaults to `true`. + +#### Inherited from + +```ts +OmitKeyof.refetchOnWindowFocus +``` + +*** + +### retry? + +```ts +optional retry: RetryValue; +``` + +Defined in: [packages/query-core/src/types.ts:246](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L246) + +If `false`, failed queries will not retry by default. +If `true`, failed queries will retry infinitely. +If set to an integer number, e.g. 3, failed queries will retry until the failed query count meets that number. +If set to a function `(failureCount, error) => boolean` failed queries will retry until the function returns false. + +Defaults to `3` on the client and `0` on the server. + +#### Inherited from + +```ts +OmitKeyof.retry +``` + +*** + +### retryDelay? + +```ts +optional retryDelay: RetryDelayValue; +``` + +Defined in: [packages/query-core/src/types.ts:258](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L258) + +This function receives a `retryAttempt` integer and the actual Error and returns the delay to apply before the +next attempt in milliseconds. + +A function like `attempt => Math.min(attempt > 1 ? 2 ** attempt * 1000 : 1000, 30 * 1000)` applies exponential +backoff. + +A function like `attempt => attempt * 1000` applies linear backoff. + +Defaults to a function that applies exponential backoff, capped at 30 seconds. + +#### Inherited from + +```ts +OmitKeyof.retryDelay +``` + +*** + +### retryOnMount? + +```ts +optional retryOnMount: QueryBooleanOption, TQueryKey>; +``` + +Defined in: [packages/query-core/src/types.ts:474](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L474) + +If set to `false`, the query will not be retried on mount if it contains an error. +If set to a function, the function will be executed with the query to compute the value. + +Defaults to `true`. + +#### Inherited from + +```ts +OmitKeyof.retryOnMount +``` + +*** + +### select()? + +```ts +optional select: (data) => TData; +``` + +Defined in: [packages/query-core/src/types.ts:500](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L500) + +This option can be used to transform or select a part of the data returned by the query function. It affects +the returned `data` value, but does not affect what gets stored in the query cache. +The `select` function will only run if `data` changed, or if the reference to the `select` function itself +changes. To optimize, memoize the function so its reference stays stable across calls. + +#### Parameters + +##### data + +[`InfiniteData`](InfiniteData.md) + +#### Returns + +`TData` + +#### Inherited from + +```ts +OmitKeyof.select +``` + +*** + +### staleTime? + +```ts +optional staleTime: StaleTimeFunction, TQueryKey>; +``` + +Defined in: [packages/query-core/src/types.ts:407](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L407) + +The time in milliseconds after data is considered stale. +If set to `Infinity`, the data will never be considered stale. +If set to `'static'`, the data will never be considered stale. +If set to a function, the function will be executed with the query to compute a `staleTime`. + +Defaults to `0`. + +#### Inherited from + +```ts +OmitKeyof.staleTime +``` + +*** + +### suspense? + +```ts +optional suspense: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:507](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L507) + +If set to `true`, the query will suspend when `status === 'pending'` +and throw errors when `status === 'error'`. + +Defaults to `false`. + +#### Inherited from + +```ts +OmitKeyof.suspense +``` + +*** + +### throwOnError? + +```ts +optional throwOnError: ThrowOnError, TQueryKey>; +``` + +Defined in: [packages/query-core/src/types.ts:493](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L493) + +Whether errors should be thrown instead of setting the `error` property. +If set to `true` or `suspense` is `true`, all errors will be thrown to the error boundary. +If set to `false` and `suspense` is `false`, errors are returned as state. +If set to a function, it will be passed the error and the query, and it should return a boolean indicating whether to show the error in an error boundary (`true`) or return the error as state (`false`). + +Defaults to `false`. + +#### Inherited from + +```ts +OmitKeyof.throwOnError +``` diff --git a/docs/framework/solid/reference/interfaces/InfiniteQueryObserverPendingResult.md b/docs/framework/solid/reference/interfaces/InfiniteQueryObserverPendingResult.md new file mode 100644 index 00000000000..a09301ab6c4 --- /dev/null +++ b/docs/framework/solid/reference/interfaces/InfiniteQueryObserverPendingResult.md @@ -0,0 +1,600 @@ +--- +id: InfiniteQueryObserverPendingResult +title: InfiniteQueryObserverPendingResult +--- + +Defined in: [packages/query-core/src/types.ts:1043](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1043) + +## Extends + +- [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md)\<`TData`, `TError`\> + +## Type Parameters + +### TData + +`TData` = `unknown` + +### TError + +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) + +## Properties + +### data + +```ts +data: undefined; +``` + +Defined in: [packages/query-core/src/types.ts:1047](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1047) + +The last successfully resolved data for the query. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`data`](InfiniteQueryObserverBaseResult.md#data) + +*** + +### dataUpdatedAt + +```ts +dataUpdatedAt: number; +``` + +Defined in: [packages/query-core/src/types.ts:775](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L775) + +The timestamp for when the query most recently returned the `status` as `"success"`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`dataUpdatedAt`](InfiniteQueryObserverBaseResult.md#dataupdatedat) + +*** + +### error + +```ts +error: null; +``` + +Defined in: [packages/query-core/src/types.ts:1048](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1048) + +The error object for the query, if an error was thrown. +- Defaults to `null`. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`error`](InfiniteQueryObserverBaseResult.md#error) + +*** + +### errorUpdateCount + +```ts +errorUpdateCount: number; +``` + +Defined in: [packages/query-core/src/types.ts:799](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L799) + +The sum of all errors. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`errorUpdateCount`](InfiniteQueryObserverBaseResult.md#errorupdatecount) + +*** + +### errorUpdatedAt + +```ts +errorUpdatedAt: number; +``` + +Defined in: [packages/query-core/src/types.ts:784](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L784) + +The timestamp for when the query most recently returned the `status` as `"error"`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`errorUpdatedAt`](InfiniteQueryObserverBaseResult.md#errorupdatedat) + +*** + +### failureCount + +```ts +failureCount: number; +``` + +Defined in: [packages/query-core/src/types.ts:790](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L790) + +The failure count for the query. +- Incremented every time the query fails. +- Reset to `0` when the query succeeds. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`failureCount`](InfiniteQueryObserverBaseResult.md#failurecount) + +*** + +### failureReason + +```ts +failureReason: TError | null; +``` + +Defined in: [packages/query-core/src/types.ts:795](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L795) + +The failure reason for the query retry. +- Reset to `null` when the query succeeds. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`failureReason`](InfiniteQueryObserverBaseResult.md#failurereason) + +*** + +### fetchNextPage() + +```ts +fetchNextPage: (options?) => Promise>; +``` + +Defined in: [packages/query-core/src/types.ts:1008](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1008) + +This function allows you to fetch the next "page" of results. + +#### Parameters + +##### options? + +[`FetchNextPageOptions`](FetchNextPageOptions.md) + +#### Returns + +`Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`fetchNextPage`](InfiniteQueryObserverBaseResult.md#fetchnextpage) + +*** + +### fetchPreviousPage() + +```ts +fetchPreviousPage: (options?) => Promise>; +``` + +Defined in: [packages/query-core/src/types.ts:1014](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1014) + +This function allows you to fetch the previous "page" of results. + +#### Parameters + +##### options? + +[`FetchPreviousPageOptions`](FetchPreviousPageOptions.md) + +#### Returns + +`Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`fetchPreviousPage`](InfiniteQueryObserverBaseResult.md#fetchpreviouspage) + +*** + +### fetchStatus + +```ts +fetchStatus: FetchStatus; +``` + +Defined in: [packages/query-core/src/types.ts:889](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L889) + +The fetch status of the query. +- `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. +- `paused`: The query wanted to fetch, but has been `paused`. +- `idle`: The query is not fetching. +- See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`fetchStatus`](InfiniteQueryObserverBaseResult.md#fetchstatus) + +*** + +### hasNextPage + +```ts +hasNextPage: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1020](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1020) + +Will be `true` if there is a next page to be fetched (known via the `getNextPageParam` option). + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`hasNextPage`](InfiniteQueryObserverBaseResult.md#hasnextpage) + +*** + +### hasPreviousPage + +```ts +hasPreviousPage: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1024](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1024) + +Will be `true` if there is a previous page to be fetched (known via the `getPreviousPageParam` option). + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`hasPreviousPage`](InfiniteQueryObserverBaseResult.md#haspreviouspage) + +*** + +### isEnabled + +```ts +isEnabled: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:867](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L867) + +`true` if this observer is enabled, `false` otherwise. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isEnabled`](InfiniteQueryObserverBaseResult.md#isenabled) + +*** + +### isError + +```ts +isError: false; +``` + +Defined in: [packages/query-core/src/types.ts:1049](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1049) + +A derived boolean from the `status` variable, provided for convenience. +- `true` if the query attempt resulted in an error. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isError`](InfiniteQueryObserverBaseResult.md#iserror) + +*** + +### isFetched + +```ts +isFetched: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:808](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L808) + +Will be `true` if the query has been fetched. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetched`](InfiniteQueryObserverBaseResult.md#isfetched) + +*** + +### isFetchedAfterMount + +```ts +isFetchedAfterMount: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:813](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L813) + +Will be `true` if the query has been fetched after the component mounted. +- This property can be used to not show any previously cached data. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchedAfterMount`](InfiniteQueryObserverBaseResult.md#isfetchedaftermount) + +*** + +### isFetching + +```ts +isFetching: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:818](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L818) + +A derived boolean from the `fetchStatus` variable, provided for convenience. +- `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetching`](InfiniteQueryObserverBaseResult.md#isfetching) + +*** + +### isFetchingNextPage + +```ts +isFetchingNextPage: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1032](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1032) + +Will be `true` while fetching the next page with `fetchNextPage`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchingNextPage`](InfiniteQueryObserverBaseResult.md#isfetchingnextpage) + +*** + +### isFetchingPreviousPage + +```ts +isFetchingPreviousPage: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1040](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1040) + +Will be `true` while fetching the previous page with `fetchPreviousPage`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchingPreviousPage`](InfiniteQueryObserverBaseResult.md#isfetchingpreviouspage) + +*** + +### isFetchNextPageError + +```ts +isFetchNextPageError: false; +``` + +Defined in: [packages/query-core/src/types.ts:1053](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1053) + +Will be `true` if the query failed while fetching the next page. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchNextPageError`](InfiniteQueryObserverBaseResult.md#isfetchnextpageerror) + +*** + +### isFetchPreviousPageError + +```ts +isFetchPreviousPageError: false; +``` + +Defined in: [packages/query-core/src/types.ts:1054](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1054) + +Will be `true` if the query failed while fetching the previous page. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchPreviousPageError`](InfiniteQueryObserverBaseResult.md#isfetchpreviouspageerror) + +*** + +### ~~isInitialLoading~~ + +```ts +isInitialLoading: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:836](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L836) + +#### Deprecated + +`isInitialLoading` is being deprecated in favor of `isLoading` +and will be removed in the next major version. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isInitialLoading`](InfiniteQueryObserverBaseResult.md#isinitialloading) + +*** + +### isLoading + +```ts +isLoading: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:823](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L823) + +Is `true` whenever the first fetch for a query is in-flight. +- Is the same as `isFetching && isPending`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoading`](InfiniteQueryObserverBaseResult.md#isloading) + +*** + +### isLoadingError + +```ts +isLoadingError: false; +``` + +Defined in: [packages/query-core/src/types.ts:1051](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1051) + +Will be `true` if the query failed while fetching for the first time. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoadingError`](InfiniteQueryObserverBaseResult.md#isloadingerror) + +*** + +### isPaused + +```ts +isPaused: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:841](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L841) + +A derived boolean from the `fetchStatus` variable, provided for convenience. +- The query wanted to fetch, but has been `paused`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPaused`](InfiniteQueryObserverBaseResult.md#ispaused) + +*** + +### isPending + +```ts +isPending: true; +``` + +Defined in: [packages/query-core/src/types.ts:1050](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1050) + +Will be `pending` if there's no cached data and no query attempt was finished yet. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPending`](InfiniteQueryObserverBaseResult.md#ispending) + +*** + +### isPlaceholderData + +```ts +isPlaceholderData: false; +``` + +Defined in: [packages/query-core/src/types.ts:1056](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1056) + +Will be `true` if the data shown is the placeholder data. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPlaceholderData`](InfiniteQueryObserverBaseResult.md#isplaceholderdata) + +*** + +### isRefetchError + +```ts +isRefetchError: false; +``` + +Defined in: [packages/query-core/src/types.ts:1052](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1052) + +Will be `true` if the query failed while refetching. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isRefetchError`](InfiniteQueryObserverBaseResult.md#isrefetcherror) + +*** + +### isRefetching + +```ts +isRefetching: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:854](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L854) + +Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. +- Is the same as `isFetching && !isPending`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isRefetching`](InfiniteQueryObserverBaseResult.md#isrefetching) + +*** + +### isStale + +```ts +isStale: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:858](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L858) + +Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isStale`](InfiniteQueryObserverBaseResult.md#isstale) + +*** + +### isSuccess + +```ts +isSuccess: false; +``` + +Defined in: [packages/query-core/src/types.ts:1055](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1055) + +A derived boolean from the `status` variable, provided for convenience. +- `true` if the query has received a response with no errors and is ready to display its data. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isSuccess`](InfiniteQueryObserverBaseResult.md#issuccess) + +*** + +### refetch() + +```ts +refetch: (options?) => Promise>; +``` + +Defined in: [packages/query-core/src/types.ts:871](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L871) + +A function to manually refetch the query. + +#### Parameters + +##### options? + +[`RefetchOptions`](RefetchOptions.md) + +#### Returns + +`Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`refetch`](InfiniteQueryObserverBaseResult.md#refetch) + +*** + +### status + +```ts +status: "pending"; +``` + +Defined in: [packages/query-core/src/types.ts:1057](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1057) + +The status of the query. +- Will be: + - `pending` if there's no cached data and no query attempt was finished yet. + - `error` if the query attempt resulted in an error. + - `success` if the query has received a response with no errors and is ready to display its data. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`status`](InfiniteQueryObserverBaseResult.md#status) diff --git a/docs/framework/solid/reference/interfaces/InfiniteQueryObserverPlaceholderResult.md b/docs/framework/solid/reference/interfaces/InfiniteQueryObserverPlaceholderResult.md new file mode 100644 index 00000000000..58193a987d1 --- /dev/null +++ b/docs/framework/solid/reference/interfaces/InfiniteQueryObserverPlaceholderResult.md @@ -0,0 +1,600 @@ +--- +id: InfiniteQueryObserverPlaceholderResult +title: InfiniteQueryObserverPlaceholderResult +--- + +Defined in: [packages/query-core/src/types.ts:1130](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1130) + +## Extends + +- [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md)\<`TData`, `TError`\> + +## Type Parameters + +### TData + +`TData` = `unknown` + +### TError + +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) + +## Properties + +### data + +```ts +data: TData; +``` + +Defined in: [packages/query-core/src/types.ts:1134](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1134) + +The last successfully resolved data for the query. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`data`](InfiniteQueryObserverBaseResult.md#data) + +*** + +### dataUpdatedAt + +```ts +dataUpdatedAt: number; +``` + +Defined in: [packages/query-core/src/types.ts:775](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L775) + +The timestamp for when the query most recently returned the `status` as `"success"`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`dataUpdatedAt`](InfiniteQueryObserverBaseResult.md#dataupdatedat) + +*** + +### error + +```ts +error: null; +``` + +Defined in: [packages/query-core/src/types.ts:1136](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1136) + +The error object for the query, if an error was thrown. +- Defaults to `null`. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`error`](InfiniteQueryObserverBaseResult.md#error) + +*** + +### errorUpdateCount + +```ts +errorUpdateCount: number; +``` + +Defined in: [packages/query-core/src/types.ts:799](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L799) + +The sum of all errors. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`errorUpdateCount`](InfiniteQueryObserverBaseResult.md#errorupdatecount) + +*** + +### errorUpdatedAt + +```ts +errorUpdatedAt: number; +``` + +Defined in: [packages/query-core/src/types.ts:784](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L784) + +The timestamp for when the query most recently returned the `status` as `"error"`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`errorUpdatedAt`](InfiniteQueryObserverBaseResult.md#errorupdatedat) + +*** + +### failureCount + +```ts +failureCount: number; +``` + +Defined in: [packages/query-core/src/types.ts:790](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L790) + +The failure count for the query. +- Incremented every time the query fails. +- Reset to `0` when the query succeeds. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`failureCount`](InfiniteQueryObserverBaseResult.md#failurecount) + +*** + +### failureReason + +```ts +failureReason: TError | null; +``` + +Defined in: [packages/query-core/src/types.ts:795](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L795) + +The failure reason for the query retry. +- Reset to `null` when the query succeeds. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`failureReason`](InfiniteQueryObserverBaseResult.md#failurereason) + +*** + +### fetchNextPage() + +```ts +fetchNextPage: (options?) => Promise>; +``` + +Defined in: [packages/query-core/src/types.ts:1008](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1008) + +This function allows you to fetch the next "page" of results. + +#### Parameters + +##### options? + +[`FetchNextPageOptions`](FetchNextPageOptions.md) + +#### Returns + +`Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`fetchNextPage`](InfiniteQueryObserverBaseResult.md#fetchnextpage) + +*** + +### fetchPreviousPage() + +```ts +fetchPreviousPage: (options?) => Promise>; +``` + +Defined in: [packages/query-core/src/types.ts:1014](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1014) + +This function allows you to fetch the previous "page" of results. + +#### Parameters + +##### options? + +[`FetchPreviousPageOptions`](FetchPreviousPageOptions.md) + +#### Returns + +`Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`fetchPreviousPage`](InfiniteQueryObserverBaseResult.md#fetchpreviouspage) + +*** + +### fetchStatus + +```ts +fetchStatus: FetchStatus; +``` + +Defined in: [packages/query-core/src/types.ts:889](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L889) + +The fetch status of the query. +- `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. +- `paused`: The query wanted to fetch, but has been `paused`. +- `idle`: The query is not fetching. +- See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`fetchStatus`](InfiniteQueryObserverBaseResult.md#fetchstatus) + +*** + +### hasNextPage + +```ts +hasNextPage: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1020](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1020) + +Will be `true` if there is a next page to be fetched (known via the `getNextPageParam` option). + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`hasNextPage`](InfiniteQueryObserverBaseResult.md#hasnextpage) + +*** + +### hasPreviousPage + +```ts +hasPreviousPage: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1024](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1024) + +Will be `true` if there is a previous page to be fetched (known via the `getPreviousPageParam` option). + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`hasPreviousPage`](InfiniteQueryObserverBaseResult.md#haspreviouspage) + +*** + +### isEnabled + +```ts +isEnabled: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:867](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L867) + +`true` if this observer is enabled, `false` otherwise. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isEnabled`](InfiniteQueryObserverBaseResult.md#isenabled) + +*** + +### isError + +```ts +isError: false; +``` + +Defined in: [packages/query-core/src/types.ts:1135](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1135) + +A derived boolean from the `status` variable, provided for convenience. +- `true` if the query attempt resulted in an error. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isError`](InfiniteQueryObserverBaseResult.md#iserror) + +*** + +### isFetched + +```ts +isFetched: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:808](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L808) + +Will be `true` if the query has been fetched. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetched`](InfiniteQueryObserverBaseResult.md#isfetched) + +*** + +### isFetchedAfterMount + +```ts +isFetchedAfterMount: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:813](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L813) + +Will be `true` if the query has been fetched after the component mounted. +- This property can be used to not show any previously cached data. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchedAfterMount`](InfiniteQueryObserverBaseResult.md#isfetchedaftermount) + +*** + +### isFetching + +```ts +isFetching: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:818](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L818) + +A derived boolean from the `fetchStatus` variable, provided for convenience. +- `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetching`](InfiniteQueryObserverBaseResult.md#isfetching) + +*** + +### isFetchingNextPage + +```ts +isFetchingNextPage: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1032](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1032) + +Will be `true` while fetching the next page with `fetchNextPage`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchingNextPage`](InfiniteQueryObserverBaseResult.md#isfetchingnextpage) + +*** + +### isFetchingPreviousPage + +```ts +isFetchingPreviousPage: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1040](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1040) + +Will be `true` while fetching the previous page with `fetchPreviousPage`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchingPreviousPage`](InfiniteQueryObserverBaseResult.md#isfetchingpreviouspage) + +*** + +### isFetchNextPageError + +```ts +isFetchNextPageError: false; +``` + +Defined in: [packages/query-core/src/types.ts:1143](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1143) + +Will be `true` if the query failed while fetching the next page. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchNextPageError`](InfiniteQueryObserverBaseResult.md#isfetchnextpageerror) + +*** + +### isFetchPreviousPageError + +```ts +isFetchPreviousPageError: false; +``` + +Defined in: [packages/query-core/src/types.ts:1144](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1144) + +Will be `true` if the query failed while fetching the previous page. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchPreviousPageError`](InfiniteQueryObserverBaseResult.md#isfetchpreviouspageerror) + +*** + +### ~~isInitialLoading~~ + +```ts +isInitialLoading: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:836](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L836) + +#### Deprecated + +`isInitialLoading` is being deprecated in favor of `isLoading` +and will be removed in the next major version. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isInitialLoading`](InfiniteQueryObserverBaseResult.md#isinitialloading) + +*** + +### isLoading + +```ts +isLoading: false; +``` + +Defined in: [packages/query-core/src/types.ts:1138](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1138) + +Is `true` whenever the first fetch for a query is in-flight. +- Is the same as `isFetching && isPending`. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoading`](InfiniteQueryObserverBaseResult.md#isloading) + +*** + +### isLoadingError + +```ts +isLoadingError: false; +``` + +Defined in: [packages/query-core/src/types.ts:1139](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1139) + +Will be `true` if the query failed while fetching for the first time. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoadingError`](InfiniteQueryObserverBaseResult.md#isloadingerror) + +*** + +### isPaused + +```ts +isPaused: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:841](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L841) + +A derived boolean from the `fetchStatus` variable, provided for convenience. +- The query wanted to fetch, but has been `paused`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPaused`](InfiniteQueryObserverBaseResult.md#ispaused) + +*** + +### isPending + +```ts +isPending: false; +``` + +Defined in: [packages/query-core/src/types.ts:1137](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1137) + +Will be `pending` if there's no cached data and no query attempt was finished yet. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPending`](InfiniteQueryObserverBaseResult.md#ispending) + +*** + +### isPlaceholderData + +```ts +isPlaceholderData: true; +``` + +Defined in: [packages/query-core/src/types.ts:1142](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1142) + +Will be `true` if the data shown is the placeholder data. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPlaceholderData`](InfiniteQueryObserverBaseResult.md#isplaceholderdata) + +*** + +### isRefetchError + +```ts +isRefetchError: false; +``` + +Defined in: [packages/query-core/src/types.ts:1140](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1140) + +Will be `true` if the query failed while refetching. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isRefetchError`](InfiniteQueryObserverBaseResult.md#isrefetcherror) + +*** + +### isRefetching + +```ts +isRefetching: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:854](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L854) + +Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. +- Is the same as `isFetching && !isPending`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isRefetching`](InfiniteQueryObserverBaseResult.md#isrefetching) + +*** + +### isStale + +```ts +isStale: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:858](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L858) + +Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isStale`](InfiniteQueryObserverBaseResult.md#isstale) + +*** + +### isSuccess + +```ts +isSuccess: true; +``` + +Defined in: [packages/query-core/src/types.ts:1141](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1141) + +A derived boolean from the `status` variable, provided for convenience. +- `true` if the query has received a response with no errors and is ready to display its data. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isSuccess`](InfiniteQueryObserverBaseResult.md#issuccess) + +*** + +### refetch() + +```ts +refetch: (options?) => Promise>; +``` + +Defined in: [packages/query-core/src/types.ts:871](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L871) + +A function to manually refetch the query. + +#### Parameters + +##### options? + +[`RefetchOptions`](RefetchOptions.md) + +#### Returns + +`Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`refetch`](InfiniteQueryObserverBaseResult.md#refetch) + +*** + +### status + +```ts +status: "success"; +``` + +Defined in: [packages/query-core/src/types.ts:1145](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1145) + +The status of the query. +- Will be: + - `pending` if there's no cached data and no query attempt was finished yet. + - `error` if the query attempt resulted in an error. + - `success` if the query has received a response with no errors and is ready to display its data. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`status`](InfiniteQueryObserverBaseResult.md#status) diff --git a/docs/framework/solid/reference/interfaces/InfiniteQueryObserverRefetchErrorResult.md b/docs/framework/solid/reference/interfaces/InfiniteQueryObserverRefetchErrorResult.md new file mode 100644 index 00000000000..4ce469bceed --- /dev/null +++ b/docs/framework/solid/reference/interfaces/InfiniteQueryObserverRefetchErrorResult.md @@ -0,0 +1,600 @@ +--- +id: InfiniteQueryObserverRefetchErrorResult +title: InfiniteQueryObserverRefetchErrorResult +--- + +Defined in: [packages/query-core/src/types.ts:1096](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1096) + +## Extends + +- [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md)\<`TData`, `TError`\> + +## Type Parameters + +### TData + +`TData` = `unknown` + +### TError + +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) + +## Properties + +### data + +```ts +data: TData; +``` + +Defined in: [packages/query-core/src/types.ts:1100](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1100) + +The last successfully resolved data for the query. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`data`](InfiniteQueryObserverBaseResult.md#data) + +*** + +### dataUpdatedAt + +```ts +dataUpdatedAt: number; +``` + +Defined in: [packages/query-core/src/types.ts:775](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L775) + +The timestamp for when the query most recently returned the `status` as `"success"`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`dataUpdatedAt`](InfiniteQueryObserverBaseResult.md#dataupdatedat) + +*** + +### error + +```ts +error: TError; +``` + +Defined in: [packages/query-core/src/types.ts:1101](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1101) + +The error object for the query, if an error was thrown. +- Defaults to `null`. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`error`](InfiniteQueryObserverBaseResult.md#error) + +*** + +### errorUpdateCount + +```ts +errorUpdateCount: number; +``` + +Defined in: [packages/query-core/src/types.ts:799](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L799) + +The sum of all errors. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`errorUpdateCount`](InfiniteQueryObserverBaseResult.md#errorupdatecount) + +*** + +### errorUpdatedAt + +```ts +errorUpdatedAt: number; +``` + +Defined in: [packages/query-core/src/types.ts:784](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L784) + +The timestamp for when the query most recently returned the `status` as `"error"`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`errorUpdatedAt`](InfiniteQueryObserverBaseResult.md#errorupdatedat) + +*** + +### failureCount + +```ts +failureCount: number; +``` + +Defined in: [packages/query-core/src/types.ts:790](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L790) + +The failure count for the query. +- Incremented every time the query fails. +- Reset to `0` when the query succeeds. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`failureCount`](InfiniteQueryObserverBaseResult.md#failurecount) + +*** + +### failureReason + +```ts +failureReason: TError | null; +``` + +Defined in: [packages/query-core/src/types.ts:795](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L795) + +The failure reason for the query retry. +- Reset to `null` when the query succeeds. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`failureReason`](InfiniteQueryObserverBaseResult.md#failurereason) + +*** + +### fetchNextPage() + +```ts +fetchNextPage: (options?) => Promise>; +``` + +Defined in: [packages/query-core/src/types.ts:1008](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1008) + +This function allows you to fetch the next "page" of results. + +#### Parameters + +##### options? + +[`FetchNextPageOptions`](FetchNextPageOptions.md) + +#### Returns + +`Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`fetchNextPage`](InfiniteQueryObserverBaseResult.md#fetchnextpage) + +*** + +### fetchPreviousPage() + +```ts +fetchPreviousPage: (options?) => Promise>; +``` + +Defined in: [packages/query-core/src/types.ts:1014](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1014) + +This function allows you to fetch the previous "page" of results. + +#### Parameters + +##### options? + +[`FetchPreviousPageOptions`](FetchPreviousPageOptions.md) + +#### Returns + +`Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`fetchPreviousPage`](InfiniteQueryObserverBaseResult.md#fetchpreviouspage) + +*** + +### fetchStatus + +```ts +fetchStatus: FetchStatus; +``` + +Defined in: [packages/query-core/src/types.ts:889](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L889) + +The fetch status of the query. +- `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. +- `paused`: The query wanted to fetch, but has been `paused`. +- `idle`: The query is not fetching. +- See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`fetchStatus`](InfiniteQueryObserverBaseResult.md#fetchstatus) + +*** + +### hasNextPage + +```ts +hasNextPage: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1020](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1020) + +Will be `true` if there is a next page to be fetched (known via the `getNextPageParam` option). + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`hasNextPage`](InfiniteQueryObserverBaseResult.md#hasnextpage) + +*** + +### hasPreviousPage + +```ts +hasPreviousPage: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1024](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1024) + +Will be `true` if there is a previous page to be fetched (known via the `getPreviousPageParam` option). + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`hasPreviousPage`](InfiniteQueryObserverBaseResult.md#haspreviouspage) + +*** + +### isEnabled + +```ts +isEnabled: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:867](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L867) + +`true` if this observer is enabled, `false` otherwise. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isEnabled`](InfiniteQueryObserverBaseResult.md#isenabled) + +*** + +### isError + +```ts +isError: true; +``` + +Defined in: [packages/query-core/src/types.ts:1102](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1102) + +A derived boolean from the `status` variable, provided for convenience. +- `true` if the query attempt resulted in an error. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isError`](InfiniteQueryObserverBaseResult.md#iserror) + +*** + +### isFetched + +```ts +isFetched: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:808](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L808) + +Will be `true` if the query has been fetched. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetched`](InfiniteQueryObserverBaseResult.md#isfetched) + +*** + +### isFetchedAfterMount + +```ts +isFetchedAfterMount: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:813](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L813) + +Will be `true` if the query has been fetched after the component mounted. +- This property can be used to not show any previously cached data. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchedAfterMount`](InfiniteQueryObserverBaseResult.md#isfetchedaftermount) + +*** + +### isFetching + +```ts +isFetching: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:818](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L818) + +A derived boolean from the `fetchStatus` variable, provided for convenience. +- `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetching`](InfiniteQueryObserverBaseResult.md#isfetching) + +*** + +### isFetchingNextPage + +```ts +isFetchingNextPage: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1032](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1032) + +Will be `true` while fetching the next page with `fetchNextPage`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchingNextPage`](InfiniteQueryObserverBaseResult.md#isfetchingnextpage) + +*** + +### isFetchingPreviousPage + +```ts +isFetchingPreviousPage: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1040](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1040) + +Will be `true` while fetching the previous page with `fetchPreviousPage`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchingPreviousPage`](InfiniteQueryObserverBaseResult.md#isfetchingpreviouspage) + +*** + +### isFetchNextPageError + +```ts +isFetchNextPageError: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1028](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1028) + +Will be `true` if the query failed while fetching the next page. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchNextPageError`](InfiniteQueryObserverBaseResult.md#isfetchnextpageerror) + +*** + +### isFetchPreviousPageError + +```ts +isFetchPreviousPageError: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1036](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1036) + +Will be `true` if the query failed while fetching the previous page. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchPreviousPageError`](InfiniteQueryObserverBaseResult.md#isfetchpreviouspageerror) + +*** + +### ~~isInitialLoading~~ + +```ts +isInitialLoading: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:836](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L836) + +#### Deprecated + +`isInitialLoading` is being deprecated in favor of `isLoading` +and will be removed in the next major version. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isInitialLoading`](InfiniteQueryObserverBaseResult.md#isinitialloading) + +*** + +### isLoading + +```ts +isLoading: false; +``` + +Defined in: [packages/query-core/src/types.ts:1104](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1104) + +Is `true` whenever the first fetch for a query is in-flight. +- Is the same as `isFetching && isPending`. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoading`](InfiniteQueryObserverBaseResult.md#isloading) + +*** + +### isLoadingError + +```ts +isLoadingError: false; +``` + +Defined in: [packages/query-core/src/types.ts:1105](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1105) + +Will be `true` if the query failed while fetching for the first time. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoadingError`](InfiniteQueryObserverBaseResult.md#isloadingerror) + +*** + +### isPaused + +```ts +isPaused: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:841](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L841) + +A derived boolean from the `fetchStatus` variable, provided for convenience. +- The query wanted to fetch, but has been `paused`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPaused`](InfiniteQueryObserverBaseResult.md#ispaused) + +*** + +### isPending + +```ts +isPending: false; +``` + +Defined in: [packages/query-core/src/types.ts:1103](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1103) + +Will be `pending` if there's no cached data and no query attempt was finished yet. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPending`](InfiniteQueryObserverBaseResult.md#ispending) + +*** + +### isPlaceholderData + +```ts +isPlaceholderData: false; +``` + +Defined in: [packages/query-core/src/types.ts:1108](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1108) + +Will be `true` if the data shown is the placeholder data. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPlaceholderData`](InfiniteQueryObserverBaseResult.md#isplaceholderdata) + +*** + +### isRefetchError + +```ts +isRefetchError: true; +``` + +Defined in: [packages/query-core/src/types.ts:1106](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1106) + +Will be `true` if the query failed while refetching. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isRefetchError`](InfiniteQueryObserverBaseResult.md#isrefetcherror) + +*** + +### isRefetching + +```ts +isRefetching: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:854](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L854) + +Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. +- Is the same as `isFetching && !isPending`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isRefetching`](InfiniteQueryObserverBaseResult.md#isrefetching) + +*** + +### isStale + +```ts +isStale: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:858](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L858) + +Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isStale`](InfiniteQueryObserverBaseResult.md#isstale) + +*** + +### isSuccess + +```ts +isSuccess: false; +``` + +Defined in: [packages/query-core/src/types.ts:1107](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1107) + +A derived boolean from the `status` variable, provided for convenience. +- `true` if the query has received a response with no errors and is ready to display its data. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isSuccess`](InfiniteQueryObserverBaseResult.md#issuccess) + +*** + +### refetch() + +```ts +refetch: (options?) => Promise>; +``` + +Defined in: [packages/query-core/src/types.ts:871](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L871) + +A function to manually refetch the query. + +#### Parameters + +##### options? + +[`RefetchOptions`](RefetchOptions.md) + +#### Returns + +`Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`refetch`](InfiniteQueryObserverBaseResult.md#refetch) + +*** + +### status + +```ts +status: "error"; +``` + +Defined in: [packages/query-core/src/types.ts:1109](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1109) + +The status of the query. +- Will be: + - `pending` if there's no cached data and no query attempt was finished yet. + - `error` if the query attempt resulted in an error. + - `success` if the query has received a response with no errors and is ready to display its data. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`status`](InfiniteQueryObserverBaseResult.md#status) diff --git a/docs/framework/solid/reference/interfaces/InfiniteQueryObserverSuccessResult.md b/docs/framework/solid/reference/interfaces/InfiniteQueryObserverSuccessResult.md new file mode 100644 index 00000000000..131f6d01ae7 --- /dev/null +++ b/docs/framework/solid/reference/interfaces/InfiniteQueryObserverSuccessResult.md @@ -0,0 +1,600 @@ +--- +id: InfiniteQueryObserverSuccessResult +title: InfiniteQueryObserverSuccessResult +--- + +Defined in: [packages/query-core/src/types.ts:1112](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1112) + +## Extends + +- [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md)\<`TData`, `TError`\> + +## Type Parameters + +### TData + +`TData` = `unknown` + +### TError + +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) + +## Properties + +### data + +```ts +data: TData; +``` + +Defined in: [packages/query-core/src/types.ts:1116](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1116) + +The last successfully resolved data for the query. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`data`](InfiniteQueryObserverBaseResult.md#data) + +*** + +### dataUpdatedAt + +```ts +dataUpdatedAt: number; +``` + +Defined in: [packages/query-core/src/types.ts:775](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L775) + +The timestamp for when the query most recently returned the `status` as `"success"`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`dataUpdatedAt`](InfiniteQueryObserverBaseResult.md#dataupdatedat) + +*** + +### error + +```ts +error: null; +``` + +Defined in: [packages/query-core/src/types.ts:1117](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1117) + +The error object for the query, if an error was thrown. +- Defaults to `null`. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`error`](InfiniteQueryObserverBaseResult.md#error) + +*** + +### errorUpdateCount + +```ts +errorUpdateCount: number; +``` + +Defined in: [packages/query-core/src/types.ts:799](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L799) + +The sum of all errors. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`errorUpdateCount`](InfiniteQueryObserverBaseResult.md#errorupdatecount) + +*** + +### errorUpdatedAt + +```ts +errorUpdatedAt: number; +``` + +Defined in: [packages/query-core/src/types.ts:784](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L784) + +The timestamp for when the query most recently returned the `status` as `"error"`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`errorUpdatedAt`](InfiniteQueryObserverBaseResult.md#errorupdatedat) + +*** + +### failureCount + +```ts +failureCount: number; +``` + +Defined in: [packages/query-core/src/types.ts:790](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L790) + +The failure count for the query. +- Incremented every time the query fails. +- Reset to `0` when the query succeeds. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`failureCount`](InfiniteQueryObserverBaseResult.md#failurecount) + +*** + +### failureReason + +```ts +failureReason: TError | null; +``` + +Defined in: [packages/query-core/src/types.ts:795](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L795) + +The failure reason for the query retry. +- Reset to `null` when the query succeeds. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`failureReason`](InfiniteQueryObserverBaseResult.md#failurereason) + +*** + +### fetchNextPage() + +```ts +fetchNextPage: (options?) => Promise>; +``` + +Defined in: [packages/query-core/src/types.ts:1008](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1008) + +This function allows you to fetch the next "page" of results. + +#### Parameters + +##### options? + +[`FetchNextPageOptions`](FetchNextPageOptions.md) + +#### Returns + +`Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`fetchNextPage`](InfiniteQueryObserverBaseResult.md#fetchnextpage) + +*** + +### fetchPreviousPage() + +```ts +fetchPreviousPage: (options?) => Promise>; +``` + +Defined in: [packages/query-core/src/types.ts:1014](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1014) + +This function allows you to fetch the previous "page" of results. + +#### Parameters + +##### options? + +[`FetchPreviousPageOptions`](FetchPreviousPageOptions.md) + +#### Returns + +`Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`fetchPreviousPage`](InfiniteQueryObserverBaseResult.md#fetchpreviouspage) + +*** + +### fetchStatus + +```ts +fetchStatus: FetchStatus; +``` + +Defined in: [packages/query-core/src/types.ts:889](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L889) + +The fetch status of the query. +- `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. +- `paused`: The query wanted to fetch, but has been `paused`. +- `idle`: The query is not fetching. +- See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`fetchStatus`](InfiniteQueryObserverBaseResult.md#fetchstatus) + +*** + +### hasNextPage + +```ts +hasNextPage: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1020](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1020) + +Will be `true` if there is a next page to be fetched (known via the `getNextPageParam` option). + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`hasNextPage`](InfiniteQueryObserverBaseResult.md#hasnextpage) + +*** + +### hasPreviousPage + +```ts +hasPreviousPage: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1024](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1024) + +Will be `true` if there is a previous page to be fetched (known via the `getPreviousPageParam` option). + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`hasPreviousPage`](InfiniteQueryObserverBaseResult.md#haspreviouspage) + +*** + +### isEnabled + +```ts +isEnabled: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:867](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L867) + +`true` if this observer is enabled, `false` otherwise. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isEnabled`](InfiniteQueryObserverBaseResult.md#isenabled) + +*** + +### isError + +```ts +isError: false; +``` + +Defined in: [packages/query-core/src/types.ts:1118](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1118) + +A derived boolean from the `status` variable, provided for convenience. +- `true` if the query attempt resulted in an error. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isError`](InfiniteQueryObserverBaseResult.md#iserror) + +*** + +### isFetched + +```ts +isFetched: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:808](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L808) + +Will be `true` if the query has been fetched. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetched`](InfiniteQueryObserverBaseResult.md#isfetched) + +*** + +### isFetchedAfterMount + +```ts +isFetchedAfterMount: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:813](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L813) + +Will be `true` if the query has been fetched after the component mounted. +- This property can be used to not show any previously cached data. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchedAfterMount`](InfiniteQueryObserverBaseResult.md#isfetchedaftermount) + +*** + +### isFetching + +```ts +isFetching: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:818](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L818) + +A derived boolean from the `fetchStatus` variable, provided for convenience. +- `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetching`](InfiniteQueryObserverBaseResult.md#isfetching) + +*** + +### isFetchingNextPage + +```ts +isFetchingNextPage: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1032](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1032) + +Will be `true` while fetching the next page with `fetchNextPage`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchingNextPage`](InfiniteQueryObserverBaseResult.md#isfetchingnextpage) + +*** + +### isFetchingPreviousPage + +```ts +isFetchingPreviousPage: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1040](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1040) + +Will be `true` while fetching the previous page with `fetchPreviousPage`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchingPreviousPage`](InfiniteQueryObserverBaseResult.md#isfetchingpreviouspage) + +*** + +### isFetchNextPageError + +```ts +isFetchNextPageError: false; +``` + +Defined in: [packages/query-core/src/types.ts:1123](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1123) + +Will be `true` if the query failed while fetching the next page. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchNextPageError`](InfiniteQueryObserverBaseResult.md#isfetchnextpageerror) + +*** + +### isFetchPreviousPageError + +```ts +isFetchPreviousPageError: false; +``` + +Defined in: [packages/query-core/src/types.ts:1124](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1124) + +Will be `true` if the query failed while fetching the previous page. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchPreviousPageError`](InfiniteQueryObserverBaseResult.md#isfetchpreviouspageerror) + +*** + +### ~~isInitialLoading~~ + +```ts +isInitialLoading: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:836](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L836) + +#### Deprecated + +`isInitialLoading` is being deprecated in favor of `isLoading` +and will be removed in the next major version. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isInitialLoading`](InfiniteQueryObserverBaseResult.md#isinitialloading) + +*** + +### isLoading + +```ts +isLoading: false; +``` + +Defined in: [packages/query-core/src/types.ts:1120](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1120) + +Is `true` whenever the first fetch for a query is in-flight. +- Is the same as `isFetching && isPending`. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoading`](InfiniteQueryObserverBaseResult.md#isloading) + +*** + +### isLoadingError + +```ts +isLoadingError: false; +``` + +Defined in: [packages/query-core/src/types.ts:1121](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1121) + +Will be `true` if the query failed while fetching for the first time. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoadingError`](InfiniteQueryObserverBaseResult.md#isloadingerror) + +*** + +### isPaused + +```ts +isPaused: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:841](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L841) + +A derived boolean from the `fetchStatus` variable, provided for convenience. +- The query wanted to fetch, but has been `paused`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPaused`](InfiniteQueryObserverBaseResult.md#ispaused) + +*** + +### isPending + +```ts +isPending: false; +``` + +Defined in: [packages/query-core/src/types.ts:1119](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1119) + +Will be `pending` if there's no cached data and no query attempt was finished yet. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPending`](InfiniteQueryObserverBaseResult.md#ispending) + +*** + +### isPlaceholderData + +```ts +isPlaceholderData: false; +``` + +Defined in: [packages/query-core/src/types.ts:1126](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1126) + +Will be `true` if the data shown is the placeholder data. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPlaceholderData`](InfiniteQueryObserverBaseResult.md#isplaceholderdata) + +*** + +### isRefetchError + +```ts +isRefetchError: false; +``` + +Defined in: [packages/query-core/src/types.ts:1122](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1122) + +Will be `true` if the query failed while refetching. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isRefetchError`](InfiniteQueryObserverBaseResult.md#isrefetcherror) + +*** + +### isRefetching + +```ts +isRefetching: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:854](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L854) + +Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. +- Is the same as `isFetching && !isPending`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isRefetching`](InfiniteQueryObserverBaseResult.md#isrefetching) + +*** + +### isStale + +```ts +isStale: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:858](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L858) + +Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isStale`](InfiniteQueryObserverBaseResult.md#isstale) + +*** + +### isSuccess + +```ts +isSuccess: true; +``` + +Defined in: [packages/query-core/src/types.ts:1125](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1125) + +A derived boolean from the `status` variable, provided for convenience. +- `true` if the query has received a response with no errors and is ready to display its data. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isSuccess`](InfiniteQueryObserverBaseResult.md#issuccess) + +*** + +### refetch() + +```ts +refetch: (options?) => Promise>; +``` + +Defined in: [packages/query-core/src/types.ts:871](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L871) + +A function to manually refetch the query. + +#### Parameters + +##### options? + +[`RefetchOptions`](RefetchOptions.md) + +#### Returns + +`Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`refetch`](InfiniteQueryObserverBaseResult.md#refetch) + +*** + +### status + +```ts +status: "success"; +``` + +Defined in: [packages/query-core/src/types.ts:1127](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1127) + +The status of the query. +- Will be: + - `pending` if there's no cached data and no query attempt was finished yet. + - `error` if the query attempt resulted in an error. + - `success` if the query has received a response with no errors and is ready to display its data. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`status`](InfiniteQueryObserverBaseResult.md#status) diff --git a/docs/framework/solid/reference/interfaces/InfiniteQueryOptions.md b/docs/framework/solid/reference/interfaces/InfiniteQueryOptions.md index 1b0803cef0d..90b3cddf167 100644 --- a/docs/framework/solid/reference/interfaces/InfiniteQueryOptions.md +++ b/docs/framework/solid/reference/interfaces/InfiniteQueryOptions.md @@ -3,13 +3,13 @@ id: InfiniteQueryOptions title: InfiniteQueryOptions --- -Defined in: [types.ts:157](https://github.com/TanStack/query/blob/main/packages/solid-query/src/types.ts#L157) +Defined in: [packages/solid-query/src/types.ts:157](https://github.com/TanStack/query/blob/main/packages/solid-query/src/types.ts#L157) The options accepted by `useInfiniteQuery`. ## Extends -- `OmitKeyof`\<[`InfiniteQueryObserverOptions`](InfiniteQueryObserverOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`, `TPageParam`\>, `"queryKey"` \| `"suspense"`\> +- [`OmitKeyof`](../type-aliases/OmitKeyof.md)\<[`InfiniteQueryObserverOptions`](InfiniteQueryObserverOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`, `TPageParam`\>, `"queryKey"` \| `"suspense"`\> ## Type Parameters @@ -21,7 +21,7 @@ The type of a single page, as your `queryFn` resolves it. ### TError -`TError` = `DefaultError` +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) The type of errors your `queryFn` may throw. @@ -33,7 +33,7 @@ The type `data` ends up as after `select` runs. ### TQueryKey -`TQueryKey` *extends* `QueryKey` = `QueryKey` +`TQueryKey` *extends* [`QueryKey`](../type-aliases/QueryKey.md) = [`QueryKey`](../type-aliases/QueryKey.md) The type of your `queryKey`. @@ -51,7 +51,7 @@ The type of the parameter passed to `queryFn` to fetch a given page. optional deferStream: boolean; ``` -Defined in: [types.ts:180](https://github.com/TanStack/query/blob/main/packages/solid-query/src/types.ts#L180) +Defined in: [packages/solid-query/src/types.ts:180](https://github.com/TanStack/query/blob/main/packages/solid-query/src/types.ts#L180) Only applicable while rendering queries on the server with streaming. Set `deferStream` to `true` to wait for the query to resolve on the server before flushing the stream. @@ -60,13 +60,333 @@ Defaults to `false`. *** +### enabled? + +```ts +optional enabled: QueryBooleanOption, TQueryKey>; +``` + +Defined in: [packages/query-core/src/types.ts:398](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L398) + +Set this to `false` or a function that returns `false` to disable automatic refetching when the query mounts or changes query keys. +To refetch the query, use the `refetch` method returned from the `useQuery` instance. +Accepts a boolean or function that returns a boolean. + +Defaults to `true`. + +#### Inherited from + +```ts +OmitKeyof.enabled +``` + +*** + +### gcTime? + +```ts +optional gcTime: number; +``` + +Defined in: [packages/query-core/src/types.ts:277](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L277) + +The time in milliseconds that unused/inactive cache data remains in memory. +When a query's cache becomes unused or inactive, that cache data will be garbage collected after this duration. +When different garbage collection times are specified, the longest one will be used. +Setting it to `Infinity` will disable garbage collection. + +Defaults to `5 * 60 * 1000` (5 minutes), or `Infinity` during SSR. + +Note: the maximum allowed time is about 24 days, imposed by `setTimeout`'s 32-bit signed integer delay — see +`timeoutManager.setTimeoutProvider` for a workaround. + +#### Inherited from + +[`QueryExecuteOptions`](QueryExecuteOptions.md).[`gcTime`](QueryExecuteOptions.md#gctime) + +*** + +### getNextPageParam + +```ts +getNextPageParam: GetNextPageParamFunction; +``` + +Defined in: [packages/query-core/src/types.ts:365](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L365) + +This function can be set to automatically get the next cursor for infinite queries. +The result will also be used to determine the value of `hasNextPage`. + +#### Inherited from + +```ts +OmitKeyof.getNextPageParam +``` + +*** + +### getPreviousPageParam? + +```ts +optional getPreviousPageParam: GetPreviousPageParamFunction; +``` + +Defined in: [packages/query-core/src/types.ts:360](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L360) + +This function can be set to automatically get the previous cursor for infinite queries. +The result will also be used to determine the value of `hasPreviousPage`. + +#### Inherited from + +```ts +OmitKeyof.getPreviousPageParam +``` + +*** + +### initialData? + +```ts +optional initialData: + | InfiniteData +| InitialDataFunction>; +``` + +Defined in: [packages/query-core/src/types.ts:317](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L317) + +If set, this value will be used as the initial data for the query cache (as long as the query hasn't been +created or cached yet). +If set to a function, the function will be called **once** during the shared/root query initialization, and be +expected to synchronously return the initial data. +Initial data is considered stale by default unless a `staleTime` has been set. +`initialData` **is persisted** to the cache. + +#### Inherited from + +```ts +OmitKeyof.initialData +``` + +*** + +### initialDataUpdatedAt? + +```ts +optional initialDataUpdatedAt: number | () => number | undefined; +``` + +Defined in: [packages/query-core/src/types.ts:321](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L321) + +If set, this value will be used as the time (in milliseconds) of when the `initialData` itself was last updated. + +#### Inherited from + +```ts +OmitKeyof.initialDataUpdatedAt +``` + +*** + +### initialPageParam + +```ts +initialPageParam: TPageParam; +``` + +Defined in: [packages/query-core/src/types.ts:349](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L349) + +#### Inherited from + +```ts +OmitKeyof.initialPageParam +``` + +*** + +### maxPages? + +```ts +optional maxPages: number; +``` + +Defined in: [packages/query-core/src/types.ts:345](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L345) + +Maximum number of pages to store in the data of an infinite query. + +#### Inherited from + +[`QueryExecuteOptions`](QueryExecuteOptions.md).[`maxPages`](QueryExecuteOptions.md#maxpages) + +*** + +### meta? + +```ts +optional meta: Record; +``` + +Defined in: [packages/query-core/src/types.ts:341](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L341) + +Additional payload to be stored on each query. +Use this property to pass information that can be used in other places. + +#### Inherited from + +[`QueryExecuteOptions`](QueryExecuteOptions.md).[`meta`](QueryExecuteOptions.md#meta) + +*** + +### networkMode? + +```ts +optional networkMode: NetworkMode; +``` + +Defined in: [packages/query-core/src/types.ts:265](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L265) + +Controls whether a query is allowed to run based on the current network connectivity. + +Defaults to `'online'`. + +#### See + +[Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. + +#### Inherited from + +[`QueryExecuteOptions`](QueryExecuteOptions.md).[`networkMode`](QueryExecuteOptions.md#networkmode) + +*** + +### notifyOnChangeProps? + +```ts +optional notifyOnChangeProps: NotifyOnChangeProps; +``` + +Defined in: [packages/query-core/src/types.ts:484](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L484) + +If set, the component will only re-render if any of the listed properties change. +When set to `['data', 'error']`, the component will only re-render when the `data` or `error` properties change. +When set to `'all'`, the component will re-render whenever a query is updated. +When set to a function, the function will be executed to compute the list of properties. + +Defaults to `undefined`, in which case property access is tracked automatically, and the +component only re-renders when one of the tracked properties changes. + +#### Inherited from + +```ts +OmitKeyof.notifyOnChangeProps +``` + +*** + +### persister? + +```ts +optional persister: QueryPersister, TPageParam>; +``` + +Defined in: [packages/query-core/src/types.ts:290](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L290) + +This option can be used to persist the result of a query to an external storage, bypassing the need to actually +call the `queryFn`. Useful for persisting a query's data across e.g. server/client boundaries. + +#### Inherited from + +```ts +OmitKeyof.persister +``` + +*** + +### placeholderData? + +```ts +optional placeholderData: + | InfiniteData +| PlaceholderDataFunction, TError, InfiniteData, TQueryKey>; +``` + +Defined in: [packages/query-core/src/types.ts:511](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L511) + +If set, this value will be used as the placeholder data for this particular query observer while the query is still in the `loading` data and no initialData has been provided. + +#### Inherited from + +```ts +OmitKeyof.placeholderData +``` + +*** + +### queryFn? + +```ts +optional queryFn: + | typeof skipToken +| QueryFunction; +``` + +Defined in: [packages/query-core/src/types.ts:285](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L285) + +The function that the query will use to request data. +Required, unless a default query function has been set via `queryClient.setQueryDefaults` or +`queryClient.setDefaultOptions`. +Receives a [QueryFunctionContext](../type-aliases/QueryFunctionContext.md). +Must return a promise that will either resolve data or throw an error. The data cannot be `undefined`. + +#### Inherited from + +```ts +OmitKeyof.queryFn +``` + +*** + +### queryHash? + +```ts +optional queryHash: string; +``` + +Defined in: [packages/query-core/src/types.ts:295](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L295) + +The hashed form of `queryKey`, computed with `queryKeyHashFn` (or the default hashing function otherwise). Used +as the actual cache key internally. + +#### Inherited from + +[`QueryExecuteOptions`](QueryExecuteOptions.md).[`queryHash`](QueryExecuteOptions.md#queryhash) + +*** + ### queryKey ```ts queryKey: TQueryKey; ``` -Defined in: [types.ts:173](https://github.com/TanStack/query/blob/main/packages/solid-query/src/types.ts#L173) +Defined in: [packages/solid-query/src/types.ts:173](https://github.com/TanStack/query/blob/main/packages/solid-query/src/types.ts#L173) + +*** + +### queryKeyHashFn? + +```ts +optional queryKeyHashFn: QueryKeyHashFunction; +``` + +Defined in: [packages/query-core/src/types.ts:308](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L308) + +If specified, this function is used to hash the `queryKey` to a string. + +#### Inherited from + +```ts +OmitKeyof.queryKeyHashFn +``` *** @@ -76,7 +396,7 @@ Defined in: [types.ts:173](https://github.com/TanStack/query/blob/main/packages/ optional reconcile: string | false | (oldData, newData) => TData; ``` -Defined in: [QueryClient.ts:84](https://github.com/TanStack/query/blob/main/packages/solid-query/src/QueryClient.ts#L84) +Defined in: [packages/solid-query/src/QueryClient.ts:84](https://github.com/TanStack/query/blob/main/packages/solid-query/src/QueryClient.ts#L84) Set this to a reconciliation key to enable reconciliation between query results. Set this to `false` to disable reconciliation between query results. @@ -91,16 +411,273 @@ OmitKeyof.reconcile *** +### refetchInterval? + +```ts +optional refetchInterval: number | false | (query) => number | false | undefined; +``` + +Defined in: [packages/query-core/src/types.ts:414](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L414) + +If set to a number, the query will continuously refetch at this frequency in milliseconds. +If set to a function, the function will be executed with the latest data and query to compute a frequency + +Defaults to `false`. + +#### Inherited from + +```ts +OmitKeyof.refetchInterval +``` + +*** + +### refetchIntervalInBackground? + +```ts +optional refetchIntervalInBackground: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:425](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L425) + +If set to `true`, the query will continue to refetch while their tab/window is in the background. + +Defaults to `false`. + +#### Inherited from + +```ts +OmitKeyof.refetchIntervalInBackground +``` + +*** + +### refetchOnMount? + +```ts +optional refetchOnMount: boolean | "always" | (query) => boolean | "always"; +``` + +Defined in: [packages/query-core/src/types.ts:462](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L462) + +If set to `true`, the query will refetch on mount if the data is stale. +If set to `false`, will disable additional instances of a query to trigger background refetch. +If set to `'always'`, the query will always refetch on mount (except when `staleTime: 'static'` is used). +If set to a function, the function will be executed with the latest data and query to compute the value + +Defaults to `true`. + +#### Inherited from + +```ts +OmitKeyof.refetchOnMount +``` + +*** + +### refetchOnReconnect? + +```ts +optional refetchOnReconnect: boolean | "always" | (query) => boolean | "always"; +``` + +Defined in: [packages/query-core/src/types.ts:448](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L448) + +If set to `true`, the query will refetch on reconnect if the data is stale. +If set to `false`, the query will not refetch on reconnect. +If set to `'always'`, the query will always refetch on reconnect (except when `staleTime: 'static'` is used). +If set to a function, the function will be executed with the latest data and query to compute the value. + +Defaults to `true` unless `networkMode` is `'always'`. + +#### Inherited from + +```ts +OmitKeyof.refetchOnReconnect +``` + +*** + +### refetchOnWindowFocus? + +```ts +optional refetchOnWindowFocus: boolean | "always" | (query) => boolean | "always"; +``` + +Defined in: [packages/query-core/src/types.ts:434](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L434) + +If set to `true`, the query will refetch on window focus if the data is stale. +If set to `false`, the query will not refetch on window focus. +If set to `'always'`, the query will always refetch on window focus (except when `staleTime: 'static'` is used). +If set to a function, the function will be executed with the latest data and query to compute the value. + +Defaults to `true`. + +#### Inherited from + +```ts +OmitKeyof.refetchOnWindowFocus +``` + +*** + +### retry? + +```ts +optional retry: RetryValue; +``` + +Defined in: [packages/query-core/src/types.ts:246](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L246) + +If `false`, failed queries will not retry by default. +If `true`, failed queries will retry infinitely. +If set to an integer number, e.g. 3, failed queries will retry until the failed query count meets that number. +If set to a function `(failureCount, error) => boolean` failed queries will retry until the function returns false. + +Defaults to `3` on the client and `0` on the server. + +#### Inherited from + +```ts +OmitKeyof.retry +``` + +*** + +### retryDelay? + +```ts +optional retryDelay: RetryDelayValue; +``` + +Defined in: [packages/query-core/src/types.ts:258](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L258) + +This function receives a `retryAttempt` integer and the actual Error and returns the delay to apply before the +next attempt in milliseconds. + +A function like `attempt => Math.min(attempt > 1 ? 2 ** attempt * 1000 : 1000, 30 * 1000)` applies exponential +backoff. + +A function like `attempt => attempt * 1000` applies linear backoff. + +Defaults to a function that applies exponential backoff, capped at 30 seconds. + +#### Inherited from + +```ts +OmitKeyof.retryDelay +``` + +*** + +### retryOnMount? + +```ts +optional retryOnMount: QueryBooleanOption, TQueryKey>; +``` + +Defined in: [packages/query-core/src/types.ts:474](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L474) + +If set to `false`, the query will not be retried on mount if it contains an error. +If set to a function, the function will be executed with the query to compute the value. + +Defaults to `true`. + +#### Inherited from + +```ts +OmitKeyof.retryOnMount +``` + +*** + +### select()? + +```ts +optional select: (data) => TData; +``` + +Defined in: [packages/query-core/src/types.ts:500](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L500) + +This option can be used to transform or select a part of the data returned by the query function. It affects +the returned `data` value, but does not affect what gets stored in the query cache. +The `select` function will only run if `data` changed, or if the reference to the `select` function itself +changes. To optimize, memoize the function so its reference stays stable across calls. + +#### Parameters + +##### data + +[`InfiniteData`](InfiniteData.md) + +#### Returns + +`TData` + +#### Inherited from + +```ts +OmitKeyof.select +``` + +*** + +### staleTime? + +```ts +optional staleTime: StaleTimeFunction, TQueryKey>; +``` + +Defined in: [packages/query-core/src/types.ts:407](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L407) + +The time in milliseconds after data is considered stale. +If set to `Infinity`, the data will never be considered stale. +If set to `'static'`, the data will never be considered stale. +If set to a function, the function will be executed with the query to compute a `staleTime`. + +Defaults to `0`. + +#### Inherited from + +```ts +OmitKeyof.staleTime +``` + +*** + ### ~~suspense?~~ ```ts optional suspense: boolean; ``` -Defined in: [types.ts:186](https://github.com/TanStack/query/blob/main/packages/solid-query/src/types.ts#L186) +Defined in: [packages/solid-query/src/types.ts:186](https://github.com/TanStack/query/blob/main/packages/solid-query/src/types.ts#L186) #### Deprecated The `suspense` option has been deprecated in v5 and will be removed in the next major version. The `data` property on useInfiniteQuery is a SolidJS resource and will automatically suspend when the data is loading. Setting `suspense` to `false` will be a no-op. + +*** + +### throwOnError? + +```ts +optional throwOnError: ThrowOnError, TQueryKey>; +``` + +Defined in: [packages/query-core/src/types.ts:493](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L493) + +Whether errors should be thrown instead of setting the `error` property. +If set to `true` or `suspense` is `true`, all errors will be thrown to the error boundary. +If set to `false` and `suspense` is `false`, errors are returned as state. +If set to a function, it will be passed the error and the query, and it should return a boolean indicating whether to show the error in an error boundary (`true`) or return the error as state (`false`). + +Defaults to `false`. + +#### Inherited from + +```ts +OmitKeyof.throwOnError +``` diff --git a/docs/framework/solid/reference/interfaces/InfiniteQueryPageParamsOptions.md b/docs/framework/solid/reference/interfaces/InfiniteQueryPageParamsOptions.md new file mode 100644 index 00000000000..2d98fbfaff4 --- /dev/null +++ b/docs/framework/solid/reference/interfaces/InfiniteQueryPageParamsOptions.md @@ -0,0 +1,60 @@ +--- +id: InfiniteQueryPageParamsOptions +title: InfiniteQueryPageParamsOptions +--- + +Defined in: [packages/query-core/src/types.ts:352](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L352) + +## Extends + +- [`InitialPageParam`](InitialPageParam.md)\<`TPageParam`\> + +## Type Parameters + +### TQueryFnData + +`TQueryFnData` = `unknown` + +### TPageParam + +`TPageParam` = `unknown` + +## Properties + +### getNextPageParam + +```ts +getNextPageParam: GetNextPageParamFunction; +``` + +Defined in: [packages/query-core/src/types.ts:365](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L365) + +This function can be set to automatically get the next cursor for infinite queries. +The result will also be used to determine the value of `hasNextPage`. + +*** + +### getPreviousPageParam? + +```ts +optional getPreviousPageParam: GetPreviousPageParamFunction; +``` + +Defined in: [packages/query-core/src/types.ts:360](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L360) + +This function can be set to automatically get the previous cursor for infinite queries. +The result will also be used to determine the value of `hasPreviousPage`. + +*** + +### initialPageParam + +```ts +initialPageParam: TPageParam; +``` + +Defined in: [packages/query-core/src/types.ts:349](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L349) + +#### Inherited from + +[`InitialPageParam`](InitialPageParam.md).[`initialPageParam`](InitialPageParam.md#initialpageparam) diff --git a/docs/framework/solid/reference/interfaces/InitialPageParam.md b/docs/framework/solid/reference/interfaces/InitialPageParam.md new file mode 100644 index 00000000000..46d2b219ea4 --- /dev/null +++ b/docs/framework/solid/reference/interfaces/InitialPageParam.md @@ -0,0 +1,26 @@ +--- +id: InitialPageParam +title: InitialPageParam +--- + +Defined in: [packages/query-core/src/types.ts:348](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L348) + +## Extended by + +- [`InfiniteQueryPageParamsOptions`](InfiniteQueryPageParamsOptions.md) + +## Type Parameters + +### TPageParam + +`TPageParam` = `unknown` + +## Properties + +### initialPageParam + +```ts +initialPageParam: TPageParam; +``` + +Defined in: [packages/query-core/src/types.ts:349](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L349) diff --git a/docs/framework/solid/reference/interfaces/InvalidateOptions.md b/docs/framework/solid/reference/interfaces/InvalidateOptions.md new file mode 100644 index 00000000000..8a81428b035 --- /dev/null +++ b/docs/framework/solid/reference/interfaces/InvalidateOptions.md @@ -0,0 +1,49 @@ +--- +id: InvalidateOptions +title: InvalidateOptions +--- + +Defined in: [packages/query-core/src/types.ts:734](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L734) + +## Extends + +- [`RefetchOptions`](RefetchOptions.md) + +## Properties + +### cancelRefetch? + +```ts +optional cancelRefetch: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:712](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L712) + +If set to `true`, a currently running request will be cancelled before a new request is made + +If set to `false`, no refetch will be made if there is already a request running. + +Defaults to `true`. + +#### Inherited from + +[`RefetchOptions`](RefetchOptions.md).[`cancelRefetch`](RefetchOptions.md#cancelrefetch) + +*** + +### throwOnError? + +```ts +optional throwOnError: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:701](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L701) + +If set to `true`, the method throws if any of the underlying query refetch tasks fail. + +Defaults to `false`, in which case failed refetches are swallowed and not surfaced to the +caller. + +#### Inherited from + +[`RefetchOptions`](RefetchOptions.md).[`throwOnError`](RefetchOptions.md#throwonerror) diff --git a/docs/framework/solid/reference/interfaces/InvalidateQueryFilters.md b/docs/framework/solid/reference/interfaces/InvalidateQueryFilters.md new file mode 100644 index 00000000000..569e42a4e1b --- /dev/null +++ b/docs/framework/solid/reference/interfaces/InvalidateQueryFilters.md @@ -0,0 +1,145 @@ +--- +id: InvalidateQueryFilters +title: InvalidateQueryFilters +--- + +Defined in: [packages/query-core/src/types.ts:715](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L715) + +Filters used to select queries, for example in `queryClient.getQueriesData` or `queryClient.invalidateQueries`. +All provided filters must match; filters that are left unspecified are ignored. + +## Extends + +- [`QueryFilters`](QueryFilters.md)\<`TQueryKey`\> + +## Type Parameters + +### TQueryKey + +`TQueryKey` *extends* [`QueryKey`](../type-aliases/QueryKey.md) = [`QueryKey`](../type-aliases/QueryKey.md) + +## Properties + +### exact? + +```ts +optional exact: boolean; +``` + +Defined in: [packages/query-core/src/utils.ts:41](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L41) + +Match query key exactly + +#### Inherited from + +[`QueryFilters`](QueryFilters.md).[`exact`](QueryFilters.md#exact) + +*** + +### fetchStatus? + +```ts +optional fetchStatus: FetchStatus; +``` + +Defined in: [packages/query-core/src/utils.ts:57](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L57) + +Include queries matching their fetchStatus + +#### Inherited from + +[`QueryFilters`](QueryFilters.md).[`fetchStatus`](QueryFilters.md#fetchstatus) + +*** + +### predicate()? + +```ts +optional predicate: (query) => boolean; +``` + +Defined in: [packages/query-core/src/utils.ts:45](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L45) + +Include queries matching this predicate function + +#### Parameters + +##### query + +[`Query`](../classes/Query.md) + +#### Returns + +`boolean` + +#### Inherited from + +[`QueryFilters`](QueryFilters.md).[`predicate`](QueryFilters.md#predicate) + +*** + +### queryKey? + +```ts +optional queryKey: TQueryKey | TuplePrefixes; +``` + +Defined in: [packages/query-core/src/utils.ts:49](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L49) + +Include queries matching this query key + +#### Inherited from + +[`QueryFilters`](QueryFilters.md).[`queryKey`](QueryFilters.md#querykey) + +*** + +### refetchType? + +```ts +optional refetchType: QueryTypeFilter | "none"; +``` + +Defined in: [packages/query-core/src/types.ts:727](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L727) + +Controls which of the matched (now-invalidated) queries are refetched in the background. + +Defaults to `'active'`. +- `'active'`: only queries with at least one active observer are refetched. +- `'inactive'`: only queries with no active observer are refetched. +- `'all'`: every matched query is refetched, active or not. +- `'none'`: no query is refetched; matched queries are only marked as invalidated. + +*** + +### stale? + +```ts +optional stale: boolean; +``` + +Defined in: [packages/query-core/src/utils.ts:53](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L53) + +Include or exclude stale queries + +#### Inherited from + +[`QueryFilters`](QueryFilters.md).[`stale`](QueryFilters.md#stale) + +*** + +### type? + +```ts +optional type: QueryTypeFilter; +``` + +Defined in: [packages/query-core/src/utils.ts:37](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L37) + +Filter to active queries, inactive queries or all queries + +Defaults to `'all'`. + +#### Inherited from + +[`QueryFilters`](QueryFilters.md).[`type`](QueryFilters.md#type) diff --git a/docs/framework/solid/reference/interfaces/MutateOptions.md b/docs/framework/solid/reference/interfaces/MutateOptions.md new file mode 100644 index 00000000000..34e2a4d4d7e --- /dev/null +++ b/docs/framework/solid/reference/interfaces/MutateOptions.md @@ -0,0 +1,124 @@ +--- +id: MutateOptions +title: MutateOptions +--- + +Defined in: [packages/query-core/src/types.ts:1284](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1284) + +## Type Parameters + +### TData + +`TData` = `unknown` + +### TError + +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) + +### TVariables + +`TVariables` = `void` + +### TOnMutateResult + +`TOnMutateResult` = `unknown` + +## Properties + +### onError()? + +```ts +optional onError: (error, variables, onMutateResult, context) => void; +``` + +Defined in: [packages/query-core/src/types.ts:1296](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1296) + +#### Parameters + +##### error + +`TError` + +##### variables + +`TVariables` + +##### onMutateResult + +`TOnMutateResult` | `undefined` + +##### context + +[`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md) + +#### Returns + +`void` + +*** + +### onSettled()? + +```ts +optional onSettled: (data, error, variables, onMutateResult, context) => void; +``` + +Defined in: [packages/query-core/src/types.ts:1302](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1302) + +#### Parameters + +##### data + +`TData` | `undefined` + +##### error + +`TError` | `null` + +##### variables + +`TVariables` + +##### onMutateResult + +`TOnMutateResult` | `undefined` + +##### context + +[`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md) + +#### Returns + +`void` + +*** + +### onSuccess()? + +```ts +optional onSuccess: (data, variables, onMutateResult, context) => void; +``` + +Defined in: [packages/query-core/src/types.ts:1290](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1290) + +#### Parameters + +##### data + +`TData` + +##### variables + +`TVariables` + +##### onMutateResult + +`TOnMutateResult` | `undefined` + +##### context + +[`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md) + +#### Returns + +`void` diff --git a/docs/framework/solid/reference/interfaces/MutationCacheConfig.md b/docs/framework/solid/reference/interfaces/MutationCacheConfig.md new file mode 100644 index 00000000000..c38d2dc26f4 --- /dev/null +++ b/docs/framework/solid/reference/interfaces/MutationCacheConfig.md @@ -0,0 +1,161 @@ +--- +id: MutationCacheConfig +title: MutationCacheConfig +--- + +Defined in: [packages/query-core/src/mutationCache.ts:26](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationCache.ts#L26) + +Global callbacks that fire for every mutation handled by a `MutationCache`, regardless of which +component or observer triggered it. They differ from the `defaultOptions` provided to a +`QueryClient` in two ways: `defaultOptions` can be overridden by each mutation, while these +callbacks are always called, and `onMutate` here does not allow returning a result. + +If a callback returns a promise, it will be awaited before the mutation continues. + +## Properties + +### onError()? + +```ts +optional onError: (error, variables, onMutateResult, mutation, context) => unknown; +``` + +Defined in: [packages/query-core/src/mutationCache.ts:28](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationCache.ts#L28) + +Called when any mutation in the cache encounters an error. + +#### Parameters + +##### error + +`Error` + +##### variables + +`unknown` + +##### onMutateResult + +`unknown` + +##### mutation + +[`Mutation`](../classes/Mutation.md)\<`unknown`, `unknown`, `unknown`\> + +##### context + +[`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md) + +#### Returns + +`unknown` + +*** + +### onMutate()? + +```ts +optional onMutate: (variables, mutation, context) => unknown; +``` + +Defined in: [packages/query-core/src/mutationCache.ts:44](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationCache.ts#L44) + +Called before any mutation in the cache executes. + +#### Parameters + +##### variables + +`unknown` + +##### mutation + +[`Mutation`](../classes/Mutation.md)\<`unknown`, `unknown`, `unknown`\> + +##### context + +[`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md) + +#### Returns + +`unknown` + +*** + +### onSettled()? + +```ts +optional onSettled: (data, error, variables, onMutateResult, mutation, context) => unknown; +``` + +Defined in: [packages/query-core/src/mutationCache.ts:50](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationCache.ts#L50) + +Called when any mutation in the cache is settled, either successfully or with an error. + +#### Parameters + +##### data + +`unknown` + +##### error + +`Error` | `null` + +##### variables + +`unknown` + +##### onMutateResult + +`unknown` + +##### mutation + +[`Mutation`](../classes/Mutation.md)\<`unknown`, `unknown`, `unknown`\> + +##### context + +[`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md) + +#### Returns + +`unknown` + +*** + +### onSuccess()? + +```ts +optional onSuccess: (data, variables, onMutateResult, mutation, context) => unknown; +``` + +Defined in: [packages/query-core/src/mutationCache.ts:36](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationCache.ts#L36) + +Called when any mutation in the cache is successful. + +#### Parameters + +##### data + +`unknown` + +##### variables + +`unknown` + +##### onMutateResult + +`unknown` + +##### mutation + +[`Mutation`](../classes/Mutation.md)\<`unknown`, `unknown`, `unknown`\> + +##### context + +[`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md) + +#### Returns + +`unknown` diff --git a/docs/framework/solid/reference/interfaces/MutationFilters.md b/docs/framework/solid/reference/interfaces/MutationFilters.md new file mode 100644 index 00000000000..fbc0208e8e1 --- /dev/null +++ b/docs/framework/solid/reference/interfaces/MutationFilters.md @@ -0,0 +1,85 @@ +--- +id: MutationFilters +title: MutationFilters +--- + +Defined in: [packages/query-core/src/utils.ts:64](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L64) + +Filters used to select mutations, for example in `mutationCache.findAll` or `queryClient.isMutating`. +All provided filters must match; filters that are left unspecified are ignored. + +## Type Parameters + +### TData + +`TData` = `unknown` + +### TError + +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) + +### TVariables + +`TVariables` = `unknown` + +### TOnMutateResult + +`TOnMutateResult` = `unknown` + +## Properties + +### exact? + +```ts +optional exact: boolean; +``` + +Defined in: [packages/query-core/src/utils.ts:73](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L73) + +Match mutation key exactly + +*** + +### mutationKey? + +```ts +optional mutationKey: readonly unknown[]; +``` + +Defined in: [packages/query-core/src/utils.ts:83](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L83) + +Include mutations matching this mutation key + +*** + +### predicate()? + +```ts +optional predicate: (mutation) => boolean; +``` + +Defined in: [packages/query-core/src/utils.ts:77](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L77) + +Include mutations matching this predicate function + +#### Parameters + +##### mutation + +[`Mutation`](../classes/Mutation.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\> + +#### Returns + +`boolean` + +*** + +### status? + +```ts +optional status: MutationStatus; +``` + +Defined in: [packages/query-core/src/utils.ts:87](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L87) + +Filter by mutation status diff --git a/docs/framework/solid/reference/interfaces/MutationObserverBaseResult.md b/docs/framework/solid/reference/interfaces/MutationObserverBaseResult.md new file mode 100644 index 00000000000..340a38cc9cc --- /dev/null +++ b/docs/framework/solid/reference/interfaces/MutationObserverBaseResult.md @@ -0,0 +1,291 @@ +--- +id: MutationObserverBaseResult +title: MutationObserverBaseResult +--- + +Defined in: [packages/query-core/src/types.ts:1335](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1335) + +The raw state stored on a `Mutation` instance. This is the underlying state +that observer results (e.g. `MutationObserverResult`) are derived from. + +## Extends + +- [`MutationState`](MutationState.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\> + +## Extended by + +- [`MutationObserverIdleResult`](MutationObserverIdleResult.md) +- [`MutationObserverLoadingResult`](MutationObserverLoadingResult.md) +- [`MutationObserverErrorResult`](MutationObserverErrorResult.md) +- [`MutationObserverSuccessResult`](MutationObserverSuccessResult.md) + +## Type Parameters + +### TData + +`TData` = `unknown` + +### TError + +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) + +### TVariables + +`TVariables` = `void` + +### TOnMutateResult + +`TOnMutateResult` = `unknown` + +## Properties + +### context + +```ts +context: TOnMutateResult | undefined; +``` + +Defined in: [packages/query-core/src/mutation.ts:40](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L40) + +The value returned by `onMutate`, if defined. Passed to `onSuccess`, +`onError` and `onSettled` as the mutation's context. + +#### Inherited from + +[`MutationState`](MutationState.md).[`context`](MutationState.md#context) + +*** + +### data + +```ts +data: TData | undefined; +``` + +Defined in: [packages/query-core/src/types.ts:1344](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1344) + +The last successfully resolved data for the mutation. + +#### Overrides + +[`MutationState`](MutationState.md).[`data`](MutationState.md#data) + +*** + +### error + +```ts +error: TError | null; +``` + +Defined in: [packages/query-core/src/types.ts:1353](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1353) + +The error object for the mutation, if an error was encountered. +- Defaults to `null`. + +#### Overrides + +[`MutationState`](MutationState.md).[`error`](MutationState.md#error) + +*** + +### failureCount + +```ts +failureCount: number; +``` + +Defined in: [packages/query-core/src/mutation.ts:53](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L53) + +The number of times the mutation function has failed for the current attempt. + +#### Inherited from + +[`MutationState`](MutationState.md).[`failureCount`](MutationState.md#failurecount) + +*** + +### failureReason + +```ts +failureReason: TError | null; +``` + +Defined in: [packages/query-core/src/mutation.ts:57](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L57) + +The reason the current attempt failed, as reported by the retryer. + +#### Inherited from + +[`MutationState`](MutationState.md).[`failureReason`](MutationState.md#failurereason) + +*** + +### isError + +```ts +isError: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1358](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1358) + +A boolean variable derived from `status`. +- `true` if the last mutation attempt resulted in an error. + +*** + +### isIdle + +```ts +isIdle: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1363](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1363) + +A boolean variable derived from `status`. +- `true` if the mutation is in its initial state prior to executing. + +*** + +### isPaused + +```ts +isPaused: boolean; +``` + +Defined in: [packages/query-core/src/mutation.ts:62](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L62) + +Whether the mutation is currently paused (see network mode), or is +waiting for another mutation with the same `scope` to finish. + +#### Inherited from + +[`MutationState`](MutationState.md).[`isPaused`](MutationState.md#ispaused) + +*** + +### isPending + +```ts +isPending: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1368](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1368) + +A boolean variable derived from `status`. +- `true` if the mutation is currently executing. + +*** + +### isSuccess + +```ts +isSuccess: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1373](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1373) + +A boolean variable derived from `status`. +- `true` if the last mutation attempt was successful. + +*** + +### mutate + +```ts +mutate: MutateFunction; +``` + +Defined in: [packages/query-core/src/types.ts:1393](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1393) + +The mutation function you can call with variables to trigger the mutation and optionally hooks on additional callback options. + +#### Param + +The variables object to pass to the `mutationFn`. + +#### Param + +This function will fire when the mutation is successful and will be passed the mutation's result. + +#### Param + +This function will fire if the mutation encounters an error and will be passed the error. + +#### Param + +This function will fire when the mutation is either successfully fetched or encounters an error and be passed either the data or error. + +#### Remarks + +- If you make multiple requests, `onSuccess` will fire only after the latest call you've made. +- All the callback functions (`onSuccess`, `onError`, `onSettled`) are void functions, and the returned value will be ignored. + +*** + +### reset() + +```ts +reset: () => void; +``` + +Defined in: [packages/query-core/src/types.ts:1397](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1397) + +A function to clean the mutation internal state (i.e., it resets the mutation to its initial state). + +#### Returns + +`void` + +*** + +### status + +```ts +status: MutationStatus; +``` + +Defined in: [packages/query-core/src/types.ts:1382](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1382) + +The status of the mutation. +- Will be: + - `idle` initial status prior to the mutation function executing. + - `pending` if the mutation is currently executing. + - `error` if the last mutation attempt resulted in an error. + - `success` if the last mutation attempt was successful. + +#### Overrides + +[`MutationState`](MutationState.md).[`status`](MutationState.md#status) + +*** + +### submittedAt + +```ts +submittedAt: number; +``` + +Defined in: [packages/query-core/src/mutation.ts:74](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L74) + +The timestamp for when the mutation was submitted. + +#### Inherited from + +[`MutationState`](MutationState.md).[`submittedAt`](MutationState.md#submittedat) + +*** + +### variables + +```ts +variables: TVariables | undefined; +``` + +Defined in: [packages/query-core/src/types.ts:1348](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1348) + +The variables object passed to the `mutationFn`. + +#### Overrides + +[`MutationState`](MutationState.md).[`variables`](MutationState.md#variables) diff --git a/docs/framework/solid/reference/interfaces/MutationObserverErrorResult.md b/docs/framework/solid/reference/interfaces/MutationObserverErrorResult.md new file mode 100644 index 00000000000..72e459a2e0b --- /dev/null +++ b/docs/framework/solid/reference/interfaces/MutationObserverErrorResult.md @@ -0,0 +1,308 @@ +--- +id: MutationObserverErrorResult +title: MutationObserverErrorResult +--- + +Defined in: [packages/query-core/src/types.ts:1442](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1442) + +The raw state stored on a `Mutation` instance. This is the underlying state +that observer results (e.g. `MutationObserverResult`) are derived from. + +## Extends + +- [`MutationObserverBaseResult`](MutationObserverBaseResult.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\> + +## Type Parameters + +### TData + +`TData` = `unknown` + +### TError + +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) + +### TVariables + +`TVariables` = `void` + +### TOnMutateResult + +`TOnMutateResult` = `unknown` + +## Properties + +### context + +```ts +context: TOnMutateResult | undefined; +``` + +Defined in: [packages/query-core/src/mutation.ts:40](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L40) + +The value returned by `onMutate`, if defined. Passed to `onSuccess`, +`onError` and `onSettled` as the mutation's context. + +#### Inherited from + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`context`](MutationObserverBaseResult.md#context) + +*** + +### data + +```ts +data: undefined; +``` + +Defined in: [packages/query-core/src/types.ts:1453](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1453) + +The last successfully resolved data for the mutation. + +#### Overrides + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`data`](MutationObserverBaseResult.md#data) + +*** + +### error + +```ts +error: TError; +``` + +Defined in: [packages/query-core/src/types.ts:1454](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1454) + +The error object for the mutation, if an error was encountered. +- Defaults to `null`. + +#### Overrides + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`error`](MutationObserverBaseResult.md#error) + +*** + +### failureCount + +```ts +failureCount: number; +``` + +Defined in: [packages/query-core/src/mutation.ts:53](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L53) + +The number of times the mutation function has failed for the current attempt. + +#### Inherited from + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`failureCount`](MutationObserverBaseResult.md#failurecount) + +*** + +### failureReason + +```ts +failureReason: TError | null; +``` + +Defined in: [packages/query-core/src/mutation.ts:57](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L57) + +The reason the current attempt failed, as reported by the retryer. + +#### Inherited from + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`failureReason`](MutationObserverBaseResult.md#failurereason) + +*** + +### isError + +```ts +isError: true; +``` + +Defined in: [packages/query-core/src/types.ts:1456](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1456) + +A boolean variable derived from `status`. +- `true` if the last mutation attempt resulted in an error. + +#### Overrides + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isError`](MutationObserverBaseResult.md#iserror) + +*** + +### isIdle + +```ts +isIdle: false; +``` + +Defined in: [packages/query-core/src/types.ts:1457](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1457) + +A boolean variable derived from `status`. +- `true` if the mutation is in its initial state prior to executing. + +#### Overrides + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isIdle`](MutationObserverBaseResult.md#isidle) + +*** + +### isPaused + +```ts +isPaused: boolean; +``` + +Defined in: [packages/query-core/src/mutation.ts:62](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L62) + +Whether the mutation is currently paused (see network mode), or is +waiting for another mutation with the same `scope` to finish. + +#### Inherited from + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isPaused`](MutationObserverBaseResult.md#ispaused) + +*** + +### isPending + +```ts +isPending: false; +``` + +Defined in: [packages/query-core/src/types.ts:1458](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1458) + +A boolean variable derived from `status`. +- `true` if the mutation is currently executing. + +#### Overrides + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isPending`](MutationObserverBaseResult.md#ispending) + +*** + +### isSuccess + +```ts +isSuccess: false; +``` + +Defined in: [packages/query-core/src/types.ts:1459](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1459) + +A boolean variable derived from `status`. +- `true` if the last mutation attempt was successful. + +#### Overrides + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isSuccess`](MutationObserverBaseResult.md#issuccess) + +*** + +### mutate + +```ts +mutate: MutateFunction; +``` + +Defined in: [packages/query-core/src/types.ts:1393](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1393) + +The mutation function you can call with variables to trigger the mutation and optionally hooks on additional callback options. + +#### Param + +The variables object to pass to the `mutationFn`. + +#### Param + +This function will fire when the mutation is successful and will be passed the mutation's result. + +#### Param + +This function will fire if the mutation encounters an error and will be passed the error. + +#### Param + +This function will fire when the mutation is either successfully fetched or encounters an error and be passed either the data or error. + +#### Remarks + +- If you make multiple requests, `onSuccess` will fire only after the latest call you've made. +- All the callback functions (`onSuccess`, `onError`, `onSettled`) are void functions, and the returned value will be ignored. + +#### Inherited from + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`mutate`](MutationObserverBaseResult.md#mutate) + +*** + +### reset() + +```ts +reset: () => void; +``` + +Defined in: [packages/query-core/src/types.ts:1397](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1397) + +A function to clean the mutation internal state (i.e., it resets the mutation to its initial state). + +#### Returns + +`void` + +#### Inherited from + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`reset`](MutationObserverBaseResult.md#reset) + +*** + +### status + +```ts +status: "error"; +``` + +Defined in: [packages/query-core/src/types.ts:1460](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1460) + +The status of the mutation. +- Will be: + - `idle` initial status prior to the mutation function executing. + - `pending` if the mutation is currently executing. + - `error` if the last mutation attempt resulted in an error. + - `success` if the last mutation attempt was successful. + +#### Overrides + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`status`](MutationObserverBaseResult.md#status) + +*** + +### submittedAt + +```ts +submittedAt: number; +``` + +Defined in: [packages/query-core/src/mutation.ts:74](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L74) + +The timestamp for when the mutation was submitted. + +#### Inherited from + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`submittedAt`](MutationObserverBaseResult.md#submittedat) + +*** + +### variables + +```ts +variables: TVariables; +``` + +Defined in: [packages/query-core/src/types.ts:1455](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1455) + +The variables object passed to the `mutationFn`. + +#### Overrides + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`variables`](MutationObserverBaseResult.md#variables) diff --git a/docs/framework/solid/reference/interfaces/MutationObserverIdleResult.md b/docs/framework/solid/reference/interfaces/MutationObserverIdleResult.md new file mode 100644 index 00000000000..cd8d6eb3130 --- /dev/null +++ b/docs/framework/solid/reference/interfaces/MutationObserverIdleResult.md @@ -0,0 +1,308 @@ +--- +id: MutationObserverIdleResult +title: MutationObserverIdleResult +--- + +Defined in: [packages/query-core/src/types.ts:1400](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1400) + +The raw state stored on a `Mutation` instance. This is the underlying state +that observer results (e.g. `MutationObserverResult`) are derived from. + +## Extends + +- [`MutationObserverBaseResult`](MutationObserverBaseResult.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\> + +## Type Parameters + +### TData + +`TData` = `unknown` + +### TError + +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) + +### TVariables + +`TVariables` = `void` + +### TOnMutateResult + +`TOnMutateResult` = `unknown` + +## Properties + +### context + +```ts +context: TOnMutateResult | undefined; +``` + +Defined in: [packages/query-core/src/mutation.ts:40](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L40) + +The value returned by `onMutate`, if defined. Passed to `onSuccess`, +`onError` and `onSettled` as the mutation's context. + +#### Inherited from + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`context`](MutationObserverBaseResult.md#context) + +*** + +### data + +```ts +data: undefined; +``` + +Defined in: [packages/query-core/src/types.ts:1411](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1411) + +The last successfully resolved data for the mutation. + +#### Overrides + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`data`](MutationObserverBaseResult.md#data) + +*** + +### error + +```ts +error: null; +``` + +Defined in: [packages/query-core/src/types.ts:1413](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1413) + +The error object for the mutation, if an error was encountered. +- Defaults to `null`. + +#### Overrides + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`error`](MutationObserverBaseResult.md#error) + +*** + +### failureCount + +```ts +failureCount: number; +``` + +Defined in: [packages/query-core/src/mutation.ts:53](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L53) + +The number of times the mutation function has failed for the current attempt. + +#### Inherited from + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`failureCount`](MutationObserverBaseResult.md#failurecount) + +*** + +### failureReason + +```ts +failureReason: TError | null; +``` + +Defined in: [packages/query-core/src/mutation.ts:57](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L57) + +The reason the current attempt failed, as reported by the retryer. + +#### Inherited from + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`failureReason`](MutationObserverBaseResult.md#failurereason) + +*** + +### isError + +```ts +isError: false; +``` + +Defined in: [packages/query-core/src/types.ts:1414](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1414) + +A boolean variable derived from `status`. +- `true` if the last mutation attempt resulted in an error. + +#### Overrides + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isError`](MutationObserverBaseResult.md#iserror) + +*** + +### isIdle + +```ts +isIdle: true; +``` + +Defined in: [packages/query-core/src/types.ts:1415](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1415) + +A boolean variable derived from `status`. +- `true` if the mutation is in its initial state prior to executing. + +#### Overrides + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isIdle`](MutationObserverBaseResult.md#isidle) + +*** + +### isPaused + +```ts +isPaused: boolean; +``` + +Defined in: [packages/query-core/src/mutation.ts:62](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L62) + +Whether the mutation is currently paused (see network mode), or is +waiting for another mutation with the same `scope` to finish. + +#### Inherited from + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isPaused`](MutationObserverBaseResult.md#ispaused) + +*** + +### isPending + +```ts +isPending: false; +``` + +Defined in: [packages/query-core/src/types.ts:1416](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1416) + +A boolean variable derived from `status`. +- `true` if the mutation is currently executing. + +#### Overrides + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isPending`](MutationObserverBaseResult.md#ispending) + +*** + +### isSuccess + +```ts +isSuccess: false; +``` + +Defined in: [packages/query-core/src/types.ts:1417](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1417) + +A boolean variable derived from `status`. +- `true` if the last mutation attempt was successful. + +#### Overrides + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isSuccess`](MutationObserverBaseResult.md#issuccess) + +*** + +### mutate + +```ts +mutate: MutateFunction; +``` + +Defined in: [packages/query-core/src/types.ts:1393](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1393) + +The mutation function you can call with variables to trigger the mutation and optionally hooks on additional callback options. + +#### Param + +The variables object to pass to the `mutationFn`. + +#### Param + +This function will fire when the mutation is successful and will be passed the mutation's result. + +#### Param + +This function will fire if the mutation encounters an error and will be passed the error. + +#### Param + +This function will fire when the mutation is either successfully fetched or encounters an error and be passed either the data or error. + +#### Remarks + +- If you make multiple requests, `onSuccess` will fire only after the latest call you've made. +- All the callback functions (`onSuccess`, `onError`, `onSettled`) are void functions, and the returned value will be ignored. + +#### Inherited from + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`mutate`](MutationObserverBaseResult.md#mutate) + +*** + +### reset() + +```ts +reset: () => void; +``` + +Defined in: [packages/query-core/src/types.ts:1397](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1397) + +A function to clean the mutation internal state (i.e., it resets the mutation to its initial state). + +#### Returns + +`void` + +#### Inherited from + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`reset`](MutationObserverBaseResult.md#reset) + +*** + +### status + +```ts +status: "idle"; +``` + +Defined in: [packages/query-core/src/types.ts:1418](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1418) + +The status of the mutation. +- Will be: + - `idle` initial status prior to the mutation function executing. + - `pending` if the mutation is currently executing. + - `error` if the last mutation attempt resulted in an error. + - `success` if the last mutation attempt was successful. + +#### Overrides + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`status`](MutationObserverBaseResult.md#status) + +*** + +### submittedAt + +```ts +submittedAt: number; +``` + +Defined in: [packages/query-core/src/mutation.ts:74](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L74) + +The timestamp for when the mutation was submitted. + +#### Inherited from + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`submittedAt`](MutationObserverBaseResult.md#submittedat) + +*** + +### variables + +```ts +variables: undefined; +``` + +Defined in: [packages/query-core/src/types.ts:1412](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1412) + +The variables object passed to the `mutationFn`. + +#### Overrides + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`variables`](MutationObserverBaseResult.md#variables) diff --git a/docs/framework/solid/reference/interfaces/MutationObserverLoadingResult.md b/docs/framework/solid/reference/interfaces/MutationObserverLoadingResult.md new file mode 100644 index 00000000000..9b70a8558e7 --- /dev/null +++ b/docs/framework/solid/reference/interfaces/MutationObserverLoadingResult.md @@ -0,0 +1,308 @@ +--- +id: MutationObserverLoadingResult +title: MutationObserverLoadingResult +--- + +Defined in: [packages/query-core/src/types.ts:1421](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1421) + +The raw state stored on a `Mutation` instance. This is the underlying state +that observer results (e.g. `MutationObserverResult`) are derived from. + +## Extends + +- [`MutationObserverBaseResult`](MutationObserverBaseResult.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\> + +## Type Parameters + +### TData + +`TData` = `unknown` + +### TError + +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) + +### TVariables + +`TVariables` = `void` + +### TOnMutateResult + +`TOnMutateResult` = `unknown` + +## Properties + +### context + +```ts +context: TOnMutateResult | undefined; +``` + +Defined in: [packages/query-core/src/mutation.ts:40](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L40) + +The value returned by `onMutate`, if defined. Passed to `onSuccess`, +`onError` and `onSettled` as the mutation's context. + +#### Inherited from + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`context`](MutationObserverBaseResult.md#context) + +*** + +### data + +```ts +data: undefined; +``` + +Defined in: [packages/query-core/src/types.ts:1432](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1432) + +The last successfully resolved data for the mutation. + +#### Overrides + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`data`](MutationObserverBaseResult.md#data) + +*** + +### error + +```ts +error: null; +``` + +Defined in: [packages/query-core/src/types.ts:1434](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1434) + +The error object for the mutation, if an error was encountered. +- Defaults to `null`. + +#### Overrides + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`error`](MutationObserverBaseResult.md#error) + +*** + +### failureCount + +```ts +failureCount: number; +``` + +Defined in: [packages/query-core/src/mutation.ts:53](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L53) + +The number of times the mutation function has failed for the current attempt. + +#### Inherited from + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`failureCount`](MutationObserverBaseResult.md#failurecount) + +*** + +### failureReason + +```ts +failureReason: TError | null; +``` + +Defined in: [packages/query-core/src/mutation.ts:57](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L57) + +The reason the current attempt failed, as reported by the retryer. + +#### Inherited from + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`failureReason`](MutationObserverBaseResult.md#failurereason) + +*** + +### isError + +```ts +isError: false; +``` + +Defined in: [packages/query-core/src/types.ts:1435](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1435) + +A boolean variable derived from `status`. +- `true` if the last mutation attempt resulted in an error. + +#### Overrides + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isError`](MutationObserverBaseResult.md#iserror) + +*** + +### isIdle + +```ts +isIdle: false; +``` + +Defined in: [packages/query-core/src/types.ts:1436](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1436) + +A boolean variable derived from `status`. +- `true` if the mutation is in its initial state prior to executing. + +#### Overrides + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isIdle`](MutationObserverBaseResult.md#isidle) + +*** + +### isPaused + +```ts +isPaused: boolean; +``` + +Defined in: [packages/query-core/src/mutation.ts:62](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L62) + +Whether the mutation is currently paused (see network mode), or is +waiting for another mutation with the same `scope` to finish. + +#### Inherited from + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isPaused`](MutationObserverBaseResult.md#ispaused) + +*** + +### isPending + +```ts +isPending: true; +``` + +Defined in: [packages/query-core/src/types.ts:1437](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1437) + +A boolean variable derived from `status`. +- `true` if the mutation is currently executing. + +#### Overrides + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isPending`](MutationObserverBaseResult.md#ispending) + +*** + +### isSuccess + +```ts +isSuccess: false; +``` + +Defined in: [packages/query-core/src/types.ts:1438](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1438) + +A boolean variable derived from `status`. +- `true` if the last mutation attempt was successful. + +#### Overrides + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isSuccess`](MutationObserverBaseResult.md#issuccess) + +*** + +### mutate + +```ts +mutate: MutateFunction; +``` + +Defined in: [packages/query-core/src/types.ts:1393](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1393) + +The mutation function you can call with variables to trigger the mutation and optionally hooks on additional callback options. + +#### Param + +The variables object to pass to the `mutationFn`. + +#### Param + +This function will fire when the mutation is successful and will be passed the mutation's result. + +#### Param + +This function will fire if the mutation encounters an error and will be passed the error. + +#### Param + +This function will fire when the mutation is either successfully fetched or encounters an error and be passed either the data or error. + +#### Remarks + +- If you make multiple requests, `onSuccess` will fire only after the latest call you've made. +- All the callback functions (`onSuccess`, `onError`, `onSettled`) are void functions, and the returned value will be ignored. + +#### Inherited from + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`mutate`](MutationObserverBaseResult.md#mutate) + +*** + +### reset() + +```ts +reset: () => void; +``` + +Defined in: [packages/query-core/src/types.ts:1397](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1397) + +A function to clean the mutation internal state (i.e., it resets the mutation to its initial state). + +#### Returns + +`void` + +#### Inherited from + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`reset`](MutationObserverBaseResult.md#reset) + +*** + +### status + +```ts +status: "pending"; +``` + +Defined in: [packages/query-core/src/types.ts:1439](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1439) + +The status of the mutation. +- Will be: + - `idle` initial status prior to the mutation function executing. + - `pending` if the mutation is currently executing. + - `error` if the last mutation attempt resulted in an error. + - `success` if the last mutation attempt was successful. + +#### Overrides + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`status`](MutationObserverBaseResult.md#status) + +*** + +### submittedAt + +```ts +submittedAt: number; +``` + +Defined in: [packages/query-core/src/mutation.ts:74](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L74) + +The timestamp for when the mutation was submitted. + +#### Inherited from + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`submittedAt`](MutationObserverBaseResult.md#submittedat) + +*** + +### variables + +```ts +variables: TVariables; +``` + +Defined in: [packages/query-core/src/types.ts:1433](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1433) + +The variables object passed to the `mutationFn`. + +#### Overrides + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`variables`](MutationObserverBaseResult.md#variables) diff --git a/docs/framework/solid/reference/interfaces/MutationObserverOptions.md b/docs/framework/solid/reference/interfaces/MutationObserverOptions.md new file mode 100644 index 00000000000..b3835184b96 --- /dev/null +++ b/docs/framework/solid/reference/interfaces/MutationObserverOptions.md @@ -0,0 +1,346 @@ +--- +id: MutationObserverOptions +title: MutationObserverOptions +--- + +Defined in: [packages/query-core/src/types.ts:1267](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1267) + +## Extends + +- `MutationOptions`\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\> + +## Type Parameters + +### TData + +`TData` = `unknown` + +### TError + +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) + +### TVariables + +`TVariables` = `void` + +### TOnMutateResult + +`TOnMutateResult` = `unknown` + +## Properties + +### gcTime? + +```ts +optional gcTime: number; +``` + +Defined in: [packages/query-core/src/types.ts:1260](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1260) + +The time in milliseconds that an unused/inactive mutation remains in memory before it is +garbage collected. + +Defaults to `5 * 60 * 1000` (5 minutes), or `Infinity` during SSR. + +#### Inherited from + +```ts +MutationOptions.gcTime +``` + +*** + +### meta? + +```ts +optional meta: Record; +``` + +Defined in: [packages/query-core/src/types.ts:1263](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1263) + +#### Inherited from + +```ts +MutationOptions.meta +``` + +*** + +### mutationFn? + +```ts +optional mutationFn: MutationFunction; +``` + +Defined in: [packages/query-core/src/types.ts:1206](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1206) + +#### Inherited from + +```ts +MutationOptions.mutationFn +``` + +*** + +### mutationKey? + +```ts +optional mutationKey: readonly unknown[]; +``` + +Defined in: [packages/query-core/src/types.ts:1207](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1207) + +#### Inherited from + +```ts +MutationOptions.mutationKey +``` + +*** + +### networkMode? + +```ts +optional networkMode: NetworkMode; +``` + +Defined in: [packages/query-core/src/types.ts:1253](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1253) + +Controls whether a mutation is allowed to run based on the current network connectivity. + +Defaults to `'online'`. + +#### See + +[Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. + +#### Inherited from + +```ts +MutationOptions.networkMode +``` + +*** + +### onError()? + +```ts +optional onError: (error, variables, onMutateResult, context) => unknown; +``` + +Defined in: [packages/query-core/src/types.ts:1218](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1218) + +#### Parameters + +##### error + +`TError` + +##### variables + +`TVariables` + +##### onMutateResult + +`TOnMutateResult` | `undefined` + +##### context + +[`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md) + +#### Returns + +`unknown` + +#### Inherited from + +```ts +MutationOptions.onError +``` + +*** + +### onMutate()? + +```ts +optional onMutate: (variables, context) => TOnMutateResult | Promise; +``` + +Defined in: [packages/query-core/src/types.ts:1208](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1208) + +#### Parameters + +##### variables + +`TVariables` + +##### context + +[`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md) + +#### Returns + +`TOnMutateResult` \| `Promise`\<`TOnMutateResult`\> + +#### Inherited from + +```ts +MutationOptions.onMutate +``` + +*** + +### onSettled()? + +```ts +optional onSettled: (data, error, variables, onMutateResult, context) => unknown; +``` + +Defined in: [packages/query-core/src/types.ts:1224](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1224) + +#### Parameters + +##### data + +`TData` | `undefined` + +##### error + +`TError` | `null` + +##### variables + +`TVariables` + +##### onMutateResult + +`TOnMutateResult` | `undefined` + +##### context + +[`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md) + +#### Returns + +`unknown` + +#### Inherited from + +```ts +MutationOptions.onSettled +``` + +*** + +### onSuccess()? + +```ts +optional onSuccess: (data, variables, onMutateResult, context) => unknown; +``` + +Defined in: [packages/query-core/src/types.ts:1212](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1212) + +#### Parameters + +##### data + +`TData` + +##### variables + +`TVariables` + +##### onMutateResult + +`TOnMutateResult` + +##### context + +[`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md) + +#### Returns + +`unknown` + +#### Inherited from + +```ts +MutationOptions.onSuccess +``` + +*** + +### retry? + +```ts +optional retry: RetryValue; +``` + +Defined in: [packages/query-core/src/types.ts:1239](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1239) + +If `false`, failed mutations will not retry by default. +If `true`, failed mutations will retry infinitely. +If set to an integer number, e.g. 3, failed mutations will retry until the failed mutation count meets that number. +If set to a function `(failureCount, error) => boolean` failed mutations will retry until the function returns false. + +Defaults to `0`. + +#### Inherited from + +```ts +MutationOptions.retry +``` + +*** + +### retryDelay? + +```ts +optional retryDelay: RetryDelayValue; +``` + +Defined in: [packages/query-core/src/types.ts:1246](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1246) + +This function receives a `retryAttempt` integer and the actual Error and returns the delay to apply before the +next attempt in milliseconds. + +Defaults to a function that applies exponential backoff, capped at 30 seconds. + +#### Inherited from + +```ts +MutationOptions.retryDelay +``` + +*** + +### scope? + +```ts +optional scope: MutationScope; +``` + +Defined in: [packages/query-core/src/types.ts:1264](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1264) + +#### Inherited from + +```ts +MutationOptions.scope +``` + +*** + +### throwOnError? + +```ts +optional throwOnError: boolean | (error) => boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1281](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1281) + +Whether errors should be thrown instead of setting the `error` property. +If set to `true`, all errors will be thrown to the nearest error boundary. +If set to a function, it will be passed the error and should return a boolean indicating whether to throw the +error (`true`) or return it as state (`false`). + +Defaults to `false`. diff --git a/docs/framework/solid/reference/interfaces/MutationObserverSuccessResult.md b/docs/framework/solid/reference/interfaces/MutationObserverSuccessResult.md new file mode 100644 index 00000000000..e2e03642f82 --- /dev/null +++ b/docs/framework/solid/reference/interfaces/MutationObserverSuccessResult.md @@ -0,0 +1,308 @@ +--- +id: MutationObserverSuccessResult +title: MutationObserverSuccessResult +--- + +Defined in: [packages/query-core/src/types.ts:1463](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1463) + +The raw state stored on a `Mutation` instance. This is the underlying state +that observer results (e.g. `MutationObserverResult`) are derived from. + +## Extends + +- [`MutationObserverBaseResult`](MutationObserverBaseResult.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\> + +## Type Parameters + +### TData + +`TData` = `unknown` + +### TError + +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) + +### TVariables + +`TVariables` = `void` + +### TOnMutateResult + +`TOnMutateResult` = `unknown` + +## Properties + +### context + +```ts +context: TOnMutateResult | undefined; +``` + +Defined in: [packages/query-core/src/mutation.ts:40](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L40) + +The value returned by `onMutate`, if defined. Passed to `onSuccess`, +`onError` and `onSettled` as the mutation's context. + +#### Inherited from + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`context`](MutationObserverBaseResult.md#context) + +*** + +### data + +```ts +data: TData; +``` + +Defined in: [packages/query-core/src/types.ts:1474](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1474) + +The last successfully resolved data for the mutation. + +#### Overrides + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`data`](MutationObserverBaseResult.md#data) + +*** + +### error + +```ts +error: null; +``` + +Defined in: [packages/query-core/src/types.ts:1475](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1475) + +The error object for the mutation, if an error was encountered. +- Defaults to `null`. + +#### Overrides + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`error`](MutationObserverBaseResult.md#error) + +*** + +### failureCount + +```ts +failureCount: number; +``` + +Defined in: [packages/query-core/src/mutation.ts:53](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L53) + +The number of times the mutation function has failed for the current attempt. + +#### Inherited from + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`failureCount`](MutationObserverBaseResult.md#failurecount) + +*** + +### failureReason + +```ts +failureReason: TError | null; +``` + +Defined in: [packages/query-core/src/mutation.ts:57](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L57) + +The reason the current attempt failed, as reported by the retryer. + +#### Inherited from + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`failureReason`](MutationObserverBaseResult.md#failurereason) + +*** + +### isError + +```ts +isError: false; +``` + +Defined in: [packages/query-core/src/types.ts:1477](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1477) + +A boolean variable derived from `status`. +- `true` if the last mutation attempt resulted in an error. + +#### Overrides + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isError`](MutationObserverBaseResult.md#iserror) + +*** + +### isIdle + +```ts +isIdle: false; +``` + +Defined in: [packages/query-core/src/types.ts:1478](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1478) + +A boolean variable derived from `status`. +- `true` if the mutation is in its initial state prior to executing. + +#### Overrides + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isIdle`](MutationObserverBaseResult.md#isidle) + +*** + +### isPaused + +```ts +isPaused: boolean; +``` + +Defined in: [packages/query-core/src/mutation.ts:62](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L62) + +Whether the mutation is currently paused (see network mode), or is +waiting for another mutation with the same `scope` to finish. + +#### Inherited from + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isPaused`](MutationObserverBaseResult.md#ispaused) + +*** + +### isPending + +```ts +isPending: false; +``` + +Defined in: [packages/query-core/src/types.ts:1479](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1479) + +A boolean variable derived from `status`. +- `true` if the mutation is currently executing. + +#### Overrides + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isPending`](MutationObserverBaseResult.md#ispending) + +*** + +### isSuccess + +```ts +isSuccess: true; +``` + +Defined in: [packages/query-core/src/types.ts:1480](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1480) + +A boolean variable derived from `status`. +- `true` if the last mutation attempt was successful. + +#### Overrides + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isSuccess`](MutationObserverBaseResult.md#issuccess) + +*** + +### mutate + +```ts +mutate: MutateFunction; +``` + +Defined in: [packages/query-core/src/types.ts:1393](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1393) + +The mutation function you can call with variables to trigger the mutation and optionally hooks on additional callback options. + +#### Param + +The variables object to pass to the `mutationFn`. + +#### Param + +This function will fire when the mutation is successful and will be passed the mutation's result. + +#### Param + +This function will fire if the mutation encounters an error and will be passed the error. + +#### Param + +This function will fire when the mutation is either successfully fetched or encounters an error and be passed either the data or error. + +#### Remarks + +- If you make multiple requests, `onSuccess` will fire only after the latest call you've made. +- All the callback functions (`onSuccess`, `onError`, `onSettled`) are void functions, and the returned value will be ignored. + +#### Inherited from + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`mutate`](MutationObserverBaseResult.md#mutate) + +*** + +### reset() + +```ts +reset: () => void; +``` + +Defined in: [packages/query-core/src/types.ts:1397](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1397) + +A function to clean the mutation internal state (i.e., it resets the mutation to its initial state). + +#### Returns + +`void` + +#### Inherited from + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`reset`](MutationObserverBaseResult.md#reset) + +*** + +### status + +```ts +status: "success"; +``` + +Defined in: [packages/query-core/src/types.ts:1481](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1481) + +The status of the mutation. +- Will be: + - `idle` initial status prior to the mutation function executing. + - `pending` if the mutation is currently executing. + - `error` if the last mutation attempt resulted in an error. + - `success` if the last mutation attempt was successful. + +#### Overrides + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`status`](MutationObserverBaseResult.md#status) + +*** + +### submittedAt + +```ts +submittedAt: number; +``` + +Defined in: [packages/query-core/src/mutation.ts:74](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L74) + +The timestamp for when the mutation was submitted. + +#### Inherited from + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`submittedAt`](MutationObserverBaseResult.md#submittedat) + +*** + +### variables + +```ts +variables: TVariables; +``` + +Defined in: [packages/query-core/src/types.ts:1476](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1476) + +The variables object passed to the `mutationFn`. + +#### Overrides + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`variables`](MutationObserverBaseResult.md#variables) diff --git a/docs/framework/solid/reference/interfaces/MutationOptions.md b/docs/framework/solid/reference/interfaces/MutationOptions.md index de6ae1a0fc3..cd5469e3df8 100644 --- a/docs/framework/solid/reference/interfaces/MutationOptions.md +++ b/docs/framework/solid/reference/interfaces/MutationOptions.md @@ -3,13 +3,13 @@ id: MutationOptions title: MutationOptions --- -Defined in: [types.ts:241](https://github.com/TanStack/query/blob/main/packages/solid-query/src/types.ts#L241) +Defined in: [packages/solid-query/src/types.ts:241](https://github.com/TanStack/query/blob/main/packages/solid-query/src/types.ts#L241) The options accepted by `useMutation` and `mutationOptions`. ## Extends -- `OmitKeyof`\<`MutationObserverOptions`\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\>, `"_defaulted"`\> +- [`OmitKeyof`](../type-aliases/OmitKeyof.md)\<[`MutationObserverOptions`](MutationObserverOptions.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\>, `"_defaulted"`\> ## Type Parameters @@ -21,7 +21,7 @@ The type your `mutationFn` resolves to. ### TError -`TError` = `DefaultError` +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) The type of errors your `mutationFn` may throw. @@ -36,3 +36,317 @@ The type of the variables your `mutationFn` accepts. `TOnMutateResult` = `unknown` The type returned by `onMutate`, passed on to `onSuccess`/`onError`/`onSettled`. + +## Properties + +### gcTime? + +```ts +optional gcTime: number; +``` + +Defined in: [packages/query-core/src/types.ts:1260](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1260) + +The time in milliseconds that an unused/inactive mutation remains in memory before it is +garbage collected. + +Defaults to `5 * 60 * 1000` (5 minutes), or `Infinity` during SSR. + +#### Inherited from + +[`MutationObserverOptions`](MutationObserverOptions.md).[`gcTime`](MutationObserverOptions.md#gctime) + +*** + +### meta? + +```ts +optional meta: Record; +``` + +Defined in: [packages/query-core/src/types.ts:1263](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1263) + +#### Inherited from + +[`MutationObserverOptions`](MutationObserverOptions.md).[`meta`](MutationObserverOptions.md#meta) + +*** + +### mutationFn? + +```ts +optional mutationFn: MutationFunction; +``` + +Defined in: [packages/query-core/src/types.ts:1206](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1206) + +#### Inherited from + +```ts +OmitKeyof.mutationFn +``` + +*** + +### mutationKey? + +```ts +optional mutationKey: readonly unknown[]; +``` + +Defined in: [packages/query-core/src/types.ts:1207](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1207) + +#### Inherited from + +[`MutationObserverOptions`](MutationObserverOptions.md).[`mutationKey`](MutationObserverOptions.md#mutationkey) + +*** + +### networkMode? + +```ts +optional networkMode: NetworkMode; +``` + +Defined in: [packages/query-core/src/types.ts:1253](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1253) + +Controls whether a mutation is allowed to run based on the current network connectivity. + +Defaults to `'online'`. + +#### See + +[Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. + +#### Inherited from + +[`MutationObserverOptions`](MutationObserverOptions.md).[`networkMode`](MutationObserverOptions.md#networkmode) + +*** + +### onError()? + +```ts +optional onError: (error, variables, onMutateResult, context) => unknown; +``` + +Defined in: [packages/query-core/src/types.ts:1218](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1218) + +#### Parameters + +##### error + +`TError` + +##### variables + +`TVariables` + +##### onMutateResult + +`TOnMutateResult` | `undefined` + +##### context + +[`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md) + +#### Returns + +`unknown` + +#### Inherited from + +```ts +OmitKeyof.onError +``` + +*** + +### onMutate()? + +```ts +optional onMutate: (variables, context) => TOnMutateResult | Promise; +``` + +Defined in: [packages/query-core/src/types.ts:1208](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1208) + +#### Parameters + +##### variables + +`TVariables` + +##### context + +[`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md) + +#### Returns + +`TOnMutateResult` \| `Promise`\<`TOnMutateResult`\> + +#### Inherited from + +```ts +OmitKeyof.onMutate +``` + +*** + +### onSettled()? + +```ts +optional onSettled: (data, error, variables, onMutateResult, context) => unknown; +``` + +Defined in: [packages/query-core/src/types.ts:1224](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1224) + +#### Parameters + +##### data + +`TData` | `undefined` + +##### error + +`TError` | `null` + +##### variables + +`TVariables` + +##### onMutateResult + +`TOnMutateResult` | `undefined` + +##### context + +[`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md) + +#### Returns + +`unknown` + +#### Inherited from + +```ts +OmitKeyof.onSettled +``` + +*** + +### onSuccess()? + +```ts +optional onSuccess: (data, variables, onMutateResult, context) => unknown; +``` + +Defined in: [packages/query-core/src/types.ts:1212](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1212) + +#### Parameters + +##### data + +`TData` + +##### variables + +`TVariables` + +##### onMutateResult + +`TOnMutateResult` + +##### context + +[`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md) + +#### Returns + +`unknown` + +#### Inherited from + +```ts +OmitKeyof.onSuccess +``` + +*** + +### retry? + +```ts +optional retry: RetryValue; +``` + +Defined in: [packages/query-core/src/types.ts:1239](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1239) + +If `false`, failed mutations will not retry by default. +If `true`, failed mutations will retry infinitely. +If set to an integer number, e.g. 3, failed mutations will retry until the failed mutation count meets that number. +If set to a function `(failureCount, error) => boolean` failed mutations will retry until the function returns false. + +Defaults to `0`. + +#### Inherited from + +```ts +OmitKeyof.retry +``` + +*** + +### retryDelay? + +```ts +optional retryDelay: RetryDelayValue; +``` + +Defined in: [packages/query-core/src/types.ts:1246](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1246) + +This function receives a `retryAttempt` integer and the actual Error and returns the delay to apply before the +next attempt in milliseconds. + +Defaults to a function that applies exponential backoff, capped at 30 seconds. + +#### Inherited from + +```ts +OmitKeyof.retryDelay +``` + +*** + +### scope? + +```ts +optional scope: MutationScope; +``` + +Defined in: [packages/query-core/src/types.ts:1264](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1264) + +#### Inherited from + +[`MutationObserverOptions`](MutationObserverOptions.md).[`scope`](MutationObserverOptions.md#scope) + +*** + +### throwOnError? + +```ts +optional throwOnError: boolean | (error) => boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1281](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1281) + +Whether errors should be thrown instead of setting the `error` property. +If set to `true`, all errors will be thrown to the nearest error boundary. +If set to a function, it will be passed the error and should return a boolean indicating whether to throw the +error (`true`) or return it as state (`false`). + +Defaults to `false`. + +#### Inherited from + +```ts +OmitKeyof.throwOnError +``` diff --git a/docs/framework/solid/reference/interfaces/MutationState.md b/docs/framework/solid/reference/interfaces/MutationState.md new file mode 100644 index 00000000000..bec050ec1d3 --- /dev/null +++ b/docs/framework/solid/reference/interfaces/MutationState.md @@ -0,0 +1,142 @@ +--- +id: MutationState +title: MutationState +--- + +Defined in: [packages/query-core/src/mutation.ts:30](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L30) + +The raw state stored on a `Mutation` instance. This is the underlying state +that observer results (e.g. `MutationObserverResult`) are derived from. + +## Extended by + +- [`MutationObserverBaseResult`](MutationObserverBaseResult.md) + +## Type Parameters + +### TData + +`TData` = `unknown` + +### TError + +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) + +### TVariables + +`TVariables` = `unknown` + +### TOnMutateResult + +`TOnMutateResult` = `unknown` + +## Properties + +### context + +```ts +context: TOnMutateResult | undefined; +``` + +Defined in: [packages/query-core/src/mutation.ts:40](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L40) + +The value returned by `onMutate`, if defined. Passed to `onSuccess`, +`onError` and `onSettled` as the mutation's context. + +*** + +### data + +```ts +data: TData | undefined; +``` + +Defined in: [packages/query-core/src/mutation.ts:44](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L44) + +The last successfully resolved data for the mutation. + +*** + +### error + +```ts +error: TError | null; +``` + +Defined in: [packages/query-core/src/mutation.ts:49](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L49) + +The error object for the mutation, if the last attempt resulted in an error. +- Defaults to `null`. + +*** + +### failureCount + +```ts +failureCount: number; +``` + +Defined in: [packages/query-core/src/mutation.ts:53](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L53) + +The number of times the mutation function has failed for the current attempt. + +*** + +### failureReason + +```ts +failureReason: TError | null; +``` + +Defined in: [packages/query-core/src/mutation.ts:57](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L57) + +The reason the current attempt failed, as reported by the retryer. + +*** + +### isPaused + +```ts +isPaused: boolean; +``` + +Defined in: [packages/query-core/src/mutation.ts:62](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L62) + +Whether the mutation is currently paused (see network mode), or is +waiting for another mutation with the same `scope` to finish. + +*** + +### status + +```ts +status: MutationStatus; +``` + +Defined in: [packages/query-core/src/mutation.ts:66](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L66) + +The status of the mutation. + +*** + +### submittedAt + +```ts +submittedAt: number; +``` + +Defined in: [packages/query-core/src/mutation.ts:74](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L74) + +The timestamp for when the mutation was submitted. + +*** + +### variables + +```ts +variables: TVariables | undefined; +``` + +Defined in: [packages/query-core/src/mutation.ts:70](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L70) + +The variables the mutation was last called with. diff --git a/docs/framework/solid/reference/interfaces/NotifyEvent.md b/docs/framework/solid/reference/interfaces/NotifyEvent.md new file mode 100644 index 00000000000..4f5b023f49a --- /dev/null +++ b/docs/framework/solid/reference/interfaces/NotifyEvent.md @@ -0,0 +1,16 @@ +--- +id: NotifyEvent +title: NotifyEvent +--- + +Defined in: [packages/query-core/src/types.ts:1539](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1539) + +## Properties + +### type + +```ts +type: NotifyEventType; +``` + +Defined in: [packages/query-core/src/types.ts:1540](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1540) diff --git a/docs/framework/solid/reference/interfaces/OnlineManager.md b/docs/framework/solid/reference/interfaces/OnlineManager.md new file mode 100644 index 00000000000..1a936c91ed9 --- /dev/null +++ b/docs/framework/solid/reference/interfaces/OnlineManager.md @@ -0,0 +1,214 @@ +--- +id: OnlineManager +title: OnlineManager +--- + +Defined in: [packages/query-core/src/onlineManager.ts:15](https://github.com/TanStack/query/blob/main/packages/query-core/src/onlineManager.ts#L15) + +The `OnlineManager` manages the online state within TanStack Query. It can +be used to change the default event listeners or to manually change the +online state. + +By default, the `onlineManager` assumes an active network connection, and +listens to the `online` and `offline` events on the `window` object to +detect changes. + +## Extends + +- `Subscribable`\<`Listener`\> + +## Properties + +### listeners + +```ts +protected listeners: Set; +``` + +Defined in: [packages/query-core/src/subscribable.ts:2](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L2) + +#### Inherited from + +```ts +Subscribable.listeners +``` + +## Methods + +### hasListeners() + +```ts +hasListeners(): boolean; +``` + +Defined in: [packages/query-core/src/subscribable.ts:19](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L19) + +#### Returns + +`boolean` + +#### Inherited from + +```ts +Subscribable.hasListeners +``` + +*** + +### isOnline() + +```ts +isOnline(): boolean; +``` + +Defined in: [packages/query-core/src/onlineManager.ts:109](https://github.com/TanStack/query/blob/main/packages/query-core/src/onlineManager.ts#L109) + +`isOnline` can be used to get the current online state. + +#### Returns + +`boolean` + +*** + +### onSubscribe() + +```ts +protected onSubscribe(): void; +``` + +Defined in: [packages/query-core/src/onlineManager.ts:44](https://github.com/TanStack/query/blob/main/packages/query-core/src/onlineManager.ts#L44) + +#### Returns + +`void` + +#### Overrides + +```ts +Subscribable.onSubscribe +``` + +*** + +### onUnsubscribe() + +```ts +protected onUnsubscribe(): void; +``` + +Defined in: [packages/query-core/src/onlineManager.ts:50](https://github.com/TanStack/query/blob/main/packages/query-core/src/onlineManager.ts#L50) + +#### Returns + +`void` + +#### Overrides + +```ts +Subscribable.onUnsubscribe +``` + +*** + +### setEventListener() + +```ts +setEventListener(setup): void; +``` + +Defined in: [packages/query-core/src/onlineManager.ts:75](https://github.com/TanStack/query/blob/main/packages/query-core/src/onlineManager.ts#L75) + +`setEventListener` can be used to set a custom event listener that will +be used to determine the online state. The provided `setup` function +receives a `setOnline` callback that should be called with a `boolean` +whenever the online state changes. + +#### Parameters + +##### setup + +`SetupFn` + +#### Returns + +`void` + +#### Example + +```ts +import NetInfo from '@react-native-community/netinfo' +import { onlineManager } from '@tanstack/query-core' + +onlineManager.setEventListener((setOnline) => { + return NetInfo.addEventListener((state) => { + setOnline(!!state.isConnected) + }) +}) +``` + +*** + +### setOnline() + +```ts +setOnline(online): void; +``` + +Defined in: [packages/query-core/src/onlineManager.ts:95](https://github.com/TanStack/query/blob/main/packages/query-core/src/onlineManager.ts#L95) + +`setOnline` can be used to manually set the online state. + +#### Parameters + +##### online + +`boolean` + +#### Returns + +`void` + +#### Example + +```ts +import { onlineManager } from '@tanstack/query-core' + +// Set to online +onlineManager.setOnline(true) + +// Set to offline +onlineManager.setOnline(false) +``` + +*** + +### subscribe() + +```ts +subscribe(listener): () => void; +``` + +Defined in: [packages/query-core/src/subscribable.ts:8](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L8) + +#### Parameters + +##### listener + +`Listener` + +#### Returns + +```ts +(): void; +``` + +##### Returns + +`void` + +#### Inherited from + +```ts +Subscribable.subscribe +``` diff --git a/docs/framework/solid/reference/interfaces/QueriesObserverOptions.md b/docs/framework/solid/reference/interfaces/QueriesObserverOptions.md new file mode 100644 index 00000000000..68e7913885d --- /dev/null +++ b/docs/framework/solid/reference/interfaces/QueriesObserverOptions.md @@ -0,0 +1,29 @@ +--- +id: QueriesObserverOptions +title: QueriesObserverOptions +--- + +Defined in: [packages/query-core/src/queriesObserver.ts:23](https://github.com/TanStack/query/blob/main/packages/query-core/src/queriesObserver.ts#L23) + +## Type Parameters + +### TCombinedResult + +`TCombinedResult` = [`QueryObserverResult`](../type-aliases/QueryObserverResult.md)[] + +## Properties + +### combine? + +```ts +optional combine: CombineFn; +``` + +Defined in: [packages/query-core/src/queriesObserver.ts:34](https://github.com/TanStack/query/blob/main/packages/query-core/src/queriesObserver.ts#L34) + +A function that combines the array of `QueryObserverResult`s (one per +observed query) into a single value. The combined value is memoized and +only recomputed when one of the underlying results, the query hashes, or +the `combine` function itself changes. + +Defaults to returning the array of `QueryObserverResult`s unchanged. diff --git a/docs/framework/solid/reference/interfaces/QueryCacheConfig.md b/docs/framework/solid/reference/interfaces/QueryCacheConfig.md new file mode 100644 index 00000000000..3c6aebe496f --- /dev/null +++ b/docs/framework/solid/reference/interfaces/QueryCacheConfig.md @@ -0,0 +1,93 @@ +--- +id: QueryCacheConfig +title: QueryCacheConfig +--- + +Defined in: [packages/query-core/src/queryCache.ts:25](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryCache.ts#L25) + +Global callbacks that fire for every query handled by a `QueryCache`, regardless of which +component or observer triggered it. Unlike `QueryClient`'s `defaultOptions`, which a query can +override, these callbacks are always called. Unlike `MutationCacheConfig`'s callbacks, these +are fire-and-forget: their return value is not awaited before the query settles. + +## Properties + +### onError()? + +```ts +optional onError: (error, query) => void; +``` + +Defined in: [packages/query-core/src/queryCache.ts:27](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryCache.ts#L27) + +Called when any query in the cache encounters an error. + +#### Parameters + +##### error + +`Error` + +##### query + +[`Query`](../classes/Query.md)\<`unknown`, `unknown`, `unknown`\> + +#### Returns + +`void` + +*** + +### onSettled()? + +```ts +optional onSettled: (data, error, query) => void; +``` + +Defined in: [packages/query-core/src/queryCache.ts:34](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryCache.ts#L34) + +Called when any query in the cache is settled, either successfully or with an error. + +#### Parameters + +##### data + +`unknown` + +##### error + +`Error` | `null` + +##### query + +[`Query`](../classes/Query.md)\<`unknown`, `unknown`, `unknown`\> + +#### Returns + +`void` + +*** + +### onSuccess()? + +```ts +optional onSuccess: (data, query) => void; +``` + +Defined in: [packages/query-core/src/queryCache.ts:32](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryCache.ts#L32) + +Called when any query in the cache is successful. + +#### Parameters + +##### data + +`unknown` + +##### query + +[`Query`](../classes/Query.md)\<`unknown`, `unknown`, `unknown`\> + +#### Returns + +`void` diff --git a/docs/framework/solid/reference/interfaces/QueryClientConfig.md b/docs/framework/solid/reference/interfaces/QueryClientConfig.md index f5843d70667..909b68c943c 100644 --- a/docs/framework/solid/reference/interfaces/QueryClientConfig.md +++ b/docs/framework/solid/reference/interfaces/QueryClientConfig.md @@ -3,7 +3,7 @@ id: QueryClientConfig title: QueryClientConfig --- -Defined in: [QueryClient.ts:105](https://github.com/TanStack/query/blob/main/packages/solid-query/src/QueryClient.ts#L105) +Defined in: [packages/solid-query/src/QueryClient.ts:105](https://github.com/TanStack/query/blob/main/packages/solid-query/src/QueryClient.ts#L105) The config accepted by `new QueryClient(config)`, with Solid's extended [DefaultOptions](DefaultOptions.md). @@ -19,10 +19,49 @@ The config accepted by `new QueryClient(config)`, with Solid's extended [Default optional defaultOptions: DefaultOptions; ``` -Defined in: [QueryClient.ts:106](https://github.com/TanStack/query/blob/main/packages/solid-query/src/QueryClient.ts#L106) +Defined in: [packages/solid-query/src/QueryClient.ts:106](https://github.com/TanStack/query/blob/main/packages/solid-query/src/QueryClient.ts#L106) + +Default options for all queries and mutations created through this client. #### Overrides ```ts QueryCoreClientConfig.defaultOptions ``` + +*** + +### mutationCache? + +```ts +optional mutationCache: MutationCache; +``` + +Defined in: [packages/query-core/src/types.ts:1502](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1502) + +The mutation cache this client is connected to. A new `MutationCache` is created if not +provided. + +#### Inherited from + +```ts +QueryCoreClientConfig.mutationCache +``` + +*** + +### queryCache? + +```ts +optional queryCache: QueryCache; +``` + +Defined in: [packages/query-core/src/types.ts:1497](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1497) + +The query cache this client is connected to. A new `QueryCache` is created if not provided. + +#### Inherited from + +```ts +QueryCoreClientConfig.queryCache +``` diff --git a/docs/framework/solid/reference/interfaces/QueryExecuteOptions.md b/docs/framework/solid/reference/interfaces/QueryExecuteOptions.md new file mode 100644 index 00000000000..b16474c4999 --- /dev/null +++ b/docs/framework/solid/reference/interfaces/QueryExecuteOptions.md @@ -0,0 +1,382 @@ +--- +id: QueryExecuteOptions +title: QueryExecuteOptions +--- + +Defined in: [packages/query-core/src/types.ts:574](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L574) + +## Extends + +- [`WithRequired`](../type-aliases/WithRequired.md)\<`QueryOptions`\<`TQueryFnData`, `TError`, `TQueryData`, `TQueryKey`, `TPageParam`\>, `"queryKey"`\> + +## Type Parameters + +### TQueryFnData + +`TQueryFnData` = `unknown` + +### TError + +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) + +### TData + +`TData` = `TQueryFnData` + +### TQueryData + +`TQueryData` = `TQueryFnData` + +### TQueryKey + +`TQueryKey` *extends* [`QueryKey`](../type-aliases/QueryKey.md) = [`QueryKey`](../type-aliases/QueryKey.md) + +### TPageParam + +`TPageParam` = `never` + +## Properties + +### gcTime? + +```ts +optional gcTime: number; +``` + +Defined in: [packages/query-core/src/types.ts:277](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L277) + +The time in milliseconds that unused/inactive cache data remains in memory. +When a query's cache becomes unused or inactive, that cache data will be garbage collected after this duration. +When different garbage collection times are specified, the longest one will be used. +Setting it to `Infinity` will disable garbage collection. + +Defaults to `5 * 60 * 1000` (5 minutes), or `Infinity` during SSR. + +Note: the maximum allowed time is about 24 days, imposed by `setTimeout`'s 32-bit signed integer delay — see +`timeoutManager.setTimeoutProvider` for a workaround. + +#### Inherited from + +```ts +WithRequired.gcTime +``` + +*** + +### initialData? + +```ts +optional initialData: + | TQueryData +| InitialDataFunction; +``` + +Defined in: [packages/query-core/src/types.ts:317](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L317) + +If set, this value will be used as the initial data for the query cache (as long as the query hasn't been +created or cached yet). +If set to a function, the function will be called **once** during the shared/root query initialization, and be +expected to synchronously return the initial data. +Initial data is considered stale by default unless a `staleTime` has been set. +`initialData` **is persisted** to the cache. + +#### Inherited from + +```ts +WithRequired.initialData +``` + +*** + +### initialDataUpdatedAt? + +```ts +optional initialDataUpdatedAt: number | () => number | undefined; +``` + +Defined in: [packages/query-core/src/types.ts:321](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L321) + +If set, this value will be used as the time (in milliseconds) of when the `initialData` itself was last updated. + +#### Inherited from + +```ts +WithRequired.initialDataUpdatedAt +``` + +*** + +### initialPageParam? + +```ts +optional initialPageParam: undefined; +``` + +Defined in: [packages/query-core/src/types.ts:585](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L585) + +*** + +### maxPages? + +```ts +optional maxPages: number; +``` + +Defined in: [packages/query-core/src/types.ts:345](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L345) + +Maximum number of pages to store in the data of an infinite query. + +#### Inherited from + +```ts +WithRequired.maxPages +``` + +*** + +### meta? + +```ts +optional meta: Record; +``` + +Defined in: [packages/query-core/src/types.ts:341](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L341) + +Additional payload to be stored on each query. +Use this property to pass information that can be used in other places. + +#### Inherited from + +```ts +WithRequired.meta +``` + +*** + +### networkMode? + +```ts +optional networkMode: NetworkMode; +``` + +Defined in: [packages/query-core/src/types.ts:265](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L265) + +Controls whether a query is allowed to run based on the current network connectivity. + +Defaults to `'online'`. + +#### See + +[Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. + +#### Inherited from + +```ts +WithRequired.networkMode +``` + +*** + +### persister? + +```ts +optional persister: QueryPersister, TPageParam>; +``` + +Defined in: [packages/query-core/src/types.ts:290](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L290) + +This option can be used to persist the result of a query to an external storage, bypassing the need to actually +call the `queryFn`. Useful for persisting a query's data across e.g. server/client boundaries. + +#### Inherited from + +```ts +WithRequired.persister +``` + +*** + +### queryFn? + +```ts +optional queryFn: + | typeof skipToken +| QueryFunction; +``` + +Defined in: [packages/query-core/src/types.ts:285](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L285) + +The function that the query will use to request data. +Required, unless a default query function has been set via `queryClient.setQueryDefaults` or +`queryClient.setDefaultOptions`. +Receives a [QueryFunctionContext](../type-aliases/QueryFunctionContext.md). +Must return a promise that will either resolve data or throw an error. The data cannot be `undefined`. + +#### Inherited from + +```ts +WithRequired.queryFn +``` + +*** + +### queryHash? + +```ts +optional queryHash: string; +``` + +Defined in: [packages/query-core/src/types.ts:295](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L295) + +The hashed form of `queryKey`, computed with `queryKeyHashFn` (or the default hashing function otherwise). Used +as the actual cache key internally. + +#### Inherited from + +```ts +WithRequired.queryHash +``` + +*** + +### queryKey + +```ts +queryKey: TQueryKey & object; +``` + +Defined in: [packages/query-core/src/types.ts:304](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L304) + +The query key to use for this query. + +The query key will be hashed into a stable hash. See [Query Keys](https://tanstack.com/query/latest/docs/framework/react/guides/query-keys) +for more information. + +The query will automatically update when this key changes (as long as `enabled` is not set to `false`). + +#### Inherited from + +```ts +WithRequired.queryKey +``` + +*** + +### queryKeyHashFn? + +```ts +optional queryKeyHashFn: QueryKeyHashFunction; +``` + +Defined in: [packages/query-core/src/types.ts:308](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L308) + +If specified, this function is used to hash the `queryKey` to a string. + +#### Inherited from + +```ts +WithRequired.queryKeyHashFn +``` + +*** + +### retry? + +```ts +optional retry: RetryValue; +``` + +Defined in: [packages/query-core/src/types.ts:246](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L246) + +If `false`, failed queries will not retry by default. +If `true`, failed queries will retry infinitely. +If set to an integer number, e.g. 3, failed queries will retry until the failed query count meets that number. +If set to a function `(failureCount, error) => boolean` failed queries will retry until the function returns false. + +Defaults to `3` on the client and `0` on the server. + +#### Inherited from + +```ts +WithRequired.retry +``` + +*** + +### retryDelay? + +```ts +optional retryDelay: RetryDelayValue; +``` + +Defined in: [packages/query-core/src/types.ts:258](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L258) + +This function receives a `retryAttempt` integer and the actual Error and returns the delay to apply before the +next attempt in milliseconds. + +A function like `attempt => Math.min(attempt > 1 ? 2 ** attempt * 1000 : 1000, 30 * 1000)` applies exponential +backoff. + +A function like `attempt => attempt * 1000` applies linear backoff. + +Defaults to a function that applies exponential backoff, capped at 30 seconds. + +#### Inherited from + +```ts +WithRequired.retryDelay +``` + +*** + +### select()? + +```ts +optional select: (data) => TData; +``` + +Defined in: [packages/query-core/src/types.ts:586](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L586) + +#### Parameters + +##### data + +`TQueryData` + +#### Returns + +`TData` + +*** + +### staleTime? + +```ts +optional staleTime: StaleTimeFunction; +``` + +Defined in: [packages/query-core/src/types.ts:591](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L591) + +The time in milliseconds after data is considered stale. +If the data is fresh it will be returned from the cache. + +*** + +### structuralSharing? + +```ts +optional structuralSharing: boolean | (oldData, newData) => unknown; +``` + +Defined in: [packages/query-core/src/types.ts:330](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L330) + +Set this to `false` to disable structural sharing between query results. +Set this to a function which accepts the old and new data and returns resolved data of the same type to implement custom structural sharing logic. + +Defaults to `true`. + +#### Inherited from + +```ts +WithRequired.structuralSharing +``` diff --git a/docs/framework/solid/reference/interfaces/QueryFilters.md b/docs/framework/solid/reference/interfaces/QueryFilters.md new file mode 100644 index 00000000000..749e4283d0d --- /dev/null +++ b/docs/framework/solid/reference/interfaces/QueryFilters.md @@ -0,0 +1,104 @@ +--- +id: QueryFilters +title: QueryFilters +--- + +Defined in: [packages/query-core/src/utils.ts:31](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L31) + +Filters used to select queries, for example in `queryClient.getQueriesData` or `queryClient.invalidateQueries`. +All provided filters must match; filters that are left unspecified are ignored. + +## Extended by + +- [`InvalidateQueryFilters`](InvalidateQueryFilters.md) +- [`RefetchQueryFilters`](RefetchQueryFilters.md) + +## Type Parameters + +### TQueryKey + +`TQueryKey` *extends* [`QueryKey`](../type-aliases/QueryKey.md) = [`QueryKey`](../type-aliases/QueryKey.md) + +## Properties + +### exact? + +```ts +optional exact: boolean; +``` + +Defined in: [packages/query-core/src/utils.ts:41](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L41) + +Match query key exactly + +*** + +### fetchStatus? + +```ts +optional fetchStatus: FetchStatus; +``` + +Defined in: [packages/query-core/src/utils.ts:57](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L57) + +Include queries matching their fetchStatus + +*** + +### predicate()? + +```ts +optional predicate: (query) => boolean; +``` + +Defined in: [packages/query-core/src/utils.ts:45](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L45) + +Include queries matching this predicate function + +#### Parameters + +##### query + +[`Query`](../classes/Query.md) + +#### Returns + +`boolean` + +*** + +### queryKey? + +```ts +optional queryKey: TQueryKey | TuplePrefixes; +``` + +Defined in: [packages/query-core/src/utils.ts:49](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L49) + +Include queries matching this query key + +*** + +### stale? + +```ts +optional stale: boolean; +``` + +Defined in: [packages/query-core/src/utils.ts:53](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L53) + +Include or exclude stale queries + +*** + +### type? + +```ts +optional type: QueryTypeFilter; +``` + +Defined in: [packages/query-core/src/utils.ts:37](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L37) + +Filter to active queries, inactive queries or all queries + +Defaults to `'all'`. diff --git a/docs/framework/solid/reference/interfaces/QueryObserverBaseResult.md b/docs/framework/solid/reference/interfaces/QueryObserverBaseResult.md new file mode 100644 index 00000000000..ef5fe0ad757 --- /dev/null +++ b/docs/framework/solid/reference/interfaces/QueryObserverBaseResult.md @@ -0,0 +1,358 @@ +--- +id: QueryObserverBaseResult +title: QueryObserverBaseResult +--- + +Defined in: [packages/query-core/src/types.ts:764](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L764) + +## Extended by + +- [`QueryObserverPendingResult`](QueryObserverPendingResult.md) +- [`QueryObserverLoadingResult`](QueryObserverLoadingResult.md) +- [`QueryObserverLoadingErrorResult`](QueryObserverLoadingErrorResult.md) +- [`QueryObserverRefetchErrorResult`](QueryObserverRefetchErrorResult.md) +- [`QueryObserverSuccessResult`](QueryObserverSuccessResult.md) +- [`QueryObserverPlaceholderResult`](QueryObserverPlaceholderResult.md) +- [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md) + +## Type Parameters + +### TData + +`TData` = `unknown` + +### TError + +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) + +## Properties + +### data + +```ts +data: TData | undefined; +``` + +Defined in: [packages/query-core/src/types.ts:771](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L771) + +The last successfully resolved data for the query. + +*** + +### dataUpdatedAt + +```ts +dataUpdatedAt: number; +``` + +Defined in: [packages/query-core/src/types.ts:775](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L775) + +The timestamp for when the query most recently returned the `status` as `"success"`. + +*** + +### error + +```ts +error: TError | null; +``` + +Defined in: [packages/query-core/src/types.ts:780](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L780) + +The error object for the query, if an error was thrown. +- Defaults to `null`. + +*** + +### errorUpdateCount + +```ts +errorUpdateCount: number; +``` + +Defined in: [packages/query-core/src/types.ts:799](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L799) + +The sum of all errors. + +*** + +### errorUpdatedAt + +```ts +errorUpdatedAt: number; +``` + +Defined in: [packages/query-core/src/types.ts:784](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L784) + +The timestamp for when the query most recently returned the `status` as `"error"`. + +*** + +### failureCount + +```ts +failureCount: number; +``` + +Defined in: [packages/query-core/src/types.ts:790](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L790) + +The failure count for the query. +- Incremented every time the query fails. +- Reset to `0` when the query succeeds. + +*** + +### failureReason + +```ts +failureReason: TError | null; +``` + +Defined in: [packages/query-core/src/types.ts:795](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L795) + +The failure reason for the query retry. +- Reset to `null` when the query succeeds. + +*** + +### fetchStatus + +```ts +fetchStatus: FetchStatus; +``` + +Defined in: [packages/query-core/src/types.ts:889](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L889) + +The fetch status of the query. +- `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. +- `paused`: The query wanted to fetch, but has been `paused`. +- `idle`: The query is not fetching. +- See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. + +*** + +### isEnabled + +```ts +isEnabled: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:867](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L867) + +`true` if this observer is enabled, `false` otherwise. + +*** + +### isError + +```ts +isError: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:804](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L804) + +A derived boolean from the `status` variable, provided for convenience. +- `true` if the query attempt resulted in an error. + +*** + +### isFetched + +```ts +isFetched: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:808](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L808) + +Will be `true` if the query has been fetched. + +*** + +### isFetchedAfterMount + +```ts +isFetchedAfterMount: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:813](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L813) + +Will be `true` if the query has been fetched after the component mounted. +- This property can be used to not show any previously cached data. + +*** + +### isFetching + +```ts +isFetching: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:818](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L818) + +A derived boolean from the `fetchStatus` variable, provided for convenience. +- `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. + +*** + +### ~~isInitialLoading~~ + +```ts +isInitialLoading: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:836](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L836) + +#### Deprecated + +`isInitialLoading` is being deprecated in favor of `isLoading` +and will be removed in the next major version. + +*** + +### isLoading + +```ts +isLoading: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:823](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L823) + +Is `true` whenever the first fetch for a query is in-flight. +- Is the same as `isFetching && isPending`. + +*** + +### isLoadingError + +```ts +isLoadingError: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:831](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L831) + +Will be `true` if the query failed while fetching for the first time. + +*** + +### isPaused + +```ts +isPaused: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:841](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L841) + +A derived boolean from the `fetchStatus` variable, provided for convenience. +- The query wanted to fetch, but has been `paused`. + +*** + +### isPending + +```ts +isPending: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:827](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L827) + +Will be `pending` if there's no cached data and no query attempt was finished yet. + +*** + +### isPlaceholderData + +```ts +isPlaceholderData: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:845](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L845) + +Will be `true` if the data shown is the placeholder data. + +*** + +### isRefetchError + +```ts +isRefetchError: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:849](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L849) + +Will be `true` if the query failed while refetching. + +*** + +### isRefetching + +```ts +isRefetching: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:854](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L854) + +Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. +- Is the same as `isFetching && !isPending`. + +*** + +### isStale + +```ts +isStale: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:858](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L858) + +Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. + +*** + +### isSuccess + +```ts +isSuccess: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:863](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L863) + +A derived boolean from the `status` variable, provided for convenience. +- `true` if the query has received a response with no errors and is ready to display its data. + +*** + +### refetch() + +```ts +refetch: (options?) => Promise>; +``` + +Defined in: [packages/query-core/src/types.ts:871](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L871) + +A function to manually refetch the query. + +#### Parameters + +##### options? + +[`RefetchOptions`](RefetchOptions.md) + +#### Returns + +`Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> + +*** + +### status + +```ts +status: QueryStatus; +``` + +Defined in: [packages/query-core/src/types.ts:881](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L881) + +The status of the query. +- Will be: + - `pending` if there's no cached data and no query attempt was finished yet. + - `error` if the query attempt resulted in an error. + - `success` if the query has received a response with no errors and is ready to display its data. diff --git a/docs/framework/solid/reference/interfaces/QueryObserverLoadingErrorResult.md b/docs/framework/solid/reference/interfaces/QueryObserverLoadingErrorResult.md new file mode 100644 index 00000000000..21b39fbffe3 --- /dev/null +++ b/docs/framework/solid/reference/interfaces/QueryObserverLoadingErrorResult.md @@ -0,0 +1,452 @@ +--- +id: QueryObserverLoadingErrorResult +title: QueryObserverLoadingErrorResult +--- + +Defined in: [packages/query-core/src/types.ts:923](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L923) + +## Extends + +- [`QueryObserverBaseResult`](QueryObserverBaseResult.md)\<`TData`, `TError`\> + +## Type Parameters + +### TData + +`TData` = `unknown` + +### TError + +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) + +## Properties + +### data + +```ts +data: undefined; +``` + +Defined in: [packages/query-core/src/types.ts:927](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L927) + +The last successfully resolved data for the query. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`data`](QueryObserverBaseResult.md#data) + +*** + +### dataUpdatedAt + +```ts +dataUpdatedAt: number; +``` + +Defined in: [packages/query-core/src/types.ts:775](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L775) + +The timestamp for when the query most recently returned the `status` as `"success"`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`dataUpdatedAt`](QueryObserverBaseResult.md#dataupdatedat) + +*** + +### error + +```ts +error: TError; +``` + +Defined in: [packages/query-core/src/types.ts:928](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L928) + +The error object for the query, if an error was thrown. +- Defaults to `null`. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`error`](QueryObserverBaseResult.md#error) + +*** + +### errorUpdateCount + +```ts +errorUpdateCount: number; +``` + +Defined in: [packages/query-core/src/types.ts:799](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L799) + +The sum of all errors. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`errorUpdateCount`](QueryObserverBaseResult.md#errorupdatecount) + +*** + +### errorUpdatedAt + +```ts +errorUpdatedAt: number; +``` + +Defined in: [packages/query-core/src/types.ts:784](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L784) + +The timestamp for when the query most recently returned the `status` as `"error"`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`errorUpdatedAt`](QueryObserverBaseResult.md#errorupdatedat) + +*** + +### failureCount + +```ts +failureCount: number; +``` + +Defined in: [packages/query-core/src/types.ts:790](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L790) + +The failure count for the query. +- Incremented every time the query fails. +- Reset to `0` when the query succeeds. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`failureCount`](QueryObserverBaseResult.md#failurecount) + +*** + +### failureReason + +```ts +failureReason: TError | null; +``` + +Defined in: [packages/query-core/src/types.ts:795](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L795) + +The failure reason for the query retry. +- Reset to `null` when the query succeeds. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`failureReason`](QueryObserverBaseResult.md#failurereason) + +*** + +### fetchStatus + +```ts +fetchStatus: FetchStatus; +``` + +Defined in: [packages/query-core/src/types.ts:889](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L889) + +The fetch status of the query. +- `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. +- `paused`: The query wanted to fetch, but has been `paused`. +- `idle`: The query is not fetching. +- See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`fetchStatus`](QueryObserverBaseResult.md#fetchstatus) + +*** + +### isEnabled + +```ts +isEnabled: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:867](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L867) + +`true` if this observer is enabled, `false` otherwise. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isEnabled`](QueryObserverBaseResult.md#isenabled) + +*** + +### isError + +```ts +isError: true; +``` + +Defined in: [packages/query-core/src/types.ts:929](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L929) + +A derived boolean from the `status` variable, provided for convenience. +- `true` if the query attempt resulted in an error. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isError`](QueryObserverBaseResult.md#iserror) + +*** + +### isFetched + +```ts +isFetched: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:808](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L808) + +Will be `true` if the query has been fetched. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isFetched`](QueryObserverBaseResult.md#isfetched) + +*** + +### isFetchedAfterMount + +```ts +isFetchedAfterMount: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:813](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L813) + +Will be `true` if the query has been fetched after the component mounted. +- This property can be used to not show any previously cached data. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isFetchedAfterMount`](QueryObserverBaseResult.md#isfetchedaftermount) + +*** + +### isFetching + +```ts +isFetching: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:818](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L818) + +A derived boolean from the `fetchStatus` variable, provided for convenience. +- `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isFetching`](QueryObserverBaseResult.md#isfetching) + +*** + +### ~~isInitialLoading~~ + +```ts +isInitialLoading: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:836](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L836) + +#### Deprecated + +`isInitialLoading` is being deprecated in favor of `isLoading` +and will be removed in the next major version. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isInitialLoading`](QueryObserverBaseResult.md#isinitialloading) + +*** + +### isLoading + +```ts +isLoading: false; +``` + +Defined in: [packages/query-core/src/types.ts:931](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L931) + +Is `true` whenever the first fetch for a query is in-flight. +- Is the same as `isFetching && isPending`. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoading`](QueryObserverBaseResult.md#isloading) + +*** + +### isLoadingError + +```ts +isLoadingError: true; +``` + +Defined in: [packages/query-core/src/types.ts:932](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L932) + +Will be `true` if the query failed while fetching for the first time. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoadingError`](QueryObserverBaseResult.md#isloadingerror) + +*** + +### isPaused + +```ts +isPaused: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:841](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L841) + +A derived boolean from the `fetchStatus` variable, provided for convenience. +- The query wanted to fetch, but has been `paused`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPaused`](QueryObserverBaseResult.md#ispaused) + +*** + +### isPending + +```ts +isPending: false; +``` + +Defined in: [packages/query-core/src/types.ts:930](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L930) + +Will be `pending` if there's no cached data and no query attempt was finished yet. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPending`](QueryObserverBaseResult.md#ispending) + +*** + +### isPlaceholderData + +```ts +isPlaceholderData: false; +``` + +Defined in: [packages/query-core/src/types.ts:935](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L935) + +Will be `true` if the data shown is the placeholder data. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPlaceholderData`](QueryObserverBaseResult.md#isplaceholderdata) + +*** + +### isRefetchError + +```ts +isRefetchError: false; +``` + +Defined in: [packages/query-core/src/types.ts:933](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L933) + +Will be `true` if the query failed while refetching. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetchError`](QueryObserverBaseResult.md#isrefetcherror) + +*** + +### isRefetching + +```ts +isRefetching: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:854](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L854) + +Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. +- Is the same as `isFetching && !isPending`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetching`](QueryObserverBaseResult.md#isrefetching) + +*** + +### isStale + +```ts +isStale: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:858](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L858) + +Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isStale`](QueryObserverBaseResult.md#isstale) + +*** + +### isSuccess + +```ts +isSuccess: false; +``` + +Defined in: [packages/query-core/src/types.ts:934](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L934) + +A derived boolean from the `status` variable, provided for convenience. +- `true` if the query has received a response with no errors and is ready to display its data. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isSuccess`](QueryObserverBaseResult.md#issuccess) + +*** + +### refetch() + +```ts +refetch: (options?) => Promise>; +``` + +Defined in: [packages/query-core/src/types.ts:871](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L871) + +A function to manually refetch the query. + +#### Parameters + +##### options? + +[`RefetchOptions`](RefetchOptions.md) + +#### Returns + +`Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`refetch`](QueryObserverBaseResult.md#refetch) + +*** + +### status + +```ts +status: "error"; +``` + +Defined in: [packages/query-core/src/types.ts:936](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L936) + +The status of the query. +- Will be: + - `pending` if there's no cached data and no query attempt was finished yet. + - `error` if the query attempt resulted in an error. + - `success` if the query has received a response with no errors and is ready to display its data. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`status`](QueryObserverBaseResult.md#status) diff --git a/docs/framework/solid/reference/interfaces/QueryObserverLoadingResult.md b/docs/framework/solid/reference/interfaces/QueryObserverLoadingResult.md new file mode 100644 index 00000000000..4966390127f --- /dev/null +++ b/docs/framework/solid/reference/interfaces/QueryObserverLoadingResult.md @@ -0,0 +1,452 @@ +--- +id: QueryObserverLoadingResult +title: QueryObserverLoadingResult +--- + +Defined in: [packages/query-core/src/types.ts:907](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L907) + +## Extends + +- [`QueryObserverBaseResult`](QueryObserverBaseResult.md)\<`TData`, `TError`\> + +## Type Parameters + +### TData + +`TData` = `unknown` + +### TError + +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) + +## Properties + +### data + +```ts +data: undefined; +``` + +Defined in: [packages/query-core/src/types.ts:911](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L911) + +The last successfully resolved data for the query. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`data`](QueryObserverBaseResult.md#data) + +*** + +### dataUpdatedAt + +```ts +dataUpdatedAt: number; +``` + +Defined in: [packages/query-core/src/types.ts:775](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L775) + +The timestamp for when the query most recently returned the `status` as `"success"`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`dataUpdatedAt`](QueryObserverBaseResult.md#dataupdatedat) + +*** + +### error + +```ts +error: null; +``` + +Defined in: [packages/query-core/src/types.ts:912](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L912) + +The error object for the query, if an error was thrown. +- Defaults to `null`. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`error`](QueryObserverBaseResult.md#error) + +*** + +### errorUpdateCount + +```ts +errorUpdateCount: number; +``` + +Defined in: [packages/query-core/src/types.ts:799](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L799) + +The sum of all errors. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`errorUpdateCount`](QueryObserverBaseResult.md#errorupdatecount) + +*** + +### errorUpdatedAt + +```ts +errorUpdatedAt: number; +``` + +Defined in: [packages/query-core/src/types.ts:784](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L784) + +The timestamp for when the query most recently returned the `status` as `"error"`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`errorUpdatedAt`](QueryObserverBaseResult.md#errorupdatedat) + +*** + +### failureCount + +```ts +failureCount: number; +``` + +Defined in: [packages/query-core/src/types.ts:790](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L790) + +The failure count for the query. +- Incremented every time the query fails. +- Reset to `0` when the query succeeds. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`failureCount`](QueryObserverBaseResult.md#failurecount) + +*** + +### failureReason + +```ts +failureReason: TError | null; +``` + +Defined in: [packages/query-core/src/types.ts:795](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L795) + +The failure reason for the query retry. +- Reset to `null` when the query succeeds. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`failureReason`](QueryObserverBaseResult.md#failurereason) + +*** + +### fetchStatus + +```ts +fetchStatus: FetchStatus; +``` + +Defined in: [packages/query-core/src/types.ts:889](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L889) + +The fetch status of the query. +- `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. +- `paused`: The query wanted to fetch, but has been `paused`. +- `idle`: The query is not fetching. +- See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`fetchStatus`](QueryObserverBaseResult.md#fetchstatus) + +*** + +### isEnabled + +```ts +isEnabled: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:867](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L867) + +`true` if this observer is enabled, `false` otherwise. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isEnabled`](QueryObserverBaseResult.md#isenabled) + +*** + +### isError + +```ts +isError: false; +``` + +Defined in: [packages/query-core/src/types.ts:913](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L913) + +A derived boolean from the `status` variable, provided for convenience. +- `true` if the query attempt resulted in an error. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isError`](QueryObserverBaseResult.md#iserror) + +*** + +### isFetched + +```ts +isFetched: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:808](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L808) + +Will be `true` if the query has been fetched. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isFetched`](QueryObserverBaseResult.md#isfetched) + +*** + +### isFetchedAfterMount + +```ts +isFetchedAfterMount: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:813](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L813) + +Will be `true` if the query has been fetched after the component mounted. +- This property can be used to not show any previously cached data. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isFetchedAfterMount`](QueryObserverBaseResult.md#isfetchedaftermount) + +*** + +### isFetching + +```ts +isFetching: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:818](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L818) + +A derived boolean from the `fetchStatus` variable, provided for convenience. +- `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isFetching`](QueryObserverBaseResult.md#isfetching) + +*** + +### ~~isInitialLoading~~ + +```ts +isInitialLoading: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:836](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L836) + +#### Deprecated + +`isInitialLoading` is being deprecated in favor of `isLoading` +and will be removed in the next major version. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isInitialLoading`](QueryObserverBaseResult.md#isinitialloading) + +*** + +### isLoading + +```ts +isLoading: true; +``` + +Defined in: [packages/query-core/src/types.ts:915](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L915) + +Is `true` whenever the first fetch for a query is in-flight. +- Is the same as `isFetching && isPending`. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoading`](QueryObserverBaseResult.md#isloading) + +*** + +### isLoadingError + +```ts +isLoadingError: false; +``` + +Defined in: [packages/query-core/src/types.ts:916](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L916) + +Will be `true` if the query failed while fetching for the first time. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoadingError`](QueryObserverBaseResult.md#isloadingerror) + +*** + +### isPaused + +```ts +isPaused: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:841](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L841) + +A derived boolean from the `fetchStatus` variable, provided for convenience. +- The query wanted to fetch, but has been `paused`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPaused`](QueryObserverBaseResult.md#ispaused) + +*** + +### isPending + +```ts +isPending: true; +``` + +Defined in: [packages/query-core/src/types.ts:914](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L914) + +Will be `pending` if there's no cached data and no query attempt was finished yet. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPending`](QueryObserverBaseResult.md#ispending) + +*** + +### isPlaceholderData + +```ts +isPlaceholderData: false; +``` + +Defined in: [packages/query-core/src/types.ts:919](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L919) + +Will be `true` if the data shown is the placeholder data. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPlaceholderData`](QueryObserverBaseResult.md#isplaceholderdata) + +*** + +### isRefetchError + +```ts +isRefetchError: false; +``` + +Defined in: [packages/query-core/src/types.ts:917](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L917) + +Will be `true` if the query failed while refetching. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetchError`](QueryObserverBaseResult.md#isrefetcherror) + +*** + +### isRefetching + +```ts +isRefetching: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:854](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L854) + +Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. +- Is the same as `isFetching && !isPending`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetching`](QueryObserverBaseResult.md#isrefetching) + +*** + +### isStale + +```ts +isStale: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:858](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L858) + +Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isStale`](QueryObserverBaseResult.md#isstale) + +*** + +### isSuccess + +```ts +isSuccess: false; +``` + +Defined in: [packages/query-core/src/types.ts:918](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L918) + +A derived boolean from the `status` variable, provided for convenience. +- `true` if the query has received a response with no errors and is ready to display its data. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isSuccess`](QueryObserverBaseResult.md#issuccess) + +*** + +### refetch() + +```ts +refetch: (options?) => Promise>; +``` + +Defined in: [packages/query-core/src/types.ts:871](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L871) + +A function to manually refetch the query. + +#### Parameters + +##### options? + +[`RefetchOptions`](RefetchOptions.md) + +#### Returns + +`Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`refetch`](QueryObserverBaseResult.md#refetch) + +*** + +### status + +```ts +status: "pending"; +``` + +Defined in: [packages/query-core/src/types.ts:920](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L920) + +The status of the query. +- Will be: + - `pending` if there's no cached data and no query attempt was finished yet. + - `error` if the query attempt resulted in an error. + - `success` if the query has received a response with no errors and is ready to display its data. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`status`](QueryObserverBaseResult.md#status) diff --git a/docs/framework/solid/reference/interfaces/QueryObserverOptions.md b/docs/framework/solid/reference/interfaces/QueryObserverOptions.md index 7d5c95448ab..29586e133b1 100644 --- a/docs/framework/solid/reference/interfaces/QueryObserverOptions.md +++ b/docs/framework/solid/reference/interfaces/QueryObserverOptions.md @@ -3,13 +3,13 @@ id: QueryObserverOptions title: QueryObserverOptions --- -Defined in: [QueryClient.ts:23](https://github.com/TanStack/query/blob/main/packages/solid-query/src/QueryClient.ts#L23) +Defined in: [packages/solid-query/src/QueryClient.ts:23](https://github.com/TanStack/query/blob/main/packages/solid-query/src/QueryClient.ts#L23) The core `QueryObserverOptions`, with Solid's `reconcile` option added. ## Extends -- `OmitKeyof`\<`QueryCoreObserverOptions`\<`TQueryFnData`, `TError`, `TData`, `TQueryData`, `TQueryKey`, `TPageParam`\>, `"structuralSharing"`\> +- [`OmitKeyof`](../type-aliases/OmitKeyof.md)\<`QueryCoreObserverOptions`\<`TQueryFnData`, `TError`, `TData`, `TQueryData`, `TQueryKey`, `TPageParam`\>, `"structuralSharing"`\> ## Type Parameters @@ -21,7 +21,7 @@ The type your `queryFn` resolves to. ### TError -`TError` = `DefaultError` +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) The type of errors your `queryFn` may throw. @@ -39,7 +39,7 @@ The type of the data actually held in the query cache. ### TQueryKey -`TQueryKey` *extends* `QueryKey` = `QueryKey` +`TQueryKey` *extends* [`QueryKey`](../type-aliases/QueryKey.md) = [`QueryKey`](../type-aliases/QueryKey.md) The type of your `queryKey`. @@ -52,15 +52,582 @@ is shared with an infinite query's observer options. Defaults to `never` for reg ## Properties +### enabled? + +```ts +optional enabled: QueryBooleanOption; +``` + +Defined in: [packages/query-core/src/types.ts:398](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L398) + +Set this to `false` or a function that returns `false` to disable automatic refetching when the query mounts or changes query keys. +To refetch the query, use the `refetch` method returned from the `useQuery` instance. +Accepts a boolean or function that returns a boolean. + +Defaults to `true`. + +#### Inherited from + +```ts +OmitKeyof.enabled +``` + +*** + +### gcTime? + +```ts +optional gcTime: number; +``` + +Defined in: [packages/query-core/src/types.ts:277](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L277) + +The time in milliseconds that unused/inactive cache data remains in memory. +When a query's cache becomes unused or inactive, that cache data will be garbage collected after this duration. +When different garbage collection times are specified, the longest one will be used. +Setting it to `Infinity` will disable garbage collection. + +Defaults to `5 * 60 * 1000` (5 minutes), or `Infinity` during SSR. + +Note: the maximum allowed time is about 24 days, imposed by `setTimeout`'s 32-bit signed integer delay — see +`timeoutManager.setTimeoutProvider` for a workaround. + +#### Inherited from + +[`QueryExecuteOptions`](QueryExecuteOptions.md).[`gcTime`](QueryExecuteOptions.md#gctime) + +*** + +### initialData? + +```ts +optional initialData: + | TQueryData +| InitialDataFunction; +``` + +Defined in: [packages/query-core/src/types.ts:317](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L317) + +If set, this value will be used as the initial data for the query cache (as long as the query hasn't been +created or cached yet). +If set to a function, the function will be called **once** during the shared/root query initialization, and be +expected to synchronously return the initial data. +Initial data is considered stale by default unless a `staleTime` has been set. +`initialData` **is persisted** to the cache. + +#### Inherited from + +```ts +OmitKeyof.initialData +``` + +*** + +### initialDataUpdatedAt? + +```ts +optional initialDataUpdatedAt: number | () => number | undefined; +``` + +Defined in: [packages/query-core/src/types.ts:321](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L321) + +If set, this value will be used as the time (in milliseconds) of when the `initialData` itself was last updated. + +#### Inherited from + +```ts +OmitKeyof.initialDataUpdatedAt +``` + +*** + +### maxPages? + +```ts +optional maxPages: number; +``` + +Defined in: [packages/query-core/src/types.ts:345](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L345) + +Maximum number of pages to store in the data of an infinite query. + +#### Inherited from + +[`QueryExecuteOptions`](QueryExecuteOptions.md).[`maxPages`](QueryExecuteOptions.md#maxpages) + +*** + +### meta? + +```ts +optional meta: Record; +``` + +Defined in: [packages/query-core/src/types.ts:341](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L341) + +Additional payload to be stored on each query. +Use this property to pass information that can be used in other places. + +#### Inherited from + +[`QueryExecuteOptions`](QueryExecuteOptions.md).[`meta`](QueryExecuteOptions.md#meta) + +*** + +### networkMode? + +```ts +optional networkMode: NetworkMode; +``` + +Defined in: [packages/query-core/src/types.ts:265](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L265) + +Controls whether a query is allowed to run based on the current network connectivity. + +Defaults to `'online'`. + +#### See + +[Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. + +#### Inherited from + +[`QueryExecuteOptions`](QueryExecuteOptions.md).[`networkMode`](QueryExecuteOptions.md#networkmode) + +*** + +### notifyOnChangeProps? + +```ts +optional notifyOnChangeProps: NotifyOnChangeProps; +``` + +Defined in: [packages/query-core/src/types.ts:484](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L484) + +If set, the component will only re-render if any of the listed properties change. +When set to `['data', 'error']`, the component will only re-render when the `data` or `error` properties change. +When set to `'all'`, the component will re-render whenever a query is updated. +When set to a function, the function will be executed to compute the list of properties. + +Defaults to `undefined`, in which case property access is tracked automatically, and the +component only re-renders when one of the tracked properties changes. + +#### Inherited from + +```ts +OmitKeyof.notifyOnChangeProps +``` + +*** + +### persister? + +```ts +optional persister: QueryPersister, TPageParam>; +``` + +Defined in: [packages/query-core/src/types.ts:290](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L290) + +This option can be used to persist the result of a query to an external storage, bypassing the need to actually +call the `queryFn`. Useful for persisting a query's data across e.g. server/client boundaries. + +#### Inherited from + +```ts +OmitKeyof.persister +``` + +*** + +### placeholderData? + +```ts +optional placeholderData: + | NonFunctionGuard +| PlaceholderDataFunction, TError, NonFunctionGuard, TQueryKey>; +``` + +Defined in: [packages/query-core/src/types.ts:511](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L511) + +If set, this value will be used as the placeholder data for this particular query observer while the query is still in the `loading` data and no initialData has been provided. + +#### Inherited from + +```ts +OmitKeyof.placeholderData +``` + +*** + +### queryFn? + +```ts +optional queryFn: + | typeof skipToken +| QueryFunction; +``` + +Defined in: [packages/query-core/src/types.ts:285](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L285) + +The function that the query will use to request data. +Required, unless a default query function has been set via `queryClient.setQueryDefaults` or +`queryClient.setDefaultOptions`. +Receives a [QueryFunctionContext](../type-aliases/QueryFunctionContext.md). +Must return a promise that will either resolve data or throw an error. The data cannot be `undefined`. + +#### Inherited from + +```ts +OmitKeyof.queryFn +``` + +*** + +### queryHash? + +```ts +optional queryHash: string; +``` + +Defined in: [packages/query-core/src/types.ts:295](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L295) + +The hashed form of `queryKey`, computed with `queryKeyHashFn` (or the default hashing function otherwise). Used +as the actual cache key internally. + +#### Inherited from + +[`QueryExecuteOptions`](QueryExecuteOptions.md).[`queryHash`](QueryExecuteOptions.md#queryhash) + +*** + +### queryKey + +```ts +queryKey: TQueryKey & object; +``` + +Defined in: [packages/query-core/src/types.ts:304](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L304) + +The query key to use for this query. + +The query key will be hashed into a stable hash. See [Query Keys](https://tanstack.com/query/latest/docs/framework/react/guides/query-keys) +for more information. + +The query will automatically update when this key changes (as long as `enabled` is not set to `false`). + +#### Inherited from + +```ts +OmitKeyof.queryKey +``` + +*** + +### queryKeyHashFn? + +```ts +optional queryKeyHashFn: QueryKeyHashFunction; +``` + +Defined in: [packages/query-core/src/types.ts:308](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L308) + +If specified, this function is used to hash the `queryKey` to a string. + +#### Inherited from + +```ts +OmitKeyof.queryKeyHashFn +``` + +*** + ### reconcile? ```ts optional reconcile: string | false | (oldData, newData) => TData; ``` -Defined in: [QueryClient.ts:47](https://github.com/TanStack/query/blob/main/packages/solid-query/src/QueryClient.ts#L47) +Defined in: [packages/solid-query/src/QueryClient.ts:47](https://github.com/TanStack/query/blob/main/packages/solid-query/src/QueryClient.ts#L47) Set this to a reconciliation key to enable reconciliation between query results. Set this to `false` to disable reconciliation between query results. Set this to a function which accepts the old and new data and returns resolved data of the same type to implement custom reconciliation logic. Defaults reconciliation to false. + +*** + +### refetchInterval? + +```ts +optional refetchInterval: number | false | (query) => number | false | undefined; +``` + +Defined in: [packages/query-core/src/types.ts:414](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L414) + +If set to a number, the query will continuously refetch at this frequency in milliseconds. +If set to a function, the function will be executed with the latest data and query to compute a frequency + +Defaults to `false`. + +#### Inherited from + +```ts +OmitKeyof.refetchInterval +``` + +*** + +### refetchIntervalInBackground? + +```ts +optional refetchIntervalInBackground: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:425](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L425) + +If set to `true`, the query will continue to refetch while their tab/window is in the background. + +Defaults to `false`. + +#### Inherited from + +```ts +OmitKeyof.refetchIntervalInBackground +``` + +*** + +### refetchOnMount? + +```ts +optional refetchOnMount: boolean | "always" | (query) => boolean | "always"; +``` + +Defined in: [packages/query-core/src/types.ts:462](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L462) + +If set to `true`, the query will refetch on mount if the data is stale. +If set to `false`, will disable additional instances of a query to trigger background refetch. +If set to `'always'`, the query will always refetch on mount (except when `staleTime: 'static'` is used). +If set to a function, the function will be executed with the latest data and query to compute the value + +Defaults to `true`. + +#### Inherited from + +```ts +OmitKeyof.refetchOnMount +``` + +*** + +### refetchOnReconnect? + +```ts +optional refetchOnReconnect: boolean | "always" | (query) => boolean | "always"; +``` + +Defined in: [packages/query-core/src/types.ts:448](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L448) + +If set to `true`, the query will refetch on reconnect if the data is stale. +If set to `false`, the query will not refetch on reconnect. +If set to `'always'`, the query will always refetch on reconnect (except when `staleTime: 'static'` is used). +If set to a function, the function will be executed with the latest data and query to compute the value. + +Defaults to `true` unless `networkMode` is `'always'`. + +#### Inherited from + +```ts +OmitKeyof.refetchOnReconnect +``` + +*** + +### refetchOnWindowFocus? + +```ts +optional refetchOnWindowFocus: boolean | "always" | (query) => boolean | "always"; +``` + +Defined in: [packages/query-core/src/types.ts:434](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L434) + +If set to `true`, the query will refetch on window focus if the data is stale. +If set to `false`, the query will not refetch on window focus. +If set to `'always'`, the query will always refetch on window focus (except when `staleTime: 'static'` is used). +If set to a function, the function will be executed with the latest data and query to compute the value. + +Defaults to `true`. + +#### Inherited from + +```ts +OmitKeyof.refetchOnWindowFocus +``` + +*** + +### retry? + +```ts +optional retry: RetryValue; +``` + +Defined in: [packages/query-core/src/types.ts:246](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L246) + +If `false`, failed queries will not retry by default. +If `true`, failed queries will retry infinitely. +If set to an integer number, e.g. 3, failed queries will retry until the failed query count meets that number. +If set to a function `(failureCount, error) => boolean` failed queries will retry until the function returns false. + +Defaults to `3` on the client and `0` on the server. + +#### Inherited from + +```ts +OmitKeyof.retry +``` + +*** + +### retryDelay? + +```ts +optional retryDelay: RetryDelayValue; +``` + +Defined in: [packages/query-core/src/types.ts:258](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L258) + +This function receives a `retryAttempt` integer and the actual Error and returns the delay to apply before the +next attempt in milliseconds. + +A function like `attempt => Math.min(attempt > 1 ? 2 ** attempt * 1000 : 1000, 30 * 1000)` applies exponential +backoff. + +A function like `attempt => attempt * 1000` applies linear backoff. + +Defaults to a function that applies exponential backoff, capped at 30 seconds. + +#### Inherited from + +```ts +OmitKeyof.retryDelay +``` + +*** + +### retryOnMount? + +```ts +optional retryOnMount: QueryBooleanOption; +``` + +Defined in: [packages/query-core/src/types.ts:474](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L474) + +If set to `false`, the query will not be retried on mount if it contains an error. +If set to a function, the function will be executed with the query to compute the value. + +Defaults to `true`. + +#### Inherited from + +```ts +OmitKeyof.retryOnMount +``` + +*** + +### select()? + +```ts +optional select: (data) => TData; +``` + +Defined in: [packages/query-core/src/types.ts:500](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L500) + +This option can be used to transform or select a part of the data returned by the query function. It affects +the returned `data` value, but does not affect what gets stored in the query cache. +The `select` function will only run if `data` changed, or if the reference to the `select` function itself +changes. To optimize, memoize the function so its reference stays stable across calls. + +#### Parameters + +##### data + +`TQueryData` + +#### Returns + +`TData` + +#### Inherited from + +```ts +OmitKeyof.select +``` + +*** + +### staleTime? + +```ts +optional staleTime: StaleTimeFunction; +``` + +Defined in: [packages/query-core/src/types.ts:407](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L407) + +The time in milliseconds after data is considered stale. +If set to `Infinity`, the data will never be considered stale. +If set to `'static'`, the data will never be considered stale. +If set to a function, the function will be executed with the query to compute a `staleTime`. + +Defaults to `0`. + +#### Inherited from + +```ts +OmitKeyof.staleTime +``` + +*** + +### suspense? + +```ts +optional suspense: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:507](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L507) + +If set to `true`, the query will suspend when `status === 'pending'` +and throw errors when `status === 'error'`. + +Defaults to `false`. + +#### Inherited from + +```ts +OmitKeyof.suspense +``` + +*** + +### throwOnError? + +```ts +optional throwOnError: ThrowOnError; +``` + +Defined in: [packages/query-core/src/types.ts:493](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L493) + +Whether errors should be thrown instead of setting the `error` property. +If set to `true` or `suspense` is `true`, all errors will be thrown to the error boundary. +If set to `false` and `suspense` is `false`, errors are returned as state. +If set to a function, it will be passed the error and the query, and it should return a boolean indicating whether to show the error in an error boundary (`true`) or return the error as state (`false`). + +Defaults to `false`. + +#### Inherited from + +```ts +OmitKeyof.throwOnError +``` diff --git a/docs/framework/solid/reference/interfaces/QueryObserverPendingResult.md b/docs/framework/solid/reference/interfaces/QueryObserverPendingResult.md new file mode 100644 index 00000000000..8f00c426b64 --- /dev/null +++ b/docs/framework/solid/reference/interfaces/QueryObserverPendingResult.md @@ -0,0 +1,452 @@ +--- +id: QueryObserverPendingResult +title: QueryObserverPendingResult +--- + +Defined in: [packages/query-core/src/types.ts:892](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L892) + +## Extends + +- [`QueryObserverBaseResult`](QueryObserverBaseResult.md)\<`TData`, `TError`\> + +## Type Parameters + +### TData + +`TData` = `unknown` + +### TError + +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) + +## Properties + +### data + +```ts +data: undefined; +``` + +Defined in: [packages/query-core/src/types.ts:896](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L896) + +The last successfully resolved data for the query. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`data`](QueryObserverBaseResult.md#data) + +*** + +### dataUpdatedAt + +```ts +dataUpdatedAt: number; +``` + +Defined in: [packages/query-core/src/types.ts:775](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L775) + +The timestamp for when the query most recently returned the `status` as `"success"`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`dataUpdatedAt`](QueryObserverBaseResult.md#dataupdatedat) + +*** + +### error + +```ts +error: null; +``` + +Defined in: [packages/query-core/src/types.ts:897](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L897) + +The error object for the query, if an error was thrown. +- Defaults to `null`. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`error`](QueryObserverBaseResult.md#error) + +*** + +### errorUpdateCount + +```ts +errorUpdateCount: number; +``` + +Defined in: [packages/query-core/src/types.ts:799](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L799) + +The sum of all errors. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`errorUpdateCount`](QueryObserverBaseResult.md#errorupdatecount) + +*** + +### errorUpdatedAt + +```ts +errorUpdatedAt: number; +``` + +Defined in: [packages/query-core/src/types.ts:784](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L784) + +The timestamp for when the query most recently returned the `status` as `"error"`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`errorUpdatedAt`](QueryObserverBaseResult.md#errorupdatedat) + +*** + +### failureCount + +```ts +failureCount: number; +``` + +Defined in: [packages/query-core/src/types.ts:790](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L790) + +The failure count for the query. +- Incremented every time the query fails. +- Reset to `0` when the query succeeds. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`failureCount`](QueryObserverBaseResult.md#failurecount) + +*** + +### failureReason + +```ts +failureReason: TError | null; +``` + +Defined in: [packages/query-core/src/types.ts:795](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L795) + +The failure reason for the query retry. +- Reset to `null` when the query succeeds. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`failureReason`](QueryObserverBaseResult.md#failurereason) + +*** + +### fetchStatus + +```ts +fetchStatus: FetchStatus; +``` + +Defined in: [packages/query-core/src/types.ts:889](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L889) + +The fetch status of the query. +- `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. +- `paused`: The query wanted to fetch, but has been `paused`. +- `idle`: The query is not fetching. +- See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`fetchStatus`](QueryObserverBaseResult.md#fetchstatus) + +*** + +### isEnabled + +```ts +isEnabled: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:867](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L867) + +`true` if this observer is enabled, `false` otherwise. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isEnabled`](QueryObserverBaseResult.md#isenabled) + +*** + +### isError + +```ts +isError: false; +``` + +Defined in: [packages/query-core/src/types.ts:898](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L898) + +A derived boolean from the `status` variable, provided for convenience. +- `true` if the query attempt resulted in an error. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isError`](QueryObserverBaseResult.md#iserror) + +*** + +### isFetched + +```ts +isFetched: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:808](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L808) + +Will be `true` if the query has been fetched. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isFetched`](QueryObserverBaseResult.md#isfetched) + +*** + +### isFetchedAfterMount + +```ts +isFetchedAfterMount: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:813](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L813) + +Will be `true` if the query has been fetched after the component mounted. +- This property can be used to not show any previously cached data. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isFetchedAfterMount`](QueryObserverBaseResult.md#isfetchedaftermount) + +*** + +### isFetching + +```ts +isFetching: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:818](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L818) + +A derived boolean from the `fetchStatus` variable, provided for convenience. +- `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isFetching`](QueryObserverBaseResult.md#isfetching) + +*** + +### ~~isInitialLoading~~ + +```ts +isInitialLoading: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:836](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L836) + +#### Deprecated + +`isInitialLoading` is being deprecated in favor of `isLoading` +and will be removed in the next major version. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isInitialLoading`](QueryObserverBaseResult.md#isinitialloading) + +*** + +### isLoading + +```ts +isLoading: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:823](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L823) + +Is `true` whenever the first fetch for a query is in-flight. +- Is the same as `isFetching && isPending`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoading`](QueryObserverBaseResult.md#isloading) + +*** + +### isLoadingError + +```ts +isLoadingError: false; +``` + +Defined in: [packages/query-core/src/types.ts:900](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L900) + +Will be `true` if the query failed while fetching for the first time. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoadingError`](QueryObserverBaseResult.md#isloadingerror) + +*** + +### isPaused + +```ts +isPaused: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:841](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L841) + +A derived boolean from the `fetchStatus` variable, provided for convenience. +- The query wanted to fetch, but has been `paused`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPaused`](QueryObserverBaseResult.md#ispaused) + +*** + +### isPending + +```ts +isPending: true; +``` + +Defined in: [packages/query-core/src/types.ts:899](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L899) + +Will be `pending` if there's no cached data and no query attempt was finished yet. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPending`](QueryObserverBaseResult.md#ispending) + +*** + +### isPlaceholderData + +```ts +isPlaceholderData: false; +``` + +Defined in: [packages/query-core/src/types.ts:903](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L903) + +Will be `true` if the data shown is the placeholder data. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPlaceholderData`](QueryObserverBaseResult.md#isplaceholderdata) + +*** + +### isRefetchError + +```ts +isRefetchError: false; +``` + +Defined in: [packages/query-core/src/types.ts:901](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L901) + +Will be `true` if the query failed while refetching. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetchError`](QueryObserverBaseResult.md#isrefetcherror) + +*** + +### isRefetching + +```ts +isRefetching: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:854](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L854) + +Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. +- Is the same as `isFetching && !isPending`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetching`](QueryObserverBaseResult.md#isrefetching) + +*** + +### isStale + +```ts +isStale: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:858](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L858) + +Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isStale`](QueryObserverBaseResult.md#isstale) + +*** + +### isSuccess + +```ts +isSuccess: false; +``` + +Defined in: [packages/query-core/src/types.ts:902](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L902) + +A derived boolean from the `status` variable, provided for convenience. +- `true` if the query has received a response with no errors and is ready to display its data. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isSuccess`](QueryObserverBaseResult.md#issuccess) + +*** + +### refetch() + +```ts +refetch: (options?) => Promise>; +``` + +Defined in: [packages/query-core/src/types.ts:871](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L871) + +A function to manually refetch the query. + +#### Parameters + +##### options? + +[`RefetchOptions`](RefetchOptions.md) + +#### Returns + +`Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`refetch`](QueryObserverBaseResult.md#refetch) + +*** + +### status + +```ts +status: "pending"; +``` + +Defined in: [packages/query-core/src/types.ts:904](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L904) + +The status of the query. +- Will be: + - `pending` if there's no cached data and no query attempt was finished yet. + - `error` if the query attempt resulted in an error. + - `success` if the query has received a response with no errors and is ready to display its data. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`status`](QueryObserverBaseResult.md#status) diff --git a/docs/framework/solid/reference/interfaces/QueryObserverPlaceholderResult.md b/docs/framework/solid/reference/interfaces/QueryObserverPlaceholderResult.md new file mode 100644 index 00000000000..bbf3da387f9 --- /dev/null +++ b/docs/framework/solid/reference/interfaces/QueryObserverPlaceholderResult.md @@ -0,0 +1,452 @@ +--- +id: QueryObserverPlaceholderResult +title: QueryObserverPlaceholderResult +--- + +Defined in: [packages/query-core/src/types.ts:971](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L971) + +## Extends + +- [`QueryObserverBaseResult`](QueryObserverBaseResult.md)\<`TData`, `TError`\> + +## Type Parameters + +### TData + +`TData` = `unknown` + +### TError + +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) + +## Properties + +### data + +```ts +data: TData; +``` + +Defined in: [packages/query-core/src/types.ts:975](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L975) + +The last successfully resolved data for the query. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`data`](QueryObserverBaseResult.md#data) + +*** + +### dataUpdatedAt + +```ts +dataUpdatedAt: number; +``` + +Defined in: [packages/query-core/src/types.ts:775](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L775) + +The timestamp for when the query most recently returned the `status` as `"success"`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`dataUpdatedAt`](QueryObserverBaseResult.md#dataupdatedat) + +*** + +### error + +```ts +error: null; +``` + +Defined in: [packages/query-core/src/types.ts:977](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L977) + +The error object for the query, if an error was thrown. +- Defaults to `null`. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`error`](QueryObserverBaseResult.md#error) + +*** + +### errorUpdateCount + +```ts +errorUpdateCount: number; +``` + +Defined in: [packages/query-core/src/types.ts:799](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L799) + +The sum of all errors. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`errorUpdateCount`](QueryObserverBaseResult.md#errorupdatecount) + +*** + +### errorUpdatedAt + +```ts +errorUpdatedAt: number; +``` + +Defined in: [packages/query-core/src/types.ts:784](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L784) + +The timestamp for when the query most recently returned the `status` as `"error"`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`errorUpdatedAt`](QueryObserverBaseResult.md#errorupdatedat) + +*** + +### failureCount + +```ts +failureCount: number; +``` + +Defined in: [packages/query-core/src/types.ts:790](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L790) + +The failure count for the query. +- Incremented every time the query fails. +- Reset to `0` when the query succeeds. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`failureCount`](QueryObserverBaseResult.md#failurecount) + +*** + +### failureReason + +```ts +failureReason: TError | null; +``` + +Defined in: [packages/query-core/src/types.ts:795](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L795) + +The failure reason for the query retry. +- Reset to `null` when the query succeeds. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`failureReason`](QueryObserverBaseResult.md#failurereason) + +*** + +### fetchStatus + +```ts +fetchStatus: FetchStatus; +``` + +Defined in: [packages/query-core/src/types.ts:889](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L889) + +The fetch status of the query. +- `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. +- `paused`: The query wanted to fetch, but has been `paused`. +- `idle`: The query is not fetching. +- See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`fetchStatus`](QueryObserverBaseResult.md#fetchstatus) + +*** + +### isEnabled + +```ts +isEnabled: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:867](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L867) + +`true` if this observer is enabled, `false` otherwise. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isEnabled`](QueryObserverBaseResult.md#isenabled) + +*** + +### isError + +```ts +isError: false; +``` + +Defined in: [packages/query-core/src/types.ts:976](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L976) + +A derived boolean from the `status` variable, provided for convenience. +- `true` if the query attempt resulted in an error. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isError`](QueryObserverBaseResult.md#iserror) + +*** + +### isFetched + +```ts +isFetched: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:808](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L808) + +Will be `true` if the query has been fetched. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isFetched`](QueryObserverBaseResult.md#isfetched) + +*** + +### isFetchedAfterMount + +```ts +isFetchedAfterMount: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:813](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L813) + +Will be `true` if the query has been fetched after the component mounted. +- This property can be used to not show any previously cached data. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isFetchedAfterMount`](QueryObserverBaseResult.md#isfetchedaftermount) + +*** + +### isFetching + +```ts +isFetching: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:818](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L818) + +A derived boolean from the `fetchStatus` variable, provided for convenience. +- `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isFetching`](QueryObserverBaseResult.md#isfetching) + +*** + +### ~~isInitialLoading~~ + +```ts +isInitialLoading: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:836](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L836) + +#### Deprecated + +`isInitialLoading` is being deprecated in favor of `isLoading` +and will be removed in the next major version. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isInitialLoading`](QueryObserverBaseResult.md#isinitialloading) + +*** + +### isLoading + +```ts +isLoading: false; +``` + +Defined in: [packages/query-core/src/types.ts:979](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L979) + +Is `true` whenever the first fetch for a query is in-flight. +- Is the same as `isFetching && isPending`. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoading`](QueryObserverBaseResult.md#isloading) + +*** + +### isLoadingError + +```ts +isLoadingError: false; +``` + +Defined in: [packages/query-core/src/types.ts:980](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L980) + +Will be `true` if the query failed while fetching for the first time. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoadingError`](QueryObserverBaseResult.md#isloadingerror) + +*** + +### isPaused + +```ts +isPaused: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:841](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L841) + +A derived boolean from the `fetchStatus` variable, provided for convenience. +- The query wanted to fetch, but has been `paused`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPaused`](QueryObserverBaseResult.md#ispaused) + +*** + +### isPending + +```ts +isPending: false; +``` + +Defined in: [packages/query-core/src/types.ts:978](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L978) + +Will be `pending` if there's no cached data and no query attempt was finished yet. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPending`](QueryObserverBaseResult.md#ispending) + +*** + +### isPlaceholderData + +```ts +isPlaceholderData: true; +``` + +Defined in: [packages/query-core/src/types.ts:983](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L983) + +Will be `true` if the data shown is the placeholder data. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPlaceholderData`](QueryObserverBaseResult.md#isplaceholderdata) + +*** + +### isRefetchError + +```ts +isRefetchError: false; +``` + +Defined in: [packages/query-core/src/types.ts:981](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L981) + +Will be `true` if the query failed while refetching. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetchError`](QueryObserverBaseResult.md#isrefetcherror) + +*** + +### isRefetching + +```ts +isRefetching: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:854](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L854) + +Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. +- Is the same as `isFetching && !isPending`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetching`](QueryObserverBaseResult.md#isrefetching) + +*** + +### isStale + +```ts +isStale: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:858](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L858) + +Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isStale`](QueryObserverBaseResult.md#isstale) + +*** + +### isSuccess + +```ts +isSuccess: true; +``` + +Defined in: [packages/query-core/src/types.ts:982](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L982) + +A derived boolean from the `status` variable, provided for convenience. +- `true` if the query has received a response with no errors and is ready to display its data. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isSuccess`](QueryObserverBaseResult.md#issuccess) + +*** + +### refetch() + +```ts +refetch: (options?) => Promise>; +``` + +Defined in: [packages/query-core/src/types.ts:871](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L871) + +A function to manually refetch the query. + +#### Parameters + +##### options? + +[`RefetchOptions`](RefetchOptions.md) + +#### Returns + +`Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`refetch`](QueryObserverBaseResult.md#refetch) + +*** + +### status + +```ts +status: "success"; +``` + +Defined in: [packages/query-core/src/types.ts:984](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L984) + +The status of the query. +- Will be: + - `pending` if there's no cached data and no query attempt was finished yet. + - `error` if the query attempt resulted in an error. + - `success` if the query has received a response with no errors and is ready to display its data. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`status`](QueryObserverBaseResult.md#status) diff --git a/docs/framework/solid/reference/interfaces/QueryObserverRefetchErrorResult.md b/docs/framework/solid/reference/interfaces/QueryObserverRefetchErrorResult.md new file mode 100644 index 00000000000..345ecab35e1 --- /dev/null +++ b/docs/framework/solid/reference/interfaces/QueryObserverRefetchErrorResult.md @@ -0,0 +1,452 @@ +--- +id: QueryObserverRefetchErrorResult +title: QueryObserverRefetchErrorResult +--- + +Defined in: [packages/query-core/src/types.ts:939](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L939) + +## Extends + +- [`QueryObserverBaseResult`](QueryObserverBaseResult.md)\<`TData`, `TError`\> + +## Type Parameters + +### TData + +`TData` = `unknown` + +### TError + +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) + +## Properties + +### data + +```ts +data: TData; +``` + +Defined in: [packages/query-core/src/types.ts:943](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L943) + +The last successfully resolved data for the query. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`data`](QueryObserverBaseResult.md#data) + +*** + +### dataUpdatedAt + +```ts +dataUpdatedAt: number; +``` + +Defined in: [packages/query-core/src/types.ts:775](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L775) + +The timestamp for when the query most recently returned the `status` as `"success"`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`dataUpdatedAt`](QueryObserverBaseResult.md#dataupdatedat) + +*** + +### error + +```ts +error: TError; +``` + +Defined in: [packages/query-core/src/types.ts:944](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L944) + +The error object for the query, if an error was thrown. +- Defaults to `null`. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`error`](QueryObserverBaseResult.md#error) + +*** + +### errorUpdateCount + +```ts +errorUpdateCount: number; +``` + +Defined in: [packages/query-core/src/types.ts:799](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L799) + +The sum of all errors. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`errorUpdateCount`](QueryObserverBaseResult.md#errorupdatecount) + +*** + +### errorUpdatedAt + +```ts +errorUpdatedAt: number; +``` + +Defined in: [packages/query-core/src/types.ts:784](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L784) + +The timestamp for when the query most recently returned the `status` as `"error"`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`errorUpdatedAt`](QueryObserverBaseResult.md#errorupdatedat) + +*** + +### failureCount + +```ts +failureCount: number; +``` + +Defined in: [packages/query-core/src/types.ts:790](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L790) + +The failure count for the query. +- Incremented every time the query fails. +- Reset to `0` when the query succeeds. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`failureCount`](QueryObserverBaseResult.md#failurecount) + +*** + +### failureReason + +```ts +failureReason: TError | null; +``` + +Defined in: [packages/query-core/src/types.ts:795](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L795) + +The failure reason for the query retry. +- Reset to `null` when the query succeeds. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`failureReason`](QueryObserverBaseResult.md#failurereason) + +*** + +### fetchStatus + +```ts +fetchStatus: FetchStatus; +``` + +Defined in: [packages/query-core/src/types.ts:889](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L889) + +The fetch status of the query. +- `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. +- `paused`: The query wanted to fetch, but has been `paused`. +- `idle`: The query is not fetching. +- See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`fetchStatus`](QueryObserverBaseResult.md#fetchstatus) + +*** + +### isEnabled + +```ts +isEnabled: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:867](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L867) + +`true` if this observer is enabled, `false` otherwise. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isEnabled`](QueryObserverBaseResult.md#isenabled) + +*** + +### isError + +```ts +isError: true; +``` + +Defined in: [packages/query-core/src/types.ts:945](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L945) + +A derived boolean from the `status` variable, provided for convenience. +- `true` if the query attempt resulted in an error. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isError`](QueryObserverBaseResult.md#iserror) + +*** + +### isFetched + +```ts +isFetched: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:808](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L808) + +Will be `true` if the query has been fetched. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isFetched`](QueryObserverBaseResult.md#isfetched) + +*** + +### isFetchedAfterMount + +```ts +isFetchedAfterMount: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:813](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L813) + +Will be `true` if the query has been fetched after the component mounted. +- This property can be used to not show any previously cached data. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isFetchedAfterMount`](QueryObserverBaseResult.md#isfetchedaftermount) + +*** + +### isFetching + +```ts +isFetching: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:818](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L818) + +A derived boolean from the `fetchStatus` variable, provided for convenience. +- `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isFetching`](QueryObserverBaseResult.md#isfetching) + +*** + +### ~~isInitialLoading~~ + +```ts +isInitialLoading: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:836](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L836) + +#### Deprecated + +`isInitialLoading` is being deprecated in favor of `isLoading` +and will be removed in the next major version. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isInitialLoading`](QueryObserverBaseResult.md#isinitialloading) + +*** + +### isLoading + +```ts +isLoading: false; +``` + +Defined in: [packages/query-core/src/types.ts:947](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L947) + +Is `true` whenever the first fetch for a query is in-flight. +- Is the same as `isFetching && isPending`. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoading`](QueryObserverBaseResult.md#isloading) + +*** + +### isLoadingError + +```ts +isLoadingError: false; +``` + +Defined in: [packages/query-core/src/types.ts:948](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L948) + +Will be `true` if the query failed while fetching for the first time. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoadingError`](QueryObserverBaseResult.md#isloadingerror) + +*** + +### isPaused + +```ts +isPaused: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:841](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L841) + +A derived boolean from the `fetchStatus` variable, provided for convenience. +- The query wanted to fetch, but has been `paused`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPaused`](QueryObserverBaseResult.md#ispaused) + +*** + +### isPending + +```ts +isPending: false; +``` + +Defined in: [packages/query-core/src/types.ts:946](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L946) + +Will be `pending` if there's no cached data and no query attempt was finished yet. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPending`](QueryObserverBaseResult.md#ispending) + +*** + +### isPlaceholderData + +```ts +isPlaceholderData: false; +``` + +Defined in: [packages/query-core/src/types.ts:951](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L951) + +Will be `true` if the data shown is the placeholder data. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPlaceholderData`](QueryObserverBaseResult.md#isplaceholderdata) + +*** + +### isRefetchError + +```ts +isRefetchError: true; +``` + +Defined in: [packages/query-core/src/types.ts:949](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L949) + +Will be `true` if the query failed while refetching. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetchError`](QueryObserverBaseResult.md#isrefetcherror) + +*** + +### isRefetching + +```ts +isRefetching: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:854](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L854) + +Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. +- Is the same as `isFetching && !isPending`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetching`](QueryObserverBaseResult.md#isrefetching) + +*** + +### isStale + +```ts +isStale: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:858](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L858) + +Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isStale`](QueryObserverBaseResult.md#isstale) + +*** + +### isSuccess + +```ts +isSuccess: false; +``` + +Defined in: [packages/query-core/src/types.ts:950](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L950) + +A derived boolean from the `status` variable, provided for convenience. +- `true` if the query has received a response with no errors and is ready to display its data. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isSuccess`](QueryObserverBaseResult.md#issuccess) + +*** + +### refetch() + +```ts +refetch: (options?) => Promise>; +``` + +Defined in: [packages/query-core/src/types.ts:871](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L871) + +A function to manually refetch the query. + +#### Parameters + +##### options? + +[`RefetchOptions`](RefetchOptions.md) + +#### Returns + +`Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`refetch`](QueryObserverBaseResult.md#refetch) + +*** + +### status + +```ts +status: "error"; +``` + +Defined in: [packages/query-core/src/types.ts:952](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L952) + +The status of the query. +- Will be: + - `pending` if there's no cached data and no query attempt was finished yet. + - `error` if the query attempt resulted in an error. + - `success` if the query has received a response with no errors and is ready to display its data. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`status`](QueryObserverBaseResult.md#status) diff --git a/docs/framework/solid/reference/interfaces/QueryObserverSuccessResult.md b/docs/framework/solid/reference/interfaces/QueryObserverSuccessResult.md new file mode 100644 index 00000000000..3942655c627 --- /dev/null +++ b/docs/framework/solid/reference/interfaces/QueryObserverSuccessResult.md @@ -0,0 +1,452 @@ +--- +id: QueryObserverSuccessResult +title: QueryObserverSuccessResult +--- + +Defined in: [packages/query-core/src/types.ts:955](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L955) + +## Extends + +- [`QueryObserverBaseResult`](QueryObserverBaseResult.md)\<`TData`, `TError`\> + +## Type Parameters + +### TData + +`TData` = `unknown` + +### TError + +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) + +## Properties + +### data + +```ts +data: TData; +``` + +Defined in: [packages/query-core/src/types.ts:959](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L959) + +The last successfully resolved data for the query. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`data`](QueryObserverBaseResult.md#data) + +*** + +### dataUpdatedAt + +```ts +dataUpdatedAt: number; +``` + +Defined in: [packages/query-core/src/types.ts:775](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L775) + +The timestamp for when the query most recently returned the `status` as `"success"`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`dataUpdatedAt`](QueryObserverBaseResult.md#dataupdatedat) + +*** + +### error + +```ts +error: null; +``` + +Defined in: [packages/query-core/src/types.ts:960](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L960) + +The error object for the query, if an error was thrown. +- Defaults to `null`. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`error`](QueryObserverBaseResult.md#error) + +*** + +### errorUpdateCount + +```ts +errorUpdateCount: number; +``` + +Defined in: [packages/query-core/src/types.ts:799](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L799) + +The sum of all errors. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`errorUpdateCount`](QueryObserverBaseResult.md#errorupdatecount) + +*** + +### errorUpdatedAt + +```ts +errorUpdatedAt: number; +``` + +Defined in: [packages/query-core/src/types.ts:784](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L784) + +The timestamp for when the query most recently returned the `status` as `"error"`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`errorUpdatedAt`](QueryObserverBaseResult.md#errorupdatedat) + +*** + +### failureCount + +```ts +failureCount: number; +``` + +Defined in: [packages/query-core/src/types.ts:790](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L790) + +The failure count for the query. +- Incremented every time the query fails. +- Reset to `0` when the query succeeds. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`failureCount`](QueryObserverBaseResult.md#failurecount) + +*** + +### failureReason + +```ts +failureReason: TError | null; +``` + +Defined in: [packages/query-core/src/types.ts:795](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L795) + +The failure reason for the query retry. +- Reset to `null` when the query succeeds. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`failureReason`](QueryObserverBaseResult.md#failurereason) + +*** + +### fetchStatus + +```ts +fetchStatus: FetchStatus; +``` + +Defined in: [packages/query-core/src/types.ts:889](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L889) + +The fetch status of the query. +- `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. +- `paused`: The query wanted to fetch, but has been `paused`. +- `idle`: The query is not fetching. +- See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`fetchStatus`](QueryObserverBaseResult.md#fetchstatus) + +*** + +### isEnabled + +```ts +isEnabled: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:867](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L867) + +`true` if this observer is enabled, `false` otherwise. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isEnabled`](QueryObserverBaseResult.md#isenabled) + +*** + +### isError + +```ts +isError: false; +``` + +Defined in: [packages/query-core/src/types.ts:961](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L961) + +A derived boolean from the `status` variable, provided for convenience. +- `true` if the query attempt resulted in an error. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isError`](QueryObserverBaseResult.md#iserror) + +*** + +### isFetched + +```ts +isFetched: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:808](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L808) + +Will be `true` if the query has been fetched. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isFetched`](QueryObserverBaseResult.md#isfetched) + +*** + +### isFetchedAfterMount + +```ts +isFetchedAfterMount: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:813](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L813) + +Will be `true` if the query has been fetched after the component mounted. +- This property can be used to not show any previously cached data. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isFetchedAfterMount`](QueryObserverBaseResult.md#isfetchedaftermount) + +*** + +### isFetching + +```ts +isFetching: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:818](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L818) + +A derived boolean from the `fetchStatus` variable, provided for convenience. +- `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isFetching`](QueryObserverBaseResult.md#isfetching) + +*** + +### ~~isInitialLoading~~ + +```ts +isInitialLoading: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:836](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L836) + +#### Deprecated + +`isInitialLoading` is being deprecated in favor of `isLoading` +and will be removed in the next major version. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isInitialLoading`](QueryObserverBaseResult.md#isinitialloading) + +*** + +### isLoading + +```ts +isLoading: false; +``` + +Defined in: [packages/query-core/src/types.ts:963](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L963) + +Is `true` whenever the first fetch for a query is in-flight. +- Is the same as `isFetching && isPending`. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoading`](QueryObserverBaseResult.md#isloading) + +*** + +### isLoadingError + +```ts +isLoadingError: false; +``` + +Defined in: [packages/query-core/src/types.ts:964](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L964) + +Will be `true` if the query failed while fetching for the first time. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoadingError`](QueryObserverBaseResult.md#isloadingerror) + +*** + +### isPaused + +```ts +isPaused: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:841](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L841) + +A derived boolean from the `fetchStatus` variable, provided for convenience. +- The query wanted to fetch, but has been `paused`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPaused`](QueryObserverBaseResult.md#ispaused) + +*** + +### isPending + +```ts +isPending: false; +``` + +Defined in: [packages/query-core/src/types.ts:962](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L962) + +Will be `pending` if there's no cached data and no query attempt was finished yet. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPending`](QueryObserverBaseResult.md#ispending) + +*** + +### isPlaceholderData + +```ts +isPlaceholderData: false; +``` + +Defined in: [packages/query-core/src/types.ts:967](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L967) + +Will be `true` if the data shown is the placeholder data. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPlaceholderData`](QueryObserverBaseResult.md#isplaceholderdata) + +*** + +### isRefetchError + +```ts +isRefetchError: false; +``` + +Defined in: [packages/query-core/src/types.ts:965](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L965) + +Will be `true` if the query failed while refetching. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetchError`](QueryObserverBaseResult.md#isrefetcherror) + +*** + +### isRefetching + +```ts +isRefetching: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:854](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L854) + +Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. +- Is the same as `isFetching && !isPending`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetching`](QueryObserverBaseResult.md#isrefetching) + +*** + +### isStale + +```ts +isStale: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:858](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L858) + +Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isStale`](QueryObserverBaseResult.md#isstale) + +*** + +### isSuccess + +```ts +isSuccess: true; +``` + +Defined in: [packages/query-core/src/types.ts:966](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L966) + +A derived boolean from the `status` variable, provided for convenience. +- `true` if the query has received a response with no errors and is ready to display its data. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isSuccess`](QueryObserverBaseResult.md#issuccess) + +*** + +### refetch() + +```ts +refetch: (options?) => Promise>; +``` + +Defined in: [packages/query-core/src/types.ts:871](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L871) + +A function to manually refetch the query. + +#### Parameters + +##### options? + +[`RefetchOptions`](RefetchOptions.md) + +#### Returns + +`Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`refetch`](QueryObserverBaseResult.md#refetch) + +*** + +### status + +```ts +status: "success"; +``` + +Defined in: [packages/query-core/src/types.ts:968](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L968) + +The status of the query. +- Will be: + - `pending` if there's no cached data and no query attempt was finished yet. + - `error` if the query attempt resulted in an error. + - `success` if the query has received a response with no errors and is ready to display its data. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`status`](QueryObserverBaseResult.md#status) diff --git a/docs/framework/solid/reference/interfaces/QueryOptions.md b/docs/framework/solid/reference/interfaces/QueryOptions.md index 83f5cc4093d..b7e06727190 100644 --- a/docs/framework/solid/reference/interfaces/QueryOptions.md +++ b/docs/framework/solid/reference/interfaces/QueryOptions.md @@ -3,7 +3,7 @@ id: QueryOptions title: QueryOptions --- -Defined in: [types.ts:68](https://github.com/TanStack/query/blob/main/packages/solid-query/src/types.ts#L68) +Defined in: [packages/solid-query/src/types.ts:68](https://github.com/TanStack/query/blob/main/packages/solid-query/src/types.ts#L68) The options accepted by `useQuery` and `queryOptions`. @@ -21,7 +21,7 @@ The type your `queryFn` resolves to. ### TError -`TError` = `DefaultError` +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) The type of errors your `queryFn` may throw. @@ -34,7 +34,7 @@ The type `data` ends up as after `select` runs. Defaults to `TQueryFnData` when ### TQueryKey -`TQueryKey` *extends* `QueryKey` = `QueryKey` +`TQueryKey` *extends* [`QueryKey`](../type-aliases/QueryKey.md) = [`QueryKey`](../type-aliases/QueryKey.md) The type of your `queryKey`. @@ -46,7 +46,7 @@ The type of your `queryKey`. optional deferStream: boolean; ``` -Defined in: [types.ts:50](https://github.com/TanStack/query/blob/main/packages/solid-query/src/types.ts#L50) +Defined in: [packages/solid-query/src/types.ts:50](https://github.com/TanStack/query/blob/main/packages/solid-query/src/types.ts#L50) Only applicable while rendering queries on the server with streaming. Set `deferStream` to `true` to wait for the query to resolve on the server before flushing the stream. @@ -59,13 +59,328 @@ Defaults to `false`. *** +### enabled? + +```ts +optional enabled: QueryBooleanOption; +``` + +Defined in: [packages/query-core/src/types.ts:398](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L398) + +Set this to `false` or a function that returns `false` to disable automatic refetching when the query mounts or changes query keys. +To refetch the query, use the `refetch` method returned from the `useQuery` instance. +Accepts a boolean or function that returns a boolean. + +Defaults to `true`. + +#### Inherited from + +[`UseBaseQueryOptions`](UseBaseQueryOptions.md).[`enabled`](UseBaseQueryOptions.md#enabled) + +*** + +### gcTime? + +```ts +optional gcTime: number; +``` + +Defined in: [packages/query-core/src/types.ts:277](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L277) + +The time in milliseconds that unused/inactive cache data remains in memory. +When a query's cache becomes unused or inactive, that cache data will be garbage collected after this duration. +When different garbage collection times are specified, the longest one will be used. +Setting it to `Infinity` will disable garbage collection. + +Defaults to `5 * 60 * 1000` (5 minutes), or `Infinity` during SSR. + +Note: the maximum allowed time is about 24 days, imposed by `setTimeout`'s 32-bit signed integer delay — see +`timeoutManager.setTimeoutProvider` for a workaround. + +#### Inherited from + +[`QueryExecuteOptions`](QueryExecuteOptions.md).[`gcTime`](QueryExecuteOptions.md#gctime) + +*** + +### initialData? + +```ts +optional initialData: + | TQueryFnData +| InitialDataFunction; +``` + +Defined in: [packages/query-core/src/types.ts:317](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L317) + +If set, this value will be used as the initial data for the query cache (as long as the query hasn't been +created or cached yet). +If set to a function, the function will be called **once** during the shared/root query initialization, and be +expected to synchronously return the initial data. +Initial data is considered stale by default unless a `staleTime` has been set. +`initialData` **is persisted** to the cache. + +#### Inherited from + +[`UseBaseQueryOptions`](UseBaseQueryOptions.md).[`initialData`](UseBaseQueryOptions.md#initialdata) + +*** + +### initialDataUpdatedAt? + +```ts +optional initialDataUpdatedAt: number | () => number | undefined; +``` + +Defined in: [packages/query-core/src/types.ts:321](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L321) + +If set, this value will be used as the time (in milliseconds) of when the `initialData` itself was last updated. + +#### Inherited from + +[`UseBaseQueryOptions`](UseBaseQueryOptions.md).[`initialDataUpdatedAt`](UseBaseQueryOptions.md#initialdataupdatedat) + +*** + +### maxPages? + +```ts +optional maxPages: number; +``` + +Defined in: [packages/query-core/src/types.ts:345](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L345) + +Maximum number of pages to store in the data of an infinite query. + +#### Inherited from + +[`QueryExecuteOptions`](QueryExecuteOptions.md).[`maxPages`](QueryExecuteOptions.md#maxpages) + +*** + +### meta? + +```ts +optional meta: Record; +``` + +Defined in: [packages/query-core/src/types.ts:341](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L341) + +Additional payload to be stored on each query. +Use this property to pass information that can be used in other places. + +#### Inherited from + +[`QueryExecuteOptions`](QueryExecuteOptions.md).[`meta`](QueryExecuteOptions.md#meta) + +*** + +### networkMode? + +```ts +optional networkMode: NetworkMode; +``` + +Defined in: [packages/query-core/src/types.ts:265](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L265) + +Controls whether a query is allowed to run based on the current network connectivity. + +Defaults to `'online'`. + +#### See + +[Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. + +#### Inherited from + +[`QueryExecuteOptions`](QueryExecuteOptions.md).[`networkMode`](QueryExecuteOptions.md#networkmode) + +*** + +### notifyOnChangeProps? + +```ts +optional notifyOnChangeProps: NotifyOnChangeProps; +``` + +Defined in: [packages/query-core/src/types.ts:484](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L484) + +If set, the component will only re-render if any of the listed properties change. +When set to `['data', 'error']`, the component will only re-render when the `data` or `error` properties change. +When set to `'all'`, the component will re-render whenever a query is updated. +When set to a function, the function will be executed to compute the list of properties. + +Defaults to `undefined`, in which case property access is tracked automatically, and the +component only re-renders when one of the tracked properties changes. + +#### Inherited from + +[`UseBaseQueryOptions`](UseBaseQueryOptions.md).[`notifyOnChangeProps`](UseBaseQueryOptions.md#notifyonchangeprops) + +*** + +### persister()? + +```ts +optional persister: (queryFn, context, query) => TQueryFnData | Promise; +``` + +Defined in: [packages/query-core/src/types.ts:290](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L290) + +This option can be used to persist the result of a query to an external storage, bypassing the need to actually +call the `queryFn`. Useful for persisting a query's data across e.g. server/client boundaries. + +#### Parameters + +##### queryFn + +[`QueryFunction`](../type-aliases/QueryFunction.md)\<`TQueryFnData`, `NoInfer`\<`TQueryKey`\>, `never`\> + +##### context + +###### client + +`QueryClient` + +###### direction? + +`unknown` + +**Deprecated** + +if you want access to the direction, you can add it to the pageParam + +###### meta + +`Record`\<`string`, `unknown`\> \| `undefined` + +###### pageParam? + +`unknown` + +###### queryKey + +`NoInfer`\<`TQueryKey`\> + +###### signal + +`AbortSignal` + +##### query + +[`Query`](../classes/Query.md) + +#### Returns + +`TQueryFnData` \| `Promise`\<`TQueryFnData`\> + +#### Inherited from + +[`UseBaseQueryOptions`](UseBaseQueryOptions.md).[`persister`](UseBaseQueryOptions.md#persister) + +*** + +### placeholderData? + +```ts +optional placeholderData: + | NonFunctionGuard +| PlaceholderDataFunction, TError, NonFunctionGuard, TQueryKey>; +``` + +Defined in: [packages/query-core/src/types.ts:511](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L511) + +If set, this value will be used as the placeholder data for this particular query observer while the query is still in the `loading` data and no initialData has been provided. + +#### Inherited from + +[`UseBaseQueryOptions`](UseBaseQueryOptions.md).[`placeholderData`](UseBaseQueryOptions.md#placeholderdata) + +*** + +### queryFn? + +```ts +optional queryFn: + | typeof skipToken +| QueryFunction; +``` + +Defined in: [packages/query-core/src/types.ts:285](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L285) + +The function that the query will use to request data. +Required, unless a default query function has been set via `queryClient.setQueryDefaults` or +`queryClient.setDefaultOptions`. +Receives a [QueryFunctionContext](../type-aliases/QueryFunctionContext.md). +Must return a promise that will either resolve data or throw an error. The data cannot be `undefined`. + +#### Inherited from + +[`UseBaseQueryOptions`](UseBaseQueryOptions.md).[`queryFn`](UseBaseQueryOptions.md#queryfn) + +*** + +### queryHash? + +```ts +optional queryHash: string; +``` + +Defined in: [packages/query-core/src/types.ts:295](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L295) + +The hashed form of `queryKey`, computed with `queryKeyHashFn` (or the default hashing function otherwise). Used +as the actual cache key internally. + +#### Inherited from + +[`QueryExecuteOptions`](QueryExecuteOptions.md).[`queryHash`](QueryExecuteOptions.md#queryhash) + +*** + +### queryKey + +```ts +queryKey: TQueryKey & object; +``` + +Defined in: [packages/query-core/src/types.ts:304](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L304) + +The query key to use for this query. + +The query key will be hashed into a stable hash. See [Query Keys](https://tanstack.com/query/latest/docs/framework/react/guides/query-keys) +for more information. + +The query will automatically update when this key changes (as long as `enabled` is not set to `false`). + +#### Inherited from + +[`UseBaseQueryOptions`](UseBaseQueryOptions.md).[`queryKey`](UseBaseQueryOptions.md#querykey) + +*** + +### queryKeyHashFn? + +```ts +optional queryKeyHashFn: QueryKeyHashFunction; +``` + +Defined in: [packages/query-core/src/types.ts:308](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L308) + +If specified, this function is used to hash the `queryKey` to a string. + +#### Inherited from + +[`UseBaseQueryOptions`](UseBaseQueryOptions.md).[`queryKeyHashFn`](UseBaseQueryOptions.md#querykeyhashfn) + +*** + ### reconcile? ```ts optional reconcile: string | false | (oldData, newData) => TData; ``` -Defined in: [QueryClient.ts:47](https://github.com/TanStack/query/blob/main/packages/solid-query/src/QueryClient.ts#L47) +Defined in: [packages/solid-query/src/QueryClient.ts:47](https://github.com/TanStack/query/blob/main/packages/solid-query/src/QueryClient.ts#L47) Set this to a reconciliation key to enable reconciliation between query results. Set this to `false` to disable reconciliation between query results. @@ -78,13 +393,227 @@ Defaults reconciliation to false. *** +### refetchInterval? + +```ts +optional refetchInterval: number | false | (query) => number | false | undefined; +``` + +Defined in: [packages/query-core/src/types.ts:414](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L414) + +If set to a number, the query will continuously refetch at this frequency in milliseconds. +If set to a function, the function will be executed with the latest data and query to compute a frequency + +Defaults to `false`. + +#### Inherited from + +[`UseBaseQueryOptions`](UseBaseQueryOptions.md).[`refetchInterval`](UseBaseQueryOptions.md#refetchinterval) + +*** + +### refetchIntervalInBackground? + +```ts +optional refetchIntervalInBackground: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:425](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L425) + +If set to `true`, the query will continue to refetch while their tab/window is in the background. + +Defaults to `false`. + +#### Inherited from + +[`UseBaseQueryOptions`](UseBaseQueryOptions.md).[`refetchIntervalInBackground`](UseBaseQueryOptions.md#refetchintervalinbackground) + +*** + +### refetchOnMount? + +```ts +optional refetchOnMount: boolean | "always" | (query) => boolean | "always"; +``` + +Defined in: [packages/query-core/src/types.ts:462](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L462) + +If set to `true`, the query will refetch on mount if the data is stale. +If set to `false`, will disable additional instances of a query to trigger background refetch. +If set to `'always'`, the query will always refetch on mount (except when `staleTime: 'static'` is used). +If set to a function, the function will be executed with the latest data and query to compute the value + +Defaults to `true`. + +#### Inherited from + +[`UseBaseQueryOptions`](UseBaseQueryOptions.md).[`refetchOnMount`](UseBaseQueryOptions.md#refetchonmount) + +*** + +### refetchOnReconnect? + +```ts +optional refetchOnReconnect: boolean | "always" | (query) => boolean | "always"; +``` + +Defined in: [packages/query-core/src/types.ts:448](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L448) + +If set to `true`, the query will refetch on reconnect if the data is stale. +If set to `false`, the query will not refetch on reconnect. +If set to `'always'`, the query will always refetch on reconnect (except when `staleTime: 'static'` is used). +If set to a function, the function will be executed with the latest data and query to compute the value. + +Defaults to `true` unless `networkMode` is `'always'`. + +#### Inherited from + +[`UseBaseQueryOptions`](UseBaseQueryOptions.md).[`refetchOnReconnect`](UseBaseQueryOptions.md#refetchonreconnect) + +*** + +### refetchOnWindowFocus? + +```ts +optional refetchOnWindowFocus: boolean | "always" | (query) => boolean | "always"; +``` + +Defined in: [packages/query-core/src/types.ts:434](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L434) + +If set to `true`, the query will refetch on window focus if the data is stale. +If set to `false`, the query will not refetch on window focus. +If set to `'always'`, the query will always refetch on window focus (except when `staleTime: 'static'` is used). +If set to a function, the function will be executed with the latest data and query to compute the value. + +Defaults to `true`. + +#### Inherited from + +[`UseBaseQueryOptions`](UseBaseQueryOptions.md).[`refetchOnWindowFocus`](UseBaseQueryOptions.md#refetchonwindowfocus) + +*** + +### retry? + +```ts +optional retry: RetryValue; +``` + +Defined in: [packages/query-core/src/types.ts:246](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L246) + +If `false`, failed queries will not retry by default. +If `true`, failed queries will retry infinitely. +If set to an integer number, e.g. 3, failed queries will retry until the failed query count meets that number. +If set to a function `(failureCount, error) => boolean` failed queries will retry until the function returns false. + +Defaults to `3` on the client and `0` on the server. + +#### Inherited from + +[`UseBaseQueryOptions`](UseBaseQueryOptions.md).[`retry`](UseBaseQueryOptions.md#retry) + +*** + +### retryDelay? + +```ts +optional retryDelay: RetryDelayValue; +``` + +Defined in: [packages/query-core/src/types.ts:258](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L258) + +This function receives a `retryAttempt` integer and the actual Error and returns the delay to apply before the +next attempt in milliseconds. + +A function like `attempt => Math.min(attempt > 1 ? 2 ** attempt * 1000 : 1000, 30 * 1000)` applies exponential +backoff. + +A function like `attempt => attempt * 1000` applies linear backoff. + +Defaults to a function that applies exponential backoff, capped at 30 seconds. + +#### Inherited from + +[`UseBaseQueryOptions`](UseBaseQueryOptions.md).[`retryDelay`](UseBaseQueryOptions.md#retrydelay) + +*** + +### retryOnMount? + +```ts +optional retryOnMount: QueryBooleanOption; +``` + +Defined in: [packages/query-core/src/types.ts:474](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L474) + +If set to `false`, the query will not be retried on mount if it contains an error. +If set to a function, the function will be executed with the query to compute the value. + +Defaults to `true`. + +#### Inherited from + +[`UseBaseQueryOptions`](UseBaseQueryOptions.md).[`retryOnMount`](UseBaseQueryOptions.md#retryonmount) + +*** + +### select()? + +```ts +optional select: (data) => TData; +``` + +Defined in: [packages/query-core/src/types.ts:500](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L500) + +This option can be used to transform or select a part of the data returned by the query function. It affects +the returned `data` value, but does not affect what gets stored in the query cache. +The `select` function will only run if `data` changed, or if the reference to the `select` function itself +changes. To optimize, memoize the function so its reference stays stable across calls. + +#### Parameters + +##### data + +`TQueryFnData` + +#### Returns + +`TData` + +#### Inherited from + +[`UseBaseQueryOptions`](UseBaseQueryOptions.md).[`select`](UseBaseQueryOptions.md#select) + +*** + +### staleTime? + +```ts +optional staleTime: StaleTimeFunction; +``` + +Defined in: [packages/query-core/src/types.ts:407](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L407) + +The time in milliseconds after data is considered stale. +If set to `Infinity`, the data will never be considered stale. +If set to `'static'`, the data will never be considered stale. +If set to a function, the function will be executed with the query to compute a `staleTime`. + +Defaults to `0`. + +#### Inherited from + +[`UseBaseQueryOptions`](UseBaseQueryOptions.md).[`staleTime`](UseBaseQueryOptions.md#staletime) + +*** + ### ~~suspense?~~ ```ts optional suspense: boolean; ``` -Defined in: [types.ts:56](https://github.com/TanStack/query/blob/main/packages/solid-query/src/types.ts#L56) +Defined in: [packages/solid-query/src/types.ts:56](https://github.com/TanStack/query/blob/main/packages/solid-query/src/types.ts#L56) #### Deprecated @@ -95,3 +624,24 @@ Setting `suspense` to `false` will be a no-op. #### Inherited from [`UseBaseQueryOptions`](UseBaseQueryOptions.md).[`suspense`](UseBaseQueryOptions.md#suspense) + +*** + +### throwOnError? + +```ts +optional throwOnError: ThrowOnError; +``` + +Defined in: [packages/query-core/src/types.ts:493](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L493) + +Whether errors should be thrown instead of setting the `error` property. +If set to `true` or `suspense` is `true`, all errors will be thrown to the error boundary. +If set to `false` and `suspense` is `false`, errors are returned as state. +If set to a function, it will be passed the error and the query, and it should return a boolean indicating whether to show the error in an error boundary (`true`) or return the error as state (`false`). + +Defaults to `false`. + +#### Inherited from + +[`UseBaseQueryOptions`](UseBaseQueryOptions.md).[`throwOnError`](UseBaseQueryOptions.md#throwonerror) diff --git a/docs/framework/solid/reference/interfaces/QueryState.md b/docs/framework/solid/reference/interfaces/QueryState.md new file mode 100644 index 00000000000..7dce476d743 --- /dev/null +++ b/docs/framework/solid/reference/interfaces/QueryState.md @@ -0,0 +1,175 @@ +--- +id: QueryState +title: QueryState +--- + +Defined in: [packages/query-core/src/query.ts:52](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L52) + +The raw state stored on a `Query` instance. This is the underlying state +that observer results (e.g. `QueryObserverResult`) are derived from. + +## Type Parameters + +### TData + +`TData` = `unknown` + +### TError + +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) + +## Properties + +### data + +```ts +data: TData | undefined; +``` + +Defined in: [packages/query-core/src/query.ts:56](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L56) + +The last successfully resolved data for the query. + +*** + +### dataUpdateCount + +```ts +dataUpdateCount: number; +``` + +Defined in: [packages/query-core/src/query.ts:60](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L60) + +The number of times the query has successfully resolved. + +*** + +### dataUpdatedAt + +```ts +dataUpdatedAt: number; +``` + +Defined in: [packages/query-core/src/query.ts:64](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L64) + +The timestamp for when the query most recently returned the `status` as `"success"`. + +*** + +### error + +```ts +error: TError | null; +``` + +Defined in: [packages/query-core/src/query.ts:69](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L69) + +The error object for the query, if the last attempt resulted in an error. +- Defaults to `null`. + +*** + +### errorUpdateCount + +```ts +errorUpdateCount: number; +``` + +Defined in: [packages/query-core/src/query.ts:73](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L73) + +The sum of all errors, incremented every time the query resolves with an error. + +*** + +### errorUpdatedAt + +```ts +errorUpdatedAt: number; +``` + +Defined in: [packages/query-core/src/query.ts:77](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L77) + +The timestamp for when the query most recently returned the `status` as `"error"`. + +*** + +### fetchFailureCount + +```ts +fetchFailureCount: number; +``` + +Defined in: [packages/query-core/src/query.ts:83](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L83) + +The failure count for the current fetch. +- Incremented every time the fetch fails. +- Reset to `0` when the fetch succeeds. + +*** + +### fetchFailureReason + +```ts +fetchFailureReason: TError | null; +``` + +Defined in: [packages/query-core/src/query.ts:88](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L88) + +The reason the current fetch failed, as reported by the retryer. +- Reset to `null` when the fetch succeeds. + +*** + +### fetchMeta + +```ts +fetchMeta: FetchMeta | null; +``` + +Defined in: [packages/query-core/src/query.ts:93](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L93) + +Metadata passed to the currently in-flight (or most recent) fetch, e.g. the +`fetchMore` direction for infinite queries. + +*** + +### fetchStatus + +```ts +fetchStatus: FetchStatus; +``` + +Defined in: [packages/query-core/src/query.ts:112](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L112) + +The fetch status of the query. +- `fetching`: the `queryFn` is currently executing. +- `paused`: a fetch wanted to run but has been paused (see network mode). +- `idle`: the query is not fetching. + +*** + +### isInvalidated + +```ts +isInvalidated: boolean; +``` + +Defined in: [packages/query-core/src/query.ts:98](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L98) + +Whether the query has been marked as invalidated via `invalidate()`. +- Reset to `false` whenever the query resolves successfully. + +*** + +### status + +```ts +status: QueryStatus; +``` + +Defined in: [packages/query-core/src/query.ts:105](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L105) + +The status of the query. +- `pending` if there's no cached data and no attempt was finished yet. +- `error` if the last attempt resulted in an error. +- `success` if the query has data. diff --git a/docs/framework/solid/reference/interfaces/RefetchOptions.md b/docs/framework/solid/reference/interfaces/RefetchOptions.md new file mode 100644 index 00000000000..cfcc0498799 --- /dev/null +++ b/docs/framework/solid/reference/interfaces/RefetchOptions.md @@ -0,0 +1,50 @@ +--- +id: RefetchOptions +title: RefetchOptions +--- + +Defined in: [packages/query-core/src/types.ts:704](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L704) + +## Extends + +- [`ResultOptions`](ResultOptions.md) + +## Extended by + +- [`InvalidateOptions`](InvalidateOptions.md) +- [`ResetOptions`](ResetOptions.md) + +## Properties + +### cancelRefetch? + +```ts +optional cancelRefetch: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:712](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L712) + +If set to `true`, a currently running request will be cancelled before a new request is made + +If set to `false`, no refetch will be made if there is already a request running. + +Defaults to `true`. + +*** + +### throwOnError? + +```ts +optional throwOnError: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:701](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L701) + +If set to `true`, the method throws if any of the underlying query refetch tasks fail. + +Defaults to `false`, in which case failed refetches are swallowed and not surfaced to the +caller. + +#### Inherited from + +[`ResultOptions`](ResultOptions.md).[`throwOnError`](ResultOptions.md#throwonerror) diff --git a/docs/framework/solid/reference/interfaces/RefetchQueryFilters.md b/docs/framework/solid/reference/interfaces/RefetchQueryFilters.md new file mode 100644 index 00000000000..c45dfa953f1 --- /dev/null +++ b/docs/framework/solid/reference/interfaces/RefetchQueryFilters.md @@ -0,0 +1,127 @@ +--- +id: RefetchQueryFilters +title: RefetchQueryFilters +--- + +Defined in: [packages/query-core/src/types.ts:730](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L730) + +Filters used to select queries, for example in `queryClient.getQueriesData` or `queryClient.invalidateQueries`. +All provided filters must match; filters that are left unspecified are ignored. + +## Extends + +- [`QueryFilters`](QueryFilters.md)\<`TQueryKey`\> + +## Type Parameters + +### TQueryKey + +`TQueryKey` *extends* [`QueryKey`](../type-aliases/QueryKey.md) = [`QueryKey`](../type-aliases/QueryKey.md) + +## Properties + +### exact? + +```ts +optional exact: boolean; +``` + +Defined in: [packages/query-core/src/utils.ts:41](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L41) + +Match query key exactly + +#### Inherited from + +[`QueryFilters`](QueryFilters.md).[`exact`](QueryFilters.md#exact) + +*** + +### fetchStatus? + +```ts +optional fetchStatus: FetchStatus; +``` + +Defined in: [packages/query-core/src/utils.ts:57](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L57) + +Include queries matching their fetchStatus + +#### Inherited from + +[`QueryFilters`](QueryFilters.md).[`fetchStatus`](QueryFilters.md#fetchstatus) + +*** + +### predicate()? + +```ts +optional predicate: (query) => boolean; +``` + +Defined in: [packages/query-core/src/utils.ts:45](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L45) + +Include queries matching this predicate function + +#### Parameters + +##### query + +[`Query`](../classes/Query.md) + +#### Returns + +`boolean` + +#### Inherited from + +[`QueryFilters`](QueryFilters.md).[`predicate`](QueryFilters.md#predicate) + +*** + +### queryKey? + +```ts +optional queryKey: TQueryKey | TuplePrefixes; +``` + +Defined in: [packages/query-core/src/utils.ts:49](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L49) + +Include queries matching this query key + +#### Inherited from + +[`QueryFilters`](QueryFilters.md).[`queryKey`](QueryFilters.md#querykey) + +*** + +### stale? + +```ts +optional stale: boolean; +``` + +Defined in: [packages/query-core/src/utils.ts:53](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L53) + +Include or exclude stale queries + +#### Inherited from + +[`QueryFilters`](QueryFilters.md).[`stale`](QueryFilters.md#stale) + +*** + +### type? + +```ts +optional type: QueryTypeFilter; +``` + +Defined in: [packages/query-core/src/utils.ts:37](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L37) + +Filter to active queries, inactive queries or all queries + +Defaults to `'all'`. + +#### Inherited from + +[`QueryFilters`](QueryFilters.md).[`type`](QueryFilters.md#type) diff --git a/docs/framework/solid/reference/interfaces/Register.md b/docs/framework/solid/reference/interfaces/Register.md new file mode 100644 index 00000000000..4f442442b48 --- /dev/null +++ b/docs/framework/solid/reference/interfaces/Register.md @@ -0,0 +1,6 @@ +--- +id: Register +title: Register +--- + +Defined in: [packages/query-core/src/types.ts:37](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L37) diff --git a/docs/framework/solid/reference/interfaces/ResetOptions.md b/docs/framework/solid/reference/interfaces/ResetOptions.md new file mode 100644 index 00000000000..9f12324ba27 --- /dev/null +++ b/docs/framework/solid/reference/interfaces/ResetOptions.md @@ -0,0 +1,49 @@ +--- +id: ResetOptions +title: ResetOptions +--- + +Defined in: [packages/query-core/src/types.ts:735](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L735) + +## Extends + +- [`RefetchOptions`](RefetchOptions.md) + +## Properties + +### cancelRefetch? + +```ts +optional cancelRefetch: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:712](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L712) + +If set to `true`, a currently running request will be cancelled before a new request is made + +If set to `false`, no refetch will be made if there is already a request running. + +Defaults to `true`. + +#### Inherited from + +[`RefetchOptions`](RefetchOptions.md).[`cancelRefetch`](RefetchOptions.md#cancelrefetch) + +*** + +### throwOnError? + +```ts +optional throwOnError: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:701](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L701) + +If set to `true`, the method throws if any of the underlying query refetch tasks fail. + +Defaults to `false`, in which case failed refetches are swallowed and not surfaced to the +caller. + +#### Inherited from + +[`RefetchOptions`](RefetchOptions.md).[`throwOnError`](RefetchOptions.md#throwonerror) diff --git a/docs/framework/solid/reference/interfaces/ResultOptions.md b/docs/framework/solid/reference/interfaces/ResultOptions.md new file mode 100644 index 00000000000..42917f20bf0 --- /dev/null +++ b/docs/framework/solid/reference/interfaces/ResultOptions.md @@ -0,0 +1,27 @@ +--- +id: ResultOptions +title: ResultOptions +--- + +Defined in: [packages/query-core/src/types.ts:694](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L694) + +## Extended by + +- [`RefetchOptions`](RefetchOptions.md) +- [`FetchNextPageOptions`](FetchNextPageOptions.md) +- [`FetchPreviousPageOptions`](FetchPreviousPageOptions.md) + +## Properties + +### throwOnError? + +```ts +optional throwOnError: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:701](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L701) + +If set to `true`, the method throws if any of the underlying query refetch tasks fail. + +Defaults to `false`, in which case failed refetches are swallowed and not surfaced to the +caller. diff --git a/docs/framework/solid/reference/interfaces/SetDataOptions.md b/docs/framework/solid/reference/interfaces/SetDataOptions.md new file mode 100644 index 00000000000..bb668fbf162 --- /dev/null +++ b/docs/framework/solid/reference/interfaces/SetDataOptions.md @@ -0,0 +1,16 @@ +--- +id: SetDataOptions +title: SetDataOptions +--- + +Defined in: [packages/query-core/src/types.ts:1526](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1526) + +## Properties + +### updatedAt? + +```ts +optional updatedAt: number; +``` + +Defined in: [packages/query-core/src/types.ts:1527](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1527) diff --git a/docs/framework/solid/reference/interfaces/TimeoutManager.md b/docs/framework/solid/reference/interfaces/TimeoutManager.md new file mode 100644 index 00000000000..95ff07b2ccc --- /dev/null +++ b/docs/framework/solid/reference/interfaces/TimeoutManager.md @@ -0,0 +1,246 @@ +--- +id: TimeoutManager +title: TimeoutManager +--- + +Defined in: [packages/query-core/src/timeoutManager.ts:70](https://github.com/TanStack/query/blob/main/packages/query-core/src/timeoutManager.ts#L70) + +Allows customization of how timeouts are created. + +@tanstack/query-core makes liberal use of timeouts to implement `staleTime` +and `gcTime`. The default TimeoutManager provider uses the platform's global +`setTimeout` implementation, which is known to have scalability issues with +thousands of timeouts on the event loop. + +If you hit this limitation, consider providing a custom TimeoutProvider that +coalesces timeouts. + +## Implements + +- `Omit`\<[`TimeoutProvider`](../type-aliases/TimeoutProvider.md), `"name"`\> + +## Methods + +### clearInterval() + +```ts +clearInterval(intervalId): void; +``` + +Defined in: [packages/query-core/src/timeoutManager.ts:224](https://github.com/TanStack/query/blob/main/packages/query-core/src/timeoutManager.ts#L224) + +`clearInterval` can be used to cancel an interval, like the global +`clearInterval` function. It should be called with an interval ID +returned by `setInterval`. + +#### Parameters + +##### intervalId + +[`ManagedTimerId`](../type-aliases/ManagedTimerId.md) | `undefined` + +#### Returns + +`void` + +#### Example + +```ts +import { timeoutManager } from '@tanstack/query-core' + +const intervalId = timeoutManager.setInterval( + () => console.log('ran at:', new Date()), + 1000, +) + +timeoutManager.clearInterval(intervalId) +``` + +#### Implementation of + +[`TimeoutProvider`](../type-aliases/TimeoutProvider.md).[`clearInterval`](../type-aliases/TimeoutProvider.md#clearinterval) + +*** + +### clearTimeout() + +```ts +clearTimeout(timeoutId): void; +``` + +Defined in: [packages/query-core/src/timeoutManager.ts:179](https://github.com/TanStack/query/blob/main/packages/query-core/src/timeoutManager.ts#L179) + +`clearTimeout` cancels a timeout callback scheduled with `setTimeout`, +like the global `clearTimeout` function. It should be called with a +timer ID returned by `setTimeout`. + +#### Parameters + +##### timeoutId + +[`ManagedTimerId`](../type-aliases/ManagedTimerId.md) | `undefined` + +#### Returns + +`void` + +#### Example + +```ts +import { timeoutManager } from '@tanstack/query-core' + +const timeoutId = timeoutManager.setTimeout( + () => console.log('ran at:', new Date()), + 1000, +) + +timeoutManager.clearTimeout(timeoutId) +``` + +#### Implementation of + +[`TimeoutProvider`](../type-aliases/TimeoutProvider.md).[`clearTimeout`](../type-aliases/TimeoutProvider.md#cleartimeout) + +*** + +### setInterval() + +```ts +setInterval(callback, delay): ManagedTimerId; +``` + +Defined in: [packages/query-core/src/timeoutManager.ts:200](https://github.com/TanStack/query/blob/main/packages/query-core/src/timeoutManager.ts#L200) + +`setInterval` schedules a callback to be called approximately every +`delay` milliseconds, like the global `setInterval` function. + +Like `setTimeout`, it returns a timer ID, which may be a number or an +object that can be coerced to a number via `Symbol.toPrimitive`. + +#### Parameters + +##### callback + +[`TimeoutCallback`](../type-aliases/TimeoutCallback.md) + +##### delay + +`number` + +#### Returns + +[`ManagedTimerId`](../type-aliases/ManagedTimerId.md) + +#### Example + +```ts +import { timeoutManager } from '@tanstack/query-core' + +const intervalId = timeoutManager.setInterval( + () => console.log('ran at:', new Date()), + 1000, +) +``` + +#### Implementation of + +[`TimeoutProvider`](../type-aliases/TimeoutProvider.md).[`setInterval`](../type-aliases/TimeoutProvider.md#setinterval) + +*** + +### setTimeout() + +```ts +setTimeout(callback, delay): ManagedTimerId; +``` + +Defined in: [packages/query-core/src/timeoutManager.ts:155](https://github.com/TanStack/query/blob/main/packages/query-core/src/timeoutManager.ts#L155) + +`setTimeout` schedules a callback to run after approximately `delay` +milliseconds, like the global `setTimeout` function. The callback can be +canceled with `clearTimeout`. + +It returns a timer ID, which may be a number or an object that can be +coerced to a number via `Symbol.toPrimitive`. + +#### Parameters + +##### callback + +[`TimeoutCallback`](../type-aliases/TimeoutCallback.md) + +##### delay + +`number` + +#### Returns + +[`ManagedTimerId`](../type-aliases/ManagedTimerId.md) + +#### Example + +```ts +import { timeoutManager } from '@tanstack/query-core' + +const timeoutId = timeoutManager.setTimeout( + () => console.log('ran at:', new Date()), + 1000, +) + +const timeoutIdNumber: number = Number(timeoutId) +``` + +#### Implementation of + +[`TimeoutProvider`](../type-aliases/TimeoutProvider.md).[`setTimeout`](../type-aliases/TimeoutProvider.md#settimeout) + +*** + +### setTimeoutProvider() + +```ts +setTimeoutProvider(provider): void; +``` + +Defined in: [packages/query-core/src/timeoutManager.ts:106](https://github.com/TanStack/query/blob/main/packages/query-core/src/timeoutManager.ts#L106) + +`setTimeoutProvider` can be used to set a custom implementation of the +`setTimeout`, `clearTimeout`, `setInterval`, `clearInterval` functions, +called a `TimeoutProvider`. + +This may be useful if you notice event loop performance issues with +thousands of queries. A custom TimeoutProvider could also support timer +delays longer than the global `setTimeout` maximum delay value of about +24 days. + +It is important to call `setTimeoutProvider` before creating a +QueryClient or queries, so that the same provider is used consistently +for all timers in the application, since different TimeoutProviders +cannot cancel each others' timers. + +#### Type Parameters + +##### TTimerId + +`TTimerId` *extends* [`ManagedTimerId`](../type-aliases/ManagedTimerId.md) + +#### Parameters + +##### provider + +[`TimeoutProvider`](../type-aliases/TimeoutProvider.md)\<`TTimerId`\> + +#### Returns + +`void` + +#### Example + +```ts +import { timeoutManager, QueryClient } from '@tanstack/query-core' +import { CustomTimeoutProvider } from './CustomTimeoutProvider' + +timeoutManager.setTimeoutProvider(new CustomTimeoutProvider()) + +export const queryClient = new QueryClient() +``` diff --git a/docs/framework/solid/reference/interfaces/UseBaseQueryOptions.md b/docs/framework/solid/reference/interfaces/UseBaseQueryOptions.md index c26094dfd33..4cab9707943 100644 --- a/docs/framework/solid/reference/interfaces/UseBaseQueryOptions.md +++ b/docs/framework/solid/reference/interfaces/UseBaseQueryOptions.md @@ -3,14 +3,14 @@ id: UseBaseQueryOptions title: UseBaseQueryOptions --- -Defined in: [types.ts:34](https://github.com/TanStack/query/blob/main/packages/solid-query/src/types.ts#L34) +Defined in: [packages/solid-query/src/types.ts:34](https://github.com/TanStack/query/blob/main/packages/solid-query/src/types.ts#L34) The options accepted by `useQuery`. Extends [QueryObserverOptions](QueryObserverOptions.md) from `@tanstack/query-core` with the `solid-query`-specific `deferStream` and `suspense` options. ## Extends -- `OmitKeyof`\<[`QueryObserverOptions`](QueryObserverOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryData`, `TQueryKey`\>, `"suspense"`\> +- [`OmitKeyof`](../type-aliases/OmitKeyof.md)\<[`QueryObserverOptions`](QueryObserverOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryData`, `TQueryKey`\>, `"suspense"`\> ## Extended by @@ -26,7 +26,7 @@ The type your `queryFn` resolves to. ### TError -`TError` = `DefaultError` +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) The type of errors your `queryFn` may throw. @@ -46,7 +46,7 @@ The type of the data actually held in the query cache — the input to `select` ### TQueryKey -`TQueryKey` *extends* `QueryKey` = `QueryKey` +`TQueryKey` *extends* [`QueryKey`](../type-aliases/QueryKey.md) = [`QueryKey`](../type-aliases/QueryKey.md) The type of your `queryKey`. @@ -58,7 +58,7 @@ The type of your `queryKey`. optional deferStream: boolean; ``` -Defined in: [types.ts:50](https://github.com/TanStack/query/blob/main/packages/solid-query/src/types.ts#L50) +Defined in: [packages/solid-query/src/types.ts:50](https://github.com/TanStack/query/blob/main/packages/solid-query/src/types.ts#L50) Only applicable while rendering queries on the server with streaming. Set `deferStream` to `true` to wait for the query to resolve on the server before flushing the stream. @@ -67,13 +67,346 @@ Defaults to `false`. *** +### enabled? + +```ts +optional enabled: QueryBooleanOption; +``` + +Defined in: [packages/query-core/src/types.ts:398](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L398) + +Set this to `false` or a function that returns `false` to disable automatic refetching when the query mounts or changes query keys. +To refetch the query, use the `refetch` method returned from the `useQuery` instance. +Accepts a boolean or function that returns a boolean. + +Defaults to `true`. + +#### Inherited from + +```ts +OmitKeyof.enabled +``` + +*** + +### gcTime? + +```ts +optional gcTime: number; +``` + +Defined in: [packages/query-core/src/types.ts:277](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L277) + +The time in milliseconds that unused/inactive cache data remains in memory. +When a query's cache becomes unused or inactive, that cache data will be garbage collected after this duration. +When different garbage collection times are specified, the longest one will be used. +Setting it to `Infinity` will disable garbage collection. + +Defaults to `5 * 60 * 1000` (5 minutes), or `Infinity` during SSR. + +Note: the maximum allowed time is about 24 days, imposed by `setTimeout`'s 32-bit signed integer delay — see +`timeoutManager.setTimeoutProvider` for a workaround. + +#### Inherited from + +[`QueryExecuteOptions`](QueryExecuteOptions.md).[`gcTime`](QueryExecuteOptions.md#gctime) + +*** + +### initialData? + +```ts +optional initialData: + | TQueryData +| InitialDataFunction; +``` + +Defined in: [packages/query-core/src/types.ts:317](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L317) + +If set, this value will be used as the initial data for the query cache (as long as the query hasn't been +created or cached yet). +If set to a function, the function will be called **once** during the shared/root query initialization, and be +expected to synchronously return the initial data. +Initial data is considered stale by default unless a `staleTime` has been set. +`initialData` **is persisted** to the cache. + +#### Inherited from + +```ts +OmitKeyof.initialData +``` + +*** + +### initialDataUpdatedAt? + +```ts +optional initialDataUpdatedAt: number | () => number | undefined; +``` + +Defined in: [packages/query-core/src/types.ts:321](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L321) + +If set, this value will be used as the time (in milliseconds) of when the `initialData` itself was last updated. + +#### Inherited from + +```ts +OmitKeyof.initialDataUpdatedAt +``` + +*** + +### maxPages? + +```ts +optional maxPages: number; +``` + +Defined in: [packages/query-core/src/types.ts:345](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L345) + +Maximum number of pages to store in the data of an infinite query. + +#### Inherited from + +[`QueryExecuteOptions`](QueryExecuteOptions.md).[`maxPages`](QueryExecuteOptions.md#maxpages) + +*** + +### meta? + +```ts +optional meta: Record; +``` + +Defined in: [packages/query-core/src/types.ts:341](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L341) + +Additional payload to be stored on each query. +Use this property to pass information that can be used in other places. + +#### Inherited from + +[`QueryExecuteOptions`](QueryExecuteOptions.md).[`meta`](QueryExecuteOptions.md#meta) + +*** + +### networkMode? + +```ts +optional networkMode: NetworkMode; +``` + +Defined in: [packages/query-core/src/types.ts:265](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L265) + +Controls whether a query is allowed to run based on the current network connectivity. + +Defaults to `'online'`. + +#### See + +[Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. + +#### Inherited from + +[`QueryExecuteOptions`](QueryExecuteOptions.md).[`networkMode`](QueryExecuteOptions.md#networkmode) + +*** + +### notifyOnChangeProps? + +```ts +optional notifyOnChangeProps: NotifyOnChangeProps; +``` + +Defined in: [packages/query-core/src/types.ts:484](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L484) + +If set, the component will only re-render if any of the listed properties change. +When set to `['data', 'error']`, the component will only re-render when the `data` or `error` properties change. +When set to `'all'`, the component will re-render whenever a query is updated. +When set to a function, the function will be executed to compute the list of properties. + +Defaults to `undefined`, in which case property access is tracked automatically, and the +component only re-renders when one of the tracked properties changes. + +#### Inherited from + +```ts +OmitKeyof.notifyOnChangeProps +``` + +*** + +### persister()? + +```ts +optional persister: (queryFn, context, query) => TQueryFnData | Promise; +``` + +Defined in: [packages/query-core/src/types.ts:290](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L290) + +This option can be used to persist the result of a query to an external storage, bypassing the need to actually +call the `queryFn`. Useful for persisting a query's data across e.g. server/client boundaries. + +#### Parameters + +##### queryFn + +[`QueryFunction`](../type-aliases/QueryFunction.md)\<`TQueryFnData`, `NoInfer`\<`TQueryKey`\>, `never`\> + +##### context + +###### client + +`QueryClient` + +###### direction? + +`unknown` + +**Deprecated** + +if you want access to the direction, you can add it to the pageParam + +###### meta + +`Record`\<`string`, `unknown`\> \| `undefined` + +###### pageParam? + +`unknown` + +###### queryKey + +`NoInfer`\<`TQueryKey`\> + +###### signal + +`AbortSignal` + +##### query + +[`Query`](../classes/Query.md) + +#### Returns + +`TQueryFnData` \| `Promise`\<`TQueryFnData`\> + +#### Inherited from + +```ts +OmitKeyof.persister +``` + +*** + +### placeholderData? + +```ts +optional placeholderData: + | NonFunctionGuard +| PlaceholderDataFunction, TError, NonFunctionGuard, TQueryKey>; +``` + +Defined in: [packages/query-core/src/types.ts:511](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L511) + +If set, this value will be used as the placeholder data for this particular query observer while the query is still in the `loading` data and no initialData has been provided. + +#### Inherited from + +```ts +OmitKeyof.placeholderData +``` + +*** + +### queryFn? + +```ts +optional queryFn: + | typeof skipToken +| QueryFunction; +``` + +Defined in: [packages/query-core/src/types.ts:285](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L285) + +The function that the query will use to request data. +Required, unless a default query function has been set via `queryClient.setQueryDefaults` or +`queryClient.setDefaultOptions`. +Receives a [QueryFunctionContext](../type-aliases/QueryFunctionContext.md). +Must return a promise that will either resolve data or throw an error. The data cannot be `undefined`. + +#### Inherited from + +```ts +OmitKeyof.queryFn +``` + +*** + +### queryHash? + +```ts +optional queryHash: string; +``` + +Defined in: [packages/query-core/src/types.ts:295](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L295) + +The hashed form of `queryKey`, computed with `queryKeyHashFn` (or the default hashing function otherwise). Used +as the actual cache key internally. + +#### Inherited from + +[`QueryExecuteOptions`](QueryExecuteOptions.md).[`queryHash`](QueryExecuteOptions.md#queryhash) + +*** + +### queryKey + +```ts +queryKey: TQueryKey & object; +``` + +Defined in: [packages/query-core/src/types.ts:304](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L304) + +The query key to use for this query. + +The query key will be hashed into a stable hash. See [Query Keys](https://tanstack.com/query/latest/docs/framework/react/guides/query-keys) +for more information. + +The query will automatically update when this key changes (as long as `enabled` is not set to `false`). + +#### Inherited from + +```ts +OmitKeyof.queryKey +``` + +*** + +### queryKeyHashFn? + +```ts +optional queryKeyHashFn: QueryKeyHashFunction; +``` + +Defined in: [packages/query-core/src/types.ts:308](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L308) + +If specified, this function is used to hash the `queryKey` to a string. + +#### Inherited from + +```ts +OmitKeyof.queryKeyHashFn +``` + +*** + ### reconcile? ```ts optional reconcile: string | false | (oldData, newData) => TData; ``` -Defined in: [QueryClient.ts:47](https://github.com/TanStack/query/blob/main/packages/solid-query/src/QueryClient.ts#L47) +Defined in: [packages/solid-query/src/QueryClient.ts:47](https://github.com/TanStack/query/blob/main/packages/solid-query/src/QueryClient.ts#L47) Set this to a reconciliation key to enable reconciliation between query results. Set this to `false` to disable reconciliation between query results. @@ -88,16 +421,273 @@ OmitKeyof.reconcile *** +### refetchInterval? + +```ts +optional refetchInterval: number | false | (query) => number | false | undefined; +``` + +Defined in: [packages/query-core/src/types.ts:414](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L414) + +If set to a number, the query will continuously refetch at this frequency in milliseconds. +If set to a function, the function will be executed with the latest data and query to compute a frequency + +Defaults to `false`. + +#### Inherited from + +```ts +OmitKeyof.refetchInterval +``` + +*** + +### refetchIntervalInBackground? + +```ts +optional refetchIntervalInBackground: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:425](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L425) + +If set to `true`, the query will continue to refetch while their tab/window is in the background. + +Defaults to `false`. + +#### Inherited from + +```ts +OmitKeyof.refetchIntervalInBackground +``` + +*** + +### refetchOnMount? + +```ts +optional refetchOnMount: boolean | "always" | (query) => boolean | "always"; +``` + +Defined in: [packages/query-core/src/types.ts:462](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L462) + +If set to `true`, the query will refetch on mount if the data is stale. +If set to `false`, will disable additional instances of a query to trigger background refetch. +If set to `'always'`, the query will always refetch on mount (except when `staleTime: 'static'` is used). +If set to a function, the function will be executed with the latest data and query to compute the value + +Defaults to `true`. + +#### Inherited from + +```ts +OmitKeyof.refetchOnMount +``` + +*** + +### refetchOnReconnect? + +```ts +optional refetchOnReconnect: boolean | "always" | (query) => boolean | "always"; +``` + +Defined in: [packages/query-core/src/types.ts:448](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L448) + +If set to `true`, the query will refetch on reconnect if the data is stale. +If set to `false`, the query will not refetch on reconnect. +If set to `'always'`, the query will always refetch on reconnect (except when `staleTime: 'static'` is used). +If set to a function, the function will be executed with the latest data and query to compute the value. + +Defaults to `true` unless `networkMode` is `'always'`. + +#### Inherited from + +```ts +OmitKeyof.refetchOnReconnect +``` + +*** + +### refetchOnWindowFocus? + +```ts +optional refetchOnWindowFocus: boolean | "always" | (query) => boolean | "always"; +``` + +Defined in: [packages/query-core/src/types.ts:434](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L434) + +If set to `true`, the query will refetch on window focus if the data is stale. +If set to `false`, the query will not refetch on window focus. +If set to `'always'`, the query will always refetch on window focus (except when `staleTime: 'static'` is used). +If set to a function, the function will be executed with the latest data and query to compute the value. + +Defaults to `true`. + +#### Inherited from + +```ts +OmitKeyof.refetchOnWindowFocus +``` + +*** + +### retry? + +```ts +optional retry: RetryValue; +``` + +Defined in: [packages/query-core/src/types.ts:246](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L246) + +If `false`, failed queries will not retry by default. +If `true`, failed queries will retry infinitely. +If set to an integer number, e.g. 3, failed queries will retry until the failed query count meets that number. +If set to a function `(failureCount, error) => boolean` failed queries will retry until the function returns false. + +Defaults to `3` on the client and `0` on the server. + +#### Inherited from + +```ts +OmitKeyof.retry +``` + +*** + +### retryDelay? + +```ts +optional retryDelay: RetryDelayValue; +``` + +Defined in: [packages/query-core/src/types.ts:258](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L258) + +This function receives a `retryAttempt` integer and the actual Error and returns the delay to apply before the +next attempt in milliseconds. + +A function like `attempt => Math.min(attempt > 1 ? 2 ** attempt * 1000 : 1000, 30 * 1000)` applies exponential +backoff. + +A function like `attempt => attempt * 1000` applies linear backoff. + +Defaults to a function that applies exponential backoff, capped at 30 seconds. + +#### Inherited from + +```ts +OmitKeyof.retryDelay +``` + +*** + +### retryOnMount? + +```ts +optional retryOnMount: QueryBooleanOption; +``` + +Defined in: [packages/query-core/src/types.ts:474](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L474) + +If set to `false`, the query will not be retried on mount if it contains an error. +If set to a function, the function will be executed with the query to compute the value. + +Defaults to `true`. + +#### Inherited from + +```ts +OmitKeyof.retryOnMount +``` + +*** + +### select()? + +```ts +optional select: (data) => TData; +``` + +Defined in: [packages/query-core/src/types.ts:500](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L500) + +This option can be used to transform or select a part of the data returned by the query function. It affects +the returned `data` value, but does not affect what gets stored in the query cache. +The `select` function will only run if `data` changed, or if the reference to the `select` function itself +changes. To optimize, memoize the function so its reference stays stable across calls. + +#### Parameters + +##### data + +`TQueryData` + +#### Returns + +`TData` + +#### Inherited from + +```ts +OmitKeyof.select +``` + +*** + +### staleTime? + +```ts +optional staleTime: StaleTimeFunction; +``` + +Defined in: [packages/query-core/src/types.ts:407](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L407) + +The time in milliseconds after data is considered stale. +If set to `Infinity`, the data will never be considered stale. +If set to `'static'`, the data will never be considered stale. +If set to a function, the function will be executed with the query to compute a `staleTime`. + +Defaults to `0`. + +#### Inherited from + +```ts +OmitKeyof.staleTime +``` + +*** + ### ~~suspense?~~ ```ts optional suspense: boolean; ``` -Defined in: [types.ts:56](https://github.com/TanStack/query/blob/main/packages/solid-query/src/types.ts#L56) +Defined in: [packages/solid-query/src/types.ts:56](https://github.com/TanStack/query/blob/main/packages/solid-query/src/types.ts#L56) #### Deprecated The `suspense` option has been deprecated in v5 and will be removed in the next major version. The `data` property on useQuery is a SolidJS resource and will automatically suspend when the data is loading. Setting `suspense` to `false` will be a no-op. + +*** + +### throwOnError? + +```ts +optional throwOnError: ThrowOnError; +``` + +Defined in: [packages/query-core/src/types.ts:493](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L493) + +Whether errors should be thrown instead of setting the `error` property. +If set to `true` or `suspense` is `true`, all errors will be thrown to the error boundary. +If set to `false` and `suspense` is `false`, errors are returned as state. +If set to a function, it will be passed the error and the query, and it should return a boolean indicating whether to show the error in an error boundary (`true`) or return the error as state (`false`). + +Defaults to `false`. + +#### Inherited from + +```ts +OmitKeyof.throwOnError +``` diff --git a/docs/framework/solid/reference/type-aliases/AnyDataTag.md b/docs/framework/solid/reference/type-aliases/AnyDataTag.md new file mode 100644 index 00000000000..d3d5e33bb3e --- /dev/null +++ b/docs/framework/solid/reference/type-aliases/AnyDataTag.md @@ -0,0 +1,30 @@ +--- +id: AnyDataTag +title: AnyDataTag +--- + +```ts +type AnyDataTag = object; +``` + +Defined in: [packages/query-core/src/types.ts:67](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L67) + +## Properties + +### \[dataTagErrorSymbol\] + +```ts +[dataTagErrorSymbol]: any; +``` + +Defined in: [packages/query-core/src/types.ts:69](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L69) + +*** + +### \[dataTagSymbol\] + +```ts +[dataTagSymbol]: any; +``` + +Defined in: [packages/query-core/src/types.ts:68](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L68) diff --git a/docs/framework/solid/reference/type-aliases/DataTag.md b/docs/framework/solid/reference/type-aliases/DataTag.md new file mode 100644 index 00000000000..904ca124464 --- /dev/null +++ b/docs/framework/solid/reference/type-aliases/DataTag.md @@ -0,0 +1,24 @@ +--- +id: DataTag +title: DataTag +--- + +```ts +type DataTag = TType extends AnyDataTag ? TType : TType & object; +``` + +Defined in: [packages/query-core/src/types.ts:71](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L71) + +## Type Parameters + +### TType + +`TType` + +### TValue + +`TValue` + +### TError + +`TError` = [`UnsetMarker`](UnsetMarker.md) diff --git a/docs/framework/solid/reference/type-aliases/DefaultError.md b/docs/framework/solid/reference/type-aliases/DefaultError.md new file mode 100644 index 00000000000..da9f615482f --- /dev/null +++ b/docs/framework/solid/reference/type-aliases/DefaultError.md @@ -0,0 +1,10 @@ +--- +id: DefaultError +title: DefaultError +--- + +```ts +type DefaultError = Register extends object ? TError : Error; +``` + +Defined in: [packages/query-core/src/types.ts:45](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L45) diff --git a/docs/framework/solid/reference/type-aliases/DefaultedInfiniteQueryObserverOptions.md b/docs/framework/solid/reference/type-aliases/DefaultedInfiniteQueryObserverOptions.md new file mode 100644 index 00000000000..82c7ddbb886 --- /dev/null +++ b/docs/framework/solid/reference/type-aliases/DefaultedInfiniteQueryObserverOptions.md @@ -0,0 +1,32 @@ +--- +id: DefaultedInfiniteQueryObserverOptions +title: DefaultedInfiniteQueryObserverOptions +--- + +```ts +type DefaultedInfiniteQueryObserverOptions = WithRequired, "throwOnError" | "refetchOnReconnect" | "queryHash">; +``` + +Defined in: [packages/query-core/src/types.ts:557](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L557) + +## Type Parameters + +### TQueryFnData + +`TQueryFnData` = `unknown` + +### TError + +`TError` = [`DefaultError`](DefaultError.md) + +### TData + +`TData` = `TQueryFnData` + +### TQueryKey + +`TQueryKey` *extends* [`QueryKey`](QueryKey.md) = [`QueryKey`](QueryKey.md) + +### TPageParam + +`TPageParam` = `unknown` diff --git a/docs/framework/solid/reference/type-aliases/DefaultedQueryObserverOptions.md b/docs/framework/solid/reference/type-aliases/DefaultedQueryObserverOptions.md new file mode 100644 index 00000000000..7687d8c24f6 --- /dev/null +++ b/docs/framework/solid/reference/type-aliases/DefaultedQueryObserverOptions.md @@ -0,0 +1,32 @@ +--- +id: DefaultedQueryObserverOptions +title: DefaultedQueryObserverOptions +--- + +```ts +type DefaultedQueryObserverOptions = WithRequired, "throwOnError" | "refetchOnReconnect" | "queryHash">; +``` + +Defined in: [packages/query-core/src/types.ts:528](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L528) + +## Type Parameters + +### TQueryFnData + +`TQueryFnData` = `unknown` + +### TError + +`TError` = [`DefaultError`](DefaultError.md) + +### TData + +`TData` = `TQueryFnData` + +### TQueryData + +`TQueryData` = `TQueryFnData` + +### TQueryKey + +`TQueryKey` *extends* [`QueryKey`](QueryKey.md) = [`QueryKey`](QueryKey.md) diff --git a/docs/framework/solid/reference/type-aliases/DefinedInfiniteQueryObserverResult.md b/docs/framework/solid/reference/type-aliases/DefinedInfiniteQueryObserverResult.md new file mode 100644 index 00000000000..38dac7cfe2b --- /dev/null +++ b/docs/framework/solid/reference/type-aliases/DefinedInfiniteQueryObserverResult.md @@ -0,0 +1,22 @@ +--- +id: DefinedInfiniteQueryObserverResult +title: DefinedInfiniteQueryObserverResult +--- + +```ts +type DefinedInfiniteQueryObserverResult = + | InfiniteQueryObserverRefetchErrorResult +| InfiniteQueryObserverSuccessResult; +``` + +Defined in: [packages/query-core/src/types.ts:1148](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1148) + +## Type Parameters + +### TData + +`TData` = `unknown` + +### TError + +`TError` = [`DefaultError`](DefaultError.md) diff --git a/docs/framework/solid/reference/type-aliases/DefinedInitialDataInfiniteOptions.md b/docs/framework/solid/reference/type-aliases/DefinedInitialDataInfiniteOptions.md index e01fb72d53a..bf0beab741b 100644 --- a/docs/framework/solid/reference/type-aliases/DefinedInitialDataInfiniteOptions.md +++ b/docs/framework/solid/reference/type-aliases/DefinedInitialDataInfiniteOptions.md @@ -7,7 +7,7 @@ title: DefinedInitialDataInfiniteOptions type DefinedInitialDataInfiniteOptions = Accessor & object>; ``` -Defined in: [infiniteQueryOptions.ts:48](https://github.com/TanStack/query/blob/main/packages/solid-query/src/infiniteQueryOptions.ts#L48) +Defined in: [packages/solid-query/src/infiniteQueryOptions.ts:48](https://github.com/TanStack/query/blob/main/packages/solid-query/src/infiniteQueryOptions.ts#L48) The options accepted by the `infiniteQueryOptions` overload selected when `initialData` is set — `data` is never `undefined`. @@ -22,20 +22,20 @@ The type of a single page, as your `queryFn` resolves it. ### TError -`TError` = `DefaultError` +`TError` = [`DefaultError`](DefaultError.md) The type of errors your `queryFn` may throw. ### TData -`TData` = `InfiniteData`\<`TQueryFnData`\> +`TData` = [`InfiniteData`](../interfaces/InfiniteData.md)\<`TQueryFnData`\> The type `data` ends up as after `select` runs — defaults to `InfiniteData`, the shape of all fetched pages plus their page params. ### TQueryKey -`TQueryKey` *extends* `QueryKey` = `QueryKey` +`TQueryKey` *extends* [`QueryKey`](QueryKey.md) = [`QueryKey`](QueryKey.md) The type of your `queryKey`. diff --git a/docs/framework/solid/reference/type-aliases/DefinedInitialDataOptions.md b/docs/framework/solid/reference/type-aliases/DefinedInitialDataOptions.md index 0a0a224bf42..5579090e80f 100644 --- a/docs/framework/solid/reference/type-aliases/DefinedInitialDataOptions.md +++ b/docs/framework/solid/reference/type-aliases/DefinedInitialDataOptions.md @@ -7,7 +7,7 @@ title: DefinedInitialDataOptions type DefinedInitialDataOptions = Accessor & object>; ``` -Defined in: [queryOptions.ts:40](https://github.com/TanStack/query/blob/main/packages/solid-query/src/queryOptions.ts#L40) +Defined in: [packages/solid-query/src/queryOptions.ts:40](https://github.com/TanStack/query/blob/main/packages/solid-query/src/queryOptions.ts#L40) The options accepted by the `queryOptions` overload selected when `initialData` is set — `data` is never `undefined`. @@ -22,7 +22,7 @@ The type your `queryFn` resolves to. ### TError -`TError` = `DefaultError` +`TError` = [`DefaultError`](DefaultError.md) The type of errors your `queryFn` may throw. @@ -34,6 +34,6 @@ The type `data` ends up as after `select` runs. ### TQueryKey -`TQueryKey` *extends* `QueryKey` = `QueryKey` +`TQueryKey` *extends* [`QueryKey`](QueryKey.md) = [`QueryKey`](QueryKey.md) The type of your `queryKey`. diff --git a/docs/framework/solid/reference/type-aliases/DefinedQueryObserverResult.md b/docs/framework/solid/reference/type-aliases/DefinedQueryObserverResult.md new file mode 100644 index 00000000000..ae77ddcc22d --- /dev/null +++ b/docs/framework/solid/reference/type-aliases/DefinedQueryObserverResult.md @@ -0,0 +1,22 @@ +--- +id: DefinedQueryObserverResult +title: DefinedQueryObserverResult +--- + +```ts +type DefinedQueryObserverResult = + | QueryObserverRefetchErrorResult +| QueryObserverSuccessResult; +``` + +Defined in: [packages/query-core/src/types.ts:987](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L987) + +## Type Parameters + +### TData + +`TData` = `unknown` + +### TError + +`TError` = [`DefaultError`](DefaultError.md) diff --git a/docs/framework/solid/reference/type-aliases/DefinedUseBaseQueryResult.md b/docs/framework/solid/reference/type-aliases/DefinedUseBaseQueryResult.md index b26b9bc63e3..1d7a5f4708e 100644 --- a/docs/framework/solid/reference/type-aliases/DefinedUseBaseQueryResult.md +++ b/docs/framework/solid/reference/type-aliases/DefinedUseBaseQueryResult.md @@ -7,7 +7,7 @@ title: DefinedUseBaseQueryResult type DefinedUseBaseQueryResult = DefinedQueryObserverResult; ``` -Defined in: [types.ts:131](https://github.com/TanStack/query/blob/main/packages/solid-query/src/types.ts#L131) +Defined in: [packages/solid-query/src/types.ts:131](https://github.com/TanStack/query/blob/main/packages/solid-query/src/types.ts#L131) The object `useQuery` returns when `initialData` guarantees `data` is never `undefined`. @@ -21,6 +21,6 @@ The type `data` ends up as, after `select` runs (if set). ### TError -`TError` = `DefaultError` +`TError` = [`DefaultError`](DefaultError.md) The type of errors this query may hold. diff --git a/docs/framework/solid/reference/type-aliases/DefinedUseInfiniteQueryResult.md b/docs/framework/solid/reference/type-aliases/DefinedUseInfiniteQueryResult.md index b854a75b36f..e3418a348e1 100644 --- a/docs/framework/solid/reference/type-aliases/DefinedUseInfiniteQueryResult.md +++ b/docs/framework/solid/reference/type-aliases/DefinedUseInfiniteQueryResult.md @@ -7,7 +7,7 @@ title: DefinedUseInfiniteQueryResult type DefinedUseInfiniteQueryResult = DefinedInfiniteQueryObserverResult; ``` -Defined in: [types.ts:227](https://github.com/TanStack/query/blob/main/packages/solid-query/src/types.ts#L227) +Defined in: [packages/solid-query/src/types.ts:227](https://github.com/TanStack/query/blob/main/packages/solid-query/src/types.ts#L227) The object `useInfiniteQuery` returns when `initialData` guarantees `data` is never `undefined`. @@ -21,6 +21,6 @@ The type `data` ends up as, after `select` runs (if set). ### TError -`TError` = `DefaultError` +`TError` = [`DefaultError`](DefaultError.md) The type of errors this query may hold. diff --git a/docs/framework/solid/reference/type-aliases/DefinedUseQueryResult.md b/docs/framework/solid/reference/type-aliases/DefinedUseQueryResult.md index c903601dd43..01c93853303 100644 --- a/docs/framework/solid/reference/type-aliases/DefinedUseQueryResult.md +++ b/docs/framework/solid/reference/type-aliases/DefinedUseQueryResult.md @@ -7,7 +7,7 @@ title: DefinedUseQueryResult type DefinedUseQueryResult = DefinedUseBaseQueryResult; ``` -Defined in: [types.ts:142](https://github.com/TanStack/query/blob/main/packages/solid-query/src/types.ts#L142) +Defined in: [packages/solid-query/src/types.ts:142](https://github.com/TanStack/query/blob/main/packages/solid-query/src/types.ts#L142) The object `useQuery` returns when `initialData` guarantees `data` is never `undefined`. @@ -21,6 +21,6 @@ The type `data` ends up as, after `select` runs (if set). ### TError -`TError` = `DefaultError` +`TError` = [`DefaultError`](DefaultError.md) The type of errors this query may hold. diff --git a/docs/framework/solid/reference/type-aliases/DistributiveOmit.md b/docs/framework/solid/reference/type-aliases/DistributiveOmit.md new file mode 100644 index 00000000000..33b87a5cd6e --- /dev/null +++ b/docs/framework/solid/reference/type-aliases/DistributiveOmit.md @@ -0,0 +1,20 @@ +--- +id: DistributiveOmit +title: DistributiveOmit +--- + +```ts +type DistributiveOmit = TObject extends any ? Omit : never; +``` + +Defined in: [packages/query-core/src/types.ts:14](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L14) + +## Type Parameters + +### TObject + +`TObject` + +### TKey + +`TKey` *extends* keyof `TObject` diff --git a/docs/framework/solid/reference/type-aliases/EnsureInfiniteQueryDataOptions.md b/docs/framework/solid/reference/type-aliases/EnsureInfiniteQueryDataOptions.md new file mode 100644 index 00000000000..7648331fca2 --- /dev/null +++ b/docs/framework/solid/reference/type-aliases/EnsureInfiniteQueryDataOptions.md @@ -0,0 +1,42 @@ +--- +id: EnsureInfiniteQueryDataOptions +title: EnsureInfiniteQueryDataOptions +--- + +```ts +type EnsureInfiniteQueryDataOptions = FetchInfiniteQueryOptions & object; +``` + +Defined in: [packages/query-core/src/types.ts:631](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L631) + +## Type Declaration + +### ~~revalidateIfStale?~~ + +```ts +optional revalidateIfStale: boolean; +``` + +## Type Parameters + +### TQueryFnData + +`TQueryFnData` = `unknown` + +### TError + +`TError` = [`DefaultError`](DefaultError.md) + +### TData + +`TData` = `TQueryFnData` + +### TQueryKey + +`TQueryKey` *extends* [`QueryKey`](QueryKey.md) = [`QueryKey`](QueryKey.md) + +### TPageParam + +`TPageParam` = `unknown` + +## Deprecated diff --git a/docs/framework/solid/reference/type-aliases/FetchInfiniteQueryOptions.md b/docs/framework/solid/reference/type-aliases/FetchInfiniteQueryOptions.md new file mode 100644 index 00000000000..d00a2455889 --- /dev/null +++ b/docs/framework/solid/reference/type-aliases/FetchInfiniteQueryOptions.md @@ -0,0 +1,34 @@ +--- +id: FetchInfiniteQueryOptions +title: FetchInfiniteQueryOptions +--- + +```ts +type FetchInfiniteQueryOptions = Omit, TQueryKey, TPageParam>, "initialPageParam"> & InitialPageParam & InfiniteQueryPages; +``` + +Defined in: [packages/query-core/src/types.ts:675](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L675) + +## Type Parameters + +### TQueryFnData + +`TQueryFnData` = `unknown` + +### TError + +`TError` = [`DefaultError`](DefaultError.md) + +### TData + +`TData` = `TQueryFnData` + +### TQueryKey + +`TQueryKey` *extends* [`QueryKey`](QueryKey.md) = [`QueryKey`](QueryKey.md) + +### TPageParam + +`TPageParam` = `unknown` + +## Deprecated diff --git a/docs/framework/solid/reference/type-aliases/FetchStatus.md b/docs/framework/solid/reference/type-aliases/FetchStatus.md new file mode 100644 index 00000000000..d50002355ca --- /dev/null +++ b/docs/framework/solid/reference/type-aliases/FetchStatus.md @@ -0,0 +1,10 @@ +--- +id: FetchStatus +title: FetchStatus +--- + +```ts +type FetchStatus = "fetching" | "paused" | "idle"; +``` + +Defined in: [packages/query-core/src/types.ts:762](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L762) diff --git a/docs/framework/solid/reference/type-aliases/GetNextPageParamFunction.md b/docs/framework/solid/reference/type-aliases/GetNextPageParamFunction.md new file mode 100644 index 00000000000..81d1a1544ab --- /dev/null +++ b/docs/framework/solid/reference/type-aliases/GetNextPageParamFunction.md @@ -0,0 +1,42 @@ +--- +id: GetNextPageParamFunction +title: GetNextPageParamFunction +--- + +```ts +type GetNextPageParamFunction = (lastPage, allPages, lastPageParam, allPageParams) => TPageParam | undefined | null; +``` + +Defined in: [packages/query-core/src/types.ts:203](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L203) + +## Type Parameters + +### TPageParam + +`TPageParam` + +### TQueryFnData + +`TQueryFnData` = `unknown` + +## Parameters + +### lastPage + +`TQueryFnData` + +### allPages + +`TQueryFnData`[] + +### lastPageParam + +`TPageParam` + +### allPageParams + +`TPageParam`[] + +## Returns + +`TPageParam` \| `undefined` \| `null` diff --git a/docs/framework/solid/reference/type-aliases/GetPreviousPageParamFunction.md b/docs/framework/solid/reference/type-aliases/GetPreviousPageParamFunction.md new file mode 100644 index 00000000000..5a6d9b93d7e --- /dev/null +++ b/docs/framework/solid/reference/type-aliases/GetPreviousPageParamFunction.md @@ -0,0 +1,42 @@ +--- +id: GetPreviousPageParamFunction +title: GetPreviousPageParamFunction +--- + +```ts +type GetPreviousPageParamFunction = (firstPage, allPages, firstPageParam, allPageParams) => TPageParam | undefined | null; +``` + +Defined in: [packages/query-core/src/types.ts:196](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L196) + +## Type Parameters + +### TPageParam + +`TPageParam` + +### TQueryFnData + +`TQueryFnData` = `unknown` + +## Parameters + +### firstPage + +`TQueryFnData` + +### allPages + +`TQueryFnData`[] + +### firstPageParam + +`TPageParam` + +### allPageParams + +`TPageParam`[] + +## Returns + +`TPageParam` \| `undefined` \| `null` diff --git a/docs/framework/solid/reference/type-aliases/InferDataFromTag.md b/docs/framework/solid/reference/type-aliases/InferDataFromTag.md new file mode 100644 index 00000000000..09a15ca4b1c --- /dev/null +++ b/docs/framework/solid/reference/type-aliases/InferDataFromTag.md @@ -0,0 +1,20 @@ +--- +id: InferDataFromTag +title: InferDataFromTag +--- + +```ts +type InferDataFromTag = TTaggedQueryKey extends DataTag ? TaggedValue : TQueryFnData; +``` + +Defined in: [packages/query-core/src/types.ts:90](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L90) + +## Type Parameters + +### TQueryFnData + +`TQueryFnData` + +### TTaggedQueryKey + +`TTaggedQueryKey` *extends* [`QueryKey`](QueryKey.md) diff --git a/docs/framework/solid/reference/type-aliases/InferErrorFromTag.md b/docs/framework/solid/reference/type-aliases/InferErrorFromTag.md new file mode 100644 index 00000000000..cd94e4b5c3f --- /dev/null +++ b/docs/framework/solid/reference/type-aliases/InferErrorFromTag.md @@ -0,0 +1,20 @@ +--- +id: InferErrorFromTag +title: InferErrorFromTag +--- + +```ts +type InferErrorFromTag = TTaggedQueryKey extends DataTag ? TaggedError extends UnsetMarker ? TError : TaggedError : TError; +``` + +Defined in: [packages/query-core/src/types.ts:95](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L95) + +## Type Parameters + +### TError + +`TError` + +### TTaggedQueryKey + +`TTaggedQueryKey` *extends* [`QueryKey`](QueryKey.md) diff --git a/docs/framework/solid/reference/type-aliases/InfiniteQueryExecuteOptions.md b/docs/framework/solid/reference/type-aliases/InfiniteQueryExecuteOptions.md new file mode 100644 index 00000000000..259c97c96bb --- /dev/null +++ b/docs/framework/solid/reference/type-aliases/InfiniteQueryExecuteOptions.md @@ -0,0 +1,32 @@ +--- +id: InfiniteQueryExecuteOptions +title: InfiniteQueryExecuteOptions +--- + +```ts +type InfiniteQueryExecuteOptions = Omit, TQueryKey, TPageParam>, "initialPageParam"> & InitialPageParam & InfiniteQueryPages; +``` + +Defined in: [packages/query-core/src/types.ts:654](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L654) + +## Type Parameters + +### TQueryFnData + +`TQueryFnData` = `unknown` + +### TError + +`TError` = [`DefaultError`](DefaultError.md) + +### TData + +`TData` = [`InfiniteData`](../interfaces/InfiniteData.md)\<`TQueryFnData`\> + +### TQueryKey + +`TQueryKey` *extends* [`QueryKey`](QueryKey.md) = [`QueryKey`](QueryKey.md) + +### TPageParam + +`TPageParam` = `unknown` diff --git a/docs/framework/solid/reference/type-aliases/InfiniteQueryObserverResult.md b/docs/framework/solid/reference/type-aliases/InfiniteQueryObserverResult.md new file mode 100644 index 00000000000..aa27563b9cd --- /dev/null +++ b/docs/framework/solid/reference/type-aliases/InfiniteQueryObserverResult.md @@ -0,0 +1,25 @@ +--- +id: InfiniteQueryObserverResult +title: InfiniteQueryObserverResult +--- + +```ts +type InfiniteQueryObserverResult = + | DefinedInfiniteQueryObserverResult + | InfiniteQueryObserverLoadingErrorResult + | InfiniteQueryObserverLoadingResult + | InfiniteQueryObserverPendingResult +| InfiniteQueryObserverPlaceholderResult; +``` + +Defined in: [packages/query-core/src/types.ts:1155](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1155) + +## Type Parameters + +### TData + +`TData` = `unknown` + +### TError + +`TError` = [`DefaultError`](DefaultError.md) diff --git a/docs/framework/solid/reference/type-aliases/InitialDataFunction.md b/docs/framework/solid/reference/type-aliases/InitialDataFunction.md new file mode 100644 index 00000000000..6ba4aaabe61 --- /dev/null +++ b/docs/framework/solid/reference/type-aliases/InitialDataFunction.md @@ -0,0 +1,20 @@ +--- +id: InitialDataFunction +title: InitialDataFunction +--- + +```ts +type InitialDataFunction = () => T | undefined; +``` + +Defined in: [packages/query-core/src/types.ts:173](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L173) + +## Type Parameters + +### T + +`T` + +## Returns + +`T` \| `undefined` diff --git a/docs/framework/solid/reference/type-aliases/ManagedTimerId.md b/docs/framework/solid/reference/type-aliases/ManagedTimerId.md new file mode 100644 index 00000000000..d7833e3e4f0 --- /dev/null +++ b/docs/framework/solid/reference/type-aliases/ManagedTimerId.md @@ -0,0 +1,19 @@ +--- +id: ManagedTimerId +title: ManagedTimerId +--- + +```ts +type ManagedTimerId = + | number + | { + [toPrimitive]: () => number; +}; +``` + +Defined in: [packages/query-core/src/timeoutManager.ts:17](https://github.com/TanStack/query/blob/main/packages/query-core/src/timeoutManager.ts#L17) + +Wrapping `setTimeout` is awkward from a typing perspective because platform +typings may extend the return type of `setTimeout`. For example, NodeJS +typings add `NodeJS.Timeout`; but a non-default `timeoutManager` may not be +able to return such a type. diff --git a/docs/framework/solid/reference/type-aliases/MutateFunction.md b/docs/framework/solid/reference/type-aliases/MutateFunction.md new file mode 100644 index 00000000000..e12b7a80291 --- /dev/null +++ b/docs/framework/solid/reference/type-aliases/MutateFunction.md @@ -0,0 +1,38 @@ +--- +id: MutateFunction +title: MutateFunction +--- + +```ts +type MutateFunction = (...rest) => Promise; +``` + +Defined in: [packages/query-core/src/types.ts:1326](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1326) + +## Type Parameters + +### TData + +`TData` = `unknown` + +### TError + +`TError` = [`DefaultError`](DefaultError.md) + +### TVariables + +`TVariables` = `void` + +### TOnMutateResult + +`TOnMutateResult` = `unknown` + +## Parameters + +### rest + +...[`MutateFunctionRest`](MutateFunctionRest.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\> + +## Returns + +`Promise`\<`TData`\> diff --git a/docs/framework/solid/reference/type-aliases/MutateFunctionRest.md b/docs/framework/solid/reference/type-aliases/MutateFunctionRest.md new file mode 100644 index 00000000000..3902f1082f9 --- /dev/null +++ b/docs/framework/solid/reference/type-aliases/MutateFunctionRest.md @@ -0,0 +1,28 @@ +--- +id: MutateFunctionRest +title: MutateFunctionRest +--- + +```ts +type MutateFunctionRest = undefined extends TVariables ? [TVariables, MutateOptions] : [TVariables, MutateOptions]; +``` + +Defined in: [packages/query-core/src/types.ts:1311](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1311) + +## Type Parameters + +### TData + +`TData` = `unknown` + +### TError + +`TError` = [`DefaultError`](DefaultError.md) + +### TVariables + +`TVariables` = `void` + +### TOnMutateResult + +`TOnMutateResult` = `unknown` diff --git a/docs/framework/solid/reference/type-aliases/MutationCacheNotifyEvent.md b/docs/framework/solid/reference/type-aliases/MutationCacheNotifyEvent.md new file mode 100644 index 00000000000..aa5e196bc72 --- /dev/null +++ b/docs/framework/solid/reference/type-aliases/MutationCacheNotifyEvent.md @@ -0,0 +1,20 @@ +--- +id: MutationCacheNotifyEvent +title: MutationCacheNotifyEvent +--- + +```ts +type MutationCacheNotifyEvent = + | NotifyEventMutationAdded + | NotifyEventMutationRemoved + | NotifyEventMutationObserverAdded + | NotifyEventMutationObserverRemoved + | NotifyEventMutationObserverOptionsUpdated + | NotifyEventMutationUpdated; +``` + +Defined in: [packages/query-core/src/mutationCache.ts:98](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationCache.ts#L98) + +The event passed to a `MutationCache` subscriber. Fired whenever a mutation is added or removed +from the cache, its state is updated, or one of its observers is added, removed, or has its +options updated. diff --git a/docs/framework/solid/reference/type-aliases/MutationFunction.md b/docs/framework/solid/reference/type-aliases/MutationFunction.md new file mode 100644 index 00000000000..9bafb3db56b --- /dev/null +++ b/docs/framework/solid/reference/type-aliases/MutationFunction.md @@ -0,0 +1,34 @@ +--- +id: MutationFunction +title: MutationFunction +--- + +```ts +type MutationFunction = (variables, context) => Promise; +``` + +Defined in: [packages/query-core/src/types.ts:1195](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1195) + +## Type Parameters + +### TData + +`TData` = `unknown` + +### TVariables + +`TVariables` = `unknown` + +## Parameters + +### variables + +`TVariables` + +### context + +[`MutationFunctionContext`](MutationFunctionContext.md) + +## Returns + +`Promise`\<`TData`\> diff --git a/docs/framework/solid/reference/type-aliases/MutationFunctionContext.md b/docs/framework/solid/reference/type-aliases/MutationFunctionContext.md new file mode 100644 index 00000000000..0207256c702 --- /dev/null +++ b/docs/framework/solid/reference/type-aliases/MutationFunctionContext.md @@ -0,0 +1,40 @@ +--- +id: MutationFunctionContext +title: MutationFunctionContext +--- + +```ts +type MutationFunctionContext = object; +``` + +Defined in: [packages/query-core/src/types.ts:1189](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1189) + +## Properties + +### client + +```ts +client: QueryClient; +``` + +Defined in: [packages/query-core/src/types.ts:1190](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1190) + +*** + +### meta + +```ts +meta: MutationMeta | undefined; +``` + +Defined in: [packages/query-core/src/types.ts:1191](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1191) + +*** + +### mutationKey? + +```ts +optional mutationKey: MutationKey; +``` + +Defined in: [packages/query-core/src/types.ts:1192](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1192) diff --git a/docs/framework/solid/reference/type-aliases/MutationKey.md b/docs/framework/solid/reference/type-aliases/MutationKey.md new file mode 100644 index 00000000000..9d1d7f0f77b --- /dev/null +++ b/docs/framework/solid/reference/type-aliases/MutationKey.md @@ -0,0 +1,10 @@ +--- +id: MutationKey +title: MutationKey +--- + +```ts +type MutationKey = Register extends object ? TMutationKey extends ReadonlyArray ? TMutationKey : TMutationKey extends unknown[] ? TMutationKey : ReadonlyArray : ReadonlyArray; +``` + +Defined in: [packages/query-core/src/types.ts:1165](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1165) diff --git a/docs/framework/solid/reference/type-aliases/MutationMeta.md b/docs/framework/solid/reference/type-aliases/MutationMeta.md new file mode 100644 index 00000000000..ff1f9b4bf94 --- /dev/null +++ b/docs/framework/solid/reference/type-aliases/MutationMeta.md @@ -0,0 +1,10 @@ +--- +id: MutationMeta +title: MutationMeta +--- + +```ts +type MutationMeta = Register extends object ? TMutationMeta extends Record ? TMutationMeta : Record : Record; +``` + +Defined in: [packages/query-core/src/types.ts:1181](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1181) diff --git a/docs/framework/solid/reference/type-aliases/MutationObserverResult.md b/docs/framework/solid/reference/type-aliases/MutationObserverResult.md new file mode 100644 index 00000000000..c21fc3ac591 --- /dev/null +++ b/docs/framework/solid/reference/type-aliases/MutationObserverResult.md @@ -0,0 +1,32 @@ +--- +id: MutationObserverResult +title: MutationObserverResult +--- + +```ts +type MutationObserverResult = + | MutationObserverIdleResult + | MutationObserverLoadingResult + | MutationObserverErrorResult +| MutationObserverSuccessResult; +``` + +Defined in: [packages/query-core/src/types.ts:1484](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1484) + +## Type Parameters + +### TData + +`TData` = `unknown` + +### TError + +`TError` = [`DefaultError`](DefaultError.md) + +### TVariables + +`TVariables` = `void` + +### TOnMutateResult + +`TOnMutateResult` = `unknown` diff --git a/docs/framework/solid/reference/type-aliases/MutationScope.md b/docs/framework/solid/reference/type-aliases/MutationScope.md new file mode 100644 index 00000000000..1d6a91bd434 --- /dev/null +++ b/docs/framework/solid/reference/type-aliases/MutationScope.md @@ -0,0 +1,20 @@ +--- +id: MutationScope +title: MutationScope +--- + +```ts +type MutationScope = object; +``` + +Defined in: [packages/query-core/src/types.ts:1177](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1177) + +## Properties + +### id + +```ts +id: string; +``` + +Defined in: [packages/query-core/src/types.ts:1178](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1178) diff --git a/docs/framework/solid/reference/type-aliases/MutationStatus.md b/docs/framework/solid/reference/type-aliases/MutationStatus.md new file mode 100644 index 00000000000..cf12d3d3ee3 --- /dev/null +++ b/docs/framework/solid/reference/type-aliases/MutationStatus.md @@ -0,0 +1,10 @@ +--- +id: MutationStatus +title: MutationStatus +--- + +```ts +type MutationStatus = "idle" | "pending" | "success" | "error"; +``` + +Defined in: [packages/query-core/src/types.ts:1175](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1175) diff --git a/docs/framework/solid/reference/type-aliases/NetworkMode.md b/docs/framework/solid/reference/type-aliases/NetworkMode.md new file mode 100644 index 00000000000..94ae0ba76ed --- /dev/null +++ b/docs/framework/solid/reference/type-aliases/NetworkMode.md @@ -0,0 +1,10 @@ +--- +id: NetworkMode +title: NetworkMode +--- + +```ts +type NetworkMode = "online" | "always" | "offlineFirst"; +``` + +Defined in: [packages/query-core/src/types.ts:223](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L223) diff --git a/docs/framework/solid/reference/type-aliases/NonUndefinedGuard.md b/docs/framework/solid/reference/type-aliases/NonUndefinedGuard.md new file mode 100644 index 00000000000..4aaf208013b --- /dev/null +++ b/docs/framework/solid/reference/type-aliases/NonUndefinedGuard.md @@ -0,0 +1,16 @@ +--- +id: NonUndefinedGuard +title: NonUndefinedGuard +--- + +```ts +type NonUndefinedGuard = T extends undefined ? never : T; +``` + +Defined in: [packages/query-core/src/types.ts:12](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L12) + +## Type Parameters + +### T + +`T` diff --git a/docs/framework/solid/reference/type-aliases/NotifyEventType.md b/docs/framework/solid/reference/type-aliases/NotifyEventType.md new file mode 100644 index 00000000000..ffa60b016e3 --- /dev/null +++ b/docs/framework/solid/reference/type-aliases/NotifyEventType.md @@ -0,0 +1,17 @@ +--- +id: NotifyEventType +title: NotifyEventType +--- + +```ts +type NotifyEventType = + | "added" + | "removed" + | "updated" + | "observerAdded" + | "observerRemoved" + | "observerResultsUpdated" + | "observerOptionsUpdated"; +``` + +Defined in: [packages/query-core/src/types.ts:1530](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1530) diff --git a/docs/framework/solid/reference/type-aliases/NotifyOnChangeProps.md b/docs/framework/solid/reference/type-aliases/NotifyOnChangeProps.md new file mode 100644 index 00000000000..7de194fa10b --- /dev/null +++ b/docs/framework/solid/reference/type-aliases/NotifyOnChangeProps.md @@ -0,0 +1,17 @@ +--- +id: NotifyOnChangeProps +title: NotifyOnChangeProps +--- + +```ts +type NotifyOnChangeProps = + | keyof InfiniteQueryObserverResult[] + | "all" + | undefined + | () => + | keyof InfiniteQueryObserverResult[] + | "all" + | undefined; +``` + +Defined in: [packages/query-core/src/types.ts:225](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L225) diff --git a/docs/framework/solid/reference/type-aliases/OmitKeyof.md b/docs/framework/solid/reference/type-aliases/OmitKeyof.md new file mode 100644 index 00000000000..690a7b0a5d2 --- /dev/null +++ b/docs/framework/solid/reference/type-aliases/OmitKeyof.md @@ -0,0 +1,28 @@ +--- +id: OmitKeyof +title: OmitKeyof +--- + +```ts +type OmitKeyof = Omit; +``` + +Defined in: [packages/query-core/src/types.ts:19](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L19) + +## Type Parameters + +### TObject + +`TObject` + +### TKey + +`TKey` *extends* `TStrictly` *extends* `"safely"` ? + \| keyof `TObject` + \| `string` & `Record`\<`never`, `never`\> + \| `number` & `Record`\<`never`, `never`\> + \| `symbol` & `Record`\<`never`, `never`\> : keyof `TObject` + +### TStrictly + +`TStrictly` *extends* `"strictly"` \| `"safely"` = `"strictly"` diff --git a/docs/framework/solid/reference/type-aliases/Override.md b/docs/framework/solid/reference/type-aliases/Override.md new file mode 100644 index 00000000000..8abcecd1e1b --- /dev/null +++ b/docs/framework/solid/reference/type-aliases/Override.md @@ -0,0 +1,20 @@ +--- +id: Override +title: Override +--- + +```ts +type Override = { [AKey in keyof TTargetA]: AKey extends keyof TTargetB ? TTargetB[AKey] : TTargetA[AKey] }; +``` + +Defined in: [packages/query-core/src/types.ts:31](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L31) + +## Type Parameters + +### TTargetA + +`TTargetA` + +### TTargetB + +`TTargetB` diff --git a/docs/framework/solid/reference/type-aliases/PlaceholderDataFunction.md b/docs/framework/solid/reference/type-aliases/PlaceholderDataFunction.md new file mode 100644 index 00000000000..cd40f28b41e --- /dev/null +++ b/docs/framework/solid/reference/type-aliases/PlaceholderDataFunction.md @@ -0,0 +1,42 @@ +--- +id: PlaceholderDataFunction +title: PlaceholderDataFunction +--- + +```ts +type PlaceholderDataFunction = (previousData, previousQuery) => TQueryData | undefined; +``` + +Defined in: [packages/query-core/src/types.ts:177](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L177) + +## Type Parameters + +### TQueryFnData + +`TQueryFnData` = `unknown` + +### TError + +`TError` = [`DefaultError`](DefaultError.md) + +### TQueryData + +`TQueryData` = `TQueryFnData` + +### TQueryKey + +`TQueryKey` *extends* [`QueryKey`](QueryKey.md) = [`QueryKey`](QueryKey.md) + +## Parameters + +### previousData + +`TQueryData` | `undefined` + +### previousQuery + +[`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryData`, `TQueryKey`\> | `undefined` + +## Returns + +`TQueryData` \| `undefined` diff --git a/docs/framework/solid/reference/type-aliases/QueriesPlaceholderDataFunction.md b/docs/framework/solid/reference/type-aliases/QueriesPlaceholderDataFunction.md new file mode 100644 index 00000000000..5d3fca8c9e0 --- /dev/null +++ b/docs/framework/solid/reference/type-aliases/QueriesPlaceholderDataFunction.md @@ -0,0 +1,30 @@ +--- +id: QueriesPlaceholderDataFunction +title: QueriesPlaceholderDataFunction +--- + +```ts +type QueriesPlaceholderDataFunction = (previousData, previousQuery) => TQueryData | undefined; +``` + +Defined in: [packages/query-core/src/types.ts:187](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L187) + +## Type Parameters + +### TQueryData + +`TQueryData` + +## Parameters + +### previousData + +`undefined` + +### previousQuery + +`undefined` + +## Returns + +`TQueryData` \| `undefined` diff --git a/docs/framework/solid/reference/type-aliases/QueryBooleanOption.md b/docs/framework/solid/reference/type-aliases/QueryBooleanOption.md new file mode 100644 index 00000000000..9759e3ddb42 --- /dev/null +++ b/docs/framework/solid/reference/type-aliases/QueryBooleanOption.md @@ -0,0 +1,28 @@ +--- +id: QueryBooleanOption +title: QueryBooleanOption +--- + +```ts +type QueryBooleanOption = boolean | (query) => boolean; +``` + +Defined in: [packages/query-core/src/types.ts:119](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L119) + +## Type Parameters + +### TQueryFnData + +`TQueryFnData` = `unknown` + +### TError + +`TError` = [`DefaultError`](DefaultError.md) + +### TData + +`TData` = `TQueryFnData` + +### TQueryKey + +`TQueryKey` *extends* [`QueryKey`](QueryKey.md) = [`QueryKey`](QueryKey.md) diff --git a/docs/framework/solid/reference/type-aliases/QueryCacheNotifyEvent.md b/docs/framework/solid/reference/type-aliases/QueryCacheNotifyEvent.md new file mode 100644 index 00000000000..b92c76fb826 --- /dev/null +++ b/docs/framework/solid/reference/type-aliases/QueryCacheNotifyEvent.md @@ -0,0 +1,21 @@ +--- +id: QueryCacheNotifyEvent +title: QueryCacheNotifyEvent +--- + +```ts +type QueryCacheNotifyEvent = + | NotifyEventQueryAdded + | NotifyEventQueryRemoved + | NotifyEventQueryUpdated + | NotifyEventQueryObserverAdded + | NotifyEventQueryObserverRemoved + | NotifyEventQueryObserverResultsUpdated + | NotifyEventQueryObserverOptionsUpdated; +``` + +Defined in: [packages/query-core/src/queryCache.ts:85](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryCache.ts#L85) + +The event passed to a `QueryCache` subscriber. Fired whenever a query is added or removed from +the cache, its state is updated (e.g. via `query.setState` or `queryClient.removeQueries`), or +one of its observers is added, removed, or has its results or options updated. diff --git a/docs/framework/solid/reference/type-aliases/QueryClientProviderProps.md b/docs/framework/solid/reference/type-aliases/QueryClientProviderProps.md index 9aa87546767..cd42ea26950 100644 --- a/docs/framework/solid/reference/type-aliases/QueryClientProviderProps.md +++ b/docs/framework/solid/reference/type-aliases/QueryClientProviderProps.md @@ -7,7 +7,7 @@ title: QueryClientProviderProps type QueryClientProviderProps = object; ``` -Defined in: [QueryClientProvider.tsx:63](https://github.com/TanStack/query/blob/main/packages/solid-query/src/QueryClientProvider.tsx#L63) +Defined in: [packages/solid-query/src/QueryClientProvider.tsx:63](https://github.com/TanStack/query/blob/main/packages/solid-query/src/QueryClientProvider.tsx#L63) The props accepted by `QueryClientProvider`. @@ -19,7 +19,7 @@ The props accepted by `QueryClientProvider`. optional children: JSX.Element; ``` -Defined in: [QueryClientProvider.tsx:73](https://github.com/TanStack/query/blob/main/packages/solid-query/src/QueryClientProvider.tsx#L73) +Defined in: [packages/solid-query/src/QueryClientProvider.tsx:73](https://github.com/TanStack/query/blob/main/packages/solid-query/src/QueryClientProvider.tsx#L73) The components that get access to the provided `QueryClient`. @@ -31,7 +31,7 @@ The components that get access to the provided `QueryClient`. client: QueryClient; ``` -Defined in: [QueryClientProvider.tsx:69](https://github.com/TanStack/query/blob/main/packages/solid-query/src/QueryClientProvider.tsx#L69) +Defined in: [packages/solid-query/src/QueryClientProvider.tsx:69](https://github.com/TanStack/query/blob/main/packages/solid-query/src/QueryClientProvider.tsx#L69) **Required** diff --git a/docs/framework/solid/reference/type-aliases/QueryFunction.md b/docs/framework/solid/reference/type-aliases/QueryFunction.md new file mode 100644 index 00000000000..306367388a1 --- /dev/null +++ b/docs/framework/solid/reference/type-aliases/QueryFunction.md @@ -0,0 +1,34 @@ +--- +id: QueryFunction +title: QueryFunction +--- + +```ts +type QueryFunction = (context) => T | Promise; +``` + +Defined in: [packages/query-core/src/types.ts:102](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L102) + +## Type Parameters + +### T + +`T` = `unknown` + +### TQueryKey + +`TQueryKey` *extends* [`QueryKey`](QueryKey.md) = [`QueryKey`](QueryKey.md) + +### TPageParam + +`TPageParam` = `never` + +## Parameters + +### context + +[`QueryFunctionContext`](QueryFunctionContext.md)\<`TQueryKey`, `TPageParam`\> + +## Returns + +`T` \| `Promise`\<`T`\> diff --git a/docs/framework/solid/reference/type-aliases/QueryFunctionContext.md b/docs/framework/solid/reference/type-aliases/QueryFunctionContext.md new file mode 100644 index 00000000000..d2c9fe3e2b2 --- /dev/null +++ b/docs/framework/solid/reference/type-aliases/QueryFunctionContext.md @@ -0,0 +1,20 @@ +--- +id: QueryFunctionContext +title: QueryFunctionContext +--- + +```ts +type QueryFunctionContext = [TPageParam] extends [never] ? object : object; +``` + +Defined in: [packages/query-core/src/types.ts:144](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L144) + +## Type Parameters + +### TQueryKey + +`TQueryKey` *extends* [`QueryKey`](QueryKey.md) = [`QueryKey`](QueryKey.md) + +### TPageParam + +`TPageParam` = `never` diff --git a/docs/framework/solid/reference/type-aliases/QueryKey.md b/docs/framework/solid/reference/type-aliases/QueryKey.md new file mode 100644 index 00000000000..1a3f34cde18 --- /dev/null +++ b/docs/framework/solid/reference/type-aliases/QueryKey.md @@ -0,0 +1,10 @@ +--- +id: QueryKey +title: QueryKey +--- + +```ts +type QueryKey = Register extends object ? TQueryKey extends ReadonlyArray ? TQueryKey : TQueryKey extends unknown[] ? TQueryKey : ReadonlyArray : ReadonlyArray; +``` + +Defined in: [packages/query-core/src/types.ts:51](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L51) diff --git a/docs/framework/solid/reference/type-aliases/QueryKeyHashFunction.md b/docs/framework/solid/reference/type-aliases/QueryKeyHashFunction.md new file mode 100644 index 00000000000..feda96373cc --- /dev/null +++ b/docs/framework/solid/reference/type-aliases/QueryKeyHashFunction.md @@ -0,0 +1,26 @@ +--- +id: QueryKeyHashFunction +title: QueryKeyHashFunction +--- + +```ts +type QueryKeyHashFunction = (queryKey) => string; +``` + +Defined in: [packages/query-core/src/types.ts:192](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L192) + +## Type Parameters + +### TQueryKey + +`TQueryKey` *extends* [`QueryKey`](QueryKey.md) + +## Parameters + +### queryKey + +`TQueryKey` + +## Returns + +`string` diff --git a/docs/framework/solid/reference/type-aliases/QueryKeyWithDataTag.md b/docs/framework/solid/reference/type-aliases/QueryKeyWithDataTag.md new file mode 100644 index 00000000000..6613f74be9e --- /dev/null +++ b/docs/framework/solid/reference/type-aliases/QueryKeyWithDataTag.md @@ -0,0 +1,34 @@ +--- +id: QueryKeyWithDataTag +title: QueryKeyWithDataTag +--- + +```ts +type QueryKeyWithDataTag = object; +``` + +Defined in: [packages/query-core/src/types.ts:82](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L82) + +## Type Parameters + +### TQueryKey + +`TQueryKey` *extends* [`QueryKey`](QueryKey.md) = [`QueryKey`](QueryKey.md) + +### TQueryFnData + +`TQueryFnData` = `unknown` + +### TError + +`TError` = [`DefaultError`](DefaultError.md) + +## Properties + +### queryKey + +```ts +queryKey: DataTag; +``` + +Defined in: [packages/query-core/src/types.ts:87](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L87) diff --git a/docs/framework/solid/reference/type-aliases/QueryMeta.md b/docs/framework/solid/reference/type-aliases/QueryMeta.md new file mode 100644 index 00000000000..c12917b2cce --- /dev/null +++ b/docs/framework/solid/reference/type-aliases/QueryMeta.md @@ -0,0 +1,10 @@ +--- +id: QueryMeta +title: QueryMeta +--- + +```ts +type QueryMeta = Register extends object ? TQueryMeta extends Record ? TQueryMeta : Record : Record; +``` + +Defined in: [packages/query-core/src/types.ts:215](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L215) diff --git a/docs/framework/solid/reference/type-aliases/QueryObserverResult.md b/docs/framework/solid/reference/type-aliases/QueryObserverResult.md new file mode 100644 index 00000000000..5138b635f2c --- /dev/null +++ b/docs/framework/solid/reference/type-aliases/QueryObserverResult.md @@ -0,0 +1,25 @@ +--- +id: QueryObserverResult +title: QueryObserverResult +--- + +```ts +type QueryObserverResult = + | DefinedQueryObserverResult + | QueryObserverLoadingErrorResult + | QueryObserverLoadingResult + | QueryObserverPendingResult +| QueryObserverPlaceholderResult; +``` + +Defined in: [packages/query-core/src/types.ts:994](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L994) + +## Type Parameters + +### TData + +`TData` = `unknown` + +### TError + +`TError` = [`DefaultError`](DefaultError.md) diff --git a/docs/framework/solid/reference/type-aliases/QueryPersister.md b/docs/framework/solid/reference/type-aliases/QueryPersister.md new file mode 100644 index 00000000000..72e80165b0d --- /dev/null +++ b/docs/framework/solid/reference/type-aliases/QueryPersister.md @@ -0,0 +1,24 @@ +--- +id: QueryPersister +title: QueryPersister +--- + +```ts +type QueryPersister = [TPageParam] extends [never] ? (queryFn, context, query) => T | Promise : (queryFn, context, query) => T | Promise; +``` + +Defined in: [packages/query-core/src/types.ts:128](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L128) + +## Type Parameters + +### T + +`T` = `unknown` + +### TQueryKey + +`TQueryKey` *extends* [`QueryKey`](QueryKey.md) = [`QueryKey`](QueryKey.md) + +### TPageParam + +`TPageParam` = `never` diff --git a/docs/framework/solid/reference/type-aliases/QueryStatus.md b/docs/framework/solid/reference/type-aliases/QueryStatus.md new file mode 100644 index 00000000000..bab00f6f423 --- /dev/null +++ b/docs/framework/solid/reference/type-aliases/QueryStatus.md @@ -0,0 +1,10 @@ +--- +id: QueryStatus +title: QueryStatus +--- + +```ts +type QueryStatus = "pending" | "error" | "success"; +``` + +Defined in: [packages/query-core/src/types.ts:761](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L761) diff --git a/docs/framework/solid/reference/type-aliases/SkipToken.md b/docs/framework/solid/reference/type-aliases/SkipToken.md new file mode 100644 index 00000000000..3a5791b982e --- /dev/null +++ b/docs/framework/solid/reference/type-aliases/SkipToken.md @@ -0,0 +1,12 @@ +--- +id: SkipToken +title: SkipToken +--- + +```ts +type SkipToken = typeof skipToken; +``` + +Defined in: [packages/query-core/src/utils.ts:526](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L526) + +The type of the [skipToken](../variables/skipToken.md) sentinel value. diff --git a/docs/framework/solid/reference/type-aliases/StaleTime.md b/docs/framework/solid/reference/type-aliases/StaleTime.md new file mode 100644 index 00000000000..3e7e21608be --- /dev/null +++ b/docs/framework/solid/reference/type-aliases/StaleTime.md @@ -0,0 +1,10 @@ +--- +id: StaleTime +title: StaleTime +--- + +```ts +type StaleTime = number | "static"; +``` + +Defined in: [packages/query-core/src/types.ts:108](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L108) diff --git a/docs/framework/solid/reference/type-aliases/StaleTimeFunction.md b/docs/framework/solid/reference/type-aliases/StaleTimeFunction.md new file mode 100644 index 00000000000..b1c541fa64e --- /dev/null +++ b/docs/framework/solid/reference/type-aliases/StaleTimeFunction.md @@ -0,0 +1,28 @@ +--- +id: StaleTimeFunction +title: StaleTimeFunction +--- + +```ts +type StaleTimeFunction = StaleTime | (query) => StaleTime; +``` + +Defined in: [packages/query-core/src/types.ts:110](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L110) + +## Type Parameters + +### TQueryFnData + +`TQueryFnData` = `unknown` + +### TError + +`TError` = [`DefaultError`](DefaultError.md) + +### TData + +`TData` = `TQueryFnData` + +### TQueryKey + +`TQueryKey` *extends* [`QueryKey`](QueryKey.md) = [`QueryKey`](QueryKey.md) diff --git a/docs/framework/solid/reference/type-aliases/ThrowOnError.md b/docs/framework/solid/reference/type-aliases/ThrowOnError.md new file mode 100644 index 00000000000..134683388ef --- /dev/null +++ b/docs/framework/solid/reference/type-aliases/ThrowOnError.md @@ -0,0 +1,28 @@ +--- +id: ThrowOnError +title: ThrowOnError +--- + +```ts +type ThrowOnError = boolean | (error, query) => boolean; +``` + +Defined in: [packages/query-core/src/types.ts:368](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L368) + +## Type Parameters + +### TQueryFnData + +`TQueryFnData` + +### TError + +`TError` + +### TQueryData + +`TQueryData` + +### TQueryKey + +`TQueryKey` *extends* [`QueryKey`](QueryKey.md) diff --git a/docs/framework/solid/reference/type-aliases/TimeoutCallback.md b/docs/framework/solid/reference/type-aliases/TimeoutCallback.md new file mode 100644 index 00000000000..773b5fdaeb9 --- /dev/null +++ b/docs/framework/solid/reference/type-aliases/TimeoutCallback.md @@ -0,0 +1,27 @@ +--- +id: TimeoutCallback +title: TimeoutCallback +--- + +```ts +type TimeoutCallback = (_) => void; +``` + +Defined in: [packages/query-core/src/timeoutManager.ts:9](https://github.com/TanStack/query/blob/main/packages/query-core/src/timeoutManager.ts#L9) + +[TimeoutManager](../interfaces/TimeoutManager.md) does not support passing arguments to the callback. + +`(_: void)` is the argument type inferred by TypeScript's default typings for +`setTimeout(cb, number)`. +If we don't accept a single void argument, then +`new Promise(resolve => timeoutManager.setTimeout(resolve, N))` is a type error. + +## Parameters + +### \_ + +`void` + +## Returns + +`void` diff --git a/docs/framework/solid/reference/type-aliases/TimeoutProvider.md b/docs/framework/solid/reference/type-aliases/TimeoutProvider.md new file mode 100644 index 00000000000..3509105bcd1 --- /dev/null +++ b/docs/framework/solid/reference/type-aliases/TimeoutProvider.md @@ -0,0 +1,112 @@ +--- +id: TimeoutProvider +title: TimeoutProvider +--- + +```ts +type TimeoutProvider = object; +``` + +Defined in: [packages/query-core/src/timeoutManager.ts:28](https://github.com/TanStack/query/blob/main/packages/query-core/src/timeoutManager.ts#L28) + +Backend for timer functions. + +Timers are performance-sensitive: short-lived timers (delays under a few seconds) tend to be +latency-sensitive, while long-lived ones may benefit more from coalescing — batching timers +with similar deadlines together — which the default provider (backed by the platform's global +`setTimeout`/`setInterval`) does not do. A custom provider can implement coalescing, and can +also support delays longer than the ~24-day maximum of the global `setTimeout`. + +## Type Parameters + +### TTimerId + +`TTimerId` *extends* [`ManagedTimerId`](ManagedTimerId.md) = [`ManagedTimerId`](ManagedTimerId.md) + +## Properties + +### clearInterval() + +```ts +readonly clearInterval: (intervalId) => void; +``` + +Defined in: [packages/query-core/src/timeoutManager.ts:34](https://github.com/TanStack/query/blob/main/packages/query-core/src/timeoutManager.ts#L34) + +#### Parameters + +##### intervalId + +`TTimerId` | `undefined` + +#### Returns + +`void` + +*** + +### clearTimeout() + +```ts +readonly clearTimeout: (timeoutId) => void; +``` + +Defined in: [packages/query-core/src/timeoutManager.ts:31](https://github.com/TanStack/query/blob/main/packages/query-core/src/timeoutManager.ts#L31) + +#### Parameters + +##### timeoutId + +`TTimerId` | `undefined` + +#### Returns + +`void` + +*** + +### setInterval() + +```ts +readonly setInterval: (callback, delay) => TTimerId; +``` + +Defined in: [packages/query-core/src/timeoutManager.ts:33](https://github.com/TanStack/query/blob/main/packages/query-core/src/timeoutManager.ts#L33) + +#### Parameters + +##### callback + +[`TimeoutCallback`](TimeoutCallback.md) + +##### delay + +`number` + +#### Returns + +`TTimerId` + +*** + +### setTimeout() + +```ts +readonly setTimeout: (callback, delay) => TTimerId; +``` + +Defined in: [packages/query-core/src/timeoutManager.ts:30](https://github.com/TanStack/query/blob/main/packages/query-core/src/timeoutManager.ts#L30) + +#### Parameters + +##### callback + +[`TimeoutCallback`](TimeoutCallback.md) + +##### delay + +`number` + +#### Returns + +`TTimerId` diff --git a/docs/framework/solid/reference/type-aliases/UndefinedInitialDataInfiniteOptions.md b/docs/framework/solid/reference/type-aliases/UndefinedInitialDataInfiniteOptions.md index 477c66c2506..760dda9cacf 100644 --- a/docs/framework/solid/reference/type-aliases/UndefinedInitialDataInfiniteOptions.md +++ b/docs/framework/solid/reference/type-aliases/UndefinedInitialDataInfiniteOptions.md @@ -7,7 +7,7 @@ title: UndefinedInitialDataInfiniteOptions type UndefinedInitialDataInfiniteOptions = Accessor & object>; ``` -Defined in: [infiniteQueryOptions.ts:25](https://github.com/TanStack/query/blob/main/packages/solid-query/src/infiniteQueryOptions.ts#L25) +Defined in: [packages/solid-query/src/infiniteQueryOptions.ts:25](https://github.com/TanStack/query/blob/main/packages/solid-query/src/infiniteQueryOptions.ts#L25) The options accepted by the `infiniteQueryOptions` overload selected when no `initialData` is set — `data` may be `undefined` while the query is `pending`. `infiniteQueryOptions` itself accepts and returns a plain @@ -25,20 +25,20 @@ The type of a single page, as your `queryFn` resolves it. ### TError -`TError` = `DefaultError` +`TError` = [`DefaultError`](DefaultError.md) The type of errors your `queryFn` may throw. ### TData -`TData` = `InfiniteData`\<`TQueryFnData`\> +`TData` = [`InfiniteData`](../interfaces/InfiniteData.md)\<`TQueryFnData`\> The type `data` ends up as after `select` runs — defaults to `InfiniteData`, the shape of all fetched pages plus their page params. ### TQueryKey -`TQueryKey` *extends* `QueryKey` = `QueryKey` +`TQueryKey` *extends* [`QueryKey`](QueryKey.md) = [`QueryKey`](QueryKey.md) The type of your `queryKey`. diff --git a/docs/framework/solid/reference/type-aliases/UndefinedInitialDataOptions.md b/docs/framework/solid/reference/type-aliases/UndefinedInitialDataOptions.md index d74fedfa95b..0455c38e371 100644 --- a/docs/framework/solid/reference/type-aliases/UndefinedInitialDataOptions.md +++ b/docs/framework/solid/reference/type-aliases/UndefinedInitialDataOptions.md @@ -7,7 +7,7 @@ title: UndefinedInitialDataOptions type UndefinedInitialDataOptions = Accessor & object>; ``` -Defined in: [queryOptions.ts:20](https://github.com/TanStack/query/blob/main/packages/solid-query/src/queryOptions.ts#L20) +Defined in: [packages/solid-query/src/queryOptions.ts:20](https://github.com/TanStack/query/blob/main/packages/solid-query/src/queryOptions.ts#L20) The options accepted by the `queryOptions` overload selected when no `initialData` is set — `data` may be `undefined` while the query is `pending`. `queryOptions` itself accepts and returns a plain object (its @@ -24,7 +24,7 @@ The type your `queryFn` resolves to. ### TError -`TError` = `DefaultError` +`TError` = [`DefaultError`](DefaultError.md) The type of errors your `queryFn` may throw. @@ -36,6 +36,6 @@ The type `data` ends up as after `select` runs. ### TQueryKey -`TQueryKey` *extends* `QueryKey` = `QueryKey` +`TQueryKey` *extends* [`QueryKey`](QueryKey.md) = [`QueryKey`](QueryKey.md) The type of your `queryKey`. diff --git a/docs/framework/solid/reference/type-aliases/UnsetMarker.md b/docs/framework/solid/reference/type-aliases/UnsetMarker.md new file mode 100644 index 00000000000..8b9c14e1907 --- /dev/null +++ b/docs/framework/solid/reference/type-aliases/UnsetMarker.md @@ -0,0 +1,10 @@ +--- +id: UnsetMarker +title: UnsetMarker +--- + +```ts +type UnsetMarker = typeof unsetMarker; +``` + +Defined in: [packages/query-core/src/types.ts:66](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L66) diff --git a/docs/framework/solid/reference/type-aliases/Updater.md b/docs/framework/solid/reference/type-aliases/Updater.md new file mode 100644 index 00000000000..7a0c2f30503 --- /dev/null +++ b/docs/framework/solid/reference/type-aliases/Updater.md @@ -0,0 +1,35 @@ +--- +id: Updater +title: Updater +--- + +```ts +type Updater = TOutput | (input) => TOutput; +``` + +Defined in: [packages/query-core/src/utils.ts:105](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L105) + +Either a plain value of type `TOutput`, or a function that receives `TInput` and returns `TOutput`. +Used for example by `setQueryData`-style updaters, which accept either the new data directly or a +function that computes it from the previous data. See functionalUpdate. + +## Type Parameters + +### TInput + +`TInput` + +### TOutput + +`TOutput` + +## Example + +```ts +queryClient.setQueryData(['posts'], newPosts) + +// Or, using an updater function that receives the current data: +queryClient.setQueryData(['posts'], (oldPosts) => + oldPosts ? [...oldPosts, newPost] : oldPosts, +) +``` diff --git a/docs/framework/solid/reference/type-aliases/UseBaseMutationResult.md b/docs/framework/solid/reference/type-aliases/UseBaseMutationResult.md index 7b3cd4a91ab..e0ea96077c4 100644 --- a/docs/framework/solid/reference/type-aliases/UseBaseMutationResult.md +++ b/docs/framework/solid/reference/type-aliases/UseBaseMutationResult.md @@ -9,9 +9,9 @@ type UseBaseMutationResult = Overrid }> & object; ``` -Defined in: [types.ts:305](https://github.com/TanStack/query/blob/main/packages/solid-query/src/types.ts#L305) +Defined in: [packages/solid-query/src/types.ts:305](https://github.com/TanStack/query/blob/main/packages/solid-query/src/types.ts#L305) -The result of `useMutation`. Same as MutationObserverResult from `@tanstack/query-core`, with +The result of `useMutation`. Same as [MutationObserverResult](MutationObserverResult.md) from `@tanstack/query-core`, with `mutate` narrowed to the fire-and-forget [UseMutateFunction](UseMutateFunction.md) signature, plus the added `mutateAsync`. ## Type Declaration @@ -34,7 +34,7 @@ The type your `mutationFn` resolves to. ### TError -`TError` = `DefaultError` +`TError` = [`DefaultError`](DefaultError.md) The type of errors your `mutationFn` may throw. diff --git a/docs/framework/solid/reference/type-aliases/UseBaseQueryResult.md b/docs/framework/solid/reference/type-aliases/UseBaseQueryResult.md index 25f70f23438..4bd3f539d41 100644 --- a/docs/framework/solid/reference/type-aliases/UseBaseQueryResult.md +++ b/docs/framework/solid/reference/type-aliases/UseBaseQueryResult.md @@ -7,10 +7,10 @@ title: UseBaseQueryResult type UseBaseQueryResult = QueryObserverResult; ``` -Defined in: [types.ts:108](https://github.com/TanStack/query/blob/main/packages/solid-query/src/types.ts#L108) +Defined in: [packages/solid-query/src/types.ts:108](https://github.com/TanStack/query/blob/main/packages/solid-query/src/types.ts#L108) The object `useQuery` returns when `initialData` isn't set — `data`/`error` may still be `undefined`/`null` -while the query is `pending`. Re-exports QueryObserverResult from `@tanstack/query-core`. +while the query is `pending`. Re-exports [QueryObserverResult](QueryObserverResult.md) from `@tanstack/query-core`. `useInfiniteQuery` returns [UseInfiniteQueryResult](UseInfiniteQueryResult.md) instead. ## Type Parameters @@ -23,6 +23,6 @@ The type `data` ends up as, after `select` runs (if set). ### TError -`TError` = `DefaultError` +`TError` = [`DefaultError`](DefaultError.md) The type of errors this query may hold. diff --git a/docs/framework/solid/reference/type-aliases/UseInfiniteQueryOptions.md b/docs/framework/solid/reference/type-aliases/UseInfiniteQueryOptions.md index ea549f2c222..126aaf1c333 100644 --- a/docs/framework/solid/reference/type-aliases/UseInfiniteQueryOptions.md +++ b/docs/framework/solid/reference/type-aliases/UseInfiniteQueryOptions.md @@ -7,7 +7,7 @@ title: UseInfiniteQueryOptions type UseInfiniteQueryOptions = Accessor>; ``` -Defined in: [types.ts:199](https://github.com/TanStack/query/blob/main/packages/solid-query/src/types.ts#L199) +Defined in: [packages/solid-query/src/types.ts:199](https://github.com/TanStack/query/blob/main/packages/solid-query/src/types.ts#L199) The accessor `useInfiniteQuery` expects as its first argument — Solid re-evaluates it reactively, so `queryKey` and other options can depend on signals. @@ -22,7 +22,7 @@ The type of a single page, as your `queryFn` resolves it. ### TError -`TError` = `DefaultError` +`TError` = [`DefaultError`](DefaultError.md) The type of errors your `queryFn` may throw. @@ -34,7 +34,7 @@ The type `data` ends up as after `select` runs. ### TQueryKey -`TQueryKey` *extends* `QueryKey` = `QueryKey` +`TQueryKey` *extends* [`QueryKey`](QueryKey.md) = [`QueryKey`](QueryKey.md) The type of your `queryKey`. diff --git a/docs/framework/solid/reference/type-aliases/UseInfiniteQueryResult.md b/docs/framework/solid/reference/type-aliases/UseInfiniteQueryResult.md index 27bbb6af675..820e0fa6ca2 100644 --- a/docs/framework/solid/reference/type-aliases/UseInfiniteQueryResult.md +++ b/docs/framework/solid/reference/type-aliases/UseInfiniteQueryResult.md @@ -7,7 +7,7 @@ title: UseInfiniteQueryResult type UseInfiniteQueryResult = InfiniteQueryObserverResult; ``` -Defined in: [types.ts:216](https://github.com/TanStack/query/blob/main/packages/solid-query/src/types.ts#L216) +Defined in: [packages/solid-query/src/types.ts:216](https://github.com/TanStack/query/blob/main/packages/solid-query/src/types.ts#L216) The object `useInfiniteQuery` returns — `data`/`error` may still be `undefined`/`null` while the query is `pending`. @@ -22,6 +22,6 @@ The type `data` ends up as, after `select` runs (if set). ### TError -`TError` = `DefaultError` +`TError` = [`DefaultError`](DefaultError.md) The type of errors this query may hold. diff --git a/docs/framework/solid/reference/type-aliases/UseMutateAsyncFunction.md b/docs/framework/solid/reference/type-aliases/UseMutateAsyncFunction.md index 5c8b2b61f89..9f34bc49c3c 100644 --- a/docs/framework/solid/reference/type-aliases/UseMutateAsyncFunction.md +++ b/docs/framework/solid/reference/type-aliases/UseMutateAsyncFunction.md @@ -7,7 +7,7 @@ title: UseMutateAsyncFunction type UseMutateAsyncFunction = MutateFunction; ``` -Defined in: [types.ts:288](https://github.com/TanStack/query/blob/main/packages/solid-query/src/types.ts#L288) +Defined in: [packages/solid-query/src/types.ts:288](https://github.com/TanStack/query/blob/main/packages/solid-query/src/types.ts#L288) The type of `mutateAsync`, as returned by `useMutation`. Similar to [UseMutateFunction](UseMutateFunction.md), but returns a promise which can be awaited. @@ -22,7 +22,7 @@ The type your `mutationFn` resolves to. ### TError -`TError` = `DefaultError` +`TError` = [`DefaultError`](DefaultError.md) The type of errors your `mutationFn` may throw. diff --git a/docs/framework/solid/reference/type-aliases/UseMutateFunction.md b/docs/framework/solid/reference/type-aliases/UseMutateFunction.md index 02efe15eeac..82adc280c52 100644 --- a/docs/framework/solid/reference/type-aliases/UseMutateFunction.md +++ b/docs/framework/solid/reference/type-aliases/UseMutateFunction.md @@ -7,7 +7,7 @@ title: UseMutateFunction type UseMutateFunction = (...args) => void; ``` -Defined in: [types.ts:267](https://github.com/TanStack/query/blob/main/packages/solid-query/src/types.ts#L267) +Defined in: [packages/solid-query/src/types.ts:267](https://github.com/TanStack/query/blob/main/packages/solid-query/src/types.ts#L267) ## Type Parameters @@ -17,7 +17,7 @@ Defined in: [types.ts:267](https://github.com/TanStack/query/blob/main/packages/ ### TError -`TError` = `DefaultError` +`TError` = [`DefaultError`](DefaultError.md) ### TVariables @@ -31,7 +31,7 @@ Defined in: [types.ts:267](https://github.com/TanStack/query/blob/main/packages/ ### args -...`Parameters`\<`MutateFunction`\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\>\> +...`Parameters`\<[`MutateFunction`](MutateFunction.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\>\> ## Returns diff --git a/docs/framework/solid/reference/type-aliases/UseMutationOptions.md b/docs/framework/solid/reference/type-aliases/UseMutationOptions.md index bf6fda35575..21fc51cfdb6 100644 --- a/docs/framework/solid/reference/type-aliases/UseMutationOptions.md +++ b/docs/framework/solid/reference/type-aliases/UseMutationOptions.md @@ -7,7 +7,7 @@ title: UseMutationOptions type UseMutationOptions = Accessor>; ``` -Defined in: [types.ts:260](https://github.com/TanStack/query/blob/main/packages/solid-query/src/types.ts#L260) +Defined in: [packages/solid-query/src/types.ts:260](https://github.com/TanStack/query/blob/main/packages/solid-query/src/types.ts#L260) The accessor `useMutation` expects as its first argument — Solid re-evaluates it reactively, so callbacks and other options can depend on signals. @@ -22,7 +22,7 @@ The type your `mutationFn` resolves to. ### TError -`TError` = `DefaultError` +`TError` = [`DefaultError`](DefaultError.md) The type of errors your `mutationFn` may throw. diff --git a/docs/framework/solid/reference/type-aliases/UseMutationResult.md b/docs/framework/solid/reference/type-aliases/UseMutationResult.md index c3d1e3b4f46..ae54de7270a 100644 --- a/docs/framework/solid/reference/type-aliases/UseMutationResult.md +++ b/docs/framework/solid/reference/type-aliases/UseMutationResult.md @@ -7,7 +7,7 @@ title: UseMutationResult type UseMutationResult = UseBaseMutationResult; ``` -Defined in: [types.ts:334](https://github.com/TanStack/query/blob/main/packages/solid-query/src/types.ts#L334) +Defined in: [packages/solid-query/src/types.ts:334](https://github.com/TanStack/query/blob/main/packages/solid-query/src/types.ts#L334) The result of `useMutation`. Same as [UseBaseMutationResult](UseBaseMutationResult.md). @@ -21,7 +21,7 @@ The type your `mutationFn` resolves to. ### TError -`TError` = `DefaultError` +`TError` = [`DefaultError`](DefaultError.md) The type of errors your `mutationFn` may throw. diff --git a/docs/framework/solid/reference/type-aliases/UseQueryOptions.md b/docs/framework/solid/reference/type-aliases/UseQueryOptions.md index 66e2b0e8a8e..b157698738b 100644 --- a/docs/framework/solid/reference/type-aliases/UseQueryOptions.md +++ b/docs/framework/solid/reference/type-aliases/UseQueryOptions.md @@ -7,7 +7,7 @@ title: UseQueryOptions type UseQueryOptions = Accessor>; ``` -Defined in: [types.ts:91](https://github.com/TanStack/query/blob/main/packages/solid-query/src/types.ts#L91) +Defined in: [packages/solid-query/src/types.ts:91](https://github.com/TanStack/query/blob/main/packages/solid-query/src/types.ts#L91) The accessor `useQuery` expects as its first argument — Solid re-evaluates it reactively, so `queryKey` and other options can depend on signals. @@ -22,7 +22,7 @@ The type your `queryFn` resolves to. ### TError -`TError` = `DefaultError` +`TError` = [`DefaultError`](DefaultError.md) The type of errors your `queryFn` may throw. @@ -35,6 +35,6 @@ The type `data` ends up as after `select` runs. Defaults to `TQueryFnData` when ### TQueryKey -`TQueryKey` *extends* `QueryKey` = `QueryKey` +`TQueryKey` *extends* [`QueryKey`](QueryKey.md) = [`QueryKey`](QueryKey.md) The type of your `queryKey`. diff --git a/docs/framework/solid/reference/type-aliases/UseQueryResult.md b/docs/framework/solid/reference/type-aliases/UseQueryResult.md index c88e14178ac..e5e40e942d8 100644 --- a/docs/framework/solid/reference/type-aliases/UseQueryResult.md +++ b/docs/framework/solid/reference/type-aliases/UseQueryResult.md @@ -7,7 +7,7 @@ title: UseQueryResult type UseQueryResult = UseBaseQueryResult; ``` -Defined in: [types.ts:120](https://github.com/TanStack/query/blob/main/packages/solid-query/src/types.ts#L120) +Defined in: [packages/solid-query/src/types.ts:120](https://github.com/TanStack/query/blob/main/packages/solid-query/src/types.ts#L120) The object `useQuery` returns — `data`/`error` may still be `undefined`/`null` while the query is `pending`. @@ -22,6 +22,6 @@ The type `data` ends up as, after `select` runs (if set). ### TError -`TError` = `DefaultError` +`TError` = [`DefaultError`](DefaultError.md) The type of errors this query may hold. diff --git a/docs/framework/solid/reference/type-aliases/WithRequired.md b/docs/framework/solid/reference/type-aliases/WithRequired.md new file mode 100644 index 00000000000..a40a48c865b --- /dev/null +++ b/docs/framework/solid/reference/type-aliases/WithRequired.md @@ -0,0 +1,20 @@ +--- +id: WithRequired +title: WithRequired +--- + +```ts +type WithRequired = TTarget & { [_ in TKey]: {} }; +``` + +Defined in: [packages/query-core/src/types.ts:524](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L524) + +## Type Parameters + +### TTarget + +`TTarget` + +### TKey + +`TKey` *extends* keyof `TTarget` diff --git a/docs/framework/solid/reference/type-aliases/dataTagErrorSymbol.md b/docs/framework/solid/reference/type-aliases/dataTagErrorSymbol.md new file mode 100644 index 00000000000..26148a94d6e --- /dev/null +++ b/docs/framework/solid/reference/type-aliases/dataTagErrorSymbol.md @@ -0,0 +1,10 @@ +--- +id: dataTagErrorSymbol +title: dataTagErrorSymbol +--- + +```ts +type dataTagErrorSymbol = typeof dataTagErrorSymbol; +``` + +Defined in: [packages/query-core/src/types.ts:63](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L63) diff --git a/docs/framework/solid/reference/type-aliases/dataTagSymbol.md b/docs/framework/solid/reference/type-aliases/dataTagSymbol.md new file mode 100644 index 00000000000..0012c108cc5 --- /dev/null +++ b/docs/framework/solid/reference/type-aliases/dataTagSymbol.md @@ -0,0 +1,10 @@ +--- +id: dataTagSymbol +title: dataTagSymbol +--- + +```ts +type dataTagSymbol = typeof dataTagSymbol; +``` + +Defined in: [packages/query-core/src/types.ts:61](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L61) diff --git a/docs/framework/solid/reference/variables/IsRestoringProvider.md b/docs/framework/solid/reference/variables/IsRestoringProvider.md index 99fd1f1b78a..255f0f58b6e 100644 --- a/docs/framework/solid/reference/variables/IsRestoringProvider.md +++ b/docs/framework/solid/reference/variables/IsRestoringProvider.md @@ -7,7 +7,7 @@ title: IsRestoringProvider const IsRestoringProvider: ContextProviderComponent> = IsRestoringContext.Provider; ``` -Defined in: [isRestoring.ts:19](https://github.com/TanStack/query/blob/main/packages/solid-query/src/isRestoring.ts#L19) +Defined in: [packages/solid-query/src/isRestoring.ts:19](https://github.com/TanStack/query/blob/main/packages/solid-query/src/isRestoring.ts#L19) The Provider that `PersistQueryClientProvider` uses to signal whether a persisted client is currently being restored, read by `useIsRestoring`. diff --git a/docs/framework/solid/reference/variables/QueryClientContext.md b/docs/framework/solid/reference/variables/QueryClientContext.md index b8883f1e9fd..531b7630c2d 100644 --- a/docs/framework/solid/reference/variables/QueryClientContext.md +++ b/docs/framework/solid/reference/variables/QueryClientContext.md @@ -7,6 +7,6 @@ title: QueryClientContext const QueryClientContext: Context<() => QueryClient | undefined>; ``` -Defined in: [QueryClientProvider.tsx:13](https://github.com/TanStack/query/blob/main/packages/solid-query/src/QueryClientProvider.tsx#L13) +Defined in: [packages/solid-query/src/QueryClientProvider.tsx:13](https://github.com/TanStack/query/blob/main/packages/solid-query/src/QueryClientProvider.tsx#L13) The context that `useQueryClient` reads from. `QueryClientProvider` is the normal way to set it. diff --git a/docs/framework/solid/reference/variables/createInfiniteQuery.md b/docs/framework/solid/reference/variables/createInfiniteQuery.md index 1b388183d4b..b9cf1879ec2 100644 --- a/docs/framework/solid/reference/variables/createInfiniteQuery.md +++ b/docs/framework/solid/reference/variables/createInfiniteQuery.md @@ -10,7 +10,7 @@ const createInfiniteQuery: { } = useInfiniteQuery; ``` -Defined in: [index.ts:72](https://github.com/TanStack/query/blob/main/packages/solid-query/src/index.ts#L72) +Defined in: [packages/solid-query/src/index.ts:72](https://github.com/TanStack/query/blob/main/packages/solid-query/src/index.ts#L72) ## Call Signature @@ -35,7 +35,7 @@ This overload is selected when `initialData` is set. #### TData -`TData` = `InfiniteData`\<`TQueryFnData`, `unknown`\> +`TData` = [`InfiniteData`](../interfaces/InfiniteData.md)\<`TQueryFnData`, `unknown`\> #### TQueryKey @@ -131,7 +131,7 @@ The options for `useInfiniteQuery` are identical to `useQuery`, with the additio #### TData -`TData` = `InfiniteData`\<`TQueryFnData`, `unknown`\> +`TData` = [`InfiniteData`](../interfaces/InfiniteData.md)\<`TQueryFnData`, `unknown`\> #### TQueryKey diff --git a/docs/framework/solid/reference/variables/createMutation.md b/docs/framework/solid/reference/variables/createMutation.md index 59f2192276a..1fb965458c9 100644 --- a/docs/framework/solid/reference/variables/createMutation.md +++ b/docs/framework/solid/reference/variables/createMutation.md @@ -7,7 +7,7 @@ title: createMutation const createMutation: (options, queryClient?) => UseMutationResult = useMutation; ``` -Defined in: [index.ts:80](https://github.com/TanStack/query/blob/main/packages/solid-query/src/index.ts#L80) +Defined in: [packages/solid-query/src/index.ts:80](https://github.com/TanStack/query/blob/main/packages/solid-query/src/index.ts#L80) ## Type Parameters diff --git a/docs/framework/solid/reference/variables/createQueries.md b/docs/framework/solid/reference/variables/createQueries.md index e535e04ce29..cbda52b5bb6 100644 --- a/docs/framework/solid/reference/variables/createQueries.md +++ b/docs/framework/solid/reference/variables/createQueries.md @@ -7,7 +7,7 @@ title: createQueries const createQueries: (queriesOptions, queryClient?) => TCombinedResult = useQueries; ``` -Defined in: [index.ts:86](https://github.com/TanStack/query/blob/main/packages/solid-query/src/index.ts#L86) +Defined in: [packages/solid-query/src/index.ts:86](https://github.com/TanStack/query/blob/main/packages/solid-query/src/index.ts#L86) The `useQueries` hook can be used to fetch a variable number of queries. @@ -36,31 +36,31 @@ previously rendered queries, because the number of queries can differ between re `TCombinedResult` *extends* \| \[\] \| \[ - \| `QueryObserverRefetchErrorResult`\<`unknown`, `Error`\> - \| `QueryObserverSuccessResult`\<`unknown`, `Error`\> - \| `QueryObserverLoadingErrorResult`\<`unknown`, `Error`\> - \| `QueryObserverLoadingResult`\<`unknown`, `Error`\> - \| `QueryObserverPendingResult`\<`unknown`, `Error`\> - \| `QueryObserverPlaceholderResult`\<`unknown`, `Error`\> - \| `QueryObserverRefetchErrorResult`\<`unknown`, `unknown`\> - \| `QueryObserverSuccessResult`\<`unknown`, `unknown`\> - \| `QueryObserverLoadingErrorResult`\<`unknown`, `unknown`\> - \| `QueryObserverLoadingResult`\<`unknown`, `unknown`\> - \| `QueryObserverPendingResult`\<`unknown`, `unknown`\> - \| `QueryObserverPlaceholderResult`\<`unknown`, `unknown`\>\] + \| [`QueryObserverRefetchErrorResult`](../interfaces/QueryObserverRefetchErrorResult.md)\<`unknown`, `Error`\> + \| [`QueryObserverSuccessResult`](../interfaces/QueryObserverSuccessResult.md)\<`unknown`, `Error`\> + \| [`QueryObserverLoadingErrorResult`](../interfaces/QueryObserverLoadingErrorResult.md)\<`unknown`, `Error`\> + \| [`QueryObserverLoadingResult`](../interfaces/QueryObserverLoadingResult.md)\<`unknown`, `Error`\> + \| [`QueryObserverPendingResult`](../interfaces/QueryObserverPendingResult.md)\<`unknown`, `Error`\> + \| [`QueryObserverPlaceholderResult`](../interfaces/QueryObserverPlaceholderResult.md)\<`unknown`, `Error`\> + \| [`QueryObserverRefetchErrorResult`](../interfaces/QueryObserverRefetchErrorResult.md)\<`unknown`, `unknown`\> + \| [`QueryObserverSuccessResult`](../interfaces/QueryObserverSuccessResult.md)\<`unknown`, `unknown`\> + \| [`QueryObserverLoadingErrorResult`](../interfaces/QueryObserverLoadingErrorResult.md)\<`unknown`, `unknown`\> + \| [`QueryObserverLoadingResult`](../interfaces/QueryObserverLoadingResult.md)\<`unknown`, `unknown`\> + \| [`QueryObserverPendingResult`](../interfaces/QueryObserverPendingResult.md)\<`unknown`, `unknown`\> + \| [`QueryObserverPlaceholderResult`](../interfaces/QueryObserverPlaceholderResult.md)\<`unknown`, `unknown`\>\] \| ( - \| `QueryObserverRefetchErrorResult`\<`unknown`, `Error`\> - \| `QueryObserverSuccessResult`\<`unknown`, `Error`\> - \| `QueryObserverLoadingErrorResult`\<`unknown`, `Error`\> - \| `QueryObserverLoadingResult`\<`unknown`, `Error`\> - \| `QueryObserverPendingResult`\<`unknown`, `Error`\> - \| `QueryObserverPlaceholderResult`\<`unknown`, `Error`\> - \| `QueryObserverRefetchErrorResult`\<`unknown`, `unknown`\> - \| `QueryObserverSuccessResult`\<`unknown`, `unknown`\> - \| `QueryObserverLoadingErrorResult`\<`unknown`, `unknown`\> - \| `QueryObserverLoadingResult`\<`unknown`, `unknown`\> - \| `QueryObserverPendingResult`\<`unknown`, `unknown`\> - \| `QueryObserverPlaceholderResult`\<`unknown`, `unknown`\>)[] = `T` *extends* \[\] ? \[\] : `T` *extends* \[`Head`\] ? \[`GetResults`\<`Head`\>\] : `T` *extends* \[`Head`, `...Tail[]`\] ? \[`...Tail[]`\] *extends* \[\] ? \[\] : \[`...Tail[]`\] *extends* \[`Head`\] ? \[`GetResults`\<`Head`\>, `GetResults`\<`Head`\>\] : \[`...Tail[]`\] *extends* \[`Head`, `...Tail[]`\] ? \[`...Tail[]`\] *extends* \[\] ? \[\] : \[`...Tail[]`\] *extends* \[`Head`\] ? \[`GetResults`\<...\>, `GetResults`\<...\>, `GetResults`\<...\>\] : \[`...(...)[]`\] *extends* \[..., `...(...)[]`\] ? ... *extends* ... ? ... : ... : \[`...(...)[]`\] : \[...\{ \[K in string \| number \| symbol\]: GetResults\<(...)\[(...)\]\> \}\[\]\] : \{ \[K in string \| number \| symbol\]: GetResults\\]\> \} + \| [`QueryObserverRefetchErrorResult`](../interfaces/QueryObserverRefetchErrorResult.md)\<`unknown`, `Error`\> + \| [`QueryObserverSuccessResult`](../interfaces/QueryObserverSuccessResult.md)\<`unknown`, `Error`\> + \| [`QueryObserverLoadingErrorResult`](../interfaces/QueryObserverLoadingErrorResult.md)\<`unknown`, `Error`\> + \| [`QueryObserverLoadingResult`](../interfaces/QueryObserverLoadingResult.md)\<`unknown`, `Error`\> + \| [`QueryObserverPendingResult`](../interfaces/QueryObserverPendingResult.md)\<`unknown`, `Error`\> + \| [`QueryObserverPlaceholderResult`](../interfaces/QueryObserverPlaceholderResult.md)\<`unknown`, `Error`\> + \| [`QueryObserverRefetchErrorResult`](../interfaces/QueryObserverRefetchErrorResult.md)\<`unknown`, `unknown`\> + \| [`QueryObserverSuccessResult`](../interfaces/QueryObserverSuccessResult.md)\<`unknown`, `unknown`\> + \| [`QueryObserverLoadingErrorResult`](../interfaces/QueryObserverLoadingErrorResult.md)\<`unknown`, `unknown`\> + \| [`QueryObserverLoadingResult`](../interfaces/QueryObserverLoadingResult.md)\<`unknown`, `unknown`\> + \| [`QueryObserverPendingResult`](../interfaces/QueryObserverPendingResult.md)\<`unknown`, `unknown`\> + \| [`QueryObserverPlaceholderResult`](../interfaces/QueryObserverPlaceholderResult.md)\<`unknown`, `unknown`\>)[] = `T` *extends* \[\] ? \[\] : `T` *extends* \[`Head`\] ? \[`GetResults`\<`Head`\>\] : `T` *extends* \[`Head`, `...Tail[]`\] ? \[`...Tail[]`\] *extends* \[\] ? \[\] : \[`...Tail[]`\] *extends* \[`Head`\] ? \[`GetResults`\<`Head`\>, `GetResults`\<`Head`\>\] : \[`...Tail[]`\] *extends* \[`Head`, `...Tail[]`\] ? \[`...Tail[]`\] *extends* \[\] ? \[\] : \[`...Tail[]`\] *extends* \[`Head`\] ? \[`GetResults`\<...\>, `GetResults`\<...\>, `GetResults`\<...\>\] : \[`...(...)[]`\] *extends* \[..., `...(...)[]`\] ? ... *extends* ... ? ... : ... : \[`...(...)[]`\] : \[...\{ \[K in string \| number \| symbol\]: GetResults\<(...)\[(...)\]\> \}\[\]\] : \{ \[K in string \| number \| symbol\]: GetResults\\]\> \} ## Parameters diff --git a/docs/framework/solid/reference/variables/createQuery.md b/docs/framework/solid/reference/variables/createQuery.md index 3f0810f24ad..df4c4c094b0 100644 --- a/docs/framework/solid/reference/variables/createQuery.md +++ b/docs/framework/solid/reference/variables/createQuery.md @@ -10,7 +10,7 @@ const createQuery: { } = useQuery; ``` -Defined in: [index.ts:57](https://github.com/TanStack/query/blob/main/packages/solid-query/src/index.ts#L57) +Defined in: [packages/solid-query/src/index.ts:57](https://github.com/TanStack/query/blob/main/packages/solid-query/src/index.ts#L57) ## Call Signature diff --git a/docs/framework/solid/reference/variables/dataTagErrorSymbol.md b/docs/framework/solid/reference/variables/dataTagErrorSymbol.md new file mode 100644 index 00000000000..20bab62fb01 --- /dev/null +++ b/docs/framework/solid/reference/variables/dataTagErrorSymbol.md @@ -0,0 +1,10 @@ +--- +id: dataTagErrorSymbol +title: dataTagErrorSymbol +--- + +```ts +const dataTagErrorSymbol: typeof dataTagErrorSymbol; +``` + +Defined in: [packages/query-core/src/types.ts:63](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L63) diff --git a/docs/framework/solid/reference/variables/dataTagSymbol.md b/docs/framework/solid/reference/variables/dataTagSymbol.md new file mode 100644 index 00000000000..83dd68a56e9 --- /dev/null +++ b/docs/framework/solid/reference/variables/dataTagSymbol.md @@ -0,0 +1,10 @@ +--- +id: dataTagSymbol +title: dataTagSymbol +--- + +```ts +const dataTagSymbol: typeof dataTagSymbol; +``` + +Defined in: [packages/query-core/src/types.ts:61](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L61) diff --git a/docs/framework/solid/reference/variables/defaultScheduler.md b/docs/framework/solid/reference/variables/defaultScheduler.md new file mode 100644 index 00000000000..70e14d3f846 --- /dev/null +++ b/docs/framework/solid/reference/variables/defaultScheduler.md @@ -0,0 +1,13 @@ +--- +id: defaultScheduler +title: defaultScheduler +--- + +```ts +const defaultScheduler: ScheduleFunction = systemSetTimeoutZero; +``` + +Defined in: [packages/query-core/src/notifyManager.ts:19](https://github.com/TanStack/query/blob/main/packages/query-core/src/notifyManager.ts#L19) + +Default scheduling function used by the notify manager. +Schedules the callback with the system's `setTimeout(callback, 0)`. diff --git a/docs/framework/solid/reference/variables/environmentManager.md b/docs/framework/solid/reference/variables/environmentManager.md new file mode 100644 index 00000000000..ed333b8747b --- /dev/null +++ b/docs/framework/solid/reference/variables/environmentManager.md @@ -0,0 +1,59 @@ +--- +id: environmentManager +title: environmentManager +--- + +```ts +const environmentManager: object; +``` + +Defined in: [packages/query-core/src/environmentManager.ts:29](https://github.com/TanStack/query/blob/main/packages/query-core/src/environmentManager.ts#L29) + +Manages how TanStack Query detects whether the current runtime should be treated as +server-side, which disables scheduling refetch timers and changes the default `retry` count +and `gcTime`. By default, the detection treats a missing `window` (or the presence of a +`Deno` global) as server. + +Override this for runtimes where that default detection would give the wrong answer — for +example, a Service Worker, where `window` is undefined even though the environment should +behave like a client. + +## Type Declaration + +### isServer() + +```ts +isServer: () => boolean; +``` + +Returns whether the current runtime should be treated as a server environment. + +#### Returns + +`boolean` + +### setIsServer() + +```ts +setIsServer(isServerValue): void; +``` + +Overrides the server check globally. + +#### Parameters + +##### isServerValue + +`IsServerValue` + +#### Returns + +`void` + +## Example + +```ts +import { environmentManager } from '@tanstack/query-core' + +environmentManager.setIsServer(() => false) +``` diff --git a/docs/framework/solid/reference/variables/focusManager.md b/docs/framework/solid/reference/variables/focusManager.md new file mode 100644 index 00000000000..86477849e06 --- /dev/null +++ b/docs/framework/solid/reference/variables/focusManager.md @@ -0,0 +1,12 @@ +--- +id: focusManager +title: focusManager +--- + +```ts +const focusManager: FocusManager; +``` + +Defined in: [packages/query-core/src/focusManager.ts:142](https://github.com/TanStack/query/blob/main/packages/query-core/src/focusManager.ts#L142) + +Singleton instance of [FocusManager](../interfaces/FocusManager.md), used to manage and observe the focus state within TanStack Query. diff --git a/docs/framework/solid/reference/variables/isServer.md b/docs/framework/solid/reference/variables/isServer.md new file mode 100644 index 00000000000..16aa39d1244 --- /dev/null +++ b/docs/framework/solid/reference/variables/isServer.md @@ -0,0 +1,14 @@ +--- +id: isServer +title: isServer +--- + +```ts +const isServer: boolean; +``` + +Defined in: [packages/query-core/src/utils.ts:114](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L114) + +## Deprecated + +use `environmentManager.isServer()` instead. diff --git a/docs/framework/solid/reference/variables/notifyManager.md b/docs/framework/solid/reference/variables/notifyManager.md new file mode 100644 index 00000000000..4bdf3478be0 --- /dev/null +++ b/docs/framework/solid/reference/variables/notifyManager.md @@ -0,0 +1,166 @@ +--- +id: notifyManager +title: notifyManager +--- + +```ts +const notifyManager: object; +``` + +Defined in: [packages/query-core/src/notifyManager.ts:144](https://github.com/TanStack/query/blob/main/packages/query-core/src/notifyManager.ts#L144) + +Handles scheduling and batching callbacks in TanStack Query. + +## Type Declaration + +### batch() + +```ts +readonly batch: (callback) => T; +``` + +Batches all updates scheduled inside the passed callback. +This is mainly used internally to optimize query client updating. +Batches can be nested; the queue is only flushed once the outermost `batch` call finishes. +The return value of `callback` is passed through. + +#### Type Parameters + +##### T + +`T` + +#### Parameters + +##### callback + +() => `T` + +#### Returns + +`T` + +### batchCalls() + +```ts +readonly batchCalls: (callback) => BatchCallsCallback; +``` + +All calls to the wrapped function will be batched. + +#### Type Parameters + +##### T + +`T` *extends* `unknown`[] + +#### Parameters + +##### callback + +`BatchCallsCallback`\<`T`\> + +#### Returns + +`BatchCallsCallback`\<`T`\> + +### schedule() + +```ts +schedule: (callback) => void; +``` + +Schedules a function to be run on the next batch. +By default, the batch is run with a `setTimeout`, but this can be configured via `setScheduler`. + +#### Parameters + +##### callback + +`NotifyCallback` + +#### Returns + +`void` + +### setBatchNotifyFunction() + +```ts +readonly setBatchNotifyFunction: (fn) => void; +``` + +Use this method to set a custom function to batch notifications together into a single tick. +Framework adapters use this to plug in their own batching primitive, so that a single query +update only triggers one re-render instead of one per subscriber. + +#### Parameters + +##### fn + +`BatchNotifyFunction` + +#### Returns + +`void` + +#### Example + +```ts +import { notifyManager } from '@tanstack/query-core' +import { batch } from 'solid-js' + +notifyManager.setBatchNotifyFunction(batch) +``` + +### setNotifyFunction() + +```ts +readonly setNotifyFunction: (fn) => void; +``` + +Use this method to set a custom notify function. +This can be used to for example wrap notifications with `React.act` while running tests. + +#### Parameters + +##### fn + +`NotifyFunction` + +#### Returns + +`void` + +### setScheduler() + +```ts +readonly setScheduler: (fn) => void; +``` + +Configures a custom callback that schedules when the next batch runs. +The default behavior is `setTimeout(callback, 0)`. + +#### Parameters + +##### fn + +`ScheduleFunction` + +#### Returns + +`void` + +#### Example + +```ts +import { notifyManager } from '@tanstack/query-core' + +// Schedule batches in the next microtask +notifyManager.setScheduler(queueMicrotask) + +// Schedule batches before the next frame is rendered +notifyManager.setScheduler(requestAnimationFrame) + +// Schedule batches some time in the future +notifyManager.setScheduler((cb) => setTimeout(cb, 10)) +``` diff --git a/docs/framework/solid/reference/variables/onlineManager.md b/docs/framework/solid/reference/variables/onlineManager.md new file mode 100644 index 00000000000..2eeec5385d8 --- /dev/null +++ b/docs/framework/solid/reference/variables/onlineManager.md @@ -0,0 +1,12 @@ +--- +id: onlineManager +title: onlineManager +--- + +```ts +const onlineManager: OnlineManager; +``` + +Defined in: [packages/query-core/src/onlineManager.ts:117](https://github.com/TanStack/query/blob/main/packages/query-core/src/onlineManager.ts#L117) + +Singleton instance of [OnlineManager](../interfaces/OnlineManager.md), used to manage and observe the online state within TanStack Query. diff --git a/docs/framework/solid/reference/variables/skipToken.md b/docs/framework/solid/reference/variables/skipToken.md new file mode 100644 index 00000000000..a390d0b7b66 --- /dev/null +++ b/docs/framework/solid/reference/variables/skipToken.md @@ -0,0 +1,23 @@ +--- +id: skipToken +title: skipToken +--- + +```ts +const skipToken: typeof skipToken; +``` + +Defined in: [packages/query-core/src/utils.ts:522](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L522) + +Sentinel value that can be passed as a query's `queryFn` to conditionally disable the query (equivalent +to `enabled: false`) while preserving full type inference for the query's data. Unlike `enabled: false`, +a query disabled via `skipToken` cannot be triggered with `refetch`. + +## Example + +```ts +new QueryObserver(queryClient, { + queryKey: ['post', postId], + queryFn: postId != null ? () => fetchPost(postId) : skipToken, +}) +``` diff --git a/docs/framework/solid/reference/variables/timeoutManager.md b/docs/framework/solid/reference/variables/timeoutManager.md new file mode 100644 index 00000000000..1eca1a5f343 --- /dev/null +++ b/docs/framework/solid/reference/variables/timeoutManager.md @@ -0,0 +1,12 @@ +--- +id: timeoutManager +title: timeoutManager +--- + +```ts +const timeoutManager: TimeoutManager; +``` + +Defined in: [packages/query-core/src/timeoutManager.ts:232](https://github.com/TanStack/query/blob/main/packages/query-core/src/timeoutManager.ts#L232) + +Singleton instance of [TimeoutManager](../interfaces/TimeoutManager.md), used throughout TanStack Query to schedule and cancel timers. diff --git a/docs/framework/solid/reference/variables/unsetMarker.md b/docs/framework/solid/reference/variables/unsetMarker.md new file mode 100644 index 00000000000..d19ee65b38e --- /dev/null +++ b/docs/framework/solid/reference/variables/unsetMarker.md @@ -0,0 +1,10 @@ +--- +id: unsetMarker +title: unsetMarker +--- + +```ts +const unsetMarker: typeof unsetMarker; +``` + +Defined in: [packages/query-core/src/types.ts:65](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L65) diff --git a/docs/framework/svelte/reference/classes/CancelledError.md b/docs/framework/svelte/reference/classes/CancelledError.md new file mode 100644 index 00000000000..7fded5da20f --- /dev/null +++ b/docs/framework/svelte/reference/classes/CancelledError.md @@ -0,0 +1,273 @@ +--- +id: CancelledError +title: CancelledError +--- + +Defined in: [packages/query-core/src/retryer.ts:77](https://github.com/TanStack/query/blob/main/packages/query-core/src/retryer.ts#L77) + +The error thrown by a `Retryer` (and surfaced to `query.promise`/`mutation`) when a fetch is cancelled, e.g. via +`query.cancel()`. `revert`, if `true`, tells the caller to restore the state the query was in before the fetch +started instead of surfacing the error. `silent`, if `true`, tells the caller to suppress this error and instead +resolve with the promise of the fetch that triggered the cancellation. + +## Example + +```ts +query.cancel() + +try { + await query.promise +} catch (error) { + if (error instanceof CancelledError) { + // the fetch was cancelled, e.g. via `query.cancel()` + } +} +``` + +## Extends + +- `Error` + +## Constructors + +### Constructor + +```ts +new CancelledError(options?): CancelledError; +``` + +Defined in: [packages/query-core/src/retryer.ts:80](https://github.com/TanStack/query/blob/main/packages/query-core/src/retryer.ts#L80) + +#### Parameters + +##### options? + +[`CancelOptions`](../interfaces/CancelOptions.md) + +#### Returns + +`CancelledError` + +#### Overrides + +```ts +Error.constructor +``` + +## Properties + +### cause? + +```ts +optional cause: unknown; +``` + +Defined in: node\_modules/.pnpm/typescript@6.0.3/node\_modules/typescript/lib/lib.es2022.error.d.ts:24 + +#### Inherited from + +```ts +Error.cause +``` + +*** + +### message + +```ts +message: string; +``` + +Defined in: node\_modules/.pnpm/typescript@6.0.3/node\_modules/typescript/lib/lib.es5.d.ts:1075 + +#### Inherited from + +```ts +Error.message +``` + +*** + +### name + +```ts +name: string; +``` + +Defined in: node\_modules/.pnpm/typescript@6.0.3/node\_modules/typescript/lib/lib.es5.d.ts:1074 + +#### Inherited from + +```ts +Error.name +``` + +*** + +### revert? + +```ts +optional revert: boolean; +``` + +Defined in: [packages/query-core/src/retryer.ts:78](https://github.com/TanStack/query/blob/main/packages/query-core/src/retryer.ts#L78) + +*** + +### silent? + +```ts +optional silent: boolean; +``` + +Defined in: [packages/query-core/src/retryer.ts:79](https://github.com/TanStack/query/blob/main/packages/query-core/src/retryer.ts#L79) + +*** + +### stack? + +```ts +optional stack: string; +``` + +Defined in: node\_modules/.pnpm/typescript@6.0.3/node\_modules/typescript/lib/lib.es5.d.ts:1076 + +#### Inherited from + +```ts +Error.stack +``` + +*** + +### stackTraceLimit + +```ts +static stackTraceLimit: number; +``` + +Defined in: node\_modules/.pnpm/@types+node@22.19.15/node\_modules/@types/node/globals.d.ts:68 + +The `Error.stackTraceLimit` property specifies the number of stack frames +collected by a stack trace (whether generated by `new Error().stack` or +`Error.captureStackTrace(obj)`). + +The default value is `10` but may be set to any valid JavaScript number. Changes +will affect any stack trace captured _after_ the value has been changed. + +If set to a non-number value, or set to a negative number, stack traces will +not capture any frames. + +#### Inherited from + +```ts +Error.stackTraceLimit +``` + +## Methods + +### captureStackTrace() + +```ts +static captureStackTrace(targetObject, constructorOpt?): void; +``` + +Defined in: node\_modules/.pnpm/@types+node@22.19.15/node\_modules/@types/node/globals.d.ts:52 + +Creates a `.stack` property on `targetObject`, which when accessed returns +a string representing the location in the code at which +`Error.captureStackTrace()` was called. + +```js +const myObject = {}; +Error.captureStackTrace(myObject); +myObject.stack; // Similar to `new Error().stack` +``` + +The first line of the trace will be prefixed with +`${myObject.name}: ${myObject.message}`. + +The optional `constructorOpt` argument accepts a function. If given, all frames +above `constructorOpt`, including `constructorOpt`, will be omitted from the +generated stack trace. + +The `constructorOpt` argument is useful for hiding implementation +details of error generation from the user. For instance: + +```js +function a() { + b(); +} + +function b() { + c(); +} + +function c() { + // Create an error without stack trace to avoid calculating the stack trace twice. + const { stackTraceLimit } = Error; + Error.stackTraceLimit = 0; + const error = new Error(); + Error.stackTraceLimit = stackTraceLimit; + + // Capture the stack trace above function b + Error.captureStackTrace(error, b); // Neither function c, nor b is included in the stack trace + throw error; +} + +a(); +``` + +#### Parameters + +##### targetObject + +`object` + +##### constructorOpt? + +`Function` + +#### Returns + +`void` + +#### Inherited from + +```ts +Error.captureStackTrace +``` + +*** + +### prepareStackTrace() + +```ts +static prepareStackTrace(err, stackTraces): any; +``` + +Defined in: node\_modules/.pnpm/@types+node@22.19.15/node\_modules/@types/node/globals.d.ts:56 + +#### Parameters + +##### err + +`Error` + +##### stackTraces + +`CallSite`[] + +#### Returns + +`any` + +#### See + +https://v8.dev/docs/stack-trace-api#customizing-stack-traces + +#### Inherited from + +```ts +Error.prepareStackTrace +``` diff --git a/docs/framework/svelte/reference/classes/InfiniteQueryObserver.md b/docs/framework/svelte/reference/classes/InfiniteQueryObserver.md new file mode 100644 index 00000000000..af43087a3ad --- /dev/null +++ b/docs/framework/svelte/reference/classes/InfiniteQueryObserver.md @@ -0,0 +1,665 @@ +--- +id: InfiniteQueryObserver +title: InfiniteQueryObserver +--- + +Defined in: [packages/query-core/src/infiniteQueryObserver.ts:41](https://github.com/TanStack/query/blob/main/packages/query-core/src/infiniteQueryObserver.ts#L41) + +An `InfiniteQueryObserver` extends `QueryObserver` to observe and switch +between infinite queries. It augments the base `QueryObserverResult` with +infinite-query-specific fields and methods, such as `hasNextPage` and +`fetchNextPage`, and is the primitive that framework adapters (e.g. +`useInfiniteQuery`) build their hooks on top of. + +## Example + +```ts +const observer = new InfiniteQueryObserver(queryClient, { + queryKey: ['projects'], + queryFn: ({ pageParam }) => fetchProjects(pageParam), + initialPageParam: 0, + getNextPageParam: (lastPage) => lastPage.nextCursor, +}) + +const unsubscribe = observer.subscribe((result) => console.log(result)) +``` + +## Extends + +- [`QueryObserver`](QueryObserver.md)\<`TQueryFnData`, `TError`, `TData`, [`InfiniteData`](../interfaces/InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\> + +## Type Parameters + +### TQueryFnData + +`TQueryFnData` = `unknown` + +### TError + +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) + +### TData + +`TData` = [`InfiniteData`](../interfaces/InfiniteData.md)\<`TQueryFnData`\> + +### TQueryKey + +`TQueryKey` *extends* [`QueryKey`](../type-aliases/QueryKey.md) = [`QueryKey`](../type-aliases/QueryKey.md) + +### TPageParam + +`TPageParam` = `unknown` + +## Constructors + +### Constructor + +```ts +new InfiniteQueryObserver(client, options): InfiniteQueryObserver; +``` + +Defined in: [packages/query-core/src/infiniteQueryObserver.ts:83](https://github.com/TanStack/query/blob/main/packages/query-core/src/infiniteQueryObserver.ts#L83) + +#### Parameters + +##### client + +[`QueryClient`](QueryClient.md) + +##### options + +[`InfiniteQueryObserverOptions`](../interfaces/InfiniteQueryObserverOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`, `TPageParam`\> + +#### Returns + +`InfiniteQueryObserver`\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`, `TPageParam`\> + +#### Overrides + +[`QueryObserver`](QueryObserver.md).[`constructor`](QueryObserver.md#constructor) + +## Properties + +### fetch + +```ts +protected fetch: ReplaceReturnType<(fetchOptions) => Promise>, Promise>>; +``` + +Defined in: [packages/query-core/src/infiniteQueryObserver.ts:72](https://github.com/TanStack/query/blob/main/packages/query-core/src/infiniteQueryObserver.ts#L72) + +#### Overrides + +```ts +QueryObserver.fetch +``` + +*** + +### getCurrentResult + +```ts +getCurrentResult: ReplaceReturnType<() => QueryObserverResult, InfiniteQueryObserverResult>; +``` + +Defined in: [packages/query-core/src/infiniteQueryObserver.ts:60](https://github.com/TanStack/query/blob/main/packages/query-core/src/infiniteQueryObserver.ts#L60) + +Returns the most recently computed `QueryObserverResult` for the +observed query. This is a point-in-time read; to be notified of updates +as they happen, subscribe to the observer instead (its inherited +`subscribe` method). + +#### Example + +```ts +const result = observer.getCurrentResult() +console.log(result.status, result.data) +``` + +#### Overrides + +```ts +QueryObserver.getCurrentResult +``` + +*** + +### listeners + +```ts +protected listeners: Set>; +``` + +Defined in: [packages/query-core/src/subscribable.ts:2](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L2) + +#### Inherited from + +[`QueryObserver`](QueryObserver.md).[`listeners`](QueryObserver.md#listeners) + +*** + +### options + +```ts +options: QueryObserverOptions, TQueryKey>; +``` + +Defined in: [packages/query-core/src/queryObserver.ts:89](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L89) + +#### Inherited from + +[`QueryObserver`](QueryObserver.md).[`options`](QueryObserver.md#options) + +*** + +### subscribe() + +```ts +subscribe: (listener) => () => void; +``` + +Defined in: [packages/query-core/src/infiniteQueryObserver.ts:55](https://github.com/TanStack/query/blob/main/packages/query-core/src/infiniteQueryObserver.ts#L55) + +#### Parameters + +##### listener + +`InfiniteQueryObserverListener` + +#### Returns + +```ts +(): void; +``` + +##### Returns + +`void` + +#### Overrides + +```ts +QueryObserver.subscribe +``` + +## Methods + +### bindMethods() + +```ts +protected bindMethods(): void; +``` + +Defined in: [packages/query-core/src/infiniteQueryObserver.ts:96](https://github.com/TanStack/query/blob/main/packages/query-core/src/infiniteQueryObserver.ts#L96) + +#### Returns + +`void` + +#### Overrides + +[`QueryObserver`](QueryObserver.md).[`bindMethods`](QueryObserver.md#bindmethods) + +*** + +### createResult() + +```ts +protected createResult(query, options): InfiniteQueryObserverResult; +``` + +Defined in: [packages/query-core/src/infiniteQueryObserver.ts:201](https://github.com/TanStack/query/blob/main/packages/query-core/src/infiniteQueryObserver.ts#L201) + +#### Parameters + +##### query + +[`Query`](Query.md)\<`TQueryFnData`, `TError`, [`InfiniteData`](../interfaces/InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\> + +##### options + +[`InfiniteQueryObserverOptions`](../interfaces/InfiniteQueryObserverOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`, `TPageParam`\> + +#### Returns + +[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\> + +#### Overrides + +[`QueryObserver`](QueryObserver.md).[`createResult`](QueryObserver.md#createresult) + +*** + +### destroy() + +```ts +destroy(): void; +``` + +Defined in: [packages/query-core/src/queryObserver.ts:161](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L161) + +Stops observing the current query: clears all listeners, cancels the +stale and refetch-interval timers, and removes this observer from the +query it was observing. + +#### Returns + +`void` + +#### Inherited from + +[`QueryObserver`](QueryObserver.md).[`destroy`](QueryObserver.md#destroy) + +*** + +### fetchNextPage() + +```ts +fetchNextPage(options?): Promise>; +``` + +Defined in: [packages/query-core/src/infiniteQueryObserver.ts:161](https://github.com/TanStack/query/blob/main/packages/query-core/src/infiniteQueryObserver.ts#L161) + +Fetches the next page of the infinite query and returns a promise that +resolves with the resulting `InfiniteQueryObserverResult`. The page +param used for the fetch is determined by `getNextPageParam`, which +receives the current pages/page params and whose result also determines +`hasNextPage`. + +#### Parameters + +##### options? + +[`FetchNextPageOptions`](../interfaces/FetchNextPageOptions.md) + +#### Returns + +`Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> + +#### Example + +```ts +const { hasNextPage } = observer.getCurrentResult() + +if (hasNextPage) { + await observer.fetchNextPage() +} +``` + +#### See + +[InfiniteQueryObserver#fetchPreviousPage](#fetchpreviouspage) + +*** + +### fetchOptimistic() + +```ts +fetchOptimistic(options): Promise>; +``` + +Defined in: [packages/query-core/src/queryObserver.ts:395](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L395) + +Fetches a query defined by the given options without affecting this +observer's own tracked query or result, and returns a promise that +resolves with the `QueryObserverResult` for that fetch. This is useful +for prefetching data that another observer (e.g. a query about to be +navigated to) will need, ahead of time. + +#### Parameters + +##### options + +[`QueryObserverOptions`](../interfaces/QueryObserverOptions.md)\<`TQueryFnData`, `TError`, `TData`, [`InfiniteData`](../interfaces/InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\> + +#### Returns + +`Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> + +#### Example + +```ts +const result = await observer.fetchOptimistic({ + queryKey: ['posts', 2], + queryFn: () => fetchPost(2), +}) +console.log(result.data) +``` + +#### Inherited from + +[`QueryObserver`](QueryObserver.md).[`fetchOptimistic`](QueryObserver.md#fetchoptimistic) + +*** + +### fetchPreviousPage() + +```ts +fetchPreviousPage(options?): Promise>; +``` + +Defined in: [packages/query-core/src/infiniteQueryObserver.ts:190](https://github.com/TanStack/query/blob/main/packages/query-core/src/infiniteQueryObserver.ts#L190) + +Fetches the previous page of the infinite query and returns a promise +that resolves with the resulting `InfiniteQueryObserverResult`. The page +param used for the fetch is determined by `getPreviousPageParam`, which +receives the current pages/page params and whose result also determines +`hasPreviousPage`. + +#### Parameters + +##### options? + +[`FetchPreviousPageOptions`](../interfaces/FetchPreviousPageOptions.md) + +#### Returns + +`Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> + +#### Example + +```ts +const { hasPreviousPage } = observer.getCurrentResult() + +if (hasPreviousPage) { + await observer.fetchPreviousPage() +} +``` + +#### See + +[InfiniteQueryObserver#fetchNextPage](#fetchnextpage) + +*** + +### getCurrentQuery() + +```ts +getCurrentQuery(): Query, TQueryKey>; +``` + +Defined in: [packages/query-core/src/queryObserver.ts:357](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L357) + +Returns the `Query` instance this observer is currently observing. + +#### Returns + +[`Query`](Query.md)\<`TQueryFnData`, `TError`, [`InfiniteData`](../interfaces/InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\> + +#### Inherited from + +[`QueryObserver`](QueryObserver.md).[`getCurrentQuery`](QueryObserver.md#getcurrentquery) + +*** + +### getOptimisticResult() + +```ts +getOptimisticResult(options): InfiniteQueryObserverResult; +``` + +Defined in: [packages/query-core/src/infiniteQueryObserver.ts:127](https://github.com/TanStack/query/blob/main/packages/query-core/src/infiniteQueryObserver.ts#L127) + +The infinite-query counterpart of [QueryObserver#getOptimisticResult](QueryObserver.md#getoptimisticresult), marking the +options as an infinite query before delegating to it. Called by framework adapters (e.g. +`useInfiniteQuery`) ahead of subscribing, to compute the current `InfiniteQueryObserverResult` +synchronously. + +#### Parameters + +##### options + +[`DefaultedInfiniteQueryObserverOptions`](../type-aliases/DefaultedInfiniteQueryObserverOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`, `TPageParam`\> + +#### Returns + +[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\> + +#### Overrides + +[`QueryObserver`](QueryObserver.md).[`getOptimisticResult`](QueryObserver.md#getoptimisticresult) + +*** + +### hasListeners() + +```ts +hasListeners(): boolean; +``` + +Defined in: [packages/query-core/src/subscribable.ts:19](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L19) + +#### Returns + +`boolean` + +#### Inherited from + +[`QueryObserver`](QueryObserver.md).[`hasListeners`](QueryObserver.md#haslisteners) + +*** + +### onSubscribe() + +```ts +protected onSubscribe(): void; +``` + +Defined in: [packages/query-core/src/queryObserver.ts:110](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L110) + +#### Returns + +`void` + +#### Inherited from + +[`QueryObserver`](QueryObserver.md).[`onSubscribe`](QueryObserver.md#onsubscribe) + +*** + +### onUnsubscribe() + +```ts +protected onUnsubscribe(): void; +``` + +Defined in: [packages/query-core/src/queryObserver.ts:124](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L124) + +#### Returns + +`void` + +#### Inherited from + +[`QueryObserver`](QueryObserver.md).[`onUnsubscribe`](QueryObserver.md#onunsubscribe) + +*** + +### refetch() + +```ts +refetch(__namedParameters): Promise>; +``` + +Defined in: [packages/query-core/src/queryObserver.ts:371](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L371) + +Refetches the observed query and returns a promise that resolves with +the resulting `QueryObserverResult`. + +#### Parameters + +##### \_\_namedParameters + +[`RefetchOptions`](../interfaces/RefetchOptions.md) = `{}` + +#### Returns + +`Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> + +#### Example + +```ts +const result = await observer.refetch({ cancelRefetch: false }) +console.log(result.data) +``` + +#### Inherited from + +[`QueryObserver`](QueryObserver.md).[`refetch`](QueryObserver.md#refetch) + +*** + +### setOptions() + +```ts +setOptions(options): void; +``` + +Defined in: [packages/query-core/src/infiniteQueryObserver.ts:108](https://github.com/TanStack/query/blob/main/packages/query-core/src/infiniteQueryObserver.ts#L108) + +Updates the observer's options. Behaves the same as +`QueryObserver.setOptions`, additionally marking the options as +belonging to an infinite query before delegating to the base +implementation. + +#### Parameters + +##### options + +[`InfiniteQueryObserverOptions`](../interfaces/InfiniteQueryObserverOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`, `TPageParam`\> + +#### Returns + +`void` + +#### Overrides + +[`QueryObserver`](QueryObserver.md).[`setOptions`](QueryObserver.md#setoptions) + +*** + +### shouldFetchOnReconnect() + +```ts +shouldFetchOnReconnect(): boolean; +``` + +Defined in: [packages/query-core/src/queryObserver.ts:135](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L135) + +Returns whether the observed query is currently stale and configured +(via the `refetchOnReconnect` option) to refetch when the network +reconnects. + +#### Returns + +`boolean` + +#### Inherited from + +[`QueryObserver`](QueryObserver.md).[`shouldFetchOnReconnect`](QueryObserver.md#shouldfetchonreconnect) + +*** + +### shouldFetchOnWindowFocus() + +```ts +shouldFetchOnWindowFocus(): boolean; +``` + +Defined in: [packages/query-core/src/queryObserver.ts:148](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L148) + +Returns whether the observed query is currently stale and configured +(via the `refetchOnWindowFocus` option) to refetch when the window +regains focus. + +#### Returns + +`boolean` + +#### Inherited from + +[`QueryObserver`](QueryObserver.md).[`shouldFetchOnWindowFocus`](QueryObserver.md#shouldfetchonwindowfocus) + +*** + +### trackProp() + +```ts +trackProp(key): void; +``` + +Defined in: [packages/query-core/src/queryObserver.ts:350](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L350) + +Records that the given `QueryObserverResult` property was read, so a subsequent update only +notifies this observer if a tracked property actually changed. Normally called indirectly via +[QueryObserver#trackResult](QueryObserver.md#trackresult)'s proxy; exposed directly for adapters that track property +access themselves (e.g. through their own reactivity system) instead of via the proxy. + +#### Parameters + +##### key + +`"error"` | `"data"` | `"isError"` | `"isPending"` | `"isLoading"` | `"isLoadingError"` | `"isRefetchError"` | `"isSuccess"` | `"isPlaceholderData"` | `"status"` | `"dataUpdatedAt"` | `"errorUpdatedAt"` | `"failureCount"` | `"failureReason"` | `"errorUpdateCount"` | `"isFetched"` | `"isFetchedAfterMount"` | `"isFetching"` | `"isInitialLoading"` | `"isPaused"` | `"isRefetching"` | `"isStale"` | `"isEnabled"` | `"refetch"` | `"fetchStatus"` + +#### Returns + +`void` + +#### Inherited from + +[`QueryObserver`](QueryObserver.md).[`trackProp`](QueryObserver.md#trackprop) + +*** + +### trackResult() + +```ts +trackResult(result, onPropTracked?): QueryObserverResult; +``` + +Defined in: [packages/query-core/src/queryObserver.ts:331](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L331) + +Wraps a `QueryObserverResult` in a `Proxy` that records which properties are read, via +[QueryObserver#trackProp](QueryObserver.md#trackprop) (and an optional `onPropTracked` callback). Used by framework +adapters when `notifyOnChangeProps` is not set, to implement its default "only re-render on +properties you actually read" behavior. + +#### Parameters + +##### result + +[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\> + +##### onPropTracked? + +(`key`) => `void` + +#### Returns + +[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\> + +#### Inherited from + +[`QueryObserver`](QueryObserver.md).[`trackResult`](QueryObserver.md#trackresult) + +*** + +### updateResult() + +```ts +updateResult(): void; +``` + +Defined in: [packages/query-core/src/queryObserver.ts:735](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L735) + +Recomputes and stores the current result from the current query/options, notifying listeners +if it changed. Framework adapters call this right after subscribing to make sure no query +update was missed in the gap between creating the observer and subscribing to it. + +#### Returns + +`void` + +#### Inherited from + +[`QueryObserver`](QueryObserver.md).[`updateResult`](QueryObserver.md#updateresult) diff --git a/docs/framework/svelte/reference/classes/Mutation.md b/docs/framework/svelte/reference/classes/Mutation.md new file mode 100644 index 00000000000..e038a9cd394 --- /dev/null +++ b/docs/framework/svelte/reference/classes/Mutation.md @@ -0,0 +1,330 @@ +--- +id: Mutation +title: Mutation +--- + +Defined in: [packages/query-core/src/mutation.ts:135](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L135) + +Represents a single mutation attempt. A `Mutation` holds the mutation's +options, state (data/error/status), and the `MutationObserver`s currently +subscribed to it. + +Instances are created and managed internally by `MutationCache`; application +code typically interacts with mutations indirectly through `QueryClient` or +a framework hook like `useMutation`. Direct access to a `Mutation` instance +is possible via `mutationCache.find()`/`getAll()` for inspecting cache state. + +## Example + +```ts +const mutationCache = queryClient.getMutationCache() + +const mutation = mutationCache.find({ mutationKey: ['addPost'] }) +``` + +## Extends + +- `Removable` + +## Type Parameters + +### TData + +`TData` = `unknown` + +### TError + +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) + +### TVariables + +`TVariables` = `unknown` + +### TOnMutateResult + +`TOnMutateResult` = `unknown` + +## Constructors + +### Constructor + +```ts +new Mutation(config): Mutation; +``` + +Defined in: [packages/query-core/src/mutation.ts:152](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L152) + +#### Parameters + +##### config + +`MutationConfig`\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\> + +#### Returns + +`Mutation`\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\> + +#### Overrides + +```ts +Removable.constructor +``` + +## Properties + +### gcTime + +```ts +gcTime: number; +``` + +Defined in: [packages/query-core/src/removable.ts:7](https://github.com/TanStack/query/blob/main/packages/query-core/src/removable.ts#L7) + +#### Inherited from + +```ts +Removable.gcTime +``` + +*** + +### mutationId + +```ts +readonly mutationId: number; +``` + +Defined in: [packages/query-core/src/mutation.ts:143](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L143) + +*** + +### options + +```ts +options: MutationOptions; +``` + +Defined in: [packages/query-core/src/mutation.ts:142](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L142) + +*** + +### state + +```ts +state: MutationState; +``` + +Defined in: [packages/query-core/src/mutation.ts:141](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L141) + +## Accessors + +### meta + +#### Get Signature + +```ts +get meta(): Record | undefined; +``` + +Defined in: [packages/query-core/src/mutation.ts:179](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L179) + +The `meta` object passed in the mutation's options, if any. + +##### Returns + +`Record`\<`string`, `unknown`\> \| `undefined` + +## Methods + +### clearGcTimeout() + +```ts +protected clearGcTimeout(): void; +``` + +Defined in: [packages/query-core/src/removable.ts:32](https://github.com/TanStack/query/blob/main/packages/query-core/src/removable.ts#L32) + +#### Returns + +`void` + +#### Inherited from + +```ts +Removable.clearGcTimeout +``` + +*** + +### continue() + +```ts +continue(): Promise; +``` + +Defined in: [packages/query-core/src/mutation.ts:243](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L243) + +Resumes a mutation that is currently paused or was restored from a +dehydrated, still-`pending` state. + +- If this mutation has an active retryer (it paused mid-attempt, e.g. due + to the network mode or scope-based queuing), its retryer is resumed. +- Otherwise, if the mutation's status is still `pending` (e.g. it was + dehydrated while an attempt was in flight and never got a retryer in + this instance), `execute` is called again with the last known variables. +- Otherwise the mutation has already settled and this resolves immediately + without running anything again. + +#### Returns + +`Promise`\<`unknown`\> + +#### Example + +```ts +// typically driven by reconnect handling, e.g. queryClient.resumePausedMutations() +const mutation = mutationCache.find({ mutationKey: ['addPost'] }) +await mutation?.continue() +``` + +#### See + +[Mutation#execute](#execute) + +*** + +### destroy() + +```ts +destroy(): void; +``` + +Defined in: [packages/query-core/src/removable.ts:10](https://github.com/TanStack/query/blob/main/packages/query-core/src/removable.ts#L10) + +#### Returns + +`void` + +#### Inherited from + +```ts +Removable.destroy +``` + +*** + +### execute() + +```ts +execute(variables): Promise; +``` + +Defined in: [packages/query-core/src/mutation.ts:284](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L284) + +Runs the mutation function for the given variables through a retryer, and +drives the mutation's state and lifecycle callbacks through to settlement. + +If this mutation's state is already `pending` when `execute` is called +(i.e. it was restored, still in-flight, from a dehydrated state), the +`onMutate` step is skipped and a `continue` action is dispatched to +unpause it; otherwise a `pending` action is dispatched first, then the +mutation cache's `onMutate` and the mutation's own `onMutate` option are +awaited in that order, and the resulting context is stored. + +The mutation function is then run (subject to `retry`/`retryDelay`/ +`networkMode`, and to the mutation cache's scope-based serialization). +On success, the cache's `onSuccess`/`onSettled` callbacks run before the +mutation's own `onSuccess`/`onSettled` options, a `success` action is +dispatched, and the resolved data is returned. On failure, the same +cache-then-option ordering is used for `onError`/`onSettled`, but each of +those four callbacks is individually caught so that a throwing callback +cannot mask the original error; an `error` action is then dispatched and +the original error is re-thrown. + +#### Parameters + +##### variables + +`TVariables` + +#### Returns + +`Promise`\<`TData`\> + +#### Example + +```ts +// Called internally by `MutationObserver.mutate` and `Mutation.continue` — +// applications normally trigger mutations through those, not this method. +const data = await mutation.execute(variables) +``` + +#### See + +[Mutation#continue](#continue) + +*** + +### optionalRemove() + +```ts +protected optionalRemove(): void; +``` + +Defined in: [packages/query-core/src/mutation.ts:212](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L212) + +#### Returns + +`void` + +#### Overrides + +```ts +Removable.optionalRemove +``` + +*** + +### scheduleGc() + +```ts +protected scheduleGc(): void; +``` + +Defined in: [packages/query-core/src/removable.ts:14](https://github.com/TanStack/query/blob/main/packages/query-core/src/removable.ts#L14) + +#### Returns + +`void` + +#### Inherited from + +```ts +Removable.scheduleGc +``` + +*** + +### updateGcTime() + +```ts +protected updateGcTime(newGcTime): void; +``` + +Defined in: [packages/query-core/src/removable.ts:24](https://github.com/TanStack/query/blob/main/packages/query-core/src/removable.ts#L24) + +#### Parameters + +##### newGcTime + +`number` | `undefined` + +#### Returns + +`void` + +#### Inherited from + +```ts +Removable.updateGcTime +``` diff --git a/docs/framework/svelte/reference/classes/MutationCache.md b/docs/framework/svelte/reference/classes/MutationCache.md new file mode 100644 index 00000000000..5a172b4cb9b --- /dev/null +++ b/docs/framework/svelte/reference/classes/MutationCache.md @@ -0,0 +1,316 @@ +--- +id: MutationCache +title: MutationCache +--- + +Defined in: [packages/query-core/src/mutationCache.ts:124](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationCache.ts#L124) + +The `MutationCache` is the storage for mutations. + +Normally, you will not interact with the `MutationCache` directly and instead use a +`QueryClient`. You can subscribe to it (inherited from `Subscribable`) to be informed of +safe/known updates to the cache, such as mutations being added, removed, or updated. + +## Example + +```ts +const unsubscribe = mutationCache.subscribe((event) => { + console.log(event.type, event.mutation) +}) +``` + +## Extends + +- `Subscribable`\<`MutationCacheListener`\> + +## Constructors + +### Constructor + +```ts +new MutationCache(config): MutationCache; +``` + +Defined in: [packages/query-core/src/mutationCache.ts:129](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationCache.ts#L129) + +#### Parameters + +##### config + +[`MutationCacheConfig`](../interfaces/MutationCacheConfig.md) = `{}` + +#### Returns + +`MutationCache` + +#### Overrides + +```ts +Subscribable.constructor +``` + +## Properties + +### config + +```ts +config: MutationCacheConfig = {}; +``` + +Defined in: [packages/query-core/src/mutationCache.ts:129](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationCache.ts#L129) + +*** + +### listeners + +```ts +protected listeners: Set; +``` + +Defined in: [packages/query-core/src/subscribable.ts:2](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L2) + +#### Inherited from + +```ts +Subscribable.listeners +``` + +## Methods + +### clear() + +```ts +clear(): void; +``` + +Defined in: [packages/query-core/src/mutationCache.ts:236](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationCache.ts#L236) + +Removes all mutations from the cache. + +#### Returns + +`void` + +#### Example + +```ts +const mutationCache = queryClient.getMutationCache() + +mutationCache.clear() +``` + +*** + +### find() + +```ts +find(filters): + | Mutation + | undefined; +``` + +Defined in: [packages/query-core/src/mutationCache.ts:278](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationCache.ts#L278) + +A slightly more advanced method that can be used to get an existing mutation instance from +the cache. If the mutation does not exist, `undefined` is returned. + +This is not typically needed for most applications, but can come in handy when needing more +information about a mutation in rare scenarios. + +#### Type Parameters + +##### TData + +`TData` = `unknown` + +##### TError + +`TError` = `Error` + +##### TVariables + +`TVariables` = `any` + +##### TOnMutateResult + +`TOnMutateResult` = `unknown` + +#### Parameters + +##### filters + +[`MutationFilters`](../interfaces/MutationFilters.md) + +#### Returns + + \| [`Mutation`](Mutation.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\> + \| `undefined` + +#### See + +[MutationCache#findAll](#findall) + +#### Example + +```ts +const mutationCache = queryClient.getMutationCache() + +const mutation = mutationCache.find({ mutationKey: ['addPost'] }) +``` + +*** + +### findAll() + +```ts +findAll(filters): Mutation[]; +``` + +Defined in: [packages/query-core/src/mutationCache.ts:308](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationCache.ts#L308) + +An even more advanced method that can be used to get existing mutation instances from the +cache that match the given filters. If no mutations match, an empty array is returned. + +This is not typically needed for most applications, but can come in handy when needing more +information about mutations in rare scenarios. + +#### Parameters + +##### filters + +[`MutationFilters`](../interfaces/MutationFilters.md) = `{}` + +#### Returns + +[`Mutation`](Mutation.md)\<`unknown`, `Error`, `unknown`, `unknown`\>[] + +#### See + +[MutationCache#find](#find) + +#### Example + +```ts +const mutationCache = queryClient.getMutationCache() + +const mutations = mutationCache.findAll({ mutationKey: ['addPost'] }) +``` + +*** + +### getAll() + +```ts +getAll(): Mutation[]; +``` + +Defined in: [packages/query-core/src/mutationCache.ts:259](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationCache.ts#L259) + +Returns all mutations within the cache. + +This is not typically needed for most applications, but can come in handy when needing more +information about a mutation in rare scenarios. + +#### Returns + +[`Mutation`](Mutation.md)\<`unknown`, `Error`, `unknown`, `unknown`\>[] + +#### Example + +```ts +const mutationCache = queryClient.getMutationCache() + +const mutations = mutationCache.getAll() +``` + +*** + +### hasListeners() + +```ts +hasListeners(): boolean; +``` + +Defined in: [packages/query-core/src/subscribable.ts:19](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L19) + +#### Returns + +`boolean` + +#### Inherited from + +```ts +Subscribable.hasListeners +``` + +*** + +### onSubscribe() + +```ts +protected onSubscribe(): void; +``` + +Defined in: [packages/query-core/src/subscribable.ts:23](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L23) + +#### Returns + +`void` + +#### Inherited from + +```ts +Subscribable.onSubscribe +``` + +*** + +### onUnsubscribe() + +```ts +protected onUnsubscribe(): void; +``` + +Defined in: [packages/query-core/src/subscribable.ts:27](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L27) + +#### Returns + +`void` + +#### Inherited from + +```ts +Subscribable.onUnsubscribe +``` + +*** + +### subscribe() + +```ts +subscribe(listener): () => void; +``` + +Defined in: [packages/query-core/src/subscribable.ts:8](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L8) + +#### Parameters + +##### listener + +`MutationCacheListener` + +#### Returns + +```ts +(): void; +``` + +##### Returns + +`void` + +#### Inherited from + +```ts +Subscribable.subscribe +``` diff --git a/docs/framework/svelte/reference/classes/MutationObserver.md b/docs/framework/svelte/reference/classes/MutationObserver.md new file mode 100644 index 00000000000..a121c67b0e8 --- /dev/null +++ b/docs/framework/svelte/reference/classes/MutationObserver.md @@ -0,0 +1,335 @@ +--- +id: MutationObserver +title: MutationObserver +--- + +Defined in: [packages/query-core/src/mutationObserver.ts:38](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationObserver.ts#L38) + +Observes a single mutation and derives a `MutationObserverResult` from it. +A framework hook like `useMutation` creates one `MutationObserver` per hook +call, keeps it stable across re-renders, calls `setOptions` when the options +passed to the hook change, subscribes to it to re-render on updates, and +reads `getCurrentResult()` for the value to return. Calling `mutate()` +builds a new underlying `Mutation` in the `MutationCache` and executes it. + +## Example + +```ts +const observer = new MutationObserver(queryClient, { + mutationFn: (variables: { title: string }) => addPost(variables), +}) +``` + +## Extends + +- `Subscribable`\<`MutationObserverListener`\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\>\> + +## Type Parameters + +### TData + +`TData` = `unknown` + +### TError + +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) + +### TVariables + +`TVariables` = `void` + +### TOnMutateResult + +`TOnMutateResult` = `unknown` + +## Constructors + +### Constructor + +```ts +new MutationObserver(client, options): MutationObserver; +``` + +Defined in: [packages/query-core/src/mutationObserver.ts:58](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationObserver.ts#L58) + +#### Parameters + +##### client + +[`QueryClient`](QueryClient.md) + +##### options + +[`MutationObserverOptions`](../interfaces/MutationObserverOptions.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\> + +#### Returns + +`MutationObserver`\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\> + +#### Overrides + +```ts +Subscribable< + MutationObserverListener +>.constructor +``` + +## Properties + +### listeners + +```ts +protected listeners: Set>; +``` + +Defined in: [packages/query-core/src/subscribable.ts:2](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L2) + +#### Inherited from + +```ts +Subscribable.listeners +``` + +*** + +### options + +```ts +options: MutationObserverOptions; +``` + +Defined in: [packages/query-core/src/mutationObserver.ts:46](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationObserver.ts#L46) + +## Methods + +### bindMethods() + +```ts +protected bindMethods(): void; +``` + +Defined in: [packages/query-core/src/mutationObserver.ts:75](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationObserver.ts#L75) + +#### Returns + +`void` + +*** + +### getCurrentResult() + +```ts +getCurrentResult(): MutationObserverResult; +``` + +Defined in: [packages/query-core/src/mutationObserver.ts:155](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationObserver.ts#L155) + +Returns the observer's current result, derived from the observed +mutation's state (or the default, `idle` state if no mutation has been +built yet, e.g. before the first `mutate()` call or after `reset()`). + +#### Returns + +[`MutationObserverResult`](../type-aliases/MutationObserverResult.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\> + +*** + +### hasListeners() + +```ts +hasListeners(): boolean; +``` + +Defined in: [packages/query-core/src/subscribable.ts:19](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L19) + +#### Returns + +`boolean` + +#### Inherited from + +```ts +Subscribable.hasListeners +``` + +*** + +### mutate() + +```ts +mutate(variables, options?): Promise; +``` + +Defined in: [packages/query-core/src/mutationObserver.ts:207](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationObserver.ts#L207) + +Builds a new `Mutation` in the `MutationCache` using the observer's +current options, detaches this observer from any previously observed +mutation, attaches it to the new one, and executes it with the given +variables. + +The optional per-call `options` (`onSuccess`/`onError`/`onSettled`) are +invoked once the mutation settles, in addition to any callbacks defined +on the observer's own options. + +#### Parameters + +##### variables + +`TVariables` + +##### options? + +[`MutateOptions`](../interfaces/MutateOptions.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\> + +#### Returns + +`Promise`\<`TData`\> + +#### Example + +```ts +await observer.mutate( + { title: 'New post' }, + { onSuccess: (data) => console.log(data) }, +) +``` + +*** + +### onSubscribe() + +```ts +protected onSubscribe(): void; +``` + +Defined in: [packages/query-core/src/mutationObserver.ts:127](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationObserver.ts#L127) + +#### Returns + +`void` + +#### Overrides + +```ts +Subscribable.onSubscribe +``` + +*** + +### onUnsubscribe() + +```ts +protected onUnsubscribe(): void; +``` + +Defined in: [packages/query-core/src/mutationObserver.ts:135](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationObserver.ts#L135) + +#### Returns + +`void` + +#### Overrides + +```ts +Subscribable.onUnsubscribe +``` + +*** + +### reset() + +```ts +reset(): void; +``` + +Defined in: [packages/query-core/src/mutationObserver.ts:180](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationObserver.ts#L180) + +Detaches the observer from the mutation it is currently observing (if +any) and resets the observed result back to its default, `idle` state. + +This does not cancel an in-flight mutation; the mutation itself keeps +running to completion and its own callbacks still fire, but this +observer stops reflecting its state and a subsequent `mutate()` call +will build a brand new mutation. + +#### Returns + +`void` + +#### Example + +```ts +observer.reset() +``` + +#### See + +[MutationObserver#mutate](#mutate) + +*** + +### setOptions() + +```ts +setOptions(options): void; +``` + +Defined in: [packages/query-core/src/mutationObserver.ts:96](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationObserver.ts#L96) + +Updates the observer's options. + +If the new `mutationKey` differs from the previous one (and both were +defined), the observer is reset, detaching it from the mutation it was +observing. Otherwise, if the currently observed mutation is still +`pending`, its options are updated in place as well. + +#### Parameters + +##### options + +[`MutationObserverOptions`](../interfaces/MutationObserverOptions.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\> + +#### Returns + +`void` + +#### Example + +```ts +observer.setOptions({ + mutationFn: (variables: { title: string }) => addPost(variables), + onSuccess: (data) => console.log(data), +}) +``` + +*** + +### subscribe() + +```ts +subscribe(listener): () => void; +``` + +Defined in: [packages/query-core/src/subscribable.ts:8](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L8) + +#### Parameters + +##### listener + +`MutationObserverListener` + +#### Returns + +```ts +(): void; +``` + +##### Returns + +`void` + +#### Inherited from + +```ts +Subscribable.subscribe +``` diff --git a/docs/framework/svelte/reference/classes/QueriesObserver.md b/docs/framework/svelte/reference/classes/QueriesObserver.md new file mode 100644 index 00000000000..379e6fc95ee --- /dev/null +++ b/docs/framework/svelte/reference/classes/QueriesObserver.md @@ -0,0 +1,325 @@ +--- +id: QueriesObserver +title: QueriesObserver +--- + +Defined in: [packages/query-core/src/queriesObserver.ts:56](https://github.com/TanStack/query/blob/main/packages/query-core/src/queriesObserver.ts#L56) + +A `QueriesObserver` watches an array of queries at once, exposing them as +a single array of `QueryObserverResult`s (or, when a `combine` option is +given, as a combined value derived from that array). It manages one +internal `QueryObserver` per query, and is the primitive that framework +adapters (e.g. `useQueries`) build their hooks on top of. + +## Example + +```ts +const observer = new QueriesObserver(queryClient, [ + { queryKey: ['post', 1], queryFn: fetchPost }, + { queryKey: ['post', 2], queryFn: fetchPost }, +]) + +const unsubscribe = observer.subscribe((result) => { + console.log(result) +}) +``` + +## Extends + +- `Subscribable`\<`QueriesObserverListener`\> + +## Type Parameters + +### TCombinedResult + +`TCombinedResult` = [`QueryObserverResult`](../type-aliases/QueryObserverResult.md)[] + +## Constructors + +### Constructor + +```ts +new QueriesObserver( + client, + queries, +options?): QueriesObserver; +``` + +Defined in: [packages/query-core/src/queriesObserver.ts:70](https://github.com/TanStack/query/blob/main/packages/query-core/src/queriesObserver.ts#L70) + +#### Parameters + +##### client + +[`QueryClient`](QueryClient.md) + +##### queries + +[`QueryObserverOptions`](../interfaces/QueryObserverOptions.md)\<`any`, `any`, `any`, `any`, `any`, `never`\>[] + +##### options? + +[`QueriesObserverOptions`](../interfaces/QueriesObserverOptions.md)\<`TCombinedResult`\> + +#### Returns + +`QueriesObserver`\<`TCombinedResult`\> + +#### Overrides + +```ts +Subscribable.constructor +``` + +## Properties + +### listeners + +```ts +protected listeners: Set; +``` + +Defined in: [packages/query-core/src/subscribable.ts:2](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L2) + +#### Inherited from + +```ts +Subscribable.listeners +``` + +## Methods + +### destroy() + +```ts +destroy(): void; +``` + +Defined in: [packages/query-core/src/queriesObserver.ts:106](https://github.com/TanStack/query/blob/main/packages/query-core/src/queriesObserver.ts#L106) + +Stops observing all queries: clears all listeners and destroys every +underlying `QueryObserver` this observer manages. + +#### Returns + +`void` + +*** + +### getCurrentResult() + +```ts +getCurrentResult(): QueryObserverResult[]; +``` + +Defined in: [packages/query-core/src/queriesObserver.ts:210](https://github.com/TanStack/query/blob/main/packages/query-core/src/queriesObserver.ts#L210) + +Returns the most recently computed array of `QueryObserverResult`s, one +per observed query, in the same order as the queries passed to the +constructor or `setQueries`. + +#### Returns + +[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)[] + +#### Example + +```ts +const results = observer.getCurrentResult() +const data = results.map((result) => result.data) +``` + +*** + +### getObservers() + +```ts +getObservers(): QueryObserver[]; +``` + +Defined in: [packages/query-core/src/queriesObserver.ts:227](https://github.com/TanStack/query/blob/main/packages/query-core/src/queriesObserver.ts#L227) + +Returns the underlying `QueryObserver` instances this observer manages, +in the same order as the queries passed to the constructor or +`setQueries`. + +#### Returns + +[`QueryObserver`](QueryObserver.md)\<`unknown`, `Error`, `unknown`, `unknown`, readonly `unknown`[]\>[] + +*** + +### getOptimisticResult() + +```ts +getOptimisticResult(queries, combine): [QueryObserverResult[], (r?) => TCombinedResult, () => QueryObserverResult[]]; +``` + +Defined in: [packages/query-core/src/queriesObserver.ts:238](https://github.com/TanStack/query/blob/main/packages/query-core/src/queriesObserver.ts#L238) + +The `QueriesObserver` counterpart of [QueryObserver#getOptimisticResult](QueryObserver.md#getoptimisticresult) — computes +the result for the given (already-defaulted) queries right now, synchronously. Called by +framework adapters (e.g. `useQueries`) ahead of subscribing, returning a tuple of the raw +per-query results, a function to compute the combined result from them, and a function to +wrap the results for property-access tracking. + +#### Parameters + +##### queries + +[`QueryObserverOptions`](../interfaces/QueryObserverOptions.md)\<`unknown`, `Error`, `unknown`, `unknown`, readonly `unknown`[], `never`\>[] + +##### combine + +`CombineFn`\<`TCombinedResult`\> | `undefined` + +#### Returns + +\[[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)[], (`r?`) => `TCombinedResult`, () => [`QueryObserverResult`](../type-aliases/QueryObserverResult.md)[]\] + +*** + +### getQueries() + +```ts +getQueries(): Query[]; +``` + +Defined in: [packages/query-core/src/queriesObserver.ts:218](https://github.com/TanStack/query/blob/main/packages/query-core/src/queriesObserver.ts#L218) + +Returns the underlying `Query` instances currently being observed, in +the same order as the queries passed to the constructor or `setQueries`. + +#### Returns + +[`Query`](Query.md)\<`unknown`, `Error`, `unknown`, readonly `unknown`[]\>[] + +*** + +### hasListeners() + +```ts +hasListeners(): boolean; +``` + +Defined in: [packages/query-core/src/subscribable.ts:19](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L19) + +#### Returns + +`boolean` + +#### Inherited from + +```ts +Subscribable.hasListeners +``` + +*** + +### onSubscribe() + +```ts +protected onSubscribe(): void; +``` + +Defined in: [packages/query-core/src/queriesObserver.ts:86](https://github.com/TanStack/query/blob/main/packages/query-core/src/queriesObserver.ts#L86) + +#### Returns + +`void` + +#### Overrides + +```ts +Subscribable.onSubscribe +``` + +*** + +### onUnsubscribe() + +```ts +protected onUnsubscribe(): void; +``` + +Defined in: [packages/query-core/src/queriesObserver.ts:96](https://github.com/TanStack/query/blob/main/packages/query-core/src/queriesObserver.ts#L96) + +#### Returns + +`void` + +#### Overrides + +```ts +Subscribable.onUnsubscribe +``` + +*** + +### setQueries() + +```ts +setQueries(queries, options?): void; +``` + +Defined in: [packages/query-core/src/queriesObserver.ts:127](https://github.com/TanStack/query/blob/main/packages/query-core/src/queriesObserver.ts#L127) + +Replaces the set of queries being observed. Existing `QueryObserver`s +are reused for queries that match an already-observed query hash; +observers for queries that are no longer present are destroyed, and new +observers are created and subscribed to for newly added queries. + +#### Parameters + +##### queries + +[`QueryObserverOptions`](../interfaces/QueryObserverOptions.md)\<`unknown`, `Error`, `unknown`, `unknown`, readonly `unknown`[], `never`\>[] + +##### options? + +[`QueriesObserverOptions`](../interfaces/QueriesObserverOptions.md)\<`TCombinedResult`\> + +#### Returns + +`void` + +#### Example + +```ts +observer.setQueries([ + { queryKey: ['post', 1], queryFn: fetchPost }, + { queryKey: ['post', 3], queryFn: fetchPost }, +]) +``` + +*** + +### subscribe() + +```ts +subscribe(listener): () => void; +``` + +Defined in: [packages/query-core/src/subscribable.ts:8](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L8) + +#### Parameters + +##### listener + +`QueriesObserverListener` + +#### Returns + +```ts +(): void; +``` + +##### Returns + +`void` + +#### Inherited from + +```ts +Subscribable.subscribe +``` diff --git a/docs/framework/svelte/reference/classes/Query.md b/docs/framework/svelte/reference/classes/Query.md new file mode 100644 index 00000000000..bc15461e541 --- /dev/null +++ b/docs/framework/svelte/reference/classes/Query.md @@ -0,0 +1,585 @@ +--- +id: Query +title: Query +--- + +Defined in: [packages/query-core/src/query.ts:225](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L225) + +Represents a single cached query. A `Query` holds the query's key, options, +state (data/error/status), and the observers currently subscribed to it. + +Instances are created and managed internally by `QueryCache`; application +code typically interacts with queries indirectly through `QueryClient` or +a framework hook like `useQuery`. Direct access to a `Query` instance is +possible via `queryCache.find()`/`findAll()` for inspecting cache state. + +## Example + +```ts +const queryCache = queryClient.getQueryCache() +const query = queryCache.find({ queryKey: ['posts'] }) + +if (query) { + console.log(query.state.dataUpdatedAt) +} +``` + +## Extends + +- `Removable` + +## Type Parameters + +### TQueryFnData + +`TQueryFnData` = `unknown` + +### TError + +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) + +### TData + +`TData` = `TQueryFnData` + +### TQueryKey + +`TQueryKey` *extends* [`QueryKey`](../type-aliases/QueryKey.md) = [`QueryKey`](../type-aliases/QueryKey.md) + +## Constructors + +### Constructor + +```ts +new Query(config): Query; +``` + +Defined in: [packages/query-core/src/query.ts:246](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L246) + +#### Parameters + +##### config + +`QueryConfig`\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`\> + +#### Returns + +`Query`\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`\> + +#### Overrides + +```ts +Removable.constructor +``` + +## Properties + +### gcTime + +```ts +gcTime: number; +``` + +Defined in: [packages/query-core/src/removable.ts:7](https://github.com/TanStack/query/blob/main/packages/query-core/src/removable.ts#L7) + +#### Inherited from + +```ts +Removable.gcTime +``` + +*** + +### observers + +```ts +observers: QueryObserver[]; +``` + +Defined in: [packages/query-core/src/query.ts:242](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L242) + +*** + +### options + +```ts +options: QueryOptions; +``` + +Defined in: [packages/query-core/src/query.ts:233](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L233) + +*** + +### queryHash + +```ts +queryHash: string; +``` + +Defined in: [packages/query-core/src/query.ts:232](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L232) + +*** + +### queryKey + +```ts +queryKey: TQueryKey; +``` + +Defined in: [packages/query-core/src/query.ts:231](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L231) + +*** + +### state + +```ts +state: QueryState; +``` + +Defined in: [packages/query-core/src/query.ts:234](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L234) + +## Accessors + +### meta + +#### Get Signature + +```ts +get meta(): Record | undefined; +``` + +Defined in: [packages/query-core/src/query.ts:264](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L264) + +The `meta` object passed in the query's options, if any. + +##### Returns + +`Record`\<`string`, `unknown`\> \| `undefined` + +*** + +### promise + +#### Get Signature + +```ts +get promise(): Promise | undefined; +``` + +Defined in: [packages/query-core/src/query.ts:277](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L277) + +The promise for the currently in-flight fetch, if the query is fetching. +`undefined` when the query is not fetching. + +##### Returns + +`Promise`\<`TData`\> \| `undefined` + +## Methods + +### cancel() + +```ts +cancel(options?): Promise; +``` + +Defined in: [packages/query-core/src/query.ts:348](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L348) + +Cancels the query's currently in-flight fetch, if any. +- Returns a promise that resolves once the cancellation has settled. +- If no fetch is in progress, resolves immediately. + +#### Parameters + +##### options? + +[`CancelOptions`](../interfaces/CancelOptions.md) + +#### Returns + +`Promise`\<`void`\> + +#### Example + +```ts +await query.cancel() +``` + +*** + +### clearGcTimeout() + +```ts +protected clearGcTimeout(): void; +``` + +Defined in: [packages/query-core/src/removable.ts:32](https://github.com/TanStack/query/blob/main/packages/query-core/src/removable.ts#L32) + +#### Returns + +`void` + +#### Inherited from + +```ts +Removable.clearGcTimeout +``` + +*** + +### destroy() + +```ts +destroy(): void; +``` + +Defined in: [packages/query-core/src/query.ts:361](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L361) + +Clears the query's garbage collection timeout and silently cancels any +in-flight fetch. Called by `QueryCache` when the query is removed from +the cache. + +#### Returns + +`void` + +#### See + +[Query#cancel](#cancel) + +#### Overrides + +```ts +Removable.destroy +``` + +*** + +### fetch() + +```ts +fetch(options?, fetchOptions?): Promise; +``` + +Defined in: [packages/query-core/src/query.ts:590](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L590) + +Fetches the query, i.e. runs its `queryFn` (through any configured +retryer/behavior) and updates the query's state with the result. +- If a fetch is already in flight, returns its promise instead of + starting a new one, unless `fetchOptions.cancelRefetch` is set and the + query already has data, in which case the current fetch is silently + cancelled first. +- If `options` is passed, it replaces the query's current options + before fetching. + +#### Parameters + +##### options? + +[`QueryOptions`](../interfaces/QueryOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`, `never`\> + +##### fetchOptions? + +`FetchOptions`\<`TQueryFnData`\> + +#### Returns + +`Promise`\<`TData`\> + +*** + +### getObserversCount() + +```ts +getObserversCount(): number; +``` + +Defined in: [packages/query-core/src/query.ts:560](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L560) + +Returns the number of observers currently subscribed to this query. + +#### Returns + +`number` + +#### Example + +```ts +if (query.getObserversCount() === 0) { + // no component is currently watching this query +} +``` + +*** + +### invalidate() + +```ts +invalidate(): void; +``` + +Defined in: [packages/query-core/src/query.ts:574](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L574) + +Marks the query as invalidated, unless it is already invalidated. This +updates `state.isInvalidated` and notifies observers, but does not by +itself trigger a refetch. + +#### Returns + +`void` + +#### Example + +```ts +query.invalidate() +``` + +*** + +### isActive() + +```ts +isActive(): boolean; +``` + +Defined in: [packages/query-core/src/query.ts:386](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L386) + +Returns `true` if the query has at least one observer for which `enabled` +does not resolve to `false`. + +#### Returns + +`boolean` + +*** + +### isDisabled() + +```ts +isDisabled(): boolean; +``` + +Defined in: [packages/query-core/src/query.ts:400](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L400) + +Returns `true` if the query is disabled, meaning it will not fetch +automatically. +- If the query has observers, it is disabled when none of them are active + (see `isActive`). +- If the query has no observers, it is disabled when its `queryFn` is + `skipToken` or it has never been fetched. + +#### Returns + +`boolean` + +*** + +### isFetched() + +```ts +isFetched(): boolean; +``` + +Defined in: [packages/query-core/src/query.ts:412](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L412) + +Returns `true` if the query has been fetched, i.e. it has resolved with +either data or an error at least once. + +#### Returns + +`boolean` + +*** + +### isStale() + +```ts +isStale(): boolean; +``` + +Defined in: [packages/query-core/src/query.ts:447](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L447) + +Returns `true` if the query is stale. +- If the query has observers, defers to whether any observer's current + result reports `isStale` (which accounts for each observer's own + `staleTime` and `enabled` state). +- If the query has no observers, it is considered stale when it has no + data or has been invalidated. + +#### Returns + +`boolean` + +#### See + +[Query#isStaleByTime](#isstalebytime) + +#### Example + +```ts +if (query.isStale()) { + // refetch or otherwise treat the cached data as outdated +} +``` + +*** + +### isStaleByTime() + +```ts +isStaleByTime(staleTime): boolean; +``` + +Defined in: [packages/query-core/src/query.ts:473](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L473) + +Returns `true` if the query's data is stale relative to the given +`staleTime` (defaults to `0`). +- A query with no data is always stale. +- `staleTime: 'static'` is never stale. +- An invalidated query is always stale. +- Otherwise, staleness is based on elapsed time since `dataUpdatedAt`. + +#### Parameters + +##### staleTime + +[`StaleTime`](../type-aliases/StaleTime.md) = `0` + +#### Returns + +`boolean` + +#### See + +[Query#isStale](#isstale) + +#### Example + +```ts +const isStale = query.isStaleByTime(1000 * 60) +``` + +*** + +### isStatic() + +```ts +isStatic(): boolean; +``` + +Defined in: [packages/query-core/src/query.ts:420](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L420) + +Returns `true` if the query has at least one observer configured with +`staleTime: 'static'`, meaning it is treated as never stale. + +#### Returns + +`boolean` + +*** + +### optionalRemove() + +```ts +protected optionalRemove(): void; +``` + +Defined in: [packages/query-core/src/query.ts:305](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L305) + +#### Returns + +`void` + +#### Overrides + +```ts +Removable.optionalRemove +``` + +*** + +### reset() + +```ts +reset(): void; +``` + +Defined in: [packages/query-core/src/query.ts:377](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L377) + +Resets the query back to its initial state (the state it had when it was +first created, e.g. any `initialData`), destroying it first to cancel any +in-flight fetch. + +#### Returns + +`void` + +*** + +### scheduleGc() + +```ts +protected scheduleGc(): void; +``` + +Defined in: [packages/query-core/src/removable.ts:14](https://github.com/TanStack/query/blob/main/packages/query-core/src/removable.ts#L14) + +#### Returns + +`void` + +#### Inherited from + +```ts +Removable.scheduleGc +``` + +*** + +### setState() + +```ts +setState(state): void; +``` + +Defined in: [packages/query-core/src/query.ts:334](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L334) + +Merges the given partial state directly into this query's state, notifying observers. Used +by persistence and broadcast plugins to restore a state snapshot, and by devtools to let a +user manually trigger a loading/error state or edit the cached data. + +#### Parameters + +##### state + +`Partial`\<[`QueryState`](../interfaces/QueryState.md)\<`TData`, `TError`\>\> + +#### Returns + +`void` + +*** + +### updateGcTime() + +```ts +protected updateGcTime(newGcTime): void; +``` + +Defined in: [packages/query-core/src/removable.ts:24](https://github.com/TanStack/query/blob/main/packages/query-core/src/removable.ts#L24) + +#### Parameters + +##### newGcTime + +`number` | `undefined` + +#### Returns + +`void` + +#### Inherited from + +```ts +Removable.updateGcTime +``` diff --git a/docs/framework/svelte/reference/classes/QueryCache.md b/docs/framework/svelte/reference/classes/QueryCache.md new file mode 100644 index 00000000000..b7a577b5e54 --- /dev/null +++ b/docs/framework/svelte/reference/classes/QueryCache.md @@ -0,0 +1,471 @@ +--- +id: QueryCache +title: QueryCache +--- + +Defined in: [packages/query-core/src/queryCache.ts:123](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryCache.ts#L123) + +The `QueryCache` is the storage mechanism for TanStack Query. It stores all the data, meta +information, and state of the queries it contains. + +Normally, you will not interact with the `QueryCache` directly and instead use a `QueryClient` +for a specific cache. You can subscribe to it (inherited from `Subscribable`) to be informed of +safe/known updates to the cache, such as queries being added, removed, or updated — updates made +outside of the cache's own tracked mechanisms (e.g. mutating a query's state object directly) do +not notify subscribers. + +## Example + +```ts +const unsubscribe = queryCache.subscribe((event) => { + console.log(event.type, event.query) +}) +``` + +## Extends + +- `Subscribable`\<`QueryCacheListener`\> + +## Constructors + +### Constructor + +```ts +new QueryCache(config): QueryCache; +``` + +Defined in: [packages/query-core/src/queryCache.ts:126](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryCache.ts#L126) + +#### Parameters + +##### config + +[`QueryCacheConfig`](../interfaces/QueryCacheConfig.md) = `{}` + +#### Returns + +`QueryCache` + +#### Overrides + +```ts +Subscribable.constructor +``` + +## Properties + +### config + +```ts +config: QueryCacheConfig = {}; +``` + +Defined in: [packages/query-core/src/queryCache.ts:126](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryCache.ts#L126) + +*** + +### listeners + +```ts +protected listeners: Set; +``` + +Defined in: [packages/query-core/src/subscribable.ts:2](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L2) + +#### Inherited from + +```ts +Subscribable.listeners +``` + +## Methods + +### build() + +```ts +build( + client, + options, +state?): Query; +``` + +Defined in: [packages/query-core/src/queryCache.ts:147](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryCache.ts#L147) + +Returns the existing `Query` instance for the given options' `queryKey`/`queryHash`, or +builds and adds a new one to the cache if none exists yet. Used by framework adapters and +plugins (e.g. broadcast/persistence) that need to get-or-create a `Query` directly, bypassing +the reactive `QueryObserver` machinery. + +#### Type Parameters + +##### TQueryFnData + +`TQueryFnData` = `unknown` + +##### TError + +`TError` = `Error` + +##### TData + +`TData` = `TQueryFnData` + +##### TQueryKey + +`TQueryKey` *extends* readonly `unknown`[] = readonly `unknown`[] + +#### Parameters + +##### client + +[`QueryClient`](QueryClient.md) + +##### options + +[`WithRequired`](../type-aliases/WithRequired.md)\<[`QueryOptions`](../interfaces/QueryOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`, `never`\>, `"queryKey"`\> + +##### state? + +[`QueryState`](../interfaces/QueryState.md)\<`TData`, `TError`\> + +#### Returns + +[`Query`](Query.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`\> + +#### Example + +```ts +const queryCache = queryClient.getQueryCache() + +const query = queryCache.build(queryClient, { + queryKey: ['posts'], + queryFn: fetchPosts, +}) +``` + +*** + +### clear() + +```ts +clear(): void; +``` + +Defined in: [packages/query-core/src/queryCache.ts:232](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryCache.ts#L232) + +Removes all queries from the cache. + +#### Returns + +`void` + +#### Example + +```ts +const queryCache = queryClient.getQueryCache() + +queryCache.clear() +``` + +*** + +### find() + +```ts +find(filters): + | Query + | undefined; +``` + +Defined in: [packages/query-core/src/queryCache.ts:299](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryCache.ts#L299) + +A slightly more advanced method that can be used to get an existing query instance from the +cache. This instance not only contains all the state for the query, but all of the instances, +and underlying guts of the query as well. If the query does not exist, `undefined` is +returned. + +This is not typically needed for most applications, but can come in handy when needing more +information about a query in rare scenarios (e.g. looking at `query.state.dataUpdatedAt` to +decide whether a query is fresh enough to be used as an initial value). + +#### Type Parameters + +##### TQueryFnData + +`TQueryFnData` = `unknown` + +##### TError + +`TError` = `Error` + +##### TData + +`TData` = `TQueryFnData` + +#### Parameters + +##### filters + +[`WithRequired`](../type-aliases/WithRequired.md)\<[`QueryFilters`](../interfaces/QueryFilters.md)\, `"queryKey"`\> + +#### Returns + + \| [`Query`](Query.md)\<`TQueryFnData`, `TError`, `TData`, readonly `unknown`[]\> + \| `undefined` + +#### See + +[QueryCache#findAll](#findall) + +#### Example + +```ts +const queryCache = queryClient.getQueryCache() + +const query = queryCache.find({ queryKey: ['posts'] }) +``` + +*** + +### findAll() + +```ts +findAll(filters): Query[]; +``` + +Defined in: [packages/query-core/src/queryCache.ts:324](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryCache.ts#L324) + +An even more advanced method that can be used to get existing query instances from the cache +that partially match a query key. If no queries match, an empty array is returned. + +This is not typically needed for most applications, but can come in handy when needing more +information about queries in rare scenarios. + +#### Parameters + +##### filters + +[`QueryFilters`](../interfaces/QueryFilters.md)\<`any`\> = `{}` + +#### Returns + +[`Query`](Query.md)\<`unknown`, `Error`, `unknown`, readonly `unknown`[]\>[] + +#### See + +[QueryCache#find](#find) + +#### Example + +```ts +const queryCache = queryClient.getQueryCache() + +const queries = queryCache.findAll({ queryKey: ['posts'] }) +``` + +*** + +### get() + +```ts +get(queryHash): + | Query + | undefined; +``` + +Defined in: [packages/query-core/src/queryCache.ts:254](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryCache.ts#L254) + +Returns the `Query` instance stored under the given `queryHash`, or `undefined` if none +exists. Unlike [QueryCache#find](#find), this looks up by the already-computed hash rather +than by `QueryFilters`. Used by plugins (e.g. broadcast/hydration) that already have a hash +to look up directly. + +#### Type Parameters + +##### TQueryFnData + +`TQueryFnData` = `unknown` + +##### TError + +`TError` = `Error` + +##### TData + +`TData` = `TQueryFnData` + +##### TQueryKey + +`TQueryKey` *extends* readonly `unknown`[] = readonly `unknown`[] + +#### Parameters + +##### queryHash + +`string` + +#### Returns + + \| [`Query`](Query.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`\> + \| `undefined` + +#### Example + +```ts +const queryCache = queryClient.getQueryCache() +const queryHash = hashKey(['posts']) + +const query = queryCache.get(queryHash) +``` + +*** + +### getAll() + +```ts +getAll(): Query[]; +``` + +Defined in: [packages/query-core/src/queryCache.ts:277](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryCache.ts#L277) + +Returns all queries within the cache. + +#### Returns + +[`Query`](Query.md)\<`unknown`, `Error`, `unknown`, readonly `unknown`[]\>[] + +#### Example + +```ts +const queryCache = queryClient.getQueryCache() + +const queries = queryCache.getAll() +``` + +*** + +### hasListeners() + +```ts +hasListeners(): boolean; +``` + +Defined in: [packages/query-core/src/subscribable.ts:19](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L19) + +#### Returns + +`boolean` + +#### Inherited from + +```ts +Subscribable.hasListeners +``` + +*** + +### onSubscribe() + +```ts +protected onSubscribe(): void; +``` + +Defined in: [packages/query-core/src/subscribable.ts:23](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L23) + +#### Returns + +`void` + +#### Inherited from + +```ts +Subscribable.onSubscribe +``` + +*** + +### onUnsubscribe() + +```ts +protected onUnsubscribe(): void; +``` + +Defined in: [packages/query-core/src/subscribable.ts:27](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L27) + +#### Returns + +`void` + +#### Inherited from + +```ts +Subscribable.onUnsubscribe +``` + +*** + +### remove() + +```ts +remove(query): void; +``` + +Defined in: [packages/query-core/src/queryCache.ts:208](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryCache.ts#L208) + +Destroys the given `Query` and removes it from the cache, notifying subscribers with a +`'removed'` event. A no-op if the query is no longer the one currently stored under its hash +(e.g. it was already replaced). Used by plugins (e.g. the broadcast client) that mirror +removals across `QueryCache` instances. + +#### Parameters + +##### query + +[`Query`](Query.md)\<`any`, `any`, `any`, `any`\> + +#### Returns + +`void` + +#### Example + +```ts +const queryCache = queryClient.getQueryCache() +const query = queryCache.find({ queryKey: ['posts'] }) + +if (query) { + queryCache.remove(query) +} +``` + +*** + +### subscribe() + +```ts +subscribe(listener): () => void; +``` + +Defined in: [packages/query-core/src/subscribable.ts:8](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L8) + +#### Parameters + +##### listener + +`QueryCacheListener` + +#### Returns + +```ts +(): void; +``` + +##### Returns + +`void` + +#### Inherited from + +```ts +Subscribable.subscribe +``` diff --git a/docs/framework/svelte/reference/classes/QueryClient.md b/docs/framework/svelte/reference/classes/QueryClient.md new file mode 100644 index 00000000000..c7d1a034545 --- /dev/null +++ b/docs/framework/svelte/reference/classes/QueryClient.md @@ -0,0 +1,1466 @@ +--- +id: QueryClient +title: QueryClient +--- + +Defined in: [packages/query-core/src/queryClient.ts:79](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L79) + +`QueryClient` is used to interact with a cache of queries and mutations. It owns a +`QueryCache` and a `MutationCache` (creating default ones if none are passed in) and holds +the default options that are applied to queries and mutations created through it. + +## Example + +```ts +const queryClient = new QueryClient({ + defaultOptions: { + queries: { + staleTime: Infinity, + }, + }, +}) + +await queryClient.query({ queryKey: ['posts'], queryFn: fetchPosts }) +``` + +## Constructors + +### Constructor + +```ts +new QueryClient(config): QueryClient; +``` + +Defined in: [packages/query-core/src/queryClient.ts:89](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L89) + +#### Parameters + +##### config + +[`QueryClientConfig`](../interfaces/QueryClientConfig.md) = `{}` + +#### Returns + +`QueryClient` + +## Methods + +### cancelQueries() + +```ts +cancelQueries(filters?, cancelOptions?): Promise; +``` + +Defined in: [packages/query-core/src/queryClient.ts:432](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L432) + +Cancels outgoing fetches for queries matching the given filters. Most useful when performing +optimistic updates, since any outgoing refetch that resolves afterwards would otherwise +overwrite the optimistic update. By default (`revert: true`), a cancelled query's data is +reverted to its state before the outgoing fetch started. + +The returned promise never rejects, even if individual cancellations fail. + +#### Type Parameters + +##### TTaggedQueryKey + +`TTaggedQueryKey` *extends* readonly `unknown`[] = readonly `unknown`[] + +#### Parameters + +##### filters? + +[`QueryFilters`](../interfaces/QueryFilters.md)\<`TTaggedQueryKey`\> + +##### cancelOptions? + +[`CancelOptions`](../interfaces/CancelOptions.md) = `{}` + +#### Returns + +`Promise`\<`void`\> + +#### Example + +```ts +await queryClient.cancelQueries({ queryKey: ['posts'], exact: true }) +``` + +*** + +### clear() + +```ts +clear(): void; +``` + +Defined in: [packages/query-core/src/queryClient.ts:1083](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L1083) + +Clears both the query cache and the mutation cache this client is connected to. + +#### Returns + +`void` + +#### Example + +```ts +import { QueryClient } from '@tanstack/query-core' + +const queryClient = new QueryClient() +queryClient.clear() +``` + +*** + +### defaultMutationOptions() + +```ts +defaultMutationOptions(options?): T; +``` + +Defined in: [packages/query-core/src/queryClient.ts:1057](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L1057) + +The mutation counterpart of [QueryClient#defaultQueryOptions](#defaultqueryoptions). Called by framework +adapters (e.g. inside `useMutation`) to merge `queryClient.setMutationDefaults` for the +given `mutationKey`, then the client's `defaultOptions.mutations`, then the caller's options +on top. A no-op if the options are already defaulted (`_defaulted: true`). + +#### Type Parameters + +##### T + +`T` *extends* [`MutationOptions`](../interfaces/MutationOptions.md)\<`any`, `any`, `any`, `any`\> + +#### Parameters + +##### options? + +`T` + +#### Returns + +`T` + +*** + +### defaultQueryOptions() + +```ts +defaultQueryOptions(options): DefaultedQueryObserverOptions; +``` + +Defined in: [packages/query-core/src/queryClient.ts:970](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L970) + +Called by framework adapters (e.g. inside `useQuery`) to resolve the options passed by the +caller into their final, defaulted form: merging `queryClient.setQueryDefaults` for the +given `queryKey`, then the client's own `defaultOptions.queries`, then the caller's options +on top. A no-op if the options are already defaulted (`_defaulted: true`). + +#### Type Parameters + +##### TQueryFnData + +`TQueryFnData` = `unknown` + +##### TError + +`TError` = `Error` + +##### TData + +`TData` = `TQueryFnData` + +##### TQueryData + +`TQueryData` = `TQueryFnData` + +##### TQueryKey + +`TQueryKey` *extends* readonly `unknown`[] = readonly `unknown`[] + +##### TPageParam + +`TPageParam` = `never` + +#### Parameters + +##### options + +[`QueryObserverOptions`](../interfaces/QueryObserverOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryData`, `TQueryKey`, `TPageParam`\> | [`DefaultedQueryObserverOptions`](../type-aliases/DefaultedQueryObserverOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryData`, `TQueryKey`\> + +#### Returns + +[`DefaultedQueryObserverOptions`](../type-aliases/DefaultedQueryObserverOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryData`, `TQueryKey`\> + +*** + +### ~~ensureInfiniteQueryData()~~ + +```ts +ensureInfiniteQueryData(options): Promise>; +``` + +Defined in: [packages/query-core/src/queryClient.ts:735](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L735) + +#### Type Parameters + +##### TQueryFnData + +`TQueryFnData` + +##### TError + +`TError` = `Error` + +##### TData + +`TData` = `TQueryFnData` + +##### TQueryKey + +`TQueryKey` *extends* readonly `unknown`[] = readonly `unknown`[] + +##### TPageParam + +`TPageParam` = `unknown` + +#### Parameters + +##### options + +[`EnsureInfiniteQueryDataOptions`](../type-aliases/EnsureInfiniteQueryDataOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`, `TPageParam`\> + +#### Returns + +`Promise`\<[`InfiniteData`](../interfaces/InfiniteData.md)\<`TData`, `TPageParam`\>\> + +#### Deprecated + +Use queryClient.infiniteQuery({ ...options, staleTime: 'static' }) instead. This method will be removed in the next major version. + +*** + +### ~~ensureQueryData()~~ + +```ts +ensureQueryData(options): Promise; +``` + +Defined in: [packages/query-core/src/queryClient.ts:197](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L197) + +#### Type Parameters + +##### TQueryFnData + +`TQueryFnData` + +##### TError + +`TError` = `Error` + +##### TData + +`TData` = `TQueryFnData` + +##### TQueryKey + +`TQueryKey` *extends* readonly `unknown`[] = readonly `unknown`[] + +#### Parameters + +##### options + +[`EnsureQueryDataOptions`](../interfaces/EnsureQueryDataOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`\> + +#### Returns + +`Promise`\<`TData`\> + +#### Deprecated + +Use queryClient.query({ ...options, staleTime: 'static' }) instead. This method will be removed in the next major version. + +*** + +### ~~fetchInfiniteQuery()~~ + +```ts +fetchInfiniteQuery(options): Promise>; +``` + +Defined in: [packages/query-core/src/queryClient.ts:692](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L692) + +#### Type Parameters + +##### TQueryFnData + +`TQueryFnData` + +##### TError + +`TError` = `Error` + +##### TData + +`TData` = `TQueryFnData` + +##### TQueryKey + +`TQueryKey` *extends* readonly `unknown`[] = readonly `unknown`[] + +##### TPageParam + +`TPageParam` = `unknown` + +#### Parameters + +##### options + +[`FetchInfiniteQueryOptions`](../type-aliases/FetchInfiniteQueryOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`, `TPageParam`\> + +#### Returns + +`Promise`\<[`InfiniteData`](../interfaces/InfiniteData.md)\<`TData`, `TPageParam`\>\> + +#### Deprecated + +Use queryClient.infiniteQuery(options) instead. This method will be removed in the next major version. + +*** + +### ~~fetchQuery()~~ + +```ts +fetchQuery(options): Promise; +``` + +Defined in: [packages/query-core/src/queryClient.ts:600](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L600) + +#### Type Parameters + +##### TQueryFnData + +`TQueryFnData` + +##### TError + +`TError` = `Error` + +##### TData + +`TData` = `TQueryFnData` + +##### TQueryKey + +`TQueryKey` *extends* readonly `unknown`[] = readonly `unknown`[] + +##### TPageParam + +`TPageParam` = `never` + +#### Parameters + +##### options + +[`FetchQueryOptions`](../interfaces/FetchQueryOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`, `TPageParam`\> + +#### Returns + +`Promise`\<`TData`\> + +#### Deprecated + +Use queryClient.query(options) instead. This method will be removed in the next major version. + +*** + +### getDefaultOptions() + +```ts +getDefaultOptions(): DefaultOptions; +``` + +Defined in: [packages/query-core/src/queryClient.ts:818](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L818) + +Returns the default options that were set when creating the client, or via +[QueryClient#setDefaultOptions](#setdefaultoptions). + +#### Returns + +[`DefaultOptions`](../interfaces/DefaultOptions.md) + +#### Example + +```ts +import { QueryClient } from '@tanstack/query-core' + +const queryClient = new QueryClient() +const defaultOptions = queryClient.getDefaultOptions() +``` + +*** + +### getMutationCache() + +```ts +getMutationCache(): MutationCache; +``` + +Defined in: [packages/query-core/src/queryClient.ts:802](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L802) + +Returns the mutation cache this client is connected to. + +#### Returns + +[`MutationCache`](MutationCache.md) + +#### Example + +```ts +import { QueryClient } from '@tanstack/query-core' + +const queryClient = new QueryClient() +const mutationCache = queryClient.getMutationCache() +const mutations = mutationCache.findAll({ status: 'pending' }) +``` + +*** + +### getMutationDefaults() + +```ts +getMutationDefaults(mutationKey): OmitKeyof, "mutationKey">; +``` + +Defined in: [packages/query-core/src/queryClient.ts:945](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L945) + +Returns the default options registered for mutations whose mutation key partially matches +the given `mutationKey`, via [QueryClient#setMutationDefaults](#setmutationdefaults). If multiple registered +defaults match, they are merged together in registration order. + +#### Parameters + +##### mutationKey + +readonly `unknown`[] + +#### Returns + +[`OmitKeyof`](../type-aliases/OmitKeyof.md)\<[`MutationObserverOptions`](../interfaces/MutationObserverOptions.md)\<`any`, `any`, `any`, `any`\>, `"mutationKey"`\> + +#### Example + +```ts +const defaultOptions = queryClient.getMutationDefaults(['addPost']) +``` + +*** + +### getQueriesData() + +```ts +getQueriesData(filters): [readonly unknown[], TQueryFnData | undefined][]; +``` + +Defined in: [packages/query-core/src/queryClient.ts:240](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L240) + +Imperative (non-reactive) way to retrieve the cached data of multiple queries at once. +Only queries matching the given filters are returned; if none match, an empty array is +returned. + +Because the matched queries can hold data of different shapes (e.g. a broad filter can match +queries with unrelated data types), the `TQueryFnData` generic defaults to `unknown` rather +than being inferred. Passing a more specific type is a convenience for call sites that know +every matched query holds the same shape — it is not checked against the actual cache +contents. + +#### Type Parameters + +##### TQueryFnData + +`TQueryFnData` = `unknown` + +##### TQueryFilters + +`TQueryFilters` *extends* [`QueryFilters`](../interfaces/QueryFilters.md)\<`any`\> = [`QueryFilters`](../interfaces/QueryFilters.md)\ + +#### Parameters + +##### filters + +`TQueryFilters` + +#### Returns + +\[readonly `unknown`[], `TQueryFnData` \| `undefined`\][] + +#### See + +[QueryClient#getQueryData](#getquerydata) + +#### Example + +```ts +const data = queryClient.getQueriesData({ queryKey: ['posts'] }) +``` + +*** + +### getQueryCache() + +```ts +getQueryCache(): QueryCache; +``` + +Defined in: [packages/query-core/src/queryClient.ts:786](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L786) + +Returns the query cache this client is connected to. + +#### Returns + +[`QueryCache`](QueryCache.md) + +#### Example + +```ts +import { QueryClient } from '@tanstack/query-core' + +const queryClient = new QueryClient() +const queryCache = queryClient.getQueryCache() +const queries = queryCache.findAll({ queryKey: ['posts'] }) +``` + +*** + +### getQueryData() + +```ts +getQueryData(queryKey): TInferredQueryFnData | undefined; +``` + +Defined in: [packages/query-core/src/queryClient.ts:183](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L183) + +Imperative (non-reactive) way to retrieve data for a QueryKey. +Should only be used in callbacks or functions where reading the latest data is necessary, e.g. for optimistic updates. + +Hint: Do not use this function inside a component, because it won't receive updates. +Use `useQuery` to create a `QueryObserver` that subscribes to changes. + +#### Type Parameters + +##### TQueryFnData + +`TQueryFnData` = `unknown` + +##### TTaggedQueryKey + +`TTaggedQueryKey` *extends* readonly `unknown`[] = readonly `unknown`[] + +##### TInferredQueryFnData + +`TInferredQueryFnData` = [`InferDataFromTag`](../type-aliases/InferDataFromTag.md)\<`TQueryFnData`, `TTaggedQueryKey`\> + +#### Parameters + +##### queryKey + +`TTaggedQueryKey` + +#### Returns + +`TInferredQueryFnData` \| `undefined` + +#### See + +[QueryClient#getQueriesData](#getqueriesdata) + +*** + +### getQueryDefaults() + +```ts +getQueryDefaults(queryKey): OmitKeyof, "queryKey">; +``` + +Defined in: [packages/query-core/src/queryClient.ts:888](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L888) + +Returns the default options registered for queries whose query key partially matches the +given `queryKey`, via [QueryClient#setQueryDefaults](#setquerydefaults). If multiple registered defaults +match, they are merged together in registration order. + +#### Parameters + +##### queryKey + +readonly `unknown`[] + +#### Returns + +[`OmitKeyof`](../type-aliases/OmitKeyof.md)\<[`QueryObserverOptions`](../interfaces/QueryObserverOptions.md)\<`any`, `any`, `any`, `any`, `any`\>, `"queryKey"`\> + +#### Example + +```ts +const defaultOptions = queryClient.getQueryDefaults(['posts']) +``` + +*** + +### getQueryState() + +```ts +getQueryState(queryKey): + | QueryState + | undefined; +``` + +Defined in: [packages/query-core/src/queryClient.ts:350](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L350) + +Imperative (non-reactive) way to retrieve an existing query's state. If the query does not +exist, `undefined` is returned. + +#### Type Parameters + +##### TQueryFnData + +`TQueryFnData` = `unknown` + +##### TError + +`TError` = `Error` + +##### TTaggedQueryKey + +`TTaggedQueryKey` *extends* readonly `unknown`[] = readonly `unknown`[] + +##### TInferredQueryFnData + +`TInferredQueryFnData` = [`InferDataFromTag`](../type-aliases/InferDataFromTag.md)\<`TQueryFnData`, `TTaggedQueryKey`\> + +##### TInferredError + +`TInferredError` = [`InferErrorFromTag`](../type-aliases/InferErrorFromTag.md)\<`TError`, `TTaggedQueryKey`\> + +#### Parameters + +##### queryKey + +`TTaggedQueryKey` + +#### Returns + + \| [`QueryState`](../interfaces/QueryState.md)\<`TInferredQueryFnData`, `TInferredError`\> + \| `undefined` + +#### Example + +```ts +const state = queryClient.getQueryState(['posts']) +console.log(state?.dataUpdatedAt) +``` + +*** + +### infiniteQuery() + +```ts +infiniteQuery(options): Promise[] ? InfiniteData : TData>; +``` + +Defined in: [packages/query-core/src/queryClient.ts:666](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L666) + +Asynchronous method to fetch and cache an infinite query, resolving with an +[InfiniteData](../interfaces/InfiniteData.md) object or throwing with the error. + +Behaves like [QueryClient#query](#query), accepting the same options (minus +`initialPageParam`), plus the required `initialPageParam`, and an optional `pages` / +`getNextPageParam` pair used to refetch a fixed number of pages from the start. + +This method replaces the deprecated `fetchInfiniteQuery`, and — combined with +`{ staleTime: 'static' }` — the deprecated `ensureInfiniteQueryData`. + +#### Type Parameters + +##### TQueryFnData + +`TQueryFnData` + +##### TError + +`TError` = `Error` + +##### TData + +`TData` = [`InfiniteData`](../interfaces/InfiniteData.md)\<`TQueryFnData`, `unknown`\> + +##### TQueryKey + +`TQueryKey` *extends* readonly `unknown`[] = readonly `unknown`[] + +##### TPageParam + +`TPageParam` = `unknown` + +#### Parameters + +##### options + +[`InfiniteQueryExecuteOptions`](../type-aliases/InfiniteQueryExecuteOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`, `TPageParam`\> + +#### Returns + +`Promise`\<`TData`[] *extends* [`InfiniteData`](../interfaces/InfiniteData.md)\<`TQueryFnData`, `unknown`\>[] ? [`InfiniteData`](../interfaces/InfiniteData.md)\<`TQueryFnData`, `TPageParam`\> : `TData`\> + +#### Example + +```ts +try { + const data = await queryClient.infiniteQuery({ queryKey, queryFn, initialPageParam: 0 }) + console.log(data.pages) +} catch (error) { + console.log(error) +} +``` + +*** + +### invalidateQueries() + +```ts +invalidateQueries(filters?, options?): Promise; +``` + +Defined in: [packages/query-core/src/queryClient.ts:460](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L460) + +Marks queries matching the given filters as invalidated. Unlike +[QueryClient#removeQueries](#removequeries), invalidated queries stay in the cache. + +Unless `filters.refetchType` is `'none'`, matching queries are then refetched via +[QueryClient#refetchQueries](#refetchqueries), using `filters.refetchType` if set, otherwise +`filters.type`, otherwise `'active'`. + +#### Type Parameters + +##### TTaggedQueryKey + +`TTaggedQueryKey` *extends* readonly `unknown`[] = readonly `unknown`[] + +#### Parameters + +##### filters? + +[`InvalidateQueryFilters`](../interfaces/InvalidateQueryFilters.md)\<`TTaggedQueryKey`\> + +##### options? + +[`InvalidateOptions`](../interfaces/InvalidateOptions.md) = `{}` + +#### Returns + +`Promise`\<`void`\> + +#### Example + +```ts +await queryClient.invalidateQueries({ queryKey: ['posts'], refetchType: 'active' }) +``` + +*** + +### isFetching() + +```ts +isFetching(filters?): number; +``` + +Defined in: [packages/query-core/src/queryClient.ts:150](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L150) + +Returns the number of queries in the cache that are currently fetching, optionally +matching a set of filters. This includes background-fetching, loading new pages, and +loading more infinite query results. + +#### Type Parameters + +##### TQueryFilters + +`TQueryFilters` *extends* [`QueryFilters`](../interfaces/QueryFilters.md)\<`any`\> = [`QueryFilters`](../interfaces/QueryFilters.md)\ + +#### Parameters + +##### filters? + +`TQueryFilters` + +#### Returns + +`number` + +#### Example + +```ts +if (queryClient.isFetching()) { + console.log('At least one query is fetching!') +} +``` + +*** + +### isMutating() + +```ts +isMutating(filters?): number; +``` + +Defined in: [packages/query-core/src/queryClient.ts:168](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L168) + +Returns the number of mutations in the cache that are currently pending, optionally +matching a set of filters. + +#### Type Parameters + +##### TMutationFilters + +`TMutationFilters` *extends* [`MutationFilters`](../interfaces/MutationFilters.md)\<`any`, `any`, `unknown`, `unknown`\> = [`MutationFilters`](../interfaces/MutationFilters.md)\<`unknown`, `Error`, `unknown`, `unknown`\> + +#### Parameters + +##### filters? + +`TMutationFilters` + +#### Returns + +`number` + +#### Example + +```ts +if (queryClient.isMutating()) { + console.log('At least one mutation is pending!') +} +``` + +*** + +### mount() + +```ts +mount(): void; +``` + +Defined in: [packages/query-core/src/queryClient.ts:104](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L104) + +Called by a framework adapter's `QueryClientProvider`-equivalent when it mounts, to start +listening for focus/online events and resume paused mutations. Ref-counted via an internal +mount count, so nested or multiple providers sharing the same `QueryClient` don't tear down +the shared listeners until the last one unmounts. + +#### Returns + +`void` + +*** + +### ~~prefetchInfiniteQuery()~~ + +```ts +prefetchInfiniteQuery(options): Promise; +``` + +Defined in: [packages/query-core/src/queryClient.ts:714](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L714) + +#### Type Parameters + +##### TQueryFnData + +`TQueryFnData` + +##### TError + +`TError` = `Error` + +##### TData + +`TData` = `TQueryFnData` + +##### TQueryKey + +`TQueryKey` *extends* readonly `unknown`[] = readonly `unknown`[] + +##### TPageParam + +`TPageParam` = `unknown` + +#### Parameters + +##### options + +[`FetchInfiniteQueryOptions`](../type-aliases/FetchInfiniteQueryOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`, `TPageParam`\> + +#### Returns + +`Promise`\<`void`\> + +#### Deprecated + +Use queryClient.infiniteQuery(options) instead. You can swallow errors with `.catch(noop)`. This method will be removed in the next major version. + +*** + +### ~~prefetchQuery()~~ + +```ts +prefetchQuery(options): Promise; +``` + +Defined in: [packages/query-core/src/queryClient.ts:634](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L634) + +#### Type Parameters + +##### TQueryFnData + +`TQueryFnData` = `unknown` + +##### TError + +`TError` = `Error` + +##### TData + +`TData` = `TQueryFnData` + +##### TQueryKey + +`TQueryKey` *extends* readonly `unknown`[] = readonly `unknown`[] + +#### Parameters + +##### options + +[`FetchQueryOptions`](../interfaces/FetchQueryOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`\> + +#### Returns + +`Promise`\<`void`\> + +#### Deprecated + +Use queryClient.query(options) instead. You can swallow errors with `.catch(noop)`. This method will be removed in the next major version. + +*** + +### query() + +```ts +query(options): Promise; +``` + +Defined in: [packages/query-core/src/queryClient.ts:554](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L554) + +Asynchronous method to fetch and cache a query, resolving with the data or throwing with +the error. + +If the query already exists in the cache and its data is not stale (per the given +`staleTime`), the cached data is returned without fetching. Otherwise, the query is fetched +and the promise resolves once the fetch settles. If a `select` function is provided, it is +applied to the data in both cases (cached or freshly fetched) before it is returned. + +Unlike a reactive observer, retries are disabled by default here (`retry: false`) unless +explicitly configured, since there is no component to catch a thrown error and retry through +re-render. + +The accepted options are `QueryObserverOptions` minus the fields that only make sense for a +reactive observer — `enabled`, `refetchInterval`, `refetchIntervalInBackground`, +`refetchOnWindowFocus`, `refetchOnReconnect`, `refetchOnMount`, `retryOnMount`, +`notifyOnChangeProps`, `throwOnError`, `suspense`, and `placeholderData` are not part of this +method's options. + +This method replaces the deprecated `fetchQuery`, and — combined with +`{ staleTime: 'static' }` — the deprecated `ensureQueryData`. + +#### Type Parameters + +##### TQueryFnData + +`TQueryFnData` + +##### TError + +`TError` = `Error` + +##### TData + +`TData` = `TQueryFnData` + +##### TQueryData + +`TQueryData` = `TQueryFnData` + +##### TQueryKey + +`TQueryKey` *extends* readonly `unknown`[] = readonly `unknown`[] + +##### TPageParam + +`TPageParam` = `never` + +#### Parameters + +##### options + +[`QueryExecuteOptions`](../interfaces/QueryExecuteOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryData`, `TQueryKey`, `TPageParam`\> + +#### Returns + +`Promise`\<`TData`\> + +#### Example + +```ts +try { + const data = await queryClient.query({ queryKey, queryFn, staleTime: 10000 }) +} catch (error) { + console.log(error) +} +``` + +*** + +### refetchQueries() + +```ts +refetchQueries(filters?, options?): Promise; +``` + +Defined in: [packages/query-core/src/queryClient.ts:497](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L497) + +Refetches queries matching the given filters, regardless of whether they are stale. Without +filters, every query in the cache is refetched. Queries that are disabled, or static (only +have observers with a static `staleTime`), are never refetched. + +By default (`cancelRefetch: true`), a currently running fetch is cancelled before the new +one starts. The returned promise resolves once all matching queries have settled; it does +not reject on individual query failures unless `throwOnError` is set. + +#### Type Parameters + +##### TTaggedQueryKey + +`TTaggedQueryKey` *extends* readonly `unknown`[] = readonly `unknown`[] + +#### Parameters + +##### filters? + +[`RefetchQueryFilters`](../interfaces/RefetchQueryFilters.md)\<`TTaggedQueryKey`\> + +##### options? + +[`RefetchOptions`](../interfaces/RefetchOptions.md) = `{}` + +#### Returns + +`Promise`\<`void`\> + +#### Example + +```ts +// refetch all active queries partially matching a query key: +await queryClient.refetchQueries({ queryKey: ['posts'], type: 'active' }) +``` + +*** + +### removeQueries() + +```ts +removeQueries(filters?): void; +``` + +Defined in: [packages/query-core/src/queryClient.ts:376](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L376) + +Removes queries from the cache that match the given filters. Unlike +[QueryClient#invalidateQueries](#invalidatequeries) or [QueryClient#refetchQueries](#refetchqueries), this removes +matching queries from the cache instead of refetching them. Without filters, every query in +the cache is removed. + +#### Type Parameters + +##### TTaggedQueryKey + +`TTaggedQueryKey` *extends* readonly `unknown`[] = readonly `unknown`[] + +#### Parameters + +##### filters? + +[`QueryFilters`](../interfaces/QueryFilters.md)\<`TTaggedQueryKey`\> + +#### Returns + +`void` + +#### Example + +```ts +queryClient.removeQueries({ queryKey: ['posts'], exact: true }) +``` + +*** + +### resetQueries() + +```ts +resetQueries(filters?, options?): Promise; +``` + +Defined in: [packages/query-core/src/queryClient.ts:397](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L397) + +Resets queries matching the given filters back to their initial state (e.g. any +`initialData`), notifying subscribers rather than removing them. Active queries among the +matched set are then refetched, and the returned promise resolves once that refetch settles. + +#### Type Parameters + +##### TTaggedQueryKey + +`TTaggedQueryKey` *extends* readonly `unknown`[] = readonly `unknown`[] + +#### Parameters + +##### filters? + +[`QueryFilters`](../interfaces/QueryFilters.md)\<`TTaggedQueryKey`\> + +##### options? + +[`ResetOptions`](../interfaces/ResetOptions.md) + +#### Returns + +`Promise`\<`void`\> + +#### Example + +```ts +await queryClient.resetQueries({ queryKey: ['posts'], exact: true }) +``` + +*** + +### resumePausedMutations() + +```ts +resumePausedMutations(): Promise; +``` + +Defined in: [packages/query-core/src/queryClient.ts:767](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L767) + +Resumes mutations that were paused because there was no network connection. Does nothing +(resolving immediately) if the client is currently offline. + +#### Returns + +`Promise`\<`unknown`\> + +#### Example + +```ts +import { QueryClient } from '@tanstack/query-core' + +const queryClient = new QueryClient() +await queryClient.resumePausedMutations() +``` + +*** + +### setDefaultOptions() + +```ts +setDefaultOptions(options): void; +``` + +Defined in: [packages/query-core/src/queryClient.ts:839](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L839) + +Dynamically sets the default options for this client, overwriting any previously defined +default options. + +#### Parameters + +##### options + +[`DefaultOptions`](../interfaces/DefaultOptions.md) + +#### Returns + +`void` + +#### See + +[QueryClient#getDefaultOptions](#getdefaultoptions) + +#### Example + +```ts +import { QueryClient } from '@tanstack/query-core' + +const queryClient = new QueryClient() +queryClient.setDefaultOptions({ + queries: { + staleTime: Infinity, + }, +}) +``` + +*** + +### setMutationDefaults() + +```ts +setMutationDefaults(mutationKey, options): void; +``` + +Defined in: [packages/query-core/src/queryClient.ts:917](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L917) + +Sets default options for mutations whose mutation key partially matches the given +`mutationKey`. As with [QueryClient#setQueryDefaults](#setquerydefaults), the order of registration +matters when several registered defaults match the same mutation key. + +#### Type Parameters + +##### TData + +`TData` = `unknown` + +##### TError + +`TError` = `Error` + +##### TVariables + +`TVariables` = `void` + +##### TOnMutateResult + +`TOnMutateResult` = `unknown` + +#### Parameters + +##### mutationKey + +readonly `unknown`[] + +##### options + +[`OmitKeyof`](../type-aliases/OmitKeyof.md)\<[`MutationObserverOptions`](../interfaces/MutationObserverOptions.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\>, `"mutationKey"`\> + +#### Returns + +`void` + +#### See + +[QueryClient#getMutationDefaults](#getmutationdefaults) + +#### Example + +```ts +queryClient.setMutationDefaults(['addPost'], { mutationFn: addPost }) +``` + +*** + +### setQueriesData() + +```ts +setQueriesData( + filters, + updater, + options?): [readonly unknown[], TQueryFnData | undefined][]; +``` + +Defined in: [packages/query-core/src/queryClient.ts:319](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L319) + +Synchronous way to immediately update the cached data of multiple queries at once, using +filters or partial query key matching. Only queries that already exist and match the given +filters are updated; no new cache entries are created. Internally this calls +[QueryClient#setQueryData](#setquerydata) for each matching query. + +#### Type Parameters + +##### TQueryFnData + +`TQueryFnData` + +##### TQueryFilters + +`TQueryFilters` *extends* [`QueryFilters`](../interfaces/QueryFilters.md)\<`any`\> = [`QueryFilters`](../interfaces/QueryFilters.md)\ + +#### Parameters + +##### filters + +`TQueryFilters` + +##### updater + +[`Updater`](../type-aliases/Updater.md)\<`NoInfer`\<`TQueryFnData`\> \| `undefined`, `NoInfer`\<`TQueryFnData`\> \| `undefined`\> + +##### options? + +[`SetDataOptions`](../interfaces/SetDataOptions.md) + +#### Returns + +\[readonly `unknown`[], `TQueryFnData` \| `undefined`\][] + +#### Example + +```ts +queryClient.setQueriesData({ queryKey: ['posts'] }, (oldPosts) => + oldPosts ? oldPosts.filter((post) => post.id !== deletedId) : oldPosts, +) +``` + +*** + +### setQueryData() + +```ts +setQueryData( + queryKey, + updater, + options?): NoInfer | undefined; +``` + +Defined in: [packages/query-core/src/queryClient.ts:271](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L271) + +Synchronous way to immediately update a query's cached data. If the updater (or the value +passed) resolves to `undefined`, the cache is left untouched and no query is created; +otherwise, if the query does not exist yet, it will be created. To update multiple queries +at once by partially matching query keys, use [QueryClient#setQueriesData](#setqueriesdata) instead. + +Updates must be performed immutably: do not mutate `oldData`, or data previously retrieved +via [QueryClient#getQueryData](#getquerydata), in place. + +#### Type Parameters + +##### TQueryFnData + +`TQueryFnData` = `unknown` + +##### TTaggedQueryKey + +`TTaggedQueryKey` *extends* readonly `unknown`[] = readonly `unknown`[] + +##### TInferredQueryFnData + +`TInferredQueryFnData` = [`InferDataFromTag`](../type-aliases/InferDataFromTag.md)\<`TQueryFnData`, `TTaggedQueryKey`\> + +#### Parameters + +##### queryKey + +`TTaggedQueryKey` + +The query key to set data for. + +##### updater + +[`Updater`](../type-aliases/Updater.md)\<`NoInfer`\<`TInferredQueryFnData`\> \| `undefined`, `NoInfer`\<`TInferredQueryFnData`\> \| `undefined`\> + +Either the new data, or a function that receives the current data (which +may be `undefined`) and returns the new data. + +##### options? + +[`SetDataOptions`](../interfaces/SetDataOptions.md) + +#### Returns + +`NoInfer`\<`TInferredQueryFnData`\> \| `undefined` + +#### Example + +```ts +queryClient.setQueryData(['posts'], newPosts) + +// Or, using an updater function that receives the current data: +queryClient.setQueryData(['posts'], (oldPosts) => [...oldPosts, newPost]) +``` + +*** + +### setQueryDefaults() + +```ts +setQueryDefaults(queryKey, options): void; +``` + +Defined in: [packages/query-core/src/queryClient.ts:858](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L858) + +Sets default options for queries whose query key partially matches the given `queryKey`. + +If several registered query defaults match a given query key, they are merged together in +registration order by [QueryClient#getQueryDefaults](#getquerydefaults), so register defaults from the +most generic key to the least generic one — more specific defaults should be registered +after more generic ones so they take precedence. + +#### Type Parameters + +##### TQueryFnData + +`TQueryFnData` = `unknown` + +##### TError + +`TError` = `Error` + +##### TData + +`TData` = `TQueryFnData` + +##### TQueryData + +`TQueryData` = `TQueryFnData` + +#### Parameters + +##### queryKey + +readonly `unknown`[] + +##### options + +`Partial`\<[`OmitKeyof`](../type-aliases/OmitKeyof.md)\<[`QueryObserverOptions`](../interfaces/QueryObserverOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryData`\>, `"queryKey"`\>\> + +#### Returns + +`void` + +#### Example + +```ts +queryClient.setQueryDefaults(['posts'], { queryFn: fetchPosts }) + +await queryClient.query({ queryKey: ['posts'] }) +``` + +*** + +### unmount() + +```ts +unmount(): void; +``` + +Defined in: [packages/query-core/src/queryClient.ts:127](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L127) + +The inverse of [QueryClient#mount](#mount) — called by a framework adapter's +`QueryClientProvider`-equivalent when it unmounts. Only tears down the focus/online +listeners once the mount count returns to `0`. + +#### Returns + +`void` diff --git a/docs/framework/svelte/reference/classes/QueryObserver.md b/docs/framework/svelte/reference/classes/QueryObserver.md new file mode 100644 index 00000000000..51ff16910df --- /dev/null +++ b/docs/framework/svelte/reference/classes/QueryObserver.md @@ -0,0 +1,555 @@ +--- +id: QueryObserver +title: QueryObserver +--- + +Defined in: [packages/query-core/src/queryObserver.ts:57](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L57) + +A `QueryObserver` watches a single query in the `QueryCache` and computes a +`QueryObserverResult` from its state, recomputing and notifying subscribers +whenever the underlying query (or the observer's options) changes. It is +the primitive that framework adapters (e.g. `useQuery`) build their hooks +on top of, but it can also be used directly to observe and switch between +queries outside of any framework. + +## Example + +```ts +const observer = new QueryObserver(queryClient, { + queryKey: ['posts'], + queryFn: fetchPosts, +}) + +const unsubscribe = observer.subscribe((result) => { + console.log(result.data) +}) +``` + +## Extends + +- `Subscribable`\<`QueryObserverListener`\<`TData`, `TError`\>\> + +## Extended by + +- [`InfiniteQueryObserver`](InfiniteQueryObserver.md) + +## Type Parameters + +### TQueryFnData + +`TQueryFnData` = `unknown` + +### TError + +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) + +### TData + +`TData` = `TQueryFnData` + +### TQueryData + +`TQueryData` = `TQueryFnData` + +### TQueryKey + +`TQueryKey` *extends* [`QueryKey`](../type-aliases/QueryKey.md) = [`QueryKey`](../type-aliases/QueryKey.md) + +## Constructors + +### Constructor + +```ts +new QueryObserver(client, options): QueryObserver; +``` + +Defined in: [packages/query-core/src/queryObserver.ts:87](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L87) + +#### Parameters + +##### client + +[`QueryClient`](QueryClient.md) + +##### options + +[`QueryObserverOptions`](../interfaces/QueryObserverOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryData`, `TQueryKey`\> + +#### Returns + +`QueryObserver`\<`TQueryFnData`, `TError`, `TData`, `TQueryData`, `TQueryKey`\> + +#### Overrides + +```ts +Subscribable>.constructor +``` + +## Properties + +### listeners + +```ts +protected listeners: Set>; +``` + +Defined in: [packages/query-core/src/subscribable.ts:2](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L2) + +#### Inherited from + +```ts +Subscribable.listeners +``` + +*** + +### options + +```ts +options: QueryObserverOptions; +``` + +Defined in: [packages/query-core/src/queryObserver.ts:89](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L89) + +## Methods + +### bindMethods() + +```ts +protected bindMethods(): void; +``` + +Defined in: [packages/query-core/src/queryObserver.ts:106](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L106) + +#### Returns + +`void` + +*** + +### createResult() + +```ts +protected createResult(query, options): QueryObserverResult; +``` + +Defined in: [packages/query-core/src/queryObserver.ts:559](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L559) + +#### Parameters + +##### query + +[`Query`](Query.md)\<`TQueryFnData`, `TError`, `TQueryData`, `TQueryKey`\> + +##### options + +[`QueryObserverOptions`](../interfaces/QueryObserverOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryData`, `TQueryKey`\> + +#### Returns + +[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\> + +*** + +### destroy() + +```ts +destroy(): void; +``` + +Defined in: [packages/query-core/src/queryObserver.ts:161](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L161) + +Stops observing the current query: clears all listeners, cancels the +stale and refetch-interval timers, and removes this observer from the +query it was observing. + +#### Returns + +`void` + +*** + +### fetch() + +```ts +protected fetch(fetchOptions): Promise>; +``` + +Defined in: [packages/query-core/src/queryObserver.ts:448](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L448) + +#### Parameters + +##### fetchOptions + +`ObserverFetchOptions` + +#### Returns + +`Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> + +*** + +### fetchOptimistic() + +```ts +fetchOptimistic(options): Promise>; +``` + +Defined in: [packages/query-core/src/queryObserver.ts:395](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L395) + +Fetches a query defined by the given options without affecting this +observer's own tracked query or result, and returns a promise that +resolves with the `QueryObserverResult` for that fetch. This is useful +for prefetching data that another observer (e.g. a query about to be +navigated to) will need, ahead of time. + +#### Parameters + +##### options + +[`QueryObserverOptions`](../interfaces/QueryObserverOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryData`, `TQueryKey`\> + +#### Returns + +`Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> + +#### Example + +```ts +const result = await observer.fetchOptimistic({ + queryKey: ['posts', 2], + queryFn: () => fetchPost(2), +}) +console.log(result.data) +``` + +*** + +### getCurrentQuery() + +```ts +getCurrentQuery(): Query; +``` + +Defined in: [packages/query-core/src/queryObserver.ts:357](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L357) + +Returns the `Query` instance this observer is currently observing. + +#### Returns + +[`Query`](Query.md)\<`TQueryFnData`, `TError`, `TQueryData`, `TQueryKey`\> + +*** + +### getCurrentResult() + +```ts +getCurrentResult(): QueryObserverResult; +``` + +Defined in: [packages/query-core/src/queryObserver.ts:321](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L321) + +Returns the most recently computed `QueryObserverResult` for the +observed query. This is a point-in-time read; to be notified of updates +as they happen, subscribe to the observer instead (its inherited +`subscribe` method). + +#### Returns + +[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\> + +#### Example + +```ts +const result = observer.getCurrentResult() +console.log(result.status, result.data) +``` + +*** + +### getOptimisticResult() + +```ts +getOptimisticResult(options): QueryObserverResult; +``` + +Defined in: [packages/query-core/src/queryObserver.ts:272](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L272) + +Computes the result the observer would produce for the given (already-defaulted) options +right now, building the underlying `Query` if it doesn't exist yet, without waiting for a +subscription callback. Called by framework adapters on every render (e.g. `useQuery`) so the +returned value is available synchronously, ahead of `setOptions` triggering an actual fetch. + +#### Parameters + +##### options + +[`DefaultedQueryObserverOptions`](../type-aliases/DefaultedQueryObserverOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryData`, `TQueryKey`\> + +#### Returns + +[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\> + +*** + +### hasListeners() + +```ts +hasListeners(): boolean; +``` + +Defined in: [packages/query-core/src/subscribable.ts:19](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L19) + +#### Returns + +`boolean` + +#### Inherited from + +```ts +Subscribable.hasListeners +``` + +*** + +### onSubscribe() + +```ts +protected onSubscribe(): void; +``` + +Defined in: [packages/query-core/src/queryObserver.ts:110](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L110) + +#### Returns + +`void` + +#### Overrides + +```ts +Subscribable.onSubscribe +``` + +*** + +### onUnsubscribe() + +```ts +protected onUnsubscribe(): void; +``` + +Defined in: [packages/query-core/src/queryObserver.ts:124](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L124) + +#### Returns + +`void` + +#### Overrides + +```ts +Subscribable.onUnsubscribe +``` + +*** + +### refetch() + +```ts +refetch(__namedParameters): Promise>; +``` + +Defined in: [packages/query-core/src/queryObserver.ts:371](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L371) + +Refetches the observed query and returns a promise that resolves with +the resulting `QueryObserverResult`. + +#### Parameters + +##### \_\_namedParameters + +[`RefetchOptions`](../interfaces/RefetchOptions.md) = `{}` + +#### Returns + +`Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> + +#### Example + +```ts +const result = await observer.refetch({ cancelRefetch: false }) +console.log(result.data) +``` + +*** + +### setOptions() + +```ts +setOptions(options): void; +``` + +Defined in: [packages/query-core/src/queryObserver.ts:182](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L182) + +Updates the observer's options. This will re-resolve the query being +observed (switching to a different query if the `queryKey` changed), +trigger a fetch if the new options require one and the observer has +subscribers, recompute the current result, and reschedule the stale and +refetch-interval timers as needed. + +#### Parameters + +##### options + +[`QueryObserverOptions`](../interfaces/QueryObserverOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryData`, `TQueryKey`\> + +#### Returns + +`void` + +#### Example + +```ts +observer.setOptions({ queryKey: ['posts', 1], queryFn: () => fetchPost(1) }) +// later: switch to a different query, reusing the same observer +observer.setOptions({ queryKey: ['posts', 2], queryFn: () => fetchPost(2) }) +``` + +*** + +### shouldFetchOnReconnect() + +```ts +shouldFetchOnReconnect(): boolean; +``` + +Defined in: [packages/query-core/src/queryObserver.ts:135](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L135) + +Returns whether the observed query is currently stale and configured +(via the `refetchOnReconnect` option) to refetch when the network +reconnects. + +#### Returns + +`boolean` + +*** + +### shouldFetchOnWindowFocus() + +```ts +shouldFetchOnWindowFocus(): boolean; +``` + +Defined in: [packages/query-core/src/queryObserver.ts:148](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L148) + +Returns whether the observed query is currently stale and configured +(via the `refetchOnWindowFocus` option) to refetch when the window +regains focus. + +#### Returns + +`boolean` + +*** + +### subscribe() + +```ts +subscribe(listener): () => void; +``` + +Defined in: [packages/query-core/src/subscribable.ts:8](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L8) + +#### Parameters + +##### listener + +`QueryObserverListener` + +#### Returns + +```ts +(): void; +``` + +##### Returns + +`void` + +#### Inherited from + +```ts +Subscribable.subscribe +``` + +*** + +### trackProp() + +```ts +trackProp(key): void; +``` + +Defined in: [packages/query-core/src/queryObserver.ts:350](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L350) + +Records that the given `QueryObserverResult` property was read, so a subsequent update only +notifies this observer if a tracked property actually changed. Normally called indirectly via +[QueryObserver#trackResult](#trackresult)'s proxy; exposed directly for adapters that track property +access themselves (e.g. through their own reactivity system) instead of via the proxy. + +#### Parameters + +##### key + +`"error"` | `"data"` | `"isError"` | `"isPending"` | `"isLoading"` | `"isLoadingError"` | `"isRefetchError"` | `"isSuccess"` | `"isPlaceholderData"` | `"status"` | `"dataUpdatedAt"` | `"errorUpdatedAt"` | `"failureCount"` | `"failureReason"` | `"errorUpdateCount"` | `"isFetched"` | `"isFetchedAfterMount"` | `"isFetching"` | `"isInitialLoading"` | `"isPaused"` | `"isRefetching"` | `"isStale"` | `"isEnabled"` | `"refetch"` | `"fetchStatus"` + +#### Returns + +`void` + +*** + +### trackResult() + +```ts +trackResult(result, onPropTracked?): QueryObserverResult; +``` + +Defined in: [packages/query-core/src/queryObserver.ts:331](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L331) + +Wraps a `QueryObserverResult` in a `Proxy` that records which properties are read, via +[QueryObserver#trackProp](#trackprop) (and an optional `onPropTracked` callback). Used by framework +adapters when `notifyOnChangeProps` is not set, to implement its default "only re-render on +properties you actually read" behavior. + +#### Parameters + +##### result + +[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\> + +##### onPropTracked? + +(`key`) => `void` + +#### Returns + +[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\> + +*** + +### updateResult() + +```ts +updateResult(): void; +``` + +Defined in: [packages/query-core/src/queryObserver.ts:735](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L735) + +Recomputes and stores the current result from the current query/options, notifying listeners +if it changed. Framework adapters call this right after subscribing to make sure no query +update was missed in the gap between creating the observer and subscribing to it. + +#### Returns + +`void` diff --git a/docs/framework/svelte/reference/functions/createInfiniteQuery.md b/docs/framework/svelte/reference/functions/createInfiniteQuery.md index a3d7e3ec5f4..dd7a56c4582 100644 --- a/docs/framework/svelte/reference/functions/createInfiniteQuery.md +++ b/docs/framework/svelte/reference/functions/createInfiniteQuery.md @@ -23,7 +23,7 @@ Defined in: [packages/svelte-query/src/createInfiniteQuery.ts:21](https://github #### TData -`TData` = `InfiniteData`\<`TQueryFnData`, `unknown`\> +`TData` = [`InfiniteData`](../interfaces/InfiniteData.md)\<`TQueryFnData`, `unknown`\> #### TQueryKey @@ -41,7 +41,7 @@ Defined in: [packages/svelte-query/src/createInfiniteQuery.ts:21](https://github #### queryClient? -[`Accessor`](../type-aliases/Accessor.md)\<`QueryClient`\> +[`Accessor`](../type-aliases/Accessor.md)\<[`QueryClient`](../classes/QueryClient.md)\> ### Returns @@ -67,7 +67,7 @@ Defined in: [packages/svelte-query/src/createInfiniteQuery.ts:40](https://github #### TData -`TData` = `InfiniteData`\<`TQueryFnData`, `unknown`\> +`TData` = [`InfiniteData`](../interfaces/InfiniteData.md)\<`TQueryFnData`, `unknown`\> #### TQueryKey @@ -85,7 +85,7 @@ Defined in: [packages/svelte-query/src/createInfiniteQuery.ts:40](https://github #### queryClient? -[`Accessor`](../type-aliases/Accessor.md)\<`QueryClient`\> +[`Accessor`](../type-aliases/Accessor.md)\<[`QueryClient`](../classes/QueryClient.md)\> ### Returns @@ -111,7 +111,7 @@ Defined in: [packages/svelte-query/src/createInfiniteQuery.ts:152](https://githu #### TData -`TData` = `InfiniteData`\<`TQueryFnData`, `unknown`\> +`TData` = [`InfiniteData`](../interfaces/InfiniteData.md)\<`TQueryFnData`, `unknown`\> #### TQueryKey @@ -132,7 +132,7 @@ The [CreateInfiniteQueryOptions](../type-aliases/CreateInfiniteQueryOptions.md) #### queryClient? -[`Accessor`](../type-aliases/Accessor.md)\<`QueryClient`\> +[`Accessor`](../type-aliases/Accessor.md)\<[`QueryClient`](../classes/QueryClient.md)\> Use this to use a custom `QueryClient`. Otherwise, the one from the nearest context will be used. diff --git a/docs/framework/svelte/reference/functions/createMutation.md b/docs/framework/svelte/reference/functions/createMutation.md index 84b812686f2..1c129fe5801 100644 --- a/docs/framework/svelte/reference/functions/createMutation.md +++ b/docs/framework/svelte/reference/functions/createMutation.md @@ -41,7 +41,7 @@ reactive. ### queryClient? -[`Accessor`](../type-aliases/Accessor.md)\<`QueryClient`\> +[`Accessor`](../type-aliases/Accessor.md)\<[`QueryClient`](../classes/QueryClient.md)\> Use this to use a custom `QueryClient`. Otherwise, the one from the nearest context will be used. diff --git a/docs/framework/svelte/reference/functions/createQueries.md b/docs/framework/svelte/reference/functions/createQueries.md index 77b3275b75e..d7bae38b57b 100644 --- a/docs/framework/svelte/reference/functions/createQueries.md +++ b/docs/framework/svelte/reference/functions/createQueries.md @@ -34,7 +34,7 @@ The `queries` array to run, and an optional `combine` function, wrapped in an ### queryClient? -[`Accessor`](../type-aliases/Accessor.md)\<`QueryClient`\> +[`Accessor`](../type-aliases/Accessor.md)\<[`QueryClient`](../classes/QueryClient.md)\> Use this to use a custom `QueryClient`. Otherwise, the one from the nearest context will be used. diff --git a/docs/framework/svelte/reference/functions/createQuery.md b/docs/framework/svelte/reference/functions/createQuery.md index 078e681de0b..043e07fa60d 100644 --- a/docs/framework/svelte/reference/functions/createQuery.md +++ b/docs/framework/svelte/reference/functions/createQuery.md @@ -40,7 +40,7 @@ wrapped in an [Accessor](../type-aliases/Accessor.md) so options can be reactive #### queryClient? -[`Accessor`](../type-aliases/Accessor.md)\<`QueryClient`\> +[`Accessor`](../type-aliases/Accessor.md)\<[`QueryClient`](../classes/QueryClient.md)\> Use this to use a custom `QueryClient`. Otherwise, the one from the nearest context will be used. @@ -145,7 +145,7 @@ with `initialData` set, wrapped in an [Accessor](../type-aliases/Accessor.md) so #### queryClient? -[`Accessor`](../type-aliases/Accessor.md)\<`QueryClient`\> +[`Accessor`](../type-aliases/Accessor.md)\<[`QueryClient`](../classes/QueryClient.md)\> Use this to use a custom `QueryClient`. Otherwise, the one from the nearest context will be used. @@ -224,7 +224,7 @@ in an [Accessor](../type-aliases/Accessor.md) so options can be reactive. #### queryClient? -[`Accessor`](../type-aliases/Accessor.md)\<`QueryClient`\> +[`Accessor`](../type-aliases/Accessor.md)\<[`QueryClient`](../classes/QueryClient.md)\> Use this to use a custom `QueryClient`. Otherwise, the one from the nearest context will be used. diff --git a/docs/framework/svelte/reference/functions/defaultShouldDehydrateMutation.md b/docs/framework/svelte/reference/functions/defaultShouldDehydrateMutation.md new file mode 100644 index 00000000000..940f8745a5d --- /dev/null +++ b/docs/framework/svelte/reference/functions/defaultShouldDehydrateMutation.md @@ -0,0 +1,23 @@ +--- +id: defaultShouldDehydrateMutation +title: defaultShouldDehydrateMutation +--- + +```ts +function defaultShouldDehydrateMutation(mutation): boolean; +``` + +Defined in: [packages/query-core/src/hydration.ts:177](https://github.com/TanStack/query/blob/main/packages/query-core/src/hydration.ts#L177) + +The default `shouldDehydrateMutation` predicate used by `dehydrate`. Only dehydrates mutations that are +currently paused (e.g. paused by `networkMode` while offline). + +## Parameters + +### mutation + +[`Mutation`](../classes/Mutation.md) + +## Returns + +`boolean` diff --git a/docs/framework/svelte/reference/functions/defaultShouldDehydrateQuery.md b/docs/framework/svelte/reference/functions/defaultShouldDehydrateQuery.md new file mode 100644 index 00000000000..abf19439d8a --- /dev/null +++ b/docs/framework/svelte/reference/functions/defaultShouldDehydrateQuery.md @@ -0,0 +1,23 @@ +--- +id: defaultShouldDehydrateQuery +title: defaultShouldDehydrateQuery +--- + +```ts +function defaultShouldDehydrateQuery(query): boolean; +``` + +Defined in: [packages/query-core/src/hydration.ts:185](https://github.com/TanStack/query/blob/main/packages/query-core/src/hydration.ts#L185) + +The default `shouldDehydrateQuery` predicate used by `dehydrate`. Only dehydrates queries whose status is +`'success'`. + +## Parameters + +### query + +[`Query`](../classes/Query.md) + +## Returns + +`boolean` diff --git a/docs/framework/svelte/reference/functions/dehydrate.md b/docs/framework/svelte/reference/functions/dehydrate.md new file mode 100644 index 00000000000..33cdcd3940d --- /dev/null +++ b/docs/framework/svelte/reference/functions/dehydrate.md @@ -0,0 +1,43 @@ +--- +id: dehydrate +title: dehydrate +--- + +```ts +function dehydrate(client, options): DehydratedState; +``` + +Defined in: [packages/query-core/src/hydration.ts:207](https://github.com/TanStack/query/blob/main/packages/query-core/src/hydration.ts#L207) + +Dehydrates a `QueryClient`'s cache (queries and mutations) into a plain, serializable `DehydratedState`, +typically to embed in server-rendered markup and later restore into a client-side `QueryClient` via `hydrate`. +Which queries/mutations are included, and how their data/errors are transformed, is controlled by `options`, +falling back to the client's `dehydrate` default options, and finally to `defaultShouldDehydrateQuery` / +`defaultShouldDehydrateMutation`. + +## Parameters + +### client + +[`QueryClient`](../classes/QueryClient.md) + +### options + +[`DehydrateOptions`](../interfaces/DehydrateOptions.md) = `{}` + +## Returns + +[`DehydratedState`](../interfaces/DehydratedState.md) + +## Example + +```ts +const queryClient = new QueryClient() + +await queryClient.prefetchQuery({ + queryKey: ['posts'], + queryFn: getPosts, +}) + +const dehydratedState = dehydrate(queryClient) +``` diff --git a/docs/framework/svelte/reference/functions/dehydrateQuery.md b/docs/framework/svelte/reference/functions/dehydrateQuery.md new file mode 100644 index 00000000000..2314f52fd91 --- /dev/null +++ b/docs/framework/svelte/reference/functions/dehydrateQuery.md @@ -0,0 +1,43 @@ +--- +id: dehydrateQuery +title: dehydrateQuery +--- + +```ts +function dehydrateQuery( + query, + serializeData?, + shouldRedactErrors?): DehydratedQuery; +``` + +Defined in: [packages/query-core/src/hydration.ts:148](https://github.com/TanStack/query/blob/main/packages/query-core/src/hydration.ts#L148) + +Dehydrates a single `Query` into a serializable `DehydratedQuery` snapshot. Note that most query config (e.g. +`queryFn`, `staleTime`) is not dehydrated but instead meant to be configured again when consuming the +de/rehydrated data, typically with `useQuery` on the client. If the query is still `pending`, its in-flight +promise is dehydrated too so it can be resumed on the other side instead of re-fetched. + +## Parameters + +### query + +[`Query`](../classes/Query.md) + +The query to dehydrate. + +### serializeData? + +`TransformerFn` + +Optional transform applied to `query.state.data` before it is included in the snapshot. + +### shouldRedactErrors? + +(`error`) => `boolean` + +Optional predicate; if it returns `false` for the promise's rejection error, that +error is kept as-is instead of being redacted. + +## Returns + +`DehydratedQuery` diff --git a/docs/framework/svelte/reference/functions/experimental_streamedQuery.md b/docs/framework/svelte/reference/functions/experimental_streamedQuery.md new file mode 100644 index 00000000000..4c490322d60 --- /dev/null +++ b/docs/framework/svelte/reference/functions/experimental_streamedQuery.md @@ -0,0 +1,52 @@ +--- +id: experimental_streamedQuery +title: experimental_streamedQuery +--- + +```ts +function experimental_streamedQuery(streamFn): QueryFunction; +``` + +Defined in: [packages/query-core/src/streamedQuery.ts:75](https://github.com/TanStack/query/blob/main/packages/query-core/src/streamedQuery.ts#L75) + +This is a helper function to create a query function that streams data from an AsyncIterable. +Data will be an Array of all the chunks received. +The query will be in a 'pending' state until the first chunk of data is received, but will go to 'success' after that. +The query will stay in fetchStatus 'fetching' until the stream ends. + +## Type Parameters + +### TQueryFnData + +`TQueryFnData` = `unknown` + +### TData + +`TData` = `TQueryFnData`[] + +### TQueryKey + +`TQueryKey` *extends* readonly `unknown`[] = readonly `unknown`[] + +## Parameters + +### streamFn + +`StreamedQueryParams`\<`TQueryFnData`, `TData`, `TQueryKey`\> + +The function that returns an AsyncIterable to stream data from. + +## Returns + +[`QueryFunction`](../type-aliases/QueryFunction.md)\<`TData`, `TQueryKey`\> + +## Example + +```ts +await queryClient.query({ + queryKey: ['data'], + queryFn: streamedQuery({ + streamFn: fetchDataInChunks, + }), +}) +``` diff --git a/docs/framework/svelte/reference/functions/getQueryClientContext.md b/docs/framework/svelte/reference/functions/getQueryClientContext.md index 9c409d66165..096087f9c1e 100644 --- a/docs/framework/svelte/reference/functions/getQueryClientContext.md +++ b/docs/framework/svelte/reference/functions/getQueryClientContext.md @@ -14,7 +14,7 @@ Retrieves the `QueryClient` set on Svelte's context by `QueryClientProvider` (or ## Returns -`QueryClient` +[`QueryClient`](../classes/QueryClient.md) The `QueryClient` set on context, whether by `QueryClientProvider` or [setQueryClientContext](setQueryClientContext.md). diff --git a/docs/framework/svelte/reference/functions/hashKey.md b/docs/framework/svelte/reference/functions/hashKey.md new file mode 100644 index 00000000000..dc774c032ce --- /dev/null +++ b/docs/framework/svelte/reference/functions/hashKey.md @@ -0,0 +1,30 @@ +--- +id: hashKey +title: hashKey +--- + +```ts +function hashKey(queryKey): string; +``` + +Defined in: [packages/query-core/src/utils.ts:284](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L284) + +Default query & mutation keys hash function. +Hashes the value into a stable hash. + +## Parameters + +### queryKey + +readonly `unknown`[] + +## Returns + +`string` + +## Example + +```ts +// Object keys are sorted, so key order doesn't affect the hash: +hashKey(['todos', { page: 1, filter: 'done' }]) // === '["todos",{"filter":"done","page":1}]' +``` diff --git a/docs/framework/svelte/reference/functions/hydrate.md b/docs/framework/svelte/reference/functions/hydrate.md new file mode 100644 index 00000000000..c0093b57457 --- /dev/null +++ b/docs/framework/svelte/reference/functions/hydrate.md @@ -0,0 +1,49 @@ +--- +id: hydrate +title: hydrate +--- + +```ts +function hydrate( + client, + dehydratedState, + options?): void; +``` + +Defined in: [packages/query-core/src/hydration.ts:264](https://github.com/TanStack/query/blob/main/packages/query-core/src/hydration.ts#L264) + +Restores a `DehydratedState` (as produced by `dehydrate`) into a `QueryClient`'s cache, typically to seed the +client with data already fetched on the server. `mutations` and `queries` are each optional on `dehydratedState`. +Queries not yet in the cache are built from the dehydrated snapshot; queries that already exist are only updated +when the dehydrated data is newer than what's already cached. Newly built queries have their `fetchStatus` reset +to `'idle'` so they don't hydrate stuck in a fetching state. If a dehydrated query still had an in-flight +promise, it is resumed via `query.fetch()` (reusing that promise as `initialPromise`) rather than re-invoking +`queryFn`. + +## Parameters + +### client + +[`QueryClient`](../classes/QueryClient.md) + +### dehydratedState + +`Partial`\<[`DehydratedState`](../interfaces/DehydratedState.md)\> + +### options? + +[`HydrateOptions`](../interfaces/HydrateOptions.md) + +## Returns + +`void` + +## Example + +```ts +// dehydratedState was produced by `dehydrate` on the server +// and sent to the client, e.g. embedded in server-rendered markup. +const queryClient = new QueryClient() + +hydrate(queryClient, dehydratedState) +``` diff --git a/docs/framework/svelte/reference/functions/infiniteQueryOptions.md b/docs/framework/svelte/reference/functions/infiniteQueryOptions.md index 528e063cee3..7f85b977af0 100644 --- a/docs/framework/svelte/reference/functions/infiniteQueryOptions.md +++ b/docs/framework/svelte/reference/functions/infiniteQueryOptions.md @@ -29,7 +29,7 @@ This overload is selected when `initialData` is set. #### TData -`TData` = `InfiniteData`\<`TQueryFnData`, `unknown`\> +`TData` = [`InfiniteData`](../interfaces/InfiniteData.md)\<`TQueryFnData`, `unknown`\> #### TQueryKey @@ -50,7 +50,7 @@ The [DefinedInitialDataInfiniteOptions](../type-aliases/DefinedInitialDataInfini ### Returns -[`CreateInfiniteQueryOptions`](../type-aliases/CreateInfiniteQueryOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`, `TPageParam`\> & `object` & `QueryKeyWithDataTag`\<`TQueryKey`, `InfiniteData`\<`TQueryFnData`, `unknown`\>, `TError`\> +[`CreateInfiniteQueryOptions`](../type-aliases/CreateInfiniteQueryOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`, `TPageParam`\> & `object` & [`QueryKeyWithDataTag`](../type-aliases/QueryKeyWithDataTag.md)\<`TQueryKey`, [`InfiniteData`](../interfaces/InfiniteData.md)\<`TQueryFnData`, `unknown`\>, `TError`\> The same options object, typed so that `queryKey` carries the inferred data type. @@ -113,7 +113,7 @@ These options can be shared across `createInfiniteQuery` calls and imperative AP #### TData -`TData` = `InfiniteData`\<`TQueryFnData`, `unknown`\> +`TData` = [`InfiniteData`](../interfaces/InfiniteData.md)\<`TQueryFnData`, `unknown`\> #### TQueryKey @@ -134,7 +134,7 @@ The [UndefinedInitialDataInfiniteOptions](../type-aliases/UndefinedInitialDataIn ### Returns -[`CreateInfiniteQueryOptions`](../type-aliases/CreateInfiniteQueryOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`, `TPageParam`\> & `object` & `QueryKeyWithDataTag`\<`TQueryKey`, `InfiniteData`\<`TQueryFnData`, `unknown`\>, `TError`\> +[`CreateInfiniteQueryOptions`](../type-aliases/CreateInfiniteQueryOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`, `TPageParam`\> & `object` & [`QueryKeyWithDataTag`](../type-aliases/QueryKeyWithDataTag.md)\<`TQueryKey`, [`InfiniteData`](../interfaces/InfiniteData.md)\<`TQueryFnData`, `unknown`\>, `TError`\> The same options object, typed so that `queryKey` carries the inferred data type. diff --git a/docs/framework/svelte/reference/functions/isCancelledError.md b/docs/framework/svelte/reference/functions/isCancelledError.md new file mode 100644 index 00000000000..c8f57c4b94d --- /dev/null +++ b/docs/framework/svelte/reference/functions/isCancelledError.md @@ -0,0 +1,24 @@ +--- +id: isCancelledError +title: isCancelledError +--- + +```ts +function isCancelledError(value): value is CancelledError; +``` + +Defined in: [packages/query-core/src/retryer.ts:90](https://github.com/TanStack/query/blob/main/packages/query-core/src/retryer.ts#L90) + +## Parameters + +### value + +`any` + +## Returns + +`value is CancelledError` + +## Deprecated + +Use instanceof `CancelledError` instead. diff --git a/docs/framework/svelte/reference/functions/keepPreviousData.md b/docs/framework/svelte/reference/functions/keepPreviousData.md new file mode 100644 index 00000000000..6a84f4c5970 --- /dev/null +++ b/docs/framework/svelte/reference/functions/keepPreviousData.md @@ -0,0 +1,40 @@ +--- +id: keepPreviousData +title: keepPreviousData +--- + +```ts +function keepPreviousData(previousData): T | undefined; +``` + +Defined in: [packages/query-core/src/utils.ts:493](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L493) + +Intended to be passed as a query's `placeholderData` option, for example +`placeholderData: keepPreviousData`. Instead of resetting the query's data to `undefined` while a new +query key is fetching, it keeps displaying the previously fetched data until the new data arrives. + +## Type Parameters + +### T + +`T` + +## Parameters + +### previousData + +`T` | `undefined` + +## Returns + +`T` \| `undefined` + +## Example + +```ts +new QueryObserver(queryClient, { + queryKey: ['posts', page], + queryFn: () => fetchPosts(page), + placeholderData: keepPreviousData, +}) +``` diff --git a/docs/framework/svelte/reference/functions/matchMutation.md b/docs/framework/svelte/reference/functions/matchMutation.md new file mode 100644 index 00000000000..40210da4cf1 --- /dev/null +++ b/docs/framework/svelte/reference/functions/matchMutation.md @@ -0,0 +1,38 @@ +--- +id: matchMutation +title: matchMutation +--- + +```ts +function matchMutation(filters, mutation): boolean; +``` + +Defined in: [packages/query-core/src/utils.ts:237](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L237) + +Checks whether a mutation matches the given [MutationFilters](../interfaces/MutationFilters.md). +Every filter that is specified must match; filters that are left unspecified are ignored. +If a `mutationKey` filter is provided but the mutation has no `mutationKey` of its own, it does not match. + +## Parameters + +### filters + +[`MutationFilters`](../interfaces/MutationFilters.md) + +### mutation + +[`Mutation`](../classes/Mutation.md)\<`any`, `any`\> + +## Returns + +`boolean` + +## Example + +```ts +const mutationCache = queryClient.getMutationCache() + +const matchingMutations = mutationCache + .getAll() + .filter((mutation) => matchMutation({ mutationKey: ['addPost'] }, mutation)) +``` diff --git a/docs/framework/svelte/reference/functions/matchQuery.md b/docs/framework/svelte/reference/functions/matchQuery.md new file mode 100644 index 00000000000..4c54b2df995 --- /dev/null +++ b/docs/framework/svelte/reference/functions/matchQuery.md @@ -0,0 +1,37 @@ +--- +id: matchQuery +title: matchQuery +--- + +```ts +function matchQuery(filters, query): boolean; +``` + +Defined in: [packages/query-core/src/utils.ts:175](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L175) + +Checks whether a query matches the given [QueryFilters](../interfaces/QueryFilters.md). +Every filter that is specified must match; filters that are left unspecified are ignored. + +## Parameters + +### filters + +[`QueryFilters`](../interfaces/QueryFilters.md) + +### query + +[`Query`](../classes/Query.md)\<`any`, `any`, `any`, `any`\> + +## Returns + +`boolean` + +## Example + +```ts +const queryCache = queryClient.getQueryCache() + +const matchingQueries = queryCache + .getAll() + .filter((query) => matchQuery({ queryKey: ['posts'] }, query)) +``` diff --git a/docs/framework/svelte/reference/functions/mutationOptions.md b/docs/framework/svelte/reference/functions/mutationOptions.md index b1b3cbdf839..70c84d47672 100644 --- a/docs/framework/svelte/reference/functions/mutationOptions.md +++ b/docs/framework/svelte/reference/functions/mutationOptions.md @@ -37,13 +37,13 @@ overload requires `mutationKey`, so the resulting options can be looked up elsew #### options -`WithRequired`\<[`CreateMutationOptions`](../type-aliases/CreateMutationOptions.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\>, `"mutationKey"`\> +[`WithRequired`](../type-aliases/WithRequired.md)\<[`CreateMutationOptions`](../type-aliases/CreateMutationOptions.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\>, `"mutationKey"`\> The options to use — everything you can pass to `createMutation`, with `mutationKey` set. ### Returns -`WithRequired`\<[`CreateMutationOptions`](../type-aliases/CreateMutationOptions.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\>, `"mutationKey"`\> +[`WithRequired`](../type-aliases/WithRequired.md)\<[`CreateMutationOptions`](../type-aliases/CreateMutationOptions.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\>, `"mutationKey"`\> The same options object. diff --git a/docs/framework/svelte/reference/functions/noop.md b/docs/framework/svelte/reference/functions/noop.md new file mode 100644 index 00000000000..01fb409f4e9 --- /dev/null +++ b/docs/framework/svelte/reference/functions/noop.md @@ -0,0 +1,32 @@ +--- +id: noop +title: noop +--- + +## Call Signature + +```ts +function noop(): void; +``` + +Defined in: [packages/query-core/src/utils.ts:119](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L119) + +A function that does nothing. + +### Returns + +`void` + +## Call Signature + +```ts +function noop(): undefined; +``` + +Defined in: [packages/query-core/src/utils.ts:120](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L120) + +A function that does nothing. + +### Returns + +`undefined` diff --git a/docs/framework/svelte/reference/functions/partialMatchKey.md b/docs/framework/svelte/reference/functions/partialMatchKey.md new file mode 100644 index 00000000000..4db67323e9b --- /dev/null +++ b/docs/framework/svelte/reference/functions/partialMatchKey.md @@ -0,0 +1,26 @@ +--- +id: partialMatchKey +title: partialMatchKey +--- + +```ts +function partialMatchKey(a, b): boolean; +``` + +Defined in: [packages/query-core/src/utils.ts:300](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L300) + +Checks if key `b` partially matches with key `a`. + +## Parameters + +### a + +readonly `unknown`[] + +### b + +readonly `unknown`[] + +## Returns + +`boolean` diff --git a/docs/framework/svelte/reference/functions/queryOptions.md b/docs/framework/svelte/reference/functions/queryOptions.md index 9df98bee357..da01a743ef8 100644 --- a/docs/framework/svelte/reference/functions/queryOptions.md +++ b/docs/framework/svelte/reference/functions/queryOptions.md @@ -46,7 +46,7 @@ with `initialData` set. ### Returns -[`CreateQueryOptions`](../type-aliases/CreateQueryOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`\> & `object` & `QueryKeyWithDataTag`\<`TQueryKey`, `TQueryFnData`, `TError`\> +[`CreateQueryOptions`](../type-aliases/CreateQueryOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`\> & `object` & [`QueryKeyWithDataTag`](../type-aliases/QueryKeyWithDataTag.md)\<`TQueryKey`, `TQueryFnData`, `TError`\> The same options object, typed so that `queryKey` carries the inferred data type. @@ -121,7 +121,7 @@ The [UndefinedInitialDataOptions](../type-aliases/UndefinedInitialDataOptions.md ### Returns -[`CreateQueryOptions`](../type-aliases/CreateQueryOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`\> & `object` & `QueryKeyWithDataTag`\<`TQueryKey`, `TQueryFnData`, `TError`\> +[`CreateQueryOptions`](../type-aliases/CreateQueryOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`\> & `object` & [`QueryKeyWithDataTag`](../type-aliases/QueryKeyWithDataTag.md)\<`TQueryKey`, `TQueryFnData`, `TError`\> The same options object, typed so that `queryKey` carries the inferred data type. diff --git a/docs/framework/svelte/reference/functions/replaceEqualDeep.md b/docs/framework/svelte/reference/functions/replaceEqualDeep.md new file mode 100644 index 00000000000..6a81c3907fb --- /dev/null +++ b/docs/framework/svelte/reference/functions/replaceEqualDeep.md @@ -0,0 +1,41 @@ +--- +id: replaceEqualDeep +title: replaceEqualDeep +--- + +```ts +function replaceEqualDeep( + a, + b, + depth?): T; +``` + +Defined in: [packages/query-core/src/utils.ts:339](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L339) + +This function returns `a` if `b` is deeply equal. +If not, it will replace any deeply equal children of `b` with those of `a`. +This can be used for structural sharing between JSON values for example. + +## Type Parameters + +### T + +`T` + +## Parameters + +### a + +`unknown` + +### b + +`T` + +### depth? + +`number` + +## Returns + +`T` diff --git a/docs/framework/svelte/reference/functions/setQueryClientContext.md b/docs/framework/svelte/reference/functions/setQueryClientContext.md index 2c469623faa..7d8309828cd 100644 --- a/docs/framework/svelte/reference/functions/setQueryClientContext.md +++ b/docs/framework/svelte/reference/functions/setQueryClientContext.md @@ -17,7 +17,7 @@ only if you need to set the client from your own component instead. ### client -`QueryClient` +[`QueryClient`](../classes/QueryClient.md) The `QueryClient` to make available to descendant components. diff --git a/docs/framework/svelte/reference/functions/shouldThrowError.md b/docs/framework/svelte/reference/functions/shouldThrowError.md new file mode 100644 index 00000000000..1f1e62a8d0e --- /dev/null +++ b/docs/framework/svelte/reference/functions/shouldThrowError.md @@ -0,0 +1,45 @@ +--- +id: shouldThrowError +title: shouldThrowError +--- + +```ts +function shouldThrowError(throwOnError, params): boolean; +``` + +Defined in: [packages/query-core/src/utils.ts:576](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L576) + +Resolves a `throwOnError` option to a boolean. +If `throwOnError` is a function, it is called with `params` (e.g. the error and, depending on the caller, +additional context such as the query or mutation) and its result is returned, allowing the throwing +behavior to be decided per error. Otherwise, `throwOnError` itself is coerced to a boolean (`undefined` +resolves to `false`). + +## Type Parameters + +### T + +`T` *extends* (...`args`) => `boolean` + +## Parameters + +### throwOnError + +`boolean` | `T` | `undefined` + +### params + +`Parameters`\<`T`\> + +## Returns + +`boolean` + +## Example + +```ts +const throwOnError = + query.state.error && typeof options.throwOnError === 'function' + ? shouldThrowError(options.throwOnError, [query.state.error, query]) + : options.throwOnError +``` diff --git a/docs/framework/svelte/reference/functions/useHydrate.md b/docs/framework/svelte/reference/functions/useHydrate.md index 780abcd1e7f..e2b0957c9ca 100644 --- a/docs/framework/svelte/reference/functions/useHydrate.md +++ b/docs/framework/svelte/reference/functions/useHydrate.md @@ -27,13 +27,13 @@ The dehydrated state to hydrate into the cache, as produced by `dehydrate`. ### options? -`HydrateOptions` +[`HydrateOptions`](../interfaces/HydrateOptions.md) -HydrateOptions to control the hydration. +[HydrateOptions](../interfaces/HydrateOptions.md) to control the hydration. ### queryClient? -`QueryClient` +[`QueryClient`](../classes/QueryClient.md) Use this to use a custom `QueryClient`. Otherwise, the one from the nearest context will be used. diff --git a/docs/framework/svelte/reference/functions/useIsFetching.md b/docs/framework/svelte/reference/functions/useIsFetching.md index 0c2eca7496f..b54ac5d3cfe 100644 --- a/docs/framework/svelte/reference/functions/useIsFetching.md +++ b/docs/framework/svelte/reference/functions/useIsFetching.md @@ -13,14 +13,14 @@ Defined in: [packages/svelte-query/src/useIsFetching.svelte.ts:40](https://githu ### filters? -`QueryFilters`\ +[`QueryFilters`](../interfaces/QueryFilters.md)\ -QueryFilters to narrow down which queries to count. Omit to count every fetching +[QueryFilters](../interfaces/QueryFilters.md) to narrow down which queries to count. Omit to count every fetching query. ### queryClient? -`QueryClient` +[`QueryClient`](../classes/QueryClient.md) Use this to use a custom `QueryClient`. Otherwise, the one from the nearest context will be used. diff --git a/docs/framework/svelte/reference/functions/useIsMutating.md b/docs/framework/svelte/reference/functions/useIsMutating.md index 7be79e23809..d81f5e6106a 100644 --- a/docs/framework/svelte/reference/functions/useIsMutating.md +++ b/docs/framework/svelte/reference/functions/useIsMutating.md @@ -16,13 +16,13 @@ running (useful for app-wide loading indicators). ### filters? -`MutationFilters`\<`unknown`, `Error`, `unknown`, `unknown`\> +[`MutationFilters`](../interfaces/MutationFilters.md)\<`unknown`, `Error`, `unknown`, `unknown`\> -MutationFilters to narrow down which mutations to count. +[MutationFilters](../interfaces/MutationFilters.md) to narrow down which mutations to count. ### queryClient? -`QueryClient` +[`QueryClient`](../classes/QueryClient.md) Use this to use a custom `QueryClient`. Otherwise, the one from the nearest context will be used. diff --git a/docs/framework/svelte/reference/functions/useMutationState.md b/docs/framework/svelte/reference/functions/useMutationState.md index 27cd0fac728..da623f58e46 100644 --- a/docs/framework/svelte/reference/functions/useMutationState.md +++ b/docs/framework/svelte/reference/functions/useMutationState.md @@ -16,11 +16,11 @@ were created by a different component or hook instance, or even ones no longer m ### TResult -`TResult` = `MutationState`\<`unknown`, `Error`, `unknown`, `unknown`\> +`TResult` = [`MutationState`](../interfaces/MutationState.md)\<`unknown`, `Error`, `unknown`, `unknown`\> ### TMutation -`TMutation` *extends* `Mutation`\<`any`, `any`, `any`, `any`\> = [`MutationTypeFromResult`](../type-aliases/MutationTypeFromResult.md)\<`TResult`\> +`TMutation` *extends* [`Mutation`](../classes/Mutation.md)\<`any`, `any`, `any`, `any`\> = [`MutationTypeFromResult`](../type-aliases/MutationTypeFromResult.md)\<`TResult`\> ## Parameters @@ -33,7 +33,7 @@ mutation state. ### queryClient? -`QueryClient` +[`QueryClient`](../classes/QueryClient.md) Use this to use a custom `QueryClient`. Otherwise, the one from the nearest context will be used. diff --git a/docs/framework/svelte/reference/functions/useQueryClient.md b/docs/framework/svelte/reference/functions/useQueryClient.md index 01116b8edee..1799ad8e45b 100644 --- a/docs/framework/svelte/reference/functions/useQueryClient.md +++ b/docs/framework/svelte/reference/functions/useQueryClient.md @@ -13,8 +13,8 @@ Defined in: [packages/svelte-query/src/useQueryClient.ts:4](https://github.com/T ### queryClient? -`QueryClient` +[`QueryClient`](../classes/QueryClient.md) ## Returns -`QueryClient` +[`QueryClient`](../classes/QueryClient.md) diff --git a/docs/framework/svelte/reference/index.md b/docs/framework/svelte/reference/index.md index daeca51b5c1..f448902ceee 100644 --- a/docs/framework/svelte/reference/index.md +++ b/docs/framework/svelte/reference/index.md @@ -3,9 +3,84 @@ id: "@tanstack/svelte-query" title: "@tanstack/svelte-query" --- +## Classes + +- [CancelledError](classes/CancelledError.md) +- [InfiniteQueryObserver](classes/InfiniteQueryObserver.md) +- [Mutation](classes/Mutation.md) +- [MutationCache](classes/MutationCache.md) +- [MutationObserver](classes/MutationObserver.md) +- [QueriesObserver](classes/QueriesObserver.md) +- [Query](classes/Query.md) +- [QueryCache](classes/QueryCache.md) +- [QueryClient](classes/QueryClient.md) +- [QueryObserver](classes/QueryObserver.md) + +## Interfaces + +- [CancelOptions](interfaces/CancelOptions.md) +- [DefaultOptions](interfaces/DefaultOptions.md) +- [DehydratedState](interfaces/DehydratedState.md) +- [DehydrateOptions](interfaces/DehydrateOptions.md) +- [~~EnsureQueryDataOptions~~](interfaces/EnsureQueryDataOptions.md) +- [FetchNextPageOptions](interfaces/FetchNextPageOptions.md) +- [FetchPreviousPageOptions](interfaces/FetchPreviousPageOptions.md) +- [~~FetchQueryOptions~~](interfaces/FetchQueryOptions.md) +- [FocusManager](interfaces/FocusManager.md) +- [HydrateOptions](interfaces/HydrateOptions.md) +- [InfiniteData](interfaces/InfiniteData.md) +- [InfiniteQueryObserverBaseResult](interfaces/InfiniteQueryObserverBaseResult.md) +- [InfiniteQueryObserverLoadingErrorResult](interfaces/InfiniteQueryObserverLoadingErrorResult.md) +- [InfiniteQueryObserverLoadingResult](interfaces/InfiniteQueryObserverLoadingResult.md) +- [InfiniteQueryObserverOptions](interfaces/InfiniteQueryObserverOptions.md) +- [InfiniteQueryObserverPendingResult](interfaces/InfiniteQueryObserverPendingResult.md) +- [InfiniteQueryObserverPlaceholderResult](interfaces/InfiniteQueryObserverPlaceholderResult.md) +- [InfiniteQueryObserverRefetchErrorResult](interfaces/InfiniteQueryObserverRefetchErrorResult.md) +- [InfiniteQueryObserverSuccessResult](interfaces/InfiniteQueryObserverSuccessResult.md) +- [InfiniteQueryPageParamsOptions](interfaces/InfiniteQueryPageParamsOptions.md) +- [InitialPageParam](interfaces/InitialPageParam.md) +- [InvalidateOptions](interfaces/InvalidateOptions.md) +- [InvalidateQueryFilters](interfaces/InvalidateQueryFilters.md) +- [MutateOptions](interfaces/MutateOptions.md) +- [MutationCacheConfig](interfaces/MutationCacheConfig.md) +- [MutationFilters](interfaces/MutationFilters.md) +- [MutationObserverBaseResult](interfaces/MutationObserverBaseResult.md) +- [MutationObserverErrorResult](interfaces/MutationObserverErrorResult.md) +- [MutationObserverIdleResult](interfaces/MutationObserverIdleResult.md) +- [MutationObserverLoadingResult](interfaces/MutationObserverLoadingResult.md) +- [MutationObserverOptions](interfaces/MutationObserverOptions.md) +- [MutationObserverSuccessResult](interfaces/MutationObserverSuccessResult.md) +- [MutationOptions](interfaces/MutationOptions.md) +- [MutationState](interfaces/MutationState.md) +- [NotifyEvent](interfaces/NotifyEvent.md) +- [OnlineManager](interfaces/OnlineManager.md) +- [QueriesObserverOptions](interfaces/QueriesObserverOptions.md) +- [QueryCacheConfig](interfaces/QueryCacheConfig.md) +- [QueryClientConfig](interfaces/QueryClientConfig.md) +- [QueryExecuteOptions](interfaces/QueryExecuteOptions.md) +- [QueryFilters](interfaces/QueryFilters.md) +- [QueryObserverBaseResult](interfaces/QueryObserverBaseResult.md) +- [QueryObserverLoadingErrorResult](interfaces/QueryObserverLoadingErrorResult.md) +- [QueryObserverLoadingResult](interfaces/QueryObserverLoadingResult.md) +- [QueryObserverOptions](interfaces/QueryObserverOptions.md) +- [QueryObserverPendingResult](interfaces/QueryObserverPendingResult.md) +- [QueryObserverPlaceholderResult](interfaces/QueryObserverPlaceholderResult.md) +- [QueryObserverRefetchErrorResult](interfaces/QueryObserverRefetchErrorResult.md) +- [QueryObserverSuccessResult](interfaces/QueryObserverSuccessResult.md) +- [QueryOptions](interfaces/QueryOptions.md) +- [QueryState](interfaces/QueryState.md) +- [RefetchOptions](interfaces/RefetchOptions.md) +- [RefetchQueryFilters](interfaces/RefetchQueryFilters.md) +- [Register](interfaces/Register.md) +- [ResetOptions](interfaces/ResetOptions.md) +- [ResultOptions](interfaces/ResultOptions.md) +- [SetDataOptions](interfaces/SetDataOptions.md) +- [TimeoutManager](interfaces/TimeoutManager.md) + ## Type Aliases - [Accessor](type-aliases/Accessor.md) +- [AnyDataTag](type-aliases/AnyDataTag.md) - [CreateBaseMutationResult](type-aliases/CreateBaseMutationResult.md) - [CreateBaseQueryOptions](type-aliases/CreateBaseQueryOptions.md) - [CreateBaseQueryResult](type-aliases/CreateBaseQueryResult.md) @@ -17,23 +92,92 @@ title: "@tanstack/svelte-query" - [CreateMutationResult](type-aliases/CreateMutationResult.md) - [CreateQueryOptions](type-aliases/CreateQueryOptions.md) - [CreateQueryResult](type-aliases/CreateQueryResult.md) +- [DataTag](type-aliases/DataTag.md) +- [dataTagErrorSymbol](type-aliases/dataTagErrorSymbol.md) +- [dataTagSymbol](type-aliases/dataTagSymbol.md) +- [DefaultedInfiniteQueryObserverOptions](type-aliases/DefaultedInfiniteQueryObserverOptions.md) +- [DefaultedQueryObserverOptions](type-aliases/DefaultedQueryObserverOptions.md) +- [DefaultError](type-aliases/DefaultError.md) - [DefinedCreateBaseQueryResult](type-aliases/DefinedCreateBaseQueryResult.md) - [DefinedCreateInfiniteQueryResult](type-aliases/DefinedCreateInfiniteQueryResult.md) - [DefinedCreateQueryResult](type-aliases/DefinedCreateQueryResult.md) +- [DefinedInfiniteQueryObserverResult](type-aliases/DefinedInfiniteQueryObserverResult.md) - [DefinedInitialDataInfiniteOptions](type-aliases/DefinedInitialDataInfiniteOptions.md) - [DefinedInitialDataOptions](type-aliases/DefinedInitialDataOptions.md) +- [DefinedQueryObserverResult](type-aliases/DefinedQueryObserverResult.md) +- [DistributiveOmit](type-aliases/DistributiveOmit.md) +- [~~EnsureInfiniteQueryDataOptions~~](type-aliases/EnsureInfiniteQueryDataOptions.md) +- [~~FetchInfiniteQueryOptions~~](type-aliases/FetchInfiniteQueryOptions.md) +- [FetchStatus](type-aliases/FetchStatus.md) +- [GetNextPageParamFunction](type-aliases/GetNextPageParamFunction.md) +- [GetPreviousPageParamFunction](type-aliases/GetPreviousPageParamFunction.md) - [HydrationBoundary](type-aliases/HydrationBoundary.md) +- [InferDataFromTag](type-aliases/InferDataFromTag.md) +- [InferErrorFromTag](type-aliases/InferErrorFromTag.md) +- [InfiniteQueryExecuteOptions](type-aliases/InfiniteQueryExecuteOptions.md) +- [InfiniteQueryObserverResult](type-aliases/InfiniteQueryObserverResult.md) +- [InitialDataFunction](type-aliases/InitialDataFunction.md) +- [ManagedTimerId](type-aliases/ManagedTimerId.md) +- [MutateFunction](type-aliases/MutateFunction.md) +- [MutateFunctionRest](type-aliases/MutateFunctionRest.md) +- [MutationCacheNotifyEvent](type-aliases/MutationCacheNotifyEvent.md) +- [MutationFunction](type-aliases/MutationFunction.md) +- [MutationFunctionContext](type-aliases/MutationFunctionContext.md) +- [MutationKey](type-aliases/MutationKey.md) +- [MutationMeta](type-aliases/MutationMeta.md) +- [MutationObserverResult](type-aliases/MutationObserverResult.md) +- [MutationScope](type-aliases/MutationScope.md) - [MutationStateOptions](type-aliases/MutationStateOptions.md) +- [MutationStatus](type-aliases/MutationStatus.md) - [MutationTypeFromResult](type-aliases/MutationTypeFromResult.md) +- [NetworkMode](type-aliases/NetworkMode.md) +- [NonUndefinedGuard](type-aliases/NonUndefinedGuard.md) +- [NotifyEventType](type-aliases/NotifyEventType.md) +- [NotifyOnChangeProps](type-aliases/NotifyOnChangeProps.md) +- [OmitKeyof](type-aliases/OmitKeyof.md) +- [Override](type-aliases/Override.md) +- [PlaceholderDataFunction](type-aliases/PlaceholderDataFunction.md) - [QueriesOptions](type-aliases/QueriesOptions.md) +- [QueriesPlaceholderDataFunction](type-aliases/QueriesPlaceholderDataFunction.md) - [QueriesResults](type-aliases/QueriesResults.md) +- [QueryBooleanOption](type-aliases/QueryBooleanOption.md) +- [QueryCacheNotifyEvent](type-aliases/QueryCacheNotifyEvent.md) - [QueryClientProviderProps](type-aliases/QueryClientProviderProps.md) +- [QueryFunction](type-aliases/QueryFunction.md) +- [QueryFunctionContext](type-aliases/QueryFunctionContext.md) +- [QueryKey](type-aliases/QueryKey.md) +- [QueryKeyHashFunction](type-aliases/QueryKeyHashFunction.md) +- [QueryKeyWithDataTag](type-aliases/QueryKeyWithDataTag.md) +- [QueryMeta](type-aliases/QueryMeta.md) +- [QueryObserverResult](type-aliases/QueryObserverResult.md) +- [QueryPersister](type-aliases/QueryPersister.md) +- [QueryStatus](type-aliases/QueryStatus.md) +- [SkipToken](type-aliases/SkipToken.md) +- [StaleTime](type-aliases/StaleTime.md) +- [StaleTimeFunction](type-aliases/StaleTimeFunction.md) +- [ThrowOnError](type-aliases/ThrowOnError.md) +- [TimeoutCallback](type-aliases/TimeoutCallback.md) +- [TimeoutProvider](type-aliases/TimeoutProvider.md) - [UndefinedInitialDataInfiniteOptions](type-aliases/UndefinedInitialDataInfiniteOptions.md) - [UndefinedInitialDataOptions](type-aliases/UndefinedInitialDataOptions.md) +- [UnsetMarker](type-aliases/UnsetMarker.md) +- [Updater](type-aliases/Updater.md) +- [WithRequired](type-aliases/WithRequired.md) ## Variables +- [dataTagErrorSymbol](variables/dataTagErrorSymbol.md) +- [dataTagSymbol](variables/dataTagSymbol.md) +- [defaultScheduler](variables/defaultScheduler.md) +- [environmentManager](variables/environmentManager.md) +- [focusManager](variables/focusManager.md) - [HydrationBoundary](variables/HydrationBoundary.md) +- [~~isServer~~](variables/isServer.md) +- [notifyManager](variables/notifyManager.md) +- [onlineManager](variables/onlineManager.md) +- [skipToken](variables/skipToken.md) +- [timeoutManager](variables/timeoutManager.md) +- [unsetMarker](variables/unsetMarker.md) ## Functions @@ -41,13 +185,28 @@ title: "@tanstack/svelte-query" - [createMutation](functions/createMutation.md) - [createQueries](functions/createQueries.md) - [createQuery](functions/createQuery.md) +- [defaultShouldDehydrateMutation](functions/defaultShouldDehydrateMutation.md) +- [defaultShouldDehydrateQuery](functions/defaultShouldDehydrateQuery.md) +- [dehydrate](functions/dehydrate.md) +- [dehydrateQuery](functions/dehydrateQuery.md) +- [experimental\_streamedQuery](functions/experimental_streamedQuery.md) - [getIsRestoringContext](functions/getIsRestoringContext.md) - [getQueryClientContext](functions/getQueryClientContext.md) +- [hashKey](functions/hashKey.md) +- [hydrate](functions/hydrate.md) - [infiniteQueryOptions](functions/infiniteQueryOptions.md) +- [~~isCancelledError~~](functions/isCancelledError.md) +- [keepPreviousData](functions/keepPreviousData.md) +- [matchMutation](functions/matchMutation.md) +- [matchQuery](functions/matchQuery.md) - [mutationOptions](functions/mutationOptions.md) +- [noop](functions/noop.md) +- [partialMatchKey](functions/partialMatchKey.md) - [queryOptions](functions/queryOptions.md) +- [replaceEqualDeep](functions/replaceEqualDeep.md) - [setIsRestoringContext](functions/setIsRestoringContext.md) - [setQueryClientContext](functions/setQueryClientContext.md) +- [shouldThrowError](functions/shouldThrowError.md) - [useHydrate](functions/useHydrate.md) - [useIsFetching](functions/useIsFetching.md) - [useIsMutating](functions/useIsMutating.md) diff --git a/docs/framework/svelte/reference/interfaces/CancelOptions.md b/docs/framework/svelte/reference/interfaces/CancelOptions.md new file mode 100644 index 00000000000..b7464c48e50 --- /dev/null +++ b/docs/framework/svelte/reference/interfaces/CancelOptions.md @@ -0,0 +1,26 @@ +--- +id: CancelOptions +title: CancelOptions +--- + +Defined in: [packages/query-core/src/types.ts:1521](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1521) + +## Properties + +### revert? + +```ts +optional revert: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1522](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1522) + +*** + +### silent? + +```ts +optional silent: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1523](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1523) diff --git a/docs/framework/svelte/reference/interfaces/DefaultOptions.md b/docs/framework/svelte/reference/interfaces/DefaultOptions.md new file mode 100644 index 00000000000..e45a56f075f --- /dev/null +++ b/docs/framework/svelte/reference/interfaces/DefaultOptions.md @@ -0,0 +1,84 @@ +--- +id: DefaultOptions +title: DefaultOptions +--- + +Defined in: [packages/query-core/src/types.ts:1507](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1507) + +## Type Parameters + +### TError + +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) + +## Properties + +### dehydrate? + +```ts +optional dehydrate: DehydrateOptions; +``` + +Defined in: [packages/query-core/src/types.ts:1518](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1518) + +Default options used when dehydrating the client's caches; see [DehydrateOptions](DehydrateOptions.md). + +*** + +### hydrate? + +```ts +optional hydrate: object; +``` + +Defined in: [packages/query-core/src/types.ts:1516](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1516) + +Default options used when hydrating queries; see [HydrateOptions](HydrateOptions.md). + +#### deserializeData? + +```ts +optional deserializeData: TransformerFn; +``` + +Transforms a query's `data` after it is read from the dehydrated state, reversing `serializeData`. + +#### mutations? + +```ts +optional mutations: MutationOptions; +``` + +Default options merged into every mutation restored from the dehydrated state. + +#### queries? + +```ts +optional queries: QueryOptions; +``` + +Default options merged into every query restored from the dehydrated state. + +*** + +### mutations? + +```ts +optional mutations: MutationObserverOptions; +``` + +Defined in: [packages/query-core/src/types.ts:1514](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1514) + +Default options applied to every mutation, unless overridden per-mutation. + +*** + +### queries? + +```ts +optional queries: OmitKeyof, "queryKey" | "suspense", "strictly">; +``` + +Defined in: [packages/query-core/src/types.ts:1509](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1509) + +Default options applied to every query, unless overridden per-query. diff --git a/docs/framework/svelte/reference/interfaces/DehydrateOptions.md b/docs/framework/svelte/reference/interfaces/DehydrateOptions.md new file mode 100644 index 00000000000..e862ae88b43 --- /dev/null +++ b/docs/framework/svelte/reference/interfaces/DehydrateOptions.md @@ -0,0 +1,89 @@ +--- +id: DehydrateOptions +title: DehydrateOptions +--- + +Defined in: [packages/query-core/src/hydration.ts:42](https://github.com/TanStack/query/blob/main/packages/query-core/src/hydration.ts#L42) + +Options for `dehydrate`, controlling which queries/mutations are included in the resulting `DehydratedState` and +how their data/errors are transformed before being serialized (e.g. for embedding in server-rendered markup). + +## Properties + +### serializeData? + +```ts +optional serializeData: TransformerFn; +``` + +Defined in: [packages/query-core/src/hydration.ts:44](https://github.com/TanStack/query/blob/main/packages/query-core/src/hydration.ts#L44) + +Transforms a query's `data` before it is dehydrated. Useful for non-JSON-serializable data. + +*** + +### shouldDehydrateMutation()? + +```ts +optional shouldDehydrateMutation: (mutation) => boolean; +``` + +Defined in: [packages/query-core/src/hydration.ts:46](https://github.com/TanStack/query/blob/main/packages/query-core/src/hydration.ts#L46) + +Predicate to decide whether a given `Mutation` should be dehydrated. Defaults to `defaultShouldDehydrateMutation`. + +#### Parameters + +##### mutation + +[`Mutation`](../classes/Mutation.md) + +#### Returns + +`boolean` + +*** + +### shouldDehydrateQuery()? + +```ts +optional shouldDehydrateQuery: (query) => boolean; +``` + +Defined in: [packages/query-core/src/hydration.ts:48](https://github.com/TanStack/query/blob/main/packages/query-core/src/hydration.ts#L48) + +Predicate to decide whether a given `Query` should be dehydrated. Defaults to `defaultShouldDehydrateQuery`. + +#### Parameters + +##### query + +[`Query`](../classes/Query.md) + +#### Returns + +`boolean` + +*** + +### shouldRedactErrors()? + +```ts +optional shouldRedactErrors: (error) => boolean; +``` + +Defined in: [packages/query-core/src/hydration.ts:54](https://github.com/TanStack/query/blob/main/packages/query-core/src/hydration.ts#L54) + +Predicate to decide whether a query's error should be redacted before dehydration. Errors are redacted +(replaced with a generic `Error('redacted')`) unless this function is provided and returns `false` for the +given error, in which case the original error is kept. + +#### Parameters + +##### error + +`unknown` + +#### Returns + +`boolean` diff --git a/docs/framework/svelte/reference/interfaces/DehydratedState.md b/docs/framework/svelte/reference/interfaces/DehydratedState.md new file mode 100644 index 00000000000..be034c9e8fd --- /dev/null +++ b/docs/framework/svelte/reference/interfaces/DehydratedState.md @@ -0,0 +1,30 @@ +--- +id: DehydratedState +title: DehydratedState +--- + +Defined in: [packages/query-core/src/hydration.ts:94](https://github.com/TanStack/query/blob/main/packages/query-core/src/hydration.ts#L94) + +A serializable snapshot of a `QueryClient`'s cache, as produced by `dehydrate` and consumed by `hydrate`. Typically +transported from server to client (e.g. embedded in server-rendered markup) to seed the client's cache with data +that has already been fetched, avoiding a redundant fetch on the client. + +## Properties + +### mutations + +```ts +mutations: DehydratedMutation[]; +``` + +Defined in: [packages/query-core/src/hydration.ts:95](https://github.com/TanStack/query/blob/main/packages/query-core/src/hydration.ts#L95) + +*** + +### queries + +```ts +queries: DehydratedQuery[]; +``` + +Defined in: [packages/query-core/src/hydration.ts:96](https://github.com/TanStack/query/blob/main/packages/query-core/src/hydration.ts#L96) diff --git a/docs/framework/svelte/reference/interfaces/EnsureQueryDataOptions.md b/docs/framework/svelte/reference/interfaces/EnsureQueryDataOptions.md new file mode 100644 index 00000000000..a67082af57e --- /dev/null +++ b/docs/framework/svelte/reference/interfaces/EnsureQueryDataOptions.md @@ -0,0 +1,350 @@ +--- +id: EnsureQueryDataOptions +title: EnsureQueryDataOptions +--- + +Defined in: [packages/query-core/src/types.ts:614](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L614) + +## Deprecated + +## Extends + +- [`FetchQueryOptions`](FetchQueryOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`, `TPageParam`\> + +## Type Parameters + +### TQueryFnData + +`TQueryFnData` = `unknown` + +### TError + +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) + +### TData + +`TData` = `TQueryFnData` + +### TQueryKey + +`TQueryKey` *extends* [`QueryKey`](../type-aliases/QueryKey.md) = [`QueryKey`](../type-aliases/QueryKey.md) + +### TPageParam + +`TPageParam` = `never` + +## Properties + +### ~~gcTime?~~ + +```ts +optional gcTime: number; +``` + +Defined in: [packages/query-core/src/types.ts:277](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L277) + +The time in milliseconds that unused/inactive cache data remains in memory. +When a query's cache becomes unused or inactive, that cache data will be garbage collected after this duration. +When different garbage collection times are specified, the longest one will be used. +Setting it to `Infinity` will disable garbage collection. + +Defaults to `5 * 60 * 1000` (5 minutes), or `Infinity` during SSR. + +Note: the maximum allowed time is about 24 days, imposed by `setTimeout`'s 32-bit signed integer delay — see +`timeoutManager.setTimeoutProvider` for a workaround. + +#### Inherited from + +[`FetchQueryOptions`](FetchQueryOptions.md).[`gcTime`](FetchQueryOptions.md#gctime) + +*** + +### ~~initialData?~~ + +```ts +optional initialData: + | TData +| InitialDataFunction; +``` + +Defined in: [packages/query-core/src/types.ts:317](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L317) + +If set, this value will be used as the initial data for the query cache (as long as the query hasn't been +created or cached yet). +If set to a function, the function will be called **once** during the shared/root query initialization, and be +expected to synchronously return the initial data. +Initial data is considered stale by default unless a `staleTime` has been set. +`initialData` **is persisted** to the cache. + +#### Inherited from + +[`FetchQueryOptions`](FetchQueryOptions.md).[`initialData`](FetchQueryOptions.md#initialdata) + +*** + +### ~~initialDataUpdatedAt?~~ + +```ts +optional initialDataUpdatedAt: number | () => number | undefined; +``` + +Defined in: [packages/query-core/src/types.ts:321](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L321) + +If set, this value will be used as the time (in milliseconds) of when the `initialData` itself was last updated. + +#### Inherited from + +[`FetchQueryOptions`](FetchQueryOptions.md).[`initialDataUpdatedAt`](FetchQueryOptions.md#initialdataupdatedat) + +*** + +### ~~initialPageParam?~~ + +```ts +optional initialPageParam: undefined; +``` + +Defined in: [packages/query-core/src/types.ts:605](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L605) + +#### Inherited from + +[`FetchQueryOptions`](FetchQueryOptions.md).[`initialPageParam`](FetchQueryOptions.md#initialpageparam) + +*** + +### ~~maxPages?~~ + +```ts +optional maxPages: number; +``` + +Defined in: [packages/query-core/src/types.ts:345](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L345) + +Maximum number of pages to store in the data of an infinite query. + +#### Inherited from + +[`FetchQueryOptions`](FetchQueryOptions.md).[`maxPages`](FetchQueryOptions.md#maxpages) + +*** + +### ~~meta?~~ + +```ts +optional meta: Record; +``` + +Defined in: [packages/query-core/src/types.ts:341](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L341) + +Additional payload to be stored on each query. +Use this property to pass information that can be used in other places. + +#### Inherited from + +[`FetchQueryOptions`](FetchQueryOptions.md).[`meta`](FetchQueryOptions.md#meta) + +*** + +### ~~networkMode?~~ + +```ts +optional networkMode: NetworkMode; +``` + +Defined in: [packages/query-core/src/types.ts:265](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L265) + +Controls whether a query is allowed to run based on the current network connectivity. + +Defaults to `'online'`. + +#### See + +[Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. + +#### Inherited from + +[`FetchQueryOptions`](FetchQueryOptions.md).[`networkMode`](FetchQueryOptions.md#networkmode) + +*** + +### ~~persister?~~ + +```ts +optional persister: QueryPersister, TPageParam>; +``` + +Defined in: [packages/query-core/src/types.ts:290](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L290) + +This option can be used to persist the result of a query to an external storage, bypassing the need to actually +call the `queryFn`. Useful for persisting a query's data across e.g. server/client boundaries. + +#### Inherited from + +[`FetchQueryOptions`](FetchQueryOptions.md).[`persister`](FetchQueryOptions.md#persister) + +*** + +### ~~queryFn?~~ + +```ts +optional queryFn: + | typeof skipToken +| QueryFunction; +``` + +Defined in: [packages/query-core/src/types.ts:285](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L285) + +The function that the query will use to request data. +Required, unless a default query function has been set via `queryClient.setQueryDefaults` or +`queryClient.setDefaultOptions`. +Receives a [QueryFunctionContext](../type-aliases/QueryFunctionContext.md). +Must return a promise that will either resolve data or throw an error. The data cannot be `undefined`. + +#### Inherited from + +[`FetchQueryOptions`](FetchQueryOptions.md).[`queryFn`](FetchQueryOptions.md#queryfn) + +*** + +### ~~queryHash?~~ + +```ts +optional queryHash: string; +``` + +Defined in: [packages/query-core/src/types.ts:295](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L295) + +The hashed form of `queryKey`, computed with `queryKeyHashFn` (or the default hashing function otherwise). Used +as the actual cache key internally. + +#### Inherited from + +[`FetchQueryOptions`](FetchQueryOptions.md).[`queryHash`](FetchQueryOptions.md#queryhash) + +*** + +### ~~queryKey~~ + +```ts +queryKey: TQueryKey & object; +``` + +Defined in: [packages/query-core/src/types.ts:304](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L304) + +The query key to use for this query. + +The query key will be hashed into a stable hash. See [Query Keys](https://tanstack.com/query/latest/docs/framework/react/guides/query-keys) +for more information. + +The query will automatically update when this key changes (as long as `enabled` is not set to `false`). + +#### Inherited from + +[`FetchQueryOptions`](FetchQueryOptions.md).[`queryKey`](FetchQueryOptions.md#querykey) + +*** + +### ~~queryKeyHashFn?~~ + +```ts +optional queryKeyHashFn: QueryKeyHashFunction; +``` + +Defined in: [packages/query-core/src/types.ts:308](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L308) + +If specified, this function is used to hash the `queryKey` to a string. + +#### Inherited from + +[`FetchQueryOptions`](FetchQueryOptions.md).[`queryKeyHashFn`](FetchQueryOptions.md#querykeyhashfn) + +*** + +### ~~retry?~~ + +```ts +optional retry: RetryValue; +``` + +Defined in: [packages/query-core/src/types.ts:246](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L246) + +If `false`, failed queries will not retry by default. +If `true`, failed queries will retry infinitely. +If set to an integer number, e.g. 3, failed queries will retry until the failed query count meets that number. +If set to a function `(failureCount, error) => boolean` failed queries will retry until the function returns false. + +Defaults to `3` on the client and `0` on the server. + +#### Inherited from + +[`FetchQueryOptions`](FetchQueryOptions.md).[`retry`](FetchQueryOptions.md#retry) + +*** + +### ~~retryDelay?~~ + +```ts +optional retryDelay: RetryDelayValue; +``` + +Defined in: [packages/query-core/src/types.ts:258](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L258) + +This function receives a `retryAttempt` integer and the actual Error and returns the delay to apply before the +next attempt in milliseconds. + +A function like `attempt => Math.min(attempt > 1 ? 2 ** attempt * 1000 : 1000, 30 * 1000)` applies exponential +backoff. + +A function like `attempt => attempt * 1000` applies linear backoff. + +Defaults to a function that applies exponential backoff, capped at 30 seconds. + +#### Inherited from + +[`FetchQueryOptions`](FetchQueryOptions.md).[`retryDelay`](FetchQueryOptions.md#retrydelay) + +*** + +### ~~revalidateIfStale?~~ + +```ts +optional revalidateIfStale: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:627](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L627) + +*** + +### ~~staleTime?~~ + +```ts +optional staleTime: StaleTimeFunction; +``` + +Defined in: [packages/query-core/src/types.ts:610](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L610) + +The time in milliseconds after data is considered stale. +If the data is fresh it will be returned from the cache. + +#### Inherited from + +[`FetchQueryOptions`](FetchQueryOptions.md).[`staleTime`](FetchQueryOptions.md#staletime) + +*** + +### ~~structuralSharing?~~ + +```ts +optional structuralSharing: boolean | (oldData, newData) => unknown; +``` + +Defined in: [packages/query-core/src/types.ts:330](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L330) + +Set this to `false` to disable structural sharing between query results. +Set this to a function which accepts the old and new data and returns resolved data of the same type to implement custom structural sharing logic. + +Defaults to `true`. + +#### Inherited from + +[`FetchQueryOptions`](FetchQueryOptions.md).[`structuralSharing`](FetchQueryOptions.md#structuralsharing) diff --git a/docs/framework/svelte/reference/interfaces/FetchNextPageOptions.md b/docs/framework/svelte/reference/interfaces/FetchNextPageOptions.md new file mode 100644 index 00000000000..b79cdbe19b3 --- /dev/null +++ b/docs/framework/svelte/reference/interfaces/FetchNextPageOptions.md @@ -0,0 +1,46 @@ +--- +id: FetchNextPageOptions +title: FetchNextPageOptions +--- + +Defined in: [packages/query-core/src/types.ts:737](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L737) + +## Extends + +- [`ResultOptions`](ResultOptions.md) + +## Properties + +### cancelRefetch? + +```ts +optional cancelRefetch: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:746](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L746) + +If set to `true`, calling `fetchNextPage` repeatedly will invoke `queryFn` every time, +whether the previous invocation has resolved or not. Also, the result from previous invocations will be ignored. + +If set to `false`, calling `fetchNextPage` repeatedly won't have any effect until the first invocation has resolved. + +Defaults to `true`. + +*** + +### throwOnError? + +```ts +optional throwOnError: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:701](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L701) + +If set to `true`, the method throws if any of the underlying query refetch tasks fail. + +Defaults to `false`, in which case failed refetches are swallowed and not surfaced to the +caller. + +#### Inherited from + +[`ResultOptions`](ResultOptions.md).[`throwOnError`](ResultOptions.md#throwonerror) diff --git a/docs/framework/svelte/reference/interfaces/FetchPreviousPageOptions.md b/docs/framework/svelte/reference/interfaces/FetchPreviousPageOptions.md new file mode 100644 index 00000000000..fd5a08767b6 --- /dev/null +++ b/docs/framework/svelte/reference/interfaces/FetchPreviousPageOptions.md @@ -0,0 +1,46 @@ +--- +id: FetchPreviousPageOptions +title: FetchPreviousPageOptions +--- + +Defined in: [packages/query-core/src/types.ts:749](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L749) + +## Extends + +- [`ResultOptions`](ResultOptions.md) + +## Properties + +### cancelRefetch? + +```ts +optional cancelRefetch: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:758](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L758) + +If set to `true`, calling `fetchPreviousPage` repeatedly will invoke `queryFn` every time, +whether the previous invocation has resolved or not. Also, the result from previous invocations will be ignored. + +If set to `false`, calling `fetchPreviousPage` repeatedly won't have any effect until the first invocation has resolved. + +Defaults to `true`. + +*** + +### throwOnError? + +```ts +optional throwOnError: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:701](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L701) + +If set to `true`, the method throws if any of the underlying query refetch tasks fail. + +Defaults to `false`, in which case failed refetches are swallowed and not surfaced to the +caller. + +#### Inherited from + +[`ResultOptions`](ResultOptions.md).[`throwOnError`](ResultOptions.md#throwonerror) diff --git a/docs/framework/svelte/reference/interfaces/FetchQueryOptions.md b/docs/framework/svelte/reference/interfaces/FetchQueryOptions.md new file mode 100644 index 00000000000..b00973badc0 --- /dev/null +++ b/docs/framework/svelte/reference/interfaces/FetchQueryOptions.md @@ -0,0 +1,364 @@ +--- +id: FetchQueryOptions +title: FetchQueryOptions +--- + +Defined in: [packages/query-core/src/types.ts:595](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L595) + +## Deprecated + +## Extends + +- [`WithRequired`](../type-aliases/WithRequired.md)\<[`QueryOptions`](QueryOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`, `TPageParam`\>, `"queryKey"`\> + +## Extended by + +- [`EnsureQueryDataOptions`](EnsureQueryDataOptions.md) + +## Type Parameters + +### TQueryFnData + +`TQueryFnData` = `unknown` + +### TError + +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) + +### TData + +`TData` = `TQueryFnData` + +### TQueryKey + +`TQueryKey` *extends* [`QueryKey`](../type-aliases/QueryKey.md) = [`QueryKey`](../type-aliases/QueryKey.md) + +### TPageParam + +`TPageParam` = `never` + +## Properties + +### ~~gcTime?~~ + +```ts +optional gcTime: number; +``` + +Defined in: [packages/query-core/src/types.ts:277](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L277) + +The time in milliseconds that unused/inactive cache data remains in memory. +When a query's cache becomes unused or inactive, that cache data will be garbage collected after this duration. +When different garbage collection times are specified, the longest one will be used. +Setting it to `Infinity` will disable garbage collection. + +Defaults to `5 * 60 * 1000` (5 minutes), or `Infinity` during SSR. + +Note: the maximum allowed time is about 24 days, imposed by `setTimeout`'s 32-bit signed integer delay — see +`timeoutManager.setTimeoutProvider` for a workaround. + +#### Inherited from + +```ts +WithRequired.gcTime +``` + +*** + +### ~~initialData?~~ + +```ts +optional initialData: + | TData +| InitialDataFunction; +``` + +Defined in: [packages/query-core/src/types.ts:317](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L317) + +If set, this value will be used as the initial data for the query cache (as long as the query hasn't been +created or cached yet). +If set to a function, the function will be called **once** during the shared/root query initialization, and be +expected to synchronously return the initial data. +Initial data is considered stale by default unless a `staleTime` has been set. +`initialData` **is persisted** to the cache. + +#### Inherited from + +```ts +WithRequired.initialData +``` + +*** + +### ~~initialDataUpdatedAt?~~ + +```ts +optional initialDataUpdatedAt: number | () => number | undefined; +``` + +Defined in: [packages/query-core/src/types.ts:321](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L321) + +If set, this value will be used as the time (in milliseconds) of when the `initialData` itself was last updated. + +#### Inherited from + +```ts +WithRequired.initialDataUpdatedAt +``` + +*** + +### ~~initialPageParam?~~ + +```ts +optional initialPageParam: undefined; +``` + +Defined in: [packages/query-core/src/types.ts:605](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L605) + +*** + +### ~~maxPages?~~ + +```ts +optional maxPages: number; +``` + +Defined in: [packages/query-core/src/types.ts:345](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L345) + +Maximum number of pages to store in the data of an infinite query. + +#### Inherited from + +```ts +WithRequired.maxPages +``` + +*** + +### ~~meta?~~ + +```ts +optional meta: Record; +``` + +Defined in: [packages/query-core/src/types.ts:341](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L341) + +Additional payload to be stored on each query. +Use this property to pass information that can be used in other places. + +#### Inherited from + +```ts +WithRequired.meta +``` + +*** + +### ~~networkMode?~~ + +```ts +optional networkMode: NetworkMode; +``` + +Defined in: [packages/query-core/src/types.ts:265](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L265) + +Controls whether a query is allowed to run based on the current network connectivity. + +Defaults to `'online'`. + +#### See + +[Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. + +#### Inherited from + +```ts +WithRequired.networkMode +``` + +*** + +### ~~persister?~~ + +```ts +optional persister: QueryPersister, TPageParam>; +``` + +Defined in: [packages/query-core/src/types.ts:290](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L290) + +This option can be used to persist the result of a query to an external storage, bypassing the need to actually +call the `queryFn`. Useful for persisting a query's data across e.g. server/client boundaries. + +#### Inherited from + +```ts +WithRequired.persister +``` + +*** + +### ~~queryFn?~~ + +```ts +optional queryFn: + | typeof skipToken +| QueryFunction; +``` + +Defined in: [packages/query-core/src/types.ts:285](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L285) + +The function that the query will use to request data. +Required, unless a default query function has been set via `queryClient.setQueryDefaults` or +`queryClient.setDefaultOptions`. +Receives a [QueryFunctionContext](../type-aliases/QueryFunctionContext.md). +Must return a promise that will either resolve data or throw an error. The data cannot be `undefined`. + +#### Inherited from + +```ts +WithRequired.queryFn +``` + +*** + +### ~~queryHash?~~ + +```ts +optional queryHash: string; +``` + +Defined in: [packages/query-core/src/types.ts:295](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L295) + +The hashed form of `queryKey`, computed with `queryKeyHashFn` (or the default hashing function otherwise). Used +as the actual cache key internally. + +#### Inherited from + +```ts +WithRequired.queryHash +``` + +*** + +### ~~queryKey~~ + +```ts +queryKey: TQueryKey & object; +``` + +Defined in: [packages/query-core/src/types.ts:304](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L304) + +The query key to use for this query. + +The query key will be hashed into a stable hash. See [Query Keys](https://tanstack.com/query/latest/docs/framework/react/guides/query-keys) +for more information. + +The query will automatically update when this key changes (as long as `enabled` is not set to `false`). + +#### Inherited from + +```ts +WithRequired.queryKey +``` + +*** + +### ~~queryKeyHashFn?~~ + +```ts +optional queryKeyHashFn: QueryKeyHashFunction; +``` + +Defined in: [packages/query-core/src/types.ts:308](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L308) + +If specified, this function is used to hash the `queryKey` to a string. + +#### Inherited from + +```ts +WithRequired.queryKeyHashFn +``` + +*** + +### ~~retry?~~ + +```ts +optional retry: RetryValue; +``` + +Defined in: [packages/query-core/src/types.ts:246](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L246) + +If `false`, failed queries will not retry by default. +If `true`, failed queries will retry infinitely. +If set to an integer number, e.g. 3, failed queries will retry until the failed query count meets that number. +If set to a function `(failureCount, error) => boolean` failed queries will retry until the function returns false. + +Defaults to `3` on the client and `0` on the server. + +#### Inherited from + +```ts +WithRequired.retry +``` + +*** + +### ~~retryDelay?~~ + +```ts +optional retryDelay: RetryDelayValue; +``` + +Defined in: [packages/query-core/src/types.ts:258](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L258) + +This function receives a `retryAttempt` integer and the actual Error and returns the delay to apply before the +next attempt in milliseconds. + +A function like `attempt => Math.min(attempt > 1 ? 2 ** attempt * 1000 : 1000, 30 * 1000)` applies exponential +backoff. + +A function like `attempt => attempt * 1000` applies linear backoff. + +Defaults to a function that applies exponential backoff, capped at 30 seconds. + +#### Inherited from + +```ts +WithRequired.retryDelay +``` + +*** + +### ~~staleTime?~~ + +```ts +optional staleTime: StaleTimeFunction; +``` + +Defined in: [packages/query-core/src/types.ts:610](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L610) + +The time in milliseconds after data is considered stale. +If the data is fresh it will be returned from the cache. + +*** + +### ~~structuralSharing?~~ + +```ts +optional structuralSharing: boolean | (oldData, newData) => unknown; +``` + +Defined in: [packages/query-core/src/types.ts:330](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L330) + +Set this to `false` to disable structural sharing between query results. +Set this to a function which accepts the old and new data and returns resolved data of the same type to implement custom structural sharing logic. + +Defaults to `true`. + +#### Inherited from + +```ts +WithRequired.structuralSharing +``` diff --git a/docs/framework/svelte/reference/interfaces/FocusManager.md b/docs/framework/svelte/reference/interfaces/FocusManager.md new file mode 100644 index 00000000000..1ab81dc6357 --- /dev/null +++ b/docs/framework/svelte/reference/interfaces/FocusManager.md @@ -0,0 +1,237 @@ +--- +id: FocusManager +title: FocusManager +--- + +Defined in: [packages/query-core/src/focusManager.ts:14](https://github.com/TanStack/query/blob/main/packages/query-core/src/focusManager.ts#L14) + +The `FocusManager` manages the focus state within TanStack Query. + +It can be used to change the default event listeners or to manually change the focus state. + +## Extends + +- `Subscribable`\<`Listener`\> + +## Properties + +### listeners + +```ts +protected listeners: Set; +``` + +Defined in: [packages/query-core/src/subscribable.ts:2](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L2) + +#### Inherited from + +```ts +Subscribable.listeners +``` + +## Methods + +### hasListeners() + +```ts +hasListeners(): boolean; +``` + +Defined in: [packages/query-core/src/subscribable.ts:19](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L19) + +#### Returns + +`boolean` + +#### Inherited from + +```ts +Subscribable.hasListeners +``` + +*** + +### isFocused() + +```ts +isFocused(): boolean; +``` + +Defined in: [packages/query-core/src/focusManager.ts:128](https://github.com/TanStack/query/blob/main/packages/query-core/src/focusManager.ts#L128) + +`isFocused` can be used to get the current focus state. + +#### Returns + +`boolean` + +*** + +### onFocus() + +```ts +onFocus(): void; +``` + +Defined in: [packages/query-core/src/focusManager.ts:118](https://github.com/TanStack/query/blob/main/packages/query-core/src/focusManager.ts#L118) + +`onFocus` notifies all subscribed listeners with the current focus state. + +#### Returns + +`void` + +*** + +### onSubscribe() + +```ts +protected onSubscribe(): void; +``` + +Defined in: [packages/query-core/src/focusManager.ts:39](https://github.com/TanStack/query/blob/main/packages/query-core/src/focusManager.ts#L39) + +#### Returns + +`void` + +#### Overrides + +```ts +Subscribable.onSubscribe +``` + +*** + +### onUnsubscribe() + +```ts +protected onUnsubscribe(): void; +``` + +Defined in: [packages/query-core/src/focusManager.ts:45](https://github.com/TanStack/query/blob/main/packages/query-core/src/focusManager.ts#L45) + +#### Returns + +`void` + +#### Overrides + +```ts +Subscribable.onUnsubscribe +``` + +*** + +### setEventListener() + +```ts +setEventListener(setup): void; +``` + +Defined in: [packages/query-core/src/focusManager.ts:77](https://github.com/TanStack/query/blob/main/packages/query-core/src/focusManager.ts#L77) + +`setEventListener` can be used to set a custom event listener that will +be used to determine the focus state. The provided `setup` function +receives a `setFocused` callback: call it with a `boolean` to manually +set the focus state, or with no arguments to re-evaluate the current +focus state and notify subscribers. + +#### Parameters + +##### setup + +`SetupFn` + +#### Returns + +`void` + +#### Example + +```ts +import { focusManager } from '@tanstack/query-core' + +focusManager.setEventListener((handleFocus) => { + const listener = () => handleFocus() + // Listen to visibilitychange + if (typeof window !== 'undefined' && window.addEventListener) { + window.addEventListener('visibilitychange', listener, false) + } + + return () => { + // Be sure to unsubscribe if a new handler is set + window.removeEventListener('visibilitychange', listener) + } +}) +``` + +*** + +### setFocused() + +```ts +setFocused(focused?): void; +``` + +Defined in: [packages/query-core/src/focusManager.ts:107](https://github.com/TanStack/query/blob/main/packages/query-core/src/focusManager.ts#L107) + +`setFocused` can be used to manually set the focus state. Set `undefined` +to fall back to the default focus check. + +#### Parameters + +##### focused? + +`boolean` + +#### Returns + +`void` + +#### Example + +```ts +import { focusManager } from '@tanstack/query-core' + +// Set focused +focusManager.setFocused(true) + +// Set unfocused +focusManager.setFocused(false) + +// Fallback to the default focus check +focusManager.setFocused(undefined) +``` + +*** + +### subscribe() + +```ts +subscribe(listener): () => void; +``` + +Defined in: [packages/query-core/src/subscribable.ts:8](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L8) + +#### Parameters + +##### listener + +`Listener` + +#### Returns + +```ts +(): void; +``` + +##### Returns + +`void` + +#### Inherited from + +```ts +Subscribable.subscribe +``` diff --git a/docs/framework/svelte/reference/interfaces/HydrateOptions.md b/docs/framework/svelte/reference/interfaces/HydrateOptions.md new file mode 100644 index 00000000000..fe8b92317e3 --- /dev/null +++ b/docs/framework/svelte/reference/interfaces/HydrateOptions.md @@ -0,0 +1,43 @@ +--- +id: HydrateOptions +title: HydrateOptions +--- + +Defined in: [packages/query-core/src/hydration.ts:61](https://github.com/TanStack/query/blob/main/packages/query-core/src/hydration.ts#L61) + +Options for `hydrate`, controlling the default options applied to queries/mutations restored from a +`DehydratedState`, and how to reverse any transformation applied by `DehydrateOptions.serializeData`. + +## Properties + +### defaultOptions? + +```ts +optional defaultOptions: object; +``` + +Defined in: [packages/query-core/src/hydration.ts:62](https://github.com/TanStack/query/blob/main/packages/query-core/src/hydration.ts#L62) + +#### deserializeData? + +```ts +optional deserializeData: TransformerFn; +``` + +Transforms a query's `data` after it is read from the dehydrated state, reversing `serializeData`. + +#### mutations? + +```ts +optional mutations: MutationOptions; +``` + +Default options merged into every mutation restored from the dehydrated state. + +#### queries? + +```ts +optional queries: QueryOptions; +``` + +Default options merged into every query restored from the dehydrated state. diff --git a/docs/framework/svelte/reference/interfaces/InfiniteData.md b/docs/framework/svelte/reference/interfaces/InfiniteData.md new file mode 100644 index 00000000000..4d7ad595c2d --- /dev/null +++ b/docs/framework/svelte/reference/interfaces/InfiniteData.md @@ -0,0 +1,36 @@ +--- +id: InfiniteData +title: InfiniteData +--- + +Defined in: [packages/query-core/src/types.ts:210](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L210) + +## Type Parameters + +### TData + +`TData` + +### TPageParam + +`TPageParam` = `unknown` + +## Properties + +### pageParams + +```ts +pageParams: TPageParam[]; +``` + +Defined in: [packages/query-core/src/types.ts:212](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L212) + +*** + +### pages + +```ts +pages: TData[]; +``` + +Defined in: [packages/query-core/src/types.ts:211](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L211) diff --git a/docs/framework/svelte/reference/interfaces/InfiniteQueryObserverBaseResult.md b/docs/framework/svelte/reference/interfaces/InfiniteQueryObserverBaseResult.md new file mode 100644 index 00000000000..0aa01962aa5 --- /dev/null +++ b/docs/framework/svelte/reference/interfaces/InfiniteQueryObserverBaseResult.md @@ -0,0 +1,577 @@ +--- +id: InfiniteQueryObserverBaseResult +title: InfiniteQueryObserverBaseResult +--- + +Defined in: [packages/query-core/src/types.ts:1001](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1001) + +## Extends + +- [`QueryObserverBaseResult`](QueryObserverBaseResult.md)\<`TData`, `TError`\> + +## Extended by + +- [`InfiniteQueryObserverPendingResult`](InfiniteQueryObserverPendingResult.md) +- [`InfiniteQueryObserverLoadingResult`](InfiniteQueryObserverLoadingResult.md) +- [`InfiniteQueryObserverLoadingErrorResult`](InfiniteQueryObserverLoadingErrorResult.md) +- [`InfiniteQueryObserverRefetchErrorResult`](InfiniteQueryObserverRefetchErrorResult.md) +- [`InfiniteQueryObserverSuccessResult`](InfiniteQueryObserverSuccessResult.md) +- [`InfiniteQueryObserverPlaceholderResult`](InfiniteQueryObserverPlaceholderResult.md) + +## Type Parameters + +### TData + +`TData` = `unknown` + +### TError + +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) + +## Properties + +### data + +```ts +data: TData | undefined; +``` + +Defined in: [packages/query-core/src/types.ts:771](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L771) + +The last successfully resolved data for the query. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`data`](QueryObserverBaseResult.md#data) + +*** + +### dataUpdatedAt + +```ts +dataUpdatedAt: number; +``` + +Defined in: [packages/query-core/src/types.ts:775](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L775) + +The timestamp for when the query most recently returned the `status` as `"success"`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`dataUpdatedAt`](QueryObserverBaseResult.md#dataupdatedat) + +*** + +### error + +```ts +error: TError | null; +``` + +Defined in: [packages/query-core/src/types.ts:780](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L780) + +The error object for the query, if an error was thrown. +- Defaults to `null`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`error`](QueryObserverBaseResult.md#error) + +*** + +### errorUpdateCount + +```ts +errorUpdateCount: number; +``` + +Defined in: [packages/query-core/src/types.ts:799](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L799) + +The sum of all errors. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`errorUpdateCount`](QueryObserverBaseResult.md#errorupdatecount) + +*** + +### errorUpdatedAt + +```ts +errorUpdatedAt: number; +``` + +Defined in: [packages/query-core/src/types.ts:784](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L784) + +The timestamp for when the query most recently returned the `status` as `"error"`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`errorUpdatedAt`](QueryObserverBaseResult.md#errorupdatedat) + +*** + +### failureCount + +```ts +failureCount: number; +``` + +Defined in: [packages/query-core/src/types.ts:790](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L790) + +The failure count for the query. +- Incremented every time the query fails. +- Reset to `0` when the query succeeds. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`failureCount`](QueryObserverBaseResult.md#failurecount) + +*** + +### failureReason + +```ts +failureReason: TError | null; +``` + +Defined in: [packages/query-core/src/types.ts:795](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L795) + +The failure reason for the query retry. +- Reset to `null` when the query succeeds. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`failureReason`](QueryObserverBaseResult.md#failurereason) + +*** + +### fetchNextPage() + +```ts +fetchNextPage: (options?) => Promise>; +``` + +Defined in: [packages/query-core/src/types.ts:1008](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1008) + +This function allows you to fetch the next "page" of results. + +#### Parameters + +##### options? + +[`FetchNextPageOptions`](FetchNextPageOptions.md) + +#### Returns + +`Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> + +*** + +### fetchPreviousPage() + +```ts +fetchPreviousPage: (options?) => Promise>; +``` + +Defined in: [packages/query-core/src/types.ts:1014](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1014) + +This function allows you to fetch the previous "page" of results. + +#### Parameters + +##### options? + +[`FetchPreviousPageOptions`](FetchPreviousPageOptions.md) + +#### Returns + +`Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> + +*** + +### fetchStatus + +```ts +fetchStatus: FetchStatus; +``` + +Defined in: [packages/query-core/src/types.ts:889](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L889) + +The fetch status of the query. +- `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. +- `paused`: The query wanted to fetch, but has been `paused`. +- `idle`: The query is not fetching. +- See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`fetchStatus`](QueryObserverBaseResult.md#fetchstatus) + +*** + +### hasNextPage + +```ts +hasNextPage: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1020](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1020) + +Will be `true` if there is a next page to be fetched (known via the `getNextPageParam` option). + +*** + +### hasPreviousPage + +```ts +hasPreviousPage: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1024](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1024) + +Will be `true` if there is a previous page to be fetched (known via the `getPreviousPageParam` option). + +*** + +### isEnabled + +```ts +isEnabled: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:867](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L867) + +`true` if this observer is enabled, `false` otherwise. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isEnabled`](QueryObserverBaseResult.md#isenabled) + +*** + +### isError + +```ts +isError: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:804](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L804) + +A derived boolean from the `status` variable, provided for convenience. +- `true` if the query attempt resulted in an error. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isError`](QueryObserverBaseResult.md#iserror) + +*** + +### isFetched + +```ts +isFetched: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:808](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L808) + +Will be `true` if the query has been fetched. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isFetched`](QueryObserverBaseResult.md#isfetched) + +*** + +### isFetchedAfterMount + +```ts +isFetchedAfterMount: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:813](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L813) + +Will be `true` if the query has been fetched after the component mounted. +- This property can be used to not show any previously cached data. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isFetchedAfterMount`](QueryObserverBaseResult.md#isfetchedaftermount) + +*** + +### isFetching + +```ts +isFetching: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:818](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L818) + +A derived boolean from the `fetchStatus` variable, provided for convenience. +- `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isFetching`](QueryObserverBaseResult.md#isfetching) + +*** + +### isFetchingNextPage + +```ts +isFetchingNextPage: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1032](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1032) + +Will be `true` while fetching the next page with `fetchNextPage`. + +*** + +### isFetchingPreviousPage + +```ts +isFetchingPreviousPage: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1040](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1040) + +Will be `true` while fetching the previous page with `fetchPreviousPage`. + +*** + +### isFetchNextPageError + +```ts +isFetchNextPageError: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1028](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1028) + +Will be `true` if the query failed while fetching the next page. + +*** + +### isFetchPreviousPageError + +```ts +isFetchPreviousPageError: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1036](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1036) + +Will be `true` if the query failed while fetching the previous page. + +*** + +### ~~isInitialLoading~~ + +```ts +isInitialLoading: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:836](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L836) + +#### Deprecated + +`isInitialLoading` is being deprecated in favor of `isLoading` +and will be removed in the next major version. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isInitialLoading`](QueryObserverBaseResult.md#isinitialloading) + +*** + +### isLoading + +```ts +isLoading: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:823](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L823) + +Is `true` whenever the first fetch for a query is in-flight. +- Is the same as `isFetching && isPending`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoading`](QueryObserverBaseResult.md#isloading) + +*** + +### isLoadingError + +```ts +isLoadingError: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:831](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L831) + +Will be `true` if the query failed while fetching for the first time. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoadingError`](QueryObserverBaseResult.md#isloadingerror) + +*** + +### isPaused + +```ts +isPaused: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:841](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L841) + +A derived boolean from the `fetchStatus` variable, provided for convenience. +- The query wanted to fetch, but has been `paused`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPaused`](QueryObserverBaseResult.md#ispaused) + +*** + +### isPending + +```ts +isPending: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:827](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L827) + +Will be `pending` if there's no cached data and no query attempt was finished yet. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPending`](QueryObserverBaseResult.md#ispending) + +*** + +### isPlaceholderData + +```ts +isPlaceholderData: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:845](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L845) + +Will be `true` if the data shown is the placeholder data. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPlaceholderData`](QueryObserverBaseResult.md#isplaceholderdata) + +*** + +### isRefetchError + +```ts +isRefetchError: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:849](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L849) + +Will be `true` if the query failed while refetching. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetchError`](QueryObserverBaseResult.md#isrefetcherror) + +*** + +### isRefetching + +```ts +isRefetching: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:854](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L854) + +Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. +- Is the same as `isFetching && !isPending`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetching`](QueryObserverBaseResult.md#isrefetching) + +*** + +### isStale + +```ts +isStale: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:858](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L858) + +Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isStale`](QueryObserverBaseResult.md#isstale) + +*** + +### isSuccess + +```ts +isSuccess: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:863](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L863) + +A derived boolean from the `status` variable, provided for convenience. +- `true` if the query has received a response with no errors and is ready to display its data. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isSuccess`](QueryObserverBaseResult.md#issuccess) + +*** + +### refetch() + +```ts +refetch: (options?) => Promise>; +``` + +Defined in: [packages/query-core/src/types.ts:871](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L871) + +A function to manually refetch the query. + +#### Parameters + +##### options? + +[`RefetchOptions`](RefetchOptions.md) + +#### Returns + +`Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`refetch`](QueryObserverBaseResult.md#refetch) + +*** + +### status + +```ts +status: QueryStatus; +``` + +Defined in: [packages/query-core/src/types.ts:881](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L881) + +The status of the query. +- Will be: + - `pending` if there's no cached data and no query attempt was finished yet. + - `error` if the query attempt resulted in an error. + - `success` if the query has received a response with no errors and is ready to display its data. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`status`](QueryObserverBaseResult.md#status) diff --git a/docs/framework/svelte/reference/interfaces/InfiniteQueryObserverLoadingErrorResult.md b/docs/framework/svelte/reference/interfaces/InfiniteQueryObserverLoadingErrorResult.md new file mode 100644 index 00000000000..f5e3352f27c --- /dev/null +++ b/docs/framework/svelte/reference/interfaces/InfiniteQueryObserverLoadingErrorResult.md @@ -0,0 +1,600 @@ +--- +id: InfiniteQueryObserverLoadingErrorResult +title: InfiniteQueryObserverLoadingErrorResult +--- + +Defined in: [packages/query-core/src/types.ts:1078](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1078) + +## Extends + +- [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md)\<`TData`, `TError`\> + +## Type Parameters + +### TData + +`TData` = `unknown` + +### TError + +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) + +## Properties + +### data + +```ts +data: undefined; +``` + +Defined in: [packages/query-core/src/types.ts:1082](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1082) + +The last successfully resolved data for the query. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`data`](InfiniteQueryObserverBaseResult.md#data) + +*** + +### dataUpdatedAt + +```ts +dataUpdatedAt: number; +``` + +Defined in: [packages/query-core/src/types.ts:775](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L775) + +The timestamp for when the query most recently returned the `status` as `"success"`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`dataUpdatedAt`](InfiniteQueryObserverBaseResult.md#dataupdatedat) + +*** + +### error + +```ts +error: TError; +``` + +Defined in: [packages/query-core/src/types.ts:1083](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1083) + +The error object for the query, if an error was thrown. +- Defaults to `null`. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`error`](InfiniteQueryObserverBaseResult.md#error) + +*** + +### errorUpdateCount + +```ts +errorUpdateCount: number; +``` + +Defined in: [packages/query-core/src/types.ts:799](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L799) + +The sum of all errors. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`errorUpdateCount`](InfiniteQueryObserverBaseResult.md#errorupdatecount) + +*** + +### errorUpdatedAt + +```ts +errorUpdatedAt: number; +``` + +Defined in: [packages/query-core/src/types.ts:784](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L784) + +The timestamp for when the query most recently returned the `status` as `"error"`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`errorUpdatedAt`](InfiniteQueryObserverBaseResult.md#errorupdatedat) + +*** + +### failureCount + +```ts +failureCount: number; +``` + +Defined in: [packages/query-core/src/types.ts:790](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L790) + +The failure count for the query. +- Incremented every time the query fails. +- Reset to `0` when the query succeeds. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`failureCount`](InfiniteQueryObserverBaseResult.md#failurecount) + +*** + +### failureReason + +```ts +failureReason: TError | null; +``` + +Defined in: [packages/query-core/src/types.ts:795](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L795) + +The failure reason for the query retry. +- Reset to `null` when the query succeeds. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`failureReason`](InfiniteQueryObserverBaseResult.md#failurereason) + +*** + +### fetchNextPage() + +```ts +fetchNextPage: (options?) => Promise>; +``` + +Defined in: [packages/query-core/src/types.ts:1008](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1008) + +This function allows you to fetch the next "page" of results. + +#### Parameters + +##### options? + +[`FetchNextPageOptions`](FetchNextPageOptions.md) + +#### Returns + +`Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`fetchNextPage`](InfiniteQueryObserverBaseResult.md#fetchnextpage) + +*** + +### fetchPreviousPage() + +```ts +fetchPreviousPage: (options?) => Promise>; +``` + +Defined in: [packages/query-core/src/types.ts:1014](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1014) + +This function allows you to fetch the previous "page" of results. + +#### Parameters + +##### options? + +[`FetchPreviousPageOptions`](FetchPreviousPageOptions.md) + +#### Returns + +`Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`fetchPreviousPage`](InfiniteQueryObserverBaseResult.md#fetchpreviouspage) + +*** + +### fetchStatus + +```ts +fetchStatus: FetchStatus; +``` + +Defined in: [packages/query-core/src/types.ts:889](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L889) + +The fetch status of the query. +- `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. +- `paused`: The query wanted to fetch, but has been `paused`. +- `idle`: The query is not fetching. +- See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`fetchStatus`](InfiniteQueryObserverBaseResult.md#fetchstatus) + +*** + +### hasNextPage + +```ts +hasNextPage: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1020](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1020) + +Will be `true` if there is a next page to be fetched (known via the `getNextPageParam` option). + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`hasNextPage`](InfiniteQueryObserverBaseResult.md#hasnextpage) + +*** + +### hasPreviousPage + +```ts +hasPreviousPage: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1024](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1024) + +Will be `true` if there is a previous page to be fetched (known via the `getPreviousPageParam` option). + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`hasPreviousPage`](InfiniteQueryObserverBaseResult.md#haspreviouspage) + +*** + +### isEnabled + +```ts +isEnabled: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:867](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L867) + +`true` if this observer is enabled, `false` otherwise. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isEnabled`](InfiniteQueryObserverBaseResult.md#isenabled) + +*** + +### isError + +```ts +isError: true; +``` + +Defined in: [packages/query-core/src/types.ts:1084](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1084) + +A derived boolean from the `status` variable, provided for convenience. +- `true` if the query attempt resulted in an error. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isError`](InfiniteQueryObserverBaseResult.md#iserror) + +*** + +### isFetched + +```ts +isFetched: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:808](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L808) + +Will be `true` if the query has been fetched. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetched`](InfiniteQueryObserverBaseResult.md#isfetched) + +*** + +### isFetchedAfterMount + +```ts +isFetchedAfterMount: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:813](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L813) + +Will be `true` if the query has been fetched after the component mounted. +- This property can be used to not show any previously cached data. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchedAfterMount`](InfiniteQueryObserverBaseResult.md#isfetchedaftermount) + +*** + +### isFetching + +```ts +isFetching: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:818](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L818) + +A derived boolean from the `fetchStatus` variable, provided for convenience. +- `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetching`](InfiniteQueryObserverBaseResult.md#isfetching) + +*** + +### isFetchingNextPage + +```ts +isFetchingNextPage: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1032](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1032) + +Will be `true` while fetching the next page with `fetchNextPage`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchingNextPage`](InfiniteQueryObserverBaseResult.md#isfetchingnextpage) + +*** + +### isFetchingPreviousPage + +```ts +isFetchingPreviousPage: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1040](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1040) + +Will be `true` while fetching the previous page with `fetchPreviousPage`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchingPreviousPage`](InfiniteQueryObserverBaseResult.md#isfetchingpreviouspage) + +*** + +### isFetchNextPageError + +```ts +isFetchNextPageError: false; +``` + +Defined in: [packages/query-core/src/types.ts:1089](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1089) + +Will be `true` if the query failed while fetching the next page. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchNextPageError`](InfiniteQueryObserverBaseResult.md#isfetchnextpageerror) + +*** + +### isFetchPreviousPageError + +```ts +isFetchPreviousPageError: false; +``` + +Defined in: [packages/query-core/src/types.ts:1090](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1090) + +Will be `true` if the query failed while fetching the previous page. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchPreviousPageError`](InfiniteQueryObserverBaseResult.md#isfetchpreviouspageerror) + +*** + +### ~~isInitialLoading~~ + +```ts +isInitialLoading: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:836](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L836) + +#### Deprecated + +`isInitialLoading` is being deprecated in favor of `isLoading` +and will be removed in the next major version. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isInitialLoading`](InfiniteQueryObserverBaseResult.md#isinitialloading) + +*** + +### isLoading + +```ts +isLoading: false; +``` + +Defined in: [packages/query-core/src/types.ts:1086](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1086) + +Is `true` whenever the first fetch for a query is in-flight. +- Is the same as `isFetching && isPending`. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoading`](InfiniteQueryObserverBaseResult.md#isloading) + +*** + +### isLoadingError + +```ts +isLoadingError: true; +``` + +Defined in: [packages/query-core/src/types.ts:1087](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1087) + +Will be `true` if the query failed while fetching for the first time. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoadingError`](InfiniteQueryObserverBaseResult.md#isloadingerror) + +*** + +### isPaused + +```ts +isPaused: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:841](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L841) + +A derived boolean from the `fetchStatus` variable, provided for convenience. +- The query wanted to fetch, but has been `paused`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPaused`](InfiniteQueryObserverBaseResult.md#ispaused) + +*** + +### isPending + +```ts +isPending: false; +``` + +Defined in: [packages/query-core/src/types.ts:1085](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1085) + +Will be `pending` if there's no cached data and no query attempt was finished yet. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPending`](InfiniteQueryObserverBaseResult.md#ispending) + +*** + +### isPlaceholderData + +```ts +isPlaceholderData: false; +``` + +Defined in: [packages/query-core/src/types.ts:1092](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1092) + +Will be `true` if the data shown is the placeholder data. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPlaceholderData`](InfiniteQueryObserverBaseResult.md#isplaceholderdata) + +*** + +### isRefetchError + +```ts +isRefetchError: false; +``` + +Defined in: [packages/query-core/src/types.ts:1088](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1088) + +Will be `true` if the query failed while refetching. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isRefetchError`](InfiniteQueryObserverBaseResult.md#isrefetcherror) + +*** + +### isRefetching + +```ts +isRefetching: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:854](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L854) + +Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. +- Is the same as `isFetching && !isPending`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isRefetching`](InfiniteQueryObserverBaseResult.md#isrefetching) + +*** + +### isStale + +```ts +isStale: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:858](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L858) + +Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isStale`](InfiniteQueryObserverBaseResult.md#isstale) + +*** + +### isSuccess + +```ts +isSuccess: false; +``` + +Defined in: [packages/query-core/src/types.ts:1091](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1091) + +A derived boolean from the `status` variable, provided for convenience. +- `true` if the query has received a response with no errors and is ready to display its data. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isSuccess`](InfiniteQueryObserverBaseResult.md#issuccess) + +*** + +### refetch() + +```ts +refetch: (options?) => Promise>; +``` + +Defined in: [packages/query-core/src/types.ts:871](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L871) + +A function to manually refetch the query. + +#### Parameters + +##### options? + +[`RefetchOptions`](RefetchOptions.md) + +#### Returns + +`Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`refetch`](InfiniteQueryObserverBaseResult.md#refetch) + +*** + +### status + +```ts +status: "error"; +``` + +Defined in: [packages/query-core/src/types.ts:1093](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1093) + +The status of the query. +- Will be: + - `pending` if there's no cached data and no query attempt was finished yet. + - `error` if the query attempt resulted in an error. + - `success` if the query has received a response with no errors and is ready to display its data. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`status`](InfiniteQueryObserverBaseResult.md#status) diff --git a/docs/framework/svelte/reference/interfaces/InfiniteQueryObserverLoadingResult.md b/docs/framework/svelte/reference/interfaces/InfiniteQueryObserverLoadingResult.md new file mode 100644 index 00000000000..b7aa67744c0 --- /dev/null +++ b/docs/framework/svelte/reference/interfaces/InfiniteQueryObserverLoadingResult.md @@ -0,0 +1,600 @@ +--- +id: InfiniteQueryObserverLoadingResult +title: InfiniteQueryObserverLoadingResult +--- + +Defined in: [packages/query-core/src/types.ts:1060](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1060) + +## Extends + +- [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md)\<`TData`, `TError`\> + +## Type Parameters + +### TData + +`TData` = `unknown` + +### TError + +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) + +## Properties + +### data + +```ts +data: undefined; +``` + +Defined in: [packages/query-core/src/types.ts:1064](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1064) + +The last successfully resolved data for the query. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`data`](InfiniteQueryObserverBaseResult.md#data) + +*** + +### dataUpdatedAt + +```ts +dataUpdatedAt: number; +``` + +Defined in: [packages/query-core/src/types.ts:775](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L775) + +The timestamp for when the query most recently returned the `status` as `"success"`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`dataUpdatedAt`](InfiniteQueryObserverBaseResult.md#dataupdatedat) + +*** + +### error + +```ts +error: null; +``` + +Defined in: [packages/query-core/src/types.ts:1065](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1065) + +The error object for the query, if an error was thrown. +- Defaults to `null`. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`error`](InfiniteQueryObserverBaseResult.md#error) + +*** + +### errorUpdateCount + +```ts +errorUpdateCount: number; +``` + +Defined in: [packages/query-core/src/types.ts:799](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L799) + +The sum of all errors. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`errorUpdateCount`](InfiniteQueryObserverBaseResult.md#errorupdatecount) + +*** + +### errorUpdatedAt + +```ts +errorUpdatedAt: number; +``` + +Defined in: [packages/query-core/src/types.ts:784](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L784) + +The timestamp for when the query most recently returned the `status` as `"error"`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`errorUpdatedAt`](InfiniteQueryObserverBaseResult.md#errorupdatedat) + +*** + +### failureCount + +```ts +failureCount: number; +``` + +Defined in: [packages/query-core/src/types.ts:790](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L790) + +The failure count for the query. +- Incremented every time the query fails. +- Reset to `0` when the query succeeds. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`failureCount`](InfiniteQueryObserverBaseResult.md#failurecount) + +*** + +### failureReason + +```ts +failureReason: TError | null; +``` + +Defined in: [packages/query-core/src/types.ts:795](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L795) + +The failure reason for the query retry. +- Reset to `null` when the query succeeds. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`failureReason`](InfiniteQueryObserverBaseResult.md#failurereason) + +*** + +### fetchNextPage() + +```ts +fetchNextPage: (options?) => Promise>; +``` + +Defined in: [packages/query-core/src/types.ts:1008](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1008) + +This function allows you to fetch the next "page" of results. + +#### Parameters + +##### options? + +[`FetchNextPageOptions`](FetchNextPageOptions.md) + +#### Returns + +`Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`fetchNextPage`](InfiniteQueryObserverBaseResult.md#fetchnextpage) + +*** + +### fetchPreviousPage() + +```ts +fetchPreviousPage: (options?) => Promise>; +``` + +Defined in: [packages/query-core/src/types.ts:1014](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1014) + +This function allows you to fetch the previous "page" of results. + +#### Parameters + +##### options? + +[`FetchPreviousPageOptions`](FetchPreviousPageOptions.md) + +#### Returns + +`Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`fetchPreviousPage`](InfiniteQueryObserverBaseResult.md#fetchpreviouspage) + +*** + +### fetchStatus + +```ts +fetchStatus: FetchStatus; +``` + +Defined in: [packages/query-core/src/types.ts:889](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L889) + +The fetch status of the query. +- `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. +- `paused`: The query wanted to fetch, but has been `paused`. +- `idle`: The query is not fetching. +- See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`fetchStatus`](InfiniteQueryObserverBaseResult.md#fetchstatus) + +*** + +### hasNextPage + +```ts +hasNextPage: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1020](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1020) + +Will be `true` if there is a next page to be fetched (known via the `getNextPageParam` option). + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`hasNextPage`](InfiniteQueryObserverBaseResult.md#hasnextpage) + +*** + +### hasPreviousPage + +```ts +hasPreviousPage: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1024](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1024) + +Will be `true` if there is a previous page to be fetched (known via the `getPreviousPageParam` option). + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`hasPreviousPage`](InfiniteQueryObserverBaseResult.md#haspreviouspage) + +*** + +### isEnabled + +```ts +isEnabled: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:867](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L867) + +`true` if this observer is enabled, `false` otherwise. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isEnabled`](InfiniteQueryObserverBaseResult.md#isenabled) + +*** + +### isError + +```ts +isError: false; +``` + +Defined in: [packages/query-core/src/types.ts:1066](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1066) + +A derived boolean from the `status` variable, provided for convenience. +- `true` if the query attempt resulted in an error. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isError`](InfiniteQueryObserverBaseResult.md#iserror) + +*** + +### isFetched + +```ts +isFetched: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:808](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L808) + +Will be `true` if the query has been fetched. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetched`](InfiniteQueryObserverBaseResult.md#isfetched) + +*** + +### isFetchedAfterMount + +```ts +isFetchedAfterMount: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:813](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L813) + +Will be `true` if the query has been fetched after the component mounted. +- This property can be used to not show any previously cached data. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchedAfterMount`](InfiniteQueryObserverBaseResult.md#isfetchedaftermount) + +*** + +### isFetching + +```ts +isFetching: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:818](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L818) + +A derived boolean from the `fetchStatus` variable, provided for convenience. +- `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetching`](InfiniteQueryObserverBaseResult.md#isfetching) + +*** + +### isFetchingNextPage + +```ts +isFetchingNextPage: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1032](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1032) + +Will be `true` while fetching the next page with `fetchNextPage`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchingNextPage`](InfiniteQueryObserverBaseResult.md#isfetchingnextpage) + +*** + +### isFetchingPreviousPage + +```ts +isFetchingPreviousPage: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1040](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1040) + +Will be `true` while fetching the previous page with `fetchPreviousPage`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchingPreviousPage`](InfiniteQueryObserverBaseResult.md#isfetchingpreviouspage) + +*** + +### isFetchNextPageError + +```ts +isFetchNextPageError: false; +``` + +Defined in: [packages/query-core/src/types.ts:1071](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1071) + +Will be `true` if the query failed while fetching the next page. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchNextPageError`](InfiniteQueryObserverBaseResult.md#isfetchnextpageerror) + +*** + +### isFetchPreviousPageError + +```ts +isFetchPreviousPageError: false; +``` + +Defined in: [packages/query-core/src/types.ts:1072](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1072) + +Will be `true` if the query failed while fetching the previous page. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchPreviousPageError`](InfiniteQueryObserverBaseResult.md#isfetchpreviouspageerror) + +*** + +### ~~isInitialLoading~~ + +```ts +isInitialLoading: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:836](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L836) + +#### Deprecated + +`isInitialLoading` is being deprecated in favor of `isLoading` +and will be removed in the next major version. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isInitialLoading`](InfiniteQueryObserverBaseResult.md#isinitialloading) + +*** + +### isLoading + +```ts +isLoading: true; +``` + +Defined in: [packages/query-core/src/types.ts:1068](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1068) + +Is `true` whenever the first fetch for a query is in-flight. +- Is the same as `isFetching && isPending`. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoading`](InfiniteQueryObserverBaseResult.md#isloading) + +*** + +### isLoadingError + +```ts +isLoadingError: false; +``` + +Defined in: [packages/query-core/src/types.ts:1069](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1069) + +Will be `true` if the query failed while fetching for the first time. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoadingError`](InfiniteQueryObserverBaseResult.md#isloadingerror) + +*** + +### isPaused + +```ts +isPaused: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:841](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L841) + +A derived boolean from the `fetchStatus` variable, provided for convenience. +- The query wanted to fetch, but has been `paused`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPaused`](InfiniteQueryObserverBaseResult.md#ispaused) + +*** + +### isPending + +```ts +isPending: true; +``` + +Defined in: [packages/query-core/src/types.ts:1067](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1067) + +Will be `pending` if there's no cached data and no query attempt was finished yet. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPending`](InfiniteQueryObserverBaseResult.md#ispending) + +*** + +### isPlaceholderData + +```ts +isPlaceholderData: false; +``` + +Defined in: [packages/query-core/src/types.ts:1074](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1074) + +Will be `true` if the data shown is the placeholder data. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPlaceholderData`](InfiniteQueryObserverBaseResult.md#isplaceholderdata) + +*** + +### isRefetchError + +```ts +isRefetchError: false; +``` + +Defined in: [packages/query-core/src/types.ts:1070](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1070) + +Will be `true` if the query failed while refetching. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isRefetchError`](InfiniteQueryObserverBaseResult.md#isrefetcherror) + +*** + +### isRefetching + +```ts +isRefetching: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:854](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L854) + +Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. +- Is the same as `isFetching && !isPending`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isRefetching`](InfiniteQueryObserverBaseResult.md#isrefetching) + +*** + +### isStale + +```ts +isStale: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:858](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L858) + +Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isStale`](InfiniteQueryObserverBaseResult.md#isstale) + +*** + +### isSuccess + +```ts +isSuccess: false; +``` + +Defined in: [packages/query-core/src/types.ts:1073](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1073) + +A derived boolean from the `status` variable, provided for convenience. +- `true` if the query has received a response with no errors and is ready to display its data. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isSuccess`](InfiniteQueryObserverBaseResult.md#issuccess) + +*** + +### refetch() + +```ts +refetch: (options?) => Promise>; +``` + +Defined in: [packages/query-core/src/types.ts:871](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L871) + +A function to manually refetch the query. + +#### Parameters + +##### options? + +[`RefetchOptions`](RefetchOptions.md) + +#### Returns + +`Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`refetch`](InfiniteQueryObserverBaseResult.md#refetch) + +*** + +### status + +```ts +status: "pending"; +``` + +Defined in: [packages/query-core/src/types.ts:1075](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1075) + +The status of the query. +- Will be: + - `pending` if there's no cached data and no query attempt was finished yet. + - `error` if the query attempt resulted in an error. + - `success` if the query has received a response with no errors and is ready to display its data. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`status`](InfiniteQueryObserverBaseResult.md#status) diff --git a/docs/framework/svelte/reference/interfaces/InfiniteQueryObserverOptions.md b/docs/framework/svelte/reference/interfaces/InfiniteQueryObserverOptions.md new file mode 100644 index 00000000000..7670bd8e24b --- /dev/null +++ b/docs/framework/svelte/reference/interfaces/InfiniteQueryObserverOptions.md @@ -0,0 +1,624 @@ +--- +id: InfiniteQueryObserverOptions +title: InfiniteQueryObserverOptions +--- + +Defined in: [packages/query-core/src/types.ts:539](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L539) + +## Extends + +- [`QueryObserverOptions`](QueryObserverOptions.md)\<`TQueryFnData`, `TError`, `TData`, [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`, `TPageParam`\>.[`InfiniteQueryPageParamsOptions`](InfiniteQueryPageParamsOptions.md)\<`TQueryFnData`, `TPageParam`\> + +## Type Parameters + +### TQueryFnData + +`TQueryFnData` = `unknown` + +### TError + +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) + +### TData + +`TData` = `TQueryFnData` + +### TQueryKey + +`TQueryKey` *extends* [`QueryKey`](../type-aliases/QueryKey.md) = [`QueryKey`](../type-aliases/QueryKey.md) + +### TPageParam + +`TPageParam` = `unknown` + +## Properties + +### enabled? + +```ts +optional enabled: QueryBooleanOption, TQueryKey>; +``` + +Defined in: [packages/query-core/src/types.ts:398](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L398) + +Set this to `false` or a function that returns `false` to disable automatic refetching when the query mounts or changes query keys. +To refetch the query, use the `refetch` method returned from the `useQuery` instance. +Accepts a boolean or function that returns a boolean. + +Defaults to `true`. + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`enabled`](QueryObserverOptions.md#enabled) + +*** + +### gcTime? + +```ts +optional gcTime: number; +``` + +Defined in: [packages/query-core/src/types.ts:277](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L277) + +The time in milliseconds that unused/inactive cache data remains in memory. +When a query's cache becomes unused or inactive, that cache data will be garbage collected after this duration. +When different garbage collection times are specified, the longest one will be used. +Setting it to `Infinity` will disable garbage collection. + +Defaults to `5 * 60 * 1000` (5 minutes), or `Infinity` during SSR. + +Note: the maximum allowed time is about 24 days, imposed by `setTimeout`'s 32-bit signed integer delay — see +`timeoutManager.setTimeoutProvider` for a workaround. + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`gcTime`](QueryObserverOptions.md#gctime) + +*** + +### getNextPageParam + +```ts +getNextPageParam: GetNextPageParamFunction; +``` + +Defined in: [packages/query-core/src/types.ts:365](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L365) + +This function can be set to automatically get the next cursor for infinite queries. +The result will also be used to determine the value of `hasNextPage`. + +#### Inherited from + +[`InfiniteQueryPageParamsOptions`](InfiniteQueryPageParamsOptions.md).[`getNextPageParam`](InfiniteQueryPageParamsOptions.md#getnextpageparam) + +*** + +### getPreviousPageParam? + +```ts +optional getPreviousPageParam: GetPreviousPageParamFunction; +``` + +Defined in: [packages/query-core/src/types.ts:360](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L360) + +This function can be set to automatically get the previous cursor for infinite queries. +The result will also be used to determine the value of `hasPreviousPage`. + +#### Inherited from + +[`InfiniteQueryPageParamsOptions`](InfiniteQueryPageParamsOptions.md).[`getPreviousPageParam`](InfiniteQueryPageParamsOptions.md#getpreviouspageparam) + +*** + +### initialData? + +```ts +optional initialData: + | InfiniteData +| InitialDataFunction>; +``` + +Defined in: [packages/query-core/src/types.ts:317](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L317) + +If set, this value will be used as the initial data for the query cache (as long as the query hasn't been +created or cached yet). +If set to a function, the function will be called **once** during the shared/root query initialization, and be +expected to synchronously return the initial data. +Initial data is considered stale by default unless a `staleTime` has been set. +`initialData` **is persisted** to the cache. + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`initialData`](QueryObserverOptions.md#initialdata) + +*** + +### initialDataUpdatedAt? + +```ts +optional initialDataUpdatedAt: number | () => number | undefined; +``` + +Defined in: [packages/query-core/src/types.ts:321](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L321) + +If set, this value will be used as the time (in milliseconds) of when the `initialData` itself was last updated. + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`initialDataUpdatedAt`](QueryObserverOptions.md#initialdataupdatedat) + +*** + +### initialPageParam + +```ts +initialPageParam: TPageParam; +``` + +Defined in: [packages/query-core/src/types.ts:349](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L349) + +#### Inherited from + +[`InfiniteQueryPageParamsOptions`](InfiniteQueryPageParamsOptions.md).[`initialPageParam`](InfiniteQueryPageParamsOptions.md#initialpageparam) + +*** + +### maxPages? + +```ts +optional maxPages: number; +``` + +Defined in: [packages/query-core/src/types.ts:345](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L345) + +Maximum number of pages to store in the data of an infinite query. + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`maxPages`](QueryObserverOptions.md#maxpages) + +*** + +### meta? + +```ts +optional meta: Record; +``` + +Defined in: [packages/query-core/src/types.ts:341](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L341) + +Additional payload to be stored on each query. +Use this property to pass information that can be used in other places. + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`meta`](QueryObserverOptions.md#meta) + +*** + +### networkMode? + +```ts +optional networkMode: NetworkMode; +``` + +Defined in: [packages/query-core/src/types.ts:265](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L265) + +Controls whether a query is allowed to run based on the current network connectivity. + +Defaults to `'online'`. + +#### See + +[Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`networkMode`](QueryObserverOptions.md#networkmode) + +*** + +### notifyOnChangeProps? + +```ts +optional notifyOnChangeProps: NotifyOnChangeProps; +``` + +Defined in: [packages/query-core/src/types.ts:484](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L484) + +If set, the component will only re-render if any of the listed properties change. +When set to `['data', 'error']`, the component will only re-render when the `data` or `error` properties change. +When set to `'all'`, the component will re-render whenever a query is updated. +When set to a function, the function will be executed to compute the list of properties. + +Defaults to `undefined`, in which case property access is tracked automatically, and the +component only re-renders when one of the tracked properties changes. + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`notifyOnChangeProps`](QueryObserverOptions.md#notifyonchangeprops) + +*** + +### persister? + +```ts +optional persister: QueryPersister, TPageParam>; +``` + +Defined in: [packages/query-core/src/types.ts:290](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L290) + +This option can be used to persist the result of a query to an external storage, bypassing the need to actually +call the `queryFn`. Useful for persisting a query's data across e.g. server/client boundaries. + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`persister`](QueryObserverOptions.md#persister) + +*** + +### placeholderData? + +```ts +optional placeholderData: + | InfiniteData +| PlaceholderDataFunction, TError, InfiniteData, TQueryKey>; +``` + +Defined in: [packages/query-core/src/types.ts:511](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L511) + +If set, this value will be used as the placeholder data for this particular query observer while the query is still in the `loading` data and no initialData has been provided. + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`placeholderData`](QueryObserverOptions.md#placeholderdata) + +*** + +### queryFn? + +```ts +optional queryFn: + | typeof skipToken +| QueryFunction; +``` + +Defined in: [packages/query-core/src/types.ts:285](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L285) + +The function that the query will use to request data. +Required, unless a default query function has been set via `queryClient.setQueryDefaults` or +`queryClient.setDefaultOptions`. +Receives a [QueryFunctionContext](../type-aliases/QueryFunctionContext.md). +Must return a promise that will either resolve data or throw an error. The data cannot be `undefined`. + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`queryFn`](QueryObserverOptions.md#queryfn) + +*** + +### queryHash? + +```ts +optional queryHash: string; +``` + +Defined in: [packages/query-core/src/types.ts:295](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L295) + +The hashed form of `queryKey`, computed with `queryKeyHashFn` (or the default hashing function otherwise). Used +as the actual cache key internally. + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`queryHash`](QueryObserverOptions.md#queryhash) + +*** + +### queryKey + +```ts +queryKey: TQueryKey & object; +``` + +Defined in: [packages/query-core/src/types.ts:304](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L304) + +The query key to use for this query. + +The query key will be hashed into a stable hash. See [Query Keys](https://tanstack.com/query/latest/docs/framework/react/guides/query-keys) +for more information. + +The query will automatically update when this key changes (as long as `enabled` is not set to `false`). + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`queryKey`](QueryObserverOptions.md#querykey) + +*** + +### queryKeyHashFn? + +```ts +optional queryKeyHashFn: QueryKeyHashFunction; +``` + +Defined in: [packages/query-core/src/types.ts:308](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L308) + +If specified, this function is used to hash the `queryKey` to a string. + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`queryKeyHashFn`](QueryObserverOptions.md#querykeyhashfn) + +*** + +### refetchInterval? + +```ts +optional refetchInterval: number | false | (query) => number | false | undefined; +``` + +Defined in: [packages/query-core/src/types.ts:414](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L414) + +If set to a number, the query will continuously refetch at this frequency in milliseconds. +If set to a function, the function will be executed with the latest data and query to compute a frequency + +Defaults to `false`. + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`refetchInterval`](QueryObserverOptions.md#refetchinterval) + +*** + +### refetchIntervalInBackground? + +```ts +optional refetchIntervalInBackground: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:425](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L425) + +If set to `true`, the query will continue to refetch while their tab/window is in the background. + +Defaults to `false`. + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`refetchIntervalInBackground`](QueryObserverOptions.md#refetchintervalinbackground) + +*** + +### refetchOnMount? + +```ts +optional refetchOnMount: boolean | "always" | (query) => boolean | "always"; +``` + +Defined in: [packages/query-core/src/types.ts:462](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L462) + +If set to `true`, the query will refetch on mount if the data is stale. +If set to `false`, will disable additional instances of a query to trigger background refetch. +If set to `'always'`, the query will always refetch on mount (except when `staleTime: 'static'` is used). +If set to a function, the function will be executed with the latest data and query to compute the value + +Defaults to `true`. + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`refetchOnMount`](QueryObserverOptions.md#refetchonmount) + +*** + +### refetchOnReconnect? + +```ts +optional refetchOnReconnect: boolean | "always" | (query) => boolean | "always"; +``` + +Defined in: [packages/query-core/src/types.ts:448](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L448) + +If set to `true`, the query will refetch on reconnect if the data is stale. +If set to `false`, the query will not refetch on reconnect. +If set to `'always'`, the query will always refetch on reconnect (except when `staleTime: 'static'` is used). +If set to a function, the function will be executed with the latest data and query to compute the value. + +Defaults to `true` unless `networkMode` is `'always'`. + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`refetchOnReconnect`](QueryObserverOptions.md#refetchonreconnect) + +*** + +### refetchOnWindowFocus? + +```ts +optional refetchOnWindowFocus: boolean | "always" | (query) => boolean | "always"; +``` + +Defined in: [packages/query-core/src/types.ts:434](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L434) + +If set to `true`, the query will refetch on window focus if the data is stale. +If set to `false`, the query will not refetch on window focus. +If set to `'always'`, the query will always refetch on window focus (except when `staleTime: 'static'` is used). +If set to a function, the function will be executed with the latest data and query to compute the value. + +Defaults to `true`. + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`refetchOnWindowFocus`](QueryObserverOptions.md#refetchonwindowfocus) + +*** + +### retry? + +```ts +optional retry: RetryValue; +``` + +Defined in: [packages/query-core/src/types.ts:246](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L246) + +If `false`, failed queries will not retry by default. +If `true`, failed queries will retry infinitely. +If set to an integer number, e.g. 3, failed queries will retry until the failed query count meets that number. +If set to a function `(failureCount, error) => boolean` failed queries will retry until the function returns false. + +Defaults to `3` on the client and `0` on the server. + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`retry`](QueryObserverOptions.md#retry) + +*** + +### retryDelay? + +```ts +optional retryDelay: RetryDelayValue; +``` + +Defined in: [packages/query-core/src/types.ts:258](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L258) + +This function receives a `retryAttempt` integer and the actual Error and returns the delay to apply before the +next attempt in milliseconds. + +A function like `attempt => Math.min(attempt > 1 ? 2 ** attempt * 1000 : 1000, 30 * 1000)` applies exponential +backoff. + +A function like `attempt => attempt * 1000` applies linear backoff. + +Defaults to a function that applies exponential backoff, capped at 30 seconds. + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`retryDelay`](QueryObserverOptions.md#retrydelay) + +*** + +### retryOnMount? + +```ts +optional retryOnMount: QueryBooleanOption, TQueryKey>; +``` + +Defined in: [packages/query-core/src/types.ts:474](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L474) + +If set to `false`, the query will not be retried on mount if it contains an error. +If set to a function, the function will be executed with the query to compute the value. + +Defaults to `true`. + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`retryOnMount`](QueryObserverOptions.md#retryonmount) + +*** + +### select()? + +```ts +optional select: (data) => TData; +``` + +Defined in: [packages/query-core/src/types.ts:500](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L500) + +This option can be used to transform or select a part of the data returned by the query function. It affects +the returned `data` value, but does not affect what gets stored in the query cache. +The `select` function will only run if `data` changed, or if the reference to the `select` function itself +changes. To optimize, memoize the function so its reference stays stable across calls. + +#### Parameters + +##### data + +[`InfiniteData`](InfiniteData.md) + +#### Returns + +`TData` + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`select`](QueryObserverOptions.md#select) + +*** + +### staleTime? + +```ts +optional staleTime: StaleTimeFunction, TQueryKey>; +``` + +Defined in: [packages/query-core/src/types.ts:407](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L407) + +The time in milliseconds after data is considered stale. +If set to `Infinity`, the data will never be considered stale. +If set to `'static'`, the data will never be considered stale. +If set to a function, the function will be executed with the query to compute a `staleTime`. + +Defaults to `0`. + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`staleTime`](QueryObserverOptions.md#staletime) + +*** + +### structuralSharing? + +```ts +optional structuralSharing: boolean | (oldData, newData) => unknown; +``` + +Defined in: [packages/query-core/src/types.ts:330](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L330) + +Set this to `false` to disable structural sharing between query results. +Set this to a function which accepts the old and new data and returns resolved data of the same type to implement custom structural sharing logic. + +Defaults to `true`. + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`structuralSharing`](QueryObserverOptions.md#structuralsharing) + +*** + +### suspense? + +```ts +optional suspense: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:507](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L507) + +If set to `true`, the query will suspend when `status === 'pending'` +and throw errors when `status === 'error'`. + +Defaults to `false`. + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`suspense`](QueryObserverOptions.md#suspense) + +*** + +### throwOnError? + +```ts +optional throwOnError: ThrowOnError, TQueryKey>; +``` + +Defined in: [packages/query-core/src/types.ts:493](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L493) + +Whether errors should be thrown instead of setting the `error` property. +If set to `true` or `suspense` is `true`, all errors will be thrown to the error boundary. +If set to `false` and `suspense` is `false`, errors are returned as state. +If set to a function, it will be passed the error and the query, and it should return a boolean indicating whether to show the error in an error boundary (`true`) or return the error as state (`false`). + +Defaults to `false`. + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`throwOnError`](QueryObserverOptions.md#throwonerror) diff --git a/docs/framework/svelte/reference/interfaces/InfiniteQueryObserverPendingResult.md b/docs/framework/svelte/reference/interfaces/InfiniteQueryObserverPendingResult.md new file mode 100644 index 00000000000..a09301ab6c4 --- /dev/null +++ b/docs/framework/svelte/reference/interfaces/InfiniteQueryObserverPendingResult.md @@ -0,0 +1,600 @@ +--- +id: InfiniteQueryObserverPendingResult +title: InfiniteQueryObserverPendingResult +--- + +Defined in: [packages/query-core/src/types.ts:1043](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1043) + +## Extends + +- [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md)\<`TData`, `TError`\> + +## Type Parameters + +### TData + +`TData` = `unknown` + +### TError + +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) + +## Properties + +### data + +```ts +data: undefined; +``` + +Defined in: [packages/query-core/src/types.ts:1047](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1047) + +The last successfully resolved data for the query. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`data`](InfiniteQueryObserverBaseResult.md#data) + +*** + +### dataUpdatedAt + +```ts +dataUpdatedAt: number; +``` + +Defined in: [packages/query-core/src/types.ts:775](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L775) + +The timestamp for when the query most recently returned the `status` as `"success"`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`dataUpdatedAt`](InfiniteQueryObserverBaseResult.md#dataupdatedat) + +*** + +### error + +```ts +error: null; +``` + +Defined in: [packages/query-core/src/types.ts:1048](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1048) + +The error object for the query, if an error was thrown. +- Defaults to `null`. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`error`](InfiniteQueryObserverBaseResult.md#error) + +*** + +### errorUpdateCount + +```ts +errorUpdateCount: number; +``` + +Defined in: [packages/query-core/src/types.ts:799](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L799) + +The sum of all errors. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`errorUpdateCount`](InfiniteQueryObserverBaseResult.md#errorupdatecount) + +*** + +### errorUpdatedAt + +```ts +errorUpdatedAt: number; +``` + +Defined in: [packages/query-core/src/types.ts:784](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L784) + +The timestamp for when the query most recently returned the `status` as `"error"`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`errorUpdatedAt`](InfiniteQueryObserverBaseResult.md#errorupdatedat) + +*** + +### failureCount + +```ts +failureCount: number; +``` + +Defined in: [packages/query-core/src/types.ts:790](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L790) + +The failure count for the query. +- Incremented every time the query fails. +- Reset to `0` when the query succeeds. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`failureCount`](InfiniteQueryObserverBaseResult.md#failurecount) + +*** + +### failureReason + +```ts +failureReason: TError | null; +``` + +Defined in: [packages/query-core/src/types.ts:795](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L795) + +The failure reason for the query retry. +- Reset to `null` when the query succeeds. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`failureReason`](InfiniteQueryObserverBaseResult.md#failurereason) + +*** + +### fetchNextPage() + +```ts +fetchNextPage: (options?) => Promise>; +``` + +Defined in: [packages/query-core/src/types.ts:1008](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1008) + +This function allows you to fetch the next "page" of results. + +#### Parameters + +##### options? + +[`FetchNextPageOptions`](FetchNextPageOptions.md) + +#### Returns + +`Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`fetchNextPage`](InfiniteQueryObserverBaseResult.md#fetchnextpage) + +*** + +### fetchPreviousPage() + +```ts +fetchPreviousPage: (options?) => Promise>; +``` + +Defined in: [packages/query-core/src/types.ts:1014](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1014) + +This function allows you to fetch the previous "page" of results. + +#### Parameters + +##### options? + +[`FetchPreviousPageOptions`](FetchPreviousPageOptions.md) + +#### Returns + +`Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`fetchPreviousPage`](InfiniteQueryObserverBaseResult.md#fetchpreviouspage) + +*** + +### fetchStatus + +```ts +fetchStatus: FetchStatus; +``` + +Defined in: [packages/query-core/src/types.ts:889](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L889) + +The fetch status of the query. +- `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. +- `paused`: The query wanted to fetch, but has been `paused`. +- `idle`: The query is not fetching. +- See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`fetchStatus`](InfiniteQueryObserverBaseResult.md#fetchstatus) + +*** + +### hasNextPage + +```ts +hasNextPage: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1020](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1020) + +Will be `true` if there is a next page to be fetched (known via the `getNextPageParam` option). + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`hasNextPage`](InfiniteQueryObserverBaseResult.md#hasnextpage) + +*** + +### hasPreviousPage + +```ts +hasPreviousPage: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1024](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1024) + +Will be `true` if there is a previous page to be fetched (known via the `getPreviousPageParam` option). + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`hasPreviousPage`](InfiniteQueryObserverBaseResult.md#haspreviouspage) + +*** + +### isEnabled + +```ts +isEnabled: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:867](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L867) + +`true` if this observer is enabled, `false` otherwise. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isEnabled`](InfiniteQueryObserverBaseResult.md#isenabled) + +*** + +### isError + +```ts +isError: false; +``` + +Defined in: [packages/query-core/src/types.ts:1049](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1049) + +A derived boolean from the `status` variable, provided for convenience. +- `true` if the query attempt resulted in an error. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isError`](InfiniteQueryObserverBaseResult.md#iserror) + +*** + +### isFetched + +```ts +isFetched: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:808](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L808) + +Will be `true` if the query has been fetched. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetched`](InfiniteQueryObserverBaseResult.md#isfetched) + +*** + +### isFetchedAfterMount + +```ts +isFetchedAfterMount: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:813](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L813) + +Will be `true` if the query has been fetched after the component mounted. +- This property can be used to not show any previously cached data. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchedAfterMount`](InfiniteQueryObserverBaseResult.md#isfetchedaftermount) + +*** + +### isFetching + +```ts +isFetching: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:818](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L818) + +A derived boolean from the `fetchStatus` variable, provided for convenience. +- `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetching`](InfiniteQueryObserverBaseResult.md#isfetching) + +*** + +### isFetchingNextPage + +```ts +isFetchingNextPage: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1032](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1032) + +Will be `true` while fetching the next page with `fetchNextPage`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchingNextPage`](InfiniteQueryObserverBaseResult.md#isfetchingnextpage) + +*** + +### isFetchingPreviousPage + +```ts +isFetchingPreviousPage: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1040](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1040) + +Will be `true` while fetching the previous page with `fetchPreviousPage`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchingPreviousPage`](InfiniteQueryObserverBaseResult.md#isfetchingpreviouspage) + +*** + +### isFetchNextPageError + +```ts +isFetchNextPageError: false; +``` + +Defined in: [packages/query-core/src/types.ts:1053](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1053) + +Will be `true` if the query failed while fetching the next page. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchNextPageError`](InfiniteQueryObserverBaseResult.md#isfetchnextpageerror) + +*** + +### isFetchPreviousPageError + +```ts +isFetchPreviousPageError: false; +``` + +Defined in: [packages/query-core/src/types.ts:1054](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1054) + +Will be `true` if the query failed while fetching the previous page. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchPreviousPageError`](InfiniteQueryObserverBaseResult.md#isfetchpreviouspageerror) + +*** + +### ~~isInitialLoading~~ + +```ts +isInitialLoading: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:836](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L836) + +#### Deprecated + +`isInitialLoading` is being deprecated in favor of `isLoading` +and will be removed in the next major version. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isInitialLoading`](InfiniteQueryObserverBaseResult.md#isinitialloading) + +*** + +### isLoading + +```ts +isLoading: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:823](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L823) + +Is `true` whenever the first fetch for a query is in-flight. +- Is the same as `isFetching && isPending`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoading`](InfiniteQueryObserverBaseResult.md#isloading) + +*** + +### isLoadingError + +```ts +isLoadingError: false; +``` + +Defined in: [packages/query-core/src/types.ts:1051](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1051) + +Will be `true` if the query failed while fetching for the first time. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoadingError`](InfiniteQueryObserverBaseResult.md#isloadingerror) + +*** + +### isPaused + +```ts +isPaused: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:841](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L841) + +A derived boolean from the `fetchStatus` variable, provided for convenience. +- The query wanted to fetch, but has been `paused`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPaused`](InfiniteQueryObserverBaseResult.md#ispaused) + +*** + +### isPending + +```ts +isPending: true; +``` + +Defined in: [packages/query-core/src/types.ts:1050](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1050) + +Will be `pending` if there's no cached data and no query attempt was finished yet. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPending`](InfiniteQueryObserverBaseResult.md#ispending) + +*** + +### isPlaceholderData + +```ts +isPlaceholderData: false; +``` + +Defined in: [packages/query-core/src/types.ts:1056](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1056) + +Will be `true` if the data shown is the placeholder data. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPlaceholderData`](InfiniteQueryObserverBaseResult.md#isplaceholderdata) + +*** + +### isRefetchError + +```ts +isRefetchError: false; +``` + +Defined in: [packages/query-core/src/types.ts:1052](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1052) + +Will be `true` if the query failed while refetching. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isRefetchError`](InfiniteQueryObserverBaseResult.md#isrefetcherror) + +*** + +### isRefetching + +```ts +isRefetching: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:854](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L854) + +Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. +- Is the same as `isFetching && !isPending`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isRefetching`](InfiniteQueryObserverBaseResult.md#isrefetching) + +*** + +### isStale + +```ts +isStale: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:858](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L858) + +Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isStale`](InfiniteQueryObserverBaseResult.md#isstale) + +*** + +### isSuccess + +```ts +isSuccess: false; +``` + +Defined in: [packages/query-core/src/types.ts:1055](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1055) + +A derived boolean from the `status` variable, provided for convenience. +- `true` if the query has received a response with no errors and is ready to display its data. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isSuccess`](InfiniteQueryObserverBaseResult.md#issuccess) + +*** + +### refetch() + +```ts +refetch: (options?) => Promise>; +``` + +Defined in: [packages/query-core/src/types.ts:871](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L871) + +A function to manually refetch the query. + +#### Parameters + +##### options? + +[`RefetchOptions`](RefetchOptions.md) + +#### Returns + +`Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`refetch`](InfiniteQueryObserverBaseResult.md#refetch) + +*** + +### status + +```ts +status: "pending"; +``` + +Defined in: [packages/query-core/src/types.ts:1057](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1057) + +The status of the query. +- Will be: + - `pending` if there's no cached data and no query attempt was finished yet. + - `error` if the query attempt resulted in an error. + - `success` if the query has received a response with no errors and is ready to display its data. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`status`](InfiniteQueryObserverBaseResult.md#status) diff --git a/docs/framework/svelte/reference/interfaces/InfiniteQueryObserverPlaceholderResult.md b/docs/framework/svelte/reference/interfaces/InfiniteQueryObserverPlaceholderResult.md new file mode 100644 index 00000000000..58193a987d1 --- /dev/null +++ b/docs/framework/svelte/reference/interfaces/InfiniteQueryObserverPlaceholderResult.md @@ -0,0 +1,600 @@ +--- +id: InfiniteQueryObserverPlaceholderResult +title: InfiniteQueryObserverPlaceholderResult +--- + +Defined in: [packages/query-core/src/types.ts:1130](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1130) + +## Extends + +- [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md)\<`TData`, `TError`\> + +## Type Parameters + +### TData + +`TData` = `unknown` + +### TError + +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) + +## Properties + +### data + +```ts +data: TData; +``` + +Defined in: [packages/query-core/src/types.ts:1134](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1134) + +The last successfully resolved data for the query. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`data`](InfiniteQueryObserverBaseResult.md#data) + +*** + +### dataUpdatedAt + +```ts +dataUpdatedAt: number; +``` + +Defined in: [packages/query-core/src/types.ts:775](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L775) + +The timestamp for when the query most recently returned the `status` as `"success"`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`dataUpdatedAt`](InfiniteQueryObserverBaseResult.md#dataupdatedat) + +*** + +### error + +```ts +error: null; +``` + +Defined in: [packages/query-core/src/types.ts:1136](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1136) + +The error object for the query, if an error was thrown. +- Defaults to `null`. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`error`](InfiniteQueryObserverBaseResult.md#error) + +*** + +### errorUpdateCount + +```ts +errorUpdateCount: number; +``` + +Defined in: [packages/query-core/src/types.ts:799](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L799) + +The sum of all errors. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`errorUpdateCount`](InfiniteQueryObserverBaseResult.md#errorupdatecount) + +*** + +### errorUpdatedAt + +```ts +errorUpdatedAt: number; +``` + +Defined in: [packages/query-core/src/types.ts:784](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L784) + +The timestamp for when the query most recently returned the `status` as `"error"`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`errorUpdatedAt`](InfiniteQueryObserverBaseResult.md#errorupdatedat) + +*** + +### failureCount + +```ts +failureCount: number; +``` + +Defined in: [packages/query-core/src/types.ts:790](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L790) + +The failure count for the query. +- Incremented every time the query fails. +- Reset to `0` when the query succeeds. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`failureCount`](InfiniteQueryObserverBaseResult.md#failurecount) + +*** + +### failureReason + +```ts +failureReason: TError | null; +``` + +Defined in: [packages/query-core/src/types.ts:795](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L795) + +The failure reason for the query retry. +- Reset to `null` when the query succeeds. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`failureReason`](InfiniteQueryObserverBaseResult.md#failurereason) + +*** + +### fetchNextPage() + +```ts +fetchNextPage: (options?) => Promise>; +``` + +Defined in: [packages/query-core/src/types.ts:1008](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1008) + +This function allows you to fetch the next "page" of results. + +#### Parameters + +##### options? + +[`FetchNextPageOptions`](FetchNextPageOptions.md) + +#### Returns + +`Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`fetchNextPage`](InfiniteQueryObserverBaseResult.md#fetchnextpage) + +*** + +### fetchPreviousPage() + +```ts +fetchPreviousPage: (options?) => Promise>; +``` + +Defined in: [packages/query-core/src/types.ts:1014](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1014) + +This function allows you to fetch the previous "page" of results. + +#### Parameters + +##### options? + +[`FetchPreviousPageOptions`](FetchPreviousPageOptions.md) + +#### Returns + +`Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`fetchPreviousPage`](InfiniteQueryObserverBaseResult.md#fetchpreviouspage) + +*** + +### fetchStatus + +```ts +fetchStatus: FetchStatus; +``` + +Defined in: [packages/query-core/src/types.ts:889](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L889) + +The fetch status of the query. +- `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. +- `paused`: The query wanted to fetch, but has been `paused`. +- `idle`: The query is not fetching. +- See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`fetchStatus`](InfiniteQueryObserverBaseResult.md#fetchstatus) + +*** + +### hasNextPage + +```ts +hasNextPage: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1020](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1020) + +Will be `true` if there is a next page to be fetched (known via the `getNextPageParam` option). + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`hasNextPage`](InfiniteQueryObserverBaseResult.md#hasnextpage) + +*** + +### hasPreviousPage + +```ts +hasPreviousPage: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1024](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1024) + +Will be `true` if there is a previous page to be fetched (known via the `getPreviousPageParam` option). + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`hasPreviousPage`](InfiniteQueryObserverBaseResult.md#haspreviouspage) + +*** + +### isEnabled + +```ts +isEnabled: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:867](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L867) + +`true` if this observer is enabled, `false` otherwise. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isEnabled`](InfiniteQueryObserverBaseResult.md#isenabled) + +*** + +### isError + +```ts +isError: false; +``` + +Defined in: [packages/query-core/src/types.ts:1135](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1135) + +A derived boolean from the `status` variable, provided for convenience. +- `true` if the query attempt resulted in an error. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isError`](InfiniteQueryObserverBaseResult.md#iserror) + +*** + +### isFetched + +```ts +isFetched: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:808](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L808) + +Will be `true` if the query has been fetched. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetched`](InfiniteQueryObserverBaseResult.md#isfetched) + +*** + +### isFetchedAfterMount + +```ts +isFetchedAfterMount: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:813](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L813) + +Will be `true` if the query has been fetched after the component mounted. +- This property can be used to not show any previously cached data. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchedAfterMount`](InfiniteQueryObserverBaseResult.md#isfetchedaftermount) + +*** + +### isFetching + +```ts +isFetching: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:818](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L818) + +A derived boolean from the `fetchStatus` variable, provided for convenience. +- `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetching`](InfiniteQueryObserverBaseResult.md#isfetching) + +*** + +### isFetchingNextPage + +```ts +isFetchingNextPage: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1032](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1032) + +Will be `true` while fetching the next page with `fetchNextPage`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchingNextPage`](InfiniteQueryObserverBaseResult.md#isfetchingnextpage) + +*** + +### isFetchingPreviousPage + +```ts +isFetchingPreviousPage: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1040](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1040) + +Will be `true` while fetching the previous page with `fetchPreviousPage`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchingPreviousPage`](InfiniteQueryObserverBaseResult.md#isfetchingpreviouspage) + +*** + +### isFetchNextPageError + +```ts +isFetchNextPageError: false; +``` + +Defined in: [packages/query-core/src/types.ts:1143](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1143) + +Will be `true` if the query failed while fetching the next page. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchNextPageError`](InfiniteQueryObserverBaseResult.md#isfetchnextpageerror) + +*** + +### isFetchPreviousPageError + +```ts +isFetchPreviousPageError: false; +``` + +Defined in: [packages/query-core/src/types.ts:1144](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1144) + +Will be `true` if the query failed while fetching the previous page. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchPreviousPageError`](InfiniteQueryObserverBaseResult.md#isfetchpreviouspageerror) + +*** + +### ~~isInitialLoading~~ + +```ts +isInitialLoading: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:836](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L836) + +#### Deprecated + +`isInitialLoading` is being deprecated in favor of `isLoading` +and will be removed in the next major version. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isInitialLoading`](InfiniteQueryObserverBaseResult.md#isinitialloading) + +*** + +### isLoading + +```ts +isLoading: false; +``` + +Defined in: [packages/query-core/src/types.ts:1138](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1138) + +Is `true` whenever the first fetch for a query is in-flight. +- Is the same as `isFetching && isPending`. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoading`](InfiniteQueryObserverBaseResult.md#isloading) + +*** + +### isLoadingError + +```ts +isLoadingError: false; +``` + +Defined in: [packages/query-core/src/types.ts:1139](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1139) + +Will be `true` if the query failed while fetching for the first time. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoadingError`](InfiniteQueryObserverBaseResult.md#isloadingerror) + +*** + +### isPaused + +```ts +isPaused: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:841](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L841) + +A derived boolean from the `fetchStatus` variable, provided for convenience. +- The query wanted to fetch, but has been `paused`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPaused`](InfiniteQueryObserverBaseResult.md#ispaused) + +*** + +### isPending + +```ts +isPending: false; +``` + +Defined in: [packages/query-core/src/types.ts:1137](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1137) + +Will be `pending` if there's no cached data and no query attempt was finished yet. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPending`](InfiniteQueryObserverBaseResult.md#ispending) + +*** + +### isPlaceholderData + +```ts +isPlaceholderData: true; +``` + +Defined in: [packages/query-core/src/types.ts:1142](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1142) + +Will be `true` if the data shown is the placeholder data. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPlaceholderData`](InfiniteQueryObserverBaseResult.md#isplaceholderdata) + +*** + +### isRefetchError + +```ts +isRefetchError: false; +``` + +Defined in: [packages/query-core/src/types.ts:1140](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1140) + +Will be `true` if the query failed while refetching. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isRefetchError`](InfiniteQueryObserverBaseResult.md#isrefetcherror) + +*** + +### isRefetching + +```ts +isRefetching: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:854](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L854) + +Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. +- Is the same as `isFetching && !isPending`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isRefetching`](InfiniteQueryObserverBaseResult.md#isrefetching) + +*** + +### isStale + +```ts +isStale: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:858](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L858) + +Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isStale`](InfiniteQueryObserverBaseResult.md#isstale) + +*** + +### isSuccess + +```ts +isSuccess: true; +``` + +Defined in: [packages/query-core/src/types.ts:1141](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1141) + +A derived boolean from the `status` variable, provided for convenience. +- `true` if the query has received a response with no errors and is ready to display its data. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isSuccess`](InfiniteQueryObserverBaseResult.md#issuccess) + +*** + +### refetch() + +```ts +refetch: (options?) => Promise>; +``` + +Defined in: [packages/query-core/src/types.ts:871](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L871) + +A function to manually refetch the query. + +#### Parameters + +##### options? + +[`RefetchOptions`](RefetchOptions.md) + +#### Returns + +`Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`refetch`](InfiniteQueryObserverBaseResult.md#refetch) + +*** + +### status + +```ts +status: "success"; +``` + +Defined in: [packages/query-core/src/types.ts:1145](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1145) + +The status of the query. +- Will be: + - `pending` if there's no cached data and no query attempt was finished yet. + - `error` if the query attempt resulted in an error. + - `success` if the query has received a response with no errors and is ready to display its data. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`status`](InfiniteQueryObserverBaseResult.md#status) diff --git a/docs/framework/svelte/reference/interfaces/InfiniteQueryObserverRefetchErrorResult.md b/docs/framework/svelte/reference/interfaces/InfiniteQueryObserverRefetchErrorResult.md new file mode 100644 index 00000000000..4ce469bceed --- /dev/null +++ b/docs/framework/svelte/reference/interfaces/InfiniteQueryObserverRefetchErrorResult.md @@ -0,0 +1,600 @@ +--- +id: InfiniteQueryObserverRefetchErrorResult +title: InfiniteQueryObserverRefetchErrorResult +--- + +Defined in: [packages/query-core/src/types.ts:1096](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1096) + +## Extends + +- [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md)\<`TData`, `TError`\> + +## Type Parameters + +### TData + +`TData` = `unknown` + +### TError + +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) + +## Properties + +### data + +```ts +data: TData; +``` + +Defined in: [packages/query-core/src/types.ts:1100](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1100) + +The last successfully resolved data for the query. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`data`](InfiniteQueryObserverBaseResult.md#data) + +*** + +### dataUpdatedAt + +```ts +dataUpdatedAt: number; +``` + +Defined in: [packages/query-core/src/types.ts:775](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L775) + +The timestamp for when the query most recently returned the `status` as `"success"`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`dataUpdatedAt`](InfiniteQueryObserverBaseResult.md#dataupdatedat) + +*** + +### error + +```ts +error: TError; +``` + +Defined in: [packages/query-core/src/types.ts:1101](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1101) + +The error object for the query, if an error was thrown. +- Defaults to `null`. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`error`](InfiniteQueryObserverBaseResult.md#error) + +*** + +### errorUpdateCount + +```ts +errorUpdateCount: number; +``` + +Defined in: [packages/query-core/src/types.ts:799](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L799) + +The sum of all errors. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`errorUpdateCount`](InfiniteQueryObserverBaseResult.md#errorupdatecount) + +*** + +### errorUpdatedAt + +```ts +errorUpdatedAt: number; +``` + +Defined in: [packages/query-core/src/types.ts:784](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L784) + +The timestamp for when the query most recently returned the `status` as `"error"`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`errorUpdatedAt`](InfiniteQueryObserverBaseResult.md#errorupdatedat) + +*** + +### failureCount + +```ts +failureCount: number; +``` + +Defined in: [packages/query-core/src/types.ts:790](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L790) + +The failure count for the query. +- Incremented every time the query fails. +- Reset to `0` when the query succeeds. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`failureCount`](InfiniteQueryObserverBaseResult.md#failurecount) + +*** + +### failureReason + +```ts +failureReason: TError | null; +``` + +Defined in: [packages/query-core/src/types.ts:795](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L795) + +The failure reason for the query retry. +- Reset to `null` when the query succeeds. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`failureReason`](InfiniteQueryObserverBaseResult.md#failurereason) + +*** + +### fetchNextPage() + +```ts +fetchNextPage: (options?) => Promise>; +``` + +Defined in: [packages/query-core/src/types.ts:1008](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1008) + +This function allows you to fetch the next "page" of results. + +#### Parameters + +##### options? + +[`FetchNextPageOptions`](FetchNextPageOptions.md) + +#### Returns + +`Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`fetchNextPage`](InfiniteQueryObserverBaseResult.md#fetchnextpage) + +*** + +### fetchPreviousPage() + +```ts +fetchPreviousPage: (options?) => Promise>; +``` + +Defined in: [packages/query-core/src/types.ts:1014](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1014) + +This function allows you to fetch the previous "page" of results. + +#### Parameters + +##### options? + +[`FetchPreviousPageOptions`](FetchPreviousPageOptions.md) + +#### Returns + +`Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`fetchPreviousPage`](InfiniteQueryObserverBaseResult.md#fetchpreviouspage) + +*** + +### fetchStatus + +```ts +fetchStatus: FetchStatus; +``` + +Defined in: [packages/query-core/src/types.ts:889](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L889) + +The fetch status of the query. +- `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. +- `paused`: The query wanted to fetch, but has been `paused`. +- `idle`: The query is not fetching. +- See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`fetchStatus`](InfiniteQueryObserverBaseResult.md#fetchstatus) + +*** + +### hasNextPage + +```ts +hasNextPage: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1020](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1020) + +Will be `true` if there is a next page to be fetched (known via the `getNextPageParam` option). + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`hasNextPage`](InfiniteQueryObserverBaseResult.md#hasnextpage) + +*** + +### hasPreviousPage + +```ts +hasPreviousPage: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1024](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1024) + +Will be `true` if there is a previous page to be fetched (known via the `getPreviousPageParam` option). + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`hasPreviousPage`](InfiniteQueryObserverBaseResult.md#haspreviouspage) + +*** + +### isEnabled + +```ts +isEnabled: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:867](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L867) + +`true` if this observer is enabled, `false` otherwise. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isEnabled`](InfiniteQueryObserverBaseResult.md#isenabled) + +*** + +### isError + +```ts +isError: true; +``` + +Defined in: [packages/query-core/src/types.ts:1102](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1102) + +A derived boolean from the `status` variable, provided for convenience. +- `true` if the query attempt resulted in an error. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isError`](InfiniteQueryObserverBaseResult.md#iserror) + +*** + +### isFetched + +```ts +isFetched: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:808](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L808) + +Will be `true` if the query has been fetched. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetched`](InfiniteQueryObserverBaseResult.md#isfetched) + +*** + +### isFetchedAfterMount + +```ts +isFetchedAfterMount: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:813](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L813) + +Will be `true` if the query has been fetched after the component mounted. +- This property can be used to not show any previously cached data. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchedAfterMount`](InfiniteQueryObserverBaseResult.md#isfetchedaftermount) + +*** + +### isFetching + +```ts +isFetching: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:818](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L818) + +A derived boolean from the `fetchStatus` variable, provided for convenience. +- `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetching`](InfiniteQueryObserverBaseResult.md#isfetching) + +*** + +### isFetchingNextPage + +```ts +isFetchingNextPage: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1032](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1032) + +Will be `true` while fetching the next page with `fetchNextPage`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchingNextPage`](InfiniteQueryObserverBaseResult.md#isfetchingnextpage) + +*** + +### isFetchingPreviousPage + +```ts +isFetchingPreviousPage: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1040](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1040) + +Will be `true` while fetching the previous page with `fetchPreviousPage`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchingPreviousPage`](InfiniteQueryObserverBaseResult.md#isfetchingpreviouspage) + +*** + +### isFetchNextPageError + +```ts +isFetchNextPageError: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1028](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1028) + +Will be `true` if the query failed while fetching the next page. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchNextPageError`](InfiniteQueryObserverBaseResult.md#isfetchnextpageerror) + +*** + +### isFetchPreviousPageError + +```ts +isFetchPreviousPageError: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1036](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1036) + +Will be `true` if the query failed while fetching the previous page. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchPreviousPageError`](InfiniteQueryObserverBaseResult.md#isfetchpreviouspageerror) + +*** + +### ~~isInitialLoading~~ + +```ts +isInitialLoading: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:836](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L836) + +#### Deprecated + +`isInitialLoading` is being deprecated in favor of `isLoading` +and will be removed in the next major version. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isInitialLoading`](InfiniteQueryObserverBaseResult.md#isinitialloading) + +*** + +### isLoading + +```ts +isLoading: false; +``` + +Defined in: [packages/query-core/src/types.ts:1104](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1104) + +Is `true` whenever the first fetch for a query is in-flight. +- Is the same as `isFetching && isPending`. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoading`](InfiniteQueryObserverBaseResult.md#isloading) + +*** + +### isLoadingError + +```ts +isLoadingError: false; +``` + +Defined in: [packages/query-core/src/types.ts:1105](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1105) + +Will be `true` if the query failed while fetching for the first time. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoadingError`](InfiniteQueryObserverBaseResult.md#isloadingerror) + +*** + +### isPaused + +```ts +isPaused: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:841](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L841) + +A derived boolean from the `fetchStatus` variable, provided for convenience. +- The query wanted to fetch, but has been `paused`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPaused`](InfiniteQueryObserverBaseResult.md#ispaused) + +*** + +### isPending + +```ts +isPending: false; +``` + +Defined in: [packages/query-core/src/types.ts:1103](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1103) + +Will be `pending` if there's no cached data and no query attempt was finished yet. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPending`](InfiniteQueryObserverBaseResult.md#ispending) + +*** + +### isPlaceholderData + +```ts +isPlaceholderData: false; +``` + +Defined in: [packages/query-core/src/types.ts:1108](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1108) + +Will be `true` if the data shown is the placeholder data. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPlaceholderData`](InfiniteQueryObserverBaseResult.md#isplaceholderdata) + +*** + +### isRefetchError + +```ts +isRefetchError: true; +``` + +Defined in: [packages/query-core/src/types.ts:1106](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1106) + +Will be `true` if the query failed while refetching. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isRefetchError`](InfiniteQueryObserverBaseResult.md#isrefetcherror) + +*** + +### isRefetching + +```ts +isRefetching: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:854](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L854) + +Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. +- Is the same as `isFetching && !isPending`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isRefetching`](InfiniteQueryObserverBaseResult.md#isrefetching) + +*** + +### isStale + +```ts +isStale: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:858](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L858) + +Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isStale`](InfiniteQueryObserverBaseResult.md#isstale) + +*** + +### isSuccess + +```ts +isSuccess: false; +``` + +Defined in: [packages/query-core/src/types.ts:1107](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1107) + +A derived boolean from the `status` variable, provided for convenience. +- `true` if the query has received a response with no errors and is ready to display its data. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isSuccess`](InfiniteQueryObserverBaseResult.md#issuccess) + +*** + +### refetch() + +```ts +refetch: (options?) => Promise>; +``` + +Defined in: [packages/query-core/src/types.ts:871](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L871) + +A function to manually refetch the query. + +#### Parameters + +##### options? + +[`RefetchOptions`](RefetchOptions.md) + +#### Returns + +`Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`refetch`](InfiniteQueryObserverBaseResult.md#refetch) + +*** + +### status + +```ts +status: "error"; +``` + +Defined in: [packages/query-core/src/types.ts:1109](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1109) + +The status of the query. +- Will be: + - `pending` if there's no cached data and no query attempt was finished yet. + - `error` if the query attempt resulted in an error. + - `success` if the query has received a response with no errors and is ready to display its data. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`status`](InfiniteQueryObserverBaseResult.md#status) diff --git a/docs/framework/svelte/reference/interfaces/InfiniteQueryObserverSuccessResult.md b/docs/framework/svelte/reference/interfaces/InfiniteQueryObserverSuccessResult.md new file mode 100644 index 00000000000..131f6d01ae7 --- /dev/null +++ b/docs/framework/svelte/reference/interfaces/InfiniteQueryObserverSuccessResult.md @@ -0,0 +1,600 @@ +--- +id: InfiniteQueryObserverSuccessResult +title: InfiniteQueryObserverSuccessResult +--- + +Defined in: [packages/query-core/src/types.ts:1112](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1112) + +## Extends + +- [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md)\<`TData`, `TError`\> + +## Type Parameters + +### TData + +`TData` = `unknown` + +### TError + +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) + +## Properties + +### data + +```ts +data: TData; +``` + +Defined in: [packages/query-core/src/types.ts:1116](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1116) + +The last successfully resolved data for the query. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`data`](InfiniteQueryObserverBaseResult.md#data) + +*** + +### dataUpdatedAt + +```ts +dataUpdatedAt: number; +``` + +Defined in: [packages/query-core/src/types.ts:775](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L775) + +The timestamp for when the query most recently returned the `status` as `"success"`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`dataUpdatedAt`](InfiniteQueryObserverBaseResult.md#dataupdatedat) + +*** + +### error + +```ts +error: null; +``` + +Defined in: [packages/query-core/src/types.ts:1117](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1117) + +The error object for the query, if an error was thrown. +- Defaults to `null`. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`error`](InfiniteQueryObserverBaseResult.md#error) + +*** + +### errorUpdateCount + +```ts +errorUpdateCount: number; +``` + +Defined in: [packages/query-core/src/types.ts:799](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L799) + +The sum of all errors. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`errorUpdateCount`](InfiniteQueryObserverBaseResult.md#errorupdatecount) + +*** + +### errorUpdatedAt + +```ts +errorUpdatedAt: number; +``` + +Defined in: [packages/query-core/src/types.ts:784](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L784) + +The timestamp for when the query most recently returned the `status` as `"error"`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`errorUpdatedAt`](InfiniteQueryObserverBaseResult.md#errorupdatedat) + +*** + +### failureCount + +```ts +failureCount: number; +``` + +Defined in: [packages/query-core/src/types.ts:790](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L790) + +The failure count for the query. +- Incremented every time the query fails. +- Reset to `0` when the query succeeds. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`failureCount`](InfiniteQueryObserverBaseResult.md#failurecount) + +*** + +### failureReason + +```ts +failureReason: TError | null; +``` + +Defined in: [packages/query-core/src/types.ts:795](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L795) + +The failure reason for the query retry. +- Reset to `null` when the query succeeds. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`failureReason`](InfiniteQueryObserverBaseResult.md#failurereason) + +*** + +### fetchNextPage() + +```ts +fetchNextPage: (options?) => Promise>; +``` + +Defined in: [packages/query-core/src/types.ts:1008](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1008) + +This function allows you to fetch the next "page" of results. + +#### Parameters + +##### options? + +[`FetchNextPageOptions`](FetchNextPageOptions.md) + +#### Returns + +`Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`fetchNextPage`](InfiniteQueryObserverBaseResult.md#fetchnextpage) + +*** + +### fetchPreviousPage() + +```ts +fetchPreviousPage: (options?) => Promise>; +``` + +Defined in: [packages/query-core/src/types.ts:1014](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1014) + +This function allows you to fetch the previous "page" of results. + +#### Parameters + +##### options? + +[`FetchPreviousPageOptions`](FetchPreviousPageOptions.md) + +#### Returns + +`Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`fetchPreviousPage`](InfiniteQueryObserverBaseResult.md#fetchpreviouspage) + +*** + +### fetchStatus + +```ts +fetchStatus: FetchStatus; +``` + +Defined in: [packages/query-core/src/types.ts:889](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L889) + +The fetch status of the query. +- `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. +- `paused`: The query wanted to fetch, but has been `paused`. +- `idle`: The query is not fetching. +- See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`fetchStatus`](InfiniteQueryObserverBaseResult.md#fetchstatus) + +*** + +### hasNextPage + +```ts +hasNextPage: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1020](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1020) + +Will be `true` if there is a next page to be fetched (known via the `getNextPageParam` option). + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`hasNextPage`](InfiniteQueryObserverBaseResult.md#hasnextpage) + +*** + +### hasPreviousPage + +```ts +hasPreviousPage: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1024](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1024) + +Will be `true` if there is a previous page to be fetched (known via the `getPreviousPageParam` option). + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`hasPreviousPage`](InfiniteQueryObserverBaseResult.md#haspreviouspage) + +*** + +### isEnabled + +```ts +isEnabled: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:867](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L867) + +`true` if this observer is enabled, `false` otherwise. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isEnabled`](InfiniteQueryObserverBaseResult.md#isenabled) + +*** + +### isError + +```ts +isError: false; +``` + +Defined in: [packages/query-core/src/types.ts:1118](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1118) + +A derived boolean from the `status` variable, provided for convenience. +- `true` if the query attempt resulted in an error. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isError`](InfiniteQueryObserverBaseResult.md#iserror) + +*** + +### isFetched + +```ts +isFetched: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:808](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L808) + +Will be `true` if the query has been fetched. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetched`](InfiniteQueryObserverBaseResult.md#isfetched) + +*** + +### isFetchedAfterMount + +```ts +isFetchedAfterMount: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:813](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L813) + +Will be `true` if the query has been fetched after the component mounted. +- This property can be used to not show any previously cached data. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchedAfterMount`](InfiniteQueryObserverBaseResult.md#isfetchedaftermount) + +*** + +### isFetching + +```ts +isFetching: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:818](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L818) + +A derived boolean from the `fetchStatus` variable, provided for convenience. +- `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetching`](InfiniteQueryObserverBaseResult.md#isfetching) + +*** + +### isFetchingNextPage + +```ts +isFetchingNextPage: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1032](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1032) + +Will be `true` while fetching the next page with `fetchNextPage`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchingNextPage`](InfiniteQueryObserverBaseResult.md#isfetchingnextpage) + +*** + +### isFetchingPreviousPage + +```ts +isFetchingPreviousPage: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1040](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1040) + +Will be `true` while fetching the previous page with `fetchPreviousPage`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchingPreviousPage`](InfiniteQueryObserverBaseResult.md#isfetchingpreviouspage) + +*** + +### isFetchNextPageError + +```ts +isFetchNextPageError: false; +``` + +Defined in: [packages/query-core/src/types.ts:1123](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1123) + +Will be `true` if the query failed while fetching the next page. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchNextPageError`](InfiniteQueryObserverBaseResult.md#isfetchnextpageerror) + +*** + +### isFetchPreviousPageError + +```ts +isFetchPreviousPageError: false; +``` + +Defined in: [packages/query-core/src/types.ts:1124](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1124) + +Will be `true` if the query failed while fetching the previous page. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchPreviousPageError`](InfiniteQueryObserverBaseResult.md#isfetchpreviouspageerror) + +*** + +### ~~isInitialLoading~~ + +```ts +isInitialLoading: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:836](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L836) + +#### Deprecated + +`isInitialLoading` is being deprecated in favor of `isLoading` +and will be removed in the next major version. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isInitialLoading`](InfiniteQueryObserverBaseResult.md#isinitialloading) + +*** + +### isLoading + +```ts +isLoading: false; +``` + +Defined in: [packages/query-core/src/types.ts:1120](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1120) + +Is `true` whenever the first fetch for a query is in-flight. +- Is the same as `isFetching && isPending`. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoading`](InfiniteQueryObserverBaseResult.md#isloading) + +*** + +### isLoadingError + +```ts +isLoadingError: false; +``` + +Defined in: [packages/query-core/src/types.ts:1121](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1121) + +Will be `true` if the query failed while fetching for the first time. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoadingError`](InfiniteQueryObserverBaseResult.md#isloadingerror) + +*** + +### isPaused + +```ts +isPaused: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:841](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L841) + +A derived boolean from the `fetchStatus` variable, provided for convenience. +- The query wanted to fetch, but has been `paused`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPaused`](InfiniteQueryObserverBaseResult.md#ispaused) + +*** + +### isPending + +```ts +isPending: false; +``` + +Defined in: [packages/query-core/src/types.ts:1119](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1119) + +Will be `pending` if there's no cached data and no query attempt was finished yet. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPending`](InfiniteQueryObserverBaseResult.md#ispending) + +*** + +### isPlaceholderData + +```ts +isPlaceholderData: false; +``` + +Defined in: [packages/query-core/src/types.ts:1126](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1126) + +Will be `true` if the data shown is the placeholder data. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPlaceholderData`](InfiniteQueryObserverBaseResult.md#isplaceholderdata) + +*** + +### isRefetchError + +```ts +isRefetchError: false; +``` + +Defined in: [packages/query-core/src/types.ts:1122](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1122) + +Will be `true` if the query failed while refetching. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isRefetchError`](InfiniteQueryObserverBaseResult.md#isrefetcherror) + +*** + +### isRefetching + +```ts +isRefetching: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:854](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L854) + +Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. +- Is the same as `isFetching && !isPending`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isRefetching`](InfiniteQueryObserverBaseResult.md#isrefetching) + +*** + +### isStale + +```ts +isStale: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:858](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L858) + +Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isStale`](InfiniteQueryObserverBaseResult.md#isstale) + +*** + +### isSuccess + +```ts +isSuccess: true; +``` + +Defined in: [packages/query-core/src/types.ts:1125](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1125) + +A derived boolean from the `status` variable, provided for convenience. +- `true` if the query has received a response with no errors and is ready to display its data. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isSuccess`](InfiniteQueryObserverBaseResult.md#issuccess) + +*** + +### refetch() + +```ts +refetch: (options?) => Promise>; +``` + +Defined in: [packages/query-core/src/types.ts:871](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L871) + +A function to manually refetch the query. + +#### Parameters + +##### options? + +[`RefetchOptions`](RefetchOptions.md) + +#### Returns + +`Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`refetch`](InfiniteQueryObserverBaseResult.md#refetch) + +*** + +### status + +```ts +status: "success"; +``` + +Defined in: [packages/query-core/src/types.ts:1127](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1127) + +The status of the query. +- Will be: + - `pending` if there's no cached data and no query attempt was finished yet. + - `error` if the query attempt resulted in an error. + - `success` if the query has received a response with no errors and is ready to display its data. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`status`](InfiniteQueryObserverBaseResult.md#status) diff --git a/docs/framework/svelte/reference/interfaces/InfiniteQueryPageParamsOptions.md b/docs/framework/svelte/reference/interfaces/InfiniteQueryPageParamsOptions.md new file mode 100644 index 00000000000..c091cc15456 --- /dev/null +++ b/docs/framework/svelte/reference/interfaces/InfiniteQueryPageParamsOptions.md @@ -0,0 +1,64 @@ +--- +id: InfiniteQueryPageParamsOptions +title: InfiniteQueryPageParamsOptions +--- + +Defined in: [packages/query-core/src/types.ts:352](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L352) + +## Extends + +- [`InitialPageParam`](InitialPageParam.md)\<`TPageParam`\> + +## Extended by + +- [`InfiniteQueryObserverOptions`](InfiniteQueryObserverOptions.md) + +## Type Parameters + +### TQueryFnData + +`TQueryFnData` = `unknown` + +### TPageParam + +`TPageParam` = `unknown` + +## Properties + +### getNextPageParam + +```ts +getNextPageParam: GetNextPageParamFunction; +``` + +Defined in: [packages/query-core/src/types.ts:365](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L365) + +This function can be set to automatically get the next cursor for infinite queries. +The result will also be used to determine the value of `hasNextPage`. + +*** + +### getPreviousPageParam? + +```ts +optional getPreviousPageParam: GetPreviousPageParamFunction; +``` + +Defined in: [packages/query-core/src/types.ts:360](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L360) + +This function can be set to automatically get the previous cursor for infinite queries. +The result will also be used to determine the value of `hasPreviousPage`. + +*** + +### initialPageParam + +```ts +initialPageParam: TPageParam; +``` + +Defined in: [packages/query-core/src/types.ts:349](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L349) + +#### Inherited from + +[`InitialPageParam`](InitialPageParam.md).[`initialPageParam`](InitialPageParam.md#initialpageparam) diff --git a/docs/framework/svelte/reference/interfaces/InitialPageParam.md b/docs/framework/svelte/reference/interfaces/InitialPageParam.md new file mode 100644 index 00000000000..46d2b219ea4 --- /dev/null +++ b/docs/framework/svelte/reference/interfaces/InitialPageParam.md @@ -0,0 +1,26 @@ +--- +id: InitialPageParam +title: InitialPageParam +--- + +Defined in: [packages/query-core/src/types.ts:348](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L348) + +## Extended by + +- [`InfiniteQueryPageParamsOptions`](InfiniteQueryPageParamsOptions.md) + +## Type Parameters + +### TPageParam + +`TPageParam` = `unknown` + +## Properties + +### initialPageParam + +```ts +initialPageParam: TPageParam; +``` + +Defined in: [packages/query-core/src/types.ts:349](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L349) diff --git a/docs/framework/svelte/reference/interfaces/InvalidateOptions.md b/docs/framework/svelte/reference/interfaces/InvalidateOptions.md new file mode 100644 index 00000000000..8a81428b035 --- /dev/null +++ b/docs/framework/svelte/reference/interfaces/InvalidateOptions.md @@ -0,0 +1,49 @@ +--- +id: InvalidateOptions +title: InvalidateOptions +--- + +Defined in: [packages/query-core/src/types.ts:734](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L734) + +## Extends + +- [`RefetchOptions`](RefetchOptions.md) + +## Properties + +### cancelRefetch? + +```ts +optional cancelRefetch: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:712](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L712) + +If set to `true`, a currently running request will be cancelled before a new request is made + +If set to `false`, no refetch will be made if there is already a request running. + +Defaults to `true`. + +#### Inherited from + +[`RefetchOptions`](RefetchOptions.md).[`cancelRefetch`](RefetchOptions.md#cancelrefetch) + +*** + +### throwOnError? + +```ts +optional throwOnError: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:701](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L701) + +If set to `true`, the method throws if any of the underlying query refetch tasks fail. + +Defaults to `false`, in which case failed refetches are swallowed and not surfaced to the +caller. + +#### Inherited from + +[`RefetchOptions`](RefetchOptions.md).[`throwOnError`](RefetchOptions.md#throwonerror) diff --git a/docs/framework/svelte/reference/interfaces/InvalidateQueryFilters.md b/docs/framework/svelte/reference/interfaces/InvalidateQueryFilters.md new file mode 100644 index 00000000000..569e42a4e1b --- /dev/null +++ b/docs/framework/svelte/reference/interfaces/InvalidateQueryFilters.md @@ -0,0 +1,145 @@ +--- +id: InvalidateQueryFilters +title: InvalidateQueryFilters +--- + +Defined in: [packages/query-core/src/types.ts:715](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L715) + +Filters used to select queries, for example in `queryClient.getQueriesData` or `queryClient.invalidateQueries`. +All provided filters must match; filters that are left unspecified are ignored. + +## Extends + +- [`QueryFilters`](QueryFilters.md)\<`TQueryKey`\> + +## Type Parameters + +### TQueryKey + +`TQueryKey` *extends* [`QueryKey`](../type-aliases/QueryKey.md) = [`QueryKey`](../type-aliases/QueryKey.md) + +## Properties + +### exact? + +```ts +optional exact: boolean; +``` + +Defined in: [packages/query-core/src/utils.ts:41](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L41) + +Match query key exactly + +#### Inherited from + +[`QueryFilters`](QueryFilters.md).[`exact`](QueryFilters.md#exact) + +*** + +### fetchStatus? + +```ts +optional fetchStatus: FetchStatus; +``` + +Defined in: [packages/query-core/src/utils.ts:57](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L57) + +Include queries matching their fetchStatus + +#### Inherited from + +[`QueryFilters`](QueryFilters.md).[`fetchStatus`](QueryFilters.md#fetchstatus) + +*** + +### predicate()? + +```ts +optional predicate: (query) => boolean; +``` + +Defined in: [packages/query-core/src/utils.ts:45](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L45) + +Include queries matching this predicate function + +#### Parameters + +##### query + +[`Query`](../classes/Query.md) + +#### Returns + +`boolean` + +#### Inherited from + +[`QueryFilters`](QueryFilters.md).[`predicate`](QueryFilters.md#predicate) + +*** + +### queryKey? + +```ts +optional queryKey: TQueryKey | TuplePrefixes; +``` + +Defined in: [packages/query-core/src/utils.ts:49](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L49) + +Include queries matching this query key + +#### Inherited from + +[`QueryFilters`](QueryFilters.md).[`queryKey`](QueryFilters.md#querykey) + +*** + +### refetchType? + +```ts +optional refetchType: QueryTypeFilter | "none"; +``` + +Defined in: [packages/query-core/src/types.ts:727](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L727) + +Controls which of the matched (now-invalidated) queries are refetched in the background. + +Defaults to `'active'`. +- `'active'`: only queries with at least one active observer are refetched. +- `'inactive'`: only queries with no active observer are refetched. +- `'all'`: every matched query is refetched, active or not. +- `'none'`: no query is refetched; matched queries are only marked as invalidated. + +*** + +### stale? + +```ts +optional stale: boolean; +``` + +Defined in: [packages/query-core/src/utils.ts:53](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L53) + +Include or exclude stale queries + +#### Inherited from + +[`QueryFilters`](QueryFilters.md).[`stale`](QueryFilters.md#stale) + +*** + +### type? + +```ts +optional type: QueryTypeFilter; +``` + +Defined in: [packages/query-core/src/utils.ts:37](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L37) + +Filter to active queries, inactive queries or all queries + +Defaults to `'all'`. + +#### Inherited from + +[`QueryFilters`](QueryFilters.md).[`type`](QueryFilters.md#type) diff --git a/docs/framework/svelte/reference/interfaces/MutateOptions.md b/docs/framework/svelte/reference/interfaces/MutateOptions.md new file mode 100644 index 00000000000..34e2a4d4d7e --- /dev/null +++ b/docs/framework/svelte/reference/interfaces/MutateOptions.md @@ -0,0 +1,124 @@ +--- +id: MutateOptions +title: MutateOptions +--- + +Defined in: [packages/query-core/src/types.ts:1284](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1284) + +## Type Parameters + +### TData + +`TData` = `unknown` + +### TError + +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) + +### TVariables + +`TVariables` = `void` + +### TOnMutateResult + +`TOnMutateResult` = `unknown` + +## Properties + +### onError()? + +```ts +optional onError: (error, variables, onMutateResult, context) => void; +``` + +Defined in: [packages/query-core/src/types.ts:1296](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1296) + +#### Parameters + +##### error + +`TError` + +##### variables + +`TVariables` + +##### onMutateResult + +`TOnMutateResult` | `undefined` + +##### context + +[`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md) + +#### Returns + +`void` + +*** + +### onSettled()? + +```ts +optional onSettled: (data, error, variables, onMutateResult, context) => void; +``` + +Defined in: [packages/query-core/src/types.ts:1302](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1302) + +#### Parameters + +##### data + +`TData` | `undefined` + +##### error + +`TError` | `null` + +##### variables + +`TVariables` + +##### onMutateResult + +`TOnMutateResult` | `undefined` + +##### context + +[`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md) + +#### Returns + +`void` + +*** + +### onSuccess()? + +```ts +optional onSuccess: (data, variables, onMutateResult, context) => void; +``` + +Defined in: [packages/query-core/src/types.ts:1290](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1290) + +#### Parameters + +##### data + +`TData` + +##### variables + +`TVariables` + +##### onMutateResult + +`TOnMutateResult` | `undefined` + +##### context + +[`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md) + +#### Returns + +`void` diff --git a/docs/framework/svelte/reference/interfaces/MutationCacheConfig.md b/docs/framework/svelte/reference/interfaces/MutationCacheConfig.md new file mode 100644 index 00000000000..c38d2dc26f4 --- /dev/null +++ b/docs/framework/svelte/reference/interfaces/MutationCacheConfig.md @@ -0,0 +1,161 @@ +--- +id: MutationCacheConfig +title: MutationCacheConfig +--- + +Defined in: [packages/query-core/src/mutationCache.ts:26](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationCache.ts#L26) + +Global callbacks that fire for every mutation handled by a `MutationCache`, regardless of which +component or observer triggered it. They differ from the `defaultOptions` provided to a +`QueryClient` in two ways: `defaultOptions` can be overridden by each mutation, while these +callbacks are always called, and `onMutate` here does not allow returning a result. + +If a callback returns a promise, it will be awaited before the mutation continues. + +## Properties + +### onError()? + +```ts +optional onError: (error, variables, onMutateResult, mutation, context) => unknown; +``` + +Defined in: [packages/query-core/src/mutationCache.ts:28](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationCache.ts#L28) + +Called when any mutation in the cache encounters an error. + +#### Parameters + +##### error + +`Error` + +##### variables + +`unknown` + +##### onMutateResult + +`unknown` + +##### mutation + +[`Mutation`](../classes/Mutation.md)\<`unknown`, `unknown`, `unknown`\> + +##### context + +[`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md) + +#### Returns + +`unknown` + +*** + +### onMutate()? + +```ts +optional onMutate: (variables, mutation, context) => unknown; +``` + +Defined in: [packages/query-core/src/mutationCache.ts:44](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationCache.ts#L44) + +Called before any mutation in the cache executes. + +#### Parameters + +##### variables + +`unknown` + +##### mutation + +[`Mutation`](../classes/Mutation.md)\<`unknown`, `unknown`, `unknown`\> + +##### context + +[`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md) + +#### Returns + +`unknown` + +*** + +### onSettled()? + +```ts +optional onSettled: (data, error, variables, onMutateResult, mutation, context) => unknown; +``` + +Defined in: [packages/query-core/src/mutationCache.ts:50](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationCache.ts#L50) + +Called when any mutation in the cache is settled, either successfully or with an error. + +#### Parameters + +##### data + +`unknown` + +##### error + +`Error` | `null` + +##### variables + +`unknown` + +##### onMutateResult + +`unknown` + +##### mutation + +[`Mutation`](../classes/Mutation.md)\<`unknown`, `unknown`, `unknown`\> + +##### context + +[`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md) + +#### Returns + +`unknown` + +*** + +### onSuccess()? + +```ts +optional onSuccess: (data, variables, onMutateResult, mutation, context) => unknown; +``` + +Defined in: [packages/query-core/src/mutationCache.ts:36](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationCache.ts#L36) + +Called when any mutation in the cache is successful. + +#### Parameters + +##### data + +`unknown` + +##### variables + +`unknown` + +##### onMutateResult + +`unknown` + +##### mutation + +[`Mutation`](../classes/Mutation.md)\<`unknown`, `unknown`, `unknown`\> + +##### context + +[`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md) + +#### Returns + +`unknown` diff --git a/docs/framework/svelte/reference/interfaces/MutationFilters.md b/docs/framework/svelte/reference/interfaces/MutationFilters.md new file mode 100644 index 00000000000..fbc0208e8e1 --- /dev/null +++ b/docs/framework/svelte/reference/interfaces/MutationFilters.md @@ -0,0 +1,85 @@ +--- +id: MutationFilters +title: MutationFilters +--- + +Defined in: [packages/query-core/src/utils.ts:64](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L64) + +Filters used to select mutations, for example in `mutationCache.findAll` or `queryClient.isMutating`. +All provided filters must match; filters that are left unspecified are ignored. + +## Type Parameters + +### TData + +`TData` = `unknown` + +### TError + +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) + +### TVariables + +`TVariables` = `unknown` + +### TOnMutateResult + +`TOnMutateResult` = `unknown` + +## Properties + +### exact? + +```ts +optional exact: boolean; +``` + +Defined in: [packages/query-core/src/utils.ts:73](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L73) + +Match mutation key exactly + +*** + +### mutationKey? + +```ts +optional mutationKey: readonly unknown[]; +``` + +Defined in: [packages/query-core/src/utils.ts:83](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L83) + +Include mutations matching this mutation key + +*** + +### predicate()? + +```ts +optional predicate: (mutation) => boolean; +``` + +Defined in: [packages/query-core/src/utils.ts:77](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L77) + +Include mutations matching this predicate function + +#### Parameters + +##### mutation + +[`Mutation`](../classes/Mutation.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\> + +#### Returns + +`boolean` + +*** + +### status? + +```ts +optional status: MutationStatus; +``` + +Defined in: [packages/query-core/src/utils.ts:87](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L87) + +Filter by mutation status diff --git a/docs/framework/svelte/reference/interfaces/MutationObserverBaseResult.md b/docs/framework/svelte/reference/interfaces/MutationObserverBaseResult.md new file mode 100644 index 00000000000..340a38cc9cc --- /dev/null +++ b/docs/framework/svelte/reference/interfaces/MutationObserverBaseResult.md @@ -0,0 +1,291 @@ +--- +id: MutationObserverBaseResult +title: MutationObserverBaseResult +--- + +Defined in: [packages/query-core/src/types.ts:1335](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1335) + +The raw state stored on a `Mutation` instance. This is the underlying state +that observer results (e.g. `MutationObserverResult`) are derived from. + +## Extends + +- [`MutationState`](MutationState.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\> + +## Extended by + +- [`MutationObserverIdleResult`](MutationObserverIdleResult.md) +- [`MutationObserverLoadingResult`](MutationObserverLoadingResult.md) +- [`MutationObserverErrorResult`](MutationObserverErrorResult.md) +- [`MutationObserverSuccessResult`](MutationObserverSuccessResult.md) + +## Type Parameters + +### TData + +`TData` = `unknown` + +### TError + +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) + +### TVariables + +`TVariables` = `void` + +### TOnMutateResult + +`TOnMutateResult` = `unknown` + +## Properties + +### context + +```ts +context: TOnMutateResult | undefined; +``` + +Defined in: [packages/query-core/src/mutation.ts:40](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L40) + +The value returned by `onMutate`, if defined. Passed to `onSuccess`, +`onError` and `onSettled` as the mutation's context. + +#### Inherited from + +[`MutationState`](MutationState.md).[`context`](MutationState.md#context) + +*** + +### data + +```ts +data: TData | undefined; +``` + +Defined in: [packages/query-core/src/types.ts:1344](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1344) + +The last successfully resolved data for the mutation. + +#### Overrides + +[`MutationState`](MutationState.md).[`data`](MutationState.md#data) + +*** + +### error + +```ts +error: TError | null; +``` + +Defined in: [packages/query-core/src/types.ts:1353](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1353) + +The error object for the mutation, if an error was encountered. +- Defaults to `null`. + +#### Overrides + +[`MutationState`](MutationState.md).[`error`](MutationState.md#error) + +*** + +### failureCount + +```ts +failureCount: number; +``` + +Defined in: [packages/query-core/src/mutation.ts:53](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L53) + +The number of times the mutation function has failed for the current attempt. + +#### Inherited from + +[`MutationState`](MutationState.md).[`failureCount`](MutationState.md#failurecount) + +*** + +### failureReason + +```ts +failureReason: TError | null; +``` + +Defined in: [packages/query-core/src/mutation.ts:57](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L57) + +The reason the current attempt failed, as reported by the retryer. + +#### Inherited from + +[`MutationState`](MutationState.md).[`failureReason`](MutationState.md#failurereason) + +*** + +### isError + +```ts +isError: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1358](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1358) + +A boolean variable derived from `status`. +- `true` if the last mutation attempt resulted in an error. + +*** + +### isIdle + +```ts +isIdle: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1363](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1363) + +A boolean variable derived from `status`. +- `true` if the mutation is in its initial state prior to executing. + +*** + +### isPaused + +```ts +isPaused: boolean; +``` + +Defined in: [packages/query-core/src/mutation.ts:62](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L62) + +Whether the mutation is currently paused (see network mode), or is +waiting for another mutation with the same `scope` to finish. + +#### Inherited from + +[`MutationState`](MutationState.md).[`isPaused`](MutationState.md#ispaused) + +*** + +### isPending + +```ts +isPending: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1368](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1368) + +A boolean variable derived from `status`. +- `true` if the mutation is currently executing. + +*** + +### isSuccess + +```ts +isSuccess: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1373](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1373) + +A boolean variable derived from `status`. +- `true` if the last mutation attempt was successful. + +*** + +### mutate + +```ts +mutate: MutateFunction; +``` + +Defined in: [packages/query-core/src/types.ts:1393](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1393) + +The mutation function you can call with variables to trigger the mutation and optionally hooks on additional callback options. + +#### Param + +The variables object to pass to the `mutationFn`. + +#### Param + +This function will fire when the mutation is successful and will be passed the mutation's result. + +#### Param + +This function will fire if the mutation encounters an error and will be passed the error. + +#### Param + +This function will fire when the mutation is either successfully fetched or encounters an error and be passed either the data or error. + +#### Remarks + +- If you make multiple requests, `onSuccess` will fire only after the latest call you've made. +- All the callback functions (`onSuccess`, `onError`, `onSettled`) are void functions, and the returned value will be ignored. + +*** + +### reset() + +```ts +reset: () => void; +``` + +Defined in: [packages/query-core/src/types.ts:1397](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1397) + +A function to clean the mutation internal state (i.e., it resets the mutation to its initial state). + +#### Returns + +`void` + +*** + +### status + +```ts +status: MutationStatus; +``` + +Defined in: [packages/query-core/src/types.ts:1382](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1382) + +The status of the mutation. +- Will be: + - `idle` initial status prior to the mutation function executing. + - `pending` if the mutation is currently executing. + - `error` if the last mutation attempt resulted in an error. + - `success` if the last mutation attempt was successful. + +#### Overrides + +[`MutationState`](MutationState.md).[`status`](MutationState.md#status) + +*** + +### submittedAt + +```ts +submittedAt: number; +``` + +Defined in: [packages/query-core/src/mutation.ts:74](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L74) + +The timestamp for when the mutation was submitted. + +#### Inherited from + +[`MutationState`](MutationState.md).[`submittedAt`](MutationState.md#submittedat) + +*** + +### variables + +```ts +variables: TVariables | undefined; +``` + +Defined in: [packages/query-core/src/types.ts:1348](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1348) + +The variables object passed to the `mutationFn`. + +#### Overrides + +[`MutationState`](MutationState.md).[`variables`](MutationState.md#variables) diff --git a/docs/framework/svelte/reference/interfaces/MutationObserverErrorResult.md b/docs/framework/svelte/reference/interfaces/MutationObserverErrorResult.md new file mode 100644 index 00000000000..72e459a2e0b --- /dev/null +++ b/docs/framework/svelte/reference/interfaces/MutationObserverErrorResult.md @@ -0,0 +1,308 @@ +--- +id: MutationObserverErrorResult +title: MutationObserverErrorResult +--- + +Defined in: [packages/query-core/src/types.ts:1442](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1442) + +The raw state stored on a `Mutation` instance. This is the underlying state +that observer results (e.g. `MutationObserverResult`) are derived from. + +## Extends + +- [`MutationObserverBaseResult`](MutationObserverBaseResult.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\> + +## Type Parameters + +### TData + +`TData` = `unknown` + +### TError + +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) + +### TVariables + +`TVariables` = `void` + +### TOnMutateResult + +`TOnMutateResult` = `unknown` + +## Properties + +### context + +```ts +context: TOnMutateResult | undefined; +``` + +Defined in: [packages/query-core/src/mutation.ts:40](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L40) + +The value returned by `onMutate`, if defined. Passed to `onSuccess`, +`onError` and `onSettled` as the mutation's context. + +#### Inherited from + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`context`](MutationObserverBaseResult.md#context) + +*** + +### data + +```ts +data: undefined; +``` + +Defined in: [packages/query-core/src/types.ts:1453](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1453) + +The last successfully resolved data for the mutation. + +#### Overrides + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`data`](MutationObserverBaseResult.md#data) + +*** + +### error + +```ts +error: TError; +``` + +Defined in: [packages/query-core/src/types.ts:1454](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1454) + +The error object for the mutation, if an error was encountered. +- Defaults to `null`. + +#### Overrides + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`error`](MutationObserverBaseResult.md#error) + +*** + +### failureCount + +```ts +failureCount: number; +``` + +Defined in: [packages/query-core/src/mutation.ts:53](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L53) + +The number of times the mutation function has failed for the current attempt. + +#### Inherited from + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`failureCount`](MutationObserverBaseResult.md#failurecount) + +*** + +### failureReason + +```ts +failureReason: TError | null; +``` + +Defined in: [packages/query-core/src/mutation.ts:57](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L57) + +The reason the current attempt failed, as reported by the retryer. + +#### Inherited from + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`failureReason`](MutationObserverBaseResult.md#failurereason) + +*** + +### isError + +```ts +isError: true; +``` + +Defined in: [packages/query-core/src/types.ts:1456](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1456) + +A boolean variable derived from `status`. +- `true` if the last mutation attempt resulted in an error. + +#### Overrides + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isError`](MutationObserverBaseResult.md#iserror) + +*** + +### isIdle + +```ts +isIdle: false; +``` + +Defined in: [packages/query-core/src/types.ts:1457](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1457) + +A boolean variable derived from `status`. +- `true` if the mutation is in its initial state prior to executing. + +#### Overrides + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isIdle`](MutationObserverBaseResult.md#isidle) + +*** + +### isPaused + +```ts +isPaused: boolean; +``` + +Defined in: [packages/query-core/src/mutation.ts:62](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L62) + +Whether the mutation is currently paused (see network mode), or is +waiting for another mutation with the same `scope` to finish. + +#### Inherited from + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isPaused`](MutationObserverBaseResult.md#ispaused) + +*** + +### isPending + +```ts +isPending: false; +``` + +Defined in: [packages/query-core/src/types.ts:1458](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1458) + +A boolean variable derived from `status`. +- `true` if the mutation is currently executing. + +#### Overrides + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isPending`](MutationObserverBaseResult.md#ispending) + +*** + +### isSuccess + +```ts +isSuccess: false; +``` + +Defined in: [packages/query-core/src/types.ts:1459](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1459) + +A boolean variable derived from `status`. +- `true` if the last mutation attempt was successful. + +#### Overrides + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isSuccess`](MutationObserverBaseResult.md#issuccess) + +*** + +### mutate + +```ts +mutate: MutateFunction; +``` + +Defined in: [packages/query-core/src/types.ts:1393](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1393) + +The mutation function you can call with variables to trigger the mutation and optionally hooks on additional callback options. + +#### Param + +The variables object to pass to the `mutationFn`. + +#### Param + +This function will fire when the mutation is successful and will be passed the mutation's result. + +#### Param + +This function will fire if the mutation encounters an error and will be passed the error. + +#### Param + +This function will fire when the mutation is either successfully fetched or encounters an error and be passed either the data or error. + +#### Remarks + +- If you make multiple requests, `onSuccess` will fire only after the latest call you've made. +- All the callback functions (`onSuccess`, `onError`, `onSettled`) are void functions, and the returned value will be ignored. + +#### Inherited from + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`mutate`](MutationObserverBaseResult.md#mutate) + +*** + +### reset() + +```ts +reset: () => void; +``` + +Defined in: [packages/query-core/src/types.ts:1397](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1397) + +A function to clean the mutation internal state (i.e., it resets the mutation to its initial state). + +#### Returns + +`void` + +#### Inherited from + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`reset`](MutationObserverBaseResult.md#reset) + +*** + +### status + +```ts +status: "error"; +``` + +Defined in: [packages/query-core/src/types.ts:1460](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1460) + +The status of the mutation. +- Will be: + - `idle` initial status prior to the mutation function executing. + - `pending` if the mutation is currently executing. + - `error` if the last mutation attempt resulted in an error. + - `success` if the last mutation attempt was successful. + +#### Overrides + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`status`](MutationObserverBaseResult.md#status) + +*** + +### submittedAt + +```ts +submittedAt: number; +``` + +Defined in: [packages/query-core/src/mutation.ts:74](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L74) + +The timestamp for when the mutation was submitted. + +#### Inherited from + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`submittedAt`](MutationObserverBaseResult.md#submittedat) + +*** + +### variables + +```ts +variables: TVariables; +``` + +Defined in: [packages/query-core/src/types.ts:1455](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1455) + +The variables object passed to the `mutationFn`. + +#### Overrides + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`variables`](MutationObserverBaseResult.md#variables) diff --git a/docs/framework/svelte/reference/interfaces/MutationObserverIdleResult.md b/docs/framework/svelte/reference/interfaces/MutationObserverIdleResult.md new file mode 100644 index 00000000000..cd8d6eb3130 --- /dev/null +++ b/docs/framework/svelte/reference/interfaces/MutationObserverIdleResult.md @@ -0,0 +1,308 @@ +--- +id: MutationObserverIdleResult +title: MutationObserverIdleResult +--- + +Defined in: [packages/query-core/src/types.ts:1400](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1400) + +The raw state stored on a `Mutation` instance. This is the underlying state +that observer results (e.g. `MutationObserverResult`) are derived from. + +## Extends + +- [`MutationObserverBaseResult`](MutationObserverBaseResult.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\> + +## Type Parameters + +### TData + +`TData` = `unknown` + +### TError + +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) + +### TVariables + +`TVariables` = `void` + +### TOnMutateResult + +`TOnMutateResult` = `unknown` + +## Properties + +### context + +```ts +context: TOnMutateResult | undefined; +``` + +Defined in: [packages/query-core/src/mutation.ts:40](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L40) + +The value returned by `onMutate`, if defined. Passed to `onSuccess`, +`onError` and `onSettled` as the mutation's context. + +#### Inherited from + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`context`](MutationObserverBaseResult.md#context) + +*** + +### data + +```ts +data: undefined; +``` + +Defined in: [packages/query-core/src/types.ts:1411](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1411) + +The last successfully resolved data for the mutation. + +#### Overrides + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`data`](MutationObserverBaseResult.md#data) + +*** + +### error + +```ts +error: null; +``` + +Defined in: [packages/query-core/src/types.ts:1413](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1413) + +The error object for the mutation, if an error was encountered. +- Defaults to `null`. + +#### Overrides + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`error`](MutationObserverBaseResult.md#error) + +*** + +### failureCount + +```ts +failureCount: number; +``` + +Defined in: [packages/query-core/src/mutation.ts:53](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L53) + +The number of times the mutation function has failed for the current attempt. + +#### Inherited from + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`failureCount`](MutationObserverBaseResult.md#failurecount) + +*** + +### failureReason + +```ts +failureReason: TError | null; +``` + +Defined in: [packages/query-core/src/mutation.ts:57](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L57) + +The reason the current attempt failed, as reported by the retryer. + +#### Inherited from + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`failureReason`](MutationObserverBaseResult.md#failurereason) + +*** + +### isError + +```ts +isError: false; +``` + +Defined in: [packages/query-core/src/types.ts:1414](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1414) + +A boolean variable derived from `status`. +- `true` if the last mutation attempt resulted in an error. + +#### Overrides + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isError`](MutationObserverBaseResult.md#iserror) + +*** + +### isIdle + +```ts +isIdle: true; +``` + +Defined in: [packages/query-core/src/types.ts:1415](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1415) + +A boolean variable derived from `status`. +- `true` if the mutation is in its initial state prior to executing. + +#### Overrides + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isIdle`](MutationObserverBaseResult.md#isidle) + +*** + +### isPaused + +```ts +isPaused: boolean; +``` + +Defined in: [packages/query-core/src/mutation.ts:62](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L62) + +Whether the mutation is currently paused (see network mode), or is +waiting for another mutation with the same `scope` to finish. + +#### Inherited from + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isPaused`](MutationObserverBaseResult.md#ispaused) + +*** + +### isPending + +```ts +isPending: false; +``` + +Defined in: [packages/query-core/src/types.ts:1416](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1416) + +A boolean variable derived from `status`. +- `true` if the mutation is currently executing. + +#### Overrides + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isPending`](MutationObserverBaseResult.md#ispending) + +*** + +### isSuccess + +```ts +isSuccess: false; +``` + +Defined in: [packages/query-core/src/types.ts:1417](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1417) + +A boolean variable derived from `status`. +- `true` if the last mutation attempt was successful. + +#### Overrides + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isSuccess`](MutationObserverBaseResult.md#issuccess) + +*** + +### mutate + +```ts +mutate: MutateFunction; +``` + +Defined in: [packages/query-core/src/types.ts:1393](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1393) + +The mutation function you can call with variables to trigger the mutation and optionally hooks on additional callback options. + +#### Param + +The variables object to pass to the `mutationFn`. + +#### Param + +This function will fire when the mutation is successful and will be passed the mutation's result. + +#### Param + +This function will fire if the mutation encounters an error and will be passed the error. + +#### Param + +This function will fire when the mutation is either successfully fetched or encounters an error and be passed either the data or error. + +#### Remarks + +- If you make multiple requests, `onSuccess` will fire only after the latest call you've made. +- All the callback functions (`onSuccess`, `onError`, `onSettled`) are void functions, and the returned value will be ignored. + +#### Inherited from + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`mutate`](MutationObserverBaseResult.md#mutate) + +*** + +### reset() + +```ts +reset: () => void; +``` + +Defined in: [packages/query-core/src/types.ts:1397](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1397) + +A function to clean the mutation internal state (i.e., it resets the mutation to its initial state). + +#### Returns + +`void` + +#### Inherited from + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`reset`](MutationObserverBaseResult.md#reset) + +*** + +### status + +```ts +status: "idle"; +``` + +Defined in: [packages/query-core/src/types.ts:1418](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1418) + +The status of the mutation. +- Will be: + - `idle` initial status prior to the mutation function executing. + - `pending` if the mutation is currently executing. + - `error` if the last mutation attempt resulted in an error. + - `success` if the last mutation attempt was successful. + +#### Overrides + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`status`](MutationObserverBaseResult.md#status) + +*** + +### submittedAt + +```ts +submittedAt: number; +``` + +Defined in: [packages/query-core/src/mutation.ts:74](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L74) + +The timestamp for when the mutation was submitted. + +#### Inherited from + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`submittedAt`](MutationObserverBaseResult.md#submittedat) + +*** + +### variables + +```ts +variables: undefined; +``` + +Defined in: [packages/query-core/src/types.ts:1412](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1412) + +The variables object passed to the `mutationFn`. + +#### Overrides + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`variables`](MutationObserverBaseResult.md#variables) diff --git a/docs/framework/svelte/reference/interfaces/MutationObserverLoadingResult.md b/docs/framework/svelte/reference/interfaces/MutationObserverLoadingResult.md new file mode 100644 index 00000000000..9b70a8558e7 --- /dev/null +++ b/docs/framework/svelte/reference/interfaces/MutationObserverLoadingResult.md @@ -0,0 +1,308 @@ +--- +id: MutationObserverLoadingResult +title: MutationObserverLoadingResult +--- + +Defined in: [packages/query-core/src/types.ts:1421](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1421) + +The raw state stored on a `Mutation` instance. This is the underlying state +that observer results (e.g. `MutationObserverResult`) are derived from. + +## Extends + +- [`MutationObserverBaseResult`](MutationObserverBaseResult.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\> + +## Type Parameters + +### TData + +`TData` = `unknown` + +### TError + +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) + +### TVariables + +`TVariables` = `void` + +### TOnMutateResult + +`TOnMutateResult` = `unknown` + +## Properties + +### context + +```ts +context: TOnMutateResult | undefined; +``` + +Defined in: [packages/query-core/src/mutation.ts:40](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L40) + +The value returned by `onMutate`, if defined. Passed to `onSuccess`, +`onError` and `onSettled` as the mutation's context. + +#### Inherited from + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`context`](MutationObserverBaseResult.md#context) + +*** + +### data + +```ts +data: undefined; +``` + +Defined in: [packages/query-core/src/types.ts:1432](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1432) + +The last successfully resolved data for the mutation. + +#### Overrides + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`data`](MutationObserverBaseResult.md#data) + +*** + +### error + +```ts +error: null; +``` + +Defined in: [packages/query-core/src/types.ts:1434](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1434) + +The error object for the mutation, if an error was encountered. +- Defaults to `null`. + +#### Overrides + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`error`](MutationObserverBaseResult.md#error) + +*** + +### failureCount + +```ts +failureCount: number; +``` + +Defined in: [packages/query-core/src/mutation.ts:53](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L53) + +The number of times the mutation function has failed for the current attempt. + +#### Inherited from + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`failureCount`](MutationObserverBaseResult.md#failurecount) + +*** + +### failureReason + +```ts +failureReason: TError | null; +``` + +Defined in: [packages/query-core/src/mutation.ts:57](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L57) + +The reason the current attempt failed, as reported by the retryer. + +#### Inherited from + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`failureReason`](MutationObserverBaseResult.md#failurereason) + +*** + +### isError + +```ts +isError: false; +``` + +Defined in: [packages/query-core/src/types.ts:1435](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1435) + +A boolean variable derived from `status`. +- `true` if the last mutation attempt resulted in an error. + +#### Overrides + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isError`](MutationObserverBaseResult.md#iserror) + +*** + +### isIdle + +```ts +isIdle: false; +``` + +Defined in: [packages/query-core/src/types.ts:1436](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1436) + +A boolean variable derived from `status`. +- `true` if the mutation is in its initial state prior to executing. + +#### Overrides + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isIdle`](MutationObserverBaseResult.md#isidle) + +*** + +### isPaused + +```ts +isPaused: boolean; +``` + +Defined in: [packages/query-core/src/mutation.ts:62](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L62) + +Whether the mutation is currently paused (see network mode), or is +waiting for another mutation with the same `scope` to finish. + +#### Inherited from + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isPaused`](MutationObserverBaseResult.md#ispaused) + +*** + +### isPending + +```ts +isPending: true; +``` + +Defined in: [packages/query-core/src/types.ts:1437](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1437) + +A boolean variable derived from `status`. +- `true` if the mutation is currently executing. + +#### Overrides + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isPending`](MutationObserverBaseResult.md#ispending) + +*** + +### isSuccess + +```ts +isSuccess: false; +``` + +Defined in: [packages/query-core/src/types.ts:1438](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1438) + +A boolean variable derived from `status`. +- `true` if the last mutation attempt was successful. + +#### Overrides + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isSuccess`](MutationObserverBaseResult.md#issuccess) + +*** + +### mutate + +```ts +mutate: MutateFunction; +``` + +Defined in: [packages/query-core/src/types.ts:1393](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1393) + +The mutation function you can call with variables to trigger the mutation and optionally hooks on additional callback options. + +#### Param + +The variables object to pass to the `mutationFn`. + +#### Param + +This function will fire when the mutation is successful and will be passed the mutation's result. + +#### Param + +This function will fire if the mutation encounters an error and will be passed the error. + +#### Param + +This function will fire when the mutation is either successfully fetched or encounters an error and be passed either the data or error. + +#### Remarks + +- If you make multiple requests, `onSuccess` will fire only after the latest call you've made. +- All the callback functions (`onSuccess`, `onError`, `onSettled`) are void functions, and the returned value will be ignored. + +#### Inherited from + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`mutate`](MutationObserverBaseResult.md#mutate) + +*** + +### reset() + +```ts +reset: () => void; +``` + +Defined in: [packages/query-core/src/types.ts:1397](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1397) + +A function to clean the mutation internal state (i.e., it resets the mutation to its initial state). + +#### Returns + +`void` + +#### Inherited from + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`reset`](MutationObserverBaseResult.md#reset) + +*** + +### status + +```ts +status: "pending"; +``` + +Defined in: [packages/query-core/src/types.ts:1439](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1439) + +The status of the mutation. +- Will be: + - `idle` initial status prior to the mutation function executing. + - `pending` if the mutation is currently executing. + - `error` if the last mutation attempt resulted in an error. + - `success` if the last mutation attempt was successful. + +#### Overrides + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`status`](MutationObserverBaseResult.md#status) + +*** + +### submittedAt + +```ts +submittedAt: number; +``` + +Defined in: [packages/query-core/src/mutation.ts:74](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L74) + +The timestamp for when the mutation was submitted. + +#### Inherited from + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`submittedAt`](MutationObserverBaseResult.md#submittedat) + +*** + +### variables + +```ts +variables: TVariables; +``` + +Defined in: [packages/query-core/src/types.ts:1433](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1433) + +The variables object passed to the `mutationFn`. + +#### Overrides + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`variables`](MutationObserverBaseResult.md#variables) diff --git a/docs/framework/svelte/reference/interfaces/MutationObserverOptions.md b/docs/framework/svelte/reference/interfaces/MutationObserverOptions.md new file mode 100644 index 00000000000..5bab2840a6d --- /dev/null +++ b/docs/framework/svelte/reference/interfaces/MutationObserverOptions.md @@ -0,0 +1,322 @@ +--- +id: MutationObserverOptions +title: MutationObserverOptions +--- + +Defined in: [packages/query-core/src/types.ts:1267](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1267) + +## Extends + +- [`MutationOptions`](MutationOptions.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\> + +## Type Parameters + +### TData + +`TData` = `unknown` + +### TError + +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) + +### TVariables + +`TVariables` = `void` + +### TOnMutateResult + +`TOnMutateResult` = `unknown` + +## Properties + +### gcTime? + +```ts +optional gcTime: number; +``` + +Defined in: [packages/query-core/src/types.ts:1260](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1260) + +The time in milliseconds that an unused/inactive mutation remains in memory before it is +garbage collected. + +Defaults to `5 * 60 * 1000` (5 minutes), or `Infinity` during SSR. + +#### Inherited from + +[`MutationOptions`](MutationOptions.md).[`gcTime`](MutationOptions.md#gctime) + +*** + +### meta? + +```ts +optional meta: Record; +``` + +Defined in: [packages/query-core/src/types.ts:1263](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1263) + +#### Inherited from + +[`MutationOptions`](MutationOptions.md).[`meta`](MutationOptions.md#meta) + +*** + +### mutationFn? + +```ts +optional mutationFn: MutationFunction; +``` + +Defined in: [packages/query-core/src/types.ts:1206](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1206) + +#### Inherited from + +[`MutationOptions`](MutationOptions.md).[`mutationFn`](MutationOptions.md#mutationfn) + +*** + +### mutationKey? + +```ts +optional mutationKey: readonly unknown[]; +``` + +Defined in: [packages/query-core/src/types.ts:1207](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1207) + +#### Inherited from + +[`MutationOptions`](MutationOptions.md).[`mutationKey`](MutationOptions.md#mutationkey) + +*** + +### networkMode? + +```ts +optional networkMode: NetworkMode; +``` + +Defined in: [packages/query-core/src/types.ts:1253](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1253) + +Controls whether a mutation is allowed to run based on the current network connectivity. + +Defaults to `'online'`. + +#### See + +[Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. + +#### Inherited from + +[`MutationOptions`](MutationOptions.md).[`networkMode`](MutationOptions.md#networkmode) + +*** + +### onError()? + +```ts +optional onError: (error, variables, onMutateResult, context) => unknown; +``` + +Defined in: [packages/query-core/src/types.ts:1218](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1218) + +#### Parameters + +##### error + +`TError` + +##### variables + +`TVariables` + +##### onMutateResult + +`TOnMutateResult` | `undefined` + +##### context + +[`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md) + +#### Returns + +`unknown` + +#### Inherited from + +[`MutationOptions`](MutationOptions.md).[`onError`](MutationOptions.md#onerror) + +*** + +### onMutate()? + +```ts +optional onMutate: (variables, context) => TOnMutateResult | Promise; +``` + +Defined in: [packages/query-core/src/types.ts:1208](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1208) + +#### Parameters + +##### variables + +`TVariables` + +##### context + +[`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md) + +#### Returns + +`TOnMutateResult` \| `Promise`\<`TOnMutateResult`\> + +#### Inherited from + +[`MutationOptions`](MutationOptions.md).[`onMutate`](MutationOptions.md#onmutate) + +*** + +### onSettled()? + +```ts +optional onSettled: (data, error, variables, onMutateResult, context) => unknown; +``` + +Defined in: [packages/query-core/src/types.ts:1224](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1224) + +#### Parameters + +##### data + +`TData` | `undefined` + +##### error + +`TError` | `null` + +##### variables + +`TVariables` + +##### onMutateResult + +`TOnMutateResult` | `undefined` + +##### context + +[`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md) + +#### Returns + +`unknown` + +#### Inherited from + +[`MutationOptions`](MutationOptions.md).[`onSettled`](MutationOptions.md#onsettled) + +*** + +### onSuccess()? + +```ts +optional onSuccess: (data, variables, onMutateResult, context) => unknown; +``` + +Defined in: [packages/query-core/src/types.ts:1212](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1212) + +#### Parameters + +##### data + +`TData` + +##### variables + +`TVariables` + +##### onMutateResult + +`TOnMutateResult` + +##### context + +[`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md) + +#### Returns + +`unknown` + +#### Inherited from + +[`MutationOptions`](MutationOptions.md).[`onSuccess`](MutationOptions.md#onsuccess) + +*** + +### retry? + +```ts +optional retry: RetryValue; +``` + +Defined in: [packages/query-core/src/types.ts:1239](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1239) + +If `false`, failed mutations will not retry by default. +If `true`, failed mutations will retry infinitely. +If set to an integer number, e.g. 3, failed mutations will retry until the failed mutation count meets that number. +If set to a function `(failureCount, error) => boolean` failed mutations will retry until the function returns false. + +Defaults to `0`. + +#### Inherited from + +[`MutationOptions`](MutationOptions.md).[`retry`](MutationOptions.md#retry) + +*** + +### retryDelay? + +```ts +optional retryDelay: RetryDelayValue; +``` + +Defined in: [packages/query-core/src/types.ts:1246](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1246) + +This function receives a `retryAttempt` integer and the actual Error and returns the delay to apply before the +next attempt in milliseconds. + +Defaults to a function that applies exponential backoff, capped at 30 seconds. + +#### Inherited from + +[`MutationOptions`](MutationOptions.md).[`retryDelay`](MutationOptions.md#retrydelay) + +*** + +### scope? + +```ts +optional scope: MutationScope; +``` + +Defined in: [packages/query-core/src/types.ts:1264](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1264) + +#### Inherited from + +[`MutationOptions`](MutationOptions.md).[`scope`](MutationOptions.md#scope) + +*** + +### throwOnError? + +```ts +optional throwOnError: boolean | (error) => boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1281](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1281) + +Whether errors should be thrown instead of setting the `error` property. +If set to `true`, all errors will be thrown to the nearest error boundary. +If set to a function, it will be passed the error and should return a boolean indicating whether to throw the +error (`true`) or return it as state (`false`). + +Defaults to `false`. diff --git a/docs/framework/svelte/reference/interfaces/MutationObserverSuccessResult.md b/docs/framework/svelte/reference/interfaces/MutationObserverSuccessResult.md new file mode 100644 index 00000000000..e2e03642f82 --- /dev/null +++ b/docs/framework/svelte/reference/interfaces/MutationObserverSuccessResult.md @@ -0,0 +1,308 @@ +--- +id: MutationObserverSuccessResult +title: MutationObserverSuccessResult +--- + +Defined in: [packages/query-core/src/types.ts:1463](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1463) + +The raw state stored on a `Mutation` instance. This is the underlying state +that observer results (e.g. `MutationObserverResult`) are derived from. + +## Extends + +- [`MutationObserverBaseResult`](MutationObserverBaseResult.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\> + +## Type Parameters + +### TData + +`TData` = `unknown` + +### TError + +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) + +### TVariables + +`TVariables` = `void` + +### TOnMutateResult + +`TOnMutateResult` = `unknown` + +## Properties + +### context + +```ts +context: TOnMutateResult | undefined; +``` + +Defined in: [packages/query-core/src/mutation.ts:40](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L40) + +The value returned by `onMutate`, if defined. Passed to `onSuccess`, +`onError` and `onSettled` as the mutation's context. + +#### Inherited from + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`context`](MutationObserverBaseResult.md#context) + +*** + +### data + +```ts +data: TData; +``` + +Defined in: [packages/query-core/src/types.ts:1474](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1474) + +The last successfully resolved data for the mutation. + +#### Overrides + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`data`](MutationObserverBaseResult.md#data) + +*** + +### error + +```ts +error: null; +``` + +Defined in: [packages/query-core/src/types.ts:1475](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1475) + +The error object for the mutation, if an error was encountered. +- Defaults to `null`. + +#### Overrides + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`error`](MutationObserverBaseResult.md#error) + +*** + +### failureCount + +```ts +failureCount: number; +``` + +Defined in: [packages/query-core/src/mutation.ts:53](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L53) + +The number of times the mutation function has failed for the current attempt. + +#### Inherited from + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`failureCount`](MutationObserverBaseResult.md#failurecount) + +*** + +### failureReason + +```ts +failureReason: TError | null; +``` + +Defined in: [packages/query-core/src/mutation.ts:57](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L57) + +The reason the current attempt failed, as reported by the retryer. + +#### Inherited from + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`failureReason`](MutationObserverBaseResult.md#failurereason) + +*** + +### isError + +```ts +isError: false; +``` + +Defined in: [packages/query-core/src/types.ts:1477](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1477) + +A boolean variable derived from `status`. +- `true` if the last mutation attempt resulted in an error. + +#### Overrides + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isError`](MutationObserverBaseResult.md#iserror) + +*** + +### isIdle + +```ts +isIdle: false; +``` + +Defined in: [packages/query-core/src/types.ts:1478](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1478) + +A boolean variable derived from `status`. +- `true` if the mutation is in its initial state prior to executing. + +#### Overrides + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isIdle`](MutationObserverBaseResult.md#isidle) + +*** + +### isPaused + +```ts +isPaused: boolean; +``` + +Defined in: [packages/query-core/src/mutation.ts:62](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L62) + +Whether the mutation is currently paused (see network mode), or is +waiting for another mutation with the same `scope` to finish. + +#### Inherited from + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isPaused`](MutationObserverBaseResult.md#ispaused) + +*** + +### isPending + +```ts +isPending: false; +``` + +Defined in: [packages/query-core/src/types.ts:1479](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1479) + +A boolean variable derived from `status`. +- `true` if the mutation is currently executing. + +#### Overrides + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isPending`](MutationObserverBaseResult.md#ispending) + +*** + +### isSuccess + +```ts +isSuccess: true; +``` + +Defined in: [packages/query-core/src/types.ts:1480](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1480) + +A boolean variable derived from `status`. +- `true` if the last mutation attempt was successful. + +#### Overrides + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isSuccess`](MutationObserverBaseResult.md#issuccess) + +*** + +### mutate + +```ts +mutate: MutateFunction; +``` + +Defined in: [packages/query-core/src/types.ts:1393](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1393) + +The mutation function you can call with variables to trigger the mutation and optionally hooks on additional callback options. + +#### Param + +The variables object to pass to the `mutationFn`. + +#### Param + +This function will fire when the mutation is successful and will be passed the mutation's result. + +#### Param + +This function will fire if the mutation encounters an error and will be passed the error. + +#### Param + +This function will fire when the mutation is either successfully fetched or encounters an error and be passed either the data or error. + +#### Remarks + +- If you make multiple requests, `onSuccess` will fire only after the latest call you've made. +- All the callback functions (`onSuccess`, `onError`, `onSettled`) are void functions, and the returned value will be ignored. + +#### Inherited from + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`mutate`](MutationObserverBaseResult.md#mutate) + +*** + +### reset() + +```ts +reset: () => void; +``` + +Defined in: [packages/query-core/src/types.ts:1397](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1397) + +A function to clean the mutation internal state (i.e., it resets the mutation to its initial state). + +#### Returns + +`void` + +#### Inherited from + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`reset`](MutationObserverBaseResult.md#reset) + +*** + +### status + +```ts +status: "success"; +``` + +Defined in: [packages/query-core/src/types.ts:1481](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1481) + +The status of the mutation. +- Will be: + - `idle` initial status prior to the mutation function executing. + - `pending` if the mutation is currently executing. + - `error` if the last mutation attempt resulted in an error. + - `success` if the last mutation attempt was successful. + +#### Overrides + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`status`](MutationObserverBaseResult.md#status) + +*** + +### submittedAt + +```ts +submittedAt: number; +``` + +Defined in: [packages/query-core/src/mutation.ts:74](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L74) + +The timestamp for when the mutation was submitted. + +#### Inherited from + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`submittedAt`](MutationObserverBaseResult.md#submittedat) + +*** + +### variables + +```ts +variables: TVariables; +``` + +Defined in: [packages/query-core/src/types.ts:1476](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1476) + +The variables object passed to the `mutationFn`. + +#### Overrides + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`variables`](MutationObserverBaseResult.md#variables) diff --git a/docs/framework/svelte/reference/interfaces/MutationOptions.md b/docs/framework/svelte/reference/interfaces/MutationOptions.md new file mode 100644 index 00000000000..5aabeeb0ca4 --- /dev/null +++ b/docs/framework/svelte/reference/interfaces/MutationOptions.md @@ -0,0 +1,257 @@ +--- +id: MutationOptions +title: MutationOptions +--- + +Defined in: [packages/query-core/src/types.ts:1200](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1200) + +## Extended by + +- [`MutationObserverOptions`](MutationObserverOptions.md) + +## Type Parameters + +### TData + +`TData` = `unknown` + +### TError + +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) + +### TVariables + +`TVariables` = `void` + +### TOnMutateResult + +`TOnMutateResult` = `unknown` + +## Properties + +### gcTime? + +```ts +optional gcTime: number; +``` + +Defined in: [packages/query-core/src/types.ts:1260](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1260) + +The time in milliseconds that an unused/inactive mutation remains in memory before it is +garbage collected. + +Defaults to `5 * 60 * 1000` (5 minutes), or `Infinity` during SSR. + +*** + +### meta? + +```ts +optional meta: Record; +``` + +Defined in: [packages/query-core/src/types.ts:1263](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1263) + +*** + +### mutationFn? + +```ts +optional mutationFn: MutationFunction; +``` + +Defined in: [packages/query-core/src/types.ts:1206](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1206) + +*** + +### mutationKey? + +```ts +optional mutationKey: readonly unknown[]; +``` + +Defined in: [packages/query-core/src/types.ts:1207](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1207) + +*** + +### networkMode? + +```ts +optional networkMode: NetworkMode; +``` + +Defined in: [packages/query-core/src/types.ts:1253](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1253) + +Controls whether a mutation is allowed to run based on the current network connectivity. + +Defaults to `'online'`. + +#### See + +[Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. + +*** + +### onError()? + +```ts +optional onError: (error, variables, onMutateResult, context) => unknown; +``` + +Defined in: [packages/query-core/src/types.ts:1218](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1218) + +#### Parameters + +##### error + +`TError` + +##### variables + +`TVariables` + +##### onMutateResult + +`TOnMutateResult` | `undefined` + +##### context + +[`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md) + +#### Returns + +`unknown` + +*** + +### onMutate()? + +```ts +optional onMutate: (variables, context) => TOnMutateResult | Promise; +``` + +Defined in: [packages/query-core/src/types.ts:1208](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1208) + +#### Parameters + +##### variables + +`TVariables` + +##### context + +[`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md) + +#### Returns + +`TOnMutateResult` \| `Promise`\<`TOnMutateResult`\> + +*** + +### onSettled()? + +```ts +optional onSettled: (data, error, variables, onMutateResult, context) => unknown; +``` + +Defined in: [packages/query-core/src/types.ts:1224](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1224) + +#### Parameters + +##### data + +`TData` | `undefined` + +##### error + +`TError` | `null` + +##### variables + +`TVariables` + +##### onMutateResult + +`TOnMutateResult` | `undefined` + +##### context + +[`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md) + +#### Returns + +`unknown` + +*** + +### onSuccess()? + +```ts +optional onSuccess: (data, variables, onMutateResult, context) => unknown; +``` + +Defined in: [packages/query-core/src/types.ts:1212](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1212) + +#### Parameters + +##### data + +`TData` + +##### variables + +`TVariables` + +##### onMutateResult + +`TOnMutateResult` + +##### context + +[`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md) + +#### Returns + +`unknown` + +*** + +### retry? + +```ts +optional retry: RetryValue; +``` + +Defined in: [packages/query-core/src/types.ts:1239](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1239) + +If `false`, failed mutations will not retry by default. +If `true`, failed mutations will retry infinitely. +If set to an integer number, e.g. 3, failed mutations will retry until the failed mutation count meets that number. +If set to a function `(failureCount, error) => boolean` failed mutations will retry until the function returns false. + +Defaults to `0`. + +*** + +### retryDelay? + +```ts +optional retryDelay: RetryDelayValue; +``` + +Defined in: [packages/query-core/src/types.ts:1246](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1246) + +This function receives a `retryAttempt` integer and the actual Error and returns the delay to apply before the +next attempt in milliseconds. + +Defaults to a function that applies exponential backoff, capped at 30 seconds. + +*** + +### scope? + +```ts +optional scope: MutationScope; +``` + +Defined in: [packages/query-core/src/types.ts:1264](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1264) diff --git a/docs/framework/svelte/reference/interfaces/MutationState.md b/docs/framework/svelte/reference/interfaces/MutationState.md new file mode 100644 index 00000000000..bec050ec1d3 --- /dev/null +++ b/docs/framework/svelte/reference/interfaces/MutationState.md @@ -0,0 +1,142 @@ +--- +id: MutationState +title: MutationState +--- + +Defined in: [packages/query-core/src/mutation.ts:30](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L30) + +The raw state stored on a `Mutation` instance. This is the underlying state +that observer results (e.g. `MutationObserverResult`) are derived from. + +## Extended by + +- [`MutationObserverBaseResult`](MutationObserverBaseResult.md) + +## Type Parameters + +### TData + +`TData` = `unknown` + +### TError + +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) + +### TVariables + +`TVariables` = `unknown` + +### TOnMutateResult + +`TOnMutateResult` = `unknown` + +## Properties + +### context + +```ts +context: TOnMutateResult | undefined; +``` + +Defined in: [packages/query-core/src/mutation.ts:40](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L40) + +The value returned by `onMutate`, if defined. Passed to `onSuccess`, +`onError` and `onSettled` as the mutation's context. + +*** + +### data + +```ts +data: TData | undefined; +``` + +Defined in: [packages/query-core/src/mutation.ts:44](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L44) + +The last successfully resolved data for the mutation. + +*** + +### error + +```ts +error: TError | null; +``` + +Defined in: [packages/query-core/src/mutation.ts:49](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L49) + +The error object for the mutation, if the last attempt resulted in an error. +- Defaults to `null`. + +*** + +### failureCount + +```ts +failureCount: number; +``` + +Defined in: [packages/query-core/src/mutation.ts:53](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L53) + +The number of times the mutation function has failed for the current attempt. + +*** + +### failureReason + +```ts +failureReason: TError | null; +``` + +Defined in: [packages/query-core/src/mutation.ts:57](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L57) + +The reason the current attempt failed, as reported by the retryer. + +*** + +### isPaused + +```ts +isPaused: boolean; +``` + +Defined in: [packages/query-core/src/mutation.ts:62](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L62) + +Whether the mutation is currently paused (see network mode), or is +waiting for another mutation with the same `scope` to finish. + +*** + +### status + +```ts +status: MutationStatus; +``` + +Defined in: [packages/query-core/src/mutation.ts:66](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L66) + +The status of the mutation. + +*** + +### submittedAt + +```ts +submittedAt: number; +``` + +Defined in: [packages/query-core/src/mutation.ts:74](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L74) + +The timestamp for when the mutation was submitted. + +*** + +### variables + +```ts +variables: TVariables | undefined; +``` + +Defined in: [packages/query-core/src/mutation.ts:70](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L70) + +The variables the mutation was last called with. diff --git a/docs/framework/svelte/reference/interfaces/NotifyEvent.md b/docs/framework/svelte/reference/interfaces/NotifyEvent.md new file mode 100644 index 00000000000..4f5b023f49a --- /dev/null +++ b/docs/framework/svelte/reference/interfaces/NotifyEvent.md @@ -0,0 +1,16 @@ +--- +id: NotifyEvent +title: NotifyEvent +--- + +Defined in: [packages/query-core/src/types.ts:1539](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1539) + +## Properties + +### type + +```ts +type: NotifyEventType; +``` + +Defined in: [packages/query-core/src/types.ts:1540](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1540) diff --git a/docs/framework/svelte/reference/interfaces/OnlineManager.md b/docs/framework/svelte/reference/interfaces/OnlineManager.md new file mode 100644 index 00000000000..1a936c91ed9 --- /dev/null +++ b/docs/framework/svelte/reference/interfaces/OnlineManager.md @@ -0,0 +1,214 @@ +--- +id: OnlineManager +title: OnlineManager +--- + +Defined in: [packages/query-core/src/onlineManager.ts:15](https://github.com/TanStack/query/blob/main/packages/query-core/src/onlineManager.ts#L15) + +The `OnlineManager` manages the online state within TanStack Query. It can +be used to change the default event listeners or to manually change the +online state. + +By default, the `onlineManager` assumes an active network connection, and +listens to the `online` and `offline` events on the `window` object to +detect changes. + +## Extends + +- `Subscribable`\<`Listener`\> + +## Properties + +### listeners + +```ts +protected listeners: Set; +``` + +Defined in: [packages/query-core/src/subscribable.ts:2](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L2) + +#### Inherited from + +```ts +Subscribable.listeners +``` + +## Methods + +### hasListeners() + +```ts +hasListeners(): boolean; +``` + +Defined in: [packages/query-core/src/subscribable.ts:19](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L19) + +#### Returns + +`boolean` + +#### Inherited from + +```ts +Subscribable.hasListeners +``` + +*** + +### isOnline() + +```ts +isOnline(): boolean; +``` + +Defined in: [packages/query-core/src/onlineManager.ts:109](https://github.com/TanStack/query/blob/main/packages/query-core/src/onlineManager.ts#L109) + +`isOnline` can be used to get the current online state. + +#### Returns + +`boolean` + +*** + +### onSubscribe() + +```ts +protected onSubscribe(): void; +``` + +Defined in: [packages/query-core/src/onlineManager.ts:44](https://github.com/TanStack/query/blob/main/packages/query-core/src/onlineManager.ts#L44) + +#### Returns + +`void` + +#### Overrides + +```ts +Subscribable.onSubscribe +``` + +*** + +### onUnsubscribe() + +```ts +protected onUnsubscribe(): void; +``` + +Defined in: [packages/query-core/src/onlineManager.ts:50](https://github.com/TanStack/query/blob/main/packages/query-core/src/onlineManager.ts#L50) + +#### Returns + +`void` + +#### Overrides + +```ts +Subscribable.onUnsubscribe +``` + +*** + +### setEventListener() + +```ts +setEventListener(setup): void; +``` + +Defined in: [packages/query-core/src/onlineManager.ts:75](https://github.com/TanStack/query/blob/main/packages/query-core/src/onlineManager.ts#L75) + +`setEventListener` can be used to set a custom event listener that will +be used to determine the online state. The provided `setup` function +receives a `setOnline` callback that should be called with a `boolean` +whenever the online state changes. + +#### Parameters + +##### setup + +`SetupFn` + +#### Returns + +`void` + +#### Example + +```ts +import NetInfo from '@react-native-community/netinfo' +import { onlineManager } from '@tanstack/query-core' + +onlineManager.setEventListener((setOnline) => { + return NetInfo.addEventListener((state) => { + setOnline(!!state.isConnected) + }) +}) +``` + +*** + +### setOnline() + +```ts +setOnline(online): void; +``` + +Defined in: [packages/query-core/src/onlineManager.ts:95](https://github.com/TanStack/query/blob/main/packages/query-core/src/onlineManager.ts#L95) + +`setOnline` can be used to manually set the online state. + +#### Parameters + +##### online + +`boolean` + +#### Returns + +`void` + +#### Example + +```ts +import { onlineManager } from '@tanstack/query-core' + +// Set to online +onlineManager.setOnline(true) + +// Set to offline +onlineManager.setOnline(false) +``` + +*** + +### subscribe() + +```ts +subscribe(listener): () => void; +``` + +Defined in: [packages/query-core/src/subscribable.ts:8](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L8) + +#### Parameters + +##### listener + +`Listener` + +#### Returns + +```ts +(): void; +``` + +##### Returns + +`void` + +#### Inherited from + +```ts +Subscribable.subscribe +``` diff --git a/docs/framework/svelte/reference/interfaces/QueriesObserverOptions.md b/docs/framework/svelte/reference/interfaces/QueriesObserverOptions.md new file mode 100644 index 00000000000..68e7913885d --- /dev/null +++ b/docs/framework/svelte/reference/interfaces/QueriesObserverOptions.md @@ -0,0 +1,29 @@ +--- +id: QueriesObserverOptions +title: QueriesObserverOptions +--- + +Defined in: [packages/query-core/src/queriesObserver.ts:23](https://github.com/TanStack/query/blob/main/packages/query-core/src/queriesObserver.ts#L23) + +## Type Parameters + +### TCombinedResult + +`TCombinedResult` = [`QueryObserverResult`](../type-aliases/QueryObserverResult.md)[] + +## Properties + +### combine? + +```ts +optional combine: CombineFn; +``` + +Defined in: [packages/query-core/src/queriesObserver.ts:34](https://github.com/TanStack/query/blob/main/packages/query-core/src/queriesObserver.ts#L34) + +A function that combines the array of `QueryObserverResult`s (one per +observed query) into a single value. The combined value is memoized and +only recomputed when one of the underlying results, the query hashes, or +the `combine` function itself changes. + +Defaults to returning the array of `QueryObserverResult`s unchanged. diff --git a/docs/framework/svelte/reference/interfaces/QueryCacheConfig.md b/docs/framework/svelte/reference/interfaces/QueryCacheConfig.md new file mode 100644 index 00000000000..3c6aebe496f --- /dev/null +++ b/docs/framework/svelte/reference/interfaces/QueryCacheConfig.md @@ -0,0 +1,93 @@ +--- +id: QueryCacheConfig +title: QueryCacheConfig +--- + +Defined in: [packages/query-core/src/queryCache.ts:25](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryCache.ts#L25) + +Global callbacks that fire for every query handled by a `QueryCache`, regardless of which +component or observer triggered it. Unlike `QueryClient`'s `defaultOptions`, which a query can +override, these callbacks are always called. Unlike `MutationCacheConfig`'s callbacks, these +are fire-and-forget: their return value is not awaited before the query settles. + +## Properties + +### onError()? + +```ts +optional onError: (error, query) => void; +``` + +Defined in: [packages/query-core/src/queryCache.ts:27](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryCache.ts#L27) + +Called when any query in the cache encounters an error. + +#### Parameters + +##### error + +`Error` + +##### query + +[`Query`](../classes/Query.md)\<`unknown`, `unknown`, `unknown`\> + +#### Returns + +`void` + +*** + +### onSettled()? + +```ts +optional onSettled: (data, error, query) => void; +``` + +Defined in: [packages/query-core/src/queryCache.ts:34](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryCache.ts#L34) + +Called when any query in the cache is settled, either successfully or with an error. + +#### Parameters + +##### data + +`unknown` + +##### error + +`Error` | `null` + +##### query + +[`Query`](../classes/Query.md)\<`unknown`, `unknown`, `unknown`\> + +#### Returns + +`void` + +*** + +### onSuccess()? + +```ts +optional onSuccess: (data, query) => void; +``` + +Defined in: [packages/query-core/src/queryCache.ts:32](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryCache.ts#L32) + +Called when any query in the cache is successful. + +#### Parameters + +##### data + +`unknown` + +##### query + +[`Query`](../classes/Query.md)\<`unknown`, `unknown`, `unknown`\> + +#### Returns + +`void` diff --git a/docs/framework/svelte/reference/interfaces/QueryClientConfig.md b/docs/framework/svelte/reference/interfaces/QueryClientConfig.md new file mode 100644 index 00000000000..070e249491f --- /dev/null +++ b/docs/framework/svelte/reference/interfaces/QueryClientConfig.md @@ -0,0 +1,43 @@ +--- +id: QueryClientConfig +title: QueryClientConfig +--- + +Defined in: [packages/query-core/src/types.ts:1495](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1495) + +## Properties + +### defaultOptions? + +```ts +optional defaultOptions: DefaultOptions; +``` + +Defined in: [packages/query-core/src/types.ts:1504](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1504) + +Default options for all queries and mutations created through this client. + +*** + +### mutationCache? + +```ts +optional mutationCache: MutationCache; +``` + +Defined in: [packages/query-core/src/types.ts:1502](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1502) + +The mutation cache this client is connected to. A new `MutationCache` is created if not +provided. + +*** + +### queryCache? + +```ts +optional queryCache: QueryCache; +``` + +Defined in: [packages/query-core/src/types.ts:1497](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1497) + +The query cache this client is connected to. A new `QueryCache` is created if not provided. diff --git a/docs/framework/svelte/reference/interfaces/QueryExecuteOptions.md b/docs/framework/svelte/reference/interfaces/QueryExecuteOptions.md new file mode 100644 index 00000000000..23d272eb25f --- /dev/null +++ b/docs/framework/svelte/reference/interfaces/QueryExecuteOptions.md @@ -0,0 +1,382 @@ +--- +id: QueryExecuteOptions +title: QueryExecuteOptions +--- + +Defined in: [packages/query-core/src/types.ts:574](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L574) + +## Extends + +- [`WithRequired`](../type-aliases/WithRequired.md)\<[`QueryOptions`](QueryOptions.md)\<`TQueryFnData`, `TError`, `TQueryData`, `TQueryKey`, `TPageParam`\>, `"queryKey"`\> + +## Type Parameters + +### TQueryFnData + +`TQueryFnData` = `unknown` + +### TError + +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) + +### TData + +`TData` = `TQueryFnData` + +### TQueryData + +`TQueryData` = `TQueryFnData` + +### TQueryKey + +`TQueryKey` *extends* [`QueryKey`](../type-aliases/QueryKey.md) = [`QueryKey`](../type-aliases/QueryKey.md) + +### TPageParam + +`TPageParam` = `never` + +## Properties + +### gcTime? + +```ts +optional gcTime: number; +``` + +Defined in: [packages/query-core/src/types.ts:277](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L277) + +The time in milliseconds that unused/inactive cache data remains in memory. +When a query's cache becomes unused or inactive, that cache data will be garbage collected after this duration. +When different garbage collection times are specified, the longest one will be used. +Setting it to `Infinity` will disable garbage collection. + +Defaults to `5 * 60 * 1000` (5 minutes), or `Infinity` during SSR. + +Note: the maximum allowed time is about 24 days, imposed by `setTimeout`'s 32-bit signed integer delay — see +`timeoutManager.setTimeoutProvider` for a workaround. + +#### Inherited from + +```ts +WithRequired.gcTime +``` + +*** + +### initialData? + +```ts +optional initialData: + | TQueryData +| InitialDataFunction; +``` + +Defined in: [packages/query-core/src/types.ts:317](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L317) + +If set, this value will be used as the initial data for the query cache (as long as the query hasn't been +created or cached yet). +If set to a function, the function will be called **once** during the shared/root query initialization, and be +expected to synchronously return the initial data. +Initial data is considered stale by default unless a `staleTime` has been set. +`initialData` **is persisted** to the cache. + +#### Inherited from + +```ts +WithRequired.initialData +``` + +*** + +### initialDataUpdatedAt? + +```ts +optional initialDataUpdatedAt: number | () => number | undefined; +``` + +Defined in: [packages/query-core/src/types.ts:321](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L321) + +If set, this value will be used as the time (in milliseconds) of when the `initialData` itself was last updated. + +#### Inherited from + +```ts +WithRequired.initialDataUpdatedAt +``` + +*** + +### initialPageParam? + +```ts +optional initialPageParam: undefined; +``` + +Defined in: [packages/query-core/src/types.ts:585](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L585) + +*** + +### maxPages? + +```ts +optional maxPages: number; +``` + +Defined in: [packages/query-core/src/types.ts:345](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L345) + +Maximum number of pages to store in the data of an infinite query. + +#### Inherited from + +```ts +WithRequired.maxPages +``` + +*** + +### meta? + +```ts +optional meta: Record; +``` + +Defined in: [packages/query-core/src/types.ts:341](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L341) + +Additional payload to be stored on each query. +Use this property to pass information that can be used in other places. + +#### Inherited from + +```ts +WithRequired.meta +``` + +*** + +### networkMode? + +```ts +optional networkMode: NetworkMode; +``` + +Defined in: [packages/query-core/src/types.ts:265](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L265) + +Controls whether a query is allowed to run based on the current network connectivity. + +Defaults to `'online'`. + +#### See + +[Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. + +#### Inherited from + +```ts +WithRequired.networkMode +``` + +*** + +### persister? + +```ts +optional persister: QueryPersister, TPageParam>; +``` + +Defined in: [packages/query-core/src/types.ts:290](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L290) + +This option can be used to persist the result of a query to an external storage, bypassing the need to actually +call the `queryFn`. Useful for persisting a query's data across e.g. server/client boundaries. + +#### Inherited from + +```ts +WithRequired.persister +``` + +*** + +### queryFn? + +```ts +optional queryFn: + | typeof skipToken +| QueryFunction; +``` + +Defined in: [packages/query-core/src/types.ts:285](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L285) + +The function that the query will use to request data. +Required, unless a default query function has been set via `queryClient.setQueryDefaults` or +`queryClient.setDefaultOptions`. +Receives a [QueryFunctionContext](../type-aliases/QueryFunctionContext.md). +Must return a promise that will either resolve data or throw an error. The data cannot be `undefined`. + +#### Inherited from + +```ts +WithRequired.queryFn +``` + +*** + +### queryHash? + +```ts +optional queryHash: string; +``` + +Defined in: [packages/query-core/src/types.ts:295](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L295) + +The hashed form of `queryKey`, computed with `queryKeyHashFn` (or the default hashing function otherwise). Used +as the actual cache key internally. + +#### Inherited from + +```ts +WithRequired.queryHash +``` + +*** + +### queryKey + +```ts +queryKey: TQueryKey & object; +``` + +Defined in: [packages/query-core/src/types.ts:304](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L304) + +The query key to use for this query. + +The query key will be hashed into a stable hash. See [Query Keys](https://tanstack.com/query/latest/docs/framework/react/guides/query-keys) +for more information. + +The query will automatically update when this key changes (as long as `enabled` is not set to `false`). + +#### Inherited from + +```ts +WithRequired.queryKey +``` + +*** + +### queryKeyHashFn? + +```ts +optional queryKeyHashFn: QueryKeyHashFunction; +``` + +Defined in: [packages/query-core/src/types.ts:308](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L308) + +If specified, this function is used to hash the `queryKey` to a string. + +#### Inherited from + +```ts +WithRequired.queryKeyHashFn +``` + +*** + +### retry? + +```ts +optional retry: RetryValue; +``` + +Defined in: [packages/query-core/src/types.ts:246](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L246) + +If `false`, failed queries will not retry by default. +If `true`, failed queries will retry infinitely. +If set to an integer number, e.g. 3, failed queries will retry until the failed query count meets that number. +If set to a function `(failureCount, error) => boolean` failed queries will retry until the function returns false. + +Defaults to `3` on the client and `0` on the server. + +#### Inherited from + +```ts +WithRequired.retry +``` + +*** + +### retryDelay? + +```ts +optional retryDelay: RetryDelayValue; +``` + +Defined in: [packages/query-core/src/types.ts:258](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L258) + +This function receives a `retryAttempt` integer and the actual Error and returns the delay to apply before the +next attempt in milliseconds. + +A function like `attempt => Math.min(attempt > 1 ? 2 ** attempt * 1000 : 1000, 30 * 1000)` applies exponential +backoff. + +A function like `attempt => attempt * 1000` applies linear backoff. + +Defaults to a function that applies exponential backoff, capped at 30 seconds. + +#### Inherited from + +```ts +WithRequired.retryDelay +``` + +*** + +### select()? + +```ts +optional select: (data) => TData; +``` + +Defined in: [packages/query-core/src/types.ts:586](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L586) + +#### Parameters + +##### data + +`TQueryData` + +#### Returns + +`TData` + +*** + +### staleTime? + +```ts +optional staleTime: StaleTimeFunction; +``` + +Defined in: [packages/query-core/src/types.ts:591](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L591) + +The time in milliseconds after data is considered stale. +If the data is fresh it will be returned from the cache. + +*** + +### structuralSharing? + +```ts +optional structuralSharing: boolean | (oldData, newData) => unknown; +``` + +Defined in: [packages/query-core/src/types.ts:330](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L330) + +Set this to `false` to disable structural sharing between query results. +Set this to a function which accepts the old and new data and returns resolved data of the same type to implement custom structural sharing logic. + +Defaults to `true`. + +#### Inherited from + +```ts +WithRequired.structuralSharing +``` diff --git a/docs/framework/svelte/reference/interfaces/QueryFilters.md b/docs/framework/svelte/reference/interfaces/QueryFilters.md new file mode 100644 index 00000000000..749e4283d0d --- /dev/null +++ b/docs/framework/svelte/reference/interfaces/QueryFilters.md @@ -0,0 +1,104 @@ +--- +id: QueryFilters +title: QueryFilters +--- + +Defined in: [packages/query-core/src/utils.ts:31](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L31) + +Filters used to select queries, for example in `queryClient.getQueriesData` or `queryClient.invalidateQueries`. +All provided filters must match; filters that are left unspecified are ignored. + +## Extended by + +- [`InvalidateQueryFilters`](InvalidateQueryFilters.md) +- [`RefetchQueryFilters`](RefetchQueryFilters.md) + +## Type Parameters + +### TQueryKey + +`TQueryKey` *extends* [`QueryKey`](../type-aliases/QueryKey.md) = [`QueryKey`](../type-aliases/QueryKey.md) + +## Properties + +### exact? + +```ts +optional exact: boolean; +``` + +Defined in: [packages/query-core/src/utils.ts:41](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L41) + +Match query key exactly + +*** + +### fetchStatus? + +```ts +optional fetchStatus: FetchStatus; +``` + +Defined in: [packages/query-core/src/utils.ts:57](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L57) + +Include queries matching their fetchStatus + +*** + +### predicate()? + +```ts +optional predicate: (query) => boolean; +``` + +Defined in: [packages/query-core/src/utils.ts:45](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L45) + +Include queries matching this predicate function + +#### Parameters + +##### query + +[`Query`](../classes/Query.md) + +#### Returns + +`boolean` + +*** + +### queryKey? + +```ts +optional queryKey: TQueryKey | TuplePrefixes; +``` + +Defined in: [packages/query-core/src/utils.ts:49](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L49) + +Include queries matching this query key + +*** + +### stale? + +```ts +optional stale: boolean; +``` + +Defined in: [packages/query-core/src/utils.ts:53](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L53) + +Include or exclude stale queries + +*** + +### type? + +```ts +optional type: QueryTypeFilter; +``` + +Defined in: [packages/query-core/src/utils.ts:37](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L37) + +Filter to active queries, inactive queries or all queries + +Defaults to `'all'`. diff --git a/docs/framework/svelte/reference/interfaces/QueryObserverBaseResult.md b/docs/framework/svelte/reference/interfaces/QueryObserverBaseResult.md new file mode 100644 index 00000000000..ef5fe0ad757 --- /dev/null +++ b/docs/framework/svelte/reference/interfaces/QueryObserverBaseResult.md @@ -0,0 +1,358 @@ +--- +id: QueryObserverBaseResult +title: QueryObserverBaseResult +--- + +Defined in: [packages/query-core/src/types.ts:764](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L764) + +## Extended by + +- [`QueryObserverPendingResult`](QueryObserverPendingResult.md) +- [`QueryObserverLoadingResult`](QueryObserverLoadingResult.md) +- [`QueryObserverLoadingErrorResult`](QueryObserverLoadingErrorResult.md) +- [`QueryObserverRefetchErrorResult`](QueryObserverRefetchErrorResult.md) +- [`QueryObserverSuccessResult`](QueryObserverSuccessResult.md) +- [`QueryObserverPlaceholderResult`](QueryObserverPlaceholderResult.md) +- [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md) + +## Type Parameters + +### TData + +`TData` = `unknown` + +### TError + +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) + +## Properties + +### data + +```ts +data: TData | undefined; +``` + +Defined in: [packages/query-core/src/types.ts:771](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L771) + +The last successfully resolved data for the query. + +*** + +### dataUpdatedAt + +```ts +dataUpdatedAt: number; +``` + +Defined in: [packages/query-core/src/types.ts:775](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L775) + +The timestamp for when the query most recently returned the `status` as `"success"`. + +*** + +### error + +```ts +error: TError | null; +``` + +Defined in: [packages/query-core/src/types.ts:780](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L780) + +The error object for the query, if an error was thrown. +- Defaults to `null`. + +*** + +### errorUpdateCount + +```ts +errorUpdateCount: number; +``` + +Defined in: [packages/query-core/src/types.ts:799](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L799) + +The sum of all errors. + +*** + +### errorUpdatedAt + +```ts +errorUpdatedAt: number; +``` + +Defined in: [packages/query-core/src/types.ts:784](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L784) + +The timestamp for when the query most recently returned the `status` as `"error"`. + +*** + +### failureCount + +```ts +failureCount: number; +``` + +Defined in: [packages/query-core/src/types.ts:790](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L790) + +The failure count for the query. +- Incremented every time the query fails. +- Reset to `0` when the query succeeds. + +*** + +### failureReason + +```ts +failureReason: TError | null; +``` + +Defined in: [packages/query-core/src/types.ts:795](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L795) + +The failure reason for the query retry. +- Reset to `null` when the query succeeds. + +*** + +### fetchStatus + +```ts +fetchStatus: FetchStatus; +``` + +Defined in: [packages/query-core/src/types.ts:889](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L889) + +The fetch status of the query. +- `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. +- `paused`: The query wanted to fetch, but has been `paused`. +- `idle`: The query is not fetching. +- See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. + +*** + +### isEnabled + +```ts +isEnabled: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:867](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L867) + +`true` if this observer is enabled, `false` otherwise. + +*** + +### isError + +```ts +isError: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:804](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L804) + +A derived boolean from the `status` variable, provided for convenience. +- `true` if the query attempt resulted in an error. + +*** + +### isFetched + +```ts +isFetched: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:808](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L808) + +Will be `true` if the query has been fetched. + +*** + +### isFetchedAfterMount + +```ts +isFetchedAfterMount: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:813](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L813) + +Will be `true` if the query has been fetched after the component mounted. +- This property can be used to not show any previously cached data. + +*** + +### isFetching + +```ts +isFetching: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:818](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L818) + +A derived boolean from the `fetchStatus` variable, provided for convenience. +- `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. + +*** + +### ~~isInitialLoading~~ + +```ts +isInitialLoading: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:836](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L836) + +#### Deprecated + +`isInitialLoading` is being deprecated in favor of `isLoading` +and will be removed in the next major version. + +*** + +### isLoading + +```ts +isLoading: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:823](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L823) + +Is `true` whenever the first fetch for a query is in-flight. +- Is the same as `isFetching && isPending`. + +*** + +### isLoadingError + +```ts +isLoadingError: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:831](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L831) + +Will be `true` if the query failed while fetching for the first time. + +*** + +### isPaused + +```ts +isPaused: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:841](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L841) + +A derived boolean from the `fetchStatus` variable, provided for convenience. +- The query wanted to fetch, but has been `paused`. + +*** + +### isPending + +```ts +isPending: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:827](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L827) + +Will be `pending` if there's no cached data and no query attempt was finished yet. + +*** + +### isPlaceholderData + +```ts +isPlaceholderData: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:845](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L845) + +Will be `true` if the data shown is the placeholder data. + +*** + +### isRefetchError + +```ts +isRefetchError: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:849](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L849) + +Will be `true` if the query failed while refetching. + +*** + +### isRefetching + +```ts +isRefetching: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:854](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L854) + +Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. +- Is the same as `isFetching && !isPending`. + +*** + +### isStale + +```ts +isStale: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:858](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L858) + +Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. + +*** + +### isSuccess + +```ts +isSuccess: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:863](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L863) + +A derived boolean from the `status` variable, provided for convenience. +- `true` if the query has received a response with no errors and is ready to display its data. + +*** + +### refetch() + +```ts +refetch: (options?) => Promise>; +``` + +Defined in: [packages/query-core/src/types.ts:871](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L871) + +A function to manually refetch the query. + +#### Parameters + +##### options? + +[`RefetchOptions`](RefetchOptions.md) + +#### Returns + +`Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> + +*** + +### status + +```ts +status: QueryStatus; +``` + +Defined in: [packages/query-core/src/types.ts:881](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L881) + +The status of the query. +- Will be: + - `pending` if there's no cached data and no query attempt was finished yet. + - `error` if the query attempt resulted in an error. + - `success` if the query has received a response with no errors and is ready to display its data. diff --git a/docs/framework/svelte/reference/interfaces/QueryObserverLoadingErrorResult.md b/docs/framework/svelte/reference/interfaces/QueryObserverLoadingErrorResult.md new file mode 100644 index 00000000000..21b39fbffe3 --- /dev/null +++ b/docs/framework/svelte/reference/interfaces/QueryObserverLoadingErrorResult.md @@ -0,0 +1,452 @@ +--- +id: QueryObserverLoadingErrorResult +title: QueryObserverLoadingErrorResult +--- + +Defined in: [packages/query-core/src/types.ts:923](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L923) + +## Extends + +- [`QueryObserverBaseResult`](QueryObserverBaseResult.md)\<`TData`, `TError`\> + +## Type Parameters + +### TData + +`TData` = `unknown` + +### TError + +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) + +## Properties + +### data + +```ts +data: undefined; +``` + +Defined in: [packages/query-core/src/types.ts:927](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L927) + +The last successfully resolved data for the query. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`data`](QueryObserverBaseResult.md#data) + +*** + +### dataUpdatedAt + +```ts +dataUpdatedAt: number; +``` + +Defined in: [packages/query-core/src/types.ts:775](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L775) + +The timestamp for when the query most recently returned the `status` as `"success"`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`dataUpdatedAt`](QueryObserverBaseResult.md#dataupdatedat) + +*** + +### error + +```ts +error: TError; +``` + +Defined in: [packages/query-core/src/types.ts:928](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L928) + +The error object for the query, if an error was thrown. +- Defaults to `null`. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`error`](QueryObserverBaseResult.md#error) + +*** + +### errorUpdateCount + +```ts +errorUpdateCount: number; +``` + +Defined in: [packages/query-core/src/types.ts:799](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L799) + +The sum of all errors. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`errorUpdateCount`](QueryObserverBaseResult.md#errorupdatecount) + +*** + +### errorUpdatedAt + +```ts +errorUpdatedAt: number; +``` + +Defined in: [packages/query-core/src/types.ts:784](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L784) + +The timestamp for when the query most recently returned the `status` as `"error"`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`errorUpdatedAt`](QueryObserverBaseResult.md#errorupdatedat) + +*** + +### failureCount + +```ts +failureCount: number; +``` + +Defined in: [packages/query-core/src/types.ts:790](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L790) + +The failure count for the query. +- Incremented every time the query fails. +- Reset to `0` when the query succeeds. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`failureCount`](QueryObserverBaseResult.md#failurecount) + +*** + +### failureReason + +```ts +failureReason: TError | null; +``` + +Defined in: [packages/query-core/src/types.ts:795](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L795) + +The failure reason for the query retry. +- Reset to `null` when the query succeeds. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`failureReason`](QueryObserverBaseResult.md#failurereason) + +*** + +### fetchStatus + +```ts +fetchStatus: FetchStatus; +``` + +Defined in: [packages/query-core/src/types.ts:889](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L889) + +The fetch status of the query. +- `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. +- `paused`: The query wanted to fetch, but has been `paused`. +- `idle`: The query is not fetching. +- See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`fetchStatus`](QueryObserverBaseResult.md#fetchstatus) + +*** + +### isEnabled + +```ts +isEnabled: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:867](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L867) + +`true` if this observer is enabled, `false` otherwise. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isEnabled`](QueryObserverBaseResult.md#isenabled) + +*** + +### isError + +```ts +isError: true; +``` + +Defined in: [packages/query-core/src/types.ts:929](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L929) + +A derived boolean from the `status` variable, provided for convenience. +- `true` if the query attempt resulted in an error. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isError`](QueryObserverBaseResult.md#iserror) + +*** + +### isFetched + +```ts +isFetched: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:808](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L808) + +Will be `true` if the query has been fetched. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isFetched`](QueryObserverBaseResult.md#isfetched) + +*** + +### isFetchedAfterMount + +```ts +isFetchedAfterMount: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:813](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L813) + +Will be `true` if the query has been fetched after the component mounted. +- This property can be used to not show any previously cached data. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isFetchedAfterMount`](QueryObserverBaseResult.md#isfetchedaftermount) + +*** + +### isFetching + +```ts +isFetching: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:818](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L818) + +A derived boolean from the `fetchStatus` variable, provided for convenience. +- `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isFetching`](QueryObserverBaseResult.md#isfetching) + +*** + +### ~~isInitialLoading~~ + +```ts +isInitialLoading: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:836](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L836) + +#### Deprecated + +`isInitialLoading` is being deprecated in favor of `isLoading` +and will be removed in the next major version. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isInitialLoading`](QueryObserverBaseResult.md#isinitialloading) + +*** + +### isLoading + +```ts +isLoading: false; +``` + +Defined in: [packages/query-core/src/types.ts:931](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L931) + +Is `true` whenever the first fetch for a query is in-flight. +- Is the same as `isFetching && isPending`. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoading`](QueryObserverBaseResult.md#isloading) + +*** + +### isLoadingError + +```ts +isLoadingError: true; +``` + +Defined in: [packages/query-core/src/types.ts:932](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L932) + +Will be `true` if the query failed while fetching for the first time. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoadingError`](QueryObserverBaseResult.md#isloadingerror) + +*** + +### isPaused + +```ts +isPaused: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:841](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L841) + +A derived boolean from the `fetchStatus` variable, provided for convenience. +- The query wanted to fetch, but has been `paused`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPaused`](QueryObserverBaseResult.md#ispaused) + +*** + +### isPending + +```ts +isPending: false; +``` + +Defined in: [packages/query-core/src/types.ts:930](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L930) + +Will be `pending` if there's no cached data and no query attempt was finished yet. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPending`](QueryObserverBaseResult.md#ispending) + +*** + +### isPlaceholderData + +```ts +isPlaceholderData: false; +``` + +Defined in: [packages/query-core/src/types.ts:935](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L935) + +Will be `true` if the data shown is the placeholder data. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPlaceholderData`](QueryObserverBaseResult.md#isplaceholderdata) + +*** + +### isRefetchError + +```ts +isRefetchError: false; +``` + +Defined in: [packages/query-core/src/types.ts:933](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L933) + +Will be `true` if the query failed while refetching. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetchError`](QueryObserverBaseResult.md#isrefetcherror) + +*** + +### isRefetching + +```ts +isRefetching: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:854](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L854) + +Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. +- Is the same as `isFetching && !isPending`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetching`](QueryObserverBaseResult.md#isrefetching) + +*** + +### isStale + +```ts +isStale: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:858](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L858) + +Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isStale`](QueryObserverBaseResult.md#isstale) + +*** + +### isSuccess + +```ts +isSuccess: false; +``` + +Defined in: [packages/query-core/src/types.ts:934](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L934) + +A derived boolean from the `status` variable, provided for convenience. +- `true` if the query has received a response with no errors and is ready to display its data. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isSuccess`](QueryObserverBaseResult.md#issuccess) + +*** + +### refetch() + +```ts +refetch: (options?) => Promise>; +``` + +Defined in: [packages/query-core/src/types.ts:871](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L871) + +A function to manually refetch the query. + +#### Parameters + +##### options? + +[`RefetchOptions`](RefetchOptions.md) + +#### Returns + +`Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`refetch`](QueryObserverBaseResult.md#refetch) + +*** + +### status + +```ts +status: "error"; +``` + +Defined in: [packages/query-core/src/types.ts:936](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L936) + +The status of the query. +- Will be: + - `pending` if there's no cached data and no query attempt was finished yet. + - `error` if the query attempt resulted in an error. + - `success` if the query has received a response with no errors and is ready to display its data. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`status`](QueryObserverBaseResult.md#status) diff --git a/docs/framework/svelte/reference/interfaces/QueryObserverLoadingResult.md b/docs/framework/svelte/reference/interfaces/QueryObserverLoadingResult.md new file mode 100644 index 00000000000..4966390127f --- /dev/null +++ b/docs/framework/svelte/reference/interfaces/QueryObserverLoadingResult.md @@ -0,0 +1,452 @@ +--- +id: QueryObserverLoadingResult +title: QueryObserverLoadingResult +--- + +Defined in: [packages/query-core/src/types.ts:907](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L907) + +## Extends + +- [`QueryObserverBaseResult`](QueryObserverBaseResult.md)\<`TData`, `TError`\> + +## Type Parameters + +### TData + +`TData` = `unknown` + +### TError + +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) + +## Properties + +### data + +```ts +data: undefined; +``` + +Defined in: [packages/query-core/src/types.ts:911](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L911) + +The last successfully resolved data for the query. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`data`](QueryObserverBaseResult.md#data) + +*** + +### dataUpdatedAt + +```ts +dataUpdatedAt: number; +``` + +Defined in: [packages/query-core/src/types.ts:775](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L775) + +The timestamp for when the query most recently returned the `status` as `"success"`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`dataUpdatedAt`](QueryObserverBaseResult.md#dataupdatedat) + +*** + +### error + +```ts +error: null; +``` + +Defined in: [packages/query-core/src/types.ts:912](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L912) + +The error object for the query, if an error was thrown. +- Defaults to `null`. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`error`](QueryObserverBaseResult.md#error) + +*** + +### errorUpdateCount + +```ts +errorUpdateCount: number; +``` + +Defined in: [packages/query-core/src/types.ts:799](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L799) + +The sum of all errors. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`errorUpdateCount`](QueryObserverBaseResult.md#errorupdatecount) + +*** + +### errorUpdatedAt + +```ts +errorUpdatedAt: number; +``` + +Defined in: [packages/query-core/src/types.ts:784](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L784) + +The timestamp for when the query most recently returned the `status` as `"error"`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`errorUpdatedAt`](QueryObserverBaseResult.md#errorupdatedat) + +*** + +### failureCount + +```ts +failureCount: number; +``` + +Defined in: [packages/query-core/src/types.ts:790](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L790) + +The failure count for the query. +- Incremented every time the query fails. +- Reset to `0` when the query succeeds. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`failureCount`](QueryObserverBaseResult.md#failurecount) + +*** + +### failureReason + +```ts +failureReason: TError | null; +``` + +Defined in: [packages/query-core/src/types.ts:795](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L795) + +The failure reason for the query retry. +- Reset to `null` when the query succeeds. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`failureReason`](QueryObserverBaseResult.md#failurereason) + +*** + +### fetchStatus + +```ts +fetchStatus: FetchStatus; +``` + +Defined in: [packages/query-core/src/types.ts:889](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L889) + +The fetch status of the query. +- `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. +- `paused`: The query wanted to fetch, but has been `paused`. +- `idle`: The query is not fetching. +- See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`fetchStatus`](QueryObserverBaseResult.md#fetchstatus) + +*** + +### isEnabled + +```ts +isEnabled: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:867](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L867) + +`true` if this observer is enabled, `false` otherwise. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isEnabled`](QueryObserverBaseResult.md#isenabled) + +*** + +### isError + +```ts +isError: false; +``` + +Defined in: [packages/query-core/src/types.ts:913](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L913) + +A derived boolean from the `status` variable, provided for convenience. +- `true` if the query attempt resulted in an error. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isError`](QueryObserverBaseResult.md#iserror) + +*** + +### isFetched + +```ts +isFetched: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:808](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L808) + +Will be `true` if the query has been fetched. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isFetched`](QueryObserverBaseResult.md#isfetched) + +*** + +### isFetchedAfterMount + +```ts +isFetchedAfterMount: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:813](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L813) + +Will be `true` if the query has been fetched after the component mounted. +- This property can be used to not show any previously cached data. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isFetchedAfterMount`](QueryObserverBaseResult.md#isfetchedaftermount) + +*** + +### isFetching + +```ts +isFetching: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:818](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L818) + +A derived boolean from the `fetchStatus` variable, provided for convenience. +- `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isFetching`](QueryObserverBaseResult.md#isfetching) + +*** + +### ~~isInitialLoading~~ + +```ts +isInitialLoading: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:836](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L836) + +#### Deprecated + +`isInitialLoading` is being deprecated in favor of `isLoading` +and will be removed in the next major version. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isInitialLoading`](QueryObserverBaseResult.md#isinitialloading) + +*** + +### isLoading + +```ts +isLoading: true; +``` + +Defined in: [packages/query-core/src/types.ts:915](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L915) + +Is `true` whenever the first fetch for a query is in-flight. +- Is the same as `isFetching && isPending`. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoading`](QueryObserverBaseResult.md#isloading) + +*** + +### isLoadingError + +```ts +isLoadingError: false; +``` + +Defined in: [packages/query-core/src/types.ts:916](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L916) + +Will be `true` if the query failed while fetching for the first time. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoadingError`](QueryObserverBaseResult.md#isloadingerror) + +*** + +### isPaused + +```ts +isPaused: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:841](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L841) + +A derived boolean from the `fetchStatus` variable, provided for convenience. +- The query wanted to fetch, but has been `paused`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPaused`](QueryObserverBaseResult.md#ispaused) + +*** + +### isPending + +```ts +isPending: true; +``` + +Defined in: [packages/query-core/src/types.ts:914](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L914) + +Will be `pending` if there's no cached data and no query attempt was finished yet. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPending`](QueryObserverBaseResult.md#ispending) + +*** + +### isPlaceholderData + +```ts +isPlaceholderData: false; +``` + +Defined in: [packages/query-core/src/types.ts:919](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L919) + +Will be `true` if the data shown is the placeholder data. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPlaceholderData`](QueryObserverBaseResult.md#isplaceholderdata) + +*** + +### isRefetchError + +```ts +isRefetchError: false; +``` + +Defined in: [packages/query-core/src/types.ts:917](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L917) + +Will be `true` if the query failed while refetching. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetchError`](QueryObserverBaseResult.md#isrefetcherror) + +*** + +### isRefetching + +```ts +isRefetching: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:854](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L854) + +Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. +- Is the same as `isFetching && !isPending`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetching`](QueryObserverBaseResult.md#isrefetching) + +*** + +### isStale + +```ts +isStale: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:858](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L858) + +Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isStale`](QueryObserverBaseResult.md#isstale) + +*** + +### isSuccess + +```ts +isSuccess: false; +``` + +Defined in: [packages/query-core/src/types.ts:918](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L918) + +A derived boolean from the `status` variable, provided for convenience. +- `true` if the query has received a response with no errors and is ready to display its data. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isSuccess`](QueryObserverBaseResult.md#issuccess) + +*** + +### refetch() + +```ts +refetch: (options?) => Promise>; +``` + +Defined in: [packages/query-core/src/types.ts:871](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L871) + +A function to manually refetch the query. + +#### Parameters + +##### options? + +[`RefetchOptions`](RefetchOptions.md) + +#### Returns + +`Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`refetch`](QueryObserverBaseResult.md#refetch) + +*** + +### status + +```ts +status: "pending"; +``` + +Defined in: [packages/query-core/src/types.ts:920](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L920) + +The status of the query. +- Will be: + - `pending` if there's no cached data and no query attempt was finished yet. + - `error` if the query attempt resulted in an error. + - `success` if the query has received a response with no errors and is ready to display its data. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`status`](QueryObserverBaseResult.md#status) diff --git a/docs/framework/svelte/reference/interfaces/QueryObserverOptions.md b/docs/framework/svelte/reference/interfaces/QueryObserverOptions.md new file mode 100644 index 00000000000..02c4f7e05f8 --- /dev/null +++ b/docs/framework/svelte/reference/interfaces/QueryObserverOptions.md @@ -0,0 +1,560 @@ +--- +id: QueryObserverOptions +title: QueryObserverOptions +--- + +Defined in: [packages/query-core/src/types.ts:380](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L380) + +## Extends + +- [`WithRequired`](../type-aliases/WithRequired.md)\<[`QueryOptions`](QueryOptions.md)\<`TQueryFnData`, `TError`, `TQueryData`, `TQueryKey`, `TPageParam`\>, `"queryKey"`\> + +## Extended by + +- [`InfiniteQueryObserverOptions`](InfiniteQueryObserverOptions.md) + +## Type Parameters + +### TQueryFnData + +`TQueryFnData` = `unknown` + +### TError + +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) + +### TData + +`TData` = `TQueryFnData` + +### TQueryData + +`TQueryData` = `TQueryFnData` + +### TQueryKey + +`TQueryKey` *extends* [`QueryKey`](../type-aliases/QueryKey.md) = [`QueryKey`](../type-aliases/QueryKey.md) + +### TPageParam + +`TPageParam` = `never` + +## Properties + +### enabled? + +```ts +optional enabled: QueryBooleanOption; +``` + +Defined in: [packages/query-core/src/types.ts:398](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L398) + +Set this to `false` or a function that returns `false` to disable automatic refetching when the query mounts or changes query keys. +To refetch the query, use the `refetch` method returned from the `useQuery` instance. +Accepts a boolean or function that returns a boolean. + +Defaults to `true`. + +*** + +### gcTime? + +```ts +optional gcTime: number; +``` + +Defined in: [packages/query-core/src/types.ts:277](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L277) + +The time in milliseconds that unused/inactive cache data remains in memory. +When a query's cache becomes unused or inactive, that cache data will be garbage collected after this duration. +When different garbage collection times are specified, the longest one will be used. +Setting it to `Infinity` will disable garbage collection. + +Defaults to `5 * 60 * 1000` (5 minutes), or `Infinity` during SSR. + +Note: the maximum allowed time is about 24 days, imposed by `setTimeout`'s 32-bit signed integer delay — see +`timeoutManager.setTimeoutProvider` for a workaround. + +#### Inherited from + +```ts +WithRequired.gcTime +``` + +*** + +### initialData? + +```ts +optional initialData: + | TQueryData +| InitialDataFunction; +``` + +Defined in: [packages/query-core/src/types.ts:317](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L317) + +If set, this value will be used as the initial data for the query cache (as long as the query hasn't been +created or cached yet). +If set to a function, the function will be called **once** during the shared/root query initialization, and be +expected to synchronously return the initial data. +Initial data is considered stale by default unless a `staleTime` has been set. +`initialData` **is persisted** to the cache. + +#### Inherited from + +```ts +WithRequired.initialData +``` + +*** + +### initialDataUpdatedAt? + +```ts +optional initialDataUpdatedAt: number | () => number | undefined; +``` + +Defined in: [packages/query-core/src/types.ts:321](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L321) + +If set, this value will be used as the time (in milliseconds) of when the `initialData` itself was last updated. + +#### Inherited from + +```ts +WithRequired.initialDataUpdatedAt +``` + +*** + +### maxPages? + +```ts +optional maxPages: number; +``` + +Defined in: [packages/query-core/src/types.ts:345](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L345) + +Maximum number of pages to store in the data of an infinite query. + +#### Inherited from + +```ts +WithRequired.maxPages +``` + +*** + +### meta? + +```ts +optional meta: Record; +``` + +Defined in: [packages/query-core/src/types.ts:341](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L341) + +Additional payload to be stored on each query. +Use this property to pass information that can be used in other places. + +#### Inherited from + +```ts +WithRequired.meta +``` + +*** + +### networkMode? + +```ts +optional networkMode: NetworkMode; +``` + +Defined in: [packages/query-core/src/types.ts:265](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L265) + +Controls whether a query is allowed to run based on the current network connectivity. + +Defaults to `'online'`. + +#### See + +[Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. + +#### Inherited from + +```ts +WithRequired.networkMode +``` + +*** + +### notifyOnChangeProps? + +```ts +optional notifyOnChangeProps: NotifyOnChangeProps; +``` + +Defined in: [packages/query-core/src/types.ts:484](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L484) + +If set, the component will only re-render if any of the listed properties change. +When set to `['data', 'error']`, the component will only re-render when the `data` or `error` properties change. +When set to `'all'`, the component will re-render whenever a query is updated. +When set to a function, the function will be executed to compute the list of properties. + +Defaults to `undefined`, in which case property access is tracked automatically, and the +component only re-renders when one of the tracked properties changes. + +*** + +### persister? + +```ts +optional persister: QueryPersister, TPageParam>; +``` + +Defined in: [packages/query-core/src/types.ts:290](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L290) + +This option can be used to persist the result of a query to an external storage, bypassing the need to actually +call the `queryFn`. Useful for persisting a query's data across e.g. server/client boundaries. + +#### Inherited from + +```ts +WithRequired.persister +``` + +*** + +### placeholderData? + +```ts +optional placeholderData: + | NonFunctionGuard +| PlaceholderDataFunction, TError, NonFunctionGuard, TQueryKey>; +``` + +Defined in: [packages/query-core/src/types.ts:511](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L511) + +If set, this value will be used as the placeholder data for this particular query observer while the query is still in the `loading` data and no initialData has been provided. + +*** + +### queryFn? + +```ts +optional queryFn: + | typeof skipToken +| QueryFunction; +``` + +Defined in: [packages/query-core/src/types.ts:285](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L285) + +The function that the query will use to request data. +Required, unless a default query function has been set via `queryClient.setQueryDefaults` or +`queryClient.setDefaultOptions`. +Receives a [QueryFunctionContext](../type-aliases/QueryFunctionContext.md). +Must return a promise that will either resolve data or throw an error. The data cannot be `undefined`. + +#### Inherited from + +```ts +WithRequired.queryFn +``` + +*** + +### queryHash? + +```ts +optional queryHash: string; +``` + +Defined in: [packages/query-core/src/types.ts:295](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L295) + +The hashed form of `queryKey`, computed with `queryKeyHashFn` (or the default hashing function otherwise). Used +as the actual cache key internally. + +#### Inherited from + +```ts +WithRequired.queryHash +``` + +*** + +### queryKey + +```ts +queryKey: TQueryKey & object; +``` + +Defined in: [packages/query-core/src/types.ts:304](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L304) + +The query key to use for this query. + +The query key will be hashed into a stable hash. See [Query Keys](https://tanstack.com/query/latest/docs/framework/react/guides/query-keys) +for more information. + +The query will automatically update when this key changes (as long as `enabled` is not set to `false`). + +#### Inherited from + +```ts +WithRequired.queryKey +``` + +*** + +### queryKeyHashFn? + +```ts +optional queryKeyHashFn: QueryKeyHashFunction; +``` + +Defined in: [packages/query-core/src/types.ts:308](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L308) + +If specified, this function is used to hash the `queryKey` to a string. + +#### Inherited from + +```ts +WithRequired.queryKeyHashFn +``` + +*** + +### refetchInterval? + +```ts +optional refetchInterval: number | false | (query) => number | false | undefined; +``` + +Defined in: [packages/query-core/src/types.ts:414](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L414) + +If set to a number, the query will continuously refetch at this frequency in milliseconds. +If set to a function, the function will be executed with the latest data and query to compute a frequency + +Defaults to `false`. + +*** + +### refetchIntervalInBackground? + +```ts +optional refetchIntervalInBackground: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:425](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L425) + +If set to `true`, the query will continue to refetch while their tab/window is in the background. + +Defaults to `false`. + +*** + +### refetchOnMount? + +```ts +optional refetchOnMount: boolean | "always" | (query) => boolean | "always"; +``` + +Defined in: [packages/query-core/src/types.ts:462](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L462) + +If set to `true`, the query will refetch on mount if the data is stale. +If set to `false`, will disable additional instances of a query to trigger background refetch. +If set to `'always'`, the query will always refetch on mount (except when `staleTime: 'static'` is used). +If set to a function, the function will be executed with the latest data and query to compute the value + +Defaults to `true`. + +*** + +### refetchOnReconnect? + +```ts +optional refetchOnReconnect: boolean | "always" | (query) => boolean | "always"; +``` + +Defined in: [packages/query-core/src/types.ts:448](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L448) + +If set to `true`, the query will refetch on reconnect if the data is stale. +If set to `false`, the query will not refetch on reconnect. +If set to `'always'`, the query will always refetch on reconnect (except when `staleTime: 'static'` is used). +If set to a function, the function will be executed with the latest data and query to compute the value. + +Defaults to `true` unless `networkMode` is `'always'`. + +*** + +### refetchOnWindowFocus? + +```ts +optional refetchOnWindowFocus: boolean | "always" | (query) => boolean | "always"; +``` + +Defined in: [packages/query-core/src/types.ts:434](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L434) + +If set to `true`, the query will refetch on window focus if the data is stale. +If set to `false`, the query will not refetch on window focus. +If set to `'always'`, the query will always refetch on window focus (except when `staleTime: 'static'` is used). +If set to a function, the function will be executed with the latest data and query to compute the value. + +Defaults to `true`. + +*** + +### retry? + +```ts +optional retry: RetryValue; +``` + +Defined in: [packages/query-core/src/types.ts:246](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L246) + +If `false`, failed queries will not retry by default. +If `true`, failed queries will retry infinitely. +If set to an integer number, e.g. 3, failed queries will retry until the failed query count meets that number. +If set to a function `(failureCount, error) => boolean` failed queries will retry until the function returns false. + +Defaults to `3` on the client and `0` on the server. + +#### Inherited from + +```ts +WithRequired.retry +``` + +*** + +### retryDelay? + +```ts +optional retryDelay: RetryDelayValue; +``` + +Defined in: [packages/query-core/src/types.ts:258](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L258) + +This function receives a `retryAttempt` integer and the actual Error and returns the delay to apply before the +next attempt in milliseconds. + +A function like `attempt => Math.min(attempt > 1 ? 2 ** attempt * 1000 : 1000, 30 * 1000)` applies exponential +backoff. + +A function like `attempt => attempt * 1000` applies linear backoff. + +Defaults to a function that applies exponential backoff, capped at 30 seconds. + +#### Inherited from + +```ts +WithRequired.retryDelay +``` + +*** + +### retryOnMount? + +```ts +optional retryOnMount: QueryBooleanOption; +``` + +Defined in: [packages/query-core/src/types.ts:474](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L474) + +If set to `false`, the query will not be retried on mount if it contains an error. +If set to a function, the function will be executed with the query to compute the value. + +Defaults to `true`. + +*** + +### select()? + +```ts +optional select: (data) => TData; +``` + +Defined in: [packages/query-core/src/types.ts:500](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L500) + +This option can be used to transform or select a part of the data returned by the query function. It affects +the returned `data` value, but does not affect what gets stored in the query cache. +The `select` function will only run if `data` changed, or if the reference to the `select` function itself +changes. To optimize, memoize the function so its reference stays stable across calls. + +#### Parameters + +##### data + +`TQueryData` + +#### Returns + +`TData` + +*** + +### staleTime? + +```ts +optional staleTime: StaleTimeFunction; +``` + +Defined in: [packages/query-core/src/types.ts:407](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L407) + +The time in milliseconds after data is considered stale. +If set to `Infinity`, the data will never be considered stale. +If set to `'static'`, the data will never be considered stale. +If set to a function, the function will be executed with the query to compute a `staleTime`. + +Defaults to `0`. + +*** + +### structuralSharing? + +```ts +optional structuralSharing: boolean | (oldData, newData) => unknown; +``` + +Defined in: [packages/query-core/src/types.ts:330](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L330) + +Set this to `false` to disable structural sharing between query results. +Set this to a function which accepts the old and new data and returns resolved data of the same type to implement custom structural sharing logic. + +Defaults to `true`. + +#### Inherited from + +```ts +WithRequired.structuralSharing +``` + +*** + +### suspense? + +```ts +optional suspense: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:507](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L507) + +If set to `true`, the query will suspend when `status === 'pending'` +and throw errors when `status === 'error'`. + +Defaults to `false`. + +*** + +### throwOnError? + +```ts +optional throwOnError: ThrowOnError; +``` + +Defined in: [packages/query-core/src/types.ts:493](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L493) + +Whether errors should be thrown instead of setting the `error` property. +If set to `true` or `suspense` is `true`, all errors will be thrown to the error boundary. +If set to `false` and `suspense` is `false`, errors are returned as state. +If set to a function, it will be passed the error and the query, and it should return a boolean indicating whether to show the error in an error boundary (`true`) or return the error as state (`false`). + +Defaults to `false`. diff --git a/docs/framework/svelte/reference/interfaces/QueryObserverPendingResult.md b/docs/framework/svelte/reference/interfaces/QueryObserverPendingResult.md new file mode 100644 index 00000000000..8f00c426b64 --- /dev/null +++ b/docs/framework/svelte/reference/interfaces/QueryObserverPendingResult.md @@ -0,0 +1,452 @@ +--- +id: QueryObserverPendingResult +title: QueryObserverPendingResult +--- + +Defined in: [packages/query-core/src/types.ts:892](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L892) + +## Extends + +- [`QueryObserverBaseResult`](QueryObserverBaseResult.md)\<`TData`, `TError`\> + +## Type Parameters + +### TData + +`TData` = `unknown` + +### TError + +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) + +## Properties + +### data + +```ts +data: undefined; +``` + +Defined in: [packages/query-core/src/types.ts:896](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L896) + +The last successfully resolved data for the query. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`data`](QueryObserverBaseResult.md#data) + +*** + +### dataUpdatedAt + +```ts +dataUpdatedAt: number; +``` + +Defined in: [packages/query-core/src/types.ts:775](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L775) + +The timestamp for when the query most recently returned the `status` as `"success"`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`dataUpdatedAt`](QueryObserverBaseResult.md#dataupdatedat) + +*** + +### error + +```ts +error: null; +``` + +Defined in: [packages/query-core/src/types.ts:897](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L897) + +The error object for the query, if an error was thrown. +- Defaults to `null`. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`error`](QueryObserverBaseResult.md#error) + +*** + +### errorUpdateCount + +```ts +errorUpdateCount: number; +``` + +Defined in: [packages/query-core/src/types.ts:799](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L799) + +The sum of all errors. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`errorUpdateCount`](QueryObserverBaseResult.md#errorupdatecount) + +*** + +### errorUpdatedAt + +```ts +errorUpdatedAt: number; +``` + +Defined in: [packages/query-core/src/types.ts:784](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L784) + +The timestamp for when the query most recently returned the `status` as `"error"`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`errorUpdatedAt`](QueryObserverBaseResult.md#errorupdatedat) + +*** + +### failureCount + +```ts +failureCount: number; +``` + +Defined in: [packages/query-core/src/types.ts:790](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L790) + +The failure count for the query. +- Incremented every time the query fails. +- Reset to `0` when the query succeeds. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`failureCount`](QueryObserverBaseResult.md#failurecount) + +*** + +### failureReason + +```ts +failureReason: TError | null; +``` + +Defined in: [packages/query-core/src/types.ts:795](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L795) + +The failure reason for the query retry. +- Reset to `null` when the query succeeds. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`failureReason`](QueryObserverBaseResult.md#failurereason) + +*** + +### fetchStatus + +```ts +fetchStatus: FetchStatus; +``` + +Defined in: [packages/query-core/src/types.ts:889](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L889) + +The fetch status of the query. +- `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. +- `paused`: The query wanted to fetch, but has been `paused`. +- `idle`: The query is not fetching. +- See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`fetchStatus`](QueryObserverBaseResult.md#fetchstatus) + +*** + +### isEnabled + +```ts +isEnabled: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:867](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L867) + +`true` if this observer is enabled, `false` otherwise. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isEnabled`](QueryObserverBaseResult.md#isenabled) + +*** + +### isError + +```ts +isError: false; +``` + +Defined in: [packages/query-core/src/types.ts:898](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L898) + +A derived boolean from the `status` variable, provided for convenience. +- `true` if the query attempt resulted in an error. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isError`](QueryObserverBaseResult.md#iserror) + +*** + +### isFetched + +```ts +isFetched: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:808](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L808) + +Will be `true` if the query has been fetched. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isFetched`](QueryObserverBaseResult.md#isfetched) + +*** + +### isFetchedAfterMount + +```ts +isFetchedAfterMount: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:813](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L813) + +Will be `true` if the query has been fetched after the component mounted. +- This property can be used to not show any previously cached data. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isFetchedAfterMount`](QueryObserverBaseResult.md#isfetchedaftermount) + +*** + +### isFetching + +```ts +isFetching: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:818](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L818) + +A derived boolean from the `fetchStatus` variable, provided for convenience. +- `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isFetching`](QueryObserverBaseResult.md#isfetching) + +*** + +### ~~isInitialLoading~~ + +```ts +isInitialLoading: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:836](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L836) + +#### Deprecated + +`isInitialLoading` is being deprecated in favor of `isLoading` +and will be removed in the next major version. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isInitialLoading`](QueryObserverBaseResult.md#isinitialloading) + +*** + +### isLoading + +```ts +isLoading: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:823](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L823) + +Is `true` whenever the first fetch for a query is in-flight. +- Is the same as `isFetching && isPending`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoading`](QueryObserverBaseResult.md#isloading) + +*** + +### isLoadingError + +```ts +isLoadingError: false; +``` + +Defined in: [packages/query-core/src/types.ts:900](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L900) + +Will be `true` if the query failed while fetching for the first time. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoadingError`](QueryObserverBaseResult.md#isloadingerror) + +*** + +### isPaused + +```ts +isPaused: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:841](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L841) + +A derived boolean from the `fetchStatus` variable, provided for convenience. +- The query wanted to fetch, but has been `paused`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPaused`](QueryObserverBaseResult.md#ispaused) + +*** + +### isPending + +```ts +isPending: true; +``` + +Defined in: [packages/query-core/src/types.ts:899](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L899) + +Will be `pending` if there's no cached data and no query attempt was finished yet. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPending`](QueryObserverBaseResult.md#ispending) + +*** + +### isPlaceholderData + +```ts +isPlaceholderData: false; +``` + +Defined in: [packages/query-core/src/types.ts:903](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L903) + +Will be `true` if the data shown is the placeholder data. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPlaceholderData`](QueryObserverBaseResult.md#isplaceholderdata) + +*** + +### isRefetchError + +```ts +isRefetchError: false; +``` + +Defined in: [packages/query-core/src/types.ts:901](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L901) + +Will be `true` if the query failed while refetching. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetchError`](QueryObserverBaseResult.md#isrefetcherror) + +*** + +### isRefetching + +```ts +isRefetching: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:854](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L854) + +Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. +- Is the same as `isFetching && !isPending`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetching`](QueryObserverBaseResult.md#isrefetching) + +*** + +### isStale + +```ts +isStale: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:858](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L858) + +Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isStale`](QueryObserverBaseResult.md#isstale) + +*** + +### isSuccess + +```ts +isSuccess: false; +``` + +Defined in: [packages/query-core/src/types.ts:902](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L902) + +A derived boolean from the `status` variable, provided for convenience. +- `true` if the query has received a response with no errors and is ready to display its data. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isSuccess`](QueryObserverBaseResult.md#issuccess) + +*** + +### refetch() + +```ts +refetch: (options?) => Promise>; +``` + +Defined in: [packages/query-core/src/types.ts:871](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L871) + +A function to manually refetch the query. + +#### Parameters + +##### options? + +[`RefetchOptions`](RefetchOptions.md) + +#### Returns + +`Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`refetch`](QueryObserverBaseResult.md#refetch) + +*** + +### status + +```ts +status: "pending"; +``` + +Defined in: [packages/query-core/src/types.ts:904](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L904) + +The status of the query. +- Will be: + - `pending` if there's no cached data and no query attempt was finished yet. + - `error` if the query attempt resulted in an error. + - `success` if the query has received a response with no errors and is ready to display its data. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`status`](QueryObserverBaseResult.md#status) diff --git a/docs/framework/svelte/reference/interfaces/QueryObserverPlaceholderResult.md b/docs/framework/svelte/reference/interfaces/QueryObserverPlaceholderResult.md new file mode 100644 index 00000000000..bbf3da387f9 --- /dev/null +++ b/docs/framework/svelte/reference/interfaces/QueryObserverPlaceholderResult.md @@ -0,0 +1,452 @@ +--- +id: QueryObserverPlaceholderResult +title: QueryObserverPlaceholderResult +--- + +Defined in: [packages/query-core/src/types.ts:971](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L971) + +## Extends + +- [`QueryObserverBaseResult`](QueryObserverBaseResult.md)\<`TData`, `TError`\> + +## Type Parameters + +### TData + +`TData` = `unknown` + +### TError + +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) + +## Properties + +### data + +```ts +data: TData; +``` + +Defined in: [packages/query-core/src/types.ts:975](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L975) + +The last successfully resolved data for the query. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`data`](QueryObserverBaseResult.md#data) + +*** + +### dataUpdatedAt + +```ts +dataUpdatedAt: number; +``` + +Defined in: [packages/query-core/src/types.ts:775](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L775) + +The timestamp for when the query most recently returned the `status` as `"success"`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`dataUpdatedAt`](QueryObserverBaseResult.md#dataupdatedat) + +*** + +### error + +```ts +error: null; +``` + +Defined in: [packages/query-core/src/types.ts:977](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L977) + +The error object for the query, if an error was thrown. +- Defaults to `null`. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`error`](QueryObserverBaseResult.md#error) + +*** + +### errorUpdateCount + +```ts +errorUpdateCount: number; +``` + +Defined in: [packages/query-core/src/types.ts:799](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L799) + +The sum of all errors. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`errorUpdateCount`](QueryObserverBaseResult.md#errorupdatecount) + +*** + +### errorUpdatedAt + +```ts +errorUpdatedAt: number; +``` + +Defined in: [packages/query-core/src/types.ts:784](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L784) + +The timestamp for when the query most recently returned the `status` as `"error"`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`errorUpdatedAt`](QueryObserverBaseResult.md#errorupdatedat) + +*** + +### failureCount + +```ts +failureCount: number; +``` + +Defined in: [packages/query-core/src/types.ts:790](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L790) + +The failure count for the query. +- Incremented every time the query fails. +- Reset to `0` when the query succeeds. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`failureCount`](QueryObserverBaseResult.md#failurecount) + +*** + +### failureReason + +```ts +failureReason: TError | null; +``` + +Defined in: [packages/query-core/src/types.ts:795](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L795) + +The failure reason for the query retry. +- Reset to `null` when the query succeeds. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`failureReason`](QueryObserverBaseResult.md#failurereason) + +*** + +### fetchStatus + +```ts +fetchStatus: FetchStatus; +``` + +Defined in: [packages/query-core/src/types.ts:889](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L889) + +The fetch status of the query. +- `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. +- `paused`: The query wanted to fetch, but has been `paused`. +- `idle`: The query is not fetching. +- See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`fetchStatus`](QueryObserverBaseResult.md#fetchstatus) + +*** + +### isEnabled + +```ts +isEnabled: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:867](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L867) + +`true` if this observer is enabled, `false` otherwise. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isEnabled`](QueryObserverBaseResult.md#isenabled) + +*** + +### isError + +```ts +isError: false; +``` + +Defined in: [packages/query-core/src/types.ts:976](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L976) + +A derived boolean from the `status` variable, provided for convenience. +- `true` if the query attempt resulted in an error. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isError`](QueryObserverBaseResult.md#iserror) + +*** + +### isFetched + +```ts +isFetched: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:808](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L808) + +Will be `true` if the query has been fetched. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isFetched`](QueryObserverBaseResult.md#isfetched) + +*** + +### isFetchedAfterMount + +```ts +isFetchedAfterMount: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:813](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L813) + +Will be `true` if the query has been fetched after the component mounted. +- This property can be used to not show any previously cached data. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isFetchedAfterMount`](QueryObserverBaseResult.md#isfetchedaftermount) + +*** + +### isFetching + +```ts +isFetching: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:818](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L818) + +A derived boolean from the `fetchStatus` variable, provided for convenience. +- `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isFetching`](QueryObserverBaseResult.md#isfetching) + +*** + +### ~~isInitialLoading~~ + +```ts +isInitialLoading: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:836](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L836) + +#### Deprecated + +`isInitialLoading` is being deprecated in favor of `isLoading` +and will be removed in the next major version. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isInitialLoading`](QueryObserverBaseResult.md#isinitialloading) + +*** + +### isLoading + +```ts +isLoading: false; +``` + +Defined in: [packages/query-core/src/types.ts:979](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L979) + +Is `true` whenever the first fetch for a query is in-flight. +- Is the same as `isFetching && isPending`. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoading`](QueryObserverBaseResult.md#isloading) + +*** + +### isLoadingError + +```ts +isLoadingError: false; +``` + +Defined in: [packages/query-core/src/types.ts:980](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L980) + +Will be `true` if the query failed while fetching for the first time. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoadingError`](QueryObserverBaseResult.md#isloadingerror) + +*** + +### isPaused + +```ts +isPaused: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:841](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L841) + +A derived boolean from the `fetchStatus` variable, provided for convenience. +- The query wanted to fetch, but has been `paused`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPaused`](QueryObserverBaseResult.md#ispaused) + +*** + +### isPending + +```ts +isPending: false; +``` + +Defined in: [packages/query-core/src/types.ts:978](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L978) + +Will be `pending` if there's no cached data and no query attempt was finished yet. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPending`](QueryObserverBaseResult.md#ispending) + +*** + +### isPlaceholderData + +```ts +isPlaceholderData: true; +``` + +Defined in: [packages/query-core/src/types.ts:983](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L983) + +Will be `true` if the data shown is the placeholder data. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPlaceholderData`](QueryObserverBaseResult.md#isplaceholderdata) + +*** + +### isRefetchError + +```ts +isRefetchError: false; +``` + +Defined in: [packages/query-core/src/types.ts:981](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L981) + +Will be `true` if the query failed while refetching. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetchError`](QueryObserverBaseResult.md#isrefetcherror) + +*** + +### isRefetching + +```ts +isRefetching: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:854](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L854) + +Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. +- Is the same as `isFetching && !isPending`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetching`](QueryObserverBaseResult.md#isrefetching) + +*** + +### isStale + +```ts +isStale: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:858](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L858) + +Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isStale`](QueryObserverBaseResult.md#isstale) + +*** + +### isSuccess + +```ts +isSuccess: true; +``` + +Defined in: [packages/query-core/src/types.ts:982](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L982) + +A derived boolean from the `status` variable, provided for convenience. +- `true` if the query has received a response with no errors and is ready to display its data. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isSuccess`](QueryObserverBaseResult.md#issuccess) + +*** + +### refetch() + +```ts +refetch: (options?) => Promise>; +``` + +Defined in: [packages/query-core/src/types.ts:871](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L871) + +A function to manually refetch the query. + +#### Parameters + +##### options? + +[`RefetchOptions`](RefetchOptions.md) + +#### Returns + +`Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`refetch`](QueryObserverBaseResult.md#refetch) + +*** + +### status + +```ts +status: "success"; +``` + +Defined in: [packages/query-core/src/types.ts:984](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L984) + +The status of the query. +- Will be: + - `pending` if there's no cached data and no query attempt was finished yet. + - `error` if the query attempt resulted in an error. + - `success` if the query has received a response with no errors and is ready to display its data. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`status`](QueryObserverBaseResult.md#status) diff --git a/docs/framework/svelte/reference/interfaces/QueryObserverRefetchErrorResult.md b/docs/framework/svelte/reference/interfaces/QueryObserverRefetchErrorResult.md new file mode 100644 index 00000000000..345ecab35e1 --- /dev/null +++ b/docs/framework/svelte/reference/interfaces/QueryObserverRefetchErrorResult.md @@ -0,0 +1,452 @@ +--- +id: QueryObserverRefetchErrorResult +title: QueryObserverRefetchErrorResult +--- + +Defined in: [packages/query-core/src/types.ts:939](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L939) + +## Extends + +- [`QueryObserverBaseResult`](QueryObserverBaseResult.md)\<`TData`, `TError`\> + +## Type Parameters + +### TData + +`TData` = `unknown` + +### TError + +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) + +## Properties + +### data + +```ts +data: TData; +``` + +Defined in: [packages/query-core/src/types.ts:943](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L943) + +The last successfully resolved data for the query. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`data`](QueryObserverBaseResult.md#data) + +*** + +### dataUpdatedAt + +```ts +dataUpdatedAt: number; +``` + +Defined in: [packages/query-core/src/types.ts:775](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L775) + +The timestamp for when the query most recently returned the `status` as `"success"`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`dataUpdatedAt`](QueryObserverBaseResult.md#dataupdatedat) + +*** + +### error + +```ts +error: TError; +``` + +Defined in: [packages/query-core/src/types.ts:944](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L944) + +The error object for the query, if an error was thrown. +- Defaults to `null`. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`error`](QueryObserverBaseResult.md#error) + +*** + +### errorUpdateCount + +```ts +errorUpdateCount: number; +``` + +Defined in: [packages/query-core/src/types.ts:799](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L799) + +The sum of all errors. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`errorUpdateCount`](QueryObserverBaseResult.md#errorupdatecount) + +*** + +### errorUpdatedAt + +```ts +errorUpdatedAt: number; +``` + +Defined in: [packages/query-core/src/types.ts:784](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L784) + +The timestamp for when the query most recently returned the `status` as `"error"`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`errorUpdatedAt`](QueryObserverBaseResult.md#errorupdatedat) + +*** + +### failureCount + +```ts +failureCount: number; +``` + +Defined in: [packages/query-core/src/types.ts:790](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L790) + +The failure count for the query. +- Incremented every time the query fails. +- Reset to `0` when the query succeeds. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`failureCount`](QueryObserverBaseResult.md#failurecount) + +*** + +### failureReason + +```ts +failureReason: TError | null; +``` + +Defined in: [packages/query-core/src/types.ts:795](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L795) + +The failure reason for the query retry. +- Reset to `null` when the query succeeds. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`failureReason`](QueryObserverBaseResult.md#failurereason) + +*** + +### fetchStatus + +```ts +fetchStatus: FetchStatus; +``` + +Defined in: [packages/query-core/src/types.ts:889](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L889) + +The fetch status of the query. +- `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. +- `paused`: The query wanted to fetch, but has been `paused`. +- `idle`: The query is not fetching. +- See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`fetchStatus`](QueryObserverBaseResult.md#fetchstatus) + +*** + +### isEnabled + +```ts +isEnabled: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:867](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L867) + +`true` if this observer is enabled, `false` otherwise. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isEnabled`](QueryObserverBaseResult.md#isenabled) + +*** + +### isError + +```ts +isError: true; +``` + +Defined in: [packages/query-core/src/types.ts:945](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L945) + +A derived boolean from the `status` variable, provided for convenience. +- `true` if the query attempt resulted in an error. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isError`](QueryObserverBaseResult.md#iserror) + +*** + +### isFetched + +```ts +isFetched: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:808](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L808) + +Will be `true` if the query has been fetched. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isFetched`](QueryObserverBaseResult.md#isfetched) + +*** + +### isFetchedAfterMount + +```ts +isFetchedAfterMount: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:813](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L813) + +Will be `true` if the query has been fetched after the component mounted. +- This property can be used to not show any previously cached data. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isFetchedAfterMount`](QueryObserverBaseResult.md#isfetchedaftermount) + +*** + +### isFetching + +```ts +isFetching: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:818](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L818) + +A derived boolean from the `fetchStatus` variable, provided for convenience. +- `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isFetching`](QueryObserverBaseResult.md#isfetching) + +*** + +### ~~isInitialLoading~~ + +```ts +isInitialLoading: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:836](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L836) + +#### Deprecated + +`isInitialLoading` is being deprecated in favor of `isLoading` +and will be removed in the next major version. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isInitialLoading`](QueryObserverBaseResult.md#isinitialloading) + +*** + +### isLoading + +```ts +isLoading: false; +``` + +Defined in: [packages/query-core/src/types.ts:947](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L947) + +Is `true` whenever the first fetch for a query is in-flight. +- Is the same as `isFetching && isPending`. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoading`](QueryObserverBaseResult.md#isloading) + +*** + +### isLoadingError + +```ts +isLoadingError: false; +``` + +Defined in: [packages/query-core/src/types.ts:948](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L948) + +Will be `true` if the query failed while fetching for the first time. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoadingError`](QueryObserverBaseResult.md#isloadingerror) + +*** + +### isPaused + +```ts +isPaused: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:841](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L841) + +A derived boolean from the `fetchStatus` variable, provided for convenience. +- The query wanted to fetch, but has been `paused`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPaused`](QueryObserverBaseResult.md#ispaused) + +*** + +### isPending + +```ts +isPending: false; +``` + +Defined in: [packages/query-core/src/types.ts:946](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L946) + +Will be `pending` if there's no cached data and no query attempt was finished yet. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPending`](QueryObserverBaseResult.md#ispending) + +*** + +### isPlaceholderData + +```ts +isPlaceholderData: false; +``` + +Defined in: [packages/query-core/src/types.ts:951](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L951) + +Will be `true` if the data shown is the placeholder data. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPlaceholderData`](QueryObserverBaseResult.md#isplaceholderdata) + +*** + +### isRefetchError + +```ts +isRefetchError: true; +``` + +Defined in: [packages/query-core/src/types.ts:949](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L949) + +Will be `true` if the query failed while refetching. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetchError`](QueryObserverBaseResult.md#isrefetcherror) + +*** + +### isRefetching + +```ts +isRefetching: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:854](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L854) + +Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. +- Is the same as `isFetching && !isPending`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetching`](QueryObserverBaseResult.md#isrefetching) + +*** + +### isStale + +```ts +isStale: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:858](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L858) + +Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isStale`](QueryObserverBaseResult.md#isstale) + +*** + +### isSuccess + +```ts +isSuccess: false; +``` + +Defined in: [packages/query-core/src/types.ts:950](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L950) + +A derived boolean from the `status` variable, provided for convenience. +- `true` if the query has received a response with no errors and is ready to display its data. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isSuccess`](QueryObserverBaseResult.md#issuccess) + +*** + +### refetch() + +```ts +refetch: (options?) => Promise>; +``` + +Defined in: [packages/query-core/src/types.ts:871](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L871) + +A function to manually refetch the query. + +#### Parameters + +##### options? + +[`RefetchOptions`](RefetchOptions.md) + +#### Returns + +`Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`refetch`](QueryObserverBaseResult.md#refetch) + +*** + +### status + +```ts +status: "error"; +``` + +Defined in: [packages/query-core/src/types.ts:952](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L952) + +The status of the query. +- Will be: + - `pending` if there's no cached data and no query attempt was finished yet. + - `error` if the query attempt resulted in an error. + - `success` if the query has received a response with no errors and is ready to display its data. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`status`](QueryObserverBaseResult.md#status) diff --git a/docs/framework/svelte/reference/interfaces/QueryObserverSuccessResult.md b/docs/framework/svelte/reference/interfaces/QueryObserverSuccessResult.md new file mode 100644 index 00000000000..3942655c627 --- /dev/null +++ b/docs/framework/svelte/reference/interfaces/QueryObserverSuccessResult.md @@ -0,0 +1,452 @@ +--- +id: QueryObserverSuccessResult +title: QueryObserverSuccessResult +--- + +Defined in: [packages/query-core/src/types.ts:955](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L955) + +## Extends + +- [`QueryObserverBaseResult`](QueryObserverBaseResult.md)\<`TData`, `TError`\> + +## Type Parameters + +### TData + +`TData` = `unknown` + +### TError + +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) + +## Properties + +### data + +```ts +data: TData; +``` + +Defined in: [packages/query-core/src/types.ts:959](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L959) + +The last successfully resolved data for the query. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`data`](QueryObserverBaseResult.md#data) + +*** + +### dataUpdatedAt + +```ts +dataUpdatedAt: number; +``` + +Defined in: [packages/query-core/src/types.ts:775](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L775) + +The timestamp for when the query most recently returned the `status` as `"success"`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`dataUpdatedAt`](QueryObserverBaseResult.md#dataupdatedat) + +*** + +### error + +```ts +error: null; +``` + +Defined in: [packages/query-core/src/types.ts:960](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L960) + +The error object for the query, if an error was thrown. +- Defaults to `null`. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`error`](QueryObserverBaseResult.md#error) + +*** + +### errorUpdateCount + +```ts +errorUpdateCount: number; +``` + +Defined in: [packages/query-core/src/types.ts:799](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L799) + +The sum of all errors. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`errorUpdateCount`](QueryObserverBaseResult.md#errorupdatecount) + +*** + +### errorUpdatedAt + +```ts +errorUpdatedAt: number; +``` + +Defined in: [packages/query-core/src/types.ts:784](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L784) + +The timestamp for when the query most recently returned the `status` as `"error"`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`errorUpdatedAt`](QueryObserverBaseResult.md#errorupdatedat) + +*** + +### failureCount + +```ts +failureCount: number; +``` + +Defined in: [packages/query-core/src/types.ts:790](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L790) + +The failure count for the query. +- Incremented every time the query fails. +- Reset to `0` when the query succeeds. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`failureCount`](QueryObserverBaseResult.md#failurecount) + +*** + +### failureReason + +```ts +failureReason: TError | null; +``` + +Defined in: [packages/query-core/src/types.ts:795](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L795) + +The failure reason for the query retry. +- Reset to `null` when the query succeeds. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`failureReason`](QueryObserverBaseResult.md#failurereason) + +*** + +### fetchStatus + +```ts +fetchStatus: FetchStatus; +``` + +Defined in: [packages/query-core/src/types.ts:889](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L889) + +The fetch status of the query. +- `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. +- `paused`: The query wanted to fetch, but has been `paused`. +- `idle`: The query is not fetching. +- See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`fetchStatus`](QueryObserverBaseResult.md#fetchstatus) + +*** + +### isEnabled + +```ts +isEnabled: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:867](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L867) + +`true` if this observer is enabled, `false` otherwise. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isEnabled`](QueryObserverBaseResult.md#isenabled) + +*** + +### isError + +```ts +isError: false; +``` + +Defined in: [packages/query-core/src/types.ts:961](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L961) + +A derived boolean from the `status` variable, provided for convenience. +- `true` if the query attempt resulted in an error. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isError`](QueryObserverBaseResult.md#iserror) + +*** + +### isFetched + +```ts +isFetched: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:808](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L808) + +Will be `true` if the query has been fetched. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isFetched`](QueryObserverBaseResult.md#isfetched) + +*** + +### isFetchedAfterMount + +```ts +isFetchedAfterMount: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:813](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L813) + +Will be `true` if the query has been fetched after the component mounted. +- This property can be used to not show any previously cached data. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isFetchedAfterMount`](QueryObserverBaseResult.md#isfetchedaftermount) + +*** + +### isFetching + +```ts +isFetching: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:818](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L818) + +A derived boolean from the `fetchStatus` variable, provided for convenience. +- `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isFetching`](QueryObserverBaseResult.md#isfetching) + +*** + +### ~~isInitialLoading~~ + +```ts +isInitialLoading: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:836](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L836) + +#### Deprecated + +`isInitialLoading` is being deprecated in favor of `isLoading` +and will be removed in the next major version. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isInitialLoading`](QueryObserverBaseResult.md#isinitialloading) + +*** + +### isLoading + +```ts +isLoading: false; +``` + +Defined in: [packages/query-core/src/types.ts:963](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L963) + +Is `true` whenever the first fetch for a query is in-flight. +- Is the same as `isFetching && isPending`. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoading`](QueryObserverBaseResult.md#isloading) + +*** + +### isLoadingError + +```ts +isLoadingError: false; +``` + +Defined in: [packages/query-core/src/types.ts:964](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L964) + +Will be `true` if the query failed while fetching for the first time. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoadingError`](QueryObserverBaseResult.md#isloadingerror) + +*** + +### isPaused + +```ts +isPaused: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:841](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L841) + +A derived boolean from the `fetchStatus` variable, provided for convenience. +- The query wanted to fetch, but has been `paused`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPaused`](QueryObserverBaseResult.md#ispaused) + +*** + +### isPending + +```ts +isPending: false; +``` + +Defined in: [packages/query-core/src/types.ts:962](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L962) + +Will be `pending` if there's no cached data and no query attempt was finished yet. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPending`](QueryObserverBaseResult.md#ispending) + +*** + +### isPlaceholderData + +```ts +isPlaceholderData: false; +``` + +Defined in: [packages/query-core/src/types.ts:967](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L967) + +Will be `true` if the data shown is the placeholder data. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPlaceholderData`](QueryObserverBaseResult.md#isplaceholderdata) + +*** + +### isRefetchError + +```ts +isRefetchError: false; +``` + +Defined in: [packages/query-core/src/types.ts:965](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L965) + +Will be `true` if the query failed while refetching. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetchError`](QueryObserverBaseResult.md#isrefetcherror) + +*** + +### isRefetching + +```ts +isRefetching: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:854](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L854) + +Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. +- Is the same as `isFetching && !isPending`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetching`](QueryObserverBaseResult.md#isrefetching) + +*** + +### isStale + +```ts +isStale: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:858](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L858) + +Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isStale`](QueryObserverBaseResult.md#isstale) + +*** + +### isSuccess + +```ts +isSuccess: true; +``` + +Defined in: [packages/query-core/src/types.ts:966](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L966) + +A derived boolean from the `status` variable, provided for convenience. +- `true` if the query has received a response with no errors and is ready to display its data. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isSuccess`](QueryObserverBaseResult.md#issuccess) + +*** + +### refetch() + +```ts +refetch: (options?) => Promise>; +``` + +Defined in: [packages/query-core/src/types.ts:871](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L871) + +A function to manually refetch the query. + +#### Parameters + +##### options? + +[`RefetchOptions`](RefetchOptions.md) + +#### Returns + +`Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`refetch`](QueryObserverBaseResult.md#refetch) + +*** + +### status + +```ts +status: "success"; +``` + +Defined in: [packages/query-core/src/types.ts:968](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L968) + +The status of the query. +- Will be: + - `pending` if there's no cached data and no query attempt was finished yet. + - `error` if the query attempt resulted in an error. + - `success` if the query has received a response with no errors and is ready to display its data. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`status`](QueryObserverBaseResult.md#status) diff --git a/docs/framework/svelte/reference/interfaces/QueryOptions.md b/docs/framework/svelte/reference/interfaces/QueryOptions.md new file mode 100644 index 00000000000..7e059d3a1d6 --- /dev/null +++ b/docs/framework/svelte/reference/interfaces/QueryOptions.md @@ -0,0 +1,247 @@ +--- +id: QueryOptions +title: QueryOptions +--- + +Defined in: [packages/query-core/src/types.ts:231](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L231) + +## Type Parameters + +### TQueryFnData + +`TQueryFnData` = `unknown` + +### TError + +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) + +### TData + +`TData` = `TQueryFnData` + +### TQueryKey + +`TQueryKey` *extends* [`QueryKey`](../type-aliases/QueryKey.md) = [`QueryKey`](../type-aliases/QueryKey.md) + +### TPageParam + +`TPageParam` = `never` + +## Properties + +### gcTime? + +```ts +optional gcTime: number; +``` + +Defined in: [packages/query-core/src/types.ts:277](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L277) + +The time in milliseconds that unused/inactive cache data remains in memory. +When a query's cache becomes unused or inactive, that cache data will be garbage collected after this duration. +When different garbage collection times are specified, the longest one will be used. +Setting it to `Infinity` will disable garbage collection. + +Defaults to `5 * 60 * 1000` (5 minutes), or `Infinity` during SSR. + +Note: the maximum allowed time is about 24 days, imposed by `setTimeout`'s 32-bit signed integer delay — see +`timeoutManager.setTimeoutProvider` for a workaround. + +*** + +### initialData? + +```ts +optional initialData: + | TData +| InitialDataFunction; +``` + +Defined in: [packages/query-core/src/types.ts:317](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L317) + +If set, this value will be used as the initial data for the query cache (as long as the query hasn't been +created or cached yet). +If set to a function, the function will be called **once** during the shared/root query initialization, and be +expected to synchronously return the initial data. +Initial data is considered stale by default unless a `staleTime` has been set. +`initialData` **is persisted** to the cache. + +*** + +### initialDataUpdatedAt? + +```ts +optional initialDataUpdatedAt: number | () => number | undefined; +``` + +Defined in: [packages/query-core/src/types.ts:321](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L321) + +If set, this value will be used as the time (in milliseconds) of when the `initialData` itself was last updated. + +*** + +### maxPages? + +```ts +optional maxPages: number; +``` + +Defined in: [packages/query-core/src/types.ts:345](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L345) + +Maximum number of pages to store in the data of an infinite query. + +*** + +### meta? + +```ts +optional meta: Record; +``` + +Defined in: [packages/query-core/src/types.ts:341](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L341) + +Additional payload to be stored on each query. +Use this property to pass information that can be used in other places. + +*** + +### networkMode? + +```ts +optional networkMode: NetworkMode; +``` + +Defined in: [packages/query-core/src/types.ts:265](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L265) + +Controls whether a query is allowed to run based on the current network connectivity. + +Defaults to `'online'`. + +#### See + +[Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. + +*** + +### persister? + +```ts +optional persister: QueryPersister, TPageParam>; +``` + +Defined in: [packages/query-core/src/types.ts:290](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L290) + +This option can be used to persist the result of a query to an external storage, bypassing the need to actually +call the `queryFn`. Useful for persisting a query's data across e.g. server/client boundaries. + +*** + +### queryFn? + +```ts +optional queryFn: + | QueryFunction + | typeof skipToken; +``` + +Defined in: [packages/query-core/src/types.ts:285](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L285) + +The function that the query will use to request data. +Required, unless a default query function has been set via `queryClient.setQueryDefaults` or +`queryClient.setDefaultOptions`. +Receives a [QueryFunctionContext](../type-aliases/QueryFunctionContext.md). +Must return a promise that will either resolve data or throw an error. The data cannot be `undefined`. + +*** + +### queryHash? + +```ts +optional queryHash: string; +``` + +Defined in: [packages/query-core/src/types.ts:295](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L295) + +The hashed form of `queryKey`, computed with `queryKeyHashFn` (or the default hashing function otherwise). Used +as the actual cache key internally. + +*** + +### queryKey? + +```ts +optional queryKey: TQueryKey; +``` + +Defined in: [packages/query-core/src/types.ts:304](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L304) + +The query key to use for this query. + +The query key will be hashed into a stable hash. See [Query Keys](https://tanstack.com/query/latest/docs/framework/react/guides/query-keys) +for more information. + +The query will automatically update when this key changes (as long as `enabled` is not set to `false`). + +*** + +### queryKeyHashFn? + +```ts +optional queryKeyHashFn: QueryKeyHashFunction; +``` + +Defined in: [packages/query-core/src/types.ts:308](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L308) + +If specified, this function is used to hash the `queryKey` to a string. + +*** + +### retry? + +```ts +optional retry: RetryValue; +``` + +Defined in: [packages/query-core/src/types.ts:246](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L246) + +If `false`, failed queries will not retry by default. +If `true`, failed queries will retry infinitely. +If set to an integer number, e.g. 3, failed queries will retry until the failed query count meets that number. +If set to a function `(failureCount, error) => boolean` failed queries will retry until the function returns false. + +Defaults to `3` on the client and `0` on the server. + +*** + +### retryDelay? + +```ts +optional retryDelay: RetryDelayValue; +``` + +Defined in: [packages/query-core/src/types.ts:258](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L258) + +This function receives a `retryAttempt` integer and the actual Error and returns the delay to apply before the +next attempt in milliseconds. + +A function like `attempt => Math.min(attempt > 1 ? 2 ** attempt * 1000 : 1000, 30 * 1000)` applies exponential +backoff. + +A function like `attempt => attempt * 1000` applies linear backoff. + +Defaults to a function that applies exponential backoff, capped at 30 seconds. + +*** + +### structuralSharing? + +```ts +optional structuralSharing: boolean | (oldData, newData) => unknown; +``` + +Defined in: [packages/query-core/src/types.ts:330](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L330) + +Set this to `false` to disable structural sharing between query results. +Set this to a function which accepts the old and new data and returns resolved data of the same type to implement custom structural sharing logic. + +Defaults to `true`. diff --git a/docs/framework/svelte/reference/interfaces/QueryState.md b/docs/framework/svelte/reference/interfaces/QueryState.md new file mode 100644 index 00000000000..7dce476d743 --- /dev/null +++ b/docs/framework/svelte/reference/interfaces/QueryState.md @@ -0,0 +1,175 @@ +--- +id: QueryState +title: QueryState +--- + +Defined in: [packages/query-core/src/query.ts:52](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L52) + +The raw state stored on a `Query` instance. This is the underlying state +that observer results (e.g. `QueryObserverResult`) are derived from. + +## Type Parameters + +### TData + +`TData` = `unknown` + +### TError + +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) + +## Properties + +### data + +```ts +data: TData | undefined; +``` + +Defined in: [packages/query-core/src/query.ts:56](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L56) + +The last successfully resolved data for the query. + +*** + +### dataUpdateCount + +```ts +dataUpdateCount: number; +``` + +Defined in: [packages/query-core/src/query.ts:60](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L60) + +The number of times the query has successfully resolved. + +*** + +### dataUpdatedAt + +```ts +dataUpdatedAt: number; +``` + +Defined in: [packages/query-core/src/query.ts:64](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L64) + +The timestamp for when the query most recently returned the `status` as `"success"`. + +*** + +### error + +```ts +error: TError | null; +``` + +Defined in: [packages/query-core/src/query.ts:69](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L69) + +The error object for the query, if the last attempt resulted in an error. +- Defaults to `null`. + +*** + +### errorUpdateCount + +```ts +errorUpdateCount: number; +``` + +Defined in: [packages/query-core/src/query.ts:73](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L73) + +The sum of all errors, incremented every time the query resolves with an error. + +*** + +### errorUpdatedAt + +```ts +errorUpdatedAt: number; +``` + +Defined in: [packages/query-core/src/query.ts:77](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L77) + +The timestamp for when the query most recently returned the `status` as `"error"`. + +*** + +### fetchFailureCount + +```ts +fetchFailureCount: number; +``` + +Defined in: [packages/query-core/src/query.ts:83](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L83) + +The failure count for the current fetch. +- Incremented every time the fetch fails. +- Reset to `0` when the fetch succeeds. + +*** + +### fetchFailureReason + +```ts +fetchFailureReason: TError | null; +``` + +Defined in: [packages/query-core/src/query.ts:88](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L88) + +The reason the current fetch failed, as reported by the retryer. +- Reset to `null` when the fetch succeeds. + +*** + +### fetchMeta + +```ts +fetchMeta: FetchMeta | null; +``` + +Defined in: [packages/query-core/src/query.ts:93](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L93) + +Metadata passed to the currently in-flight (or most recent) fetch, e.g. the +`fetchMore` direction for infinite queries. + +*** + +### fetchStatus + +```ts +fetchStatus: FetchStatus; +``` + +Defined in: [packages/query-core/src/query.ts:112](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L112) + +The fetch status of the query. +- `fetching`: the `queryFn` is currently executing. +- `paused`: a fetch wanted to run but has been paused (see network mode). +- `idle`: the query is not fetching. + +*** + +### isInvalidated + +```ts +isInvalidated: boolean; +``` + +Defined in: [packages/query-core/src/query.ts:98](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L98) + +Whether the query has been marked as invalidated via `invalidate()`. +- Reset to `false` whenever the query resolves successfully. + +*** + +### status + +```ts +status: QueryStatus; +``` + +Defined in: [packages/query-core/src/query.ts:105](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L105) + +The status of the query. +- `pending` if there's no cached data and no attempt was finished yet. +- `error` if the last attempt resulted in an error. +- `success` if the query has data. diff --git a/docs/framework/svelte/reference/interfaces/RefetchOptions.md b/docs/framework/svelte/reference/interfaces/RefetchOptions.md new file mode 100644 index 00000000000..cfcc0498799 --- /dev/null +++ b/docs/framework/svelte/reference/interfaces/RefetchOptions.md @@ -0,0 +1,50 @@ +--- +id: RefetchOptions +title: RefetchOptions +--- + +Defined in: [packages/query-core/src/types.ts:704](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L704) + +## Extends + +- [`ResultOptions`](ResultOptions.md) + +## Extended by + +- [`InvalidateOptions`](InvalidateOptions.md) +- [`ResetOptions`](ResetOptions.md) + +## Properties + +### cancelRefetch? + +```ts +optional cancelRefetch: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:712](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L712) + +If set to `true`, a currently running request will be cancelled before a new request is made + +If set to `false`, no refetch will be made if there is already a request running. + +Defaults to `true`. + +*** + +### throwOnError? + +```ts +optional throwOnError: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:701](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L701) + +If set to `true`, the method throws if any of the underlying query refetch tasks fail. + +Defaults to `false`, in which case failed refetches are swallowed and not surfaced to the +caller. + +#### Inherited from + +[`ResultOptions`](ResultOptions.md).[`throwOnError`](ResultOptions.md#throwonerror) diff --git a/docs/framework/svelte/reference/interfaces/RefetchQueryFilters.md b/docs/framework/svelte/reference/interfaces/RefetchQueryFilters.md new file mode 100644 index 00000000000..c45dfa953f1 --- /dev/null +++ b/docs/framework/svelte/reference/interfaces/RefetchQueryFilters.md @@ -0,0 +1,127 @@ +--- +id: RefetchQueryFilters +title: RefetchQueryFilters +--- + +Defined in: [packages/query-core/src/types.ts:730](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L730) + +Filters used to select queries, for example in `queryClient.getQueriesData` or `queryClient.invalidateQueries`. +All provided filters must match; filters that are left unspecified are ignored. + +## Extends + +- [`QueryFilters`](QueryFilters.md)\<`TQueryKey`\> + +## Type Parameters + +### TQueryKey + +`TQueryKey` *extends* [`QueryKey`](../type-aliases/QueryKey.md) = [`QueryKey`](../type-aliases/QueryKey.md) + +## Properties + +### exact? + +```ts +optional exact: boolean; +``` + +Defined in: [packages/query-core/src/utils.ts:41](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L41) + +Match query key exactly + +#### Inherited from + +[`QueryFilters`](QueryFilters.md).[`exact`](QueryFilters.md#exact) + +*** + +### fetchStatus? + +```ts +optional fetchStatus: FetchStatus; +``` + +Defined in: [packages/query-core/src/utils.ts:57](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L57) + +Include queries matching their fetchStatus + +#### Inherited from + +[`QueryFilters`](QueryFilters.md).[`fetchStatus`](QueryFilters.md#fetchstatus) + +*** + +### predicate()? + +```ts +optional predicate: (query) => boolean; +``` + +Defined in: [packages/query-core/src/utils.ts:45](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L45) + +Include queries matching this predicate function + +#### Parameters + +##### query + +[`Query`](../classes/Query.md) + +#### Returns + +`boolean` + +#### Inherited from + +[`QueryFilters`](QueryFilters.md).[`predicate`](QueryFilters.md#predicate) + +*** + +### queryKey? + +```ts +optional queryKey: TQueryKey | TuplePrefixes; +``` + +Defined in: [packages/query-core/src/utils.ts:49](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L49) + +Include queries matching this query key + +#### Inherited from + +[`QueryFilters`](QueryFilters.md).[`queryKey`](QueryFilters.md#querykey) + +*** + +### stale? + +```ts +optional stale: boolean; +``` + +Defined in: [packages/query-core/src/utils.ts:53](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L53) + +Include or exclude stale queries + +#### Inherited from + +[`QueryFilters`](QueryFilters.md).[`stale`](QueryFilters.md#stale) + +*** + +### type? + +```ts +optional type: QueryTypeFilter; +``` + +Defined in: [packages/query-core/src/utils.ts:37](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L37) + +Filter to active queries, inactive queries or all queries + +Defaults to `'all'`. + +#### Inherited from + +[`QueryFilters`](QueryFilters.md).[`type`](QueryFilters.md#type) diff --git a/docs/framework/svelte/reference/interfaces/Register.md b/docs/framework/svelte/reference/interfaces/Register.md new file mode 100644 index 00000000000..4f442442b48 --- /dev/null +++ b/docs/framework/svelte/reference/interfaces/Register.md @@ -0,0 +1,6 @@ +--- +id: Register +title: Register +--- + +Defined in: [packages/query-core/src/types.ts:37](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L37) diff --git a/docs/framework/svelte/reference/interfaces/ResetOptions.md b/docs/framework/svelte/reference/interfaces/ResetOptions.md new file mode 100644 index 00000000000..9f12324ba27 --- /dev/null +++ b/docs/framework/svelte/reference/interfaces/ResetOptions.md @@ -0,0 +1,49 @@ +--- +id: ResetOptions +title: ResetOptions +--- + +Defined in: [packages/query-core/src/types.ts:735](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L735) + +## Extends + +- [`RefetchOptions`](RefetchOptions.md) + +## Properties + +### cancelRefetch? + +```ts +optional cancelRefetch: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:712](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L712) + +If set to `true`, a currently running request will be cancelled before a new request is made + +If set to `false`, no refetch will be made if there is already a request running. + +Defaults to `true`. + +#### Inherited from + +[`RefetchOptions`](RefetchOptions.md).[`cancelRefetch`](RefetchOptions.md#cancelrefetch) + +*** + +### throwOnError? + +```ts +optional throwOnError: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:701](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L701) + +If set to `true`, the method throws if any of the underlying query refetch tasks fail. + +Defaults to `false`, in which case failed refetches are swallowed and not surfaced to the +caller. + +#### Inherited from + +[`RefetchOptions`](RefetchOptions.md).[`throwOnError`](RefetchOptions.md#throwonerror) diff --git a/docs/framework/svelte/reference/interfaces/ResultOptions.md b/docs/framework/svelte/reference/interfaces/ResultOptions.md new file mode 100644 index 00000000000..42917f20bf0 --- /dev/null +++ b/docs/framework/svelte/reference/interfaces/ResultOptions.md @@ -0,0 +1,27 @@ +--- +id: ResultOptions +title: ResultOptions +--- + +Defined in: [packages/query-core/src/types.ts:694](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L694) + +## Extended by + +- [`RefetchOptions`](RefetchOptions.md) +- [`FetchNextPageOptions`](FetchNextPageOptions.md) +- [`FetchPreviousPageOptions`](FetchPreviousPageOptions.md) + +## Properties + +### throwOnError? + +```ts +optional throwOnError: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:701](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L701) + +If set to `true`, the method throws if any of the underlying query refetch tasks fail. + +Defaults to `false`, in which case failed refetches are swallowed and not surfaced to the +caller. diff --git a/docs/framework/svelte/reference/interfaces/SetDataOptions.md b/docs/framework/svelte/reference/interfaces/SetDataOptions.md new file mode 100644 index 00000000000..bb668fbf162 --- /dev/null +++ b/docs/framework/svelte/reference/interfaces/SetDataOptions.md @@ -0,0 +1,16 @@ +--- +id: SetDataOptions +title: SetDataOptions +--- + +Defined in: [packages/query-core/src/types.ts:1526](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1526) + +## Properties + +### updatedAt? + +```ts +optional updatedAt: number; +``` + +Defined in: [packages/query-core/src/types.ts:1527](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1527) diff --git a/docs/framework/svelte/reference/interfaces/TimeoutManager.md b/docs/framework/svelte/reference/interfaces/TimeoutManager.md new file mode 100644 index 00000000000..95ff07b2ccc --- /dev/null +++ b/docs/framework/svelte/reference/interfaces/TimeoutManager.md @@ -0,0 +1,246 @@ +--- +id: TimeoutManager +title: TimeoutManager +--- + +Defined in: [packages/query-core/src/timeoutManager.ts:70](https://github.com/TanStack/query/blob/main/packages/query-core/src/timeoutManager.ts#L70) + +Allows customization of how timeouts are created. + +@tanstack/query-core makes liberal use of timeouts to implement `staleTime` +and `gcTime`. The default TimeoutManager provider uses the platform's global +`setTimeout` implementation, which is known to have scalability issues with +thousands of timeouts on the event loop. + +If you hit this limitation, consider providing a custom TimeoutProvider that +coalesces timeouts. + +## Implements + +- `Omit`\<[`TimeoutProvider`](../type-aliases/TimeoutProvider.md), `"name"`\> + +## Methods + +### clearInterval() + +```ts +clearInterval(intervalId): void; +``` + +Defined in: [packages/query-core/src/timeoutManager.ts:224](https://github.com/TanStack/query/blob/main/packages/query-core/src/timeoutManager.ts#L224) + +`clearInterval` can be used to cancel an interval, like the global +`clearInterval` function. It should be called with an interval ID +returned by `setInterval`. + +#### Parameters + +##### intervalId + +[`ManagedTimerId`](../type-aliases/ManagedTimerId.md) | `undefined` + +#### Returns + +`void` + +#### Example + +```ts +import { timeoutManager } from '@tanstack/query-core' + +const intervalId = timeoutManager.setInterval( + () => console.log('ran at:', new Date()), + 1000, +) + +timeoutManager.clearInterval(intervalId) +``` + +#### Implementation of + +[`TimeoutProvider`](../type-aliases/TimeoutProvider.md).[`clearInterval`](../type-aliases/TimeoutProvider.md#clearinterval) + +*** + +### clearTimeout() + +```ts +clearTimeout(timeoutId): void; +``` + +Defined in: [packages/query-core/src/timeoutManager.ts:179](https://github.com/TanStack/query/blob/main/packages/query-core/src/timeoutManager.ts#L179) + +`clearTimeout` cancels a timeout callback scheduled with `setTimeout`, +like the global `clearTimeout` function. It should be called with a +timer ID returned by `setTimeout`. + +#### Parameters + +##### timeoutId + +[`ManagedTimerId`](../type-aliases/ManagedTimerId.md) | `undefined` + +#### Returns + +`void` + +#### Example + +```ts +import { timeoutManager } from '@tanstack/query-core' + +const timeoutId = timeoutManager.setTimeout( + () => console.log('ran at:', new Date()), + 1000, +) + +timeoutManager.clearTimeout(timeoutId) +``` + +#### Implementation of + +[`TimeoutProvider`](../type-aliases/TimeoutProvider.md).[`clearTimeout`](../type-aliases/TimeoutProvider.md#cleartimeout) + +*** + +### setInterval() + +```ts +setInterval(callback, delay): ManagedTimerId; +``` + +Defined in: [packages/query-core/src/timeoutManager.ts:200](https://github.com/TanStack/query/blob/main/packages/query-core/src/timeoutManager.ts#L200) + +`setInterval` schedules a callback to be called approximately every +`delay` milliseconds, like the global `setInterval` function. + +Like `setTimeout`, it returns a timer ID, which may be a number or an +object that can be coerced to a number via `Symbol.toPrimitive`. + +#### Parameters + +##### callback + +[`TimeoutCallback`](../type-aliases/TimeoutCallback.md) + +##### delay + +`number` + +#### Returns + +[`ManagedTimerId`](../type-aliases/ManagedTimerId.md) + +#### Example + +```ts +import { timeoutManager } from '@tanstack/query-core' + +const intervalId = timeoutManager.setInterval( + () => console.log('ran at:', new Date()), + 1000, +) +``` + +#### Implementation of + +[`TimeoutProvider`](../type-aliases/TimeoutProvider.md).[`setInterval`](../type-aliases/TimeoutProvider.md#setinterval) + +*** + +### setTimeout() + +```ts +setTimeout(callback, delay): ManagedTimerId; +``` + +Defined in: [packages/query-core/src/timeoutManager.ts:155](https://github.com/TanStack/query/blob/main/packages/query-core/src/timeoutManager.ts#L155) + +`setTimeout` schedules a callback to run after approximately `delay` +milliseconds, like the global `setTimeout` function. The callback can be +canceled with `clearTimeout`. + +It returns a timer ID, which may be a number or an object that can be +coerced to a number via `Symbol.toPrimitive`. + +#### Parameters + +##### callback + +[`TimeoutCallback`](../type-aliases/TimeoutCallback.md) + +##### delay + +`number` + +#### Returns + +[`ManagedTimerId`](../type-aliases/ManagedTimerId.md) + +#### Example + +```ts +import { timeoutManager } from '@tanstack/query-core' + +const timeoutId = timeoutManager.setTimeout( + () => console.log('ran at:', new Date()), + 1000, +) + +const timeoutIdNumber: number = Number(timeoutId) +``` + +#### Implementation of + +[`TimeoutProvider`](../type-aliases/TimeoutProvider.md).[`setTimeout`](../type-aliases/TimeoutProvider.md#settimeout) + +*** + +### setTimeoutProvider() + +```ts +setTimeoutProvider(provider): void; +``` + +Defined in: [packages/query-core/src/timeoutManager.ts:106](https://github.com/TanStack/query/blob/main/packages/query-core/src/timeoutManager.ts#L106) + +`setTimeoutProvider` can be used to set a custom implementation of the +`setTimeout`, `clearTimeout`, `setInterval`, `clearInterval` functions, +called a `TimeoutProvider`. + +This may be useful if you notice event loop performance issues with +thousands of queries. A custom TimeoutProvider could also support timer +delays longer than the global `setTimeout` maximum delay value of about +24 days. + +It is important to call `setTimeoutProvider` before creating a +QueryClient or queries, so that the same provider is used consistently +for all timers in the application, since different TimeoutProviders +cannot cancel each others' timers. + +#### Type Parameters + +##### TTimerId + +`TTimerId` *extends* [`ManagedTimerId`](../type-aliases/ManagedTimerId.md) + +#### Parameters + +##### provider + +[`TimeoutProvider`](../type-aliases/TimeoutProvider.md)\<`TTimerId`\> + +#### Returns + +`void` + +#### Example + +```ts +import { timeoutManager, QueryClient } from '@tanstack/query-core' +import { CustomTimeoutProvider } from './CustomTimeoutProvider' + +timeoutManager.setTimeoutProvider(new CustomTimeoutProvider()) + +export const queryClient = new QueryClient() +``` diff --git a/docs/framework/svelte/reference/type-aliases/AnyDataTag.md b/docs/framework/svelte/reference/type-aliases/AnyDataTag.md new file mode 100644 index 00000000000..d3d5e33bb3e --- /dev/null +++ b/docs/framework/svelte/reference/type-aliases/AnyDataTag.md @@ -0,0 +1,30 @@ +--- +id: AnyDataTag +title: AnyDataTag +--- + +```ts +type AnyDataTag = object; +``` + +Defined in: [packages/query-core/src/types.ts:67](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L67) + +## Properties + +### \[dataTagErrorSymbol\] + +```ts +[dataTagErrorSymbol]: any; +``` + +Defined in: [packages/query-core/src/types.ts:69](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L69) + +*** + +### \[dataTagSymbol\] + +```ts +[dataTagSymbol]: any; +``` + +Defined in: [packages/query-core/src/types.ts:68](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L68) diff --git a/docs/framework/svelte/reference/type-aliases/CreateBaseMutationResult.md b/docs/framework/svelte/reference/type-aliases/CreateBaseMutationResult.md index 458782e77ba..22f42183cda 100644 --- a/docs/framework/svelte/reference/type-aliases/CreateBaseMutationResult.md +++ b/docs/framework/svelte/reference/type-aliases/CreateBaseMutationResult.md @@ -27,7 +27,7 @@ mutateAsync: CreateMutateAsyncFunction\> +...`Parameters`\<[`MutateFunction`](MutateFunction.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\>\> ## Returns diff --git a/docs/framework/svelte/reference/type-aliases/CreateMutationOptions.md b/docs/framework/svelte/reference/type-aliases/CreateMutationOptions.md index 4b70afeba75..690e447757a 100644 --- a/docs/framework/svelte/reference/type-aliases/CreateMutationOptions.md +++ b/docs/framework/svelte/reference/type-aliases/CreateMutationOptions.md @@ -19,7 +19,7 @@ Options for createMutation ### TError -`TError` = `DefaultError` +`TError` = [`DefaultError`](DefaultError.md) ### TVariables diff --git a/docs/framework/svelte/reference/type-aliases/CreateMutationResult.md b/docs/framework/svelte/reference/type-aliases/CreateMutationResult.md index 79bb862bec4..e91def2c93e 100644 --- a/docs/framework/svelte/reference/type-aliases/CreateMutationResult.md +++ b/docs/framework/svelte/reference/type-aliases/CreateMutationResult.md @@ -19,7 +19,7 @@ Result from createMutation ### TError -`TError` = `DefaultError` +`TError` = [`DefaultError`](DefaultError.md) ### TVariables diff --git a/docs/framework/svelte/reference/type-aliases/CreateQueryOptions.md b/docs/framework/svelte/reference/type-aliases/CreateQueryOptions.md index b11b5aa11db..f25a4fb4db0 100644 --- a/docs/framework/svelte/reference/type-aliases/CreateQueryOptions.md +++ b/docs/framework/svelte/reference/type-aliases/CreateQueryOptions.md @@ -19,7 +19,7 @@ Options for createQuery ### TError -`TError` = `DefaultError` +`TError` = [`DefaultError`](DefaultError.md) ### TData @@ -27,4 +27,4 @@ Options for createQuery ### TQueryKey -`TQueryKey` *extends* `QueryKey` = `QueryKey` +`TQueryKey` *extends* [`QueryKey`](QueryKey.md) = [`QueryKey`](QueryKey.md) diff --git a/docs/framework/svelte/reference/type-aliases/CreateQueryResult.md b/docs/framework/svelte/reference/type-aliases/CreateQueryResult.md index d7187e3cdd1..74cecd3f9c6 100644 --- a/docs/framework/svelte/reference/type-aliases/CreateQueryResult.md +++ b/docs/framework/svelte/reference/type-aliases/CreateQueryResult.md @@ -19,4 +19,4 @@ Result from createQuery ### TError -`TError` = `DefaultError` +`TError` = [`DefaultError`](DefaultError.md) diff --git a/docs/framework/svelte/reference/type-aliases/DataTag.md b/docs/framework/svelte/reference/type-aliases/DataTag.md new file mode 100644 index 00000000000..904ca124464 --- /dev/null +++ b/docs/framework/svelte/reference/type-aliases/DataTag.md @@ -0,0 +1,24 @@ +--- +id: DataTag +title: DataTag +--- + +```ts +type DataTag = TType extends AnyDataTag ? TType : TType & object; +``` + +Defined in: [packages/query-core/src/types.ts:71](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L71) + +## Type Parameters + +### TType + +`TType` + +### TValue + +`TValue` + +### TError + +`TError` = [`UnsetMarker`](UnsetMarker.md) diff --git a/docs/framework/svelte/reference/type-aliases/DefaultError.md b/docs/framework/svelte/reference/type-aliases/DefaultError.md new file mode 100644 index 00000000000..da9f615482f --- /dev/null +++ b/docs/framework/svelte/reference/type-aliases/DefaultError.md @@ -0,0 +1,10 @@ +--- +id: DefaultError +title: DefaultError +--- + +```ts +type DefaultError = Register extends object ? TError : Error; +``` + +Defined in: [packages/query-core/src/types.ts:45](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L45) diff --git a/docs/framework/svelte/reference/type-aliases/DefaultedInfiniteQueryObserverOptions.md b/docs/framework/svelte/reference/type-aliases/DefaultedInfiniteQueryObserverOptions.md new file mode 100644 index 00000000000..82c7ddbb886 --- /dev/null +++ b/docs/framework/svelte/reference/type-aliases/DefaultedInfiniteQueryObserverOptions.md @@ -0,0 +1,32 @@ +--- +id: DefaultedInfiniteQueryObserverOptions +title: DefaultedInfiniteQueryObserverOptions +--- + +```ts +type DefaultedInfiniteQueryObserverOptions = WithRequired, "throwOnError" | "refetchOnReconnect" | "queryHash">; +``` + +Defined in: [packages/query-core/src/types.ts:557](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L557) + +## Type Parameters + +### TQueryFnData + +`TQueryFnData` = `unknown` + +### TError + +`TError` = [`DefaultError`](DefaultError.md) + +### TData + +`TData` = `TQueryFnData` + +### TQueryKey + +`TQueryKey` *extends* [`QueryKey`](QueryKey.md) = [`QueryKey`](QueryKey.md) + +### TPageParam + +`TPageParam` = `unknown` diff --git a/docs/framework/svelte/reference/type-aliases/DefaultedQueryObserverOptions.md b/docs/framework/svelte/reference/type-aliases/DefaultedQueryObserverOptions.md new file mode 100644 index 00000000000..7687d8c24f6 --- /dev/null +++ b/docs/framework/svelte/reference/type-aliases/DefaultedQueryObserverOptions.md @@ -0,0 +1,32 @@ +--- +id: DefaultedQueryObserverOptions +title: DefaultedQueryObserverOptions +--- + +```ts +type DefaultedQueryObserverOptions = WithRequired, "throwOnError" | "refetchOnReconnect" | "queryHash">; +``` + +Defined in: [packages/query-core/src/types.ts:528](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L528) + +## Type Parameters + +### TQueryFnData + +`TQueryFnData` = `unknown` + +### TError + +`TError` = [`DefaultError`](DefaultError.md) + +### TData + +`TData` = `TQueryFnData` + +### TQueryData + +`TQueryData` = `TQueryFnData` + +### TQueryKey + +`TQueryKey` *extends* [`QueryKey`](QueryKey.md) = [`QueryKey`](QueryKey.md) diff --git a/docs/framework/svelte/reference/type-aliases/DefinedCreateBaseQueryResult.md b/docs/framework/svelte/reference/type-aliases/DefinedCreateBaseQueryResult.md index b0cac595928..e73b278ec7a 100644 --- a/docs/framework/svelte/reference/type-aliases/DefinedCreateBaseQueryResult.md +++ b/docs/framework/svelte/reference/type-aliases/DefinedCreateBaseQueryResult.md @@ -19,4 +19,4 @@ Options for createBaseQuery with initialData ### TError -`TError` = `DefaultError` +`TError` = [`DefaultError`](DefaultError.md) diff --git a/docs/framework/svelte/reference/type-aliases/DefinedCreateInfiniteQueryResult.md b/docs/framework/svelte/reference/type-aliases/DefinedCreateInfiniteQueryResult.md index add7ce8a0ec..0e07398bf67 100644 --- a/docs/framework/svelte/reference/type-aliases/DefinedCreateInfiniteQueryResult.md +++ b/docs/framework/svelte/reference/type-aliases/DefinedCreateInfiniteQueryResult.md @@ -19,4 +19,4 @@ Result from createInfiniteQuery with initialData ### TError -`TError` = `DefaultError` +`TError` = [`DefaultError`](DefaultError.md) diff --git a/docs/framework/svelte/reference/type-aliases/DefinedCreateQueryResult.md b/docs/framework/svelte/reference/type-aliases/DefinedCreateQueryResult.md index 238a9d9188b..b064912ecec 100644 --- a/docs/framework/svelte/reference/type-aliases/DefinedCreateQueryResult.md +++ b/docs/framework/svelte/reference/type-aliases/DefinedCreateQueryResult.md @@ -19,4 +19,4 @@ Options for createQuery with initialData ### TError -`TError` = `DefaultError` +`TError` = [`DefaultError`](DefaultError.md) diff --git a/docs/framework/svelte/reference/type-aliases/DefinedInfiniteQueryObserverResult.md b/docs/framework/svelte/reference/type-aliases/DefinedInfiniteQueryObserverResult.md new file mode 100644 index 00000000000..38dac7cfe2b --- /dev/null +++ b/docs/framework/svelte/reference/type-aliases/DefinedInfiniteQueryObserverResult.md @@ -0,0 +1,22 @@ +--- +id: DefinedInfiniteQueryObserverResult +title: DefinedInfiniteQueryObserverResult +--- + +```ts +type DefinedInfiniteQueryObserverResult = + | InfiniteQueryObserverRefetchErrorResult +| InfiniteQueryObserverSuccessResult; +``` + +Defined in: [packages/query-core/src/types.ts:1148](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1148) + +## Type Parameters + +### TData + +`TData` = `unknown` + +### TError + +`TError` = [`DefaultError`](DefaultError.md) diff --git a/docs/framework/svelte/reference/type-aliases/DefinedInitialDataInfiniteOptions.md b/docs/framework/svelte/reference/type-aliases/DefinedInitialDataInfiniteOptions.md index e9e635dc277..4d6b305fb5e 100644 --- a/docs/framework/svelte/reference/type-aliases/DefinedInitialDataInfiniteOptions.md +++ b/docs/framework/svelte/reference/type-aliases/DefinedInitialDataInfiniteOptions.md @@ -27,15 +27,15 @@ initialData: ### TError -`TError` = `DefaultError` +`TError` = [`DefaultError`](DefaultError.md) ### TData -`TData` = `InfiniteData`\<`TQueryFnData`\> +`TData` = [`InfiniteData`](../interfaces/InfiniteData.md)\<`TQueryFnData`\> ### TQueryKey -`TQueryKey` *extends* `QueryKey` = `QueryKey` +`TQueryKey` *extends* [`QueryKey`](QueryKey.md) = [`QueryKey`](QueryKey.md) ### TPageParam diff --git a/docs/framework/svelte/reference/type-aliases/DefinedInitialDataOptions.md b/docs/framework/svelte/reference/type-aliases/DefinedInitialDataOptions.md index 0f223ff1182..e45af352af7 100644 --- a/docs/framework/svelte/reference/type-aliases/DefinedInitialDataOptions.md +++ b/docs/framework/svelte/reference/type-aliases/DefinedInitialDataOptions.md @@ -27,7 +27,7 @@ initialData: ### TError -`TError` = `DefaultError` +`TError` = [`DefaultError`](DefaultError.md) ### TData @@ -35,4 +35,4 @@ initialData: ### TQueryKey -`TQueryKey` *extends* `QueryKey` = `QueryKey` +`TQueryKey` *extends* [`QueryKey`](QueryKey.md) = [`QueryKey`](QueryKey.md) diff --git a/docs/framework/svelte/reference/type-aliases/DefinedQueryObserverResult.md b/docs/framework/svelte/reference/type-aliases/DefinedQueryObserverResult.md new file mode 100644 index 00000000000..ae77ddcc22d --- /dev/null +++ b/docs/framework/svelte/reference/type-aliases/DefinedQueryObserverResult.md @@ -0,0 +1,22 @@ +--- +id: DefinedQueryObserverResult +title: DefinedQueryObserverResult +--- + +```ts +type DefinedQueryObserverResult = + | QueryObserverRefetchErrorResult +| QueryObserverSuccessResult; +``` + +Defined in: [packages/query-core/src/types.ts:987](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L987) + +## Type Parameters + +### TData + +`TData` = `unknown` + +### TError + +`TError` = [`DefaultError`](DefaultError.md) diff --git a/docs/framework/svelte/reference/type-aliases/DistributiveOmit.md b/docs/framework/svelte/reference/type-aliases/DistributiveOmit.md new file mode 100644 index 00000000000..33b87a5cd6e --- /dev/null +++ b/docs/framework/svelte/reference/type-aliases/DistributiveOmit.md @@ -0,0 +1,20 @@ +--- +id: DistributiveOmit +title: DistributiveOmit +--- + +```ts +type DistributiveOmit = TObject extends any ? Omit : never; +``` + +Defined in: [packages/query-core/src/types.ts:14](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L14) + +## Type Parameters + +### TObject + +`TObject` + +### TKey + +`TKey` *extends* keyof `TObject` diff --git a/docs/framework/svelte/reference/type-aliases/EnsureInfiniteQueryDataOptions.md b/docs/framework/svelte/reference/type-aliases/EnsureInfiniteQueryDataOptions.md new file mode 100644 index 00000000000..7648331fca2 --- /dev/null +++ b/docs/framework/svelte/reference/type-aliases/EnsureInfiniteQueryDataOptions.md @@ -0,0 +1,42 @@ +--- +id: EnsureInfiniteQueryDataOptions +title: EnsureInfiniteQueryDataOptions +--- + +```ts +type EnsureInfiniteQueryDataOptions = FetchInfiniteQueryOptions & object; +``` + +Defined in: [packages/query-core/src/types.ts:631](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L631) + +## Type Declaration + +### ~~revalidateIfStale?~~ + +```ts +optional revalidateIfStale: boolean; +``` + +## Type Parameters + +### TQueryFnData + +`TQueryFnData` = `unknown` + +### TError + +`TError` = [`DefaultError`](DefaultError.md) + +### TData + +`TData` = `TQueryFnData` + +### TQueryKey + +`TQueryKey` *extends* [`QueryKey`](QueryKey.md) = [`QueryKey`](QueryKey.md) + +### TPageParam + +`TPageParam` = `unknown` + +## Deprecated diff --git a/docs/framework/svelte/reference/type-aliases/FetchInfiniteQueryOptions.md b/docs/framework/svelte/reference/type-aliases/FetchInfiniteQueryOptions.md new file mode 100644 index 00000000000..d00a2455889 --- /dev/null +++ b/docs/framework/svelte/reference/type-aliases/FetchInfiniteQueryOptions.md @@ -0,0 +1,34 @@ +--- +id: FetchInfiniteQueryOptions +title: FetchInfiniteQueryOptions +--- + +```ts +type FetchInfiniteQueryOptions = Omit, TQueryKey, TPageParam>, "initialPageParam"> & InitialPageParam & InfiniteQueryPages; +``` + +Defined in: [packages/query-core/src/types.ts:675](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L675) + +## Type Parameters + +### TQueryFnData + +`TQueryFnData` = `unknown` + +### TError + +`TError` = [`DefaultError`](DefaultError.md) + +### TData + +`TData` = `TQueryFnData` + +### TQueryKey + +`TQueryKey` *extends* [`QueryKey`](QueryKey.md) = [`QueryKey`](QueryKey.md) + +### TPageParam + +`TPageParam` = `unknown` + +## Deprecated diff --git a/docs/framework/svelte/reference/type-aliases/FetchStatus.md b/docs/framework/svelte/reference/type-aliases/FetchStatus.md new file mode 100644 index 00000000000..d50002355ca --- /dev/null +++ b/docs/framework/svelte/reference/type-aliases/FetchStatus.md @@ -0,0 +1,10 @@ +--- +id: FetchStatus +title: FetchStatus +--- + +```ts +type FetchStatus = "fetching" | "paused" | "idle"; +``` + +Defined in: [packages/query-core/src/types.ts:762](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L762) diff --git a/docs/framework/svelte/reference/type-aliases/GetNextPageParamFunction.md b/docs/framework/svelte/reference/type-aliases/GetNextPageParamFunction.md new file mode 100644 index 00000000000..81d1a1544ab --- /dev/null +++ b/docs/framework/svelte/reference/type-aliases/GetNextPageParamFunction.md @@ -0,0 +1,42 @@ +--- +id: GetNextPageParamFunction +title: GetNextPageParamFunction +--- + +```ts +type GetNextPageParamFunction = (lastPage, allPages, lastPageParam, allPageParams) => TPageParam | undefined | null; +``` + +Defined in: [packages/query-core/src/types.ts:203](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L203) + +## Type Parameters + +### TPageParam + +`TPageParam` + +### TQueryFnData + +`TQueryFnData` = `unknown` + +## Parameters + +### lastPage + +`TQueryFnData` + +### allPages + +`TQueryFnData`[] + +### lastPageParam + +`TPageParam` + +### allPageParams + +`TPageParam`[] + +## Returns + +`TPageParam` \| `undefined` \| `null` diff --git a/docs/framework/svelte/reference/type-aliases/GetPreviousPageParamFunction.md b/docs/framework/svelte/reference/type-aliases/GetPreviousPageParamFunction.md new file mode 100644 index 00000000000..5a6d9b93d7e --- /dev/null +++ b/docs/framework/svelte/reference/type-aliases/GetPreviousPageParamFunction.md @@ -0,0 +1,42 @@ +--- +id: GetPreviousPageParamFunction +title: GetPreviousPageParamFunction +--- + +```ts +type GetPreviousPageParamFunction = (firstPage, allPages, firstPageParam, allPageParams) => TPageParam | undefined | null; +``` + +Defined in: [packages/query-core/src/types.ts:196](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L196) + +## Type Parameters + +### TPageParam + +`TPageParam` + +### TQueryFnData + +`TQueryFnData` = `unknown` + +## Parameters + +### firstPage + +`TQueryFnData` + +### allPages + +`TQueryFnData`[] + +### firstPageParam + +`TPageParam` + +### allPageParams + +`TPageParam`[] + +## Returns + +`TPageParam` \| `undefined` \| `null` diff --git a/docs/framework/svelte/reference/type-aliases/InferDataFromTag.md b/docs/framework/svelte/reference/type-aliases/InferDataFromTag.md new file mode 100644 index 00000000000..09a15ca4b1c --- /dev/null +++ b/docs/framework/svelte/reference/type-aliases/InferDataFromTag.md @@ -0,0 +1,20 @@ +--- +id: InferDataFromTag +title: InferDataFromTag +--- + +```ts +type InferDataFromTag = TTaggedQueryKey extends DataTag ? TaggedValue : TQueryFnData; +``` + +Defined in: [packages/query-core/src/types.ts:90](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L90) + +## Type Parameters + +### TQueryFnData + +`TQueryFnData` + +### TTaggedQueryKey + +`TTaggedQueryKey` *extends* [`QueryKey`](QueryKey.md) diff --git a/docs/framework/svelte/reference/type-aliases/InferErrorFromTag.md b/docs/framework/svelte/reference/type-aliases/InferErrorFromTag.md new file mode 100644 index 00000000000..cd94e4b5c3f --- /dev/null +++ b/docs/framework/svelte/reference/type-aliases/InferErrorFromTag.md @@ -0,0 +1,20 @@ +--- +id: InferErrorFromTag +title: InferErrorFromTag +--- + +```ts +type InferErrorFromTag = TTaggedQueryKey extends DataTag ? TaggedError extends UnsetMarker ? TError : TaggedError : TError; +``` + +Defined in: [packages/query-core/src/types.ts:95](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L95) + +## Type Parameters + +### TError + +`TError` + +### TTaggedQueryKey + +`TTaggedQueryKey` *extends* [`QueryKey`](QueryKey.md) diff --git a/docs/framework/svelte/reference/type-aliases/InfiniteQueryExecuteOptions.md b/docs/framework/svelte/reference/type-aliases/InfiniteQueryExecuteOptions.md new file mode 100644 index 00000000000..259c97c96bb --- /dev/null +++ b/docs/framework/svelte/reference/type-aliases/InfiniteQueryExecuteOptions.md @@ -0,0 +1,32 @@ +--- +id: InfiniteQueryExecuteOptions +title: InfiniteQueryExecuteOptions +--- + +```ts +type InfiniteQueryExecuteOptions = Omit, TQueryKey, TPageParam>, "initialPageParam"> & InitialPageParam & InfiniteQueryPages; +``` + +Defined in: [packages/query-core/src/types.ts:654](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L654) + +## Type Parameters + +### TQueryFnData + +`TQueryFnData` = `unknown` + +### TError + +`TError` = [`DefaultError`](DefaultError.md) + +### TData + +`TData` = [`InfiniteData`](../interfaces/InfiniteData.md)\<`TQueryFnData`\> + +### TQueryKey + +`TQueryKey` *extends* [`QueryKey`](QueryKey.md) = [`QueryKey`](QueryKey.md) + +### TPageParam + +`TPageParam` = `unknown` diff --git a/docs/framework/svelte/reference/type-aliases/InfiniteQueryObserverResult.md b/docs/framework/svelte/reference/type-aliases/InfiniteQueryObserverResult.md new file mode 100644 index 00000000000..aa27563b9cd --- /dev/null +++ b/docs/framework/svelte/reference/type-aliases/InfiniteQueryObserverResult.md @@ -0,0 +1,25 @@ +--- +id: InfiniteQueryObserverResult +title: InfiniteQueryObserverResult +--- + +```ts +type InfiniteQueryObserverResult = + | DefinedInfiniteQueryObserverResult + | InfiniteQueryObserverLoadingErrorResult + | InfiniteQueryObserverLoadingResult + | InfiniteQueryObserverPendingResult +| InfiniteQueryObserverPlaceholderResult; +``` + +Defined in: [packages/query-core/src/types.ts:1155](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1155) + +## Type Parameters + +### TData + +`TData` = `unknown` + +### TError + +`TError` = [`DefaultError`](DefaultError.md) diff --git a/docs/framework/svelte/reference/type-aliases/InitialDataFunction.md b/docs/framework/svelte/reference/type-aliases/InitialDataFunction.md new file mode 100644 index 00000000000..6ba4aaabe61 --- /dev/null +++ b/docs/framework/svelte/reference/type-aliases/InitialDataFunction.md @@ -0,0 +1,20 @@ +--- +id: InitialDataFunction +title: InitialDataFunction +--- + +```ts +type InitialDataFunction = () => T | undefined; +``` + +Defined in: [packages/query-core/src/types.ts:173](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L173) + +## Type Parameters + +### T + +`T` + +## Returns + +`T` \| `undefined` diff --git a/docs/framework/svelte/reference/type-aliases/ManagedTimerId.md b/docs/framework/svelte/reference/type-aliases/ManagedTimerId.md new file mode 100644 index 00000000000..d7833e3e4f0 --- /dev/null +++ b/docs/framework/svelte/reference/type-aliases/ManagedTimerId.md @@ -0,0 +1,19 @@ +--- +id: ManagedTimerId +title: ManagedTimerId +--- + +```ts +type ManagedTimerId = + | number + | { + [toPrimitive]: () => number; +}; +``` + +Defined in: [packages/query-core/src/timeoutManager.ts:17](https://github.com/TanStack/query/blob/main/packages/query-core/src/timeoutManager.ts#L17) + +Wrapping `setTimeout` is awkward from a typing perspective because platform +typings may extend the return type of `setTimeout`. For example, NodeJS +typings add `NodeJS.Timeout`; but a non-default `timeoutManager` may not be +able to return such a type. diff --git a/docs/framework/svelte/reference/type-aliases/MutateFunction.md b/docs/framework/svelte/reference/type-aliases/MutateFunction.md new file mode 100644 index 00000000000..e12b7a80291 --- /dev/null +++ b/docs/framework/svelte/reference/type-aliases/MutateFunction.md @@ -0,0 +1,38 @@ +--- +id: MutateFunction +title: MutateFunction +--- + +```ts +type MutateFunction = (...rest) => Promise; +``` + +Defined in: [packages/query-core/src/types.ts:1326](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1326) + +## Type Parameters + +### TData + +`TData` = `unknown` + +### TError + +`TError` = [`DefaultError`](DefaultError.md) + +### TVariables + +`TVariables` = `void` + +### TOnMutateResult + +`TOnMutateResult` = `unknown` + +## Parameters + +### rest + +...[`MutateFunctionRest`](MutateFunctionRest.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\> + +## Returns + +`Promise`\<`TData`\> diff --git a/docs/framework/svelte/reference/type-aliases/MutateFunctionRest.md b/docs/framework/svelte/reference/type-aliases/MutateFunctionRest.md new file mode 100644 index 00000000000..3902f1082f9 --- /dev/null +++ b/docs/framework/svelte/reference/type-aliases/MutateFunctionRest.md @@ -0,0 +1,28 @@ +--- +id: MutateFunctionRest +title: MutateFunctionRest +--- + +```ts +type MutateFunctionRest = undefined extends TVariables ? [TVariables, MutateOptions] : [TVariables, MutateOptions]; +``` + +Defined in: [packages/query-core/src/types.ts:1311](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1311) + +## Type Parameters + +### TData + +`TData` = `unknown` + +### TError + +`TError` = [`DefaultError`](DefaultError.md) + +### TVariables + +`TVariables` = `void` + +### TOnMutateResult + +`TOnMutateResult` = `unknown` diff --git a/docs/framework/svelte/reference/type-aliases/MutationCacheNotifyEvent.md b/docs/framework/svelte/reference/type-aliases/MutationCacheNotifyEvent.md new file mode 100644 index 00000000000..aa5e196bc72 --- /dev/null +++ b/docs/framework/svelte/reference/type-aliases/MutationCacheNotifyEvent.md @@ -0,0 +1,20 @@ +--- +id: MutationCacheNotifyEvent +title: MutationCacheNotifyEvent +--- + +```ts +type MutationCacheNotifyEvent = + | NotifyEventMutationAdded + | NotifyEventMutationRemoved + | NotifyEventMutationObserverAdded + | NotifyEventMutationObserverRemoved + | NotifyEventMutationObserverOptionsUpdated + | NotifyEventMutationUpdated; +``` + +Defined in: [packages/query-core/src/mutationCache.ts:98](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationCache.ts#L98) + +The event passed to a `MutationCache` subscriber. Fired whenever a mutation is added or removed +from the cache, its state is updated, or one of its observers is added, removed, or has its +options updated. diff --git a/docs/framework/svelte/reference/type-aliases/MutationFunction.md b/docs/framework/svelte/reference/type-aliases/MutationFunction.md new file mode 100644 index 00000000000..9bafb3db56b --- /dev/null +++ b/docs/framework/svelte/reference/type-aliases/MutationFunction.md @@ -0,0 +1,34 @@ +--- +id: MutationFunction +title: MutationFunction +--- + +```ts +type MutationFunction = (variables, context) => Promise; +``` + +Defined in: [packages/query-core/src/types.ts:1195](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1195) + +## Type Parameters + +### TData + +`TData` = `unknown` + +### TVariables + +`TVariables` = `unknown` + +## Parameters + +### variables + +`TVariables` + +### context + +[`MutationFunctionContext`](MutationFunctionContext.md) + +## Returns + +`Promise`\<`TData`\> diff --git a/docs/framework/svelte/reference/type-aliases/MutationFunctionContext.md b/docs/framework/svelte/reference/type-aliases/MutationFunctionContext.md new file mode 100644 index 00000000000..0207256c702 --- /dev/null +++ b/docs/framework/svelte/reference/type-aliases/MutationFunctionContext.md @@ -0,0 +1,40 @@ +--- +id: MutationFunctionContext +title: MutationFunctionContext +--- + +```ts +type MutationFunctionContext = object; +``` + +Defined in: [packages/query-core/src/types.ts:1189](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1189) + +## Properties + +### client + +```ts +client: QueryClient; +``` + +Defined in: [packages/query-core/src/types.ts:1190](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1190) + +*** + +### meta + +```ts +meta: MutationMeta | undefined; +``` + +Defined in: [packages/query-core/src/types.ts:1191](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1191) + +*** + +### mutationKey? + +```ts +optional mutationKey: MutationKey; +``` + +Defined in: [packages/query-core/src/types.ts:1192](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1192) diff --git a/docs/framework/svelte/reference/type-aliases/MutationKey.md b/docs/framework/svelte/reference/type-aliases/MutationKey.md new file mode 100644 index 00000000000..9d1d7f0f77b --- /dev/null +++ b/docs/framework/svelte/reference/type-aliases/MutationKey.md @@ -0,0 +1,10 @@ +--- +id: MutationKey +title: MutationKey +--- + +```ts +type MutationKey = Register extends object ? TMutationKey extends ReadonlyArray ? TMutationKey : TMutationKey extends unknown[] ? TMutationKey : ReadonlyArray : ReadonlyArray; +``` + +Defined in: [packages/query-core/src/types.ts:1165](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1165) diff --git a/docs/framework/svelte/reference/type-aliases/MutationMeta.md b/docs/framework/svelte/reference/type-aliases/MutationMeta.md new file mode 100644 index 00000000000..ff1f9b4bf94 --- /dev/null +++ b/docs/framework/svelte/reference/type-aliases/MutationMeta.md @@ -0,0 +1,10 @@ +--- +id: MutationMeta +title: MutationMeta +--- + +```ts +type MutationMeta = Register extends object ? TMutationMeta extends Record ? TMutationMeta : Record : Record; +``` + +Defined in: [packages/query-core/src/types.ts:1181](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1181) diff --git a/docs/framework/svelte/reference/type-aliases/MutationObserverResult.md b/docs/framework/svelte/reference/type-aliases/MutationObserverResult.md new file mode 100644 index 00000000000..c21fc3ac591 --- /dev/null +++ b/docs/framework/svelte/reference/type-aliases/MutationObserverResult.md @@ -0,0 +1,32 @@ +--- +id: MutationObserverResult +title: MutationObserverResult +--- + +```ts +type MutationObserverResult = + | MutationObserverIdleResult + | MutationObserverLoadingResult + | MutationObserverErrorResult +| MutationObserverSuccessResult; +``` + +Defined in: [packages/query-core/src/types.ts:1484](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1484) + +## Type Parameters + +### TData + +`TData` = `unknown` + +### TError + +`TError` = [`DefaultError`](DefaultError.md) + +### TVariables + +`TVariables` = `void` + +### TOnMutateResult + +`TOnMutateResult` = `unknown` diff --git a/docs/framework/svelte/reference/type-aliases/MutationScope.md b/docs/framework/svelte/reference/type-aliases/MutationScope.md new file mode 100644 index 00000000000..1d6a91bd434 --- /dev/null +++ b/docs/framework/svelte/reference/type-aliases/MutationScope.md @@ -0,0 +1,20 @@ +--- +id: MutationScope +title: MutationScope +--- + +```ts +type MutationScope = object; +``` + +Defined in: [packages/query-core/src/types.ts:1177](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1177) + +## Properties + +### id + +```ts +id: string; +``` + +Defined in: [packages/query-core/src/types.ts:1178](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1178) diff --git a/docs/framework/svelte/reference/type-aliases/MutationStateOptions.md b/docs/framework/svelte/reference/type-aliases/MutationStateOptions.md index 0b5a5f875e7..faa4070e9fc 100644 --- a/docs/framework/svelte/reference/type-aliases/MutationStateOptions.md +++ b/docs/framework/svelte/reference/type-aliases/MutationStateOptions.md @@ -15,11 +15,11 @@ Options for useMutationState ### TResult -`TResult` = `MutationState` +`TResult` = [`MutationState`](../interfaces/MutationState.md) ### TMutation -`TMutation` *extends* `Mutation`\<`any`, `any`, `any`, `any`\> = [`MutationTypeFromResult`](MutationTypeFromResult.md)\<`TResult`\> +`TMutation` *extends* [`Mutation`](../classes/Mutation.md)\<`any`, `any`, `any`, `any`\> = [`MutationTypeFromResult`](MutationTypeFromResult.md)\<`TResult`\> ## Properties diff --git a/docs/framework/svelte/reference/type-aliases/MutationStatus.md b/docs/framework/svelte/reference/type-aliases/MutationStatus.md new file mode 100644 index 00000000000..cf12d3d3ee3 --- /dev/null +++ b/docs/framework/svelte/reference/type-aliases/MutationStatus.md @@ -0,0 +1,10 @@ +--- +id: MutationStatus +title: MutationStatus +--- + +```ts +type MutationStatus = "idle" | "pending" | "success" | "error"; +``` + +Defined in: [packages/query-core/src/types.ts:1175](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1175) diff --git a/docs/framework/svelte/reference/type-aliases/NetworkMode.md b/docs/framework/svelte/reference/type-aliases/NetworkMode.md new file mode 100644 index 00000000000..94ae0ba76ed --- /dev/null +++ b/docs/framework/svelte/reference/type-aliases/NetworkMode.md @@ -0,0 +1,10 @@ +--- +id: NetworkMode +title: NetworkMode +--- + +```ts +type NetworkMode = "online" | "always" | "offlineFirst"; +``` + +Defined in: [packages/query-core/src/types.ts:223](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L223) diff --git a/docs/framework/svelte/reference/type-aliases/NonUndefinedGuard.md b/docs/framework/svelte/reference/type-aliases/NonUndefinedGuard.md new file mode 100644 index 00000000000..4aaf208013b --- /dev/null +++ b/docs/framework/svelte/reference/type-aliases/NonUndefinedGuard.md @@ -0,0 +1,16 @@ +--- +id: NonUndefinedGuard +title: NonUndefinedGuard +--- + +```ts +type NonUndefinedGuard = T extends undefined ? never : T; +``` + +Defined in: [packages/query-core/src/types.ts:12](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L12) + +## Type Parameters + +### T + +`T` diff --git a/docs/framework/svelte/reference/type-aliases/NotifyEventType.md b/docs/framework/svelte/reference/type-aliases/NotifyEventType.md new file mode 100644 index 00000000000..ffa60b016e3 --- /dev/null +++ b/docs/framework/svelte/reference/type-aliases/NotifyEventType.md @@ -0,0 +1,17 @@ +--- +id: NotifyEventType +title: NotifyEventType +--- + +```ts +type NotifyEventType = + | "added" + | "removed" + | "updated" + | "observerAdded" + | "observerRemoved" + | "observerResultsUpdated" + | "observerOptionsUpdated"; +``` + +Defined in: [packages/query-core/src/types.ts:1530](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1530) diff --git a/docs/framework/svelte/reference/type-aliases/NotifyOnChangeProps.md b/docs/framework/svelte/reference/type-aliases/NotifyOnChangeProps.md new file mode 100644 index 00000000000..7de194fa10b --- /dev/null +++ b/docs/framework/svelte/reference/type-aliases/NotifyOnChangeProps.md @@ -0,0 +1,17 @@ +--- +id: NotifyOnChangeProps +title: NotifyOnChangeProps +--- + +```ts +type NotifyOnChangeProps = + | keyof InfiniteQueryObserverResult[] + | "all" + | undefined + | () => + | keyof InfiniteQueryObserverResult[] + | "all" + | undefined; +``` + +Defined in: [packages/query-core/src/types.ts:225](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L225) diff --git a/docs/framework/svelte/reference/type-aliases/OmitKeyof.md b/docs/framework/svelte/reference/type-aliases/OmitKeyof.md new file mode 100644 index 00000000000..690a7b0a5d2 --- /dev/null +++ b/docs/framework/svelte/reference/type-aliases/OmitKeyof.md @@ -0,0 +1,28 @@ +--- +id: OmitKeyof +title: OmitKeyof +--- + +```ts +type OmitKeyof = Omit; +``` + +Defined in: [packages/query-core/src/types.ts:19](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L19) + +## Type Parameters + +### TObject + +`TObject` + +### TKey + +`TKey` *extends* `TStrictly` *extends* `"safely"` ? + \| keyof `TObject` + \| `string` & `Record`\<`never`, `never`\> + \| `number` & `Record`\<`never`, `never`\> + \| `symbol` & `Record`\<`never`, `never`\> : keyof `TObject` + +### TStrictly + +`TStrictly` *extends* `"strictly"` \| `"safely"` = `"strictly"` diff --git a/docs/framework/svelte/reference/type-aliases/Override.md b/docs/framework/svelte/reference/type-aliases/Override.md new file mode 100644 index 00000000000..8abcecd1e1b --- /dev/null +++ b/docs/framework/svelte/reference/type-aliases/Override.md @@ -0,0 +1,20 @@ +--- +id: Override +title: Override +--- + +```ts +type Override = { [AKey in keyof TTargetA]: AKey extends keyof TTargetB ? TTargetB[AKey] : TTargetA[AKey] }; +``` + +Defined in: [packages/query-core/src/types.ts:31](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L31) + +## Type Parameters + +### TTargetA + +`TTargetA` + +### TTargetB + +`TTargetB` diff --git a/docs/framework/svelte/reference/type-aliases/PlaceholderDataFunction.md b/docs/framework/svelte/reference/type-aliases/PlaceholderDataFunction.md new file mode 100644 index 00000000000..cd40f28b41e --- /dev/null +++ b/docs/framework/svelte/reference/type-aliases/PlaceholderDataFunction.md @@ -0,0 +1,42 @@ +--- +id: PlaceholderDataFunction +title: PlaceholderDataFunction +--- + +```ts +type PlaceholderDataFunction = (previousData, previousQuery) => TQueryData | undefined; +``` + +Defined in: [packages/query-core/src/types.ts:177](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L177) + +## Type Parameters + +### TQueryFnData + +`TQueryFnData` = `unknown` + +### TError + +`TError` = [`DefaultError`](DefaultError.md) + +### TQueryData + +`TQueryData` = `TQueryFnData` + +### TQueryKey + +`TQueryKey` *extends* [`QueryKey`](QueryKey.md) = [`QueryKey`](QueryKey.md) + +## Parameters + +### previousData + +`TQueryData` | `undefined` + +### previousQuery + +[`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryData`, `TQueryKey`\> | `undefined` + +## Returns + +`TQueryData` \| `undefined` diff --git a/docs/framework/svelte/reference/type-aliases/QueriesPlaceholderDataFunction.md b/docs/framework/svelte/reference/type-aliases/QueriesPlaceholderDataFunction.md new file mode 100644 index 00000000000..5d3fca8c9e0 --- /dev/null +++ b/docs/framework/svelte/reference/type-aliases/QueriesPlaceholderDataFunction.md @@ -0,0 +1,30 @@ +--- +id: QueriesPlaceholderDataFunction +title: QueriesPlaceholderDataFunction +--- + +```ts +type QueriesPlaceholderDataFunction = (previousData, previousQuery) => TQueryData | undefined; +``` + +Defined in: [packages/query-core/src/types.ts:187](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L187) + +## Type Parameters + +### TQueryData + +`TQueryData` + +## Parameters + +### previousData + +`undefined` + +### previousQuery + +`undefined` + +## Returns + +`TQueryData` \| `undefined` diff --git a/docs/framework/svelte/reference/type-aliases/QueryBooleanOption.md b/docs/framework/svelte/reference/type-aliases/QueryBooleanOption.md new file mode 100644 index 00000000000..9759e3ddb42 --- /dev/null +++ b/docs/framework/svelte/reference/type-aliases/QueryBooleanOption.md @@ -0,0 +1,28 @@ +--- +id: QueryBooleanOption +title: QueryBooleanOption +--- + +```ts +type QueryBooleanOption = boolean | (query) => boolean; +``` + +Defined in: [packages/query-core/src/types.ts:119](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L119) + +## Type Parameters + +### TQueryFnData + +`TQueryFnData` = `unknown` + +### TError + +`TError` = [`DefaultError`](DefaultError.md) + +### TData + +`TData` = `TQueryFnData` + +### TQueryKey + +`TQueryKey` *extends* [`QueryKey`](QueryKey.md) = [`QueryKey`](QueryKey.md) diff --git a/docs/framework/svelte/reference/type-aliases/QueryCacheNotifyEvent.md b/docs/framework/svelte/reference/type-aliases/QueryCacheNotifyEvent.md new file mode 100644 index 00000000000..b92c76fb826 --- /dev/null +++ b/docs/framework/svelte/reference/type-aliases/QueryCacheNotifyEvent.md @@ -0,0 +1,21 @@ +--- +id: QueryCacheNotifyEvent +title: QueryCacheNotifyEvent +--- + +```ts +type QueryCacheNotifyEvent = + | NotifyEventQueryAdded + | NotifyEventQueryRemoved + | NotifyEventQueryUpdated + | NotifyEventQueryObserverAdded + | NotifyEventQueryObserverRemoved + | NotifyEventQueryObserverResultsUpdated + | NotifyEventQueryObserverOptionsUpdated; +``` + +Defined in: [packages/query-core/src/queryCache.ts:85](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryCache.ts#L85) + +The event passed to a `QueryCache` subscriber. Fired whenever a query is added or removed from +the cache, its state is updated (e.g. via `query.setState` or `queryClient.removeQueries`), or +one of its observers is added, removed, or has its results or options updated. diff --git a/docs/framework/svelte/reference/type-aliases/QueryFunction.md b/docs/framework/svelte/reference/type-aliases/QueryFunction.md new file mode 100644 index 00000000000..306367388a1 --- /dev/null +++ b/docs/framework/svelte/reference/type-aliases/QueryFunction.md @@ -0,0 +1,34 @@ +--- +id: QueryFunction +title: QueryFunction +--- + +```ts +type QueryFunction = (context) => T | Promise; +``` + +Defined in: [packages/query-core/src/types.ts:102](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L102) + +## Type Parameters + +### T + +`T` = `unknown` + +### TQueryKey + +`TQueryKey` *extends* [`QueryKey`](QueryKey.md) = [`QueryKey`](QueryKey.md) + +### TPageParam + +`TPageParam` = `never` + +## Parameters + +### context + +[`QueryFunctionContext`](QueryFunctionContext.md)\<`TQueryKey`, `TPageParam`\> + +## Returns + +`T` \| `Promise`\<`T`\> diff --git a/docs/framework/svelte/reference/type-aliases/QueryFunctionContext.md b/docs/framework/svelte/reference/type-aliases/QueryFunctionContext.md new file mode 100644 index 00000000000..d2c9fe3e2b2 --- /dev/null +++ b/docs/framework/svelte/reference/type-aliases/QueryFunctionContext.md @@ -0,0 +1,20 @@ +--- +id: QueryFunctionContext +title: QueryFunctionContext +--- + +```ts +type QueryFunctionContext = [TPageParam] extends [never] ? object : object; +``` + +Defined in: [packages/query-core/src/types.ts:144](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L144) + +## Type Parameters + +### TQueryKey + +`TQueryKey` *extends* [`QueryKey`](QueryKey.md) = [`QueryKey`](QueryKey.md) + +### TPageParam + +`TPageParam` = `never` diff --git a/docs/framework/svelte/reference/type-aliases/QueryKey.md b/docs/framework/svelte/reference/type-aliases/QueryKey.md new file mode 100644 index 00000000000..1a3f34cde18 --- /dev/null +++ b/docs/framework/svelte/reference/type-aliases/QueryKey.md @@ -0,0 +1,10 @@ +--- +id: QueryKey +title: QueryKey +--- + +```ts +type QueryKey = Register extends object ? TQueryKey extends ReadonlyArray ? TQueryKey : TQueryKey extends unknown[] ? TQueryKey : ReadonlyArray : ReadonlyArray; +``` + +Defined in: [packages/query-core/src/types.ts:51](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L51) diff --git a/docs/framework/svelte/reference/type-aliases/QueryKeyHashFunction.md b/docs/framework/svelte/reference/type-aliases/QueryKeyHashFunction.md new file mode 100644 index 00000000000..feda96373cc --- /dev/null +++ b/docs/framework/svelte/reference/type-aliases/QueryKeyHashFunction.md @@ -0,0 +1,26 @@ +--- +id: QueryKeyHashFunction +title: QueryKeyHashFunction +--- + +```ts +type QueryKeyHashFunction = (queryKey) => string; +``` + +Defined in: [packages/query-core/src/types.ts:192](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L192) + +## Type Parameters + +### TQueryKey + +`TQueryKey` *extends* [`QueryKey`](QueryKey.md) + +## Parameters + +### queryKey + +`TQueryKey` + +## Returns + +`string` diff --git a/docs/framework/svelte/reference/type-aliases/QueryKeyWithDataTag.md b/docs/framework/svelte/reference/type-aliases/QueryKeyWithDataTag.md new file mode 100644 index 00000000000..6613f74be9e --- /dev/null +++ b/docs/framework/svelte/reference/type-aliases/QueryKeyWithDataTag.md @@ -0,0 +1,34 @@ +--- +id: QueryKeyWithDataTag +title: QueryKeyWithDataTag +--- + +```ts +type QueryKeyWithDataTag = object; +``` + +Defined in: [packages/query-core/src/types.ts:82](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L82) + +## Type Parameters + +### TQueryKey + +`TQueryKey` *extends* [`QueryKey`](QueryKey.md) = [`QueryKey`](QueryKey.md) + +### TQueryFnData + +`TQueryFnData` = `unknown` + +### TError + +`TError` = [`DefaultError`](DefaultError.md) + +## Properties + +### queryKey + +```ts +queryKey: DataTag; +``` + +Defined in: [packages/query-core/src/types.ts:87](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L87) diff --git a/docs/framework/svelte/reference/type-aliases/QueryMeta.md b/docs/framework/svelte/reference/type-aliases/QueryMeta.md new file mode 100644 index 00000000000..c12917b2cce --- /dev/null +++ b/docs/framework/svelte/reference/type-aliases/QueryMeta.md @@ -0,0 +1,10 @@ +--- +id: QueryMeta +title: QueryMeta +--- + +```ts +type QueryMeta = Register extends object ? TQueryMeta extends Record ? TQueryMeta : Record : Record; +``` + +Defined in: [packages/query-core/src/types.ts:215](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L215) diff --git a/docs/framework/svelte/reference/type-aliases/QueryObserverResult.md b/docs/framework/svelte/reference/type-aliases/QueryObserverResult.md new file mode 100644 index 00000000000..5138b635f2c --- /dev/null +++ b/docs/framework/svelte/reference/type-aliases/QueryObserverResult.md @@ -0,0 +1,25 @@ +--- +id: QueryObserverResult +title: QueryObserverResult +--- + +```ts +type QueryObserverResult = + | DefinedQueryObserverResult + | QueryObserverLoadingErrorResult + | QueryObserverLoadingResult + | QueryObserverPendingResult +| QueryObserverPlaceholderResult; +``` + +Defined in: [packages/query-core/src/types.ts:994](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L994) + +## Type Parameters + +### TData + +`TData` = `unknown` + +### TError + +`TError` = [`DefaultError`](DefaultError.md) diff --git a/docs/framework/svelte/reference/type-aliases/QueryPersister.md b/docs/framework/svelte/reference/type-aliases/QueryPersister.md new file mode 100644 index 00000000000..72e80165b0d --- /dev/null +++ b/docs/framework/svelte/reference/type-aliases/QueryPersister.md @@ -0,0 +1,24 @@ +--- +id: QueryPersister +title: QueryPersister +--- + +```ts +type QueryPersister = [TPageParam] extends [never] ? (queryFn, context, query) => T | Promise : (queryFn, context, query) => T | Promise; +``` + +Defined in: [packages/query-core/src/types.ts:128](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L128) + +## Type Parameters + +### T + +`T` = `unknown` + +### TQueryKey + +`TQueryKey` *extends* [`QueryKey`](QueryKey.md) = [`QueryKey`](QueryKey.md) + +### TPageParam + +`TPageParam` = `never` diff --git a/docs/framework/svelte/reference/type-aliases/QueryStatus.md b/docs/framework/svelte/reference/type-aliases/QueryStatus.md new file mode 100644 index 00000000000..bab00f6f423 --- /dev/null +++ b/docs/framework/svelte/reference/type-aliases/QueryStatus.md @@ -0,0 +1,10 @@ +--- +id: QueryStatus +title: QueryStatus +--- + +```ts +type QueryStatus = "pending" | "error" | "success"; +``` + +Defined in: [packages/query-core/src/types.ts:761](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L761) diff --git a/docs/framework/svelte/reference/type-aliases/SkipToken.md b/docs/framework/svelte/reference/type-aliases/SkipToken.md new file mode 100644 index 00000000000..3a5791b982e --- /dev/null +++ b/docs/framework/svelte/reference/type-aliases/SkipToken.md @@ -0,0 +1,12 @@ +--- +id: SkipToken +title: SkipToken +--- + +```ts +type SkipToken = typeof skipToken; +``` + +Defined in: [packages/query-core/src/utils.ts:526](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L526) + +The type of the [skipToken](../variables/skipToken.md) sentinel value. diff --git a/docs/framework/svelte/reference/type-aliases/StaleTime.md b/docs/framework/svelte/reference/type-aliases/StaleTime.md new file mode 100644 index 00000000000..3e7e21608be --- /dev/null +++ b/docs/framework/svelte/reference/type-aliases/StaleTime.md @@ -0,0 +1,10 @@ +--- +id: StaleTime +title: StaleTime +--- + +```ts +type StaleTime = number | "static"; +``` + +Defined in: [packages/query-core/src/types.ts:108](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L108) diff --git a/docs/framework/svelte/reference/type-aliases/StaleTimeFunction.md b/docs/framework/svelte/reference/type-aliases/StaleTimeFunction.md new file mode 100644 index 00000000000..b1c541fa64e --- /dev/null +++ b/docs/framework/svelte/reference/type-aliases/StaleTimeFunction.md @@ -0,0 +1,28 @@ +--- +id: StaleTimeFunction +title: StaleTimeFunction +--- + +```ts +type StaleTimeFunction = StaleTime | (query) => StaleTime; +``` + +Defined in: [packages/query-core/src/types.ts:110](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L110) + +## Type Parameters + +### TQueryFnData + +`TQueryFnData` = `unknown` + +### TError + +`TError` = [`DefaultError`](DefaultError.md) + +### TData + +`TData` = `TQueryFnData` + +### TQueryKey + +`TQueryKey` *extends* [`QueryKey`](QueryKey.md) = [`QueryKey`](QueryKey.md) diff --git a/docs/framework/svelte/reference/type-aliases/ThrowOnError.md b/docs/framework/svelte/reference/type-aliases/ThrowOnError.md new file mode 100644 index 00000000000..134683388ef --- /dev/null +++ b/docs/framework/svelte/reference/type-aliases/ThrowOnError.md @@ -0,0 +1,28 @@ +--- +id: ThrowOnError +title: ThrowOnError +--- + +```ts +type ThrowOnError = boolean | (error, query) => boolean; +``` + +Defined in: [packages/query-core/src/types.ts:368](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L368) + +## Type Parameters + +### TQueryFnData + +`TQueryFnData` + +### TError + +`TError` + +### TQueryData + +`TQueryData` + +### TQueryKey + +`TQueryKey` *extends* [`QueryKey`](QueryKey.md) diff --git a/docs/framework/svelte/reference/type-aliases/TimeoutCallback.md b/docs/framework/svelte/reference/type-aliases/TimeoutCallback.md new file mode 100644 index 00000000000..773b5fdaeb9 --- /dev/null +++ b/docs/framework/svelte/reference/type-aliases/TimeoutCallback.md @@ -0,0 +1,27 @@ +--- +id: TimeoutCallback +title: TimeoutCallback +--- + +```ts +type TimeoutCallback = (_) => void; +``` + +Defined in: [packages/query-core/src/timeoutManager.ts:9](https://github.com/TanStack/query/blob/main/packages/query-core/src/timeoutManager.ts#L9) + +[TimeoutManager](../interfaces/TimeoutManager.md) does not support passing arguments to the callback. + +`(_: void)` is the argument type inferred by TypeScript's default typings for +`setTimeout(cb, number)`. +If we don't accept a single void argument, then +`new Promise(resolve => timeoutManager.setTimeout(resolve, N))` is a type error. + +## Parameters + +### \_ + +`void` + +## Returns + +`void` diff --git a/docs/framework/svelte/reference/type-aliases/TimeoutProvider.md b/docs/framework/svelte/reference/type-aliases/TimeoutProvider.md new file mode 100644 index 00000000000..3509105bcd1 --- /dev/null +++ b/docs/framework/svelte/reference/type-aliases/TimeoutProvider.md @@ -0,0 +1,112 @@ +--- +id: TimeoutProvider +title: TimeoutProvider +--- + +```ts +type TimeoutProvider = object; +``` + +Defined in: [packages/query-core/src/timeoutManager.ts:28](https://github.com/TanStack/query/blob/main/packages/query-core/src/timeoutManager.ts#L28) + +Backend for timer functions. + +Timers are performance-sensitive: short-lived timers (delays under a few seconds) tend to be +latency-sensitive, while long-lived ones may benefit more from coalescing — batching timers +with similar deadlines together — which the default provider (backed by the platform's global +`setTimeout`/`setInterval`) does not do. A custom provider can implement coalescing, and can +also support delays longer than the ~24-day maximum of the global `setTimeout`. + +## Type Parameters + +### TTimerId + +`TTimerId` *extends* [`ManagedTimerId`](ManagedTimerId.md) = [`ManagedTimerId`](ManagedTimerId.md) + +## Properties + +### clearInterval() + +```ts +readonly clearInterval: (intervalId) => void; +``` + +Defined in: [packages/query-core/src/timeoutManager.ts:34](https://github.com/TanStack/query/blob/main/packages/query-core/src/timeoutManager.ts#L34) + +#### Parameters + +##### intervalId + +`TTimerId` | `undefined` + +#### Returns + +`void` + +*** + +### clearTimeout() + +```ts +readonly clearTimeout: (timeoutId) => void; +``` + +Defined in: [packages/query-core/src/timeoutManager.ts:31](https://github.com/TanStack/query/blob/main/packages/query-core/src/timeoutManager.ts#L31) + +#### Parameters + +##### timeoutId + +`TTimerId` | `undefined` + +#### Returns + +`void` + +*** + +### setInterval() + +```ts +readonly setInterval: (callback, delay) => TTimerId; +``` + +Defined in: [packages/query-core/src/timeoutManager.ts:33](https://github.com/TanStack/query/blob/main/packages/query-core/src/timeoutManager.ts#L33) + +#### Parameters + +##### callback + +[`TimeoutCallback`](TimeoutCallback.md) + +##### delay + +`number` + +#### Returns + +`TTimerId` + +*** + +### setTimeout() + +```ts +readonly setTimeout: (callback, delay) => TTimerId; +``` + +Defined in: [packages/query-core/src/timeoutManager.ts:30](https://github.com/TanStack/query/blob/main/packages/query-core/src/timeoutManager.ts#L30) + +#### Parameters + +##### callback + +[`TimeoutCallback`](TimeoutCallback.md) + +##### delay + +`number` + +#### Returns + +`TTimerId` diff --git a/docs/framework/svelte/reference/type-aliases/UndefinedInitialDataInfiniteOptions.md b/docs/framework/svelte/reference/type-aliases/UndefinedInitialDataInfiniteOptions.md index a51304370d2..a0d8c1907d6 100644 --- a/docs/framework/svelte/reference/type-aliases/UndefinedInitialDataInfiniteOptions.md +++ b/docs/framework/svelte/reference/type-aliases/UndefinedInitialDataInfiniteOptions.md @@ -27,15 +27,15 @@ optional initialData: ### TError -`TError` = `DefaultError` +`TError` = [`DefaultError`](DefaultError.md) ### TData -`TData` = `InfiniteData`\<`TQueryFnData`\> +`TData` = [`InfiniteData`](../interfaces/InfiniteData.md)\<`TQueryFnData`\> ### TQueryKey -`TQueryKey` *extends* `QueryKey` = `QueryKey` +`TQueryKey` *extends* [`QueryKey`](QueryKey.md) = [`QueryKey`](QueryKey.md) ### TPageParam diff --git a/docs/framework/svelte/reference/type-aliases/UndefinedInitialDataOptions.md b/docs/framework/svelte/reference/type-aliases/UndefinedInitialDataOptions.md index 7f974342fb6..dd7717c4716 100644 --- a/docs/framework/svelte/reference/type-aliases/UndefinedInitialDataOptions.md +++ b/docs/framework/svelte/reference/type-aliases/UndefinedInitialDataOptions.md @@ -25,7 +25,7 @@ optional initialData: InitialDataFunction>; ### TError -`TError` = `DefaultError` +`TError` = [`DefaultError`](DefaultError.md) ### TData @@ -33,4 +33,4 @@ optional initialData: InitialDataFunction>; ### TQueryKey -`TQueryKey` *extends* `QueryKey` = `QueryKey` +`TQueryKey` *extends* [`QueryKey`](QueryKey.md) = [`QueryKey`](QueryKey.md) diff --git a/docs/framework/svelte/reference/type-aliases/UnsetMarker.md b/docs/framework/svelte/reference/type-aliases/UnsetMarker.md new file mode 100644 index 00000000000..8b9c14e1907 --- /dev/null +++ b/docs/framework/svelte/reference/type-aliases/UnsetMarker.md @@ -0,0 +1,10 @@ +--- +id: UnsetMarker +title: UnsetMarker +--- + +```ts +type UnsetMarker = typeof unsetMarker; +``` + +Defined in: [packages/query-core/src/types.ts:66](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L66) diff --git a/docs/framework/svelte/reference/type-aliases/Updater.md b/docs/framework/svelte/reference/type-aliases/Updater.md new file mode 100644 index 00000000000..7a0c2f30503 --- /dev/null +++ b/docs/framework/svelte/reference/type-aliases/Updater.md @@ -0,0 +1,35 @@ +--- +id: Updater +title: Updater +--- + +```ts +type Updater = TOutput | (input) => TOutput; +``` + +Defined in: [packages/query-core/src/utils.ts:105](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L105) + +Either a plain value of type `TOutput`, or a function that receives `TInput` and returns `TOutput`. +Used for example by `setQueryData`-style updaters, which accept either the new data directly or a +function that computes it from the previous data. See functionalUpdate. + +## Type Parameters + +### TInput + +`TInput` + +### TOutput + +`TOutput` + +## Example + +```ts +queryClient.setQueryData(['posts'], newPosts) + +// Or, using an updater function that receives the current data: +queryClient.setQueryData(['posts'], (oldPosts) => + oldPosts ? [...oldPosts, newPost] : oldPosts, +) +``` diff --git a/docs/framework/svelte/reference/type-aliases/WithRequired.md b/docs/framework/svelte/reference/type-aliases/WithRequired.md new file mode 100644 index 00000000000..a40a48c865b --- /dev/null +++ b/docs/framework/svelte/reference/type-aliases/WithRequired.md @@ -0,0 +1,20 @@ +--- +id: WithRequired +title: WithRequired +--- + +```ts +type WithRequired = TTarget & { [_ in TKey]: {} }; +``` + +Defined in: [packages/query-core/src/types.ts:524](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L524) + +## Type Parameters + +### TTarget + +`TTarget` + +### TKey + +`TKey` *extends* keyof `TTarget` diff --git a/docs/framework/svelte/reference/type-aliases/dataTagErrorSymbol.md b/docs/framework/svelte/reference/type-aliases/dataTagErrorSymbol.md new file mode 100644 index 00000000000..26148a94d6e --- /dev/null +++ b/docs/framework/svelte/reference/type-aliases/dataTagErrorSymbol.md @@ -0,0 +1,10 @@ +--- +id: dataTagErrorSymbol +title: dataTagErrorSymbol +--- + +```ts +type dataTagErrorSymbol = typeof dataTagErrorSymbol; +``` + +Defined in: [packages/query-core/src/types.ts:63](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L63) diff --git a/docs/framework/svelte/reference/type-aliases/dataTagSymbol.md b/docs/framework/svelte/reference/type-aliases/dataTagSymbol.md new file mode 100644 index 00000000000..0012c108cc5 --- /dev/null +++ b/docs/framework/svelte/reference/type-aliases/dataTagSymbol.md @@ -0,0 +1,10 @@ +--- +id: dataTagSymbol +title: dataTagSymbol +--- + +```ts +type dataTagSymbol = typeof dataTagSymbol; +``` + +Defined in: [packages/query-core/src/types.ts:61](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L61) diff --git a/docs/framework/svelte/reference/variables/dataTagErrorSymbol.md b/docs/framework/svelte/reference/variables/dataTagErrorSymbol.md new file mode 100644 index 00000000000..20bab62fb01 --- /dev/null +++ b/docs/framework/svelte/reference/variables/dataTagErrorSymbol.md @@ -0,0 +1,10 @@ +--- +id: dataTagErrorSymbol +title: dataTagErrorSymbol +--- + +```ts +const dataTagErrorSymbol: typeof dataTagErrorSymbol; +``` + +Defined in: [packages/query-core/src/types.ts:63](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L63) diff --git a/docs/framework/svelte/reference/variables/dataTagSymbol.md b/docs/framework/svelte/reference/variables/dataTagSymbol.md new file mode 100644 index 00000000000..83dd68a56e9 --- /dev/null +++ b/docs/framework/svelte/reference/variables/dataTagSymbol.md @@ -0,0 +1,10 @@ +--- +id: dataTagSymbol +title: dataTagSymbol +--- + +```ts +const dataTagSymbol: typeof dataTagSymbol; +``` + +Defined in: [packages/query-core/src/types.ts:61](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L61) diff --git a/docs/framework/svelte/reference/variables/defaultScheduler.md b/docs/framework/svelte/reference/variables/defaultScheduler.md new file mode 100644 index 00000000000..70e14d3f846 --- /dev/null +++ b/docs/framework/svelte/reference/variables/defaultScheduler.md @@ -0,0 +1,13 @@ +--- +id: defaultScheduler +title: defaultScheduler +--- + +```ts +const defaultScheduler: ScheduleFunction = systemSetTimeoutZero; +``` + +Defined in: [packages/query-core/src/notifyManager.ts:19](https://github.com/TanStack/query/blob/main/packages/query-core/src/notifyManager.ts#L19) + +Default scheduling function used by the notify manager. +Schedules the callback with the system's `setTimeout(callback, 0)`. diff --git a/docs/framework/svelte/reference/variables/environmentManager.md b/docs/framework/svelte/reference/variables/environmentManager.md new file mode 100644 index 00000000000..ed333b8747b --- /dev/null +++ b/docs/framework/svelte/reference/variables/environmentManager.md @@ -0,0 +1,59 @@ +--- +id: environmentManager +title: environmentManager +--- + +```ts +const environmentManager: object; +``` + +Defined in: [packages/query-core/src/environmentManager.ts:29](https://github.com/TanStack/query/blob/main/packages/query-core/src/environmentManager.ts#L29) + +Manages how TanStack Query detects whether the current runtime should be treated as +server-side, which disables scheduling refetch timers and changes the default `retry` count +and `gcTime`. By default, the detection treats a missing `window` (or the presence of a +`Deno` global) as server. + +Override this for runtimes where that default detection would give the wrong answer — for +example, a Service Worker, where `window` is undefined even though the environment should +behave like a client. + +## Type Declaration + +### isServer() + +```ts +isServer: () => boolean; +``` + +Returns whether the current runtime should be treated as a server environment. + +#### Returns + +`boolean` + +### setIsServer() + +```ts +setIsServer(isServerValue): void; +``` + +Overrides the server check globally. + +#### Parameters + +##### isServerValue + +`IsServerValue` + +#### Returns + +`void` + +## Example + +```ts +import { environmentManager } from '@tanstack/query-core' + +environmentManager.setIsServer(() => false) +``` diff --git a/docs/framework/svelte/reference/variables/focusManager.md b/docs/framework/svelte/reference/variables/focusManager.md new file mode 100644 index 00000000000..86477849e06 --- /dev/null +++ b/docs/framework/svelte/reference/variables/focusManager.md @@ -0,0 +1,12 @@ +--- +id: focusManager +title: focusManager +--- + +```ts +const focusManager: FocusManager; +``` + +Defined in: [packages/query-core/src/focusManager.ts:142](https://github.com/TanStack/query/blob/main/packages/query-core/src/focusManager.ts#L142) + +Singleton instance of [FocusManager](../interfaces/FocusManager.md), used to manage and observe the focus state within TanStack Query. diff --git a/docs/framework/svelte/reference/variables/isServer.md b/docs/framework/svelte/reference/variables/isServer.md new file mode 100644 index 00000000000..16aa39d1244 --- /dev/null +++ b/docs/framework/svelte/reference/variables/isServer.md @@ -0,0 +1,14 @@ +--- +id: isServer +title: isServer +--- + +```ts +const isServer: boolean; +``` + +Defined in: [packages/query-core/src/utils.ts:114](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L114) + +## Deprecated + +use `environmentManager.isServer()` instead. diff --git a/docs/framework/svelte/reference/variables/notifyManager.md b/docs/framework/svelte/reference/variables/notifyManager.md new file mode 100644 index 00000000000..4bdf3478be0 --- /dev/null +++ b/docs/framework/svelte/reference/variables/notifyManager.md @@ -0,0 +1,166 @@ +--- +id: notifyManager +title: notifyManager +--- + +```ts +const notifyManager: object; +``` + +Defined in: [packages/query-core/src/notifyManager.ts:144](https://github.com/TanStack/query/blob/main/packages/query-core/src/notifyManager.ts#L144) + +Handles scheduling and batching callbacks in TanStack Query. + +## Type Declaration + +### batch() + +```ts +readonly batch: (callback) => T; +``` + +Batches all updates scheduled inside the passed callback. +This is mainly used internally to optimize query client updating. +Batches can be nested; the queue is only flushed once the outermost `batch` call finishes. +The return value of `callback` is passed through. + +#### Type Parameters + +##### T + +`T` + +#### Parameters + +##### callback + +() => `T` + +#### Returns + +`T` + +### batchCalls() + +```ts +readonly batchCalls: (callback) => BatchCallsCallback; +``` + +All calls to the wrapped function will be batched. + +#### Type Parameters + +##### T + +`T` *extends* `unknown`[] + +#### Parameters + +##### callback + +`BatchCallsCallback`\<`T`\> + +#### Returns + +`BatchCallsCallback`\<`T`\> + +### schedule() + +```ts +schedule: (callback) => void; +``` + +Schedules a function to be run on the next batch. +By default, the batch is run with a `setTimeout`, but this can be configured via `setScheduler`. + +#### Parameters + +##### callback + +`NotifyCallback` + +#### Returns + +`void` + +### setBatchNotifyFunction() + +```ts +readonly setBatchNotifyFunction: (fn) => void; +``` + +Use this method to set a custom function to batch notifications together into a single tick. +Framework adapters use this to plug in their own batching primitive, so that a single query +update only triggers one re-render instead of one per subscriber. + +#### Parameters + +##### fn + +`BatchNotifyFunction` + +#### Returns + +`void` + +#### Example + +```ts +import { notifyManager } from '@tanstack/query-core' +import { batch } from 'solid-js' + +notifyManager.setBatchNotifyFunction(batch) +``` + +### setNotifyFunction() + +```ts +readonly setNotifyFunction: (fn) => void; +``` + +Use this method to set a custom notify function. +This can be used to for example wrap notifications with `React.act` while running tests. + +#### Parameters + +##### fn + +`NotifyFunction` + +#### Returns + +`void` + +### setScheduler() + +```ts +readonly setScheduler: (fn) => void; +``` + +Configures a custom callback that schedules when the next batch runs. +The default behavior is `setTimeout(callback, 0)`. + +#### Parameters + +##### fn + +`ScheduleFunction` + +#### Returns + +`void` + +#### Example + +```ts +import { notifyManager } from '@tanstack/query-core' + +// Schedule batches in the next microtask +notifyManager.setScheduler(queueMicrotask) + +// Schedule batches before the next frame is rendered +notifyManager.setScheduler(requestAnimationFrame) + +// Schedule batches some time in the future +notifyManager.setScheduler((cb) => setTimeout(cb, 10)) +``` diff --git a/docs/framework/svelte/reference/variables/onlineManager.md b/docs/framework/svelte/reference/variables/onlineManager.md new file mode 100644 index 00000000000..2eeec5385d8 --- /dev/null +++ b/docs/framework/svelte/reference/variables/onlineManager.md @@ -0,0 +1,12 @@ +--- +id: onlineManager +title: onlineManager +--- + +```ts +const onlineManager: OnlineManager; +``` + +Defined in: [packages/query-core/src/onlineManager.ts:117](https://github.com/TanStack/query/blob/main/packages/query-core/src/onlineManager.ts#L117) + +Singleton instance of [OnlineManager](../interfaces/OnlineManager.md), used to manage and observe the online state within TanStack Query. diff --git a/docs/framework/svelte/reference/variables/skipToken.md b/docs/framework/svelte/reference/variables/skipToken.md new file mode 100644 index 00000000000..a390d0b7b66 --- /dev/null +++ b/docs/framework/svelte/reference/variables/skipToken.md @@ -0,0 +1,23 @@ +--- +id: skipToken +title: skipToken +--- + +```ts +const skipToken: typeof skipToken; +``` + +Defined in: [packages/query-core/src/utils.ts:522](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L522) + +Sentinel value that can be passed as a query's `queryFn` to conditionally disable the query (equivalent +to `enabled: false`) while preserving full type inference for the query's data. Unlike `enabled: false`, +a query disabled via `skipToken` cannot be triggered with `refetch`. + +## Example + +```ts +new QueryObserver(queryClient, { + queryKey: ['post', postId], + queryFn: postId != null ? () => fetchPost(postId) : skipToken, +}) +``` diff --git a/docs/framework/svelte/reference/variables/timeoutManager.md b/docs/framework/svelte/reference/variables/timeoutManager.md new file mode 100644 index 00000000000..1eca1a5f343 --- /dev/null +++ b/docs/framework/svelte/reference/variables/timeoutManager.md @@ -0,0 +1,12 @@ +--- +id: timeoutManager +title: timeoutManager +--- + +```ts +const timeoutManager: TimeoutManager; +``` + +Defined in: [packages/query-core/src/timeoutManager.ts:232](https://github.com/TanStack/query/blob/main/packages/query-core/src/timeoutManager.ts#L232) + +Singleton instance of [TimeoutManager](../interfaces/TimeoutManager.md), used throughout TanStack Query to schedule and cancel timers. diff --git a/docs/framework/svelte/reference/variables/unsetMarker.md b/docs/framework/svelte/reference/variables/unsetMarker.md new file mode 100644 index 00000000000..d19ee65b38e --- /dev/null +++ b/docs/framework/svelte/reference/variables/unsetMarker.md @@ -0,0 +1,10 @@ +--- +id: unsetMarker +title: unsetMarker +--- + +```ts +const unsetMarker: typeof unsetMarker; +``` + +Defined in: [packages/query-core/src/types.ts:65](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L65) diff --git a/docs/framework/vue/guides/ssr.md b/docs/framework/vue/guides/ssr.md index eee4e59bfdf..f4467c713b6 100644 --- a/docs/framework/vue/guides/ssr.md +++ b/docs/framework/vue/guides/ssr.md @@ -254,7 +254,7 @@ In case you are creating the `QueryClient` for every request, Vue Query creates On the server, `gcTime` defaults to `Infinity` which disables manual garbage collection and will automatically clear memory once a request has finished. If you are explicitly setting a non-Infinity `gcTime` then you will be responsible for clearing the cache early. -To clear the cache after it is not needed and to lower memory consumption, you can add a call to [`queryClient.clear()`](../../../reference/QueryClient/#queryclientclear) after the request is handled and dehydrated state has been sent to the client. +To clear the cache after it is not needed and to lower memory consumption, you can add a call to [`queryClient.clear()`](../reference/classes/QueryClient.md#clear) after the request is handled and dehydrated state has been sent to the client. ## `dehydrate`/`hydrate` options diff --git a/docs/framework/vue/reference/classes/CancelledError.md b/docs/framework/vue/reference/classes/CancelledError.md new file mode 100644 index 00000000000..7fded5da20f --- /dev/null +++ b/docs/framework/vue/reference/classes/CancelledError.md @@ -0,0 +1,273 @@ +--- +id: CancelledError +title: CancelledError +--- + +Defined in: [packages/query-core/src/retryer.ts:77](https://github.com/TanStack/query/blob/main/packages/query-core/src/retryer.ts#L77) + +The error thrown by a `Retryer` (and surfaced to `query.promise`/`mutation`) when a fetch is cancelled, e.g. via +`query.cancel()`. `revert`, if `true`, tells the caller to restore the state the query was in before the fetch +started instead of surfacing the error. `silent`, if `true`, tells the caller to suppress this error and instead +resolve with the promise of the fetch that triggered the cancellation. + +## Example + +```ts +query.cancel() + +try { + await query.promise +} catch (error) { + if (error instanceof CancelledError) { + // the fetch was cancelled, e.g. via `query.cancel()` + } +} +``` + +## Extends + +- `Error` + +## Constructors + +### Constructor + +```ts +new CancelledError(options?): CancelledError; +``` + +Defined in: [packages/query-core/src/retryer.ts:80](https://github.com/TanStack/query/blob/main/packages/query-core/src/retryer.ts#L80) + +#### Parameters + +##### options? + +[`CancelOptions`](../interfaces/CancelOptions.md) + +#### Returns + +`CancelledError` + +#### Overrides + +```ts +Error.constructor +``` + +## Properties + +### cause? + +```ts +optional cause: unknown; +``` + +Defined in: node\_modules/.pnpm/typescript@6.0.3/node\_modules/typescript/lib/lib.es2022.error.d.ts:24 + +#### Inherited from + +```ts +Error.cause +``` + +*** + +### message + +```ts +message: string; +``` + +Defined in: node\_modules/.pnpm/typescript@6.0.3/node\_modules/typescript/lib/lib.es5.d.ts:1075 + +#### Inherited from + +```ts +Error.message +``` + +*** + +### name + +```ts +name: string; +``` + +Defined in: node\_modules/.pnpm/typescript@6.0.3/node\_modules/typescript/lib/lib.es5.d.ts:1074 + +#### Inherited from + +```ts +Error.name +``` + +*** + +### revert? + +```ts +optional revert: boolean; +``` + +Defined in: [packages/query-core/src/retryer.ts:78](https://github.com/TanStack/query/blob/main/packages/query-core/src/retryer.ts#L78) + +*** + +### silent? + +```ts +optional silent: boolean; +``` + +Defined in: [packages/query-core/src/retryer.ts:79](https://github.com/TanStack/query/blob/main/packages/query-core/src/retryer.ts#L79) + +*** + +### stack? + +```ts +optional stack: string; +``` + +Defined in: node\_modules/.pnpm/typescript@6.0.3/node\_modules/typescript/lib/lib.es5.d.ts:1076 + +#### Inherited from + +```ts +Error.stack +``` + +*** + +### stackTraceLimit + +```ts +static stackTraceLimit: number; +``` + +Defined in: node\_modules/.pnpm/@types+node@22.19.15/node\_modules/@types/node/globals.d.ts:68 + +The `Error.stackTraceLimit` property specifies the number of stack frames +collected by a stack trace (whether generated by `new Error().stack` or +`Error.captureStackTrace(obj)`). + +The default value is `10` but may be set to any valid JavaScript number. Changes +will affect any stack trace captured _after_ the value has been changed. + +If set to a non-number value, or set to a negative number, stack traces will +not capture any frames. + +#### Inherited from + +```ts +Error.stackTraceLimit +``` + +## Methods + +### captureStackTrace() + +```ts +static captureStackTrace(targetObject, constructorOpt?): void; +``` + +Defined in: node\_modules/.pnpm/@types+node@22.19.15/node\_modules/@types/node/globals.d.ts:52 + +Creates a `.stack` property on `targetObject`, which when accessed returns +a string representing the location in the code at which +`Error.captureStackTrace()` was called. + +```js +const myObject = {}; +Error.captureStackTrace(myObject); +myObject.stack; // Similar to `new Error().stack` +``` + +The first line of the trace will be prefixed with +`${myObject.name}: ${myObject.message}`. + +The optional `constructorOpt` argument accepts a function. If given, all frames +above `constructorOpt`, including `constructorOpt`, will be omitted from the +generated stack trace. + +The `constructorOpt` argument is useful for hiding implementation +details of error generation from the user. For instance: + +```js +function a() { + b(); +} + +function b() { + c(); +} + +function c() { + // Create an error without stack trace to avoid calculating the stack trace twice. + const { stackTraceLimit } = Error; + Error.stackTraceLimit = 0; + const error = new Error(); + Error.stackTraceLimit = stackTraceLimit; + + // Capture the stack trace above function b + Error.captureStackTrace(error, b); // Neither function c, nor b is included in the stack trace + throw error; +} + +a(); +``` + +#### Parameters + +##### targetObject + +`object` + +##### constructorOpt? + +`Function` + +#### Returns + +`void` + +#### Inherited from + +```ts +Error.captureStackTrace +``` + +*** + +### prepareStackTrace() + +```ts +static prepareStackTrace(err, stackTraces): any; +``` + +Defined in: node\_modules/.pnpm/@types+node@22.19.15/node\_modules/@types/node/globals.d.ts:56 + +#### Parameters + +##### err + +`Error` + +##### stackTraces + +`CallSite`[] + +#### Returns + +`any` + +#### See + +https://v8.dev/docs/stack-trace-api#customizing-stack-traces + +#### Inherited from + +```ts +Error.prepareStackTrace +``` diff --git a/docs/framework/vue/reference/classes/InfiniteQueryObserver.md b/docs/framework/vue/reference/classes/InfiniteQueryObserver.md new file mode 100644 index 00000000000..fdc87755e8a --- /dev/null +++ b/docs/framework/vue/reference/classes/InfiniteQueryObserver.md @@ -0,0 +1,665 @@ +--- +id: InfiniteQueryObserver +title: InfiniteQueryObserver +--- + +Defined in: [packages/query-core/src/infiniteQueryObserver.ts:41](https://github.com/TanStack/query/blob/main/packages/query-core/src/infiniteQueryObserver.ts#L41) + +An `InfiniteQueryObserver` extends `QueryObserver` to observe and switch +between infinite queries. It augments the base `QueryObserverResult` with +infinite-query-specific fields and methods, such as `hasNextPage` and +`fetchNextPage`, and is the primitive that framework adapters (e.g. +`useInfiniteQuery`) build their hooks on top of. + +## Example + +```ts +const observer = new InfiniteQueryObserver(queryClient, { + queryKey: ['projects'], + queryFn: ({ pageParam }) => fetchProjects(pageParam), + initialPageParam: 0, + getNextPageParam: (lastPage) => lastPage.nextCursor, +}) + +const unsubscribe = observer.subscribe((result) => console.log(result)) +``` + +## Extends + +- [`QueryObserver`](QueryObserver.md)\<`TQueryFnData`, `TError`, `TData`, [`InfiniteData`](../interfaces/InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\> + +## Type Parameters + +### TQueryFnData + +`TQueryFnData` = `unknown` + +### TError + +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) + +### TData + +`TData` = [`InfiniteData`](../interfaces/InfiniteData.md)\<`TQueryFnData`\> + +### TQueryKey + +`TQueryKey` *extends* [`QueryKey`](../type-aliases/QueryKey.md) = [`QueryKey`](../type-aliases/QueryKey.md) + +### TPageParam + +`TPageParam` = `unknown` + +## Constructors + +### Constructor + +```ts +new InfiniteQueryObserver(client, options): InfiniteQueryObserver; +``` + +Defined in: [packages/query-core/src/infiniteQueryObserver.ts:83](https://github.com/TanStack/query/blob/main/packages/query-core/src/infiniteQueryObserver.ts#L83) + +#### Parameters + +##### client + +`QueryClient` + +##### options + +[`InfiniteQueryObserverOptions`](../interfaces/InfiniteQueryObserverOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`, `TPageParam`\> + +#### Returns + +`InfiniteQueryObserver`\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`, `TPageParam`\> + +#### Overrides + +[`QueryObserver`](QueryObserver.md).[`constructor`](QueryObserver.md#constructor) + +## Properties + +### fetch + +```ts +protected fetch: ReplaceReturnType<(fetchOptions) => Promise>, Promise>>; +``` + +Defined in: [packages/query-core/src/infiniteQueryObserver.ts:72](https://github.com/TanStack/query/blob/main/packages/query-core/src/infiniteQueryObserver.ts#L72) + +#### Overrides + +```ts +QueryObserver.fetch +``` + +*** + +### getCurrentResult + +```ts +getCurrentResult: ReplaceReturnType<() => QueryObserverResult, InfiniteQueryObserverResult>; +``` + +Defined in: [packages/query-core/src/infiniteQueryObserver.ts:60](https://github.com/TanStack/query/blob/main/packages/query-core/src/infiniteQueryObserver.ts#L60) + +Returns the most recently computed `QueryObserverResult` for the +observed query. This is a point-in-time read; to be notified of updates +as they happen, subscribe to the observer instead (its inherited +`subscribe` method). + +#### Example + +```ts +const result = observer.getCurrentResult() +console.log(result.status, result.data) +``` + +#### Overrides + +```ts +QueryObserver.getCurrentResult +``` + +*** + +### listeners + +```ts +protected listeners: Set>; +``` + +Defined in: [packages/query-core/src/subscribable.ts:2](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L2) + +#### Inherited from + +[`QueryObserver`](QueryObserver.md).[`listeners`](QueryObserver.md#listeners) + +*** + +### options + +```ts +options: QueryObserverOptions, TQueryKey>; +``` + +Defined in: [packages/query-core/src/queryObserver.ts:89](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L89) + +#### Inherited from + +[`QueryObserver`](QueryObserver.md).[`options`](QueryObserver.md#options) + +*** + +### subscribe() + +```ts +subscribe: (listener) => () => void; +``` + +Defined in: [packages/query-core/src/infiniteQueryObserver.ts:55](https://github.com/TanStack/query/blob/main/packages/query-core/src/infiniteQueryObserver.ts#L55) + +#### Parameters + +##### listener + +`InfiniteQueryObserverListener` + +#### Returns + +```ts +(): void; +``` + +##### Returns + +`void` + +#### Overrides + +```ts +QueryObserver.subscribe +``` + +## Methods + +### bindMethods() + +```ts +protected bindMethods(): void; +``` + +Defined in: [packages/query-core/src/infiniteQueryObserver.ts:96](https://github.com/TanStack/query/blob/main/packages/query-core/src/infiniteQueryObserver.ts#L96) + +#### Returns + +`void` + +#### Overrides + +[`QueryObserver`](QueryObserver.md).[`bindMethods`](QueryObserver.md#bindmethods) + +*** + +### createResult() + +```ts +protected createResult(query, options): InfiniteQueryObserverResult; +``` + +Defined in: [packages/query-core/src/infiniteQueryObserver.ts:201](https://github.com/TanStack/query/blob/main/packages/query-core/src/infiniteQueryObserver.ts#L201) + +#### Parameters + +##### query + +[`Query`](Query.md)\<`TQueryFnData`, `TError`, [`InfiniteData`](../interfaces/InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\> + +##### options + +[`InfiniteQueryObserverOptions`](../interfaces/InfiniteQueryObserverOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`, `TPageParam`\> + +#### Returns + +[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\> + +#### Overrides + +[`QueryObserver`](QueryObserver.md).[`createResult`](QueryObserver.md#createresult) + +*** + +### destroy() + +```ts +destroy(): void; +``` + +Defined in: [packages/query-core/src/queryObserver.ts:161](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L161) + +Stops observing the current query: clears all listeners, cancels the +stale and refetch-interval timers, and removes this observer from the +query it was observing. + +#### Returns + +`void` + +#### Inherited from + +[`QueryObserver`](QueryObserver.md).[`destroy`](QueryObserver.md#destroy) + +*** + +### fetchNextPage() + +```ts +fetchNextPage(options?): Promise>; +``` + +Defined in: [packages/query-core/src/infiniteQueryObserver.ts:161](https://github.com/TanStack/query/blob/main/packages/query-core/src/infiniteQueryObserver.ts#L161) + +Fetches the next page of the infinite query and returns a promise that +resolves with the resulting `InfiniteQueryObserverResult`. The page +param used for the fetch is determined by `getNextPageParam`, which +receives the current pages/page params and whose result also determines +`hasNextPage`. + +#### Parameters + +##### options? + +[`FetchNextPageOptions`](../interfaces/FetchNextPageOptions.md) + +#### Returns + +`Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> + +#### Example + +```ts +const { hasNextPage } = observer.getCurrentResult() + +if (hasNextPage) { + await observer.fetchNextPage() +} +``` + +#### See + +[InfiniteQueryObserver#fetchPreviousPage](#fetchpreviouspage) + +*** + +### fetchOptimistic() + +```ts +fetchOptimistic(options): Promise>; +``` + +Defined in: [packages/query-core/src/queryObserver.ts:395](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L395) + +Fetches a query defined by the given options without affecting this +observer's own tracked query or result, and returns a promise that +resolves with the `QueryObserverResult` for that fetch. This is useful +for prefetching data that another observer (e.g. a query about to be +navigated to) will need, ahead of time. + +#### Parameters + +##### options + +[`QueryObserverOptions`](../interfaces/QueryObserverOptions.md)\<`TQueryFnData`, `TError`, `TData`, [`InfiniteData`](../interfaces/InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\> + +#### Returns + +`Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> + +#### Example + +```ts +const result = await observer.fetchOptimistic({ + queryKey: ['posts', 2], + queryFn: () => fetchPost(2), +}) +console.log(result.data) +``` + +#### Inherited from + +[`QueryObserver`](QueryObserver.md).[`fetchOptimistic`](QueryObserver.md#fetchoptimistic) + +*** + +### fetchPreviousPage() + +```ts +fetchPreviousPage(options?): Promise>; +``` + +Defined in: [packages/query-core/src/infiniteQueryObserver.ts:190](https://github.com/TanStack/query/blob/main/packages/query-core/src/infiniteQueryObserver.ts#L190) + +Fetches the previous page of the infinite query and returns a promise +that resolves with the resulting `InfiniteQueryObserverResult`. The page +param used for the fetch is determined by `getPreviousPageParam`, which +receives the current pages/page params and whose result also determines +`hasPreviousPage`. + +#### Parameters + +##### options? + +[`FetchPreviousPageOptions`](../interfaces/FetchPreviousPageOptions.md) + +#### Returns + +`Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> + +#### Example + +```ts +const { hasPreviousPage } = observer.getCurrentResult() + +if (hasPreviousPage) { + await observer.fetchPreviousPage() +} +``` + +#### See + +[InfiniteQueryObserver#fetchNextPage](#fetchnextpage) + +*** + +### getCurrentQuery() + +```ts +getCurrentQuery(): Query, TQueryKey>; +``` + +Defined in: [packages/query-core/src/queryObserver.ts:357](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L357) + +Returns the `Query` instance this observer is currently observing. + +#### Returns + +[`Query`](Query.md)\<`TQueryFnData`, `TError`, [`InfiniteData`](../interfaces/InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`\> + +#### Inherited from + +[`QueryObserver`](QueryObserver.md).[`getCurrentQuery`](QueryObserver.md#getcurrentquery) + +*** + +### getOptimisticResult() + +```ts +getOptimisticResult(options): InfiniteQueryObserverResult; +``` + +Defined in: [packages/query-core/src/infiniteQueryObserver.ts:127](https://github.com/TanStack/query/blob/main/packages/query-core/src/infiniteQueryObserver.ts#L127) + +The infinite-query counterpart of [QueryObserver#getOptimisticResult](QueryObserver.md#getoptimisticresult), marking the +options as an infinite query before delegating to it. Called by framework adapters (e.g. +`useInfiniteQuery`) ahead of subscribing, to compute the current `InfiniteQueryObserverResult` +synchronously. + +#### Parameters + +##### options + +[`DefaultedInfiniteQueryObserverOptions`](../type-aliases/DefaultedInfiniteQueryObserverOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`, `TPageParam`\> + +#### Returns + +[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\> + +#### Overrides + +[`QueryObserver`](QueryObserver.md).[`getOptimisticResult`](QueryObserver.md#getoptimisticresult) + +*** + +### hasListeners() + +```ts +hasListeners(): boolean; +``` + +Defined in: [packages/query-core/src/subscribable.ts:19](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L19) + +#### Returns + +`boolean` + +#### Inherited from + +[`QueryObserver`](QueryObserver.md).[`hasListeners`](QueryObserver.md#haslisteners) + +*** + +### onSubscribe() + +```ts +protected onSubscribe(): void; +``` + +Defined in: [packages/query-core/src/queryObserver.ts:110](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L110) + +#### Returns + +`void` + +#### Inherited from + +[`QueryObserver`](QueryObserver.md).[`onSubscribe`](QueryObserver.md#onsubscribe) + +*** + +### onUnsubscribe() + +```ts +protected onUnsubscribe(): void; +``` + +Defined in: [packages/query-core/src/queryObserver.ts:124](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L124) + +#### Returns + +`void` + +#### Inherited from + +[`QueryObserver`](QueryObserver.md).[`onUnsubscribe`](QueryObserver.md#onunsubscribe) + +*** + +### refetch() + +```ts +refetch(__namedParameters): Promise>; +``` + +Defined in: [packages/query-core/src/queryObserver.ts:371](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L371) + +Refetches the observed query and returns a promise that resolves with +the resulting `QueryObserverResult`. + +#### Parameters + +##### \_\_namedParameters + +[`RefetchOptions`](../interfaces/RefetchOptions.md) = `{}` + +#### Returns + +`Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> + +#### Example + +```ts +const result = await observer.refetch({ cancelRefetch: false }) +console.log(result.data) +``` + +#### Inherited from + +[`QueryObserver`](QueryObserver.md).[`refetch`](QueryObserver.md#refetch) + +*** + +### setOptions() + +```ts +setOptions(options): void; +``` + +Defined in: [packages/query-core/src/infiniteQueryObserver.ts:108](https://github.com/TanStack/query/blob/main/packages/query-core/src/infiniteQueryObserver.ts#L108) + +Updates the observer's options. Behaves the same as +`QueryObserver.setOptions`, additionally marking the options as +belonging to an infinite query before delegating to the base +implementation. + +#### Parameters + +##### options + +[`InfiniteQueryObserverOptions`](../interfaces/InfiniteQueryObserverOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`, `TPageParam`\> + +#### Returns + +`void` + +#### Overrides + +[`QueryObserver`](QueryObserver.md).[`setOptions`](QueryObserver.md#setoptions) + +*** + +### shouldFetchOnReconnect() + +```ts +shouldFetchOnReconnect(): boolean; +``` + +Defined in: [packages/query-core/src/queryObserver.ts:135](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L135) + +Returns whether the observed query is currently stale and configured +(via the `refetchOnReconnect` option) to refetch when the network +reconnects. + +#### Returns + +`boolean` + +#### Inherited from + +[`QueryObserver`](QueryObserver.md).[`shouldFetchOnReconnect`](QueryObserver.md#shouldfetchonreconnect) + +*** + +### shouldFetchOnWindowFocus() + +```ts +shouldFetchOnWindowFocus(): boolean; +``` + +Defined in: [packages/query-core/src/queryObserver.ts:148](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L148) + +Returns whether the observed query is currently stale and configured +(via the `refetchOnWindowFocus` option) to refetch when the window +regains focus. + +#### Returns + +`boolean` + +#### Inherited from + +[`QueryObserver`](QueryObserver.md).[`shouldFetchOnWindowFocus`](QueryObserver.md#shouldfetchonwindowfocus) + +*** + +### trackProp() + +```ts +trackProp(key): void; +``` + +Defined in: [packages/query-core/src/queryObserver.ts:350](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L350) + +Records that the given `QueryObserverResult` property was read, so a subsequent update only +notifies this observer if a tracked property actually changed. Normally called indirectly via +[QueryObserver#trackResult](QueryObserver.md#trackresult)'s proxy; exposed directly for adapters that track property +access themselves (e.g. through their own reactivity system) instead of via the proxy. + +#### Parameters + +##### key + +`"error"` | `"data"` | `"isError"` | `"isPending"` | `"isLoading"` | `"isLoadingError"` | `"isRefetchError"` | `"isSuccess"` | `"isPlaceholderData"` | `"status"` | `"dataUpdatedAt"` | `"errorUpdatedAt"` | `"failureCount"` | `"failureReason"` | `"errorUpdateCount"` | `"isFetched"` | `"isFetchedAfterMount"` | `"isFetching"` | `"isInitialLoading"` | `"isPaused"` | `"isRefetching"` | `"isStale"` | `"isEnabled"` | `"refetch"` | `"fetchStatus"` + +#### Returns + +`void` + +#### Inherited from + +[`QueryObserver`](QueryObserver.md).[`trackProp`](QueryObserver.md#trackprop) + +*** + +### trackResult() + +```ts +trackResult(result, onPropTracked?): QueryObserverResult; +``` + +Defined in: [packages/query-core/src/queryObserver.ts:331](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L331) + +Wraps a `QueryObserverResult` in a `Proxy` that records which properties are read, via +[QueryObserver#trackProp](QueryObserver.md#trackprop) (and an optional `onPropTracked` callback). Used by framework +adapters when `notifyOnChangeProps` is not set, to implement its default "only re-render on +properties you actually read" behavior. + +#### Parameters + +##### result + +[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\> + +##### onPropTracked? + +(`key`) => `void` + +#### Returns + +[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\> + +#### Inherited from + +[`QueryObserver`](QueryObserver.md).[`trackResult`](QueryObserver.md#trackresult) + +*** + +### updateResult() + +```ts +updateResult(): void; +``` + +Defined in: [packages/query-core/src/queryObserver.ts:735](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L735) + +Recomputes and stores the current result from the current query/options, notifying listeners +if it changed. Framework adapters call this right after subscribing to make sure no query +update was missed in the gap between creating the observer and subscribing to it. + +#### Returns + +`void` + +#### Inherited from + +[`QueryObserver`](QueryObserver.md).[`updateResult`](QueryObserver.md#updateresult) diff --git a/docs/framework/vue/reference/classes/Mutation.md b/docs/framework/vue/reference/classes/Mutation.md new file mode 100644 index 00000000000..e038a9cd394 --- /dev/null +++ b/docs/framework/vue/reference/classes/Mutation.md @@ -0,0 +1,330 @@ +--- +id: Mutation +title: Mutation +--- + +Defined in: [packages/query-core/src/mutation.ts:135](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L135) + +Represents a single mutation attempt. A `Mutation` holds the mutation's +options, state (data/error/status), and the `MutationObserver`s currently +subscribed to it. + +Instances are created and managed internally by `MutationCache`; application +code typically interacts with mutations indirectly through `QueryClient` or +a framework hook like `useMutation`. Direct access to a `Mutation` instance +is possible via `mutationCache.find()`/`getAll()` for inspecting cache state. + +## Example + +```ts +const mutationCache = queryClient.getMutationCache() + +const mutation = mutationCache.find({ mutationKey: ['addPost'] }) +``` + +## Extends + +- `Removable` + +## Type Parameters + +### TData + +`TData` = `unknown` + +### TError + +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) + +### TVariables + +`TVariables` = `unknown` + +### TOnMutateResult + +`TOnMutateResult` = `unknown` + +## Constructors + +### Constructor + +```ts +new Mutation(config): Mutation; +``` + +Defined in: [packages/query-core/src/mutation.ts:152](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L152) + +#### Parameters + +##### config + +`MutationConfig`\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\> + +#### Returns + +`Mutation`\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\> + +#### Overrides + +```ts +Removable.constructor +``` + +## Properties + +### gcTime + +```ts +gcTime: number; +``` + +Defined in: [packages/query-core/src/removable.ts:7](https://github.com/TanStack/query/blob/main/packages/query-core/src/removable.ts#L7) + +#### Inherited from + +```ts +Removable.gcTime +``` + +*** + +### mutationId + +```ts +readonly mutationId: number; +``` + +Defined in: [packages/query-core/src/mutation.ts:143](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L143) + +*** + +### options + +```ts +options: MutationOptions; +``` + +Defined in: [packages/query-core/src/mutation.ts:142](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L142) + +*** + +### state + +```ts +state: MutationState; +``` + +Defined in: [packages/query-core/src/mutation.ts:141](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L141) + +## Accessors + +### meta + +#### Get Signature + +```ts +get meta(): Record | undefined; +``` + +Defined in: [packages/query-core/src/mutation.ts:179](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L179) + +The `meta` object passed in the mutation's options, if any. + +##### Returns + +`Record`\<`string`, `unknown`\> \| `undefined` + +## Methods + +### clearGcTimeout() + +```ts +protected clearGcTimeout(): void; +``` + +Defined in: [packages/query-core/src/removable.ts:32](https://github.com/TanStack/query/blob/main/packages/query-core/src/removable.ts#L32) + +#### Returns + +`void` + +#### Inherited from + +```ts +Removable.clearGcTimeout +``` + +*** + +### continue() + +```ts +continue(): Promise; +``` + +Defined in: [packages/query-core/src/mutation.ts:243](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L243) + +Resumes a mutation that is currently paused or was restored from a +dehydrated, still-`pending` state. + +- If this mutation has an active retryer (it paused mid-attempt, e.g. due + to the network mode or scope-based queuing), its retryer is resumed. +- Otherwise, if the mutation's status is still `pending` (e.g. it was + dehydrated while an attempt was in flight and never got a retryer in + this instance), `execute` is called again with the last known variables. +- Otherwise the mutation has already settled and this resolves immediately + without running anything again. + +#### Returns + +`Promise`\<`unknown`\> + +#### Example + +```ts +// typically driven by reconnect handling, e.g. queryClient.resumePausedMutations() +const mutation = mutationCache.find({ mutationKey: ['addPost'] }) +await mutation?.continue() +``` + +#### See + +[Mutation#execute](#execute) + +*** + +### destroy() + +```ts +destroy(): void; +``` + +Defined in: [packages/query-core/src/removable.ts:10](https://github.com/TanStack/query/blob/main/packages/query-core/src/removable.ts#L10) + +#### Returns + +`void` + +#### Inherited from + +```ts +Removable.destroy +``` + +*** + +### execute() + +```ts +execute(variables): Promise; +``` + +Defined in: [packages/query-core/src/mutation.ts:284](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L284) + +Runs the mutation function for the given variables through a retryer, and +drives the mutation's state and lifecycle callbacks through to settlement. + +If this mutation's state is already `pending` when `execute` is called +(i.e. it was restored, still in-flight, from a dehydrated state), the +`onMutate` step is skipped and a `continue` action is dispatched to +unpause it; otherwise a `pending` action is dispatched first, then the +mutation cache's `onMutate` and the mutation's own `onMutate` option are +awaited in that order, and the resulting context is stored. + +The mutation function is then run (subject to `retry`/`retryDelay`/ +`networkMode`, and to the mutation cache's scope-based serialization). +On success, the cache's `onSuccess`/`onSettled` callbacks run before the +mutation's own `onSuccess`/`onSettled` options, a `success` action is +dispatched, and the resolved data is returned. On failure, the same +cache-then-option ordering is used for `onError`/`onSettled`, but each of +those four callbacks is individually caught so that a throwing callback +cannot mask the original error; an `error` action is then dispatched and +the original error is re-thrown. + +#### Parameters + +##### variables + +`TVariables` + +#### Returns + +`Promise`\<`TData`\> + +#### Example + +```ts +// Called internally by `MutationObserver.mutate` and `Mutation.continue` — +// applications normally trigger mutations through those, not this method. +const data = await mutation.execute(variables) +``` + +#### See + +[Mutation#continue](#continue) + +*** + +### optionalRemove() + +```ts +protected optionalRemove(): void; +``` + +Defined in: [packages/query-core/src/mutation.ts:212](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L212) + +#### Returns + +`void` + +#### Overrides + +```ts +Removable.optionalRemove +``` + +*** + +### scheduleGc() + +```ts +protected scheduleGc(): void; +``` + +Defined in: [packages/query-core/src/removable.ts:14](https://github.com/TanStack/query/blob/main/packages/query-core/src/removable.ts#L14) + +#### Returns + +`void` + +#### Inherited from + +```ts +Removable.scheduleGc +``` + +*** + +### updateGcTime() + +```ts +protected updateGcTime(newGcTime): void; +``` + +Defined in: [packages/query-core/src/removable.ts:24](https://github.com/TanStack/query/blob/main/packages/query-core/src/removable.ts#L24) + +#### Parameters + +##### newGcTime + +`number` | `undefined` + +#### Returns + +`void` + +#### Inherited from + +```ts +Removable.updateGcTime +``` diff --git a/docs/framework/vue/reference/classes/MutationCache.md b/docs/framework/vue/reference/classes/MutationCache.md index 9febd420a78..e7ad90f7368 100644 --- a/docs/framework/vue/reference/classes/MutationCache.md +++ b/docs/framework/vue/reference/classes/MutationCache.md @@ -3,7 +3,7 @@ id: MutationCache title: MutationCache --- -Defined in: [vue-query/src/mutationCache.ts:15](https://github.com/TanStack/query/blob/main/packages/vue-query/src/mutationCache.ts#L15) +Defined in: [packages/vue-query/src/mutationCache.ts:15](https://github.com/TanStack/query/blob/main/packages/vue-query/src/mutationCache.ts#L15) Vue-aware subclass of `@tanstack/query-core`'s `MutationCache`. `find`/`findAll` also accept a MaybeRefDeep filters object, so `ref`s can be passed directly without unwrapping. Access it via @@ -18,16 +18,16 @@ MaybeRefDeep filters object, so `ref`s can be passed directly without unwrapping ### Constructor ```ts -new MutationCache(config?): MutationCache; +new MutationCache(config): MutationCache; ``` -Defined in: query-core/dist-ts/src/mutationCache.d.ts:47 +Defined in: [packages/query-core/src/mutationCache.ts:129](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationCache.ts#L129) #### Parameters -##### config? +##### config -`MutationCacheConfig` +[`MutationCacheConfig`](../interfaces/MutationCacheConfig.md) = `{}` #### Returns @@ -39,8 +39,70 @@ Defined in: query-core/dist-ts/src/mutationCache.d.ts:47 MC.constructor ``` +## Properties + +### config + +```ts +config: MutationCacheConfig = {}; +``` + +Defined in: [packages/query-core/src/mutationCache.ts:129](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationCache.ts#L129) + +#### Inherited from + +```ts +MC.config +``` + +*** + +### listeners + +```ts +protected listeners: Set; +``` + +Defined in: [packages/query-core/src/subscribable.ts:2](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L2) + +#### Inherited from + +```ts +MC.listeners +``` + ## Methods +### clear() + +```ts +clear(): void; +``` + +Defined in: [packages/query-core/src/mutationCache.ts:236](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationCache.ts#L236) + +Removes all mutations from the cache. + +#### Returns + +`void` + +#### Example + +```ts +const mutationCache = queryClient.getMutationCache() + +mutationCache.clear() +``` + +#### Inherited from + +```ts +MC.clear +``` + +*** + ### find() ```ts @@ -49,7 +111,13 @@ find(filters): | undefined; ``` -Defined in: [vue-query/src/mutationCache.ts:16](https://github.com/TanStack/query/blob/main/packages/vue-query/src/mutationCache.ts#L16) +Defined in: [packages/vue-query/src/mutationCache.ts:16](https://github.com/TanStack/query/blob/main/packages/vue-query/src/mutationCache.ts#L16) + +A slightly more advanced method that can be used to get an existing mutation instance from +the cache. If the mutation does not exist, `undefined` is returned. + +This is not typically needed for most applications, but can come in handy when needing more +information about a mutation in rare scenarios. #### Type Parameters @@ -77,9 +145,21 @@ Defined in: [vue-query/src/mutationCache.ts:16](https://github.com/TanStack/quer #### Returns - \| `Mutation`\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\> + \| [`Mutation`](Mutation.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\> \| `undefined` +#### See + +[MutationCache#findAll](#findall) + +#### Example + +```ts +const mutationCache = queryClient.getMutationCache() + +const mutation = mutationCache.find({ mutationKey: ['addPost'] }) +``` + #### Overrides ```ts @@ -94,7 +174,13 @@ MC.find findAll(filters): Mutation[]; ``` -Defined in: [vue-query/src/mutationCache.ts:27](https://github.com/TanStack/query/blob/main/packages/vue-query/src/mutationCache.ts#L27) +Defined in: [packages/vue-query/src/mutationCache.ts:27](https://github.com/TanStack/query/blob/main/packages/vue-query/src/mutationCache.ts#L27) + +An even more advanced method that can be used to get existing mutation instances from the +cache that match the given filters. If no mutations match, an empty array is returned. + +This is not typically needed for most applications, but can come in handy when needing more +information about mutations in rare scenarios. #### Parameters @@ -104,10 +190,147 @@ Defined in: [vue-query/src/mutationCache.ts:27](https://github.com/TanStack/quer #### Returns -`Mutation`\<`unknown`, `Error`, `unknown`, `unknown`\>[] +[`Mutation`](Mutation.md)\<`unknown`, `Error`, `unknown`, `unknown`\>[] + +#### See + +[MutationCache#find](#find) + +#### Example + +```ts +const mutationCache = queryClient.getMutationCache() + +const mutations = mutationCache.findAll({ mutationKey: ['addPost'] }) +``` #### Overrides ```ts MC.findAll ``` + +*** + +### getAll() + +```ts +getAll(): Mutation[]; +``` + +Defined in: [packages/query-core/src/mutationCache.ts:259](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationCache.ts#L259) + +Returns all mutations within the cache. + +This is not typically needed for most applications, but can come in handy when needing more +information about a mutation in rare scenarios. + +#### Returns + +[`Mutation`](Mutation.md)\<`unknown`, `Error`, `unknown`, `unknown`\>[] + +#### Example + +```ts +const mutationCache = queryClient.getMutationCache() + +const mutations = mutationCache.getAll() +``` + +#### Inherited from + +```ts +MC.getAll +``` + +*** + +### hasListeners() + +```ts +hasListeners(): boolean; +``` + +Defined in: [packages/query-core/src/subscribable.ts:19](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L19) + +#### Returns + +`boolean` + +#### Inherited from + +```ts +MC.hasListeners +``` + +*** + +### onSubscribe() + +```ts +protected onSubscribe(): void; +``` + +Defined in: [packages/query-core/src/subscribable.ts:23](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L23) + +#### Returns + +`void` + +#### Inherited from + +```ts +MC.onSubscribe +``` + +*** + +### onUnsubscribe() + +```ts +protected onUnsubscribe(): void; +``` + +Defined in: [packages/query-core/src/subscribable.ts:27](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L27) + +#### Returns + +`void` + +#### Inherited from + +```ts +MC.onUnsubscribe +``` + +*** + +### subscribe() + +```ts +subscribe(listener): () => void; +``` + +Defined in: [packages/query-core/src/subscribable.ts:8](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L8) + +#### Parameters + +##### listener + +`MutationCacheListener` + +#### Returns + +```ts +(): void; +``` + +##### Returns + +`void` + +#### Inherited from + +```ts +MC.subscribe +``` diff --git a/docs/framework/vue/reference/classes/MutationObserver.md b/docs/framework/vue/reference/classes/MutationObserver.md new file mode 100644 index 00000000000..b6c88ef3463 --- /dev/null +++ b/docs/framework/vue/reference/classes/MutationObserver.md @@ -0,0 +1,335 @@ +--- +id: MutationObserver +title: MutationObserver +--- + +Defined in: [packages/query-core/src/mutationObserver.ts:38](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationObserver.ts#L38) + +Observes a single mutation and derives a `MutationObserverResult` from it. +A framework hook like `useMutation` creates one `MutationObserver` per hook +call, keeps it stable across re-renders, calls `setOptions` when the options +passed to the hook change, subscribes to it to re-render on updates, and +reads `getCurrentResult()` for the value to return. Calling `mutate()` +builds a new underlying `Mutation` in the `MutationCache` and executes it. + +## Example + +```ts +const observer = new MutationObserver(queryClient, { + mutationFn: (variables: { title: string }) => addPost(variables), +}) +``` + +## Extends + +- `Subscribable`\<`MutationObserverListener`\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\>\> + +## Type Parameters + +### TData + +`TData` = `unknown` + +### TError + +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) + +### TVariables + +`TVariables` = `void` + +### TOnMutateResult + +`TOnMutateResult` = `unknown` + +## Constructors + +### Constructor + +```ts +new MutationObserver(client, options): MutationObserver; +``` + +Defined in: [packages/query-core/src/mutationObserver.ts:58](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationObserver.ts#L58) + +#### Parameters + +##### client + +`QueryClient` + +##### options + +[`MutationObserverOptions`](../interfaces/MutationObserverOptions.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\> + +#### Returns + +`MutationObserver`\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\> + +#### Overrides + +```ts +Subscribable< + MutationObserverListener +>.constructor +``` + +## Properties + +### listeners + +```ts +protected listeners: Set>; +``` + +Defined in: [packages/query-core/src/subscribable.ts:2](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L2) + +#### Inherited from + +```ts +Subscribable.listeners +``` + +*** + +### options + +```ts +options: MutationObserverOptions; +``` + +Defined in: [packages/query-core/src/mutationObserver.ts:46](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationObserver.ts#L46) + +## Methods + +### bindMethods() + +```ts +protected bindMethods(): void; +``` + +Defined in: [packages/query-core/src/mutationObserver.ts:75](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationObserver.ts#L75) + +#### Returns + +`void` + +*** + +### getCurrentResult() + +```ts +getCurrentResult(): MutationObserverResult; +``` + +Defined in: [packages/query-core/src/mutationObserver.ts:155](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationObserver.ts#L155) + +Returns the observer's current result, derived from the observed +mutation's state (or the default, `idle` state if no mutation has been +built yet, e.g. before the first `mutate()` call or after `reset()`). + +#### Returns + +[`MutationObserverResult`](../type-aliases/MutationObserverResult.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\> + +*** + +### hasListeners() + +```ts +hasListeners(): boolean; +``` + +Defined in: [packages/query-core/src/subscribable.ts:19](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L19) + +#### Returns + +`boolean` + +#### Inherited from + +```ts +Subscribable.hasListeners +``` + +*** + +### mutate() + +```ts +mutate(variables, options?): Promise; +``` + +Defined in: [packages/query-core/src/mutationObserver.ts:207](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationObserver.ts#L207) + +Builds a new `Mutation` in the `MutationCache` using the observer's +current options, detaches this observer from any previously observed +mutation, attaches it to the new one, and executes it with the given +variables. + +The optional per-call `options` (`onSuccess`/`onError`/`onSettled`) are +invoked once the mutation settles, in addition to any callbacks defined +on the observer's own options. + +#### Parameters + +##### variables + +`TVariables` + +##### options? + +[`MutateOptions`](../interfaces/MutateOptions.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\> + +#### Returns + +`Promise`\<`TData`\> + +#### Example + +```ts +await observer.mutate( + { title: 'New post' }, + { onSuccess: (data) => console.log(data) }, +) +``` + +*** + +### onSubscribe() + +```ts +protected onSubscribe(): void; +``` + +Defined in: [packages/query-core/src/mutationObserver.ts:127](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationObserver.ts#L127) + +#### Returns + +`void` + +#### Overrides + +```ts +Subscribable.onSubscribe +``` + +*** + +### onUnsubscribe() + +```ts +protected onUnsubscribe(): void; +``` + +Defined in: [packages/query-core/src/mutationObserver.ts:135](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationObserver.ts#L135) + +#### Returns + +`void` + +#### Overrides + +```ts +Subscribable.onUnsubscribe +``` + +*** + +### reset() + +```ts +reset(): void; +``` + +Defined in: [packages/query-core/src/mutationObserver.ts:180](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationObserver.ts#L180) + +Detaches the observer from the mutation it is currently observing (if +any) and resets the observed result back to its default, `idle` state. + +This does not cancel an in-flight mutation; the mutation itself keeps +running to completion and its own callbacks still fire, but this +observer stops reflecting its state and a subsequent `mutate()` call +will build a brand new mutation. + +#### Returns + +`void` + +#### Example + +```ts +observer.reset() +``` + +#### See + +[MutationObserver#mutate](#mutate) + +*** + +### setOptions() + +```ts +setOptions(options): void; +``` + +Defined in: [packages/query-core/src/mutationObserver.ts:96](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationObserver.ts#L96) + +Updates the observer's options. + +If the new `mutationKey` differs from the previous one (and both were +defined), the observer is reset, detaching it from the mutation it was +observing. Otherwise, if the currently observed mutation is still +`pending`, its options are updated in place as well. + +#### Parameters + +##### options + +[`MutationObserverOptions`](../interfaces/MutationObserverOptions.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\> + +#### Returns + +`void` + +#### Example + +```ts +observer.setOptions({ + mutationFn: (variables: { title: string }) => addPost(variables), + onSuccess: (data) => console.log(data), +}) +``` + +*** + +### subscribe() + +```ts +subscribe(listener): () => void; +``` + +Defined in: [packages/query-core/src/subscribable.ts:8](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L8) + +#### Parameters + +##### listener + +`MutationObserverListener` + +#### Returns + +```ts +(): void; +``` + +##### Returns + +`void` + +#### Inherited from + +```ts +Subscribable.subscribe +``` diff --git a/docs/framework/vue/reference/classes/QueriesObserver.md b/docs/framework/vue/reference/classes/QueriesObserver.md new file mode 100644 index 00000000000..cfc6a776f6b --- /dev/null +++ b/docs/framework/vue/reference/classes/QueriesObserver.md @@ -0,0 +1,325 @@ +--- +id: QueriesObserver +title: QueriesObserver +--- + +Defined in: [packages/query-core/src/queriesObserver.ts:56](https://github.com/TanStack/query/blob/main/packages/query-core/src/queriesObserver.ts#L56) + +A `QueriesObserver` watches an array of queries at once, exposing them as +a single array of `QueryObserverResult`s (or, when a `combine` option is +given, as a combined value derived from that array). It manages one +internal `QueryObserver` per query, and is the primitive that framework +adapters (e.g. `useQueries`) build their hooks on top of. + +## Example + +```ts +const observer = new QueriesObserver(queryClient, [ + { queryKey: ['post', 1], queryFn: fetchPost }, + { queryKey: ['post', 2], queryFn: fetchPost }, +]) + +const unsubscribe = observer.subscribe((result) => { + console.log(result) +}) +``` + +## Extends + +- `Subscribable`\<`QueriesObserverListener`\> + +## Type Parameters + +### TCombinedResult + +`TCombinedResult` = [`QueryObserverResult`](../type-aliases/QueryObserverResult.md)[] + +## Constructors + +### Constructor + +```ts +new QueriesObserver( + client, + queries, +options?): QueriesObserver; +``` + +Defined in: [packages/query-core/src/queriesObserver.ts:70](https://github.com/TanStack/query/blob/main/packages/query-core/src/queriesObserver.ts#L70) + +#### Parameters + +##### client + +`QueryClient` + +##### queries + +[`QueryObserverOptions`](../interfaces/QueryObserverOptions.md)\<`any`, `any`, `any`, `any`, `any`, `never`\>[] + +##### options? + +[`QueriesObserverOptions`](../interfaces/QueriesObserverOptions.md)\<`TCombinedResult`\> + +#### Returns + +`QueriesObserver`\<`TCombinedResult`\> + +#### Overrides + +```ts +Subscribable.constructor +``` + +## Properties + +### listeners + +```ts +protected listeners: Set; +``` + +Defined in: [packages/query-core/src/subscribable.ts:2](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L2) + +#### Inherited from + +```ts +Subscribable.listeners +``` + +## Methods + +### destroy() + +```ts +destroy(): void; +``` + +Defined in: [packages/query-core/src/queriesObserver.ts:106](https://github.com/TanStack/query/blob/main/packages/query-core/src/queriesObserver.ts#L106) + +Stops observing all queries: clears all listeners and destroys every +underlying `QueryObserver` this observer manages. + +#### Returns + +`void` + +*** + +### getCurrentResult() + +```ts +getCurrentResult(): QueryObserverResult[]; +``` + +Defined in: [packages/query-core/src/queriesObserver.ts:210](https://github.com/TanStack/query/blob/main/packages/query-core/src/queriesObserver.ts#L210) + +Returns the most recently computed array of `QueryObserverResult`s, one +per observed query, in the same order as the queries passed to the +constructor or `setQueries`. + +#### Returns + +[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)[] + +#### Example + +```ts +const results = observer.getCurrentResult() +const data = results.map((result) => result.data) +``` + +*** + +### getObservers() + +```ts +getObservers(): QueryObserver[]; +``` + +Defined in: [packages/query-core/src/queriesObserver.ts:227](https://github.com/TanStack/query/blob/main/packages/query-core/src/queriesObserver.ts#L227) + +Returns the underlying `QueryObserver` instances this observer manages, +in the same order as the queries passed to the constructor or +`setQueries`. + +#### Returns + +[`QueryObserver`](QueryObserver.md)\<`unknown`, `Error`, `unknown`, `unknown`, readonly `unknown`[]\>[] + +*** + +### getOptimisticResult() + +```ts +getOptimisticResult(queries, combine): [QueryObserverResult[], (r?) => TCombinedResult, () => QueryObserverResult[]]; +``` + +Defined in: [packages/query-core/src/queriesObserver.ts:238](https://github.com/TanStack/query/blob/main/packages/query-core/src/queriesObserver.ts#L238) + +The `QueriesObserver` counterpart of [QueryObserver#getOptimisticResult](QueryObserver.md#getoptimisticresult) — computes +the result for the given (already-defaulted) queries right now, synchronously. Called by +framework adapters (e.g. `useQueries`) ahead of subscribing, returning a tuple of the raw +per-query results, a function to compute the combined result from them, and a function to +wrap the results for property-access tracking. + +#### Parameters + +##### queries + +[`QueryObserverOptions`](../interfaces/QueryObserverOptions.md)\<`unknown`, `Error`, `unknown`, `unknown`, readonly `unknown`[], `never`\>[] + +##### combine + +`CombineFn`\<`TCombinedResult`\> | `undefined` + +#### Returns + +\[[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)[], (`r?`) => `TCombinedResult`, () => [`QueryObserverResult`](../type-aliases/QueryObserverResult.md)[]\] + +*** + +### getQueries() + +```ts +getQueries(): Query[]; +``` + +Defined in: [packages/query-core/src/queriesObserver.ts:218](https://github.com/TanStack/query/blob/main/packages/query-core/src/queriesObserver.ts#L218) + +Returns the underlying `Query` instances currently being observed, in +the same order as the queries passed to the constructor or `setQueries`. + +#### Returns + +[`Query`](Query.md)\<`unknown`, `Error`, `unknown`, readonly `unknown`[]\>[] + +*** + +### hasListeners() + +```ts +hasListeners(): boolean; +``` + +Defined in: [packages/query-core/src/subscribable.ts:19](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L19) + +#### Returns + +`boolean` + +#### Inherited from + +```ts +Subscribable.hasListeners +``` + +*** + +### onSubscribe() + +```ts +protected onSubscribe(): void; +``` + +Defined in: [packages/query-core/src/queriesObserver.ts:86](https://github.com/TanStack/query/blob/main/packages/query-core/src/queriesObserver.ts#L86) + +#### Returns + +`void` + +#### Overrides + +```ts +Subscribable.onSubscribe +``` + +*** + +### onUnsubscribe() + +```ts +protected onUnsubscribe(): void; +``` + +Defined in: [packages/query-core/src/queriesObserver.ts:96](https://github.com/TanStack/query/blob/main/packages/query-core/src/queriesObserver.ts#L96) + +#### Returns + +`void` + +#### Overrides + +```ts +Subscribable.onUnsubscribe +``` + +*** + +### setQueries() + +```ts +setQueries(queries, options?): void; +``` + +Defined in: [packages/query-core/src/queriesObserver.ts:127](https://github.com/TanStack/query/blob/main/packages/query-core/src/queriesObserver.ts#L127) + +Replaces the set of queries being observed. Existing `QueryObserver`s +are reused for queries that match an already-observed query hash; +observers for queries that are no longer present are destroyed, and new +observers are created and subscribed to for newly added queries. + +#### Parameters + +##### queries + +[`QueryObserverOptions`](../interfaces/QueryObserverOptions.md)\<`unknown`, `Error`, `unknown`, `unknown`, readonly `unknown`[], `never`\>[] + +##### options? + +[`QueriesObserverOptions`](../interfaces/QueriesObserverOptions.md)\<`TCombinedResult`\> + +#### Returns + +`void` + +#### Example + +```ts +observer.setQueries([ + { queryKey: ['post', 1], queryFn: fetchPost }, + { queryKey: ['post', 3], queryFn: fetchPost }, +]) +``` + +*** + +### subscribe() + +```ts +subscribe(listener): () => void; +``` + +Defined in: [packages/query-core/src/subscribable.ts:8](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L8) + +#### Parameters + +##### listener + +`QueriesObserverListener` + +#### Returns + +```ts +(): void; +``` + +##### Returns + +`void` + +#### Inherited from + +```ts +Subscribable.subscribe +``` diff --git a/docs/framework/vue/reference/classes/Query.md b/docs/framework/vue/reference/classes/Query.md new file mode 100644 index 00000000000..273d24bdbe8 --- /dev/null +++ b/docs/framework/vue/reference/classes/Query.md @@ -0,0 +1,585 @@ +--- +id: Query +title: Query +--- + +Defined in: [packages/query-core/src/query.ts:225](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L225) + +Represents a single cached query. A `Query` holds the query's key, options, +state (data/error/status), and the observers currently subscribed to it. + +Instances are created and managed internally by `QueryCache`; application +code typically interacts with queries indirectly through `QueryClient` or +a framework hook like `useQuery`. Direct access to a `Query` instance is +possible via `queryCache.find()`/`findAll()` for inspecting cache state. + +## Example + +```ts +const queryCache = queryClient.getQueryCache() +const query = queryCache.find({ queryKey: ['posts'] }) + +if (query) { + console.log(query.state.dataUpdatedAt) +} +``` + +## Extends + +- `Removable` + +## Type Parameters + +### TQueryFnData + +`TQueryFnData` = `unknown` + +### TError + +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) + +### TData + +`TData` = `TQueryFnData` + +### TQueryKey + +`TQueryKey` *extends* [`QueryKey`](../type-aliases/QueryKey.md) = [`QueryKey`](../type-aliases/QueryKey.md) + +## Constructors + +### Constructor + +```ts +new Query(config): Query; +``` + +Defined in: [packages/query-core/src/query.ts:246](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L246) + +#### Parameters + +##### config + +`QueryConfig`\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`\> + +#### Returns + +`Query`\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`\> + +#### Overrides + +```ts +Removable.constructor +``` + +## Properties + +### gcTime + +```ts +gcTime: number; +``` + +Defined in: [packages/query-core/src/removable.ts:7](https://github.com/TanStack/query/blob/main/packages/query-core/src/removable.ts#L7) + +#### Inherited from + +```ts +Removable.gcTime +``` + +*** + +### observers + +```ts +observers: QueryObserver[]; +``` + +Defined in: [packages/query-core/src/query.ts:242](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L242) + +*** + +### options + +```ts +options: QueryOptions; +``` + +Defined in: [packages/query-core/src/query.ts:233](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L233) + +*** + +### queryHash + +```ts +queryHash: string; +``` + +Defined in: [packages/query-core/src/query.ts:232](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L232) + +*** + +### queryKey + +```ts +queryKey: TQueryKey; +``` + +Defined in: [packages/query-core/src/query.ts:231](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L231) + +*** + +### state + +```ts +state: QueryState; +``` + +Defined in: [packages/query-core/src/query.ts:234](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L234) + +## Accessors + +### meta + +#### Get Signature + +```ts +get meta(): Record | undefined; +``` + +Defined in: [packages/query-core/src/query.ts:264](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L264) + +The `meta` object passed in the query's options, if any. + +##### Returns + +`Record`\<`string`, `unknown`\> \| `undefined` + +*** + +### promise + +#### Get Signature + +```ts +get promise(): Promise | undefined; +``` + +Defined in: [packages/query-core/src/query.ts:277](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L277) + +The promise for the currently in-flight fetch, if the query is fetching. +`undefined` when the query is not fetching. + +##### Returns + +`Promise`\<`TData`\> \| `undefined` + +## Methods + +### cancel() + +```ts +cancel(options?): Promise; +``` + +Defined in: [packages/query-core/src/query.ts:348](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L348) + +Cancels the query's currently in-flight fetch, if any. +- Returns a promise that resolves once the cancellation has settled. +- If no fetch is in progress, resolves immediately. + +#### Parameters + +##### options? + +[`CancelOptions`](../interfaces/CancelOptions.md) + +#### Returns + +`Promise`\<`void`\> + +#### Example + +```ts +await query.cancel() +``` + +*** + +### clearGcTimeout() + +```ts +protected clearGcTimeout(): void; +``` + +Defined in: [packages/query-core/src/removable.ts:32](https://github.com/TanStack/query/blob/main/packages/query-core/src/removable.ts#L32) + +#### Returns + +`void` + +#### Inherited from + +```ts +Removable.clearGcTimeout +``` + +*** + +### destroy() + +```ts +destroy(): void; +``` + +Defined in: [packages/query-core/src/query.ts:361](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L361) + +Clears the query's garbage collection timeout and silently cancels any +in-flight fetch. Called by `QueryCache` when the query is removed from +the cache. + +#### Returns + +`void` + +#### See + +[Query#cancel](#cancel) + +#### Overrides + +```ts +Removable.destroy +``` + +*** + +### fetch() + +```ts +fetch(options?, fetchOptions?): Promise; +``` + +Defined in: [packages/query-core/src/query.ts:590](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L590) + +Fetches the query, i.e. runs its `queryFn` (through any configured +retryer/behavior) and updates the query's state with the result. +- If a fetch is already in flight, returns its promise instead of + starting a new one, unless `fetchOptions.cancelRefetch` is set and the + query already has data, in which case the current fetch is silently + cancelled first. +- If `options` is passed, it replaces the query's current options + before fetching. + +#### Parameters + +##### options? + +`QueryOptions`\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`, `never`\> + +##### fetchOptions? + +`FetchOptions`\<`TQueryFnData`\> + +#### Returns + +`Promise`\<`TData`\> + +*** + +### getObserversCount() + +```ts +getObserversCount(): number; +``` + +Defined in: [packages/query-core/src/query.ts:560](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L560) + +Returns the number of observers currently subscribed to this query. + +#### Returns + +`number` + +#### Example + +```ts +if (query.getObserversCount() === 0) { + // no component is currently watching this query +} +``` + +*** + +### invalidate() + +```ts +invalidate(): void; +``` + +Defined in: [packages/query-core/src/query.ts:574](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L574) + +Marks the query as invalidated, unless it is already invalidated. This +updates `state.isInvalidated` and notifies observers, but does not by +itself trigger a refetch. + +#### Returns + +`void` + +#### Example + +```ts +query.invalidate() +``` + +*** + +### isActive() + +```ts +isActive(): boolean; +``` + +Defined in: [packages/query-core/src/query.ts:386](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L386) + +Returns `true` if the query has at least one observer for which `enabled` +does not resolve to `false`. + +#### Returns + +`boolean` + +*** + +### isDisabled() + +```ts +isDisabled(): boolean; +``` + +Defined in: [packages/query-core/src/query.ts:400](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L400) + +Returns `true` if the query is disabled, meaning it will not fetch +automatically. +- If the query has observers, it is disabled when none of them are active + (see `isActive`). +- If the query has no observers, it is disabled when its `queryFn` is + `skipToken` or it has never been fetched. + +#### Returns + +`boolean` + +*** + +### isFetched() + +```ts +isFetched(): boolean; +``` + +Defined in: [packages/query-core/src/query.ts:412](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L412) + +Returns `true` if the query has been fetched, i.e. it has resolved with +either data or an error at least once. + +#### Returns + +`boolean` + +*** + +### isStale() + +```ts +isStale(): boolean; +``` + +Defined in: [packages/query-core/src/query.ts:447](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L447) + +Returns `true` if the query is stale. +- If the query has observers, defers to whether any observer's current + result reports `isStale` (which accounts for each observer's own + `staleTime` and `enabled` state). +- If the query has no observers, it is considered stale when it has no + data or has been invalidated. + +#### Returns + +`boolean` + +#### See + +[Query#isStaleByTime](#isstalebytime) + +#### Example + +```ts +if (query.isStale()) { + // refetch or otherwise treat the cached data as outdated +} +``` + +*** + +### isStaleByTime() + +```ts +isStaleByTime(staleTime): boolean; +``` + +Defined in: [packages/query-core/src/query.ts:473](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L473) + +Returns `true` if the query's data is stale relative to the given +`staleTime` (defaults to `0`). +- A query with no data is always stale. +- `staleTime: 'static'` is never stale. +- An invalidated query is always stale. +- Otherwise, staleness is based on elapsed time since `dataUpdatedAt`. + +#### Parameters + +##### staleTime + +[`StaleTime`](../type-aliases/StaleTime.md) = `0` + +#### Returns + +`boolean` + +#### See + +[Query#isStale](#isstale) + +#### Example + +```ts +const isStale = query.isStaleByTime(1000 * 60) +``` + +*** + +### isStatic() + +```ts +isStatic(): boolean; +``` + +Defined in: [packages/query-core/src/query.ts:420](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L420) + +Returns `true` if the query has at least one observer configured with +`staleTime: 'static'`, meaning it is treated as never stale. + +#### Returns + +`boolean` + +*** + +### optionalRemove() + +```ts +protected optionalRemove(): void; +``` + +Defined in: [packages/query-core/src/query.ts:305](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L305) + +#### Returns + +`void` + +#### Overrides + +```ts +Removable.optionalRemove +``` + +*** + +### reset() + +```ts +reset(): void; +``` + +Defined in: [packages/query-core/src/query.ts:377](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L377) + +Resets the query back to its initial state (the state it had when it was +first created, e.g. any `initialData`), destroying it first to cancel any +in-flight fetch. + +#### Returns + +`void` + +*** + +### scheduleGc() + +```ts +protected scheduleGc(): void; +``` + +Defined in: [packages/query-core/src/removable.ts:14](https://github.com/TanStack/query/blob/main/packages/query-core/src/removable.ts#L14) + +#### Returns + +`void` + +#### Inherited from + +```ts +Removable.scheduleGc +``` + +*** + +### setState() + +```ts +setState(state): void; +``` + +Defined in: [packages/query-core/src/query.ts:334](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L334) + +Merges the given partial state directly into this query's state, notifying observers. Used +by persistence and broadcast plugins to restore a state snapshot, and by devtools to let a +user manually trigger a loading/error state or edit the cached data. + +#### Parameters + +##### state + +`Partial`\<[`QueryState`](../interfaces/QueryState.md)\<`TData`, `TError`\>\> + +#### Returns + +`void` + +*** + +### updateGcTime() + +```ts +protected updateGcTime(newGcTime): void; +``` + +Defined in: [packages/query-core/src/removable.ts:24](https://github.com/TanStack/query/blob/main/packages/query-core/src/removable.ts#L24) + +#### Parameters + +##### newGcTime + +`number` | `undefined` + +#### Returns + +`void` + +#### Inherited from + +```ts +Removable.updateGcTime +``` diff --git a/docs/framework/vue/reference/classes/QueryCache.md b/docs/framework/vue/reference/classes/QueryCache.md index 957135213ac..f67625fe8af 100644 --- a/docs/framework/vue/reference/classes/QueryCache.md +++ b/docs/framework/vue/reference/classes/QueryCache.md @@ -3,7 +3,7 @@ id: QueryCache title: QueryCache --- -Defined in: [vue-query/src/queryCache.ts:16](https://github.com/TanStack/query/blob/main/packages/vue-query/src/queryCache.ts#L16) +Defined in: [packages/vue-query/src/queryCache.ts:16](https://github.com/TanStack/query/blob/main/packages/vue-query/src/queryCache.ts#L16) Vue-aware subclass of `@tanstack/query-core`'s `QueryCache`. `find`/`findAll` also accept a MaybeRefDeep filters object, so `ref`s can be passed directly without unwrapping. Access it via @@ -18,16 +18,16 @@ MaybeRefDeep filters object, so `ref`s can be passed directly without unwrapping ### Constructor ```ts -new QueryCache(config?): QueryCache; +new QueryCache(config): QueryCache; ``` -Defined in: query-core/dist-ts/src/queryCache.d.ts:57 +Defined in: [packages/query-core/src/queryCache.ts:126](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryCache.ts#L126) #### Parameters -##### config? +##### config -`QueryCacheConfig` +[`QueryCacheConfig`](../interfaces/QueryCacheConfig.md) = `{}` #### Returns @@ -39,8 +39,141 @@ Defined in: query-core/dist-ts/src/queryCache.d.ts:57 QC.constructor ``` +## Properties + +### config + +```ts +config: QueryCacheConfig = {}; +``` + +Defined in: [packages/query-core/src/queryCache.ts:126](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryCache.ts#L126) + +#### Inherited from + +```ts +QC.config +``` + +*** + +### listeners + +```ts +protected listeners: Set; +``` + +Defined in: [packages/query-core/src/subscribable.ts:2](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L2) + +#### Inherited from + +```ts +QC.listeners +``` + ## Methods +### build() + +```ts +build( + client, + options, +state?): Query; +``` + +Defined in: [packages/query-core/src/queryCache.ts:147](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryCache.ts#L147) + +Returns the existing `Query` instance for the given options' `queryKey`/`queryHash`, or +builds and adds a new one to the cache if none exists yet. Used by framework adapters and +plugins (e.g. broadcast/persistence) that need to get-or-create a `Query` directly, bypassing +the reactive `QueryObserver` machinery. + +#### Type Parameters + +##### TQueryFnData + +`TQueryFnData` = `unknown` + +##### TError + +`TError` = `Error` + +##### TData + +`TData` = `TQueryFnData` + +##### TQueryKey + +`TQueryKey` *extends* readonly `unknown`[] = readonly `unknown`[] + +#### Parameters + +##### client + +`QueryClient` + +##### options + +[`WithRequired`](../type-aliases/WithRequired.md)\<`QueryOptions`\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`, `never`\>, `"queryKey"`\> + +##### state? + +[`QueryState`](../interfaces/QueryState.md)\<`TData`, `TError`\> + +#### Returns + +[`Query`](Query.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`\> + +#### Example + +```ts +const queryCache = queryClient.getQueryCache() + +const query = queryCache.build(queryClient, { + queryKey: ['posts'], + queryFn: fetchPosts, +}) +``` + +#### Inherited from + +```ts +QC.build +``` + +*** + +### clear() + +```ts +clear(): void; +``` + +Defined in: [packages/query-core/src/queryCache.ts:232](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryCache.ts#L232) + +Removes all queries from the cache. + +#### Returns + +`void` + +#### Example + +```ts +const queryCache = queryClient.getQueryCache() + +queryCache.clear() +``` + +#### Inherited from + +```ts +QC.clear +``` + +*** + ### find() ```ts @@ -49,7 +182,16 @@ find(filters): | undefined; ``` -Defined in: [vue-query/src/queryCache.ts:17](https://github.com/TanStack/query/blob/main/packages/vue-query/src/queryCache.ts#L17) +Defined in: [packages/vue-query/src/queryCache.ts:17](https://github.com/TanStack/query/blob/main/packages/vue-query/src/queryCache.ts#L17) + +A slightly more advanced method that can be used to get an existing query instance from the +cache. This instance not only contains all the state for the query, but all of the instances, +and underlying guts of the query as well. If the query does not exist, `undefined` is +returned. + +This is not typically needed for most applications, but can come in handy when needing more +information about a query in rare scenarios (e.g. looking at `query.state.dataUpdatedAt` to +decide whether a query is fresh enough to be used as an initial value). #### Type Parameters @@ -69,13 +211,25 @@ Defined in: [vue-query/src/queryCache.ts:17](https://github.com/TanStack/query/b ##### filters -`MaybeRefDeep`\<`WithRequired`\<`QueryFilters`\, `"queryKey"`\>\> +`MaybeRefDeep`\<[`WithRequired`](../type-aliases/WithRequired.md)\<`QueryFilters`\, `"queryKey"`\>\> #### Returns - \| `Query`\<`TQueryFnData`, `TError`, `TData`, readonly `unknown`[]\> + \| [`Query`](Query.md)\<`TQueryFnData`, `TError`, `TData`, readonly `unknown`[]\> \| `undefined` +#### See + +[QueryCache#findAll](#findall) + +#### Example + +```ts +const queryCache = queryClient.getQueryCache() + +const query = queryCache.find({ queryKey: ['posts'] }) +``` + #### Overrides ```ts @@ -90,7 +244,13 @@ QC.find findAll(filters): Query[]; ``` -Defined in: [vue-query/src/queryCache.ts:23](https://github.com/TanStack/query/blob/main/packages/vue-query/src/queryCache.ts#L23) +Defined in: [packages/vue-query/src/queryCache.ts:23](https://github.com/TanStack/query/blob/main/packages/vue-query/src/queryCache.ts#L23) + +An even more advanced method that can be used to get existing query instances from the cache +that partially match a query key. If no queries match, an empty array is returned. + +This is not typically needed for most applications, but can come in handy when needing more +information about queries in rare scenarios. #### Parameters @@ -100,10 +260,247 @@ Defined in: [vue-query/src/queryCache.ts:23](https://github.com/TanStack/query/b #### Returns -`Query`\<`unknown`, `Error`, `unknown`, readonly `unknown`[]\>[] +[`Query`](Query.md)\<`unknown`, `Error`, `unknown`, readonly `unknown`[]\>[] + +#### See + +[QueryCache#find](#find) + +#### Example + +```ts +const queryCache = queryClient.getQueryCache() + +const queries = queryCache.findAll({ queryKey: ['posts'] }) +``` #### Overrides ```ts QC.findAll ``` + +*** + +### get() + +```ts +get(queryHash): + | Query + | undefined; +``` + +Defined in: [packages/query-core/src/queryCache.ts:254](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryCache.ts#L254) + +Returns the `Query` instance stored under the given `queryHash`, or `undefined` if none +exists. Unlike [QueryCache#find](#find), this looks up by the already-computed hash rather +than by `QueryFilters`. Used by plugins (e.g. broadcast/hydration) that already have a hash +to look up directly. + +#### Type Parameters + +##### TQueryFnData + +`TQueryFnData` = `unknown` + +##### TError + +`TError` = `Error` + +##### TData + +`TData` = `TQueryFnData` + +##### TQueryKey + +`TQueryKey` *extends* readonly `unknown`[] = readonly `unknown`[] + +#### Parameters + +##### queryHash + +`string` + +#### Returns + + \| [`Query`](Query.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`\> + \| `undefined` + +#### Example + +```ts +const queryCache = queryClient.getQueryCache() +const queryHash = hashKey(['posts']) + +const query = queryCache.get(queryHash) +``` + +#### Inherited from + +```ts +QC.get +``` + +*** + +### getAll() + +```ts +getAll(): Query[]; +``` + +Defined in: [packages/query-core/src/queryCache.ts:277](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryCache.ts#L277) + +Returns all queries within the cache. + +#### Returns + +[`Query`](Query.md)\<`unknown`, `Error`, `unknown`, readonly `unknown`[]\>[] + +#### Example + +```ts +const queryCache = queryClient.getQueryCache() + +const queries = queryCache.getAll() +``` + +#### Inherited from + +```ts +QC.getAll +``` + +*** + +### hasListeners() + +```ts +hasListeners(): boolean; +``` + +Defined in: [packages/query-core/src/subscribable.ts:19](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L19) + +#### Returns + +`boolean` + +#### Inherited from + +```ts +QC.hasListeners +``` + +*** + +### onSubscribe() + +```ts +protected onSubscribe(): void; +``` + +Defined in: [packages/query-core/src/subscribable.ts:23](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L23) + +#### Returns + +`void` + +#### Inherited from + +```ts +QC.onSubscribe +``` + +*** + +### onUnsubscribe() + +```ts +protected onUnsubscribe(): void; +``` + +Defined in: [packages/query-core/src/subscribable.ts:27](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L27) + +#### Returns + +`void` + +#### Inherited from + +```ts +QC.onUnsubscribe +``` + +*** + +### remove() + +```ts +remove(query): void; +``` + +Defined in: [packages/query-core/src/queryCache.ts:208](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryCache.ts#L208) + +Destroys the given `Query` and removes it from the cache, notifying subscribers with a +`'removed'` event. A no-op if the query is no longer the one currently stored under its hash +(e.g. it was already replaced). Used by plugins (e.g. the broadcast client) that mirror +removals across `QueryCache` instances. + +#### Parameters + +##### query + +[`Query`](Query.md)\<`any`, `any`, `any`, `any`\> + +#### Returns + +`void` + +#### Example + +```ts +const queryCache = queryClient.getQueryCache() +const query = queryCache.find({ queryKey: ['posts'] }) + +if (query) { + queryCache.remove(query) +} +``` + +#### Inherited from + +```ts +QC.remove +``` + +*** + +### subscribe() + +```ts +subscribe(listener): () => void; +``` + +Defined in: [packages/query-core/src/subscribable.ts:8](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L8) + +#### Parameters + +##### listener + +`QueryCacheListener` + +#### Returns + +```ts +(): void; +``` + +##### Returns + +`void` + +#### Inherited from + +```ts +QC.subscribe +``` diff --git a/docs/framework/vue/reference/classes/QueryClient.md b/docs/framework/vue/reference/classes/QueryClient.md index 2fb44e83c1e..810249f0ef6 100644 --- a/docs/framework/vue/reference/classes/QueryClient.md +++ b/docs/framework/vue/reference/classes/QueryClient.md @@ -3,7 +3,7 @@ id: QueryClient title: QueryClient --- -Defined in: [vue-query/src/queryClient.ts:44](https://github.com/TanStack/query/blob/main/packages/vue-query/src/queryClient.ts#L44) +Defined in: [packages/vue-query/src/queryClient.ts:44](https://github.com/TanStack/query/blob/main/packages/vue-query/src/queryClient.ts#L44) Vue-aware subclass of `@tanstack/query-core`'s `QueryClient`. Methods that accept `options` (such as `CancelOptions` or `InvalidateOptions`) or filters (such as the `QueryFilters` accepted by @@ -23,7 +23,7 @@ Install one on your app with `VueQueryPlugin`, or retrieve it with `useQueryClie new QueryClient(config): QueryClient; ``` -Defined in: [vue-query/src/queryClient.ts:45](https://github.com/TanStack/query/blob/main/packages/vue-query/src/queryClient.ts#L45) +Defined in: [packages/vue-query/src/queryClient.ts:45](https://github.com/TanStack/query/blob/main/packages/vue-query/src/queryClient.ts#L45) #### Parameters @@ -49,7 +49,7 @@ QC.constructor optional isRestoring: Ref; ``` -Defined in: [vue-query/src/queryClient.ts:58](https://github.com/TanStack/query/blob/main/packages/vue-query/src/queryClient.ts#L58) +Defined in: [packages/vue-query/src/queryClient.ts:58](https://github.com/TanStack/query/blob/main/packages/vue-query/src/queryClient.ts#L58) `true` while a `clientPersister` passed to `VueQueryPlugin` is restoring the cache. Queries don't fetch while this is `true`. Defaults to `false` if no persister is configured. @@ -62,7 +62,14 @@ while this is `true`. Defaults to `false` if no persister is configured. cancelQueries(filters?, options?): Promise; ``` -Defined in: [vue-query/src/queryClient.ts:185](https://github.com/TanStack/query/blob/main/packages/vue-query/src/queryClient.ts#L185) +Defined in: [packages/vue-query/src/queryClient.ts:185](https://github.com/TanStack/query/blob/main/packages/vue-query/src/queryClient.ts#L185) + +Cancels outgoing fetches for queries matching the given filters. Most useful when performing +optimistic updates, since any outgoing refetch that resolves afterwards would otherwise +overwrite the optimistic update. By default (`revert: true`), a cancelled query's data is +reverted to its state before the outgoing fetch started. + +The returned promise never rejects, even if individual cancellations fail. #### Type Parameters @@ -78,12 +85,18 @@ Defined in: [vue-query/src/queryClient.ts:185](https://github.com/TanStack/query ##### options? -`MaybeRefDeep`\<`CancelOptions`\> +`MaybeRefDeep`\<[`CancelOptions`](../interfaces/CancelOptions.md)\> #### Returns `Promise`\<`void`\> +#### Example + +```ts +await queryClient.cancelQueries({ queryKey: ['posts'], exact: true }) +``` + #### Overrides ```ts @@ -92,6 +105,183 @@ QC.cancelQueries *** +### clear() + +```ts +clear(): void; +``` + +Defined in: [packages/query-core/src/queryClient.ts:1083](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L1083) + +Clears both the query cache and the mutation cache this client is connected to. + +#### Returns + +`void` + +#### Example + +```ts +import { QueryClient } from '@tanstack/query-core' + +const queryClient = new QueryClient() +queryClient.clear() +``` + +#### Inherited from + +```ts +QC.clear +``` + +*** + +### defaultMutationOptions() + +```ts +defaultMutationOptions(options?): T; +``` + +Defined in: [packages/query-core/src/queryClient.ts:1057](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L1057) + +The mutation counterpart of [QueryClient#defaultQueryOptions](#defaultqueryoptions). Called by framework +adapters (e.g. inside `useMutation`) to merge `queryClient.setMutationDefaults` for the +given `mutationKey`, then the client's `defaultOptions.mutations`, then the caller's options +on top. A no-op if the options are already defaulted (`_defaulted: true`). + +#### Type Parameters + +##### T + +`T` *extends* `MutationOptions`\<`any`, `any`, `any`, `any`\> + +#### Parameters + +##### options? + +`T` + +#### Returns + +`T` + +#### Inherited from + +```ts +QC.defaultMutationOptions +``` + +*** + +### defaultQueryOptions() + +```ts +defaultQueryOptions(options): DefaultedQueryObserverOptions; +``` + +Defined in: [packages/query-core/src/queryClient.ts:970](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L970) + +Called by framework adapters (e.g. inside `useQuery`) to resolve the options passed by the +caller into their final, defaulted form: merging `queryClient.setQueryDefaults` for the +given `queryKey`, then the client's own `defaultOptions.queries`, then the caller's options +on top. A no-op if the options are already defaulted (`_defaulted: true`). + +#### Type Parameters + +##### TQueryFnData + +`TQueryFnData` = `unknown` + +##### TError + +`TError` = `Error` + +##### TData + +`TData` = `TQueryFnData` + +##### TQueryData + +`TQueryData` = `TQueryFnData` + +##### TQueryKey + +`TQueryKey` *extends* readonly `unknown`[] = readonly `unknown`[] + +##### TPageParam + +`TPageParam` = `never` + +#### Parameters + +##### options + +[`QueryObserverOptions`](../interfaces/QueryObserverOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryData`, `TQueryKey`, `TPageParam`\> | [`DefaultedQueryObserverOptions`](../type-aliases/DefaultedQueryObserverOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryData`, `TQueryKey`\> + +#### Returns + +[`DefaultedQueryObserverOptions`](../type-aliases/DefaultedQueryObserverOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryData`, `TQueryKey`\> + +#### Inherited from + +```ts +QC.defaultQueryOptions +``` + +*** + +### ~~ensureInfiniteQueryData()~~ + +```ts +ensureInfiniteQueryData(options): Promise>; +``` + +Defined in: [packages/query-core/src/queryClient.ts:735](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L735) + +#### Type Parameters + +##### TQueryFnData + +`TQueryFnData` + +##### TError + +`TError` = `Error` + +##### TData + +`TData` = `TQueryFnData` + +##### TQueryKey + +`TQueryKey` *extends* readonly `unknown`[] = readonly `unknown`[] + +##### TPageParam + +`TPageParam` = `unknown` + +#### Parameters + +##### options + +[`EnsureInfiniteQueryDataOptions`](../type-aliases/EnsureInfiniteQueryDataOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`, `TPageParam`\> + +#### Returns + +`Promise`\<[`InfiniteData`](../interfaces/InfiniteData.md)\<`TData`, `TPageParam`\>\> + +#### Deprecated + +Use queryClient.infiniteQuery({ ...options, staleTime: 'static' }) instead. This method will be removed in the next major version. + +#### Inherited from + +```ts +QC.ensureInfiniteQueryData +``` + +*** + ### ~~ensureQueryData()~~ #### Call Signature @@ -100,7 +290,7 @@ QC.cancelQueries ensureQueryData(options): Promise; ``` -Defined in: [vue-query/src/queryClient.ts:83](https://github.com/TanStack/query/blob/main/packages/vue-query/src/queryClient.ts#L83) +Defined in: [packages/vue-query/src/queryClient.ts:83](https://github.com/TanStack/query/blob/main/packages/vue-query/src/queryClient.ts#L83) ##### Type Parameters @@ -124,7 +314,7 @@ Defined in: [vue-query/src/queryClient.ts:83](https://github.com/TanStack/query/ ###### options -`EnsureQueryDataOptions`\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`\> +[`EnsureQueryDataOptions`](../interfaces/EnsureQueryDataOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`\> ##### Returns @@ -146,7 +336,7 @@ QC.ensureQueryData ensureQueryData(options): Promise; ``` -Defined in: [vue-query/src/queryClient.ts:91](https://github.com/TanStack/query/blob/main/packages/vue-query/src/queryClient.ts#L91) +Defined in: [packages/vue-query/src/queryClient.ts:91](https://github.com/TanStack/query/blob/main/packages/vue-query/src/queryClient.ts#L91) ##### Type Parameters @@ -170,7 +360,7 @@ Defined in: [vue-query/src/queryClient.ts:91](https://github.com/TanStack/query/ ###### options -`MaybeRefDeep`\<`EnsureQueryDataOptions`\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`, `never`\>\> +`MaybeRefDeep`\<[`EnsureQueryDataOptions`](../interfaces/EnsureQueryDataOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`, `never`\>\> ##### Returns @@ -196,7 +386,7 @@ QC.ensureQueryData fetchInfiniteQuery(options): Promise>; ``` -Defined in: [vue-query/src/queryClient.ts:464](https://github.com/TanStack/query/blob/main/packages/vue-query/src/queryClient.ts#L464) +Defined in: [packages/vue-query/src/queryClient.ts:464](https://github.com/TanStack/query/blob/main/packages/vue-query/src/queryClient.ts#L464) ##### Type Parameters @@ -224,11 +414,11 @@ Defined in: [vue-query/src/queryClient.ts:464](https://github.com/TanStack/query ###### options -`FetchInfiniteQueryOptions`\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`, `TPageParam`\> +[`FetchInfiniteQueryOptions`](../type-aliases/FetchInfiniteQueryOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`, `TPageParam`\> ##### Returns -`Promise`\<`InfiniteData`\<`TData`, `TPageParam`\>\> +`Promise`\<[`InfiniteData`](../interfaces/InfiniteData.md)\<`TData`, `TPageParam`\>\> ##### Deprecated @@ -246,7 +436,7 @@ QC.fetchInfiniteQuery fetchInfiniteQuery(options): Promise>; ``` -Defined in: [vue-query/src/queryClient.ts:479](https://github.com/TanStack/query/blob/main/packages/vue-query/src/queryClient.ts#L479) +Defined in: [packages/vue-query/src/queryClient.ts:479](https://github.com/TanStack/query/blob/main/packages/vue-query/src/queryClient.ts#L479) ##### Type Parameters @@ -274,11 +464,11 @@ Defined in: [vue-query/src/queryClient.ts:479](https://github.com/TanStack/query ###### options -`MaybeRefDeep`\<`FetchInfiniteQueryOptions`\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`, `TPageParam`\>\> +`MaybeRefDeep`\<[`FetchInfiniteQueryOptions`](../type-aliases/FetchInfiniteQueryOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`, `TPageParam`\>\> ##### Returns -`Promise`\<`InfiniteData`\<`TData`, `TPageParam`\>\> +`Promise`\<[`InfiniteData`](../interfaces/InfiniteData.md)\<`TData`, `TPageParam`\>\> ##### Deprecated @@ -300,7 +490,7 @@ QC.fetchInfiniteQuery fetchQuery(options): Promise; ``` -Defined in: [vue-query/src/queryClient.ts:313](https://github.com/TanStack/query/blob/main/packages/vue-query/src/queryClient.ts#L313) +Defined in: [packages/vue-query/src/queryClient.ts:313](https://github.com/TanStack/query/blob/main/packages/vue-query/src/queryClient.ts#L313) ##### Type Parameters @@ -328,7 +518,7 @@ Defined in: [vue-query/src/queryClient.ts:313](https://github.com/TanStack/query ###### options -`FetchQueryOptions`\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`, `TPageParam`\> +[`FetchQueryOptions`](../interfaces/FetchQueryOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`, `TPageParam`\> ##### Returns @@ -350,7 +540,7 @@ QC.fetchQuery fetchQuery(options): Promise; ``` -Defined in: [vue-query/src/queryClient.ts:328](https://github.com/TanStack/query/blob/main/packages/vue-query/src/queryClient.ts#L328) +Defined in: [packages/vue-query/src/queryClient.ts:328](https://github.com/TanStack/query/blob/main/packages/vue-query/src/queryClient.ts#L328) ##### Type Parameters @@ -378,7 +568,7 @@ Defined in: [vue-query/src/queryClient.ts:328](https://github.com/TanStack/query ###### options -`MaybeRefDeep`\<`FetchQueryOptions`\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`, `TPageParam`\>\> | () => `FetchQueryOptions`\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`, `TPageParam`\> +`MaybeRefDeep`\<[`FetchQueryOptions`](../interfaces/FetchQueryOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`, `TPageParam`\>\> | () => [`FetchQueryOptions`](../interfaces/FetchQueryOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`, `TPageParam`\> ##### Returns @@ -396,13 +586,81 @@ QC.fetchQuery *** +### getDefaultOptions() + +```ts +getDefaultOptions(): DefaultOptions; +``` + +Defined in: [packages/query-core/src/queryClient.ts:818](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L818) + +Returns the default options that were set when creating the client, or via +[QueryClient#setDefaultOptions](#setdefaultoptions). + +#### Returns + +[`DefaultOptions`](../interfaces/DefaultOptions.md) + +#### Example + +```ts +import { QueryClient } from '@tanstack/query-core' + +const queryClient = new QueryClient() +const defaultOptions = queryClient.getDefaultOptions() +``` + +#### Inherited from + +```ts +QC.getDefaultOptions +``` + +*** + +### getMutationCache() + +```ts +getMutationCache(): MutationCache; +``` + +Defined in: [packages/query-core/src/queryClient.ts:802](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L802) + +Returns the mutation cache this client is connected to. + +#### Returns + +`MutationCache` + +#### Example + +```ts +import { QueryClient } from '@tanstack/query-core' + +const queryClient = new QueryClient() +const mutationCache = queryClient.getMutationCache() +const mutations = mutationCache.findAll({ status: 'pending' }) +``` + +#### Inherited from + +```ts +QC.getMutationCache +``` + +*** + ### getMutationDefaults() ```ts getMutationDefaults(mutationKey): MutationObserverOptions; ``` -Defined in: [vue-query/src/queryClient.ts:612](https://github.com/TanStack/query/blob/main/packages/vue-query/src/queryClient.ts#L612) +Defined in: [packages/vue-query/src/queryClient.ts:612](https://github.com/TanStack/query/blob/main/packages/vue-query/src/queryClient.ts#L612) + +Returns the default options registered for mutations whose mutation key partially matches +the given `mutationKey`, via [QueryClient#setMutationDefaults](#setmutationdefaults). If multiple registered +defaults match, they are merged together in registration order. #### Parameters @@ -412,7 +670,13 @@ Defined in: [vue-query/src/queryClient.ts:612](https://github.com/TanStack/query #### Returns -`MutationObserverOptions`\<`any`, `any`, `any`, `any`\> +[`MutationObserverOptions`](../interfaces/MutationObserverOptions.md)\<`any`, `any`, `any`, `any`\> + +#### Example + +```ts +const defaultOptions = queryClient.getMutationDefaults(['addPost']) +``` #### Overrides @@ -428,7 +692,17 @@ QC.getMutationDefaults getQueriesData(filters): [readonly unknown[], TData | undefined][]; ``` -Defined in: [vue-query/src/queryClient.ts:114](https://github.com/TanStack/query/blob/main/packages/vue-query/src/queryClient.ts#L114) +Defined in: [packages/vue-query/src/queryClient.ts:114](https://github.com/TanStack/query/blob/main/packages/vue-query/src/queryClient.ts#L114) + +Imperative (non-reactive) way to retrieve the cached data of multiple queries at once. +Only queries matching the given filters are returned; if none match, an empty array is +returned. + +Because the matched queries can hold data of different shapes (e.g. a broad filter can match +queries with unrelated data types), the `TQueryFnData` generic defaults to `unknown` rather +than being inferred. Passing a more specific type is a convenience for call sites that know +every matched query holds the same shape — it is not checked against the actual cache +contents. #### Type Parameters @@ -446,6 +720,16 @@ Defined in: [vue-query/src/queryClient.ts:114](https://github.com/TanStack/query \[readonly `unknown`[], `TData` \| `undefined`\][] +#### See + +[QueryClient#getQueryData](#getquerydata) + +#### Example + +```ts +const data = queryClient.getQueriesData({ queryKey: ['posts'] }) +``` + #### Overrides ```ts @@ -454,15 +738,49 @@ QC.getQueriesData *** +### getQueryCache() + +```ts +getQueryCache(): QueryCache; +``` + +Defined in: [packages/query-core/src/queryClient.ts:786](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L786) + +Returns the query cache this client is connected to. + +#### Returns + +`QueryCache` + +#### Example + +```ts +import { QueryClient } from '@tanstack/query-core' + +const queryClient = new QueryClient() +const queryCache = queryClient.getQueryCache() +const queries = queryCache.findAll({ queryKey: ['posts'] }) +``` + +#### Inherited from + +```ts +QC.getQueryCache +``` + +*** + ### getQueryData() #### Call Signature ```ts -getQueryData(queryKey): InferDataFromTag | undefined; +getQueryData(queryKey): + | InferDataFromTag + | undefined; ``` -Defined in: [vue-query/src/queryClient.ts:68](https://github.com/TanStack/query/blob/main/packages/vue-query/src/queryClient.ts#L68) +Defined in: [packages/vue-query/src/queryClient.ts:68](https://github.com/TanStack/query/blob/main/packages/vue-query/src/queryClient.ts#L68) Imperative (non-reactive) way to retrieve data for a QueryKey. Should only be used in callbacks or functions where reading the latest data is necessary, e.g. for optimistic updates. @@ -488,7 +806,12 @@ Use `useQuery` to create a `QueryObserver` that subscribes to changes. ##### Returns -`InferDataFromTag`\<`TData`, `TTaggedQueryKey`\> \| `undefined` + \| [`InferDataFromTag`](../type-aliases/InferDataFromTag.md)\<`TData`, `TTaggedQueryKey`\> + \| `undefined` + +##### See + +[QueryClient#getQueriesData](#getqueriesdata) ##### Overrides @@ -502,7 +825,7 @@ QC.getQueryData getQueryData(queryKey): TData | undefined; ``` -Defined in: [vue-query/src/queryClient.ts:71](https://github.com/TanStack/query/blob/main/packages/vue-query/src/queryClient.ts#L71) +Defined in: [packages/vue-query/src/queryClient.ts:71](https://github.com/TanStack/query/blob/main/packages/vue-query/src/queryClient.ts#L71) ##### Type Parameters @@ -534,7 +857,11 @@ QC.getQueryData getQueryDefaults(queryKey): OmitKeyof, "queryKey">; ``` -Defined in: [vue-query/src/queryClient.ts:589](https://github.com/TanStack/query/blob/main/packages/vue-query/src/queryClient.ts#L589) +Defined in: [packages/vue-query/src/queryClient.ts:589](https://github.com/TanStack/query/blob/main/packages/vue-query/src/queryClient.ts#L589) + +Returns the default options registered for queries whose query key partially matches the +given `queryKey`, via [QueryClient#setQueryDefaults](#setquerydefaults). If multiple registered defaults +match, they are merged together in registration order. #### Parameters @@ -544,7 +871,13 @@ Defined in: [vue-query/src/queryClient.ts:589](https://github.com/TanStack/query #### Returns -`OmitKeyof`\<`QueryObserverOptions`\<`any`, `any`, `any`, `any`, `any`\>, `"queryKey"`\> +[`OmitKeyof`](../type-aliases/OmitKeyof.md)\<[`QueryObserverOptions`](../interfaces/QueryObserverOptions.md)\<`any`, `any`, `any`, `any`, `any`\>, `"queryKey"`\> + +#### Example + +```ts +const defaultOptions = queryClient.getQueryDefaults(['posts']) +``` #### Overrides @@ -557,10 +890,15 @@ QC.getQueryDefaults ### getQueryState() ```ts -getQueryState(queryKey): QueryState | undefined; +getQueryState(queryKey): + | QueryState + | undefined; ``` -Defined in: [vue-query/src/queryClient.ts:161](https://github.com/TanStack/query/blob/main/packages/vue-query/src/queryClient.ts#L161) +Defined in: [packages/vue-query/src/queryClient.ts:161](https://github.com/TanStack/query/blob/main/packages/vue-query/src/queryClient.ts#L161) + +Imperative (non-reactive) way to retrieve an existing query's state. If the query does not +exist, `undefined` is returned. #### Type Parameters @@ -580,7 +918,15 @@ Defined in: [vue-query/src/queryClient.ts:161](https://github.com/TanStack/query #### Returns -`QueryState`\<`TData`, `TError`\> \| `undefined` + \| [`QueryState`](../interfaces/QueryState.md)\<`TData`, `TError`\> + \| `undefined` + +#### Example + +```ts +const state = queryClient.getQueryState(['posts']) +console.log(state?.dataUpdatedAt) +``` #### Overrides @@ -598,7 +944,17 @@ QC.getQueryState infiniteQuery(options): Promise[] ? InfiniteData : TData>; ``` -Defined in: [vue-query/src/queryClient.ts:397](https://github.com/TanStack/query/blob/main/packages/vue-query/src/queryClient.ts#L397) +Defined in: [packages/vue-query/src/queryClient.ts:397](https://github.com/TanStack/query/blob/main/packages/vue-query/src/queryClient.ts#L397) + +Asynchronous method to fetch and cache an infinite query, resolving with an +[InfiniteData](../interfaces/InfiniteData.md) object or throwing with the error. + +Behaves like [QueryClient#query](#query), accepting the same options (minus +`initialPageParam`), plus the required `initialPageParam`, and an optional `pages` / +`getNextPageParam` pair used to refetch a fixed number of pages from the start. + +This method replaces the deprecated `fetchInfiniteQuery`, and — combined with +`{ staleTime: 'static' }` — the deprecated `ensureInfiniteQueryData`. ##### Type Parameters @@ -612,7 +968,7 @@ Defined in: [vue-query/src/queryClient.ts:397](https://github.com/TanStack/query ###### TData -`TData` = `InfiniteData`\<`TQueryFnData`, `unknown`\> +`TData` = [`InfiniteData`](../interfaces/InfiniteData.md)\<`TQueryFnData`, `unknown`\> ###### TQueryKey @@ -626,11 +982,22 @@ Defined in: [vue-query/src/queryClient.ts:397](https://github.com/TanStack/query ###### options -`InfiniteQueryExecuteOptions`\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`, `TPageParam`\> +[`InfiniteQueryExecuteOptions`](../type-aliases/InfiniteQueryExecuteOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`, `TPageParam`\> ##### Returns -`Promise`\<`TData`[] *extends* `InfiniteData`\<`TQueryFnData`, `unknown`\>[] ? `InfiniteData`\<`TQueryFnData`, `TPageParam`\> : `TData`\> +`Promise`\<`TData`[] *extends* [`InfiniteData`](../interfaces/InfiniteData.md)\<`TQueryFnData`, `unknown`\>[] ? [`InfiniteData`](../interfaces/InfiniteData.md)\<`TQueryFnData`, `TPageParam`\> : `TData`\> + +##### Example + +```ts +try { + const data = await queryClient.infiniteQuery({ queryKey, queryFn, initialPageParam: 0 }) + console.log(data.pages) +} catch (error) { + console.log(error) +} +``` ##### Overrides @@ -644,7 +1011,7 @@ QC.infiniteQuery infiniteQuery(options): Promise[] ? InfiniteData : TData>; ``` -Defined in: [vue-query/src/queryClient.ts:416](https://github.com/TanStack/query/blob/main/packages/vue-query/src/queryClient.ts#L416) +Defined in: [packages/vue-query/src/queryClient.ts:416](https://github.com/TanStack/query/blob/main/packages/vue-query/src/queryClient.ts#L416) ##### Type Parameters @@ -658,7 +1025,7 @@ Defined in: [vue-query/src/queryClient.ts:416](https://github.com/TanStack/query ###### TData -`TData` = `InfiniteData`\<`TQueryFnData`, `unknown`\> +`TData` = [`InfiniteData`](../interfaces/InfiniteData.md)\<`TQueryFnData`, `unknown`\> ###### TQueryKey @@ -672,11 +1039,11 @@ Defined in: [vue-query/src/queryClient.ts:416](https://github.com/TanStack/query ###### options -`MaybeRefDeep`\<`InfiniteQueryExecuteOptions`\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`, `TPageParam`\>\> +`MaybeRefDeep`\<[`InfiniteQueryExecuteOptions`](../type-aliases/InfiniteQueryExecuteOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`, `TPageParam`\>\> ##### Returns -`Promise`\<`TData`[] *extends* `InfiniteData`\<`TQueryFnData`, `unknown`\>[] ? `InfiniteData`\<`TQueryFnData`, `TPageParam`\> : `TData`\> +`Promise`\<`TData`[] *extends* [`InfiniteData`](../interfaces/InfiniteData.md)\<`TQueryFnData`, `unknown`\>[] ? [`InfiniteData`](../interfaces/InfiniteData.md)\<`TQueryFnData`, `TPageParam`\> : `TData`\> ##### Overrides @@ -692,7 +1059,14 @@ QC.infiniteQuery invalidateQueries(filters?, options?): Promise; ``` -Defined in: [vue-query/src/queryClient.ts:196](https://github.com/TanStack/query/blob/main/packages/vue-query/src/queryClient.ts#L196) +Defined in: [packages/vue-query/src/queryClient.ts:196](https://github.com/TanStack/query/blob/main/packages/vue-query/src/queryClient.ts#L196) + +Marks queries matching the given filters as invalidated. Unlike +[QueryClient#removeQueries](#removequeries), invalidated queries stay in the cache. + +Unless `filters.refetchType` is `'none'`, matching queries are then refetched via +[QueryClient#refetchQueries](#refetchqueries), using `filters.refetchType` if set, otherwise +`filters.type`, otherwise `'active'`. #### Type Parameters @@ -704,16 +1078,22 @@ Defined in: [vue-query/src/queryClient.ts:196](https://github.com/TanStack/query ##### filters? -`InvalidateQueryFilters`\<`TTaggedQueryKey`\> | () => `InvalidateQueryFilters`\<`TTaggedQueryKey`\> +[`InvalidateQueryFilters`](../interfaces/InvalidateQueryFilters.md)\<`TTaggedQueryKey`\> | () => [`InvalidateQueryFilters`](../interfaces/InvalidateQueryFilters.md)\<`TTaggedQueryKey`\> ##### options? -`MaybeRefDeep`\<`InvalidateOptions`\> +`MaybeRefDeep`\<[`InvalidateOptions`](../interfaces/InvalidateOptions.md)\> #### Returns `Promise`\<`void`\> +#### Example + +```ts +await queryClient.invalidateQueries({ queryKey: ['posts'], refetchType: 'active' }) +``` + #### Overrides ```ts @@ -728,7 +1108,11 @@ QC.invalidateQueries isFetching(filters): number; ``` -Defined in: [vue-query/src/queryClient.ts:60](https://github.com/TanStack/query/blob/main/packages/vue-query/src/queryClient.ts#L60) +Defined in: [packages/vue-query/src/queryClient.ts:60](https://github.com/TanStack/query/blob/main/packages/vue-query/src/queryClient.ts#L60) + +Returns the number of queries in the cache that are currently fetching, optionally +matching a set of filters. This includes background-fetching, loading new pages, and +loading more infinite query results. #### Parameters @@ -740,6 +1124,14 @@ Defined in: [vue-query/src/queryClient.ts:60](https://github.com/TanStack/query/ `number` +#### Example + +```ts +if (queryClient.isFetching()) { + console.log('At least one query is fetching!') +} +``` + #### Overrides ```ts @@ -754,7 +1146,10 @@ QC.isFetching isMutating(filters): number; ``` -Defined in: [vue-query/src/queryClient.ts:64](https://github.com/TanStack/query/blob/main/packages/vue-query/src/queryClient.ts#L64) +Defined in: [packages/vue-query/src/queryClient.ts:64](https://github.com/TanStack/query/blob/main/packages/vue-query/src/queryClient.ts#L64) + +Returns the number of mutations in the cache that are currently pending, optionally +matching a set of filters. #### Parameters @@ -766,6 +1161,14 @@ Defined in: [vue-query/src/queryClient.ts:64](https://github.com/TanStack/query/ `number` +#### Example + +```ts +if (queryClient.isMutating()) { + console.log('At least one mutation is pending!') +} +``` + #### Overrides ```ts @@ -774,6 +1177,31 @@ QC.isMutating *** +### mount() + +```ts +mount(): void; +``` + +Defined in: [packages/query-core/src/queryClient.ts:104](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L104) + +Called by a framework adapter's `QueryClientProvider`-equivalent when it mounts, to start +listening for focus/online events and resume paused mutations. Ref-counted via an internal +mount count, so nested or multiple providers sharing the same `QueryClient` don't tear down +the shared listeners until the last one unmounts. + +#### Returns + +`void` + +#### Inherited from + +```ts +QC.mount +``` + +*** + ### ~~prefetchInfiniteQuery()~~ #### Call Signature @@ -782,7 +1210,7 @@ QC.isMutating prefetchInfiniteQuery(options): Promise; ``` -Defined in: [vue-query/src/queryClient.ts:519](https://github.com/TanStack/query/blob/main/packages/vue-query/src/queryClient.ts#L519) +Defined in: [packages/vue-query/src/queryClient.ts:519](https://github.com/TanStack/query/blob/main/packages/vue-query/src/queryClient.ts#L519) ##### Type Parameters @@ -810,7 +1238,7 @@ Defined in: [vue-query/src/queryClient.ts:519](https://github.com/TanStack/query ###### options -`FetchInfiniteQueryOptions`\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`, `TPageParam`\> +[`FetchInfiniteQueryOptions`](../type-aliases/FetchInfiniteQueryOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`, `TPageParam`\> ##### Returns @@ -832,7 +1260,7 @@ QC.prefetchInfiniteQuery prefetchInfiniteQuery(options): Promise; ``` -Defined in: [vue-query/src/queryClient.ts:534](https://github.com/TanStack/query/blob/main/packages/vue-query/src/queryClient.ts#L534) +Defined in: [packages/vue-query/src/queryClient.ts:534](https://github.com/TanStack/query/blob/main/packages/vue-query/src/queryClient.ts#L534) ##### Type Parameters @@ -860,7 +1288,7 @@ Defined in: [vue-query/src/queryClient.ts:534](https://github.com/TanStack/query ###### options -`MaybeRefDeep`\<`FetchInfiniteQueryOptions`\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`, `TPageParam`\>\> +`MaybeRefDeep`\<[`FetchInfiniteQueryOptions`](../type-aliases/FetchInfiniteQueryOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`, `TPageParam`\>\> ##### Returns @@ -886,7 +1314,7 @@ QC.prefetchInfiniteQuery prefetchQuery(options): Promise; ``` -Defined in: [vue-query/src/queryClient.ts:364](https://github.com/TanStack/query/blob/main/packages/vue-query/src/queryClient.ts#L364) +Defined in: [packages/vue-query/src/queryClient.ts:364](https://github.com/TanStack/query/blob/main/packages/vue-query/src/queryClient.ts#L364) ##### Type Parameters @@ -910,7 +1338,7 @@ Defined in: [vue-query/src/queryClient.ts:364](https://github.com/TanStack/query ###### options -`FetchQueryOptions`\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`\> +[`FetchQueryOptions`](../interfaces/FetchQueryOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`\> ##### Returns @@ -932,7 +1360,7 @@ QC.prefetchQuery prefetchQuery(options): Promise; ``` -Defined in: [vue-query/src/queryClient.ts:372](https://github.com/TanStack/query/blob/main/packages/vue-query/src/queryClient.ts#L372) +Defined in: [packages/vue-query/src/queryClient.ts:372](https://github.com/TanStack/query/blob/main/packages/vue-query/src/queryClient.ts#L372) ##### Type Parameters @@ -956,7 +1384,7 @@ Defined in: [vue-query/src/queryClient.ts:372](https://github.com/TanStack/query ###### options -`MaybeRefDeep`\<`FetchQueryOptions`\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`, `never`\>\> +`MaybeRefDeep`\<[`FetchQueryOptions`](../interfaces/FetchQueryOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`, `never`\>\> ##### Returns @@ -982,7 +1410,28 @@ QC.prefetchQuery query(options): Promise; ``` -Defined in: [vue-query/src/queryClient.ts:252](https://github.com/TanStack/query/blob/main/packages/vue-query/src/queryClient.ts#L252) +Defined in: [packages/vue-query/src/queryClient.ts:252](https://github.com/TanStack/query/blob/main/packages/vue-query/src/queryClient.ts#L252) + +Asynchronous method to fetch and cache a query, resolving with the data or throwing with +the error. + +If the query already exists in the cache and its data is not stale (per the given +`staleTime`), the cached data is returned without fetching. Otherwise, the query is fetched +and the promise resolves once the fetch settles. If a `select` function is provided, it is +applied to the data in both cases (cached or freshly fetched) before it is returned. + +Unlike a reactive observer, retries are disabled by default here (`retry: false`) unless +explicitly configured, since there is no component to catch a thrown error and retry through +re-render. + +The accepted options are `QueryObserverOptions` minus the fields that only make sense for a +reactive observer — `enabled`, `refetchInterval`, `refetchIntervalInBackground`, +`refetchOnWindowFocus`, `refetchOnReconnect`, `refetchOnMount`, `retryOnMount`, +`notifyOnChangeProps`, `throwOnError`, `suspense`, and `placeholderData` are not part of this +method's options. + +This method replaces the deprecated `fetchQuery`, and — combined with +`{ staleTime: 'static' }` — the deprecated `ensureQueryData`. ##### Type Parameters @@ -1014,12 +1463,22 @@ Defined in: [vue-query/src/queryClient.ts:252](https://github.com/TanStack/query ###### options -`QueryExecuteOptions`\<`TQueryFnData`, `TError`, `TData`, `TQueryData`, `TQueryKey`, `TPageParam`\> +[`QueryExecuteOptions`](../interfaces/QueryExecuteOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryData`, `TQueryKey`, `TPageParam`\> ##### Returns `Promise`\<`TData`\> +##### Example + +```ts +try { + const data = await queryClient.query({ queryKey, queryFn, staleTime: 10000 }) +} catch (error) { + console.log(error) +} +``` + ##### Overrides ```ts @@ -1032,7 +1491,7 @@ QC.query query(options): Promise; ``` -Defined in: [vue-query/src/queryClient.ts:269](https://github.com/TanStack/query/blob/main/packages/vue-query/src/queryClient.ts#L269) +Defined in: [packages/vue-query/src/queryClient.ts:269](https://github.com/TanStack/query/blob/main/packages/vue-query/src/queryClient.ts#L269) ##### Type Parameters @@ -1064,7 +1523,7 @@ Defined in: [vue-query/src/queryClient.ts:269](https://github.com/TanStack/query ###### options -`MaybeRefDeep`\<`QueryExecuteOptions`\<`TQueryFnData`, `TError`, `TData`, `TQueryData`, `TQueryKey`, `TPageParam`\>\> +`MaybeRefDeep`\<[`QueryExecuteOptions`](../interfaces/QueryExecuteOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryData`, `TQueryKey`, `TPageParam`\>\> ##### Returns @@ -1084,7 +1543,15 @@ QC.query refetchQueries(filters?, options?): Promise; ``` -Defined in: [vue-query/src/queryClient.ts:236](https://github.com/TanStack/query/blob/main/packages/vue-query/src/queryClient.ts#L236) +Defined in: [packages/vue-query/src/queryClient.ts:236](https://github.com/TanStack/query/blob/main/packages/vue-query/src/queryClient.ts#L236) + +Refetches queries matching the given filters, regardless of whether they are stale. Without +filters, every query in the cache is refetched. Queries that are disabled, or static (only +have observers with a static `staleTime`), are never refetched. + +By default (`cancelRefetch: true`), a currently running fetch is cancelled before the new +one starts. The returned promise resolves once all matching queries have settled; it does +not reject on individual query failures unless `throwOnError` is set. #### Type Parameters @@ -1096,16 +1563,23 @@ Defined in: [vue-query/src/queryClient.ts:236](https://github.com/TanStack/query ##### filters? -`RefetchQueryFilters`\<`TTaggedQueryKey`\> +[`RefetchQueryFilters`](../interfaces/RefetchQueryFilters.md)\<`TTaggedQueryKey`\> ##### options? -`MaybeRefDeep`\<`RefetchOptions`\> +`MaybeRefDeep`\<[`RefetchOptions`](../interfaces/RefetchOptions.md)\> #### Returns `Promise`\<`void`\> +#### Example + +```ts +// refetch all active queries partially matching a query key: +await queryClient.refetchQueries({ queryKey: ['posts'], type: 'active' }) +``` + #### Overrides ```ts @@ -1120,7 +1594,12 @@ QC.refetchQueries removeQueries(filters?): void; ``` -Defined in: [vue-query/src/queryClient.ts:167](https://github.com/TanStack/query/blob/main/packages/vue-query/src/queryClient.ts#L167) +Defined in: [packages/vue-query/src/queryClient.ts:167](https://github.com/TanStack/query/blob/main/packages/vue-query/src/queryClient.ts#L167) + +Removes queries from the cache that match the given filters. Unlike +[QueryClient#invalidateQueries](#invalidatequeries) or [QueryClient#refetchQueries](#refetchqueries), this removes +matching queries from the cache instead of refetching them. Without filters, every query in +the cache is removed. #### Type Parameters @@ -1138,6 +1617,12 @@ Defined in: [vue-query/src/queryClient.ts:167](https://github.com/TanStack/query `void` +#### Example + +```ts +queryClient.removeQueries({ queryKey: ['posts'], exact: true }) +``` + #### Overrides ```ts @@ -1152,7 +1637,11 @@ QC.removeQueries resetQueries(filters?, options?): Promise; ``` -Defined in: [vue-query/src/queryClient.ts:174](https://github.com/TanStack/query/blob/main/packages/vue-query/src/queryClient.ts#L174) +Defined in: [packages/vue-query/src/queryClient.ts:174](https://github.com/TanStack/query/blob/main/packages/vue-query/src/queryClient.ts#L174) + +Resets queries matching the given filters back to their initial state (e.g. any +`initialData`), notifying subscribers rather than removing them. Active queries among the +matched set are then refetched, and the returned promise resolves once that refetch settles. #### Type Parameters @@ -1168,12 +1657,18 @@ Defined in: [vue-query/src/queryClient.ts:174](https://github.com/TanStack/query ##### options? -`MaybeRefDeep`\<`ResetOptions`\> +`MaybeRefDeep`\<[`ResetOptions`](../interfaces/ResetOptions.md)\> #### Returns `Promise`\<`void`\> +#### Example + +```ts +await queryClient.resetQueries({ queryKey: ['posts'], exact: true }) +``` + #### Overrides ```ts @@ -1182,24 +1677,76 @@ QC.resetQueries *** +### resumePausedMutations() + +```ts +resumePausedMutations(): Promise; +``` + +Defined in: [packages/query-core/src/queryClient.ts:767](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L767) + +Resumes mutations that were paused because there was no network connection. Does nothing +(resolving immediately) if the client is currently offline. + +#### Returns + +`Promise`\<`unknown`\> + +#### Example + +```ts +import { QueryClient } from '@tanstack/query-core' + +const queryClient = new QueryClient() +await queryClient.resumePausedMutations() +``` + +#### Inherited from + +```ts +QC.resumePausedMutations +``` + +*** + ### setDefaultOptions() ```ts setDefaultOptions(options): void; ``` -Defined in: [vue-query/src/queryClient.ts:571](https://github.com/TanStack/query/blob/main/packages/vue-query/src/queryClient.ts#L571) +Defined in: [packages/vue-query/src/queryClient.ts:571](https://github.com/TanStack/query/blob/main/packages/vue-query/src/queryClient.ts#L571) + +Dynamically sets the default options for this client, overwriting any previously defined +default options. #### Parameters ##### options -`MaybeRefDeep`\<`DefaultOptions`\<`Error`\>\> +`MaybeRefDeep`\<[`DefaultOptions`](../interfaces/DefaultOptions.md)\<`Error`\>\> #### Returns `void` +#### See + +[QueryClient#getDefaultOptions](#getdefaultoptions) + +#### Example + +```ts +import { QueryClient } from '@tanstack/query-core' + +const queryClient = new QueryClient() +queryClient.setDefaultOptions({ + queries: { + staleTime: Infinity, + }, +}) +``` + #### Overrides ```ts @@ -1214,7 +1761,11 @@ QC.setDefaultOptions setMutationDefaults(mutationKey, options): void; ``` -Defined in: [vue-query/src/queryClient.ts:595](https://github.com/TanStack/query/blob/main/packages/vue-query/src/queryClient.ts#L595) +Defined in: [packages/vue-query/src/queryClient.ts:595](https://github.com/TanStack/query/blob/main/packages/vue-query/src/queryClient.ts#L595) + +Sets default options for mutations whose mutation key partially matches the given +`mutationKey`. As with [QueryClient#setQueryDefaults](#setquerydefaults), the order of registration +matters when several registered defaults match the same mutation key. #### Type Parameters @@ -1242,12 +1793,22 @@ Defined in: [vue-query/src/queryClient.ts:595](https://github.com/TanStack/query ##### options -`MaybeRefDeep`\<`MutationObserverOptions`\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\>\> +`MaybeRefDeep`\<[`MutationObserverOptions`](../interfaces/MutationObserverOptions.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\>\> #### Returns `void` +#### See + +[QueryClient#getMutationDefaults](#getmutationdefaults) + +#### Example + +```ts +queryClient.setMutationDefaults(['addPost'], { mutationFn: addPost }) +``` + #### Overrides ```ts @@ -1265,7 +1826,12 @@ setQueriesData( options): [readonly unknown[], TData | undefined][]; ``` -Defined in: [vue-query/src/queryClient.ts:149](https://github.com/TanStack/query/blob/main/packages/vue-query/src/queryClient.ts#L149) +Defined in: [packages/vue-query/src/queryClient.ts:149](https://github.com/TanStack/query/blob/main/packages/vue-query/src/queryClient.ts#L149) + +Synchronous way to immediately update the cached data of multiple queries at once, using +filters or partial query key matching. Only queries that already exist and match the given +filters are updated; no new cache entries are created. Internally this calls +[QueryClient#setQueryData](#setquerydata) for each matching query. #### Type Parameters @@ -1281,16 +1847,24 @@ Defined in: [vue-query/src/queryClient.ts:149](https://github.com/TanStack/query ##### updater -`Updater`\<`TData` \| `undefined`, `TData` \| `undefined`\> +[`Updater`](../type-aliases/Updater.md)\<`TData` \| `undefined`, `TData` \| `undefined`\> ##### options -`MaybeRefDeep`\<`SetDataOptions`\> = `{}` +`MaybeRefDeep`\<[`SetDataOptions`](../interfaces/SetDataOptions.md)\> = `{}` #### Returns \[readonly `unknown`[], `TData` \| `undefined`\][] +#### Example + +```ts +queryClient.setQueriesData({ queryKey: ['posts'] }, (oldPosts) => + oldPosts ? oldPosts.filter((post) => post.id !== deletedId) : oldPosts, +) +``` + #### Overrides ```ts @@ -1310,7 +1884,15 @@ setQueryData( options?): NoInfer | undefined; ``` -Defined in: [vue-query/src/queryClient.ts:120](https://github.com/TanStack/query/blob/main/packages/vue-query/src/queryClient.ts#L120) +Defined in: [packages/vue-query/src/queryClient.ts:120](https://github.com/TanStack/query/blob/main/packages/vue-query/src/queryClient.ts#L120) + +Synchronous way to immediately update a query's cached data. If the updater (or the value +passed) resolves to `undefined`, the cache is left untouched and no query is created; +otherwise, if the query does not exist yet, it will be created. To update multiple queries +at once by partially matching query keys, use [QueryClient#setQueriesData](#setqueriesdata) instead. + +Updates must be performed immutably: do not mutate `oldData`, or data previously retrieved +via [QueryClient#getQueryData](#getquerydata), in place. ##### Type Parameters @@ -1324,7 +1906,7 @@ Defined in: [vue-query/src/queryClient.ts:120](https://github.com/TanStack/query ###### TInferredQueryFnData -`TInferredQueryFnData` = `InferDataFromTag`\<`TQueryFnData`, `TTaggedQueryKey`\> +`TInferredQueryFnData` = [`InferDataFromTag`](../type-aliases/InferDataFromTag.md)\<`TQueryFnData`, `TTaggedQueryKey`\> ##### Parameters @@ -1332,18 +1914,32 @@ Defined in: [vue-query/src/queryClient.ts:120](https://github.com/TanStack/query `TTaggedQueryKey` +The query key to set data for. + ###### updater -`Updater`\<`NoInfer`\<`TInferredQueryFnData`\> \| `undefined`, `NoInfer`\<`TInferredQueryFnData`\> \| `undefined`\> +[`Updater`](../type-aliases/Updater.md)\<`NoInfer`\<`TInferredQueryFnData`\> \| `undefined`, `NoInfer`\<`TInferredQueryFnData`\> \| `undefined`\> + +Either the new data, or a function that receives the current data (which +may be `undefined`) and returns the new data. ###### options? -`MaybeRefDeep`\<`SetDataOptions`\> +`MaybeRefDeep`\<[`SetDataOptions`](../interfaces/SetDataOptions.md)\> ##### Returns `NoInfer`\<`TInferredQueryFnData`\> \| `undefined` +##### Example + +```ts +queryClient.setQueryData(['posts'], newPosts) + +// Or, using an updater function that receives the current data: +queryClient.setQueryData(['posts'], (oldPosts) => [...oldPosts, newPost]) +``` + ##### Overrides ```ts @@ -1359,7 +1955,7 @@ setQueryData( options?): NoInfer | undefined; ``` -Defined in: [vue-query/src/queryClient.ts:132](https://github.com/TanStack/query/blob/main/packages/vue-query/src/queryClient.ts#L132) +Defined in: [packages/vue-query/src/queryClient.ts:132](https://github.com/TanStack/query/blob/main/packages/vue-query/src/queryClient.ts#L132) ##### Type Parameters @@ -1379,11 +1975,11 @@ Defined in: [vue-query/src/queryClient.ts:132](https://github.com/TanStack/query ###### updater -`Updater`\<`NoInfer`\<`TData`\> \| `undefined`, `NoInfer`\<`TData`\> \| `undefined`\> +[`Updater`](../type-aliases/Updater.md)\<`NoInfer`\<`TData`\> \| `undefined`, `NoInfer`\<`TData`\> \| `undefined`\> ###### options? -`MaybeRefDeep`\<`SetDataOptions`\> +`MaybeRefDeep`\<[`SetDataOptions`](../interfaces/SetDataOptions.md)\> ##### Returns @@ -1403,7 +1999,14 @@ QC.setQueryData setQueryDefaults(queryKey, options): void; ``` -Defined in: [vue-query/src/queryClient.ts:575](https://github.com/TanStack/query/blob/main/packages/vue-query/src/queryClient.ts#L575) +Defined in: [packages/vue-query/src/queryClient.ts:575](https://github.com/TanStack/query/blob/main/packages/vue-query/src/queryClient.ts#L575) + +Sets default options for queries whose query key partially matches the given `queryKey`. + +If several registered query defaults match a given query key, they are merged together in +registration order by [QueryClient#getQueryDefaults](#getquerydefaults), so register defaults from the +most generic key to the least generic one — more specific defaults should be registered +after more generic ones so they take precedence. #### Type Parameters @@ -1437,8 +2040,40 @@ Defined in: [vue-query/src/queryClient.ts:575](https://github.com/TanStack/query `void` +#### Example + +```ts +queryClient.setQueryDefaults(['posts'], { queryFn: fetchPosts }) + +await queryClient.query({ queryKey: ['posts'] }) +``` + #### Overrides ```ts QC.setQueryDefaults ``` + +*** + +### unmount() + +```ts +unmount(): void; +``` + +Defined in: [packages/query-core/src/queryClient.ts:127](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryClient.ts#L127) + +The inverse of [QueryClient#mount](#mount) — called by a framework adapter's +`QueryClientProvider`-equivalent when it unmounts. Only tears down the focus/online +listeners once the mount count returns to `0`. + +#### Returns + +`void` + +#### Inherited from + +```ts +QC.unmount +``` diff --git a/docs/framework/vue/reference/classes/QueryObserver.md b/docs/framework/vue/reference/classes/QueryObserver.md new file mode 100644 index 00000000000..1e2bae4353a --- /dev/null +++ b/docs/framework/vue/reference/classes/QueryObserver.md @@ -0,0 +1,555 @@ +--- +id: QueryObserver +title: QueryObserver +--- + +Defined in: [packages/query-core/src/queryObserver.ts:57](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L57) + +A `QueryObserver` watches a single query in the `QueryCache` and computes a +`QueryObserverResult` from its state, recomputing and notifying subscribers +whenever the underlying query (or the observer's options) changes. It is +the primitive that framework adapters (e.g. `useQuery`) build their hooks +on top of, but it can also be used directly to observe and switch between +queries outside of any framework. + +## Example + +```ts +const observer = new QueryObserver(queryClient, { + queryKey: ['posts'], + queryFn: fetchPosts, +}) + +const unsubscribe = observer.subscribe((result) => { + console.log(result.data) +}) +``` + +## Extends + +- `Subscribable`\<`QueryObserverListener`\<`TData`, `TError`\>\> + +## Extended by + +- [`InfiniteQueryObserver`](InfiniteQueryObserver.md) + +## Type Parameters + +### TQueryFnData + +`TQueryFnData` = `unknown` + +### TError + +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) + +### TData + +`TData` = `TQueryFnData` + +### TQueryData + +`TQueryData` = `TQueryFnData` + +### TQueryKey + +`TQueryKey` *extends* [`QueryKey`](../type-aliases/QueryKey.md) = [`QueryKey`](../type-aliases/QueryKey.md) + +## Constructors + +### Constructor + +```ts +new QueryObserver(client, options): QueryObserver; +``` + +Defined in: [packages/query-core/src/queryObserver.ts:87](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L87) + +#### Parameters + +##### client + +`QueryClient` + +##### options + +[`QueryObserverOptions`](../interfaces/QueryObserverOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryData`, `TQueryKey`\> + +#### Returns + +`QueryObserver`\<`TQueryFnData`, `TError`, `TData`, `TQueryData`, `TQueryKey`\> + +#### Overrides + +```ts +Subscribable>.constructor +``` + +## Properties + +### listeners + +```ts +protected listeners: Set>; +``` + +Defined in: [packages/query-core/src/subscribable.ts:2](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L2) + +#### Inherited from + +```ts +Subscribable.listeners +``` + +*** + +### options + +```ts +options: QueryObserverOptions; +``` + +Defined in: [packages/query-core/src/queryObserver.ts:89](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L89) + +## Methods + +### bindMethods() + +```ts +protected bindMethods(): void; +``` + +Defined in: [packages/query-core/src/queryObserver.ts:106](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L106) + +#### Returns + +`void` + +*** + +### createResult() + +```ts +protected createResult(query, options): QueryObserverResult; +``` + +Defined in: [packages/query-core/src/queryObserver.ts:559](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L559) + +#### Parameters + +##### query + +[`Query`](Query.md)\<`TQueryFnData`, `TError`, `TQueryData`, `TQueryKey`\> + +##### options + +[`QueryObserverOptions`](../interfaces/QueryObserverOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryData`, `TQueryKey`\> + +#### Returns + +[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\> + +*** + +### destroy() + +```ts +destroy(): void; +``` + +Defined in: [packages/query-core/src/queryObserver.ts:161](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L161) + +Stops observing the current query: clears all listeners, cancels the +stale and refetch-interval timers, and removes this observer from the +query it was observing. + +#### Returns + +`void` + +*** + +### fetch() + +```ts +protected fetch(fetchOptions): Promise>; +``` + +Defined in: [packages/query-core/src/queryObserver.ts:448](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L448) + +#### Parameters + +##### fetchOptions + +`ObserverFetchOptions` + +#### Returns + +`Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> + +*** + +### fetchOptimistic() + +```ts +fetchOptimistic(options): Promise>; +``` + +Defined in: [packages/query-core/src/queryObserver.ts:395](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L395) + +Fetches a query defined by the given options without affecting this +observer's own tracked query or result, and returns a promise that +resolves with the `QueryObserverResult` for that fetch. This is useful +for prefetching data that another observer (e.g. a query about to be +navigated to) will need, ahead of time. + +#### Parameters + +##### options + +[`QueryObserverOptions`](../interfaces/QueryObserverOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryData`, `TQueryKey`\> + +#### Returns + +`Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> + +#### Example + +```ts +const result = await observer.fetchOptimistic({ + queryKey: ['posts', 2], + queryFn: () => fetchPost(2), +}) +console.log(result.data) +``` + +*** + +### getCurrentQuery() + +```ts +getCurrentQuery(): Query; +``` + +Defined in: [packages/query-core/src/queryObserver.ts:357](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L357) + +Returns the `Query` instance this observer is currently observing. + +#### Returns + +[`Query`](Query.md)\<`TQueryFnData`, `TError`, `TQueryData`, `TQueryKey`\> + +*** + +### getCurrentResult() + +```ts +getCurrentResult(): QueryObserverResult; +``` + +Defined in: [packages/query-core/src/queryObserver.ts:321](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L321) + +Returns the most recently computed `QueryObserverResult` for the +observed query. This is a point-in-time read; to be notified of updates +as they happen, subscribe to the observer instead (its inherited +`subscribe` method). + +#### Returns + +[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\> + +#### Example + +```ts +const result = observer.getCurrentResult() +console.log(result.status, result.data) +``` + +*** + +### getOptimisticResult() + +```ts +getOptimisticResult(options): QueryObserverResult; +``` + +Defined in: [packages/query-core/src/queryObserver.ts:272](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L272) + +Computes the result the observer would produce for the given (already-defaulted) options +right now, building the underlying `Query` if it doesn't exist yet, without waiting for a +subscription callback. Called by framework adapters on every render (e.g. `useQuery`) so the +returned value is available synchronously, ahead of `setOptions` triggering an actual fetch. + +#### Parameters + +##### options + +[`DefaultedQueryObserverOptions`](../type-aliases/DefaultedQueryObserverOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryData`, `TQueryKey`\> + +#### Returns + +[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\> + +*** + +### hasListeners() + +```ts +hasListeners(): boolean; +``` + +Defined in: [packages/query-core/src/subscribable.ts:19](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L19) + +#### Returns + +`boolean` + +#### Inherited from + +```ts +Subscribable.hasListeners +``` + +*** + +### onSubscribe() + +```ts +protected onSubscribe(): void; +``` + +Defined in: [packages/query-core/src/queryObserver.ts:110](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L110) + +#### Returns + +`void` + +#### Overrides + +```ts +Subscribable.onSubscribe +``` + +*** + +### onUnsubscribe() + +```ts +protected onUnsubscribe(): void; +``` + +Defined in: [packages/query-core/src/queryObserver.ts:124](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L124) + +#### Returns + +`void` + +#### Overrides + +```ts +Subscribable.onUnsubscribe +``` + +*** + +### refetch() + +```ts +refetch(__namedParameters): Promise>; +``` + +Defined in: [packages/query-core/src/queryObserver.ts:371](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L371) + +Refetches the observed query and returns a promise that resolves with +the resulting `QueryObserverResult`. + +#### Parameters + +##### \_\_namedParameters + +[`RefetchOptions`](../interfaces/RefetchOptions.md) = `{}` + +#### Returns + +`Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> + +#### Example + +```ts +const result = await observer.refetch({ cancelRefetch: false }) +console.log(result.data) +``` + +*** + +### setOptions() + +```ts +setOptions(options): void; +``` + +Defined in: [packages/query-core/src/queryObserver.ts:182](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L182) + +Updates the observer's options. This will re-resolve the query being +observed (switching to a different query if the `queryKey` changed), +trigger a fetch if the new options require one and the observer has +subscribers, recompute the current result, and reschedule the stale and +refetch-interval timers as needed. + +#### Parameters + +##### options + +[`QueryObserverOptions`](../interfaces/QueryObserverOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryData`, `TQueryKey`\> + +#### Returns + +`void` + +#### Example + +```ts +observer.setOptions({ queryKey: ['posts', 1], queryFn: () => fetchPost(1) }) +// later: switch to a different query, reusing the same observer +observer.setOptions({ queryKey: ['posts', 2], queryFn: () => fetchPost(2) }) +``` + +*** + +### shouldFetchOnReconnect() + +```ts +shouldFetchOnReconnect(): boolean; +``` + +Defined in: [packages/query-core/src/queryObserver.ts:135](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L135) + +Returns whether the observed query is currently stale and configured +(via the `refetchOnReconnect` option) to refetch when the network +reconnects. + +#### Returns + +`boolean` + +*** + +### shouldFetchOnWindowFocus() + +```ts +shouldFetchOnWindowFocus(): boolean; +``` + +Defined in: [packages/query-core/src/queryObserver.ts:148](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L148) + +Returns whether the observed query is currently stale and configured +(via the `refetchOnWindowFocus` option) to refetch when the window +regains focus. + +#### Returns + +`boolean` + +*** + +### subscribe() + +```ts +subscribe(listener): () => void; +``` + +Defined in: [packages/query-core/src/subscribable.ts:8](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L8) + +#### Parameters + +##### listener + +`QueryObserverListener` + +#### Returns + +```ts +(): void; +``` + +##### Returns + +`void` + +#### Inherited from + +```ts +Subscribable.subscribe +``` + +*** + +### trackProp() + +```ts +trackProp(key): void; +``` + +Defined in: [packages/query-core/src/queryObserver.ts:350](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L350) + +Records that the given `QueryObserverResult` property was read, so a subsequent update only +notifies this observer if a tracked property actually changed. Normally called indirectly via +[QueryObserver#trackResult](#trackresult)'s proxy; exposed directly for adapters that track property +access themselves (e.g. through their own reactivity system) instead of via the proxy. + +#### Parameters + +##### key + +`"error"` | `"data"` | `"isError"` | `"isPending"` | `"isLoading"` | `"isLoadingError"` | `"isRefetchError"` | `"isSuccess"` | `"isPlaceholderData"` | `"status"` | `"dataUpdatedAt"` | `"errorUpdatedAt"` | `"failureCount"` | `"failureReason"` | `"errorUpdateCount"` | `"isFetched"` | `"isFetchedAfterMount"` | `"isFetching"` | `"isInitialLoading"` | `"isPaused"` | `"isRefetching"` | `"isStale"` | `"isEnabled"` | `"refetch"` | `"fetchStatus"` + +#### Returns + +`void` + +*** + +### trackResult() + +```ts +trackResult(result, onPropTracked?): QueryObserverResult; +``` + +Defined in: [packages/query-core/src/queryObserver.ts:331](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L331) + +Wraps a `QueryObserverResult` in a `Proxy` that records which properties are read, via +[QueryObserver#trackProp](#trackprop) (and an optional `onPropTracked` callback). Used by framework +adapters when `notifyOnChangeProps` is not set, to implement its default "only re-render on +properties you actually read" behavior. + +#### Parameters + +##### result + +[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\> + +##### onPropTracked? + +(`key`) => `void` + +#### Returns + +[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\> + +*** + +### updateResult() + +```ts +updateResult(): void; +``` + +Defined in: [packages/query-core/src/queryObserver.ts:735](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryObserver.ts#L735) + +Recomputes and stores the current result from the current query/options, notifying listeners +if it changed. Framework adapters call this right after subscribing to make sure no query +update was missed in the gap between creating the observer and subscribing to it. + +#### Returns + +`void` diff --git a/docs/framework/vue/reference/functions/defaultShouldDehydrateMutation.md b/docs/framework/vue/reference/functions/defaultShouldDehydrateMutation.md new file mode 100644 index 00000000000..940f8745a5d --- /dev/null +++ b/docs/framework/vue/reference/functions/defaultShouldDehydrateMutation.md @@ -0,0 +1,23 @@ +--- +id: defaultShouldDehydrateMutation +title: defaultShouldDehydrateMutation +--- + +```ts +function defaultShouldDehydrateMutation(mutation): boolean; +``` + +Defined in: [packages/query-core/src/hydration.ts:177](https://github.com/TanStack/query/blob/main/packages/query-core/src/hydration.ts#L177) + +The default `shouldDehydrateMutation` predicate used by `dehydrate`. Only dehydrates mutations that are +currently paused (e.g. paused by `networkMode` while offline). + +## Parameters + +### mutation + +[`Mutation`](../classes/Mutation.md) + +## Returns + +`boolean` diff --git a/docs/framework/vue/reference/functions/defaultShouldDehydrateQuery.md b/docs/framework/vue/reference/functions/defaultShouldDehydrateQuery.md new file mode 100644 index 00000000000..abf19439d8a --- /dev/null +++ b/docs/framework/vue/reference/functions/defaultShouldDehydrateQuery.md @@ -0,0 +1,23 @@ +--- +id: defaultShouldDehydrateQuery +title: defaultShouldDehydrateQuery +--- + +```ts +function defaultShouldDehydrateQuery(query): boolean; +``` + +Defined in: [packages/query-core/src/hydration.ts:185](https://github.com/TanStack/query/blob/main/packages/query-core/src/hydration.ts#L185) + +The default `shouldDehydrateQuery` predicate used by `dehydrate`. Only dehydrates queries whose status is +`'success'`. + +## Parameters + +### query + +[`Query`](../classes/Query.md) + +## Returns + +`boolean` diff --git a/docs/framework/vue/reference/functions/dehydrate.md b/docs/framework/vue/reference/functions/dehydrate.md new file mode 100644 index 00000000000..816469e6119 --- /dev/null +++ b/docs/framework/vue/reference/functions/dehydrate.md @@ -0,0 +1,43 @@ +--- +id: dehydrate +title: dehydrate +--- + +```ts +function dehydrate(client, options): DehydratedState; +``` + +Defined in: [packages/query-core/src/hydration.ts:207](https://github.com/TanStack/query/blob/main/packages/query-core/src/hydration.ts#L207) + +Dehydrates a `QueryClient`'s cache (queries and mutations) into a plain, serializable `DehydratedState`, +typically to embed in server-rendered markup and later restore into a client-side `QueryClient` via `hydrate`. +Which queries/mutations are included, and how their data/errors are transformed, is controlled by `options`, +falling back to the client's `dehydrate` default options, and finally to `defaultShouldDehydrateQuery` / +`defaultShouldDehydrateMutation`. + +## Parameters + +### client + +`QueryClient` + +### options + +[`DehydrateOptions`](../interfaces/DehydrateOptions.md) = `{}` + +## Returns + +[`DehydratedState`](../interfaces/DehydratedState.md) + +## Example + +```ts +const queryClient = new QueryClient() + +await queryClient.prefetchQuery({ + queryKey: ['posts'], + queryFn: getPosts, +}) + +const dehydratedState = dehydrate(queryClient) +``` diff --git a/docs/framework/vue/reference/functions/dehydrateQuery.md b/docs/framework/vue/reference/functions/dehydrateQuery.md new file mode 100644 index 00000000000..2314f52fd91 --- /dev/null +++ b/docs/framework/vue/reference/functions/dehydrateQuery.md @@ -0,0 +1,43 @@ +--- +id: dehydrateQuery +title: dehydrateQuery +--- + +```ts +function dehydrateQuery( + query, + serializeData?, + shouldRedactErrors?): DehydratedQuery; +``` + +Defined in: [packages/query-core/src/hydration.ts:148](https://github.com/TanStack/query/blob/main/packages/query-core/src/hydration.ts#L148) + +Dehydrates a single `Query` into a serializable `DehydratedQuery` snapshot. Note that most query config (e.g. +`queryFn`, `staleTime`) is not dehydrated but instead meant to be configured again when consuming the +de/rehydrated data, typically with `useQuery` on the client. If the query is still `pending`, its in-flight +promise is dehydrated too so it can be resumed on the other side instead of re-fetched. + +## Parameters + +### query + +[`Query`](../classes/Query.md) + +The query to dehydrate. + +### serializeData? + +`TransformerFn` + +Optional transform applied to `query.state.data` before it is included in the snapshot. + +### shouldRedactErrors? + +(`error`) => `boolean` + +Optional predicate; if it returns `false` for the promise's rejection error, that +error is kept as-is instead of being redacted. + +## Returns + +`DehydratedQuery` diff --git a/docs/framework/vue/reference/functions/experimental_streamedQuery.md b/docs/framework/vue/reference/functions/experimental_streamedQuery.md new file mode 100644 index 00000000000..4c490322d60 --- /dev/null +++ b/docs/framework/vue/reference/functions/experimental_streamedQuery.md @@ -0,0 +1,52 @@ +--- +id: experimental_streamedQuery +title: experimental_streamedQuery +--- + +```ts +function experimental_streamedQuery(streamFn): QueryFunction; +``` + +Defined in: [packages/query-core/src/streamedQuery.ts:75](https://github.com/TanStack/query/blob/main/packages/query-core/src/streamedQuery.ts#L75) + +This is a helper function to create a query function that streams data from an AsyncIterable. +Data will be an Array of all the chunks received. +The query will be in a 'pending' state until the first chunk of data is received, but will go to 'success' after that. +The query will stay in fetchStatus 'fetching' until the stream ends. + +## Type Parameters + +### TQueryFnData + +`TQueryFnData` = `unknown` + +### TData + +`TData` = `TQueryFnData`[] + +### TQueryKey + +`TQueryKey` *extends* readonly `unknown`[] = readonly `unknown`[] + +## Parameters + +### streamFn + +`StreamedQueryParams`\<`TQueryFnData`, `TData`, `TQueryKey`\> + +The function that returns an AsyncIterable to stream data from. + +## Returns + +[`QueryFunction`](../type-aliases/QueryFunction.md)\<`TData`, `TQueryKey`\> + +## Example + +```ts +await queryClient.query({ + queryKey: ['data'], + queryFn: streamedQuery({ + streamFn: fetchDataInChunks, + }), +}) +``` diff --git a/docs/framework/vue/reference/functions/hashKey.md b/docs/framework/vue/reference/functions/hashKey.md new file mode 100644 index 00000000000..dc774c032ce --- /dev/null +++ b/docs/framework/vue/reference/functions/hashKey.md @@ -0,0 +1,30 @@ +--- +id: hashKey +title: hashKey +--- + +```ts +function hashKey(queryKey): string; +``` + +Defined in: [packages/query-core/src/utils.ts:284](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L284) + +Default query & mutation keys hash function. +Hashes the value into a stable hash. + +## Parameters + +### queryKey + +readonly `unknown`[] + +## Returns + +`string` + +## Example + +```ts +// Object keys are sorted, so key order doesn't affect the hash: +hashKey(['todos', { page: 1, filter: 'done' }]) // === '["todos",{"filter":"done","page":1}]' +``` diff --git a/docs/framework/vue/reference/functions/hydrate.md b/docs/framework/vue/reference/functions/hydrate.md new file mode 100644 index 00000000000..0283d46b709 --- /dev/null +++ b/docs/framework/vue/reference/functions/hydrate.md @@ -0,0 +1,49 @@ +--- +id: hydrate +title: hydrate +--- + +```ts +function hydrate( + client, + dehydratedState, + options?): void; +``` + +Defined in: [packages/query-core/src/hydration.ts:264](https://github.com/TanStack/query/blob/main/packages/query-core/src/hydration.ts#L264) + +Restores a `DehydratedState` (as produced by `dehydrate`) into a `QueryClient`'s cache, typically to seed the +client with data already fetched on the server. `mutations` and `queries` are each optional on `dehydratedState`. +Queries not yet in the cache are built from the dehydrated snapshot; queries that already exist are only updated +when the dehydrated data is newer than what's already cached. Newly built queries have their `fetchStatus` reset +to `'idle'` so they don't hydrate stuck in a fetching state. If a dehydrated query still had an in-flight +promise, it is resumed via `query.fetch()` (reusing that promise as `initialPromise`) rather than re-invoking +`queryFn`. + +## Parameters + +### client + +`QueryClient` + +### dehydratedState + +`Partial`\<[`DehydratedState`](../interfaces/DehydratedState.md)\> + +### options? + +[`HydrateOptions`](../interfaces/HydrateOptions.md) + +## Returns + +`void` + +## Example + +```ts +// dehydratedState was produced by `dehydrate` on the server +// and sent to the client, e.g. embedded in server-rendered markup. +const queryClient = new QueryClient() + +hydrate(queryClient, dehydratedState) +``` diff --git a/docs/framework/vue/reference/functions/infiniteQueryOptions.md b/docs/framework/vue/reference/functions/infiniteQueryOptions.md index 564d4cc8258..d3bd0bef5fd 100644 --- a/docs/framework/vue/reference/functions/infiniteQueryOptions.md +++ b/docs/framework/vue/reference/functions/infiniteQueryOptions.md @@ -9,7 +9,7 @@ title: infiniteQueryOptions function infiniteQueryOptions(options): UndefinedInitialDataInfiniteOptions & QueryKeyWithDataTag, TError>; ``` -Defined in: [vue-query/src/infiniteQueryOptions.ts:99](https://github.com/TanStack/query/blob/main/packages/vue-query/src/infiniteQueryOptions.ts#L99) +Defined in: [packages/vue-query/src/infiniteQueryOptions.ts:99](https://github.com/TanStack/query/blob/main/packages/vue-query/src/infiniteQueryOptions.ts#L99) You can generally pass everything to `infiniteQueryOptions` that you can also pass to `useInfiniteQuery`. These options can be shared across hooks and imperative APIs such as `queryClient.infiniteQuery`. @@ -27,7 +27,7 @@ These options can be shared across hooks and imperative APIs such as `queryClien #### TData -`TData` = `InfiniteData`\<`TQueryFnData`, `unknown`\> +`TData` = [`InfiniteData`](../interfaces/InfiniteData.md)\<`TQueryFnData`, `unknown`\> #### TQueryKey @@ -48,7 +48,7 @@ The [UndefinedInitialDataInfiniteOptions](../type-aliases/UndefinedInitialDataIn ### Returns -[`UndefinedInitialDataInfiniteOptions`](../type-aliases/UndefinedInitialDataInfiniteOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`, `TPageParam`\> & `QueryKeyWithDataTag`\<`TQueryKey`, `InfiniteData`\<`TQueryFnData`, `unknown`\>, `TError`\> +[`UndefinedInitialDataInfiniteOptions`](../type-aliases/UndefinedInitialDataInfiniteOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`, `TPageParam`\> & [`QueryKeyWithDataTag`](../type-aliases/QueryKeyWithDataTag.md)\<`TQueryKey`, [`InfiniteData`](../interfaces/InfiniteData.md)\<`TQueryFnData`, `unknown`\>, `TError`\> The same options object, typed so that `queryKey` carries the inferred data type. @@ -79,7 +79,7 @@ const { data, isError, error, fetchNextPage } = useInfiniteQuery(projectsOptions function infiniteQueryOptions(options): DefinedInitialDataInfiniteOptions & QueryKeyWithDataTag, TError>; ``` -Defined in: [vue-query/src/infiniteQueryOptions.ts:153](https://github.com/TanStack/query/blob/main/packages/vue-query/src/infiniteQueryOptions.ts#L153) +Defined in: [packages/vue-query/src/infiniteQueryOptions.ts:153](https://github.com/TanStack/query/blob/main/packages/vue-query/src/infiniteQueryOptions.ts#L153) You can generally pass everything to `infiniteQueryOptions` that you can also pass to `useInfiniteQuery`. These options can be shared across hooks and imperative APIs such as `queryClient.infiniteQuery`. @@ -99,7 +99,7 @@ This overload is selected when `initialData` is set, so the resulting `data` is #### TData -`TData` = `InfiniteData`\<`TQueryFnData`, `unknown`\> +`TData` = [`InfiniteData`](../interfaces/InfiniteData.md)\<`TQueryFnData`, `unknown`\> #### TQueryKey @@ -120,7 +120,7 @@ The [DefinedInitialDataInfiniteOptions](../type-aliases/DefinedInitialDataInfini ### Returns -[`DefinedInitialDataInfiniteOptions`](../type-aliases/DefinedInitialDataInfiniteOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`, `TPageParam`\> & `QueryKeyWithDataTag`\<`TQueryKey`, `InfiniteData`\<`TQueryFnData`, `unknown`\>, `TError`\> +[`DefinedInitialDataInfiniteOptions`](../type-aliases/DefinedInitialDataInfiniteOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`, `TPageParam`\> & [`QueryKeyWithDataTag`](../type-aliases/QueryKeyWithDataTag.md)\<`TQueryKey`, [`InfiniteData`](../interfaces/InfiniteData.md)\<`TQueryFnData`, `unknown`\>, `TError`\> The same options object, typed so that `queryKey` carries the inferred data type. diff --git a/docs/framework/vue/reference/functions/isCancelledError.md b/docs/framework/vue/reference/functions/isCancelledError.md new file mode 100644 index 00000000000..c8f57c4b94d --- /dev/null +++ b/docs/framework/vue/reference/functions/isCancelledError.md @@ -0,0 +1,24 @@ +--- +id: isCancelledError +title: isCancelledError +--- + +```ts +function isCancelledError(value): value is CancelledError; +``` + +Defined in: [packages/query-core/src/retryer.ts:90](https://github.com/TanStack/query/blob/main/packages/query-core/src/retryer.ts#L90) + +## Parameters + +### value + +`any` + +## Returns + +`value is CancelledError` + +## Deprecated + +Use instanceof `CancelledError` instead. diff --git a/docs/framework/vue/reference/functions/keepPreviousData.md b/docs/framework/vue/reference/functions/keepPreviousData.md new file mode 100644 index 00000000000..6a84f4c5970 --- /dev/null +++ b/docs/framework/vue/reference/functions/keepPreviousData.md @@ -0,0 +1,40 @@ +--- +id: keepPreviousData +title: keepPreviousData +--- + +```ts +function keepPreviousData(previousData): T | undefined; +``` + +Defined in: [packages/query-core/src/utils.ts:493](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L493) + +Intended to be passed as a query's `placeholderData` option, for example +`placeholderData: keepPreviousData`. Instead of resetting the query's data to `undefined` while a new +query key is fetching, it keeps displaying the previously fetched data until the new data arrives. + +## Type Parameters + +### T + +`T` + +## Parameters + +### previousData + +`T` | `undefined` + +## Returns + +`T` \| `undefined` + +## Example + +```ts +new QueryObserver(queryClient, { + queryKey: ['posts', page], + queryFn: () => fetchPosts(page), + placeholderData: keepPreviousData, +}) +``` diff --git a/docs/framework/vue/reference/functions/matchMutation.md b/docs/framework/vue/reference/functions/matchMutation.md new file mode 100644 index 00000000000..9d91464e098 --- /dev/null +++ b/docs/framework/vue/reference/functions/matchMutation.md @@ -0,0 +1,38 @@ +--- +id: matchMutation +title: matchMutation +--- + +```ts +function matchMutation(filters, mutation): boolean; +``` + +Defined in: [packages/query-core/src/utils.ts:237](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L237) + +Checks whether a mutation matches the given [MutationFilters](../type-aliases/MutationFilters.md). +Every filter that is specified must match; filters that are left unspecified are ignored. +If a `mutationKey` filter is provided but the mutation has no `mutationKey` of its own, it does not match. + +## Parameters + +### filters + +`MutationFilters` + +### mutation + +[`Mutation`](../classes/Mutation.md)\<`any`, `any`\> + +## Returns + +`boolean` + +## Example + +```ts +const mutationCache = queryClient.getMutationCache() + +const matchingMutations = mutationCache + .getAll() + .filter((mutation) => matchMutation({ mutationKey: ['addPost'] }, mutation)) +``` diff --git a/docs/framework/vue/reference/functions/matchQuery.md b/docs/framework/vue/reference/functions/matchQuery.md new file mode 100644 index 00000000000..d052d0abcd4 --- /dev/null +++ b/docs/framework/vue/reference/functions/matchQuery.md @@ -0,0 +1,37 @@ +--- +id: matchQuery +title: matchQuery +--- + +```ts +function matchQuery(filters, query): boolean; +``` + +Defined in: [packages/query-core/src/utils.ts:175](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L175) + +Checks whether a query matches the given [QueryFilters](../type-aliases/QueryFilters.md). +Every filter that is specified must match; filters that are left unspecified are ignored. + +## Parameters + +### filters + +`QueryFilters` + +### query + +[`Query`](../classes/Query.md)\<`any`, `any`, `any`, `any`\> + +## Returns + +`boolean` + +## Example + +```ts +const queryCache = queryClient.getQueryCache() + +const matchingQueries = queryCache + .getAll() + .filter((query) => matchQuery({ queryKey: ['posts'] }, query)) +``` diff --git a/docs/framework/vue/reference/functions/mutationOptions.md b/docs/framework/vue/reference/functions/mutationOptions.md index fdf3af339b7..04c7166203b 100644 --- a/docs/framework/vue/reference/functions/mutationOptions.md +++ b/docs/framework/vue/reference/functions/mutationOptions.md @@ -9,7 +9,7 @@ title: mutationOptions function mutationOptions(options): WithRequired, "mutationKey">; ``` -Defined in: [vue-query/src/mutationOptions.ts:34](https://github.com/TanStack/query/blob/main/packages/vue-query/src/mutationOptions.ts#L34) +Defined in: [packages/vue-query/src/mutationOptions.ts:34](https://github.com/TanStack/query/blob/main/packages/vue-query/src/mutationOptions.ts#L34) You can generally pass everything to `mutationOptions` that you can also pass to `useMutation`. A `mutationKey` is required on this overload so the mutation can be looked up later, e.g. with @@ -37,14 +37,14 @@ You can generally pass everything to `mutationOptions` that you can also pass to #### options -`WithRequired`\<[`MutationOptions`](../type-aliases/MutationOptions.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\>, `"mutationKey"`\> +[`WithRequired`](../type-aliases/WithRequired.md)\<[`MutationOptions`](../type-aliases/MutationOptions.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\>, `"mutationKey"`\> The mutation options to use, identical to what you'd pass to `useMutation`, with a required `mutationKey`. ### Returns -`WithRequired`\<[`MutationOptions`](../type-aliases/MutationOptions.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\>, `"mutationKey"`\> +[`WithRequired`](../type-aliases/WithRequired.md)\<[`MutationOptions`](../type-aliases/MutationOptions.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\>, `"mutationKey"`\> The same options object, unchanged. @@ -79,7 +79,7 @@ const isCreatingPost = computed(() => creatingPosts.value.length > 0) function mutationOptions(options): () => WithRequired, "mutationKey">; ``` -Defined in: [vue-query/src/mutationOptions.ts:80](https://github.com/TanStack/query/blob/main/packages/vue-query/src/mutationOptions.ts#L80) +Defined in: [packages/vue-query/src/mutationOptions.ts:80](https://github.com/TanStack/query/blob/main/packages/vue-query/src/mutationOptions.ts#L80) Same as the plain-object overload with a required `mutationKey`, but for options that close over reactive state (`ref`s read inside the function body). Wrap them in a getter so `useMutation` and the other consumers @@ -107,7 +107,7 @@ always read the current values instead of the ones captured when the options wer #### options -() => `WithRequired`\<[`MutationOptions`](../type-aliases/MutationOptions.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\>, `"mutationKey"`\> +() => [`WithRequired`](../type-aliases/WithRequired.md)\<[`MutationOptions`](../type-aliases/MutationOptions.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\>, `"mutationKey"`\> A function returning the mutation options to use, with a required `mutationKey`, re-evaluated on demand. @@ -122,7 +122,7 @@ A function that returns the same options object, unchanged. #### Returns -`WithRequired`\<[`MutationOptions`](../type-aliases/MutationOptions.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\>, `"mutationKey"`\> +[`WithRequired`](../type-aliases/WithRequired.md)\<[`MutationOptions`](../type-aliases/MutationOptions.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\>, `"mutationKey"`\> ### See @@ -156,7 +156,7 @@ const mutation = useMutation(createPostOptions) function mutationOptions(options): Omit, "mutationKey">; ``` -Defined in: [vue-query/src/mutationOptions.ts:124](https://github.com/TanStack/query/blob/main/packages/vue-query/src/mutationOptions.ts#L124) +Defined in: [packages/vue-query/src/mutationOptions.ts:124](https://github.com/TanStack/query/blob/main/packages/vue-query/src/mutationOptions.ts#L124) You can generally pass everything to `mutationOptions` that you can also pass to `useMutation`. No `mutationKey` is required on this overload — use this when you don't need to target the mutation via a @@ -228,7 +228,7 @@ const mutation = useMutation(createPostOptions) function mutationOptions(options): () => Omit, "mutationKey">; ``` -Defined in: [vue-query/src/mutationOptions.ts:169](https://github.com/TanStack/query/blob/main/packages/vue-query/src/mutationOptions.ts#L169) +Defined in: [packages/vue-query/src/mutationOptions.ts:169](https://github.com/TanStack/query/blob/main/packages/vue-query/src/mutationOptions.ts#L169) Same as the plain-object overload without a `mutationKey`, but for options that close over reactive state (`ref`s read inside the function body). Wrap them in a getter so `useMutation` and the other consumers diff --git a/docs/framework/vue/reference/functions/noop.md b/docs/framework/vue/reference/functions/noop.md new file mode 100644 index 00000000000..01fb409f4e9 --- /dev/null +++ b/docs/framework/vue/reference/functions/noop.md @@ -0,0 +1,32 @@ +--- +id: noop +title: noop +--- + +## Call Signature + +```ts +function noop(): void; +``` + +Defined in: [packages/query-core/src/utils.ts:119](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L119) + +A function that does nothing. + +### Returns + +`void` + +## Call Signature + +```ts +function noop(): undefined; +``` + +Defined in: [packages/query-core/src/utils.ts:120](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L120) + +A function that does nothing. + +### Returns + +`undefined` diff --git a/docs/framework/vue/reference/functions/partialMatchKey.md b/docs/framework/vue/reference/functions/partialMatchKey.md new file mode 100644 index 00000000000..4db67323e9b --- /dev/null +++ b/docs/framework/vue/reference/functions/partialMatchKey.md @@ -0,0 +1,26 @@ +--- +id: partialMatchKey +title: partialMatchKey +--- + +```ts +function partialMatchKey(a, b): boolean; +``` + +Defined in: [packages/query-core/src/utils.ts:300](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L300) + +Checks if key `b` partially matches with key `a`. + +## Parameters + +### a + +readonly `unknown`[] + +### b + +readonly `unknown`[] + +## Returns + +`boolean` diff --git a/docs/framework/vue/reference/functions/queryOptions.md b/docs/framework/vue/reference/functions/queryOptions.md index 812e61478e0..2745dfdd55e 100644 --- a/docs/framework/vue/reference/functions/queryOptions.md +++ b/docs/framework/vue/reference/functions/queryOptions.md @@ -9,7 +9,7 @@ title: queryOptions function queryOptions(options): DefinedInitialQueryOptionsWithDataTag; ``` -Defined in: [vue-query/src/queryOptions.ts:168](https://github.com/TanStack/query/blob/main/packages/vue-query/src/queryOptions.ts#L168) +Defined in: [packages/vue-query/src/queryOptions.ts:168](https://github.com/TanStack/query/blob/main/packages/vue-query/src/queryOptions.ts#L168) You can generally pass everything to `queryOptions` that you can also pass to `useQuery`. These options can be shared across hooks and imperative APIs such as `queryClient.query`. `options.queryKey` is required and @@ -78,7 +78,7 @@ const { data, isError, error } = useQuery(postsOptions) function queryOptions(options): () => DefinedInitialQueryOptionsWithDataTag; ``` -Defined in: [vue-query/src/queryOptions.ts:205](https://github.com/TanStack/query/blob/main/packages/vue-query/src/queryOptions.ts#L205) +Defined in: [packages/vue-query/src/queryOptions.ts:205](https://github.com/TanStack/query/blob/main/packages/vue-query/src/queryOptions.ts#L205) Same as the plain-object overload, but for options that close over reactive state (`ref`s read inside the function body). Wrap them in a getter so `queryClient` methods like `invalidateQueries`/`fetchQuery` always @@ -152,7 +152,7 @@ const { data } = useQuery(postOptions) function queryOptions(options): UndefinedInitialQueryOptionsWithDataTag; ``` -Defined in: [vue-query/src/queryOptions.ts:250](https://github.com/TanStack/query/blob/main/packages/vue-query/src/queryOptions.ts#L250) +Defined in: [packages/vue-query/src/queryOptions.ts:250](https://github.com/TanStack/query/blob/main/packages/vue-query/src/queryOptions.ts#L250) You can generally pass everything to `queryOptions` that you can also pass to `useQuery`. These options can be shared across hooks and imperative APIs such as `queryClient.query`. `options.queryKey` is required and @@ -218,7 +218,7 @@ const { data, isPending, isError, error } = useQuery(postOptions('1')) function queryOptions(options): () => UndefinedInitialQueryOptionsWithDataTag; ``` -Defined in: [vue-query/src/queryOptions.ts:316](https://github.com/TanStack/query/blob/main/packages/vue-query/src/queryOptions.ts#L316) +Defined in: [packages/vue-query/src/queryOptions.ts:316](https://github.com/TanStack/query/blob/main/packages/vue-query/src/queryOptions.ts#L316) Same as the plain-object overload, but for options that close over reactive state (`ref`s read inside the function body). Wrap them in a getter so the `queryKey` — and anything else derived from a `ref` — reacts diff --git a/docs/framework/vue/reference/functions/replaceEqualDeep.md b/docs/framework/vue/reference/functions/replaceEqualDeep.md new file mode 100644 index 00000000000..6a81c3907fb --- /dev/null +++ b/docs/framework/vue/reference/functions/replaceEqualDeep.md @@ -0,0 +1,41 @@ +--- +id: replaceEqualDeep +title: replaceEqualDeep +--- + +```ts +function replaceEqualDeep( + a, + b, + depth?): T; +``` + +Defined in: [packages/query-core/src/utils.ts:339](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L339) + +This function returns `a` if `b` is deeply equal. +If not, it will replace any deeply equal children of `b` with those of `a`. +This can be used for structural sharing between JSON values for example. + +## Type Parameters + +### T + +`T` + +## Parameters + +### a + +`unknown` + +### b + +`T` + +### depth? + +`number` + +## Returns + +`T` diff --git a/docs/framework/vue/reference/functions/shouldThrowError.md b/docs/framework/vue/reference/functions/shouldThrowError.md new file mode 100644 index 00000000000..1f1e62a8d0e --- /dev/null +++ b/docs/framework/vue/reference/functions/shouldThrowError.md @@ -0,0 +1,45 @@ +--- +id: shouldThrowError +title: shouldThrowError +--- + +```ts +function shouldThrowError(throwOnError, params): boolean; +``` + +Defined in: [packages/query-core/src/utils.ts:576](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L576) + +Resolves a `throwOnError` option to a boolean. +If `throwOnError` is a function, it is called with `params` (e.g. the error and, depending on the caller, +additional context such as the query or mutation) and its result is returned, allowing the throwing +behavior to be decided per error. Otherwise, `throwOnError` itself is coerced to a boolean (`undefined` +resolves to `false`). + +## Type Parameters + +### T + +`T` *extends* (...`args`) => `boolean` + +## Parameters + +### throwOnError + +`boolean` | `T` | `undefined` + +### params + +`Parameters`\<`T`\> + +## Returns + +`boolean` + +## Example + +```ts +const throwOnError = + query.state.error && typeof options.throwOnError === 'function' + ? shouldThrowError(options.throwOnError, [query.state.error, query]) + : options.throwOnError +``` diff --git a/docs/framework/vue/reference/functions/useInfiniteQuery.md b/docs/framework/vue/reference/functions/useInfiniteQuery.md index c41b2af7691..83f022d402e 100644 --- a/docs/framework/vue/reference/functions/useInfiniteQuery.md +++ b/docs/framework/vue/reference/functions/useInfiniteQuery.md @@ -9,7 +9,7 @@ title: useInfiniteQuery function useInfiniteQuery(options, queryClient?): UseInfiniteQueryReturnType; ``` -Defined in: [vue-query/src/useInfiniteQuery.ts:117](https://github.com/TanStack/query/blob/main/packages/vue-query/src/useInfiniteQuery.ts#L117) +Defined in: [packages/vue-query/src/useInfiniteQuery.ts:117](https://github.com/TanStack/query/blob/main/packages/vue-query/src/useInfiniteQuery.ts#L117) The options for `useInfiniteQuery` are identical to `useQuery`, with the addition of `initialPageParam`, `getNextPageParam`, `getPreviousPageParam`, and `maxPages`. @@ -32,7 +32,7 @@ individual entries — the array itself can't be a bare getter. #### TData -`TData` = `InfiniteData`\<`TQueryFnData`, `unknown`\> +`TData` = [`InfiniteData`](../interfaces/InfiniteData.md)\<`TQueryFnData`, `unknown`\> #### TQueryKey @@ -106,7 +106,7 @@ const { data, isError, error } = useInfiniteQuery({ function useInfiniteQuery(options, queryClient?): UseInfiniteQueryReturnType; ``` -Defined in: [vue-query/src/useInfiniteQuery.ts:251](https://github.com/TanStack/query/blob/main/packages/vue-query/src/useInfiniteQuery.ts#L251) +Defined in: [packages/vue-query/src/useInfiniteQuery.ts:251](https://github.com/TanStack/query/blob/main/packages/vue-query/src/useInfiniteQuery.ts#L251) The options for `useInfiniteQuery` are identical to `useQuery`, with the addition of `initialPageParam`, `getNextPageParam`, `getPreviousPageParam`, and `maxPages`. @@ -127,7 +127,7 @@ individual entries — the array itself can't be a bare getter. #### TData -`TData` = `InfiniteData`\<`TQueryFnData`, `unknown`\> +`TData` = [`InfiniteData`](../interfaces/InfiniteData.md)\<`TQueryFnData`, `unknown`\> #### TQueryKey @@ -269,7 +269,7 @@ onUnmounted(() => observer?.disconnect()) function useInfiniteQuery(options, queryClient?): UseInfiniteQueryReturnType; ``` -Defined in: [vue-query/src/useInfiniteQuery.ts:347](https://github.com/TanStack/query/blob/main/packages/vue-query/src/useInfiniteQuery.ts#L347) +Defined in: [packages/vue-query/src/useInfiniteQuery.ts:347](https://github.com/TanStack/query/blob/main/packages/vue-query/src/useInfiniteQuery.ts#L347) Fallback overload for options whose `initialData` presence isn't statically known — for example, a `ref`/reactive object built up conditionally, rather than a plain object literal. Prefer one of the other @@ -291,7 +291,7 @@ individual entries — the array itself can't be a bare getter. #### TData -`TData` = `InfiniteData`\<`TQueryFnData`, `unknown`\> +`TData` = [`InfiniteData`](../interfaces/InfiniteData.md)\<`TQueryFnData`, `unknown`\> #### TQueryKey diff --git a/docs/framework/vue/reference/functions/useIsFetching.md b/docs/framework/vue/reference/functions/useIsFetching.md index 3f4a5ea6495..d4b625520a0 100644 --- a/docs/framework/vue/reference/functions/useIsFetching.md +++ b/docs/framework/vue/reference/functions/useIsFetching.md @@ -7,7 +7,7 @@ title: useIsFetching function useIsFetching(fetchingFilters, queryClient?): Ref; ``` -Defined in: [vue-query/src/useIsFetching.ts:52](https://github.com/TanStack/query/blob/main/packages/vue-query/src/useIsFetching.ts#L52) +Defined in: [packages/vue-query/src/useIsFetching.ts:52](https://github.com/TanStack/query/blob/main/packages/vue-query/src/useIsFetching.ts#L52) The `useIsFetching` composable returns a `ref` to the `number` of the queries that your application is loading or fetching in the background (useful for app-wide loading indicators). diff --git a/docs/framework/vue/reference/functions/useIsMutating.md b/docs/framework/vue/reference/functions/useIsMutating.md index fc46618834b..8c61c366387 100644 --- a/docs/framework/vue/reference/functions/useIsMutating.md +++ b/docs/framework/vue/reference/functions/useIsMutating.md @@ -7,7 +7,7 @@ title: useIsMutating function useIsMutating(filters, queryClient?): Ref; ``` -Defined in: [vue-query/src/useMutationState.ts:49](https://github.com/TanStack/query/blob/main/packages/vue-query/src/useMutationState.ts#L49) +Defined in: [packages/vue-query/src/useMutationState.ts:49](https://github.com/TanStack/query/blob/main/packages/vue-query/src/useMutationState.ts#L49) The `useIsMutating` composable returns a `ref` to the `number` of mutations that your application currently has `pending` (useful for app-wide loading indicators). diff --git a/docs/framework/vue/reference/functions/useMutation.md b/docs/framework/vue/reference/functions/useMutation.md index 9ec0c218da0..0a749c571ed 100644 --- a/docs/framework/vue/reference/functions/useMutation.md +++ b/docs/framework/vue/reference/functions/useMutation.md @@ -7,7 +7,7 @@ title: useMutation function useMutation(options, queryClient?): UseMutationReturnType; ``` -Defined in: [vue-query/src/useMutation.ts:231](https://github.com/TanStack/query/blob/main/packages/vue-query/src/useMutation.ts#L231) +Defined in: [packages/vue-query/src/useMutation.ts:231](https://github.com/TanStack/query/blob/main/packages/vue-query/src/useMutation.ts#L231) Unlike queries, mutations are typically used to create/update/delete data or perform server side-effects. `useMutation` is the composable for that. diff --git a/docs/framework/vue/reference/functions/useMutationState.md b/docs/framework/vue/reference/functions/useMutationState.md index c09346c2d17..5956266c1a3 100644 --- a/docs/framework/vue/reference/functions/useMutationState.md +++ b/docs/framework/vue/reference/functions/useMutationState.md @@ -7,7 +7,7 @@ title: useMutationState function useMutationState(options, queryClient?): Readonly>; ``` -Defined in: [vue-query/src/useMutationState.ts:192](https://github.com/TanStack/query/blob/main/packages/vue-query/src/useMutationState.ts#L192) +Defined in: [packages/vue-query/src/useMutationState.ts:192](https://github.com/TanStack/query/blob/main/packages/vue-query/src/useMutationState.ts#L192) `useMutationState` is a composable that gives you access to all mutations in the `MutationCache`. You can pass `filters` ([MutationFilters](../type-aliases/MutationFilters.md)) to narrow down your mutations, and `select` to transform the @@ -20,11 +20,11 @@ themselves depend on other reactive state. ### TResult -`TResult` = `MutationState`\<`unknown`, `Error`, `unknown`, `unknown`\> +`TResult` = [`MutationState`](../interfaces/MutationState.md)\<`unknown`, `Error`, `unknown`, `unknown`\> ### TMutation -`TMutation` *extends* `Mutation`\<`any`, `any`, `any`, `any`\> = `MutationTypeFromResult`\<`TResult`\> +`TMutation` *extends* [`Mutation`](../classes/Mutation.md)\<`any`, `any`, `any`, `any`\> = `MutationTypeFromResult`\<`TResult`\> ## Parameters diff --git a/docs/framework/vue/reference/functions/usePrefetchInfiniteQuery.md b/docs/framework/vue/reference/functions/usePrefetchInfiniteQuery.md index f2278bd02fd..d2c92fe5c44 100644 --- a/docs/framework/vue/reference/functions/usePrefetchInfiniteQuery.md +++ b/docs/framework/vue/reference/functions/usePrefetchInfiniteQuery.md @@ -7,7 +7,7 @@ title: usePrefetchInfiniteQuery function usePrefetchInfiniteQuery(options, queryClient?): void; ``` -Defined in: [vue-query/src/usePrefetchInfiniteQuery.ts:94](https://github.com/TanStack/query/blob/main/packages/vue-query/src/usePrefetchInfiniteQuery.ts#L94) +Defined in: [packages/vue-query/src/usePrefetchInfiniteQuery.ts:94](https://github.com/TanStack/query/blob/main/packages/vue-query/src/usePrefetchInfiniteQuery.ts#L94) `usePrefetchInfiniteQuery` does not return anything — it fires a prefetch as a reactive side effect, useful for kicking off a fetch ahead of the component that will actually render the data with `useInfiniteQuery`. @@ -38,7 +38,7 @@ Fire this during render, before a suspense boundary that wraps a component using ### TData -`TData` = `InfiniteData`\<`TQueryFnData`, `unknown`\> +`TData` = [`InfiniteData`](../interfaces/InfiniteData.md)\<`TQueryFnData`, `unknown`\> ### TQueryKey diff --git a/docs/framework/vue/reference/functions/usePrefetchQuery.md b/docs/framework/vue/reference/functions/usePrefetchQuery.md index 873c8437506..e9c6aa823ec 100644 --- a/docs/framework/vue/reference/functions/usePrefetchQuery.md +++ b/docs/framework/vue/reference/functions/usePrefetchQuery.md @@ -7,7 +7,7 @@ title: usePrefetchQuery function usePrefetchQuery(options, queryClient?): void; ``` -Defined in: [vue-query/src/usePrefetchQuery.ts:86](https://github.com/TanStack/query/blob/main/packages/vue-query/src/usePrefetchQuery.ts#L86) +Defined in: [packages/vue-query/src/usePrefetchQuery.ts:86](https://github.com/TanStack/query/blob/main/packages/vue-query/src/usePrefetchQuery.ts#L86) `usePrefetchQuery` does not return anything — it fires a prefetch as a reactive side effect, useful for kicking off a fetch ahead of the component that will actually render the data with `useQuery`. You can pass diff --git a/docs/framework/vue/reference/functions/useQueries.md b/docs/framework/vue/reference/functions/useQueries.md index cc5c587b8c7..39f4d4229ad 100644 --- a/docs/framework/vue/reference/functions/useQueries.md +++ b/docs/framework/vue/reference/functions/useQueries.md @@ -7,7 +7,7 @@ title: useQueries function useQueries(__namedParameters, queryClient?): Readonly>; ``` -Defined in: [vue-query/src/useQueries.ts:357](https://github.com/TanStack/query/blob/main/packages/vue-query/src/useQueries.ts#L357) +Defined in: [packages/vue-query/src/useQueries.ts:357](https://github.com/TanStack/query/blob/main/packages/vue-query/src/useQueries.ts#L357) The `useQueries` composable can be used to fetch a variable number of queries. diff --git a/docs/framework/vue/reference/functions/useQuery.md b/docs/framework/vue/reference/functions/useQuery.md index d27c031cdd8..6604d955202 100644 --- a/docs/framework/vue/reference/functions/useQuery.md +++ b/docs/framework/vue/reference/functions/useQuery.md @@ -9,7 +9,7 @@ title: useQuery function useQuery(options, queryClient?): UseQueryDefinedReturnType; ``` -Defined in: [vue-query/src/useQuery.ts:138](https://github.com/TanStack/query/blob/main/packages/vue-query/src/useQuery.ts#L138) +Defined in: [packages/vue-query/src/useQuery.ts:138](https://github.com/TanStack/query/blob/main/packages/vue-query/src/useQuery.ts#L138) This overload is selected when `initialData` is set, so the resulting `data` is never `undefined`. @@ -88,7 +88,7 @@ const { data, isError, error } = useQuery({ function useQuery(options, queryClient?): UseQueryReturnType; ``` -Defined in: [vue-query/src/useQuery.ts:279](https://github.com/TanStack/query/blob/main/packages/vue-query/src/useQuery.ts#L279) +Defined in: [packages/vue-query/src/useQuery.ts:279](https://github.com/TanStack/query/blob/main/packages/vue-query/src/useQuery.ts#L279) `enabled` tracks reactive dependencies automatically as a `ref`, a plain value, or a reactive getter (`() => ...`). `queryKey` reacts through a `ref` for the array itself, or `ref`s and reactive getters as @@ -257,7 +257,7 @@ const { data, isPlaceholderData, isError, error } = useQuery({ function useQuery(options, queryClient?): UseQueryReturnType; ``` -Defined in: [vue-query/src/useQuery.ts:355](https://github.com/TanStack/query/blob/main/packages/vue-query/src/useQuery.ts#L355) +Defined in: [packages/vue-query/src/useQuery.ts:355](https://github.com/TanStack/query/blob/main/packages/vue-query/src/useQuery.ts#L355) Fallback overload for options whose `initialData` presence isn't statically known — for example, a `ref`/reactive object built up conditionally, rather than a plain object literal. Prefer one of the other diff --git a/docs/framework/vue/reference/functions/useQueryClient.md b/docs/framework/vue/reference/functions/useQueryClient.md index d605ababd9c..b229c52ef00 100644 --- a/docs/framework/vue/reference/functions/useQueryClient.md +++ b/docs/framework/vue/reference/functions/useQueryClient.md @@ -7,7 +7,7 @@ title: useQueryClient function useQueryClient(id): QueryClient; ``` -Defined in: [vue-query/src/useQueryClient.ts:27](https://github.com/TanStack/query/blob/main/packages/vue-query/src/useQueryClient.ts#L27) +Defined in: [packages/vue-query/src/useQueryClient.ts:27](https://github.com/TanStack/query/blob/main/packages/vue-query/src/useQueryClient.ts#L27) Retrieves the `QueryClient` installed by `VueQueryPlugin`, via Vue's `inject`. Must be called inside `setup()` or another function that supports an injection context. diff --git a/docs/framework/vue/reference/index.md b/docs/framework/vue/reference/index.md index 00eac42f674..69bc24c81c7 100644 --- a/docs/framework/vue/reference/index.md +++ b/docs/framework/vue/reference/index.md @@ -5,23 +5,145 @@ title: "@tanstack/vue-query" ## Classes +- [CancelledError](classes/CancelledError.md) +- [InfiniteQueryObserver](classes/InfiniteQueryObserver.md) +- [Mutation](classes/Mutation.md) - [MutationCache](classes/MutationCache.md) +- [MutationObserver](classes/MutationObserver.md) +- [QueriesObserver](classes/QueriesObserver.md) +- [Query](classes/Query.md) - [QueryCache](classes/QueryCache.md) - [QueryClient](classes/QueryClient.md) +- [QueryObserver](classes/QueryObserver.md) + +## Interfaces + +- [CancelOptions](interfaces/CancelOptions.md) +- [DefaultOptions](interfaces/DefaultOptions.md) +- [DehydratedState](interfaces/DehydratedState.md) +- [DehydrateOptions](interfaces/DehydrateOptions.md) +- [~~EnsureQueryDataOptions~~](interfaces/EnsureQueryDataOptions.md) +- [FetchNextPageOptions](interfaces/FetchNextPageOptions.md) +- [FetchPreviousPageOptions](interfaces/FetchPreviousPageOptions.md) +- [~~FetchQueryOptions~~](interfaces/FetchQueryOptions.md) +- [FocusManager](interfaces/FocusManager.md) +- [HydrateOptions](interfaces/HydrateOptions.md) +- [InfiniteData](interfaces/InfiniteData.md) +- [InfiniteQueryObserverBaseResult](interfaces/InfiniteQueryObserverBaseResult.md) +- [InfiniteQueryObserverLoadingErrorResult](interfaces/InfiniteQueryObserverLoadingErrorResult.md) +- [InfiniteQueryObserverLoadingResult](interfaces/InfiniteQueryObserverLoadingResult.md) +- [InfiniteQueryObserverOptions](interfaces/InfiniteQueryObserverOptions.md) +- [InfiniteQueryObserverPendingResult](interfaces/InfiniteQueryObserverPendingResult.md) +- [InfiniteQueryObserverPlaceholderResult](interfaces/InfiniteQueryObserverPlaceholderResult.md) +- [InfiniteQueryObserverRefetchErrorResult](interfaces/InfiniteQueryObserverRefetchErrorResult.md) +- [InfiniteQueryObserverSuccessResult](interfaces/InfiniteQueryObserverSuccessResult.md) +- [InfiniteQueryPageParamsOptions](interfaces/InfiniteQueryPageParamsOptions.md) +- [InitialPageParam](interfaces/InitialPageParam.md) +- [InvalidateOptions](interfaces/InvalidateOptions.md) +- [InvalidateQueryFilters](interfaces/InvalidateQueryFilters.md) +- [MutateOptions](interfaces/MutateOptions.md) +- [MutationCacheConfig](interfaces/MutationCacheConfig.md) +- [MutationObserverBaseResult](interfaces/MutationObserverBaseResult.md) +- [MutationObserverErrorResult](interfaces/MutationObserverErrorResult.md) +- [MutationObserverIdleResult](interfaces/MutationObserverIdleResult.md) +- [MutationObserverLoadingResult](interfaces/MutationObserverLoadingResult.md) +- [MutationObserverOptions](interfaces/MutationObserverOptions.md) +- [MutationObserverSuccessResult](interfaces/MutationObserverSuccessResult.md) +- [MutationState](interfaces/MutationState.md) +- [NotifyEvent](interfaces/NotifyEvent.md) +- [OnlineManager](interfaces/OnlineManager.md) +- [QueriesObserverOptions](interfaces/QueriesObserverOptions.md) +- [QueryCacheConfig](interfaces/QueryCacheConfig.md) +- [QueryClientConfig](interfaces/QueryClientConfig.md) +- [QueryExecuteOptions](interfaces/QueryExecuteOptions.md) +- [QueryObserverBaseResult](interfaces/QueryObserverBaseResult.md) +- [QueryObserverLoadingErrorResult](interfaces/QueryObserverLoadingErrorResult.md) +- [QueryObserverLoadingResult](interfaces/QueryObserverLoadingResult.md) +- [QueryObserverOptions](interfaces/QueryObserverOptions.md) +- [QueryObserverPendingResult](interfaces/QueryObserverPendingResult.md) +- [QueryObserverPlaceholderResult](interfaces/QueryObserverPlaceholderResult.md) +- [QueryObserverRefetchErrorResult](interfaces/QueryObserverRefetchErrorResult.md) +- [QueryObserverSuccessResult](interfaces/QueryObserverSuccessResult.md) +- [QueryState](interfaces/QueryState.md) +- [RefetchOptions](interfaces/RefetchOptions.md) +- [RefetchQueryFilters](interfaces/RefetchQueryFilters.md) +- [Register](interfaces/Register.md) +- [ResetOptions](interfaces/ResetOptions.md) +- [ResultOptions](interfaces/ResultOptions.md) +- [SetDataOptions](interfaces/SetDataOptions.md) +- [TimeoutManager](interfaces/TimeoutManager.md) ## Type Aliases +- [AnyDataTag](type-aliases/AnyDataTag.md) +- [DataTag](type-aliases/DataTag.md) +- [dataTagErrorSymbol](type-aliases/dataTagErrorSymbol.md) +- [dataTagSymbol](type-aliases/dataTagSymbol.md) +- [DefaultedInfiniteQueryObserverOptions](type-aliases/DefaultedInfiniteQueryObserverOptions.md) +- [DefaultedQueryObserverOptions](type-aliases/DefaultedQueryObserverOptions.md) +- [DefaultError](type-aliases/DefaultError.md) +- [DefinedInfiniteQueryObserverResult](type-aliases/DefinedInfiniteQueryObserverResult.md) - [DefinedInitialDataInfiniteOptions](type-aliases/DefinedInitialDataInfiniteOptions.md) - [DefinedInitialQueryOptions](type-aliases/DefinedInitialQueryOptions.md) - [DefinedInitialQueryOptionsWithDataTag](type-aliases/DefinedInitialQueryOptionsWithDataTag.md) +- [DefinedQueryObserverResult](type-aliases/DefinedQueryObserverResult.md) +- [DistributiveOmit](type-aliases/DistributiveOmit.md) +- [~~EnsureInfiniteQueryDataOptions~~](type-aliases/EnsureInfiniteQueryDataOptions.md) +- [~~FetchInfiniteQueryOptions~~](type-aliases/FetchInfiniteQueryOptions.md) +- [FetchStatus](type-aliases/FetchStatus.md) +- [GetNextPageParamFunction](type-aliases/GetNextPageParamFunction.md) +- [GetPreviousPageParamFunction](type-aliases/GetPreviousPageParamFunction.md) +- [InferDataFromTag](type-aliases/InferDataFromTag.md) +- [InferErrorFromTag](type-aliases/InferErrorFromTag.md) +- [InfiniteQueryExecuteOptions](type-aliases/InfiniteQueryExecuteOptions.md) +- [InfiniteQueryObserverResult](type-aliases/InfiniteQueryObserverResult.md) +- [InitialDataFunction](type-aliases/InitialDataFunction.md) +- [ManagedTimerId](type-aliases/ManagedTimerId.md) +- [MutateFunction](type-aliases/MutateFunction.md) +- [MutateFunctionRest](type-aliases/MutateFunctionRest.md) +- [MutationCacheNotifyEvent](type-aliases/MutationCacheNotifyEvent.md) - [MutationFilters](type-aliases/MutationFilters.md) +- [MutationFunction](type-aliases/MutationFunction.md) +- [MutationFunctionContext](type-aliases/MutationFunctionContext.md) +- [MutationKey](type-aliases/MutationKey.md) +- [MutationMeta](type-aliases/MutationMeta.md) +- [MutationObserverResult](type-aliases/MutationObserverResult.md) - [MutationOptions](type-aliases/MutationOptions.md) +- [MutationScope](type-aliases/MutationScope.md) - [MutationStateOptions](type-aliases/MutationStateOptions.md) +- [MutationStatus](type-aliases/MutationStatus.md) +- [NetworkMode](type-aliases/NetworkMode.md) +- [NonUndefinedGuard](type-aliases/NonUndefinedGuard.md) +- [NotifyEventType](type-aliases/NotifyEventType.md) +- [NotifyOnChangeProps](type-aliases/NotifyOnChangeProps.md) +- [OmitKeyof](type-aliases/OmitKeyof.md) +- [Override](type-aliases/Override.md) +- [PlaceholderDataFunction](type-aliases/PlaceholderDataFunction.md) +- [QueriesPlaceholderDataFunction](type-aliases/QueriesPlaceholderDataFunction.md) +- [QueryBooleanOption](type-aliases/QueryBooleanOption.md) +- [QueryCacheNotifyEvent](type-aliases/QueryCacheNotifyEvent.md) - [QueryFilters](type-aliases/QueryFilters.md) +- [QueryFunction](type-aliases/QueryFunction.md) +- [QueryFunctionContext](type-aliases/QueryFunctionContext.md) +- [QueryKey](type-aliases/QueryKey.md) +- [QueryKeyHashFunction](type-aliases/QueryKeyHashFunction.md) +- [QueryKeyWithDataTag](type-aliases/QueryKeyWithDataTag.md) +- [QueryMeta](type-aliases/QueryMeta.md) +- [QueryObserverResult](type-aliases/QueryObserverResult.md) - [QueryOptions](type-aliases/QueryOptions.md) +- [QueryPersister](type-aliases/QueryPersister.md) +- [QueryStatus](type-aliases/QueryStatus.md) +- [SkipToken](type-aliases/SkipToken.md) +- [StaleTime](type-aliases/StaleTime.md) +- [StaleTimeFunction](type-aliases/StaleTimeFunction.md) +- [ThrowOnError](type-aliases/ThrowOnError.md) +- [TimeoutCallback](type-aliases/TimeoutCallback.md) +- [TimeoutProvider](type-aliases/TimeoutProvider.md) - [UndefinedInitialDataInfiniteOptions](type-aliases/UndefinedInitialDataInfiniteOptions.md) - [UndefinedInitialQueryOptions](type-aliases/UndefinedInitialQueryOptions.md) - [UndefinedInitialQueryOptionsWithDataTag](type-aliases/UndefinedInitialQueryOptionsWithDataTag.md) +- [UnsetMarker](type-aliases/UnsetMarker.md) +- [Updater](type-aliases/Updater.md) - [UseInfiniteQueryOptions](type-aliases/UseInfiniteQueryOptions.md) - [UseInfiniteQueryReturnType](type-aliases/UseInfiniteQueryReturnType.md) - [UseMutationOptions](type-aliases/UseMutationOptions.md) @@ -34,16 +156,43 @@ title: "@tanstack/vue-query" - [UseQueryOptions](type-aliases/UseQueryOptions.md) - [UseQueryReturnType](type-aliases/UseQueryReturnType.md) - [VueQueryPluginOptions](type-aliases/VueQueryPluginOptions.md) +- [WithRequired](type-aliases/WithRequired.md) ## Variables +- [dataTagErrorSymbol](variables/dataTagErrorSymbol.md) +- [dataTagSymbol](variables/dataTagSymbol.md) +- [defaultScheduler](variables/defaultScheduler.md) +- [environmentManager](variables/environmentManager.md) +- [focusManager](variables/focusManager.md) +- [~~isServer~~](variables/isServer.md) +- [notifyManager](variables/notifyManager.md) +- [onlineManager](variables/onlineManager.md) +- [skipToken](variables/skipToken.md) +- [timeoutManager](variables/timeoutManager.md) +- [unsetMarker](variables/unsetMarker.md) - [VueQueryPlugin](variables/VueQueryPlugin.md) ## Functions +- [defaultShouldDehydrateMutation](functions/defaultShouldDehydrateMutation.md) +- [defaultShouldDehydrateQuery](functions/defaultShouldDehydrateQuery.md) +- [dehydrate](functions/dehydrate.md) +- [dehydrateQuery](functions/dehydrateQuery.md) +- [experimental\_streamedQuery](functions/experimental_streamedQuery.md) +- [hashKey](functions/hashKey.md) +- [hydrate](functions/hydrate.md) - [infiniteQueryOptions](functions/infiniteQueryOptions.md) +- [~~isCancelledError~~](functions/isCancelledError.md) +- [keepPreviousData](functions/keepPreviousData.md) +- [matchMutation](functions/matchMutation.md) +- [matchQuery](functions/matchQuery.md) - [mutationOptions](functions/mutationOptions.md) +- [noop](functions/noop.md) +- [partialMatchKey](functions/partialMatchKey.md) - [queryOptions](functions/queryOptions.md) +- [replaceEqualDeep](functions/replaceEqualDeep.md) +- [shouldThrowError](functions/shouldThrowError.md) - [useInfiniteQuery](functions/useInfiniteQuery.md) - [useIsFetching](functions/useIsFetching.md) - [useIsMutating](functions/useIsMutating.md) diff --git a/docs/framework/vue/reference/interfaces/CancelOptions.md b/docs/framework/vue/reference/interfaces/CancelOptions.md new file mode 100644 index 00000000000..b7464c48e50 --- /dev/null +++ b/docs/framework/vue/reference/interfaces/CancelOptions.md @@ -0,0 +1,26 @@ +--- +id: CancelOptions +title: CancelOptions +--- + +Defined in: [packages/query-core/src/types.ts:1521](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1521) + +## Properties + +### revert? + +```ts +optional revert: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1522](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1522) + +*** + +### silent? + +```ts +optional silent: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1523](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1523) diff --git a/docs/framework/vue/reference/interfaces/DefaultOptions.md b/docs/framework/vue/reference/interfaces/DefaultOptions.md new file mode 100644 index 00000000000..e45a56f075f --- /dev/null +++ b/docs/framework/vue/reference/interfaces/DefaultOptions.md @@ -0,0 +1,84 @@ +--- +id: DefaultOptions +title: DefaultOptions +--- + +Defined in: [packages/query-core/src/types.ts:1507](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1507) + +## Type Parameters + +### TError + +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) + +## Properties + +### dehydrate? + +```ts +optional dehydrate: DehydrateOptions; +``` + +Defined in: [packages/query-core/src/types.ts:1518](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1518) + +Default options used when dehydrating the client's caches; see [DehydrateOptions](DehydrateOptions.md). + +*** + +### hydrate? + +```ts +optional hydrate: object; +``` + +Defined in: [packages/query-core/src/types.ts:1516](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1516) + +Default options used when hydrating queries; see [HydrateOptions](HydrateOptions.md). + +#### deserializeData? + +```ts +optional deserializeData: TransformerFn; +``` + +Transforms a query's `data` after it is read from the dehydrated state, reversing `serializeData`. + +#### mutations? + +```ts +optional mutations: MutationOptions; +``` + +Default options merged into every mutation restored from the dehydrated state. + +#### queries? + +```ts +optional queries: QueryOptions; +``` + +Default options merged into every query restored from the dehydrated state. + +*** + +### mutations? + +```ts +optional mutations: MutationObserverOptions; +``` + +Defined in: [packages/query-core/src/types.ts:1514](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1514) + +Default options applied to every mutation, unless overridden per-mutation. + +*** + +### queries? + +```ts +optional queries: OmitKeyof, "queryKey" | "suspense", "strictly">; +``` + +Defined in: [packages/query-core/src/types.ts:1509](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1509) + +Default options applied to every query, unless overridden per-query. diff --git a/docs/framework/vue/reference/interfaces/DehydrateOptions.md b/docs/framework/vue/reference/interfaces/DehydrateOptions.md new file mode 100644 index 00000000000..e862ae88b43 --- /dev/null +++ b/docs/framework/vue/reference/interfaces/DehydrateOptions.md @@ -0,0 +1,89 @@ +--- +id: DehydrateOptions +title: DehydrateOptions +--- + +Defined in: [packages/query-core/src/hydration.ts:42](https://github.com/TanStack/query/blob/main/packages/query-core/src/hydration.ts#L42) + +Options for `dehydrate`, controlling which queries/mutations are included in the resulting `DehydratedState` and +how their data/errors are transformed before being serialized (e.g. for embedding in server-rendered markup). + +## Properties + +### serializeData? + +```ts +optional serializeData: TransformerFn; +``` + +Defined in: [packages/query-core/src/hydration.ts:44](https://github.com/TanStack/query/blob/main/packages/query-core/src/hydration.ts#L44) + +Transforms a query's `data` before it is dehydrated. Useful for non-JSON-serializable data. + +*** + +### shouldDehydrateMutation()? + +```ts +optional shouldDehydrateMutation: (mutation) => boolean; +``` + +Defined in: [packages/query-core/src/hydration.ts:46](https://github.com/TanStack/query/blob/main/packages/query-core/src/hydration.ts#L46) + +Predicate to decide whether a given `Mutation` should be dehydrated. Defaults to `defaultShouldDehydrateMutation`. + +#### Parameters + +##### mutation + +[`Mutation`](../classes/Mutation.md) + +#### Returns + +`boolean` + +*** + +### shouldDehydrateQuery()? + +```ts +optional shouldDehydrateQuery: (query) => boolean; +``` + +Defined in: [packages/query-core/src/hydration.ts:48](https://github.com/TanStack/query/blob/main/packages/query-core/src/hydration.ts#L48) + +Predicate to decide whether a given `Query` should be dehydrated. Defaults to `defaultShouldDehydrateQuery`. + +#### Parameters + +##### query + +[`Query`](../classes/Query.md) + +#### Returns + +`boolean` + +*** + +### shouldRedactErrors()? + +```ts +optional shouldRedactErrors: (error) => boolean; +``` + +Defined in: [packages/query-core/src/hydration.ts:54](https://github.com/TanStack/query/blob/main/packages/query-core/src/hydration.ts#L54) + +Predicate to decide whether a query's error should be redacted before dehydration. Errors are redacted +(replaced with a generic `Error('redacted')`) unless this function is provided and returns `false` for the +given error, in which case the original error is kept. + +#### Parameters + +##### error + +`unknown` + +#### Returns + +`boolean` diff --git a/docs/framework/vue/reference/interfaces/DehydratedState.md b/docs/framework/vue/reference/interfaces/DehydratedState.md new file mode 100644 index 00000000000..be034c9e8fd --- /dev/null +++ b/docs/framework/vue/reference/interfaces/DehydratedState.md @@ -0,0 +1,30 @@ +--- +id: DehydratedState +title: DehydratedState +--- + +Defined in: [packages/query-core/src/hydration.ts:94](https://github.com/TanStack/query/blob/main/packages/query-core/src/hydration.ts#L94) + +A serializable snapshot of a `QueryClient`'s cache, as produced by `dehydrate` and consumed by `hydrate`. Typically +transported from server to client (e.g. embedded in server-rendered markup) to seed the client's cache with data +that has already been fetched, avoiding a redundant fetch on the client. + +## Properties + +### mutations + +```ts +mutations: DehydratedMutation[]; +``` + +Defined in: [packages/query-core/src/hydration.ts:95](https://github.com/TanStack/query/blob/main/packages/query-core/src/hydration.ts#L95) + +*** + +### queries + +```ts +queries: DehydratedQuery[]; +``` + +Defined in: [packages/query-core/src/hydration.ts:96](https://github.com/TanStack/query/blob/main/packages/query-core/src/hydration.ts#L96) diff --git a/docs/framework/vue/reference/interfaces/EnsureQueryDataOptions.md b/docs/framework/vue/reference/interfaces/EnsureQueryDataOptions.md new file mode 100644 index 00000000000..a67082af57e --- /dev/null +++ b/docs/framework/vue/reference/interfaces/EnsureQueryDataOptions.md @@ -0,0 +1,350 @@ +--- +id: EnsureQueryDataOptions +title: EnsureQueryDataOptions +--- + +Defined in: [packages/query-core/src/types.ts:614](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L614) + +## Deprecated + +## Extends + +- [`FetchQueryOptions`](FetchQueryOptions.md)\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`, `TPageParam`\> + +## Type Parameters + +### TQueryFnData + +`TQueryFnData` = `unknown` + +### TError + +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) + +### TData + +`TData` = `TQueryFnData` + +### TQueryKey + +`TQueryKey` *extends* [`QueryKey`](../type-aliases/QueryKey.md) = [`QueryKey`](../type-aliases/QueryKey.md) + +### TPageParam + +`TPageParam` = `never` + +## Properties + +### ~~gcTime?~~ + +```ts +optional gcTime: number; +``` + +Defined in: [packages/query-core/src/types.ts:277](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L277) + +The time in milliseconds that unused/inactive cache data remains in memory. +When a query's cache becomes unused or inactive, that cache data will be garbage collected after this duration. +When different garbage collection times are specified, the longest one will be used. +Setting it to `Infinity` will disable garbage collection. + +Defaults to `5 * 60 * 1000` (5 minutes), or `Infinity` during SSR. + +Note: the maximum allowed time is about 24 days, imposed by `setTimeout`'s 32-bit signed integer delay — see +`timeoutManager.setTimeoutProvider` for a workaround. + +#### Inherited from + +[`FetchQueryOptions`](FetchQueryOptions.md).[`gcTime`](FetchQueryOptions.md#gctime) + +*** + +### ~~initialData?~~ + +```ts +optional initialData: + | TData +| InitialDataFunction; +``` + +Defined in: [packages/query-core/src/types.ts:317](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L317) + +If set, this value will be used as the initial data for the query cache (as long as the query hasn't been +created or cached yet). +If set to a function, the function will be called **once** during the shared/root query initialization, and be +expected to synchronously return the initial data. +Initial data is considered stale by default unless a `staleTime` has been set. +`initialData` **is persisted** to the cache. + +#### Inherited from + +[`FetchQueryOptions`](FetchQueryOptions.md).[`initialData`](FetchQueryOptions.md#initialdata) + +*** + +### ~~initialDataUpdatedAt?~~ + +```ts +optional initialDataUpdatedAt: number | () => number | undefined; +``` + +Defined in: [packages/query-core/src/types.ts:321](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L321) + +If set, this value will be used as the time (in milliseconds) of when the `initialData` itself was last updated. + +#### Inherited from + +[`FetchQueryOptions`](FetchQueryOptions.md).[`initialDataUpdatedAt`](FetchQueryOptions.md#initialdataupdatedat) + +*** + +### ~~initialPageParam?~~ + +```ts +optional initialPageParam: undefined; +``` + +Defined in: [packages/query-core/src/types.ts:605](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L605) + +#### Inherited from + +[`FetchQueryOptions`](FetchQueryOptions.md).[`initialPageParam`](FetchQueryOptions.md#initialpageparam) + +*** + +### ~~maxPages?~~ + +```ts +optional maxPages: number; +``` + +Defined in: [packages/query-core/src/types.ts:345](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L345) + +Maximum number of pages to store in the data of an infinite query. + +#### Inherited from + +[`FetchQueryOptions`](FetchQueryOptions.md).[`maxPages`](FetchQueryOptions.md#maxpages) + +*** + +### ~~meta?~~ + +```ts +optional meta: Record; +``` + +Defined in: [packages/query-core/src/types.ts:341](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L341) + +Additional payload to be stored on each query. +Use this property to pass information that can be used in other places. + +#### Inherited from + +[`FetchQueryOptions`](FetchQueryOptions.md).[`meta`](FetchQueryOptions.md#meta) + +*** + +### ~~networkMode?~~ + +```ts +optional networkMode: NetworkMode; +``` + +Defined in: [packages/query-core/src/types.ts:265](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L265) + +Controls whether a query is allowed to run based on the current network connectivity. + +Defaults to `'online'`. + +#### See + +[Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. + +#### Inherited from + +[`FetchQueryOptions`](FetchQueryOptions.md).[`networkMode`](FetchQueryOptions.md#networkmode) + +*** + +### ~~persister?~~ + +```ts +optional persister: QueryPersister, TPageParam>; +``` + +Defined in: [packages/query-core/src/types.ts:290](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L290) + +This option can be used to persist the result of a query to an external storage, bypassing the need to actually +call the `queryFn`. Useful for persisting a query's data across e.g. server/client boundaries. + +#### Inherited from + +[`FetchQueryOptions`](FetchQueryOptions.md).[`persister`](FetchQueryOptions.md#persister) + +*** + +### ~~queryFn?~~ + +```ts +optional queryFn: + | typeof skipToken +| QueryFunction; +``` + +Defined in: [packages/query-core/src/types.ts:285](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L285) + +The function that the query will use to request data. +Required, unless a default query function has been set via `queryClient.setQueryDefaults` or +`queryClient.setDefaultOptions`. +Receives a [QueryFunctionContext](../type-aliases/QueryFunctionContext.md). +Must return a promise that will either resolve data or throw an error. The data cannot be `undefined`. + +#### Inherited from + +[`FetchQueryOptions`](FetchQueryOptions.md).[`queryFn`](FetchQueryOptions.md#queryfn) + +*** + +### ~~queryHash?~~ + +```ts +optional queryHash: string; +``` + +Defined in: [packages/query-core/src/types.ts:295](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L295) + +The hashed form of `queryKey`, computed with `queryKeyHashFn` (or the default hashing function otherwise). Used +as the actual cache key internally. + +#### Inherited from + +[`FetchQueryOptions`](FetchQueryOptions.md).[`queryHash`](FetchQueryOptions.md#queryhash) + +*** + +### ~~queryKey~~ + +```ts +queryKey: TQueryKey & object; +``` + +Defined in: [packages/query-core/src/types.ts:304](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L304) + +The query key to use for this query. + +The query key will be hashed into a stable hash. See [Query Keys](https://tanstack.com/query/latest/docs/framework/react/guides/query-keys) +for more information. + +The query will automatically update when this key changes (as long as `enabled` is not set to `false`). + +#### Inherited from + +[`FetchQueryOptions`](FetchQueryOptions.md).[`queryKey`](FetchQueryOptions.md#querykey) + +*** + +### ~~queryKeyHashFn?~~ + +```ts +optional queryKeyHashFn: QueryKeyHashFunction; +``` + +Defined in: [packages/query-core/src/types.ts:308](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L308) + +If specified, this function is used to hash the `queryKey` to a string. + +#### Inherited from + +[`FetchQueryOptions`](FetchQueryOptions.md).[`queryKeyHashFn`](FetchQueryOptions.md#querykeyhashfn) + +*** + +### ~~retry?~~ + +```ts +optional retry: RetryValue; +``` + +Defined in: [packages/query-core/src/types.ts:246](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L246) + +If `false`, failed queries will not retry by default. +If `true`, failed queries will retry infinitely. +If set to an integer number, e.g. 3, failed queries will retry until the failed query count meets that number. +If set to a function `(failureCount, error) => boolean` failed queries will retry until the function returns false. + +Defaults to `3` on the client and `0` on the server. + +#### Inherited from + +[`FetchQueryOptions`](FetchQueryOptions.md).[`retry`](FetchQueryOptions.md#retry) + +*** + +### ~~retryDelay?~~ + +```ts +optional retryDelay: RetryDelayValue; +``` + +Defined in: [packages/query-core/src/types.ts:258](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L258) + +This function receives a `retryAttempt` integer and the actual Error and returns the delay to apply before the +next attempt in milliseconds. + +A function like `attempt => Math.min(attempt > 1 ? 2 ** attempt * 1000 : 1000, 30 * 1000)` applies exponential +backoff. + +A function like `attempt => attempt * 1000` applies linear backoff. + +Defaults to a function that applies exponential backoff, capped at 30 seconds. + +#### Inherited from + +[`FetchQueryOptions`](FetchQueryOptions.md).[`retryDelay`](FetchQueryOptions.md#retrydelay) + +*** + +### ~~revalidateIfStale?~~ + +```ts +optional revalidateIfStale: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:627](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L627) + +*** + +### ~~staleTime?~~ + +```ts +optional staleTime: StaleTimeFunction; +``` + +Defined in: [packages/query-core/src/types.ts:610](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L610) + +The time in milliseconds after data is considered stale. +If the data is fresh it will be returned from the cache. + +#### Inherited from + +[`FetchQueryOptions`](FetchQueryOptions.md).[`staleTime`](FetchQueryOptions.md#staletime) + +*** + +### ~~structuralSharing?~~ + +```ts +optional structuralSharing: boolean | (oldData, newData) => unknown; +``` + +Defined in: [packages/query-core/src/types.ts:330](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L330) + +Set this to `false` to disable structural sharing between query results. +Set this to a function which accepts the old and new data and returns resolved data of the same type to implement custom structural sharing logic. + +Defaults to `true`. + +#### Inherited from + +[`FetchQueryOptions`](FetchQueryOptions.md).[`structuralSharing`](FetchQueryOptions.md#structuralsharing) diff --git a/docs/framework/vue/reference/interfaces/FetchNextPageOptions.md b/docs/framework/vue/reference/interfaces/FetchNextPageOptions.md new file mode 100644 index 00000000000..b79cdbe19b3 --- /dev/null +++ b/docs/framework/vue/reference/interfaces/FetchNextPageOptions.md @@ -0,0 +1,46 @@ +--- +id: FetchNextPageOptions +title: FetchNextPageOptions +--- + +Defined in: [packages/query-core/src/types.ts:737](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L737) + +## Extends + +- [`ResultOptions`](ResultOptions.md) + +## Properties + +### cancelRefetch? + +```ts +optional cancelRefetch: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:746](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L746) + +If set to `true`, calling `fetchNextPage` repeatedly will invoke `queryFn` every time, +whether the previous invocation has resolved or not. Also, the result from previous invocations will be ignored. + +If set to `false`, calling `fetchNextPage` repeatedly won't have any effect until the first invocation has resolved. + +Defaults to `true`. + +*** + +### throwOnError? + +```ts +optional throwOnError: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:701](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L701) + +If set to `true`, the method throws if any of the underlying query refetch tasks fail. + +Defaults to `false`, in which case failed refetches are swallowed and not surfaced to the +caller. + +#### Inherited from + +[`ResultOptions`](ResultOptions.md).[`throwOnError`](ResultOptions.md#throwonerror) diff --git a/docs/framework/vue/reference/interfaces/FetchPreviousPageOptions.md b/docs/framework/vue/reference/interfaces/FetchPreviousPageOptions.md new file mode 100644 index 00000000000..fd5a08767b6 --- /dev/null +++ b/docs/framework/vue/reference/interfaces/FetchPreviousPageOptions.md @@ -0,0 +1,46 @@ +--- +id: FetchPreviousPageOptions +title: FetchPreviousPageOptions +--- + +Defined in: [packages/query-core/src/types.ts:749](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L749) + +## Extends + +- [`ResultOptions`](ResultOptions.md) + +## Properties + +### cancelRefetch? + +```ts +optional cancelRefetch: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:758](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L758) + +If set to `true`, calling `fetchPreviousPage` repeatedly will invoke `queryFn` every time, +whether the previous invocation has resolved or not. Also, the result from previous invocations will be ignored. + +If set to `false`, calling `fetchPreviousPage` repeatedly won't have any effect until the first invocation has resolved. + +Defaults to `true`. + +*** + +### throwOnError? + +```ts +optional throwOnError: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:701](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L701) + +If set to `true`, the method throws if any of the underlying query refetch tasks fail. + +Defaults to `false`, in which case failed refetches are swallowed and not surfaced to the +caller. + +#### Inherited from + +[`ResultOptions`](ResultOptions.md).[`throwOnError`](ResultOptions.md#throwonerror) diff --git a/docs/framework/vue/reference/interfaces/FetchQueryOptions.md b/docs/framework/vue/reference/interfaces/FetchQueryOptions.md new file mode 100644 index 00000000000..1b8582adba7 --- /dev/null +++ b/docs/framework/vue/reference/interfaces/FetchQueryOptions.md @@ -0,0 +1,364 @@ +--- +id: FetchQueryOptions +title: FetchQueryOptions +--- + +Defined in: [packages/query-core/src/types.ts:595](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L595) + +## Deprecated + +## Extends + +- [`WithRequired`](../type-aliases/WithRequired.md)\<`QueryOptions`\<`TQueryFnData`, `TError`, `TData`, `TQueryKey`, `TPageParam`\>, `"queryKey"`\> + +## Extended by + +- [`EnsureQueryDataOptions`](EnsureQueryDataOptions.md) + +## Type Parameters + +### TQueryFnData + +`TQueryFnData` = `unknown` + +### TError + +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) + +### TData + +`TData` = `TQueryFnData` + +### TQueryKey + +`TQueryKey` *extends* [`QueryKey`](../type-aliases/QueryKey.md) = [`QueryKey`](../type-aliases/QueryKey.md) + +### TPageParam + +`TPageParam` = `never` + +## Properties + +### ~~gcTime?~~ + +```ts +optional gcTime: number; +``` + +Defined in: [packages/query-core/src/types.ts:277](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L277) + +The time in milliseconds that unused/inactive cache data remains in memory. +When a query's cache becomes unused or inactive, that cache data will be garbage collected after this duration. +When different garbage collection times are specified, the longest one will be used. +Setting it to `Infinity` will disable garbage collection. + +Defaults to `5 * 60 * 1000` (5 minutes), or `Infinity` during SSR. + +Note: the maximum allowed time is about 24 days, imposed by `setTimeout`'s 32-bit signed integer delay — see +`timeoutManager.setTimeoutProvider` for a workaround. + +#### Inherited from + +```ts +WithRequired.gcTime +``` + +*** + +### ~~initialData?~~ + +```ts +optional initialData: + | TData +| InitialDataFunction; +``` + +Defined in: [packages/query-core/src/types.ts:317](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L317) + +If set, this value will be used as the initial data for the query cache (as long as the query hasn't been +created or cached yet). +If set to a function, the function will be called **once** during the shared/root query initialization, and be +expected to synchronously return the initial data. +Initial data is considered stale by default unless a `staleTime` has been set. +`initialData` **is persisted** to the cache. + +#### Inherited from + +```ts +WithRequired.initialData +``` + +*** + +### ~~initialDataUpdatedAt?~~ + +```ts +optional initialDataUpdatedAt: number | () => number | undefined; +``` + +Defined in: [packages/query-core/src/types.ts:321](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L321) + +If set, this value will be used as the time (in milliseconds) of when the `initialData` itself was last updated. + +#### Inherited from + +```ts +WithRequired.initialDataUpdatedAt +``` + +*** + +### ~~initialPageParam?~~ + +```ts +optional initialPageParam: undefined; +``` + +Defined in: [packages/query-core/src/types.ts:605](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L605) + +*** + +### ~~maxPages?~~ + +```ts +optional maxPages: number; +``` + +Defined in: [packages/query-core/src/types.ts:345](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L345) + +Maximum number of pages to store in the data of an infinite query. + +#### Inherited from + +```ts +WithRequired.maxPages +``` + +*** + +### ~~meta?~~ + +```ts +optional meta: Record; +``` + +Defined in: [packages/query-core/src/types.ts:341](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L341) + +Additional payload to be stored on each query. +Use this property to pass information that can be used in other places. + +#### Inherited from + +```ts +WithRequired.meta +``` + +*** + +### ~~networkMode?~~ + +```ts +optional networkMode: NetworkMode; +``` + +Defined in: [packages/query-core/src/types.ts:265](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L265) + +Controls whether a query is allowed to run based on the current network connectivity. + +Defaults to `'online'`. + +#### See + +[Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. + +#### Inherited from + +```ts +WithRequired.networkMode +``` + +*** + +### ~~persister?~~ + +```ts +optional persister: QueryPersister, TPageParam>; +``` + +Defined in: [packages/query-core/src/types.ts:290](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L290) + +This option can be used to persist the result of a query to an external storage, bypassing the need to actually +call the `queryFn`. Useful for persisting a query's data across e.g. server/client boundaries. + +#### Inherited from + +```ts +WithRequired.persister +``` + +*** + +### ~~queryFn?~~ + +```ts +optional queryFn: + | typeof skipToken +| QueryFunction; +``` + +Defined in: [packages/query-core/src/types.ts:285](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L285) + +The function that the query will use to request data. +Required, unless a default query function has been set via `queryClient.setQueryDefaults` or +`queryClient.setDefaultOptions`. +Receives a [QueryFunctionContext](../type-aliases/QueryFunctionContext.md). +Must return a promise that will either resolve data or throw an error. The data cannot be `undefined`. + +#### Inherited from + +```ts +WithRequired.queryFn +``` + +*** + +### ~~queryHash?~~ + +```ts +optional queryHash: string; +``` + +Defined in: [packages/query-core/src/types.ts:295](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L295) + +The hashed form of `queryKey`, computed with `queryKeyHashFn` (or the default hashing function otherwise). Used +as the actual cache key internally. + +#### Inherited from + +```ts +WithRequired.queryHash +``` + +*** + +### ~~queryKey~~ + +```ts +queryKey: TQueryKey & object; +``` + +Defined in: [packages/query-core/src/types.ts:304](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L304) + +The query key to use for this query. + +The query key will be hashed into a stable hash. See [Query Keys](https://tanstack.com/query/latest/docs/framework/react/guides/query-keys) +for more information. + +The query will automatically update when this key changes (as long as `enabled` is not set to `false`). + +#### Inherited from + +```ts +WithRequired.queryKey +``` + +*** + +### ~~queryKeyHashFn?~~ + +```ts +optional queryKeyHashFn: QueryKeyHashFunction; +``` + +Defined in: [packages/query-core/src/types.ts:308](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L308) + +If specified, this function is used to hash the `queryKey` to a string. + +#### Inherited from + +```ts +WithRequired.queryKeyHashFn +``` + +*** + +### ~~retry?~~ + +```ts +optional retry: RetryValue; +``` + +Defined in: [packages/query-core/src/types.ts:246](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L246) + +If `false`, failed queries will not retry by default. +If `true`, failed queries will retry infinitely. +If set to an integer number, e.g. 3, failed queries will retry until the failed query count meets that number. +If set to a function `(failureCount, error) => boolean` failed queries will retry until the function returns false. + +Defaults to `3` on the client and `0` on the server. + +#### Inherited from + +```ts +WithRequired.retry +``` + +*** + +### ~~retryDelay?~~ + +```ts +optional retryDelay: RetryDelayValue; +``` + +Defined in: [packages/query-core/src/types.ts:258](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L258) + +This function receives a `retryAttempt` integer and the actual Error and returns the delay to apply before the +next attempt in milliseconds. + +A function like `attempt => Math.min(attempt > 1 ? 2 ** attempt * 1000 : 1000, 30 * 1000)` applies exponential +backoff. + +A function like `attempt => attempt * 1000` applies linear backoff. + +Defaults to a function that applies exponential backoff, capped at 30 seconds. + +#### Inherited from + +```ts +WithRequired.retryDelay +``` + +*** + +### ~~staleTime?~~ + +```ts +optional staleTime: StaleTimeFunction; +``` + +Defined in: [packages/query-core/src/types.ts:610](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L610) + +The time in milliseconds after data is considered stale. +If the data is fresh it will be returned from the cache. + +*** + +### ~~structuralSharing?~~ + +```ts +optional structuralSharing: boolean | (oldData, newData) => unknown; +``` + +Defined in: [packages/query-core/src/types.ts:330](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L330) + +Set this to `false` to disable structural sharing between query results. +Set this to a function which accepts the old and new data and returns resolved data of the same type to implement custom structural sharing logic. + +Defaults to `true`. + +#### Inherited from + +```ts +WithRequired.structuralSharing +``` diff --git a/docs/framework/vue/reference/interfaces/FocusManager.md b/docs/framework/vue/reference/interfaces/FocusManager.md new file mode 100644 index 00000000000..1ab81dc6357 --- /dev/null +++ b/docs/framework/vue/reference/interfaces/FocusManager.md @@ -0,0 +1,237 @@ +--- +id: FocusManager +title: FocusManager +--- + +Defined in: [packages/query-core/src/focusManager.ts:14](https://github.com/TanStack/query/blob/main/packages/query-core/src/focusManager.ts#L14) + +The `FocusManager` manages the focus state within TanStack Query. + +It can be used to change the default event listeners or to manually change the focus state. + +## Extends + +- `Subscribable`\<`Listener`\> + +## Properties + +### listeners + +```ts +protected listeners: Set; +``` + +Defined in: [packages/query-core/src/subscribable.ts:2](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L2) + +#### Inherited from + +```ts +Subscribable.listeners +``` + +## Methods + +### hasListeners() + +```ts +hasListeners(): boolean; +``` + +Defined in: [packages/query-core/src/subscribable.ts:19](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L19) + +#### Returns + +`boolean` + +#### Inherited from + +```ts +Subscribable.hasListeners +``` + +*** + +### isFocused() + +```ts +isFocused(): boolean; +``` + +Defined in: [packages/query-core/src/focusManager.ts:128](https://github.com/TanStack/query/blob/main/packages/query-core/src/focusManager.ts#L128) + +`isFocused` can be used to get the current focus state. + +#### Returns + +`boolean` + +*** + +### onFocus() + +```ts +onFocus(): void; +``` + +Defined in: [packages/query-core/src/focusManager.ts:118](https://github.com/TanStack/query/blob/main/packages/query-core/src/focusManager.ts#L118) + +`onFocus` notifies all subscribed listeners with the current focus state. + +#### Returns + +`void` + +*** + +### onSubscribe() + +```ts +protected onSubscribe(): void; +``` + +Defined in: [packages/query-core/src/focusManager.ts:39](https://github.com/TanStack/query/blob/main/packages/query-core/src/focusManager.ts#L39) + +#### Returns + +`void` + +#### Overrides + +```ts +Subscribable.onSubscribe +``` + +*** + +### onUnsubscribe() + +```ts +protected onUnsubscribe(): void; +``` + +Defined in: [packages/query-core/src/focusManager.ts:45](https://github.com/TanStack/query/blob/main/packages/query-core/src/focusManager.ts#L45) + +#### Returns + +`void` + +#### Overrides + +```ts +Subscribable.onUnsubscribe +``` + +*** + +### setEventListener() + +```ts +setEventListener(setup): void; +``` + +Defined in: [packages/query-core/src/focusManager.ts:77](https://github.com/TanStack/query/blob/main/packages/query-core/src/focusManager.ts#L77) + +`setEventListener` can be used to set a custom event listener that will +be used to determine the focus state. The provided `setup` function +receives a `setFocused` callback: call it with a `boolean` to manually +set the focus state, or with no arguments to re-evaluate the current +focus state and notify subscribers. + +#### Parameters + +##### setup + +`SetupFn` + +#### Returns + +`void` + +#### Example + +```ts +import { focusManager } from '@tanstack/query-core' + +focusManager.setEventListener((handleFocus) => { + const listener = () => handleFocus() + // Listen to visibilitychange + if (typeof window !== 'undefined' && window.addEventListener) { + window.addEventListener('visibilitychange', listener, false) + } + + return () => { + // Be sure to unsubscribe if a new handler is set + window.removeEventListener('visibilitychange', listener) + } +}) +``` + +*** + +### setFocused() + +```ts +setFocused(focused?): void; +``` + +Defined in: [packages/query-core/src/focusManager.ts:107](https://github.com/TanStack/query/blob/main/packages/query-core/src/focusManager.ts#L107) + +`setFocused` can be used to manually set the focus state. Set `undefined` +to fall back to the default focus check. + +#### Parameters + +##### focused? + +`boolean` + +#### Returns + +`void` + +#### Example + +```ts +import { focusManager } from '@tanstack/query-core' + +// Set focused +focusManager.setFocused(true) + +// Set unfocused +focusManager.setFocused(false) + +// Fallback to the default focus check +focusManager.setFocused(undefined) +``` + +*** + +### subscribe() + +```ts +subscribe(listener): () => void; +``` + +Defined in: [packages/query-core/src/subscribable.ts:8](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L8) + +#### Parameters + +##### listener + +`Listener` + +#### Returns + +```ts +(): void; +``` + +##### Returns + +`void` + +#### Inherited from + +```ts +Subscribable.subscribe +``` diff --git a/docs/framework/vue/reference/interfaces/HydrateOptions.md b/docs/framework/vue/reference/interfaces/HydrateOptions.md new file mode 100644 index 00000000000..fe8b92317e3 --- /dev/null +++ b/docs/framework/vue/reference/interfaces/HydrateOptions.md @@ -0,0 +1,43 @@ +--- +id: HydrateOptions +title: HydrateOptions +--- + +Defined in: [packages/query-core/src/hydration.ts:61](https://github.com/TanStack/query/blob/main/packages/query-core/src/hydration.ts#L61) + +Options for `hydrate`, controlling the default options applied to queries/mutations restored from a +`DehydratedState`, and how to reverse any transformation applied by `DehydrateOptions.serializeData`. + +## Properties + +### defaultOptions? + +```ts +optional defaultOptions: object; +``` + +Defined in: [packages/query-core/src/hydration.ts:62](https://github.com/TanStack/query/blob/main/packages/query-core/src/hydration.ts#L62) + +#### deserializeData? + +```ts +optional deserializeData: TransformerFn; +``` + +Transforms a query's `data` after it is read from the dehydrated state, reversing `serializeData`. + +#### mutations? + +```ts +optional mutations: MutationOptions; +``` + +Default options merged into every mutation restored from the dehydrated state. + +#### queries? + +```ts +optional queries: QueryOptions; +``` + +Default options merged into every query restored from the dehydrated state. diff --git a/docs/framework/vue/reference/interfaces/InfiniteData.md b/docs/framework/vue/reference/interfaces/InfiniteData.md new file mode 100644 index 00000000000..4d7ad595c2d --- /dev/null +++ b/docs/framework/vue/reference/interfaces/InfiniteData.md @@ -0,0 +1,36 @@ +--- +id: InfiniteData +title: InfiniteData +--- + +Defined in: [packages/query-core/src/types.ts:210](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L210) + +## Type Parameters + +### TData + +`TData` + +### TPageParam + +`TPageParam` = `unknown` + +## Properties + +### pageParams + +```ts +pageParams: TPageParam[]; +``` + +Defined in: [packages/query-core/src/types.ts:212](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L212) + +*** + +### pages + +```ts +pages: TData[]; +``` + +Defined in: [packages/query-core/src/types.ts:211](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L211) diff --git a/docs/framework/vue/reference/interfaces/InfiniteQueryObserverBaseResult.md b/docs/framework/vue/reference/interfaces/InfiniteQueryObserverBaseResult.md new file mode 100644 index 00000000000..0aa01962aa5 --- /dev/null +++ b/docs/framework/vue/reference/interfaces/InfiniteQueryObserverBaseResult.md @@ -0,0 +1,577 @@ +--- +id: InfiniteQueryObserverBaseResult +title: InfiniteQueryObserverBaseResult +--- + +Defined in: [packages/query-core/src/types.ts:1001](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1001) + +## Extends + +- [`QueryObserverBaseResult`](QueryObserverBaseResult.md)\<`TData`, `TError`\> + +## Extended by + +- [`InfiniteQueryObserverPendingResult`](InfiniteQueryObserverPendingResult.md) +- [`InfiniteQueryObserverLoadingResult`](InfiniteQueryObserverLoadingResult.md) +- [`InfiniteQueryObserverLoadingErrorResult`](InfiniteQueryObserverLoadingErrorResult.md) +- [`InfiniteQueryObserverRefetchErrorResult`](InfiniteQueryObserverRefetchErrorResult.md) +- [`InfiniteQueryObserverSuccessResult`](InfiniteQueryObserverSuccessResult.md) +- [`InfiniteQueryObserverPlaceholderResult`](InfiniteQueryObserverPlaceholderResult.md) + +## Type Parameters + +### TData + +`TData` = `unknown` + +### TError + +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) + +## Properties + +### data + +```ts +data: TData | undefined; +``` + +Defined in: [packages/query-core/src/types.ts:771](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L771) + +The last successfully resolved data for the query. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`data`](QueryObserverBaseResult.md#data) + +*** + +### dataUpdatedAt + +```ts +dataUpdatedAt: number; +``` + +Defined in: [packages/query-core/src/types.ts:775](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L775) + +The timestamp for when the query most recently returned the `status` as `"success"`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`dataUpdatedAt`](QueryObserverBaseResult.md#dataupdatedat) + +*** + +### error + +```ts +error: TError | null; +``` + +Defined in: [packages/query-core/src/types.ts:780](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L780) + +The error object for the query, if an error was thrown. +- Defaults to `null`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`error`](QueryObserverBaseResult.md#error) + +*** + +### errorUpdateCount + +```ts +errorUpdateCount: number; +``` + +Defined in: [packages/query-core/src/types.ts:799](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L799) + +The sum of all errors. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`errorUpdateCount`](QueryObserverBaseResult.md#errorupdatecount) + +*** + +### errorUpdatedAt + +```ts +errorUpdatedAt: number; +``` + +Defined in: [packages/query-core/src/types.ts:784](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L784) + +The timestamp for when the query most recently returned the `status` as `"error"`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`errorUpdatedAt`](QueryObserverBaseResult.md#errorupdatedat) + +*** + +### failureCount + +```ts +failureCount: number; +``` + +Defined in: [packages/query-core/src/types.ts:790](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L790) + +The failure count for the query. +- Incremented every time the query fails. +- Reset to `0` when the query succeeds. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`failureCount`](QueryObserverBaseResult.md#failurecount) + +*** + +### failureReason + +```ts +failureReason: TError | null; +``` + +Defined in: [packages/query-core/src/types.ts:795](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L795) + +The failure reason for the query retry. +- Reset to `null` when the query succeeds. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`failureReason`](QueryObserverBaseResult.md#failurereason) + +*** + +### fetchNextPage() + +```ts +fetchNextPage: (options?) => Promise>; +``` + +Defined in: [packages/query-core/src/types.ts:1008](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1008) + +This function allows you to fetch the next "page" of results. + +#### Parameters + +##### options? + +[`FetchNextPageOptions`](FetchNextPageOptions.md) + +#### Returns + +`Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> + +*** + +### fetchPreviousPage() + +```ts +fetchPreviousPage: (options?) => Promise>; +``` + +Defined in: [packages/query-core/src/types.ts:1014](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1014) + +This function allows you to fetch the previous "page" of results. + +#### Parameters + +##### options? + +[`FetchPreviousPageOptions`](FetchPreviousPageOptions.md) + +#### Returns + +`Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> + +*** + +### fetchStatus + +```ts +fetchStatus: FetchStatus; +``` + +Defined in: [packages/query-core/src/types.ts:889](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L889) + +The fetch status of the query. +- `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. +- `paused`: The query wanted to fetch, but has been `paused`. +- `idle`: The query is not fetching. +- See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`fetchStatus`](QueryObserverBaseResult.md#fetchstatus) + +*** + +### hasNextPage + +```ts +hasNextPage: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1020](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1020) + +Will be `true` if there is a next page to be fetched (known via the `getNextPageParam` option). + +*** + +### hasPreviousPage + +```ts +hasPreviousPage: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1024](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1024) + +Will be `true` if there is a previous page to be fetched (known via the `getPreviousPageParam` option). + +*** + +### isEnabled + +```ts +isEnabled: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:867](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L867) + +`true` if this observer is enabled, `false` otherwise. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isEnabled`](QueryObserverBaseResult.md#isenabled) + +*** + +### isError + +```ts +isError: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:804](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L804) + +A derived boolean from the `status` variable, provided for convenience. +- `true` if the query attempt resulted in an error. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isError`](QueryObserverBaseResult.md#iserror) + +*** + +### isFetched + +```ts +isFetched: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:808](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L808) + +Will be `true` if the query has been fetched. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isFetched`](QueryObserverBaseResult.md#isfetched) + +*** + +### isFetchedAfterMount + +```ts +isFetchedAfterMount: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:813](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L813) + +Will be `true` if the query has been fetched after the component mounted. +- This property can be used to not show any previously cached data. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isFetchedAfterMount`](QueryObserverBaseResult.md#isfetchedaftermount) + +*** + +### isFetching + +```ts +isFetching: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:818](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L818) + +A derived boolean from the `fetchStatus` variable, provided for convenience. +- `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isFetching`](QueryObserverBaseResult.md#isfetching) + +*** + +### isFetchingNextPage + +```ts +isFetchingNextPage: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1032](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1032) + +Will be `true` while fetching the next page with `fetchNextPage`. + +*** + +### isFetchingPreviousPage + +```ts +isFetchingPreviousPage: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1040](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1040) + +Will be `true` while fetching the previous page with `fetchPreviousPage`. + +*** + +### isFetchNextPageError + +```ts +isFetchNextPageError: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1028](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1028) + +Will be `true` if the query failed while fetching the next page. + +*** + +### isFetchPreviousPageError + +```ts +isFetchPreviousPageError: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1036](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1036) + +Will be `true` if the query failed while fetching the previous page. + +*** + +### ~~isInitialLoading~~ + +```ts +isInitialLoading: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:836](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L836) + +#### Deprecated + +`isInitialLoading` is being deprecated in favor of `isLoading` +and will be removed in the next major version. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isInitialLoading`](QueryObserverBaseResult.md#isinitialloading) + +*** + +### isLoading + +```ts +isLoading: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:823](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L823) + +Is `true` whenever the first fetch for a query is in-flight. +- Is the same as `isFetching && isPending`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoading`](QueryObserverBaseResult.md#isloading) + +*** + +### isLoadingError + +```ts +isLoadingError: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:831](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L831) + +Will be `true` if the query failed while fetching for the first time. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoadingError`](QueryObserverBaseResult.md#isloadingerror) + +*** + +### isPaused + +```ts +isPaused: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:841](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L841) + +A derived boolean from the `fetchStatus` variable, provided for convenience. +- The query wanted to fetch, but has been `paused`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPaused`](QueryObserverBaseResult.md#ispaused) + +*** + +### isPending + +```ts +isPending: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:827](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L827) + +Will be `pending` if there's no cached data and no query attempt was finished yet. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPending`](QueryObserverBaseResult.md#ispending) + +*** + +### isPlaceholderData + +```ts +isPlaceholderData: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:845](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L845) + +Will be `true` if the data shown is the placeholder data. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPlaceholderData`](QueryObserverBaseResult.md#isplaceholderdata) + +*** + +### isRefetchError + +```ts +isRefetchError: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:849](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L849) + +Will be `true` if the query failed while refetching. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetchError`](QueryObserverBaseResult.md#isrefetcherror) + +*** + +### isRefetching + +```ts +isRefetching: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:854](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L854) + +Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. +- Is the same as `isFetching && !isPending`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetching`](QueryObserverBaseResult.md#isrefetching) + +*** + +### isStale + +```ts +isStale: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:858](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L858) + +Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isStale`](QueryObserverBaseResult.md#isstale) + +*** + +### isSuccess + +```ts +isSuccess: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:863](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L863) + +A derived boolean from the `status` variable, provided for convenience. +- `true` if the query has received a response with no errors and is ready to display its data. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isSuccess`](QueryObserverBaseResult.md#issuccess) + +*** + +### refetch() + +```ts +refetch: (options?) => Promise>; +``` + +Defined in: [packages/query-core/src/types.ts:871](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L871) + +A function to manually refetch the query. + +#### Parameters + +##### options? + +[`RefetchOptions`](RefetchOptions.md) + +#### Returns + +`Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`refetch`](QueryObserverBaseResult.md#refetch) + +*** + +### status + +```ts +status: QueryStatus; +``` + +Defined in: [packages/query-core/src/types.ts:881](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L881) + +The status of the query. +- Will be: + - `pending` if there's no cached data and no query attempt was finished yet. + - `error` if the query attempt resulted in an error. + - `success` if the query has received a response with no errors and is ready to display its data. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`status`](QueryObserverBaseResult.md#status) diff --git a/docs/framework/vue/reference/interfaces/InfiniteQueryObserverLoadingErrorResult.md b/docs/framework/vue/reference/interfaces/InfiniteQueryObserverLoadingErrorResult.md new file mode 100644 index 00000000000..f5e3352f27c --- /dev/null +++ b/docs/framework/vue/reference/interfaces/InfiniteQueryObserverLoadingErrorResult.md @@ -0,0 +1,600 @@ +--- +id: InfiniteQueryObserverLoadingErrorResult +title: InfiniteQueryObserverLoadingErrorResult +--- + +Defined in: [packages/query-core/src/types.ts:1078](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1078) + +## Extends + +- [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md)\<`TData`, `TError`\> + +## Type Parameters + +### TData + +`TData` = `unknown` + +### TError + +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) + +## Properties + +### data + +```ts +data: undefined; +``` + +Defined in: [packages/query-core/src/types.ts:1082](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1082) + +The last successfully resolved data for the query. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`data`](InfiniteQueryObserverBaseResult.md#data) + +*** + +### dataUpdatedAt + +```ts +dataUpdatedAt: number; +``` + +Defined in: [packages/query-core/src/types.ts:775](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L775) + +The timestamp for when the query most recently returned the `status` as `"success"`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`dataUpdatedAt`](InfiniteQueryObserverBaseResult.md#dataupdatedat) + +*** + +### error + +```ts +error: TError; +``` + +Defined in: [packages/query-core/src/types.ts:1083](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1083) + +The error object for the query, if an error was thrown. +- Defaults to `null`. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`error`](InfiniteQueryObserverBaseResult.md#error) + +*** + +### errorUpdateCount + +```ts +errorUpdateCount: number; +``` + +Defined in: [packages/query-core/src/types.ts:799](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L799) + +The sum of all errors. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`errorUpdateCount`](InfiniteQueryObserverBaseResult.md#errorupdatecount) + +*** + +### errorUpdatedAt + +```ts +errorUpdatedAt: number; +``` + +Defined in: [packages/query-core/src/types.ts:784](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L784) + +The timestamp for when the query most recently returned the `status` as `"error"`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`errorUpdatedAt`](InfiniteQueryObserverBaseResult.md#errorupdatedat) + +*** + +### failureCount + +```ts +failureCount: number; +``` + +Defined in: [packages/query-core/src/types.ts:790](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L790) + +The failure count for the query. +- Incremented every time the query fails. +- Reset to `0` when the query succeeds. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`failureCount`](InfiniteQueryObserverBaseResult.md#failurecount) + +*** + +### failureReason + +```ts +failureReason: TError | null; +``` + +Defined in: [packages/query-core/src/types.ts:795](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L795) + +The failure reason for the query retry. +- Reset to `null` when the query succeeds. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`failureReason`](InfiniteQueryObserverBaseResult.md#failurereason) + +*** + +### fetchNextPage() + +```ts +fetchNextPage: (options?) => Promise>; +``` + +Defined in: [packages/query-core/src/types.ts:1008](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1008) + +This function allows you to fetch the next "page" of results. + +#### Parameters + +##### options? + +[`FetchNextPageOptions`](FetchNextPageOptions.md) + +#### Returns + +`Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`fetchNextPage`](InfiniteQueryObserverBaseResult.md#fetchnextpage) + +*** + +### fetchPreviousPage() + +```ts +fetchPreviousPage: (options?) => Promise>; +``` + +Defined in: [packages/query-core/src/types.ts:1014](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1014) + +This function allows you to fetch the previous "page" of results. + +#### Parameters + +##### options? + +[`FetchPreviousPageOptions`](FetchPreviousPageOptions.md) + +#### Returns + +`Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`fetchPreviousPage`](InfiniteQueryObserverBaseResult.md#fetchpreviouspage) + +*** + +### fetchStatus + +```ts +fetchStatus: FetchStatus; +``` + +Defined in: [packages/query-core/src/types.ts:889](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L889) + +The fetch status of the query. +- `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. +- `paused`: The query wanted to fetch, but has been `paused`. +- `idle`: The query is not fetching. +- See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`fetchStatus`](InfiniteQueryObserverBaseResult.md#fetchstatus) + +*** + +### hasNextPage + +```ts +hasNextPage: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1020](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1020) + +Will be `true` if there is a next page to be fetched (known via the `getNextPageParam` option). + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`hasNextPage`](InfiniteQueryObserverBaseResult.md#hasnextpage) + +*** + +### hasPreviousPage + +```ts +hasPreviousPage: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1024](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1024) + +Will be `true` if there is a previous page to be fetched (known via the `getPreviousPageParam` option). + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`hasPreviousPage`](InfiniteQueryObserverBaseResult.md#haspreviouspage) + +*** + +### isEnabled + +```ts +isEnabled: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:867](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L867) + +`true` if this observer is enabled, `false` otherwise. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isEnabled`](InfiniteQueryObserverBaseResult.md#isenabled) + +*** + +### isError + +```ts +isError: true; +``` + +Defined in: [packages/query-core/src/types.ts:1084](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1084) + +A derived boolean from the `status` variable, provided for convenience. +- `true` if the query attempt resulted in an error. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isError`](InfiniteQueryObserverBaseResult.md#iserror) + +*** + +### isFetched + +```ts +isFetched: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:808](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L808) + +Will be `true` if the query has been fetched. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetched`](InfiniteQueryObserverBaseResult.md#isfetched) + +*** + +### isFetchedAfterMount + +```ts +isFetchedAfterMount: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:813](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L813) + +Will be `true` if the query has been fetched after the component mounted. +- This property can be used to not show any previously cached data. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchedAfterMount`](InfiniteQueryObserverBaseResult.md#isfetchedaftermount) + +*** + +### isFetching + +```ts +isFetching: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:818](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L818) + +A derived boolean from the `fetchStatus` variable, provided for convenience. +- `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetching`](InfiniteQueryObserverBaseResult.md#isfetching) + +*** + +### isFetchingNextPage + +```ts +isFetchingNextPage: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1032](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1032) + +Will be `true` while fetching the next page with `fetchNextPage`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchingNextPage`](InfiniteQueryObserverBaseResult.md#isfetchingnextpage) + +*** + +### isFetchingPreviousPage + +```ts +isFetchingPreviousPage: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1040](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1040) + +Will be `true` while fetching the previous page with `fetchPreviousPage`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchingPreviousPage`](InfiniteQueryObserverBaseResult.md#isfetchingpreviouspage) + +*** + +### isFetchNextPageError + +```ts +isFetchNextPageError: false; +``` + +Defined in: [packages/query-core/src/types.ts:1089](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1089) + +Will be `true` if the query failed while fetching the next page. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchNextPageError`](InfiniteQueryObserverBaseResult.md#isfetchnextpageerror) + +*** + +### isFetchPreviousPageError + +```ts +isFetchPreviousPageError: false; +``` + +Defined in: [packages/query-core/src/types.ts:1090](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1090) + +Will be `true` if the query failed while fetching the previous page. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchPreviousPageError`](InfiniteQueryObserverBaseResult.md#isfetchpreviouspageerror) + +*** + +### ~~isInitialLoading~~ + +```ts +isInitialLoading: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:836](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L836) + +#### Deprecated + +`isInitialLoading` is being deprecated in favor of `isLoading` +and will be removed in the next major version. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isInitialLoading`](InfiniteQueryObserverBaseResult.md#isinitialloading) + +*** + +### isLoading + +```ts +isLoading: false; +``` + +Defined in: [packages/query-core/src/types.ts:1086](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1086) + +Is `true` whenever the first fetch for a query is in-flight. +- Is the same as `isFetching && isPending`. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoading`](InfiniteQueryObserverBaseResult.md#isloading) + +*** + +### isLoadingError + +```ts +isLoadingError: true; +``` + +Defined in: [packages/query-core/src/types.ts:1087](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1087) + +Will be `true` if the query failed while fetching for the first time. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoadingError`](InfiniteQueryObserverBaseResult.md#isloadingerror) + +*** + +### isPaused + +```ts +isPaused: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:841](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L841) + +A derived boolean from the `fetchStatus` variable, provided for convenience. +- The query wanted to fetch, but has been `paused`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPaused`](InfiniteQueryObserverBaseResult.md#ispaused) + +*** + +### isPending + +```ts +isPending: false; +``` + +Defined in: [packages/query-core/src/types.ts:1085](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1085) + +Will be `pending` if there's no cached data and no query attempt was finished yet. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPending`](InfiniteQueryObserverBaseResult.md#ispending) + +*** + +### isPlaceholderData + +```ts +isPlaceholderData: false; +``` + +Defined in: [packages/query-core/src/types.ts:1092](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1092) + +Will be `true` if the data shown is the placeholder data. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPlaceholderData`](InfiniteQueryObserverBaseResult.md#isplaceholderdata) + +*** + +### isRefetchError + +```ts +isRefetchError: false; +``` + +Defined in: [packages/query-core/src/types.ts:1088](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1088) + +Will be `true` if the query failed while refetching. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isRefetchError`](InfiniteQueryObserverBaseResult.md#isrefetcherror) + +*** + +### isRefetching + +```ts +isRefetching: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:854](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L854) + +Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. +- Is the same as `isFetching && !isPending`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isRefetching`](InfiniteQueryObserverBaseResult.md#isrefetching) + +*** + +### isStale + +```ts +isStale: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:858](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L858) + +Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isStale`](InfiniteQueryObserverBaseResult.md#isstale) + +*** + +### isSuccess + +```ts +isSuccess: false; +``` + +Defined in: [packages/query-core/src/types.ts:1091](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1091) + +A derived boolean from the `status` variable, provided for convenience. +- `true` if the query has received a response with no errors and is ready to display its data. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isSuccess`](InfiniteQueryObserverBaseResult.md#issuccess) + +*** + +### refetch() + +```ts +refetch: (options?) => Promise>; +``` + +Defined in: [packages/query-core/src/types.ts:871](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L871) + +A function to manually refetch the query. + +#### Parameters + +##### options? + +[`RefetchOptions`](RefetchOptions.md) + +#### Returns + +`Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`refetch`](InfiniteQueryObserverBaseResult.md#refetch) + +*** + +### status + +```ts +status: "error"; +``` + +Defined in: [packages/query-core/src/types.ts:1093](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1093) + +The status of the query. +- Will be: + - `pending` if there's no cached data and no query attempt was finished yet. + - `error` if the query attempt resulted in an error. + - `success` if the query has received a response with no errors and is ready to display its data. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`status`](InfiniteQueryObserverBaseResult.md#status) diff --git a/docs/framework/vue/reference/interfaces/InfiniteQueryObserverLoadingResult.md b/docs/framework/vue/reference/interfaces/InfiniteQueryObserverLoadingResult.md new file mode 100644 index 00000000000..b7aa67744c0 --- /dev/null +++ b/docs/framework/vue/reference/interfaces/InfiniteQueryObserverLoadingResult.md @@ -0,0 +1,600 @@ +--- +id: InfiniteQueryObserverLoadingResult +title: InfiniteQueryObserverLoadingResult +--- + +Defined in: [packages/query-core/src/types.ts:1060](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1060) + +## Extends + +- [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md)\<`TData`, `TError`\> + +## Type Parameters + +### TData + +`TData` = `unknown` + +### TError + +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) + +## Properties + +### data + +```ts +data: undefined; +``` + +Defined in: [packages/query-core/src/types.ts:1064](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1064) + +The last successfully resolved data for the query. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`data`](InfiniteQueryObserverBaseResult.md#data) + +*** + +### dataUpdatedAt + +```ts +dataUpdatedAt: number; +``` + +Defined in: [packages/query-core/src/types.ts:775](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L775) + +The timestamp for when the query most recently returned the `status` as `"success"`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`dataUpdatedAt`](InfiniteQueryObserverBaseResult.md#dataupdatedat) + +*** + +### error + +```ts +error: null; +``` + +Defined in: [packages/query-core/src/types.ts:1065](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1065) + +The error object for the query, if an error was thrown. +- Defaults to `null`. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`error`](InfiniteQueryObserverBaseResult.md#error) + +*** + +### errorUpdateCount + +```ts +errorUpdateCount: number; +``` + +Defined in: [packages/query-core/src/types.ts:799](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L799) + +The sum of all errors. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`errorUpdateCount`](InfiniteQueryObserverBaseResult.md#errorupdatecount) + +*** + +### errorUpdatedAt + +```ts +errorUpdatedAt: number; +``` + +Defined in: [packages/query-core/src/types.ts:784](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L784) + +The timestamp for when the query most recently returned the `status` as `"error"`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`errorUpdatedAt`](InfiniteQueryObserverBaseResult.md#errorupdatedat) + +*** + +### failureCount + +```ts +failureCount: number; +``` + +Defined in: [packages/query-core/src/types.ts:790](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L790) + +The failure count for the query. +- Incremented every time the query fails. +- Reset to `0` when the query succeeds. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`failureCount`](InfiniteQueryObserverBaseResult.md#failurecount) + +*** + +### failureReason + +```ts +failureReason: TError | null; +``` + +Defined in: [packages/query-core/src/types.ts:795](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L795) + +The failure reason for the query retry. +- Reset to `null` when the query succeeds. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`failureReason`](InfiniteQueryObserverBaseResult.md#failurereason) + +*** + +### fetchNextPage() + +```ts +fetchNextPage: (options?) => Promise>; +``` + +Defined in: [packages/query-core/src/types.ts:1008](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1008) + +This function allows you to fetch the next "page" of results. + +#### Parameters + +##### options? + +[`FetchNextPageOptions`](FetchNextPageOptions.md) + +#### Returns + +`Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`fetchNextPage`](InfiniteQueryObserverBaseResult.md#fetchnextpage) + +*** + +### fetchPreviousPage() + +```ts +fetchPreviousPage: (options?) => Promise>; +``` + +Defined in: [packages/query-core/src/types.ts:1014](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1014) + +This function allows you to fetch the previous "page" of results. + +#### Parameters + +##### options? + +[`FetchPreviousPageOptions`](FetchPreviousPageOptions.md) + +#### Returns + +`Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`fetchPreviousPage`](InfiniteQueryObserverBaseResult.md#fetchpreviouspage) + +*** + +### fetchStatus + +```ts +fetchStatus: FetchStatus; +``` + +Defined in: [packages/query-core/src/types.ts:889](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L889) + +The fetch status of the query. +- `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. +- `paused`: The query wanted to fetch, but has been `paused`. +- `idle`: The query is not fetching. +- See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`fetchStatus`](InfiniteQueryObserverBaseResult.md#fetchstatus) + +*** + +### hasNextPage + +```ts +hasNextPage: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1020](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1020) + +Will be `true` if there is a next page to be fetched (known via the `getNextPageParam` option). + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`hasNextPage`](InfiniteQueryObserverBaseResult.md#hasnextpage) + +*** + +### hasPreviousPage + +```ts +hasPreviousPage: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1024](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1024) + +Will be `true` if there is a previous page to be fetched (known via the `getPreviousPageParam` option). + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`hasPreviousPage`](InfiniteQueryObserverBaseResult.md#haspreviouspage) + +*** + +### isEnabled + +```ts +isEnabled: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:867](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L867) + +`true` if this observer is enabled, `false` otherwise. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isEnabled`](InfiniteQueryObserverBaseResult.md#isenabled) + +*** + +### isError + +```ts +isError: false; +``` + +Defined in: [packages/query-core/src/types.ts:1066](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1066) + +A derived boolean from the `status` variable, provided for convenience. +- `true` if the query attempt resulted in an error. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isError`](InfiniteQueryObserverBaseResult.md#iserror) + +*** + +### isFetched + +```ts +isFetched: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:808](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L808) + +Will be `true` if the query has been fetched. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetched`](InfiniteQueryObserverBaseResult.md#isfetched) + +*** + +### isFetchedAfterMount + +```ts +isFetchedAfterMount: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:813](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L813) + +Will be `true` if the query has been fetched after the component mounted. +- This property can be used to not show any previously cached data. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchedAfterMount`](InfiniteQueryObserverBaseResult.md#isfetchedaftermount) + +*** + +### isFetching + +```ts +isFetching: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:818](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L818) + +A derived boolean from the `fetchStatus` variable, provided for convenience. +- `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetching`](InfiniteQueryObserverBaseResult.md#isfetching) + +*** + +### isFetchingNextPage + +```ts +isFetchingNextPage: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1032](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1032) + +Will be `true` while fetching the next page with `fetchNextPage`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchingNextPage`](InfiniteQueryObserverBaseResult.md#isfetchingnextpage) + +*** + +### isFetchingPreviousPage + +```ts +isFetchingPreviousPage: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1040](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1040) + +Will be `true` while fetching the previous page with `fetchPreviousPage`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchingPreviousPage`](InfiniteQueryObserverBaseResult.md#isfetchingpreviouspage) + +*** + +### isFetchNextPageError + +```ts +isFetchNextPageError: false; +``` + +Defined in: [packages/query-core/src/types.ts:1071](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1071) + +Will be `true` if the query failed while fetching the next page. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchNextPageError`](InfiniteQueryObserverBaseResult.md#isfetchnextpageerror) + +*** + +### isFetchPreviousPageError + +```ts +isFetchPreviousPageError: false; +``` + +Defined in: [packages/query-core/src/types.ts:1072](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1072) + +Will be `true` if the query failed while fetching the previous page. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchPreviousPageError`](InfiniteQueryObserverBaseResult.md#isfetchpreviouspageerror) + +*** + +### ~~isInitialLoading~~ + +```ts +isInitialLoading: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:836](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L836) + +#### Deprecated + +`isInitialLoading` is being deprecated in favor of `isLoading` +and will be removed in the next major version. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isInitialLoading`](InfiniteQueryObserverBaseResult.md#isinitialloading) + +*** + +### isLoading + +```ts +isLoading: true; +``` + +Defined in: [packages/query-core/src/types.ts:1068](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1068) + +Is `true` whenever the first fetch for a query is in-flight. +- Is the same as `isFetching && isPending`. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoading`](InfiniteQueryObserverBaseResult.md#isloading) + +*** + +### isLoadingError + +```ts +isLoadingError: false; +``` + +Defined in: [packages/query-core/src/types.ts:1069](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1069) + +Will be `true` if the query failed while fetching for the first time. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoadingError`](InfiniteQueryObserverBaseResult.md#isloadingerror) + +*** + +### isPaused + +```ts +isPaused: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:841](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L841) + +A derived boolean from the `fetchStatus` variable, provided for convenience. +- The query wanted to fetch, but has been `paused`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPaused`](InfiniteQueryObserverBaseResult.md#ispaused) + +*** + +### isPending + +```ts +isPending: true; +``` + +Defined in: [packages/query-core/src/types.ts:1067](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1067) + +Will be `pending` if there's no cached data and no query attempt was finished yet. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPending`](InfiniteQueryObserverBaseResult.md#ispending) + +*** + +### isPlaceholderData + +```ts +isPlaceholderData: false; +``` + +Defined in: [packages/query-core/src/types.ts:1074](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1074) + +Will be `true` if the data shown is the placeholder data. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPlaceholderData`](InfiniteQueryObserverBaseResult.md#isplaceholderdata) + +*** + +### isRefetchError + +```ts +isRefetchError: false; +``` + +Defined in: [packages/query-core/src/types.ts:1070](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1070) + +Will be `true` if the query failed while refetching. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isRefetchError`](InfiniteQueryObserverBaseResult.md#isrefetcherror) + +*** + +### isRefetching + +```ts +isRefetching: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:854](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L854) + +Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. +- Is the same as `isFetching && !isPending`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isRefetching`](InfiniteQueryObserverBaseResult.md#isrefetching) + +*** + +### isStale + +```ts +isStale: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:858](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L858) + +Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isStale`](InfiniteQueryObserverBaseResult.md#isstale) + +*** + +### isSuccess + +```ts +isSuccess: false; +``` + +Defined in: [packages/query-core/src/types.ts:1073](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1073) + +A derived boolean from the `status` variable, provided for convenience. +- `true` if the query has received a response with no errors and is ready to display its data. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isSuccess`](InfiniteQueryObserverBaseResult.md#issuccess) + +*** + +### refetch() + +```ts +refetch: (options?) => Promise>; +``` + +Defined in: [packages/query-core/src/types.ts:871](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L871) + +A function to manually refetch the query. + +#### Parameters + +##### options? + +[`RefetchOptions`](RefetchOptions.md) + +#### Returns + +`Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`refetch`](InfiniteQueryObserverBaseResult.md#refetch) + +*** + +### status + +```ts +status: "pending"; +``` + +Defined in: [packages/query-core/src/types.ts:1075](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1075) + +The status of the query. +- Will be: + - `pending` if there's no cached data and no query attempt was finished yet. + - `error` if the query attempt resulted in an error. + - `success` if the query has received a response with no errors and is ready to display its data. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`status`](InfiniteQueryObserverBaseResult.md#status) diff --git a/docs/framework/vue/reference/interfaces/InfiniteQueryObserverOptions.md b/docs/framework/vue/reference/interfaces/InfiniteQueryObserverOptions.md new file mode 100644 index 00000000000..7670bd8e24b --- /dev/null +++ b/docs/framework/vue/reference/interfaces/InfiniteQueryObserverOptions.md @@ -0,0 +1,624 @@ +--- +id: InfiniteQueryObserverOptions +title: InfiniteQueryObserverOptions +--- + +Defined in: [packages/query-core/src/types.ts:539](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L539) + +## Extends + +- [`QueryObserverOptions`](QueryObserverOptions.md)\<`TQueryFnData`, `TError`, `TData`, [`InfiniteData`](InfiniteData.md)\<`TQueryFnData`, `TPageParam`\>, `TQueryKey`, `TPageParam`\>.[`InfiniteQueryPageParamsOptions`](InfiniteQueryPageParamsOptions.md)\<`TQueryFnData`, `TPageParam`\> + +## Type Parameters + +### TQueryFnData + +`TQueryFnData` = `unknown` + +### TError + +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) + +### TData + +`TData` = `TQueryFnData` + +### TQueryKey + +`TQueryKey` *extends* [`QueryKey`](../type-aliases/QueryKey.md) = [`QueryKey`](../type-aliases/QueryKey.md) + +### TPageParam + +`TPageParam` = `unknown` + +## Properties + +### enabled? + +```ts +optional enabled: QueryBooleanOption, TQueryKey>; +``` + +Defined in: [packages/query-core/src/types.ts:398](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L398) + +Set this to `false` or a function that returns `false` to disable automatic refetching when the query mounts or changes query keys. +To refetch the query, use the `refetch` method returned from the `useQuery` instance. +Accepts a boolean or function that returns a boolean. + +Defaults to `true`. + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`enabled`](QueryObserverOptions.md#enabled) + +*** + +### gcTime? + +```ts +optional gcTime: number; +``` + +Defined in: [packages/query-core/src/types.ts:277](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L277) + +The time in milliseconds that unused/inactive cache data remains in memory. +When a query's cache becomes unused or inactive, that cache data will be garbage collected after this duration. +When different garbage collection times are specified, the longest one will be used. +Setting it to `Infinity` will disable garbage collection. + +Defaults to `5 * 60 * 1000` (5 minutes), or `Infinity` during SSR. + +Note: the maximum allowed time is about 24 days, imposed by `setTimeout`'s 32-bit signed integer delay — see +`timeoutManager.setTimeoutProvider` for a workaround. + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`gcTime`](QueryObserverOptions.md#gctime) + +*** + +### getNextPageParam + +```ts +getNextPageParam: GetNextPageParamFunction; +``` + +Defined in: [packages/query-core/src/types.ts:365](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L365) + +This function can be set to automatically get the next cursor for infinite queries. +The result will also be used to determine the value of `hasNextPage`. + +#### Inherited from + +[`InfiniteQueryPageParamsOptions`](InfiniteQueryPageParamsOptions.md).[`getNextPageParam`](InfiniteQueryPageParamsOptions.md#getnextpageparam) + +*** + +### getPreviousPageParam? + +```ts +optional getPreviousPageParam: GetPreviousPageParamFunction; +``` + +Defined in: [packages/query-core/src/types.ts:360](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L360) + +This function can be set to automatically get the previous cursor for infinite queries. +The result will also be used to determine the value of `hasPreviousPage`. + +#### Inherited from + +[`InfiniteQueryPageParamsOptions`](InfiniteQueryPageParamsOptions.md).[`getPreviousPageParam`](InfiniteQueryPageParamsOptions.md#getpreviouspageparam) + +*** + +### initialData? + +```ts +optional initialData: + | InfiniteData +| InitialDataFunction>; +``` + +Defined in: [packages/query-core/src/types.ts:317](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L317) + +If set, this value will be used as the initial data for the query cache (as long as the query hasn't been +created or cached yet). +If set to a function, the function will be called **once** during the shared/root query initialization, and be +expected to synchronously return the initial data. +Initial data is considered stale by default unless a `staleTime` has been set. +`initialData` **is persisted** to the cache. + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`initialData`](QueryObserverOptions.md#initialdata) + +*** + +### initialDataUpdatedAt? + +```ts +optional initialDataUpdatedAt: number | () => number | undefined; +``` + +Defined in: [packages/query-core/src/types.ts:321](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L321) + +If set, this value will be used as the time (in milliseconds) of when the `initialData` itself was last updated. + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`initialDataUpdatedAt`](QueryObserverOptions.md#initialdataupdatedat) + +*** + +### initialPageParam + +```ts +initialPageParam: TPageParam; +``` + +Defined in: [packages/query-core/src/types.ts:349](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L349) + +#### Inherited from + +[`InfiniteQueryPageParamsOptions`](InfiniteQueryPageParamsOptions.md).[`initialPageParam`](InfiniteQueryPageParamsOptions.md#initialpageparam) + +*** + +### maxPages? + +```ts +optional maxPages: number; +``` + +Defined in: [packages/query-core/src/types.ts:345](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L345) + +Maximum number of pages to store in the data of an infinite query. + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`maxPages`](QueryObserverOptions.md#maxpages) + +*** + +### meta? + +```ts +optional meta: Record; +``` + +Defined in: [packages/query-core/src/types.ts:341](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L341) + +Additional payload to be stored on each query. +Use this property to pass information that can be used in other places. + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`meta`](QueryObserverOptions.md#meta) + +*** + +### networkMode? + +```ts +optional networkMode: NetworkMode; +``` + +Defined in: [packages/query-core/src/types.ts:265](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L265) + +Controls whether a query is allowed to run based on the current network connectivity. + +Defaults to `'online'`. + +#### See + +[Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`networkMode`](QueryObserverOptions.md#networkmode) + +*** + +### notifyOnChangeProps? + +```ts +optional notifyOnChangeProps: NotifyOnChangeProps; +``` + +Defined in: [packages/query-core/src/types.ts:484](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L484) + +If set, the component will only re-render if any of the listed properties change. +When set to `['data', 'error']`, the component will only re-render when the `data` or `error` properties change. +When set to `'all'`, the component will re-render whenever a query is updated. +When set to a function, the function will be executed to compute the list of properties. + +Defaults to `undefined`, in which case property access is tracked automatically, and the +component only re-renders when one of the tracked properties changes. + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`notifyOnChangeProps`](QueryObserverOptions.md#notifyonchangeprops) + +*** + +### persister? + +```ts +optional persister: QueryPersister, TPageParam>; +``` + +Defined in: [packages/query-core/src/types.ts:290](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L290) + +This option can be used to persist the result of a query to an external storage, bypassing the need to actually +call the `queryFn`. Useful for persisting a query's data across e.g. server/client boundaries. + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`persister`](QueryObserverOptions.md#persister) + +*** + +### placeholderData? + +```ts +optional placeholderData: + | InfiniteData +| PlaceholderDataFunction, TError, InfiniteData, TQueryKey>; +``` + +Defined in: [packages/query-core/src/types.ts:511](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L511) + +If set, this value will be used as the placeholder data for this particular query observer while the query is still in the `loading` data and no initialData has been provided. + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`placeholderData`](QueryObserverOptions.md#placeholderdata) + +*** + +### queryFn? + +```ts +optional queryFn: + | typeof skipToken +| QueryFunction; +``` + +Defined in: [packages/query-core/src/types.ts:285](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L285) + +The function that the query will use to request data. +Required, unless a default query function has been set via `queryClient.setQueryDefaults` or +`queryClient.setDefaultOptions`. +Receives a [QueryFunctionContext](../type-aliases/QueryFunctionContext.md). +Must return a promise that will either resolve data or throw an error. The data cannot be `undefined`. + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`queryFn`](QueryObserverOptions.md#queryfn) + +*** + +### queryHash? + +```ts +optional queryHash: string; +``` + +Defined in: [packages/query-core/src/types.ts:295](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L295) + +The hashed form of `queryKey`, computed with `queryKeyHashFn` (or the default hashing function otherwise). Used +as the actual cache key internally. + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`queryHash`](QueryObserverOptions.md#queryhash) + +*** + +### queryKey + +```ts +queryKey: TQueryKey & object; +``` + +Defined in: [packages/query-core/src/types.ts:304](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L304) + +The query key to use for this query. + +The query key will be hashed into a stable hash. See [Query Keys](https://tanstack.com/query/latest/docs/framework/react/guides/query-keys) +for more information. + +The query will automatically update when this key changes (as long as `enabled` is not set to `false`). + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`queryKey`](QueryObserverOptions.md#querykey) + +*** + +### queryKeyHashFn? + +```ts +optional queryKeyHashFn: QueryKeyHashFunction; +``` + +Defined in: [packages/query-core/src/types.ts:308](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L308) + +If specified, this function is used to hash the `queryKey` to a string. + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`queryKeyHashFn`](QueryObserverOptions.md#querykeyhashfn) + +*** + +### refetchInterval? + +```ts +optional refetchInterval: number | false | (query) => number | false | undefined; +``` + +Defined in: [packages/query-core/src/types.ts:414](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L414) + +If set to a number, the query will continuously refetch at this frequency in milliseconds. +If set to a function, the function will be executed with the latest data and query to compute a frequency + +Defaults to `false`. + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`refetchInterval`](QueryObserverOptions.md#refetchinterval) + +*** + +### refetchIntervalInBackground? + +```ts +optional refetchIntervalInBackground: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:425](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L425) + +If set to `true`, the query will continue to refetch while their tab/window is in the background. + +Defaults to `false`. + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`refetchIntervalInBackground`](QueryObserverOptions.md#refetchintervalinbackground) + +*** + +### refetchOnMount? + +```ts +optional refetchOnMount: boolean | "always" | (query) => boolean | "always"; +``` + +Defined in: [packages/query-core/src/types.ts:462](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L462) + +If set to `true`, the query will refetch on mount if the data is stale. +If set to `false`, will disable additional instances of a query to trigger background refetch. +If set to `'always'`, the query will always refetch on mount (except when `staleTime: 'static'` is used). +If set to a function, the function will be executed with the latest data and query to compute the value + +Defaults to `true`. + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`refetchOnMount`](QueryObserverOptions.md#refetchonmount) + +*** + +### refetchOnReconnect? + +```ts +optional refetchOnReconnect: boolean | "always" | (query) => boolean | "always"; +``` + +Defined in: [packages/query-core/src/types.ts:448](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L448) + +If set to `true`, the query will refetch on reconnect if the data is stale. +If set to `false`, the query will not refetch on reconnect. +If set to `'always'`, the query will always refetch on reconnect (except when `staleTime: 'static'` is used). +If set to a function, the function will be executed with the latest data and query to compute the value. + +Defaults to `true` unless `networkMode` is `'always'`. + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`refetchOnReconnect`](QueryObserverOptions.md#refetchonreconnect) + +*** + +### refetchOnWindowFocus? + +```ts +optional refetchOnWindowFocus: boolean | "always" | (query) => boolean | "always"; +``` + +Defined in: [packages/query-core/src/types.ts:434](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L434) + +If set to `true`, the query will refetch on window focus if the data is stale. +If set to `false`, the query will not refetch on window focus. +If set to `'always'`, the query will always refetch on window focus (except when `staleTime: 'static'` is used). +If set to a function, the function will be executed with the latest data and query to compute the value. + +Defaults to `true`. + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`refetchOnWindowFocus`](QueryObserverOptions.md#refetchonwindowfocus) + +*** + +### retry? + +```ts +optional retry: RetryValue; +``` + +Defined in: [packages/query-core/src/types.ts:246](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L246) + +If `false`, failed queries will not retry by default. +If `true`, failed queries will retry infinitely. +If set to an integer number, e.g. 3, failed queries will retry until the failed query count meets that number. +If set to a function `(failureCount, error) => boolean` failed queries will retry until the function returns false. + +Defaults to `3` on the client and `0` on the server. + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`retry`](QueryObserverOptions.md#retry) + +*** + +### retryDelay? + +```ts +optional retryDelay: RetryDelayValue; +``` + +Defined in: [packages/query-core/src/types.ts:258](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L258) + +This function receives a `retryAttempt` integer and the actual Error and returns the delay to apply before the +next attempt in milliseconds. + +A function like `attempt => Math.min(attempt > 1 ? 2 ** attempt * 1000 : 1000, 30 * 1000)` applies exponential +backoff. + +A function like `attempt => attempt * 1000` applies linear backoff. + +Defaults to a function that applies exponential backoff, capped at 30 seconds. + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`retryDelay`](QueryObserverOptions.md#retrydelay) + +*** + +### retryOnMount? + +```ts +optional retryOnMount: QueryBooleanOption, TQueryKey>; +``` + +Defined in: [packages/query-core/src/types.ts:474](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L474) + +If set to `false`, the query will not be retried on mount if it contains an error. +If set to a function, the function will be executed with the query to compute the value. + +Defaults to `true`. + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`retryOnMount`](QueryObserverOptions.md#retryonmount) + +*** + +### select()? + +```ts +optional select: (data) => TData; +``` + +Defined in: [packages/query-core/src/types.ts:500](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L500) + +This option can be used to transform or select a part of the data returned by the query function. It affects +the returned `data` value, but does not affect what gets stored in the query cache. +The `select` function will only run if `data` changed, or if the reference to the `select` function itself +changes. To optimize, memoize the function so its reference stays stable across calls. + +#### Parameters + +##### data + +[`InfiniteData`](InfiniteData.md) + +#### Returns + +`TData` + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`select`](QueryObserverOptions.md#select) + +*** + +### staleTime? + +```ts +optional staleTime: StaleTimeFunction, TQueryKey>; +``` + +Defined in: [packages/query-core/src/types.ts:407](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L407) + +The time in milliseconds after data is considered stale. +If set to `Infinity`, the data will never be considered stale. +If set to `'static'`, the data will never be considered stale. +If set to a function, the function will be executed with the query to compute a `staleTime`. + +Defaults to `0`. + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`staleTime`](QueryObserverOptions.md#staletime) + +*** + +### structuralSharing? + +```ts +optional structuralSharing: boolean | (oldData, newData) => unknown; +``` + +Defined in: [packages/query-core/src/types.ts:330](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L330) + +Set this to `false` to disable structural sharing between query results. +Set this to a function which accepts the old and new data and returns resolved data of the same type to implement custom structural sharing logic. + +Defaults to `true`. + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`structuralSharing`](QueryObserverOptions.md#structuralsharing) + +*** + +### suspense? + +```ts +optional suspense: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:507](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L507) + +If set to `true`, the query will suspend when `status === 'pending'` +and throw errors when `status === 'error'`. + +Defaults to `false`. + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`suspense`](QueryObserverOptions.md#suspense) + +*** + +### throwOnError? + +```ts +optional throwOnError: ThrowOnError, TQueryKey>; +``` + +Defined in: [packages/query-core/src/types.ts:493](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L493) + +Whether errors should be thrown instead of setting the `error` property. +If set to `true` or `suspense` is `true`, all errors will be thrown to the error boundary. +If set to `false` and `suspense` is `false`, errors are returned as state. +If set to a function, it will be passed the error and the query, and it should return a boolean indicating whether to show the error in an error boundary (`true`) or return the error as state (`false`). + +Defaults to `false`. + +#### Inherited from + +[`QueryObserverOptions`](QueryObserverOptions.md).[`throwOnError`](QueryObserverOptions.md#throwonerror) diff --git a/docs/framework/vue/reference/interfaces/InfiniteQueryObserverPendingResult.md b/docs/framework/vue/reference/interfaces/InfiniteQueryObserverPendingResult.md new file mode 100644 index 00000000000..a09301ab6c4 --- /dev/null +++ b/docs/framework/vue/reference/interfaces/InfiniteQueryObserverPendingResult.md @@ -0,0 +1,600 @@ +--- +id: InfiniteQueryObserverPendingResult +title: InfiniteQueryObserverPendingResult +--- + +Defined in: [packages/query-core/src/types.ts:1043](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1043) + +## Extends + +- [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md)\<`TData`, `TError`\> + +## Type Parameters + +### TData + +`TData` = `unknown` + +### TError + +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) + +## Properties + +### data + +```ts +data: undefined; +``` + +Defined in: [packages/query-core/src/types.ts:1047](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1047) + +The last successfully resolved data for the query. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`data`](InfiniteQueryObserverBaseResult.md#data) + +*** + +### dataUpdatedAt + +```ts +dataUpdatedAt: number; +``` + +Defined in: [packages/query-core/src/types.ts:775](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L775) + +The timestamp for when the query most recently returned the `status` as `"success"`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`dataUpdatedAt`](InfiniteQueryObserverBaseResult.md#dataupdatedat) + +*** + +### error + +```ts +error: null; +``` + +Defined in: [packages/query-core/src/types.ts:1048](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1048) + +The error object for the query, if an error was thrown. +- Defaults to `null`. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`error`](InfiniteQueryObserverBaseResult.md#error) + +*** + +### errorUpdateCount + +```ts +errorUpdateCount: number; +``` + +Defined in: [packages/query-core/src/types.ts:799](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L799) + +The sum of all errors. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`errorUpdateCount`](InfiniteQueryObserverBaseResult.md#errorupdatecount) + +*** + +### errorUpdatedAt + +```ts +errorUpdatedAt: number; +``` + +Defined in: [packages/query-core/src/types.ts:784](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L784) + +The timestamp for when the query most recently returned the `status` as `"error"`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`errorUpdatedAt`](InfiniteQueryObserverBaseResult.md#errorupdatedat) + +*** + +### failureCount + +```ts +failureCount: number; +``` + +Defined in: [packages/query-core/src/types.ts:790](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L790) + +The failure count for the query. +- Incremented every time the query fails. +- Reset to `0` when the query succeeds. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`failureCount`](InfiniteQueryObserverBaseResult.md#failurecount) + +*** + +### failureReason + +```ts +failureReason: TError | null; +``` + +Defined in: [packages/query-core/src/types.ts:795](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L795) + +The failure reason for the query retry. +- Reset to `null` when the query succeeds. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`failureReason`](InfiniteQueryObserverBaseResult.md#failurereason) + +*** + +### fetchNextPage() + +```ts +fetchNextPage: (options?) => Promise>; +``` + +Defined in: [packages/query-core/src/types.ts:1008](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1008) + +This function allows you to fetch the next "page" of results. + +#### Parameters + +##### options? + +[`FetchNextPageOptions`](FetchNextPageOptions.md) + +#### Returns + +`Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`fetchNextPage`](InfiniteQueryObserverBaseResult.md#fetchnextpage) + +*** + +### fetchPreviousPage() + +```ts +fetchPreviousPage: (options?) => Promise>; +``` + +Defined in: [packages/query-core/src/types.ts:1014](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1014) + +This function allows you to fetch the previous "page" of results. + +#### Parameters + +##### options? + +[`FetchPreviousPageOptions`](FetchPreviousPageOptions.md) + +#### Returns + +`Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`fetchPreviousPage`](InfiniteQueryObserverBaseResult.md#fetchpreviouspage) + +*** + +### fetchStatus + +```ts +fetchStatus: FetchStatus; +``` + +Defined in: [packages/query-core/src/types.ts:889](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L889) + +The fetch status of the query. +- `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. +- `paused`: The query wanted to fetch, but has been `paused`. +- `idle`: The query is not fetching. +- See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`fetchStatus`](InfiniteQueryObserverBaseResult.md#fetchstatus) + +*** + +### hasNextPage + +```ts +hasNextPage: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1020](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1020) + +Will be `true` if there is a next page to be fetched (known via the `getNextPageParam` option). + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`hasNextPage`](InfiniteQueryObserverBaseResult.md#hasnextpage) + +*** + +### hasPreviousPage + +```ts +hasPreviousPage: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1024](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1024) + +Will be `true` if there is a previous page to be fetched (known via the `getPreviousPageParam` option). + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`hasPreviousPage`](InfiniteQueryObserverBaseResult.md#haspreviouspage) + +*** + +### isEnabled + +```ts +isEnabled: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:867](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L867) + +`true` if this observer is enabled, `false` otherwise. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isEnabled`](InfiniteQueryObserverBaseResult.md#isenabled) + +*** + +### isError + +```ts +isError: false; +``` + +Defined in: [packages/query-core/src/types.ts:1049](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1049) + +A derived boolean from the `status` variable, provided for convenience. +- `true` if the query attempt resulted in an error. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isError`](InfiniteQueryObserverBaseResult.md#iserror) + +*** + +### isFetched + +```ts +isFetched: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:808](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L808) + +Will be `true` if the query has been fetched. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetched`](InfiniteQueryObserverBaseResult.md#isfetched) + +*** + +### isFetchedAfterMount + +```ts +isFetchedAfterMount: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:813](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L813) + +Will be `true` if the query has been fetched after the component mounted. +- This property can be used to not show any previously cached data. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchedAfterMount`](InfiniteQueryObserverBaseResult.md#isfetchedaftermount) + +*** + +### isFetching + +```ts +isFetching: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:818](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L818) + +A derived boolean from the `fetchStatus` variable, provided for convenience. +- `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetching`](InfiniteQueryObserverBaseResult.md#isfetching) + +*** + +### isFetchingNextPage + +```ts +isFetchingNextPage: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1032](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1032) + +Will be `true` while fetching the next page with `fetchNextPage`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchingNextPage`](InfiniteQueryObserverBaseResult.md#isfetchingnextpage) + +*** + +### isFetchingPreviousPage + +```ts +isFetchingPreviousPage: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1040](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1040) + +Will be `true` while fetching the previous page with `fetchPreviousPage`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchingPreviousPage`](InfiniteQueryObserverBaseResult.md#isfetchingpreviouspage) + +*** + +### isFetchNextPageError + +```ts +isFetchNextPageError: false; +``` + +Defined in: [packages/query-core/src/types.ts:1053](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1053) + +Will be `true` if the query failed while fetching the next page. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchNextPageError`](InfiniteQueryObserverBaseResult.md#isfetchnextpageerror) + +*** + +### isFetchPreviousPageError + +```ts +isFetchPreviousPageError: false; +``` + +Defined in: [packages/query-core/src/types.ts:1054](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1054) + +Will be `true` if the query failed while fetching the previous page. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchPreviousPageError`](InfiniteQueryObserverBaseResult.md#isfetchpreviouspageerror) + +*** + +### ~~isInitialLoading~~ + +```ts +isInitialLoading: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:836](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L836) + +#### Deprecated + +`isInitialLoading` is being deprecated in favor of `isLoading` +and will be removed in the next major version. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isInitialLoading`](InfiniteQueryObserverBaseResult.md#isinitialloading) + +*** + +### isLoading + +```ts +isLoading: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:823](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L823) + +Is `true` whenever the first fetch for a query is in-flight. +- Is the same as `isFetching && isPending`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoading`](InfiniteQueryObserverBaseResult.md#isloading) + +*** + +### isLoadingError + +```ts +isLoadingError: false; +``` + +Defined in: [packages/query-core/src/types.ts:1051](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1051) + +Will be `true` if the query failed while fetching for the first time. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoadingError`](InfiniteQueryObserverBaseResult.md#isloadingerror) + +*** + +### isPaused + +```ts +isPaused: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:841](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L841) + +A derived boolean from the `fetchStatus` variable, provided for convenience. +- The query wanted to fetch, but has been `paused`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPaused`](InfiniteQueryObserverBaseResult.md#ispaused) + +*** + +### isPending + +```ts +isPending: true; +``` + +Defined in: [packages/query-core/src/types.ts:1050](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1050) + +Will be `pending` if there's no cached data and no query attempt was finished yet. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPending`](InfiniteQueryObserverBaseResult.md#ispending) + +*** + +### isPlaceholderData + +```ts +isPlaceholderData: false; +``` + +Defined in: [packages/query-core/src/types.ts:1056](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1056) + +Will be `true` if the data shown is the placeholder data. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPlaceholderData`](InfiniteQueryObserverBaseResult.md#isplaceholderdata) + +*** + +### isRefetchError + +```ts +isRefetchError: false; +``` + +Defined in: [packages/query-core/src/types.ts:1052](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1052) + +Will be `true` if the query failed while refetching. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isRefetchError`](InfiniteQueryObserverBaseResult.md#isrefetcherror) + +*** + +### isRefetching + +```ts +isRefetching: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:854](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L854) + +Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. +- Is the same as `isFetching && !isPending`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isRefetching`](InfiniteQueryObserverBaseResult.md#isrefetching) + +*** + +### isStale + +```ts +isStale: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:858](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L858) + +Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isStale`](InfiniteQueryObserverBaseResult.md#isstale) + +*** + +### isSuccess + +```ts +isSuccess: false; +``` + +Defined in: [packages/query-core/src/types.ts:1055](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1055) + +A derived boolean from the `status` variable, provided for convenience. +- `true` if the query has received a response with no errors and is ready to display its data. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isSuccess`](InfiniteQueryObserverBaseResult.md#issuccess) + +*** + +### refetch() + +```ts +refetch: (options?) => Promise>; +``` + +Defined in: [packages/query-core/src/types.ts:871](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L871) + +A function to manually refetch the query. + +#### Parameters + +##### options? + +[`RefetchOptions`](RefetchOptions.md) + +#### Returns + +`Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`refetch`](InfiniteQueryObserverBaseResult.md#refetch) + +*** + +### status + +```ts +status: "pending"; +``` + +Defined in: [packages/query-core/src/types.ts:1057](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1057) + +The status of the query. +- Will be: + - `pending` if there's no cached data and no query attempt was finished yet. + - `error` if the query attempt resulted in an error. + - `success` if the query has received a response with no errors and is ready to display its data. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`status`](InfiniteQueryObserverBaseResult.md#status) diff --git a/docs/framework/vue/reference/interfaces/InfiniteQueryObserverPlaceholderResult.md b/docs/framework/vue/reference/interfaces/InfiniteQueryObserverPlaceholderResult.md new file mode 100644 index 00000000000..58193a987d1 --- /dev/null +++ b/docs/framework/vue/reference/interfaces/InfiniteQueryObserverPlaceholderResult.md @@ -0,0 +1,600 @@ +--- +id: InfiniteQueryObserverPlaceholderResult +title: InfiniteQueryObserverPlaceholderResult +--- + +Defined in: [packages/query-core/src/types.ts:1130](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1130) + +## Extends + +- [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md)\<`TData`, `TError`\> + +## Type Parameters + +### TData + +`TData` = `unknown` + +### TError + +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) + +## Properties + +### data + +```ts +data: TData; +``` + +Defined in: [packages/query-core/src/types.ts:1134](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1134) + +The last successfully resolved data for the query. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`data`](InfiniteQueryObserverBaseResult.md#data) + +*** + +### dataUpdatedAt + +```ts +dataUpdatedAt: number; +``` + +Defined in: [packages/query-core/src/types.ts:775](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L775) + +The timestamp for when the query most recently returned the `status` as `"success"`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`dataUpdatedAt`](InfiniteQueryObserverBaseResult.md#dataupdatedat) + +*** + +### error + +```ts +error: null; +``` + +Defined in: [packages/query-core/src/types.ts:1136](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1136) + +The error object for the query, if an error was thrown. +- Defaults to `null`. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`error`](InfiniteQueryObserverBaseResult.md#error) + +*** + +### errorUpdateCount + +```ts +errorUpdateCount: number; +``` + +Defined in: [packages/query-core/src/types.ts:799](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L799) + +The sum of all errors. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`errorUpdateCount`](InfiniteQueryObserverBaseResult.md#errorupdatecount) + +*** + +### errorUpdatedAt + +```ts +errorUpdatedAt: number; +``` + +Defined in: [packages/query-core/src/types.ts:784](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L784) + +The timestamp for when the query most recently returned the `status` as `"error"`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`errorUpdatedAt`](InfiniteQueryObserverBaseResult.md#errorupdatedat) + +*** + +### failureCount + +```ts +failureCount: number; +``` + +Defined in: [packages/query-core/src/types.ts:790](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L790) + +The failure count for the query. +- Incremented every time the query fails. +- Reset to `0` when the query succeeds. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`failureCount`](InfiniteQueryObserverBaseResult.md#failurecount) + +*** + +### failureReason + +```ts +failureReason: TError | null; +``` + +Defined in: [packages/query-core/src/types.ts:795](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L795) + +The failure reason for the query retry. +- Reset to `null` when the query succeeds. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`failureReason`](InfiniteQueryObserverBaseResult.md#failurereason) + +*** + +### fetchNextPage() + +```ts +fetchNextPage: (options?) => Promise>; +``` + +Defined in: [packages/query-core/src/types.ts:1008](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1008) + +This function allows you to fetch the next "page" of results. + +#### Parameters + +##### options? + +[`FetchNextPageOptions`](FetchNextPageOptions.md) + +#### Returns + +`Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`fetchNextPage`](InfiniteQueryObserverBaseResult.md#fetchnextpage) + +*** + +### fetchPreviousPage() + +```ts +fetchPreviousPage: (options?) => Promise>; +``` + +Defined in: [packages/query-core/src/types.ts:1014](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1014) + +This function allows you to fetch the previous "page" of results. + +#### Parameters + +##### options? + +[`FetchPreviousPageOptions`](FetchPreviousPageOptions.md) + +#### Returns + +`Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`fetchPreviousPage`](InfiniteQueryObserverBaseResult.md#fetchpreviouspage) + +*** + +### fetchStatus + +```ts +fetchStatus: FetchStatus; +``` + +Defined in: [packages/query-core/src/types.ts:889](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L889) + +The fetch status of the query. +- `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. +- `paused`: The query wanted to fetch, but has been `paused`. +- `idle`: The query is not fetching. +- See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`fetchStatus`](InfiniteQueryObserverBaseResult.md#fetchstatus) + +*** + +### hasNextPage + +```ts +hasNextPage: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1020](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1020) + +Will be `true` if there is a next page to be fetched (known via the `getNextPageParam` option). + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`hasNextPage`](InfiniteQueryObserverBaseResult.md#hasnextpage) + +*** + +### hasPreviousPage + +```ts +hasPreviousPage: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1024](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1024) + +Will be `true` if there is a previous page to be fetched (known via the `getPreviousPageParam` option). + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`hasPreviousPage`](InfiniteQueryObserverBaseResult.md#haspreviouspage) + +*** + +### isEnabled + +```ts +isEnabled: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:867](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L867) + +`true` if this observer is enabled, `false` otherwise. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isEnabled`](InfiniteQueryObserverBaseResult.md#isenabled) + +*** + +### isError + +```ts +isError: false; +``` + +Defined in: [packages/query-core/src/types.ts:1135](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1135) + +A derived boolean from the `status` variable, provided for convenience. +- `true` if the query attempt resulted in an error. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isError`](InfiniteQueryObserverBaseResult.md#iserror) + +*** + +### isFetched + +```ts +isFetched: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:808](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L808) + +Will be `true` if the query has been fetched. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetched`](InfiniteQueryObserverBaseResult.md#isfetched) + +*** + +### isFetchedAfterMount + +```ts +isFetchedAfterMount: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:813](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L813) + +Will be `true` if the query has been fetched after the component mounted. +- This property can be used to not show any previously cached data. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchedAfterMount`](InfiniteQueryObserverBaseResult.md#isfetchedaftermount) + +*** + +### isFetching + +```ts +isFetching: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:818](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L818) + +A derived boolean from the `fetchStatus` variable, provided for convenience. +- `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetching`](InfiniteQueryObserverBaseResult.md#isfetching) + +*** + +### isFetchingNextPage + +```ts +isFetchingNextPage: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1032](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1032) + +Will be `true` while fetching the next page with `fetchNextPage`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchingNextPage`](InfiniteQueryObserverBaseResult.md#isfetchingnextpage) + +*** + +### isFetchingPreviousPage + +```ts +isFetchingPreviousPage: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1040](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1040) + +Will be `true` while fetching the previous page with `fetchPreviousPage`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchingPreviousPage`](InfiniteQueryObserverBaseResult.md#isfetchingpreviouspage) + +*** + +### isFetchNextPageError + +```ts +isFetchNextPageError: false; +``` + +Defined in: [packages/query-core/src/types.ts:1143](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1143) + +Will be `true` if the query failed while fetching the next page. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchNextPageError`](InfiniteQueryObserverBaseResult.md#isfetchnextpageerror) + +*** + +### isFetchPreviousPageError + +```ts +isFetchPreviousPageError: false; +``` + +Defined in: [packages/query-core/src/types.ts:1144](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1144) + +Will be `true` if the query failed while fetching the previous page. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchPreviousPageError`](InfiniteQueryObserverBaseResult.md#isfetchpreviouspageerror) + +*** + +### ~~isInitialLoading~~ + +```ts +isInitialLoading: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:836](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L836) + +#### Deprecated + +`isInitialLoading` is being deprecated in favor of `isLoading` +and will be removed in the next major version. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isInitialLoading`](InfiniteQueryObserverBaseResult.md#isinitialloading) + +*** + +### isLoading + +```ts +isLoading: false; +``` + +Defined in: [packages/query-core/src/types.ts:1138](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1138) + +Is `true` whenever the first fetch for a query is in-flight. +- Is the same as `isFetching && isPending`. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoading`](InfiniteQueryObserverBaseResult.md#isloading) + +*** + +### isLoadingError + +```ts +isLoadingError: false; +``` + +Defined in: [packages/query-core/src/types.ts:1139](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1139) + +Will be `true` if the query failed while fetching for the first time. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoadingError`](InfiniteQueryObserverBaseResult.md#isloadingerror) + +*** + +### isPaused + +```ts +isPaused: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:841](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L841) + +A derived boolean from the `fetchStatus` variable, provided for convenience. +- The query wanted to fetch, but has been `paused`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPaused`](InfiniteQueryObserverBaseResult.md#ispaused) + +*** + +### isPending + +```ts +isPending: false; +``` + +Defined in: [packages/query-core/src/types.ts:1137](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1137) + +Will be `pending` if there's no cached data and no query attempt was finished yet. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPending`](InfiniteQueryObserverBaseResult.md#ispending) + +*** + +### isPlaceholderData + +```ts +isPlaceholderData: true; +``` + +Defined in: [packages/query-core/src/types.ts:1142](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1142) + +Will be `true` if the data shown is the placeholder data. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPlaceholderData`](InfiniteQueryObserverBaseResult.md#isplaceholderdata) + +*** + +### isRefetchError + +```ts +isRefetchError: false; +``` + +Defined in: [packages/query-core/src/types.ts:1140](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1140) + +Will be `true` if the query failed while refetching. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isRefetchError`](InfiniteQueryObserverBaseResult.md#isrefetcherror) + +*** + +### isRefetching + +```ts +isRefetching: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:854](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L854) + +Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. +- Is the same as `isFetching && !isPending`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isRefetching`](InfiniteQueryObserverBaseResult.md#isrefetching) + +*** + +### isStale + +```ts +isStale: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:858](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L858) + +Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isStale`](InfiniteQueryObserverBaseResult.md#isstale) + +*** + +### isSuccess + +```ts +isSuccess: true; +``` + +Defined in: [packages/query-core/src/types.ts:1141](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1141) + +A derived boolean from the `status` variable, provided for convenience. +- `true` if the query has received a response with no errors and is ready to display its data. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isSuccess`](InfiniteQueryObserverBaseResult.md#issuccess) + +*** + +### refetch() + +```ts +refetch: (options?) => Promise>; +``` + +Defined in: [packages/query-core/src/types.ts:871](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L871) + +A function to manually refetch the query. + +#### Parameters + +##### options? + +[`RefetchOptions`](RefetchOptions.md) + +#### Returns + +`Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`refetch`](InfiniteQueryObserverBaseResult.md#refetch) + +*** + +### status + +```ts +status: "success"; +``` + +Defined in: [packages/query-core/src/types.ts:1145](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1145) + +The status of the query. +- Will be: + - `pending` if there's no cached data and no query attempt was finished yet. + - `error` if the query attempt resulted in an error. + - `success` if the query has received a response with no errors and is ready to display its data. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`status`](InfiniteQueryObserverBaseResult.md#status) diff --git a/docs/framework/vue/reference/interfaces/InfiniteQueryObserverRefetchErrorResult.md b/docs/framework/vue/reference/interfaces/InfiniteQueryObserverRefetchErrorResult.md new file mode 100644 index 00000000000..4ce469bceed --- /dev/null +++ b/docs/framework/vue/reference/interfaces/InfiniteQueryObserverRefetchErrorResult.md @@ -0,0 +1,600 @@ +--- +id: InfiniteQueryObserverRefetchErrorResult +title: InfiniteQueryObserverRefetchErrorResult +--- + +Defined in: [packages/query-core/src/types.ts:1096](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1096) + +## Extends + +- [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md)\<`TData`, `TError`\> + +## Type Parameters + +### TData + +`TData` = `unknown` + +### TError + +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) + +## Properties + +### data + +```ts +data: TData; +``` + +Defined in: [packages/query-core/src/types.ts:1100](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1100) + +The last successfully resolved data for the query. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`data`](InfiniteQueryObserverBaseResult.md#data) + +*** + +### dataUpdatedAt + +```ts +dataUpdatedAt: number; +``` + +Defined in: [packages/query-core/src/types.ts:775](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L775) + +The timestamp for when the query most recently returned the `status` as `"success"`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`dataUpdatedAt`](InfiniteQueryObserverBaseResult.md#dataupdatedat) + +*** + +### error + +```ts +error: TError; +``` + +Defined in: [packages/query-core/src/types.ts:1101](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1101) + +The error object for the query, if an error was thrown. +- Defaults to `null`. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`error`](InfiniteQueryObserverBaseResult.md#error) + +*** + +### errorUpdateCount + +```ts +errorUpdateCount: number; +``` + +Defined in: [packages/query-core/src/types.ts:799](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L799) + +The sum of all errors. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`errorUpdateCount`](InfiniteQueryObserverBaseResult.md#errorupdatecount) + +*** + +### errorUpdatedAt + +```ts +errorUpdatedAt: number; +``` + +Defined in: [packages/query-core/src/types.ts:784](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L784) + +The timestamp for when the query most recently returned the `status` as `"error"`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`errorUpdatedAt`](InfiniteQueryObserverBaseResult.md#errorupdatedat) + +*** + +### failureCount + +```ts +failureCount: number; +``` + +Defined in: [packages/query-core/src/types.ts:790](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L790) + +The failure count for the query. +- Incremented every time the query fails. +- Reset to `0` when the query succeeds. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`failureCount`](InfiniteQueryObserverBaseResult.md#failurecount) + +*** + +### failureReason + +```ts +failureReason: TError | null; +``` + +Defined in: [packages/query-core/src/types.ts:795](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L795) + +The failure reason for the query retry. +- Reset to `null` when the query succeeds. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`failureReason`](InfiniteQueryObserverBaseResult.md#failurereason) + +*** + +### fetchNextPage() + +```ts +fetchNextPage: (options?) => Promise>; +``` + +Defined in: [packages/query-core/src/types.ts:1008](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1008) + +This function allows you to fetch the next "page" of results. + +#### Parameters + +##### options? + +[`FetchNextPageOptions`](FetchNextPageOptions.md) + +#### Returns + +`Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`fetchNextPage`](InfiniteQueryObserverBaseResult.md#fetchnextpage) + +*** + +### fetchPreviousPage() + +```ts +fetchPreviousPage: (options?) => Promise>; +``` + +Defined in: [packages/query-core/src/types.ts:1014](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1014) + +This function allows you to fetch the previous "page" of results. + +#### Parameters + +##### options? + +[`FetchPreviousPageOptions`](FetchPreviousPageOptions.md) + +#### Returns + +`Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`fetchPreviousPage`](InfiniteQueryObserverBaseResult.md#fetchpreviouspage) + +*** + +### fetchStatus + +```ts +fetchStatus: FetchStatus; +``` + +Defined in: [packages/query-core/src/types.ts:889](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L889) + +The fetch status of the query. +- `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. +- `paused`: The query wanted to fetch, but has been `paused`. +- `idle`: The query is not fetching. +- See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`fetchStatus`](InfiniteQueryObserverBaseResult.md#fetchstatus) + +*** + +### hasNextPage + +```ts +hasNextPage: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1020](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1020) + +Will be `true` if there is a next page to be fetched (known via the `getNextPageParam` option). + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`hasNextPage`](InfiniteQueryObserverBaseResult.md#hasnextpage) + +*** + +### hasPreviousPage + +```ts +hasPreviousPage: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1024](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1024) + +Will be `true` if there is a previous page to be fetched (known via the `getPreviousPageParam` option). + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`hasPreviousPage`](InfiniteQueryObserverBaseResult.md#haspreviouspage) + +*** + +### isEnabled + +```ts +isEnabled: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:867](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L867) + +`true` if this observer is enabled, `false` otherwise. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isEnabled`](InfiniteQueryObserverBaseResult.md#isenabled) + +*** + +### isError + +```ts +isError: true; +``` + +Defined in: [packages/query-core/src/types.ts:1102](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1102) + +A derived boolean from the `status` variable, provided for convenience. +- `true` if the query attempt resulted in an error. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isError`](InfiniteQueryObserverBaseResult.md#iserror) + +*** + +### isFetched + +```ts +isFetched: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:808](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L808) + +Will be `true` if the query has been fetched. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetched`](InfiniteQueryObserverBaseResult.md#isfetched) + +*** + +### isFetchedAfterMount + +```ts +isFetchedAfterMount: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:813](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L813) + +Will be `true` if the query has been fetched after the component mounted. +- This property can be used to not show any previously cached data. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchedAfterMount`](InfiniteQueryObserverBaseResult.md#isfetchedaftermount) + +*** + +### isFetching + +```ts +isFetching: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:818](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L818) + +A derived boolean from the `fetchStatus` variable, provided for convenience. +- `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetching`](InfiniteQueryObserverBaseResult.md#isfetching) + +*** + +### isFetchingNextPage + +```ts +isFetchingNextPage: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1032](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1032) + +Will be `true` while fetching the next page with `fetchNextPage`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchingNextPage`](InfiniteQueryObserverBaseResult.md#isfetchingnextpage) + +*** + +### isFetchingPreviousPage + +```ts +isFetchingPreviousPage: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1040](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1040) + +Will be `true` while fetching the previous page with `fetchPreviousPage`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchingPreviousPage`](InfiniteQueryObserverBaseResult.md#isfetchingpreviouspage) + +*** + +### isFetchNextPageError + +```ts +isFetchNextPageError: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1028](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1028) + +Will be `true` if the query failed while fetching the next page. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchNextPageError`](InfiniteQueryObserverBaseResult.md#isfetchnextpageerror) + +*** + +### isFetchPreviousPageError + +```ts +isFetchPreviousPageError: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1036](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1036) + +Will be `true` if the query failed while fetching the previous page. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchPreviousPageError`](InfiniteQueryObserverBaseResult.md#isfetchpreviouspageerror) + +*** + +### ~~isInitialLoading~~ + +```ts +isInitialLoading: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:836](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L836) + +#### Deprecated + +`isInitialLoading` is being deprecated in favor of `isLoading` +and will be removed in the next major version. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isInitialLoading`](InfiniteQueryObserverBaseResult.md#isinitialloading) + +*** + +### isLoading + +```ts +isLoading: false; +``` + +Defined in: [packages/query-core/src/types.ts:1104](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1104) + +Is `true` whenever the first fetch for a query is in-flight. +- Is the same as `isFetching && isPending`. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoading`](InfiniteQueryObserverBaseResult.md#isloading) + +*** + +### isLoadingError + +```ts +isLoadingError: false; +``` + +Defined in: [packages/query-core/src/types.ts:1105](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1105) + +Will be `true` if the query failed while fetching for the first time. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoadingError`](InfiniteQueryObserverBaseResult.md#isloadingerror) + +*** + +### isPaused + +```ts +isPaused: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:841](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L841) + +A derived boolean from the `fetchStatus` variable, provided for convenience. +- The query wanted to fetch, but has been `paused`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPaused`](InfiniteQueryObserverBaseResult.md#ispaused) + +*** + +### isPending + +```ts +isPending: false; +``` + +Defined in: [packages/query-core/src/types.ts:1103](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1103) + +Will be `pending` if there's no cached data and no query attempt was finished yet. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPending`](InfiniteQueryObserverBaseResult.md#ispending) + +*** + +### isPlaceholderData + +```ts +isPlaceholderData: false; +``` + +Defined in: [packages/query-core/src/types.ts:1108](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1108) + +Will be `true` if the data shown is the placeholder data. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPlaceholderData`](InfiniteQueryObserverBaseResult.md#isplaceholderdata) + +*** + +### isRefetchError + +```ts +isRefetchError: true; +``` + +Defined in: [packages/query-core/src/types.ts:1106](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1106) + +Will be `true` if the query failed while refetching. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isRefetchError`](InfiniteQueryObserverBaseResult.md#isrefetcherror) + +*** + +### isRefetching + +```ts +isRefetching: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:854](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L854) + +Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. +- Is the same as `isFetching && !isPending`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isRefetching`](InfiniteQueryObserverBaseResult.md#isrefetching) + +*** + +### isStale + +```ts +isStale: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:858](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L858) + +Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isStale`](InfiniteQueryObserverBaseResult.md#isstale) + +*** + +### isSuccess + +```ts +isSuccess: false; +``` + +Defined in: [packages/query-core/src/types.ts:1107](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1107) + +A derived boolean from the `status` variable, provided for convenience. +- `true` if the query has received a response with no errors and is ready to display its data. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isSuccess`](InfiniteQueryObserverBaseResult.md#issuccess) + +*** + +### refetch() + +```ts +refetch: (options?) => Promise>; +``` + +Defined in: [packages/query-core/src/types.ts:871](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L871) + +A function to manually refetch the query. + +#### Parameters + +##### options? + +[`RefetchOptions`](RefetchOptions.md) + +#### Returns + +`Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`refetch`](InfiniteQueryObserverBaseResult.md#refetch) + +*** + +### status + +```ts +status: "error"; +``` + +Defined in: [packages/query-core/src/types.ts:1109](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1109) + +The status of the query. +- Will be: + - `pending` if there's no cached data and no query attempt was finished yet. + - `error` if the query attempt resulted in an error. + - `success` if the query has received a response with no errors and is ready to display its data. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`status`](InfiniteQueryObserverBaseResult.md#status) diff --git a/docs/framework/vue/reference/interfaces/InfiniteQueryObserverSuccessResult.md b/docs/framework/vue/reference/interfaces/InfiniteQueryObserverSuccessResult.md new file mode 100644 index 00000000000..131f6d01ae7 --- /dev/null +++ b/docs/framework/vue/reference/interfaces/InfiniteQueryObserverSuccessResult.md @@ -0,0 +1,600 @@ +--- +id: InfiniteQueryObserverSuccessResult +title: InfiniteQueryObserverSuccessResult +--- + +Defined in: [packages/query-core/src/types.ts:1112](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1112) + +## Extends + +- [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md)\<`TData`, `TError`\> + +## Type Parameters + +### TData + +`TData` = `unknown` + +### TError + +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) + +## Properties + +### data + +```ts +data: TData; +``` + +Defined in: [packages/query-core/src/types.ts:1116](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1116) + +The last successfully resolved data for the query. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`data`](InfiniteQueryObserverBaseResult.md#data) + +*** + +### dataUpdatedAt + +```ts +dataUpdatedAt: number; +``` + +Defined in: [packages/query-core/src/types.ts:775](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L775) + +The timestamp for when the query most recently returned the `status` as `"success"`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`dataUpdatedAt`](InfiniteQueryObserverBaseResult.md#dataupdatedat) + +*** + +### error + +```ts +error: null; +``` + +Defined in: [packages/query-core/src/types.ts:1117](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1117) + +The error object for the query, if an error was thrown. +- Defaults to `null`. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`error`](InfiniteQueryObserverBaseResult.md#error) + +*** + +### errorUpdateCount + +```ts +errorUpdateCount: number; +``` + +Defined in: [packages/query-core/src/types.ts:799](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L799) + +The sum of all errors. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`errorUpdateCount`](InfiniteQueryObserverBaseResult.md#errorupdatecount) + +*** + +### errorUpdatedAt + +```ts +errorUpdatedAt: number; +``` + +Defined in: [packages/query-core/src/types.ts:784](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L784) + +The timestamp for when the query most recently returned the `status` as `"error"`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`errorUpdatedAt`](InfiniteQueryObserverBaseResult.md#errorupdatedat) + +*** + +### failureCount + +```ts +failureCount: number; +``` + +Defined in: [packages/query-core/src/types.ts:790](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L790) + +The failure count for the query. +- Incremented every time the query fails. +- Reset to `0` when the query succeeds. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`failureCount`](InfiniteQueryObserverBaseResult.md#failurecount) + +*** + +### failureReason + +```ts +failureReason: TError | null; +``` + +Defined in: [packages/query-core/src/types.ts:795](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L795) + +The failure reason for the query retry. +- Reset to `null` when the query succeeds. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`failureReason`](InfiniteQueryObserverBaseResult.md#failurereason) + +*** + +### fetchNextPage() + +```ts +fetchNextPage: (options?) => Promise>; +``` + +Defined in: [packages/query-core/src/types.ts:1008](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1008) + +This function allows you to fetch the next "page" of results. + +#### Parameters + +##### options? + +[`FetchNextPageOptions`](FetchNextPageOptions.md) + +#### Returns + +`Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`fetchNextPage`](InfiniteQueryObserverBaseResult.md#fetchnextpage) + +*** + +### fetchPreviousPage() + +```ts +fetchPreviousPage: (options?) => Promise>; +``` + +Defined in: [packages/query-core/src/types.ts:1014](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1014) + +This function allows you to fetch the previous "page" of results. + +#### Parameters + +##### options? + +[`FetchPreviousPageOptions`](FetchPreviousPageOptions.md) + +#### Returns + +`Promise`\<[`InfiniteQueryObserverResult`](../type-aliases/InfiniteQueryObserverResult.md)\<`TData`, `TError`\>\> + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`fetchPreviousPage`](InfiniteQueryObserverBaseResult.md#fetchpreviouspage) + +*** + +### fetchStatus + +```ts +fetchStatus: FetchStatus; +``` + +Defined in: [packages/query-core/src/types.ts:889](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L889) + +The fetch status of the query. +- `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. +- `paused`: The query wanted to fetch, but has been `paused`. +- `idle`: The query is not fetching. +- See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`fetchStatus`](InfiniteQueryObserverBaseResult.md#fetchstatus) + +*** + +### hasNextPage + +```ts +hasNextPage: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1020](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1020) + +Will be `true` if there is a next page to be fetched (known via the `getNextPageParam` option). + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`hasNextPage`](InfiniteQueryObserverBaseResult.md#hasnextpage) + +*** + +### hasPreviousPage + +```ts +hasPreviousPage: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1024](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1024) + +Will be `true` if there is a previous page to be fetched (known via the `getPreviousPageParam` option). + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`hasPreviousPage`](InfiniteQueryObserverBaseResult.md#haspreviouspage) + +*** + +### isEnabled + +```ts +isEnabled: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:867](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L867) + +`true` if this observer is enabled, `false` otherwise. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isEnabled`](InfiniteQueryObserverBaseResult.md#isenabled) + +*** + +### isError + +```ts +isError: false; +``` + +Defined in: [packages/query-core/src/types.ts:1118](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1118) + +A derived boolean from the `status` variable, provided for convenience. +- `true` if the query attempt resulted in an error. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isError`](InfiniteQueryObserverBaseResult.md#iserror) + +*** + +### isFetched + +```ts +isFetched: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:808](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L808) + +Will be `true` if the query has been fetched. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetched`](InfiniteQueryObserverBaseResult.md#isfetched) + +*** + +### isFetchedAfterMount + +```ts +isFetchedAfterMount: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:813](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L813) + +Will be `true` if the query has been fetched after the component mounted. +- This property can be used to not show any previously cached data. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchedAfterMount`](InfiniteQueryObserverBaseResult.md#isfetchedaftermount) + +*** + +### isFetching + +```ts +isFetching: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:818](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L818) + +A derived boolean from the `fetchStatus` variable, provided for convenience. +- `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetching`](InfiniteQueryObserverBaseResult.md#isfetching) + +*** + +### isFetchingNextPage + +```ts +isFetchingNextPage: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1032](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1032) + +Will be `true` while fetching the next page with `fetchNextPage`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchingNextPage`](InfiniteQueryObserverBaseResult.md#isfetchingnextpage) + +*** + +### isFetchingPreviousPage + +```ts +isFetchingPreviousPage: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1040](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1040) + +Will be `true` while fetching the previous page with `fetchPreviousPage`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchingPreviousPage`](InfiniteQueryObserverBaseResult.md#isfetchingpreviouspage) + +*** + +### isFetchNextPageError + +```ts +isFetchNextPageError: false; +``` + +Defined in: [packages/query-core/src/types.ts:1123](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1123) + +Will be `true` if the query failed while fetching the next page. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchNextPageError`](InfiniteQueryObserverBaseResult.md#isfetchnextpageerror) + +*** + +### isFetchPreviousPageError + +```ts +isFetchPreviousPageError: false; +``` + +Defined in: [packages/query-core/src/types.ts:1124](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1124) + +Will be `true` if the query failed while fetching the previous page. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isFetchPreviousPageError`](InfiniteQueryObserverBaseResult.md#isfetchpreviouspageerror) + +*** + +### ~~isInitialLoading~~ + +```ts +isInitialLoading: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:836](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L836) + +#### Deprecated + +`isInitialLoading` is being deprecated in favor of `isLoading` +and will be removed in the next major version. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isInitialLoading`](InfiniteQueryObserverBaseResult.md#isinitialloading) + +*** + +### isLoading + +```ts +isLoading: false; +``` + +Defined in: [packages/query-core/src/types.ts:1120](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1120) + +Is `true` whenever the first fetch for a query is in-flight. +- Is the same as `isFetching && isPending`. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoading`](InfiniteQueryObserverBaseResult.md#isloading) + +*** + +### isLoadingError + +```ts +isLoadingError: false; +``` + +Defined in: [packages/query-core/src/types.ts:1121](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1121) + +Will be `true` if the query failed while fetching for the first time. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isLoadingError`](InfiniteQueryObserverBaseResult.md#isloadingerror) + +*** + +### isPaused + +```ts +isPaused: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:841](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L841) + +A derived boolean from the `fetchStatus` variable, provided for convenience. +- The query wanted to fetch, but has been `paused`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPaused`](InfiniteQueryObserverBaseResult.md#ispaused) + +*** + +### isPending + +```ts +isPending: false; +``` + +Defined in: [packages/query-core/src/types.ts:1119](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1119) + +Will be `pending` if there's no cached data and no query attempt was finished yet. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPending`](InfiniteQueryObserverBaseResult.md#ispending) + +*** + +### isPlaceholderData + +```ts +isPlaceholderData: false; +``` + +Defined in: [packages/query-core/src/types.ts:1126](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1126) + +Will be `true` if the data shown is the placeholder data. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isPlaceholderData`](InfiniteQueryObserverBaseResult.md#isplaceholderdata) + +*** + +### isRefetchError + +```ts +isRefetchError: false; +``` + +Defined in: [packages/query-core/src/types.ts:1122](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1122) + +Will be `true` if the query failed while refetching. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isRefetchError`](InfiniteQueryObserverBaseResult.md#isrefetcherror) + +*** + +### isRefetching + +```ts +isRefetching: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:854](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L854) + +Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. +- Is the same as `isFetching && !isPending`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isRefetching`](InfiniteQueryObserverBaseResult.md#isrefetching) + +*** + +### isStale + +```ts +isStale: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:858](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L858) + +Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isStale`](InfiniteQueryObserverBaseResult.md#isstale) + +*** + +### isSuccess + +```ts +isSuccess: true; +``` + +Defined in: [packages/query-core/src/types.ts:1125](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1125) + +A derived boolean from the `status` variable, provided for convenience. +- `true` if the query has received a response with no errors and is ready to display its data. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`isSuccess`](InfiniteQueryObserverBaseResult.md#issuccess) + +*** + +### refetch() + +```ts +refetch: (options?) => Promise>; +``` + +Defined in: [packages/query-core/src/types.ts:871](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L871) + +A function to manually refetch the query. + +#### Parameters + +##### options? + +[`RefetchOptions`](RefetchOptions.md) + +#### Returns + +`Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> + +#### Inherited from + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`refetch`](InfiniteQueryObserverBaseResult.md#refetch) + +*** + +### status + +```ts +status: "success"; +``` + +Defined in: [packages/query-core/src/types.ts:1127](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1127) + +The status of the query. +- Will be: + - `pending` if there's no cached data and no query attempt was finished yet. + - `error` if the query attempt resulted in an error. + - `success` if the query has received a response with no errors and is ready to display its data. + +#### Overrides + +[`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md).[`status`](InfiniteQueryObserverBaseResult.md#status) diff --git a/docs/framework/vue/reference/interfaces/InfiniteQueryPageParamsOptions.md b/docs/framework/vue/reference/interfaces/InfiniteQueryPageParamsOptions.md new file mode 100644 index 00000000000..c091cc15456 --- /dev/null +++ b/docs/framework/vue/reference/interfaces/InfiniteQueryPageParamsOptions.md @@ -0,0 +1,64 @@ +--- +id: InfiniteQueryPageParamsOptions +title: InfiniteQueryPageParamsOptions +--- + +Defined in: [packages/query-core/src/types.ts:352](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L352) + +## Extends + +- [`InitialPageParam`](InitialPageParam.md)\<`TPageParam`\> + +## Extended by + +- [`InfiniteQueryObserverOptions`](InfiniteQueryObserverOptions.md) + +## Type Parameters + +### TQueryFnData + +`TQueryFnData` = `unknown` + +### TPageParam + +`TPageParam` = `unknown` + +## Properties + +### getNextPageParam + +```ts +getNextPageParam: GetNextPageParamFunction; +``` + +Defined in: [packages/query-core/src/types.ts:365](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L365) + +This function can be set to automatically get the next cursor for infinite queries. +The result will also be used to determine the value of `hasNextPage`. + +*** + +### getPreviousPageParam? + +```ts +optional getPreviousPageParam: GetPreviousPageParamFunction; +``` + +Defined in: [packages/query-core/src/types.ts:360](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L360) + +This function can be set to automatically get the previous cursor for infinite queries. +The result will also be used to determine the value of `hasPreviousPage`. + +*** + +### initialPageParam + +```ts +initialPageParam: TPageParam; +``` + +Defined in: [packages/query-core/src/types.ts:349](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L349) + +#### Inherited from + +[`InitialPageParam`](InitialPageParam.md).[`initialPageParam`](InitialPageParam.md#initialpageparam) diff --git a/docs/framework/vue/reference/interfaces/InitialPageParam.md b/docs/framework/vue/reference/interfaces/InitialPageParam.md new file mode 100644 index 00000000000..46d2b219ea4 --- /dev/null +++ b/docs/framework/vue/reference/interfaces/InitialPageParam.md @@ -0,0 +1,26 @@ +--- +id: InitialPageParam +title: InitialPageParam +--- + +Defined in: [packages/query-core/src/types.ts:348](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L348) + +## Extended by + +- [`InfiniteQueryPageParamsOptions`](InfiniteQueryPageParamsOptions.md) + +## Type Parameters + +### TPageParam + +`TPageParam` = `unknown` + +## Properties + +### initialPageParam + +```ts +initialPageParam: TPageParam; +``` + +Defined in: [packages/query-core/src/types.ts:349](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L349) diff --git a/docs/framework/vue/reference/interfaces/InvalidateOptions.md b/docs/framework/vue/reference/interfaces/InvalidateOptions.md new file mode 100644 index 00000000000..8a81428b035 --- /dev/null +++ b/docs/framework/vue/reference/interfaces/InvalidateOptions.md @@ -0,0 +1,49 @@ +--- +id: InvalidateOptions +title: InvalidateOptions +--- + +Defined in: [packages/query-core/src/types.ts:734](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L734) + +## Extends + +- [`RefetchOptions`](RefetchOptions.md) + +## Properties + +### cancelRefetch? + +```ts +optional cancelRefetch: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:712](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L712) + +If set to `true`, a currently running request will be cancelled before a new request is made + +If set to `false`, no refetch will be made if there is already a request running. + +Defaults to `true`. + +#### Inherited from + +[`RefetchOptions`](RefetchOptions.md).[`cancelRefetch`](RefetchOptions.md#cancelrefetch) + +*** + +### throwOnError? + +```ts +optional throwOnError: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:701](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L701) + +If set to `true`, the method throws if any of the underlying query refetch tasks fail. + +Defaults to `false`, in which case failed refetches are swallowed and not surfaced to the +caller. + +#### Inherited from + +[`RefetchOptions`](RefetchOptions.md).[`throwOnError`](RefetchOptions.md#throwonerror) diff --git a/docs/framework/vue/reference/interfaces/InvalidateQueryFilters.md b/docs/framework/vue/reference/interfaces/InvalidateQueryFilters.md new file mode 100644 index 00000000000..14461260d18 --- /dev/null +++ b/docs/framework/vue/reference/interfaces/InvalidateQueryFilters.md @@ -0,0 +1,154 @@ +--- +id: InvalidateQueryFilters +title: InvalidateQueryFilters +--- + +Defined in: [packages/query-core/src/types.ts:715](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L715) + +## Extends + +- `QueryFilters`\<`TQueryKey`\> + +## Type Parameters + +### TQueryKey + +`TQueryKey` *extends* [`QueryKey`](../type-aliases/QueryKey.md) = [`QueryKey`](../type-aliases/QueryKey.md) + +## Properties + +### exact? + +```ts +optional exact: boolean; +``` + +Defined in: [packages/query-core/src/utils.ts:41](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L41) + +Match query key exactly + +#### Inherited from + +```ts +QueryFilters.exact +``` + +*** + +### fetchStatus? + +```ts +optional fetchStatus: FetchStatus; +``` + +Defined in: [packages/query-core/src/utils.ts:57](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L57) + +Include queries matching their fetchStatus + +#### Inherited from + +```ts +QueryFilters.fetchStatus +``` + +*** + +### predicate()? + +```ts +optional predicate: (query) => boolean; +``` + +Defined in: [packages/query-core/src/utils.ts:45](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L45) + +Include queries matching this predicate function + +#### Parameters + +##### query + +[`Query`](../classes/Query.md) + +#### Returns + +`boolean` + +#### Inherited from + +```ts +QueryFilters.predicate +``` + +*** + +### queryKey? + +```ts +optional queryKey: TQueryKey | TuplePrefixes; +``` + +Defined in: [packages/query-core/src/utils.ts:49](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L49) + +Include queries matching this query key + +#### Inherited from + +```ts +QueryFilters.queryKey +``` + +*** + +### refetchType? + +```ts +optional refetchType: QueryTypeFilter | "none"; +``` + +Defined in: [packages/query-core/src/types.ts:727](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L727) + +Controls which of the matched (now-invalidated) queries are refetched in the background. + +Defaults to `'active'`. +- `'active'`: only queries with at least one active observer are refetched. +- `'inactive'`: only queries with no active observer are refetched. +- `'all'`: every matched query is refetched, active or not. +- `'none'`: no query is refetched; matched queries are only marked as invalidated. + +*** + +### stale? + +```ts +optional stale: boolean; +``` + +Defined in: [packages/query-core/src/utils.ts:53](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L53) + +Include or exclude stale queries + +#### Inherited from + +```ts +QueryFilters.stale +``` + +*** + +### type? + +```ts +optional type: QueryTypeFilter; +``` + +Defined in: [packages/query-core/src/utils.ts:37](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L37) + +Filter to active queries, inactive queries or all queries + +Defaults to `'all'`. + +#### Inherited from + +```ts +QueryFilters.type +``` diff --git a/docs/framework/vue/reference/interfaces/MutateOptions.md b/docs/framework/vue/reference/interfaces/MutateOptions.md new file mode 100644 index 00000000000..34e2a4d4d7e --- /dev/null +++ b/docs/framework/vue/reference/interfaces/MutateOptions.md @@ -0,0 +1,124 @@ +--- +id: MutateOptions +title: MutateOptions +--- + +Defined in: [packages/query-core/src/types.ts:1284](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1284) + +## Type Parameters + +### TData + +`TData` = `unknown` + +### TError + +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) + +### TVariables + +`TVariables` = `void` + +### TOnMutateResult + +`TOnMutateResult` = `unknown` + +## Properties + +### onError()? + +```ts +optional onError: (error, variables, onMutateResult, context) => void; +``` + +Defined in: [packages/query-core/src/types.ts:1296](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1296) + +#### Parameters + +##### error + +`TError` + +##### variables + +`TVariables` + +##### onMutateResult + +`TOnMutateResult` | `undefined` + +##### context + +[`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md) + +#### Returns + +`void` + +*** + +### onSettled()? + +```ts +optional onSettled: (data, error, variables, onMutateResult, context) => void; +``` + +Defined in: [packages/query-core/src/types.ts:1302](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1302) + +#### Parameters + +##### data + +`TData` | `undefined` + +##### error + +`TError` | `null` + +##### variables + +`TVariables` + +##### onMutateResult + +`TOnMutateResult` | `undefined` + +##### context + +[`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md) + +#### Returns + +`void` + +*** + +### onSuccess()? + +```ts +optional onSuccess: (data, variables, onMutateResult, context) => void; +``` + +Defined in: [packages/query-core/src/types.ts:1290](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1290) + +#### Parameters + +##### data + +`TData` + +##### variables + +`TVariables` + +##### onMutateResult + +`TOnMutateResult` | `undefined` + +##### context + +[`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md) + +#### Returns + +`void` diff --git a/docs/framework/vue/reference/interfaces/MutationCacheConfig.md b/docs/framework/vue/reference/interfaces/MutationCacheConfig.md new file mode 100644 index 00000000000..c38d2dc26f4 --- /dev/null +++ b/docs/framework/vue/reference/interfaces/MutationCacheConfig.md @@ -0,0 +1,161 @@ +--- +id: MutationCacheConfig +title: MutationCacheConfig +--- + +Defined in: [packages/query-core/src/mutationCache.ts:26](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationCache.ts#L26) + +Global callbacks that fire for every mutation handled by a `MutationCache`, regardless of which +component or observer triggered it. They differ from the `defaultOptions` provided to a +`QueryClient` in two ways: `defaultOptions` can be overridden by each mutation, while these +callbacks are always called, and `onMutate` here does not allow returning a result. + +If a callback returns a promise, it will be awaited before the mutation continues. + +## Properties + +### onError()? + +```ts +optional onError: (error, variables, onMutateResult, mutation, context) => unknown; +``` + +Defined in: [packages/query-core/src/mutationCache.ts:28](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationCache.ts#L28) + +Called when any mutation in the cache encounters an error. + +#### Parameters + +##### error + +`Error` + +##### variables + +`unknown` + +##### onMutateResult + +`unknown` + +##### mutation + +[`Mutation`](../classes/Mutation.md)\<`unknown`, `unknown`, `unknown`\> + +##### context + +[`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md) + +#### Returns + +`unknown` + +*** + +### onMutate()? + +```ts +optional onMutate: (variables, mutation, context) => unknown; +``` + +Defined in: [packages/query-core/src/mutationCache.ts:44](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationCache.ts#L44) + +Called before any mutation in the cache executes. + +#### Parameters + +##### variables + +`unknown` + +##### mutation + +[`Mutation`](../classes/Mutation.md)\<`unknown`, `unknown`, `unknown`\> + +##### context + +[`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md) + +#### Returns + +`unknown` + +*** + +### onSettled()? + +```ts +optional onSettled: (data, error, variables, onMutateResult, mutation, context) => unknown; +``` + +Defined in: [packages/query-core/src/mutationCache.ts:50](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationCache.ts#L50) + +Called when any mutation in the cache is settled, either successfully or with an error. + +#### Parameters + +##### data + +`unknown` + +##### error + +`Error` | `null` + +##### variables + +`unknown` + +##### onMutateResult + +`unknown` + +##### mutation + +[`Mutation`](../classes/Mutation.md)\<`unknown`, `unknown`, `unknown`\> + +##### context + +[`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md) + +#### Returns + +`unknown` + +*** + +### onSuccess()? + +```ts +optional onSuccess: (data, variables, onMutateResult, mutation, context) => unknown; +``` + +Defined in: [packages/query-core/src/mutationCache.ts:36](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationCache.ts#L36) + +Called when any mutation in the cache is successful. + +#### Parameters + +##### data + +`unknown` + +##### variables + +`unknown` + +##### onMutateResult + +`unknown` + +##### mutation + +[`Mutation`](../classes/Mutation.md)\<`unknown`, `unknown`, `unknown`\> + +##### context + +[`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md) + +#### Returns + +`unknown` diff --git a/docs/framework/vue/reference/interfaces/MutationObserverBaseResult.md b/docs/framework/vue/reference/interfaces/MutationObserverBaseResult.md new file mode 100644 index 00000000000..340a38cc9cc --- /dev/null +++ b/docs/framework/vue/reference/interfaces/MutationObserverBaseResult.md @@ -0,0 +1,291 @@ +--- +id: MutationObserverBaseResult +title: MutationObserverBaseResult +--- + +Defined in: [packages/query-core/src/types.ts:1335](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1335) + +The raw state stored on a `Mutation` instance. This is the underlying state +that observer results (e.g. `MutationObserverResult`) are derived from. + +## Extends + +- [`MutationState`](MutationState.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\> + +## Extended by + +- [`MutationObserverIdleResult`](MutationObserverIdleResult.md) +- [`MutationObserverLoadingResult`](MutationObserverLoadingResult.md) +- [`MutationObserverErrorResult`](MutationObserverErrorResult.md) +- [`MutationObserverSuccessResult`](MutationObserverSuccessResult.md) + +## Type Parameters + +### TData + +`TData` = `unknown` + +### TError + +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) + +### TVariables + +`TVariables` = `void` + +### TOnMutateResult + +`TOnMutateResult` = `unknown` + +## Properties + +### context + +```ts +context: TOnMutateResult | undefined; +``` + +Defined in: [packages/query-core/src/mutation.ts:40](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L40) + +The value returned by `onMutate`, if defined. Passed to `onSuccess`, +`onError` and `onSettled` as the mutation's context. + +#### Inherited from + +[`MutationState`](MutationState.md).[`context`](MutationState.md#context) + +*** + +### data + +```ts +data: TData | undefined; +``` + +Defined in: [packages/query-core/src/types.ts:1344](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1344) + +The last successfully resolved data for the mutation. + +#### Overrides + +[`MutationState`](MutationState.md).[`data`](MutationState.md#data) + +*** + +### error + +```ts +error: TError | null; +``` + +Defined in: [packages/query-core/src/types.ts:1353](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1353) + +The error object for the mutation, if an error was encountered. +- Defaults to `null`. + +#### Overrides + +[`MutationState`](MutationState.md).[`error`](MutationState.md#error) + +*** + +### failureCount + +```ts +failureCount: number; +``` + +Defined in: [packages/query-core/src/mutation.ts:53](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L53) + +The number of times the mutation function has failed for the current attempt. + +#### Inherited from + +[`MutationState`](MutationState.md).[`failureCount`](MutationState.md#failurecount) + +*** + +### failureReason + +```ts +failureReason: TError | null; +``` + +Defined in: [packages/query-core/src/mutation.ts:57](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L57) + +The reason the current attempt failed, as reported by the retryer. + +#### Inherited from + +[`MutationState`](MutationState.md).[`failureReason`](MutationState.md#failurereason) + +*** + +### isError + +```ts +isError: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1358](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1358) + +A boolean variable derived from `status`. +- `true` if the last mutation attempt resulted in an error. + +*** + +### isIdle + +```ts +isIdle: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1363](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1363) + +A boolean variable derived from `status`. +- `true` if the mutation is in its initial state prior to executing. + +*** + +### isPaused + +```ts +isPaused: boolean; +``` + +Defined in: [packages/query-core/src/mutation.ts:62](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L62) + +Whether the mutation is currently paused (see network mode), or is +waiting for another mutation with the same `scope` to finish. + +#### Inherited from + +[`MutationState`](MutationState.md).[`isPaused`](MutationState.md#ispaused) + +*** + +### isPending + +```ts +isPending: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1368](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1368) + +A boolean variable derived from `status`. +- `true` if the mutation is currently executing. + +*** + +### isSuccess + +```ts +isSuccess: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1373](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1373) + +A boolean variable derived from `status`. +- `true` if the last mutation attempt was successful. + +*** + +### mutate + +```ts +mutate: MutateFunction; +``` + +Defined in: [packages/query-core/src/types.ts:1393](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1393) + +The mutation function you can call with variables to trigger the mutation and optionally hooks on additional callback options. + +#### Param + +The variables object to pass to the `mutationFn`. + +#### Param + +This function will fire when the mutation is successful and will be passed the mutation's result. + +#### Param + +This function will fire if the mutation encounters an error and will be passed the error. + +#### Param + +This function will fire when the mutation is either successfully fetched or encounters an error and be passed either the data or error. + +#### Remarks + +- If you make multiple requests, `onSuccess` will fire only after the latest call you've made. +- All the callback functions (`onSuccess`, `onError`, `onSettled`) are void functions, and the returned value will be ignored. + +*** + +### reset() + +```ts +reset: () => void; +``` + +Defined in: [packages/query-core/src/types.ts:1397](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1397) + +A function to clean the mutation internal state (i.e., it resets the mutation to its initial state). + +#### Returns + +`void` + +*** + +### status + +```ts +status: MutationStatus; +``` + +Defined in: [packages/query-core/src/types.ts:1382](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1382) + +The status of the mutation. +- Will be: + - `idle` initial status prior to the mutation function executing. + - `pending` if the mutation is currently executing. + - `error` if the last mutation attempt resulted in an error. + - `success` if the last mutation attempt was successful. + +#### Overrides + +[`MutationState`](MutationState.md).[`status`](MutationState.md#status) + +*** + +### submittedAt + +```ts +submittedAt: number; +``` + +Defined in: [packages/query-core/src/mutation.ts:74](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L74) + +The timestamp for when the mutation was submitted. + +#### Inherited from + +[`MutationState`](MutationState.md).[`submittedAt`](MutationState.md#submittedat) + +*** + +### variables + +```ts +variables: TVariables | undefined; +``` + +Defined in: [packages/query-core/src/types.ts:1348](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1348) + +The variables object passed to the `mutationFn`. + +#### Overrides + +[`MutationState`](MutationState.md).[`variables`](MutationState.md#variables) diff --git a/docs/framework/vue/reference/interfaces/MutationObserverErrorResult.md b/docs/framework/vue/reference/interfaces/MutationObserverErrorResult.md new file mode 100644 index 00000000000..72e459a2e0b --- /dev/null +++ b/docs/framework/vue/reference/interfaces/MutationObserverErrorResult.md @@ -0,0 +1,308 @@ +--- +id: MutationObserverErrorResult +title: MutationObserverErrorResult +--- + +Defined in: [packages/query-core/src/types.ts:1442](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1442) + +The raw state stored on a `Mutation` instance. This is the underlying state +that observer results (e.g. `MutationObserverResult`) are derived from. + +## Extends + +- [`MutationObserverBaseResult`](MutationObserverBaseResult.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\> + +## Type Parameters + +### TData + +`TData` = `unknown` + +### TError + +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) + +### TVariables + +`TVariables` = `void` + +### TOnMutateResult + +`TOnMutateResult` = `unknown` + +## Properties + +### context + +```ts +context: TOnMutateResult | undefined; +``` + +Defined in: [packages/query-core/src/mutation.ts:40](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L40) + +The value returned by `onMutate`, if defined. Passed to `onSuccess`, +`onError` and `onSettled` as the mutation's context. + +#### Inherited from + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`context`](MutationObserverBaseResult.md#context) + +*** + +### data + +```ts +data: undefined; +``` + +Defined in: [packages/query-core/src/types.ts:1453](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1453) + +The last successfully resolved data for the mutation. + +#### Overrides + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`data`](MutationObserverBaseResult.md#data) + +*** + +### error + +```ts +error: TError; +``` + +Defined in: [packages/query-core/src/types.ts:1454](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1454) + +The error object for the mutation, if an error was encountered. +- Defaults to `null`. + +#### Overrides + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`error`](MutationObserverBaseResult.md#error) + +*** + +### failureCount + +```ts +failureCount: number; +``` + +Defined in: [packages/query-core/src/mutation.ts:53](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L53) + +The number of times the mutation function has failed for the current attempt. + +#### Inherited from + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`failureCount`](MutationObserverBaseResult.md#failurecount) + +*** + +### failureReason + +```ts +failureReason: TError | null; +``` + +Defined in: [packages/query-core/src/mutation.ts:57](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L57) + +The reason the current attempt failed, as reported by the retryer. + +#### Inherited from + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`failureReason`](MutationObserverBaseResult.md#failurereason) + +*** + +### isError + +```ts +isError: true; +``` + +Defined in: [packages/query-core/src/types.ts:1456](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1456) + +A boolean variable derived from `status`. +- `true` if the last mutation attempt resulted in an error. + +#### Overrides + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isError`](MutationObserverBaseResult.md#iserror) + +*** + +### isIdle + +```ts +isIdle: false; +``` + +Defined in: [packages/query-core/src/types.ts:1457](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1457) + +A boolean variable derived from `status`. +- `true` if the mutation is in its initial state prior to executing. + +#### Overrides + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isIdle`](MutationObserverBaseResult.md#isidle) + +*** + +### isPaused + +```ts +isPaused: boolean; +``` + +Defined in: [packages/query-core/src/mutation.ts:62](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L62) + +Whether the mutation is currently paused (see network mode), or is +waiting for another mutation with the same `scope` to finish. + +#### Inherited from + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isPaused`](MutationObserverBaseResult.md#ispaused) + +*** + +### isPending + +```ts +isPending: false; +``` + +Defined in: [packages/query-core/src/types.ts:1458](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1458) + +A boolean variable derived from `status`. +- `true` if the mutation is currently executing. + +#### Overrides + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isPending`](MutationObserverBaseResult.md#ispending) + +*** + +### isSuccess + +```ts +isSuccess: false; +``` + +Defined in: [packages/query-core/src/types.ts:1459](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1459) + +A boolean variable derived from `status`. +- `true` if the last mutation attempt was successful. + +#### Overrides + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isSuccess`](MutationObserverBaseResult.md#issuccess) + +*** + +### mutate + +```ts +mutate: MutateFunction; +``` + +Defined in: [packages/query-core/src/types.ts:1393](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1393) + +The mutation function you can call with variables to trigger the mutation and optionally hooks on additional callback options. + +#### Param + +The variables object to pass to the `mutationFn`. + +#### Param + +This function will fire when the mutation is successful and will be passed the mutation's result. + +#### Param + +This function will fire if the mutation encounters an error and will be passed the error. + +#### Param + +This function will fire when the mutation is either successfully fetched or encounters an error and be passed either the data or error. + +#### Remarks + +- If you make multiple requests, `onSuccess` will fire only after the latest call you've made. +- All the callback functions (`onSuccess`, `onError`, `onSettled`) are void functions, and the returned value will be ignored. + +#### Inherited from + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`mutate`](MutationObserverBaseResult.md#mutate) + +*** + +### reset() + +```ts +reset: () => void; +``` + +Defined in: [packages/query-core/src/types.ts:1397](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1397) + +A function to clean the mutation internal state (i.e., it resets the mutation to its initial state). + +#### Returns + +`void` + +#### Inherited from + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`reset`](MutationObserverBaseResult.md#reset) + +*** + +### status + +```ts +status: "error"; +``` + +Defined in: [packages/query-core/src/types.ts:1460](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1460) + +The status of the mutation. +- Will be: + - `idle` initial status prior to the mutation function executing. + - `pending` if the mutation is currently executing. + - `error` if the last mutation attempt resulted in an error. + - `success` if the last mutation attempt was successful. + +#### Overrides + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`status`](MutationObserverBaseResult.md#status) + +*** + +### submittedAt + +```ts +submittedAt: number; +``` + +Defined in: [packages/query-core/src/mutation.ts:74](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L74) + +The timestamp for when the mutation was submitted. + +#### Inherited from + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`submittedAt`](MutationObserverBaseResult.md#submittedat) + +*** + +### variables + +```ts +variables: TVariables; +``` + +Defined in: [packages/query-core/src/types.ts:1455](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1455) + +The variables object passed to the `mutationFn`. + +#### Overrides + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`variables`](MutationObserverBaseResult.md#variables) diff --git a/docs/framework/vue/reference/interfaces/MutationObserverIdleResult.md b/docs/framework/vue/reference/interfaces/MutationObserverIdleResult.md new file mode 100644 index 00000000000..cd8d6eb3130 --- /dev/null +++ b/docs/framework/vue/reference/interfaces/MutationObserverIdleResult.md @@ -0,0 +1,308 @@ +--- +id: MutationObserverIdleResult +title: MutationObserverIdleResult +--- + +Defined in: [packages/query-core/src/types.ts:1400](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1400) + +The raw state stored on a `Mutation` instance. This is the underlying state +that observer results (e.g. `MutationObserverResult`) are derived from. + +## Extends + +- [`MutationObserverBaseResult`](MutationObserverBaseResult.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\> + +## Type Parameters + +### TData + +`TData` = `unknown` + +### TError + +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) + +### TVariables + +`TVariables` = `void` + +### TOnMutateResult + +`TOnMutateResult` = `unknown` + +## Properties + +### context + +```ts +context: TOnMutateResult | undefined; +``` + +Defined in: [packages/query-core/src/mutation.ts:40](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L40) + +The value returned by `onMutate`, if defined. Passed to `onSuccess`, +`onError` and `onSettled` as the mutation's context. + +#### Inherited from + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`context`](MutationObserverBaseResult.md#context) + +*** + +### data + +```ts +data: undefined; +``` + +Defined in: [packages/query-core/src/types.ts:1411](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1411) + +The last successfully resolved data for the mutation. + +#### Overrides + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`data`](MutationObserverBaseResult.md#data) + +*** + +### error + +```ts +error: null; +``` + +Defined in: [packages/query-core/src/types.ts:1413](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1413) + +The error object for the mutation, if an error was encountered. +- Defaults to `null`. + +#### Overrides + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`error`](MutationObserverBaseResult.md#error) + +*** + +### failureCount + +```ts +failureCount: number; +``` + +Defined in: [packages/query-core/src/mutation.ts:53](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L53) + +The number of times the mutation function has failed for the current attempt. + +#### Inherited from + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`failureCount`](MutationObserverBaseResult.md#failurecount) + +*** + +### failureReason + +```ts +failureReason: TError | null; +``` + +Defined in: [packages/query-core/src/mutation.ts:57](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L57) + +The reason the current attempt failed, as reported by the retryer. + +#### Inherited from + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`failureReason`](MutationObserverBaseResult.md#failurereason) + +*** + +### isError + +```ts +isError: false; +``` + +Defined in: [packages/query-core/src/types.ts:1414](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1414) + +A boolean variable derived from `status`. +- `true` if the last mutation attempt resulted in an error. + +#### Overrides + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isError`](MutationObserverBaseResult.md#iserror) + +*** + +### isIdle + +```ts +isIdle: true; +``` + +Defined in: [packages/query-core/src/types.ts:1415](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1415) + +A boolean variable derived from `status`. +- `true` if the mutation is in its initial state prior to executing. + +#### Overrides + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isIdle`](MutationObserverBaseResult.md#isidle) + +*** + +### isPaused + +```ts +isPaused: boolean; +``` + +Defined in: [packages/query-core/src/mutation.ts:62](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L62) + +Whether the mutation is currently paused (see network mode), or is +waiting for another mutation with the same `scope` to finish. + +#### Inherited from + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isPaused`](MutationObserverBaseResult.md#ispaused) + +*** + +### isPending + +```ts +isPending: false; +``` + +Defined in: [packages/query-core/src/types.ts:1416](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1416) + +A boolean variable derived from `status`. +- `true` if the mutation is currently executing. + +#### Overrides + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isPending`](MutationObserverBaseResult.md#ispending) + +*** + +### isSuccess + +```ts +isSuccess: false; +``` + +Defined in: [packages/query-core/src/types.ts:1417](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1417) + +A boolean variable derived from `status`. +- `true` if the last mutation attempt was successful. + +#### Overrides + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isSuccess`](MutationObserverBaseResult.md#issuccess) + +*** + +### mutate + +```ts +mutate: MutateFunction; +``` + +Defined in: [packages/query-core/src/types.ts:1393](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1393) + +The mutation function you can call with variables to trigger the mutation and optionally hooks on additional callback options. + +#### Param + +The variables object to pass to the `mutationFn`. + +#### Param + +This function will fire when the mutation is successful and will be passed the mutation's result. + +#### Param + +This function will fire if the mutation encounters an error and will be passed the error. + +#### Param + +This function will fire when the mutation is either successfully fetched or encounters an error and be passed either the data or error. + +#### Remarks + +- If you make multiple requests, `onSuccess` will fire only after the latest call you've made. +- All the callback functions (`onSuccess`, `onError`, `onSettled`) are void functions, and the returned value will be ignored. + +#### Inherited from + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`mutate`](MutationObserverBaseResult.md#mutate) + +*** + +### reset() + +```ts +reset: () => void; +``` + +Defined in: [packages/query-core/src/types.ts:1397](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1397) + +A function to clean the mutation internal state (i.e., it resets the mutation to its initial state). + +#### Returns + +`void` + +#### Inherited from + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`reset`](MutationObserverBaseResult.md#reset) + +*** + +### status + +```ts +status: "idle"; +``` + +Defined in: [packages/query-core/src/types.ts:1418](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1418) + +The status of the mutation. +- Will be: + - `idle` initial status prior to the mutation function executing. + - `pending` if the mutation is currently executing. + - `error` if the last mutation attempt resulted in an error. + - `success` if the last mutation attempt was successful. + +#### Overrides + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`status`](MutationObserverBaseResult.md#status) + +*** + +### submittedAt + +```ts +submittedAt: number; +``` + +Defined in: [packages/query-core/src/mutation.ts:74](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L74) + +The timestamp for when the mutation was submitted. + +#### Inherited from + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`submittedAt`](MutationObserverBaseResult.md#submittedat) + +*** + +### variables + +```ts +variables: undefined; +``` + +Defined in: [packages/query-core/src/types.ts:1412](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1412) + +The variables object passed to the `mutationFn`. + +#### Overrides + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`variables`](MutationObserverBaseResult.md#variables) diff --git a/docs/framework/vue/reference/interfaces/MutationObserverLoadingResult.md b/docs/framework/vue/reference/interfaces/MutationObserverLoadingResult.md new file mode 100644 index 00000000000..9b70a8558e7 --- /dev/null +++ b/docs/framework/vue/reference/interfaces/MutationObserverLoadingResult.md @@ -0,0 +1,308 @@ +--- +id: MutationObserverLoadingResult +title: MutationObserverLoadingResult +--- + +Defined in: [packages/query-core/src/types.ts:1421](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1421) + +The raw state stored on a `Mutation` instance. This is the underlying state +that observer results (e.g. `MutationObserverResult`) are derived from. + +## Extends + +- [`MutationObserverBaseResult`](MutationObserverBaseResult.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\> + +## Type Parameters + +### TData + +`TData` = `unknown` + +### TError + +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) + +### TVariables + +`TVariables` = `void` + +### TOnMutateResult + +`TOnMutateResult` = `unknown` + +## Properties + +### context + +```ts +context: TOnMutateResult | undefined; +``` + +Defined in: [packages/query-core/src/mutation.ts:40](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L40) + +The value returned by `onMutate`, if defined. Passed to `onSuccess`, +`onError` and `onSettled` as the mutation's context. + +#### Inherited from + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`context`](MutationObserverBaseResult.md#context) + +*** + +### data + +```ts +data: undefined; +``` + +Defined in: [packages/query-core/src/types.ts:1432](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1432) + +The last successfully resolved data for the mutation. + +#### Overrides + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`data`](MutationObserverBaseResult.md#data) + +*** + +### error + +```ts +error: null; +``` + +Defined in: [packages/query-core/src/types.ts:1434](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1434) + +The error object for the mutation, if an error was encountered. +- Defaults to `null`. + +#### Overrides + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`error`](MutationObserverBaseResult.md#error) + +*** + +### failureCount + +```ts +failureCount: number; +``` + +Defined in: [packages/query-core/src/mutation.ts:53](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L53) + +The number of times the mutation function has failed for the current attempt. + +#### Inherited from + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`failureCount`](MutationObserverBaseResult.md#failurecount) + +*** + +### failureReason + +```ts +failureReason: TError | null; +``` + +Defined in: [packages/query-core/src/mutation.ts:57](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L57) + +The reason the current attempt failed, as reported by the retryer. + +#### Inherited from + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`failureReason`](MutationObserverBaseResult.md#failurereason) + +*** + +### isError + +```ts +isError: false; +``` + +Defined in: [packages/query-core/src/types.ts:1435](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1435) + +A boolean variable derived from `status`. +- `true` if the last mutation attempt resulted in an error. + +#### Overrides + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isError`](MutationObserverBaseResult.md#iserror) + +*** + +### isIdle + +```ts +isIdle: false; +``` + +Defined in: [packages/query-core/src/types.ts:1436](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1436) + +A boolean variable derived from `status`. +- `true` if the mutation is in its initial state prior to executing. + +#### Overrides + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isIdle`](MutationObserverBaseResult.md#isidle) + +*** + +### isPaused + +```ts +isPaused: boolean; +``` + +Defined in: [packages/query-core/src/mutation.ts:62](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L62) + +Whether the mutation is currently paused (see network mode), or is +waiting for another mutation with the same `scope` to finish. + +#### Inherited from + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isPaused`](MutationObserverBaseResult.md#ispaused) + +*** + +### isPending + +```ts +isPending: true; +``` + +Defined in: [packages/query-core/src/types.ts:1437](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1437) + +A boolean variable derived from `status`. +- `true` if the mutation is currently executing. + +#### Overrides + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isPending`](MutationObserverBaseResult.md#ispending) + +*** + +### isSuccess + +```ts +isSuccess: false; +``` + +Defined in: [packages/query-core/src/types.ts:1438](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1438) + +A boolean variable derived from `status`. +- `true` if the last mutation attempt was successful. + +#### Overrides + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isSuccess`](MutationObserverBaseResult.md#issuccess) + +*** + +### mutate + +```ts +mutate: MutateFunction; +``` + +Defined in: [packages/query-core/src/types.ts:1393](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1393) + +The mutation function you can call with variables to trigger the mutation and optionally hooks on additional callback options. + +#### Param + +The variables object to pass to the `mutationFn`. + +#### Param + +This function will fire when the mutation is successful and will be passed the mutation's result. + +#### Param + +This function will fire if the mutation encounters an error and will be passed the error. + +#### Param + +This function will fire when the mutation is either successfully fetched or encounters an error and be passed either the data or error. + +#### Remarks + +- If you make multiple requests, `onSuccess` will fire only after the latest call you've made. +- All the callback functions (`onSuccess`, `onError`, `onSettled`) are void functions, and the returned value will be ignored. + +#### Inherited from + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`mutate`](MutationObserverBaseResult.md#mutate) + +*** + +### reset() + +```ts +reset: () => void; +``` + +Defined in: [packages/query-core/src/types.ts:1397](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1397) + +A function to clean the mutation internal state (i.e., it resets the mutation to its initial state). + +#### Returns + +`void` + +#### Inherited from + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`reset`](MutationObserverBaseResult.md#reset) + +*** + +### status + +```ts +status: "pending"; +``` + +Defined in: [packages/query-core/src/types.ts:1439](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1439) + +The status of the mutation. +- Will be: + - `idle` initial status prior to the mutation function executing. + - `pending` if the mutation is currently executing. + - `error` if the last mutation attempt resulted in an error. + - `success` if the last mutation attempt was successful. + +#### Overrides + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`status`](MutationObserverBaseResult.md#status) + +*** + +### submittedAt + +```ts +submittedAt: number; +``` + +Defined in: [packages/query-core/src/mutation.ts:74](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L74) + +The timestamp for when the mutation was submitted. + +#### Inherited from + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`submittedAt`](MutationObserverBaseResult.md#submittedat) + +*** + +### variables + +```ts +variables: TVariables; +``` + +Defined in: [packages/query-core/src/types.ts:1433](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1433) + +The variables object passed to the `mutationFn`. + +#### Overrides + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`variables`](MutationObserverBaseResult.md#variables) diff --git a/docs/framework/vue/reference/interfaces/MutationObserverOptions.md b/docs/framework/vue/reference/interfaces/MutationObserverOptions.md new file mode 100644 index 00000000000..b3835184b96 --- /dev/null +++ b/docs/framework/vue/reference/interfaces/MutationObserverOptions.md @@ -0,0 +1,346 @@ +--- +id: MutationObserverOptions +title: MutationObserverOptions +--- + +Defined in: [packages/query-core/src/types.ts:1267](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1267) + +## Extends + +- `MutationOptions`\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\> + +## Type Parameters + +### TData + +`TData` = `unknown` + +### TError + +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) + +### TVariables + +`TVariables` = `void` + +### TOnMutateResult + +`TOnMutateResult` = `unknown` + +## Properties + +### gcTime? + +```ts +optional gcTime: number; +``` + +Defined in: [packages/query-core/src/types.ts:1260](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1260) + +The time in milliseconds that an unused/inactive mutation remains in memory before it is +garbage collected. + +Defaults to `5 * 60 * 1000` (5 minutes), or `Infinity` during SSR. + +#### Inherited from + +```ts +MutationOptions.gcTime +``` + +*** + +### meta? + +```ts +optional meta: Record; +``` + +Defined in: [packages/query-core/src/types.ts:1263](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1263) + +#### Inherited from + +```ts +MutationOptions.meta +``` + +*** + +### mutationFn? + +```ts +optional mutationFn: MutationFunction; +``` + +Defined in: [packages/query-core/src/types.ts:1206](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1206) + +#### Inherited from + +```ts +MutationOptions.mutationFn +``` + +*** + +### mutationKey? + +```ts +optional mutationKey: readonly unknown[]; +``` + +Defined in: [packages/query-core/src/types.ts:1207](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1207) + +#### Inherited from + +```ts +MutationOptions.mutationKey +``` + +*** + +### networkMode? + +```ts +optional networkMode: NetworkMode; +``` + +Defined in: [packages/query-core/src/types.ts:1253](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1253) + +Controls whether a mutation is allowed to run based on the current network connectivity. + +Defaults to `'online'`. + +#### See + +[Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. + +#### Inherited from + +```ts +MutationOptions.networkMode +``` + +*** + +### onError()? + +```ts +optional onError: (error, variables, onMutateResult, context) => unknown; +``` + +Defined in: [packages/query-core/src/types.ts:1218](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1218) + +#### Parameters + +##### error + +`TError` + +##### variables + +`TVariables` + +##### onMutateResult + +`TOnMutateResult` | `undefined` + +##### context + +[`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md) + +#### Returns + +`unknown` + +#### Inherited from + +```ts +MutationOptions.onError +``` + +*** + +### onMutate()? + +```ts +optional onMutate: (variables, context) => TOnMutateResult | Promise; +``` + +Defined in: [packages/query-core/src/types.ts:1208](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1208) + +#### Parameters + +##### variables + +`TVariables` + +##### context + +[`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md) + +#### Returns + +`TOnMutateResult` \| `Promise`\<`TOnMutateResult`\> + +#### Inherited from + +```ts +MutationOptions.onMutate +``` + +*** + +### onSettled()? + +```ts +optional onSettled: (data, error, variables, onMutateResult, context) => unknown; +``` + +Defined in: [packages/query-core/src/types.ts:1224](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1224) + +#### Parameters + +##### data + +`TData` | `undefined` + +##### error + +`TError` | `null` + +##### variables + +`TVariables` + +##### onMutateResult + +`TOnMutateResult` | `undefined` + +##### context + +[`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md) + +#### Returns + +`unknown` + +#### Inherited from + +```ts +MutationOptions.onSettled +``` + +*** + +### onSuccess()? + +```ts +optional onSuccess: (data, variables, onMutateResult, context) => unknown; +``` + +Defined in: [packages/query-core/src/types.ts:1212](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1212) + +#### Parameters + +##### data + +`TData` + +##### variables + +`TVariables` + +##### onMutateResult + +`TOnMutateResult` + +##### context + +[`MutationFunctionContext`](../type-aliases/MutationFunctionContext.md) + +#### Returns + +`unknown` + +#### Inherited from + +```ts +MutationOptions.onSuccess +``` + +*** + +### retry? + +```ts +optional retry: RetryValue; +``` + +Defined in: [packages/query-core/src/types.ts:1239](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1239) + +If `false`, failed mutations will not retry by default. +If `true`, failed mutations will retry infinitely. +If set to an integer number, e.g. 3, failed mutations will retry until the failed mutation count meets that number. +If set to a function `(failureCount, error) => boolean` failed mutations will retry until the function returns false. + +Defaults to `0`. + +#### Inherited from + +```ts +MutationOptions.retry +``` + +*** + +### retryDelay? + +```ts +optional retryDelay: RetryDelayValue; +``` + +Defined in: [packages/query-core/src/types.ts:1246](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1246) + +This function receives a `retryAttempt` integer and the actual Error and returns the delay to apply before the +next attempt in milliseconds. + +Defaults to a function that applies exponential backoff, capped at 30 seconds. + +#### Inherited from + +```ts +MutationOptions.retryDelay +``` + +*** + +### scope? + +```ts +optional scope: MutationScope; +``` + +Defined in: [packages/query-core/src/types.ts:1264](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1264) + +#### Inherited from + +```ts +MutationOptions.scope +``` + +*** + +### throwOnError? + +```ts +optional throwOnError: boolean | (error) => boolean; +``` + +Defined in: [packages/query-core/src/types.ts:1281](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1281) + +Whether errors should be thrown instead of setting the `error` property. +If set to `true`, all errors will be thrown to the nearest error boundary. +If set to a function, it will be passed the error and should return a boolean indicating whether to throw the +error (`true`) or return it as state (`false`). + +Defaults to `false`. diff --git a/docs/framework/vue/reference/interfaces/MutationObserverSuccessResult.md b/docs/framework/vue/reference/interfaces/MutationObserverSuccessResult.md new file mode 100644 index 00000000000..e2e03642f82 --- /dev/null +++ b/docs/framework/vue/reference/interfaces/MutationObserverSuccessResult.md @@ -0,0 +1,308 @@ +--- +id: MutationObserverSuccessResult +title: MutationObserverSuccessResult +--- + +Defined in: [packages/query-core/src/types.ts:1463](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1463) + +The raw state stored on a `Mutation` instance. This is the underlying state +that observer results (e.g. `MutationObserverResult`) are derived from. + +## Extends + +- [`MutationObserverBaseResult`](MutationObserverBaseResult.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\> + +## Type Parameters + +### TData + +`TData` = `unknown` + +### TError + +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) + +### TVariables + +`TVariables` = `void` + +### TOnMutateResult + +`TOnMutateResult` = `unknown` + +## Properties + +### context + +```ts +context: TOnMutateResult | undefined; +``` + +Defined in: [packages/query-core/src/mutation.ts:40](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L40) + +The value returned by `onMutate`, if defined. Passed to `onSuccess`, +`onError` and `onSettled` as the mutation's context. + +#### Inherited from + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`context`](MutationObserverBaseResult.md#context) + +*** + +### data + +```ts +data: TData; +``` + +Defined in: [packages/query-core/src/types.ts:1474](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1474) + +The last successfully resolved data for the mutation. + +#### Overrides + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`data`](MutationObserverBaseResult.md#data) + +*** + +### error + +```ts +error: null; +``` + +Defined in: [packages/query-core/src/types.ts:1475](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1475) + +The error object for the mutation, if an error was encountered. +- Defaults to `null`. + +#### Overrides + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`error`](MutationObserverBaseResult.md#error) + +*** + +### failureCount + +```ts +failureCount: number; +``` + +Defined in: [packages/query-core/src/mutation.ts:53](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L53) + +The number of times the mutation function has failed for the current attempt. + +#### Inherited from + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`failureCount`](MutationObserverBaseResult.md#failurecount) + +*** + +### failureReason + +```ts +failureReason: TError | null; +``` + +Defined in: [packages/query-core/src/mutation.ts:57](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L57) + +The reason the current attempt failed, as reported by the retryer. + +#### Inherited from + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`failureReason`](MutationObserverBaseResult.md#failurereason) + +*** + +### isError + +```ts +isError: false; +``` + +Defined in: [packages/query-core/src/types.ts:1477](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1477) + +A boolean variable derived from `status`. +- `true` if the last mutation attempt resulted in an error. + +#### Overrides + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isError`](MutationObserverBaseResult.md#iserror) + +*** + +### isIdle + +```ts +isIdle: false; +``` + +Defined in: [packages/query-core/src/types.ts:1478](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1478) + +A boolean variable derived from `status`. +- `true` if the mutation is in its initial state prior to executing. + +#### Overrides + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isIdle`](MutationObserverBaseResult.md#isidle) + +*** + +### isPaused + +```ts +isPaused: boolean; +``` + +Defined in: [packages/query-core/src/mutation.ts:62](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L62) + +Whether the mutation is currently paused (see network mode), or is +waiting for another mutation with the same `scope` to finish. + +#### Inherited from + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isPaused`](MutationObserverBaseResult.md#ispaused) + +*** + +### isPending + +```ts +isPending: false; +``` + +Defined in: [packages/query-core/src/types.ts:1479](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1479) + +A boolean variable derived from `status`. +- `true` if the mutation is currently executing. + +#### Overrides + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isPending`](MutationObserverBaseResult.md#ispending) + +*** + +### isSuccess + +```ts +isSuccess: true; +``` + +Defined in: [packages/query-core/src/types.ts:1480](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1480) + +A boolean variable derived from `status`. +- `true` if the last mutation attempt was successful. + +#### Overrides + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`isSuccess`](MutationObserverBaseResult.md#issuccess) + +*** + +### mutate + +```ts +mutate: MutateFunction; +``` + +Defined in: [packages/query-core/src/types.ts:1393](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1393) + +The mutation function you can call with variables to trigger the mutation and optionally hooks on additional callback options. + +#### Param + +The variables object to pass to the `mutationFn`. + +#### Param + +This function will fire when the mutation is successful and will be passed the mutation's result. + +#### Param + +This function will fire if the mutation encounters an error and will be passed the error. + +#### Param + +This function will fire when the mutation is either successfully fetched or encounters an error and be passed either the data or error. + +#### Remarks + +- If you make multiple requests, `onSuccess` will fire only after the latest call you've made. +- All the callback functions (`onSuccess`, `onError`, `onSettled`) are void functions, and the returned value will be ignored. + +#### Inherited from + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`mutate`](MutationObserverBaseResult.md#mutate) + +*** + +### reset() + +```ts +reset: () => void; +``` + +Defined in: [packages/query-core/src/types.ts:1397](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1397) + +A function to clean the mutation internal state (i.e., it resets the mutation to its initial state). + +#### Returns + +`void` + +#### Inherited from + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`reset`](MutationObserverBaseResult.md#reset) + +*** + +### status + +```ts +status: "success"; +``` + +Defined in: [packages/query-core/src/types.ts:1481](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1481) + +The status of the mutation. +- Will be: + - `idle` initial status prior to the mutation function executing. + - `pending` if the mutation is currently executing. + - `error` if the last mutation attempt resulted in an error. + - `success` if the last mutation attempt was successful. + +#### Overrides + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`status`](MutationObserverBaseResult.md#status) + +*** + +### submittedAt + +```ts +submittedAt: number; +``` + +Defined in: [packages/query-core/src/mutation.ts:74](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L74) + +The timestamp for when the mutation was submitted. + +#### Inherited from + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`submittedAt`](MutationObserverBaseResult.md#submittedat) + +*** + +### variables + +```ts +variables: TVariables; +``` + +Defined in: [packages/query-core/src/types.ts:1476](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1476) + +The variables object passed to the `mutationFn`. + +#### Overrides + +[`MutationObserverBaseResult`](MutationObserverBaseResult.md).[`variables`](MutationObserverBaseResult.md#variables) diff --git a/docs/framework/vue/reference/interfaces/MutationState.md b/docs/framework/vue/reference/interfaces/MutationState.md new file mode 100644 index 00000000000..bec050ec1d3 --- /dev/null +++ b/docs/framework/vue/reference/interfaces/MutationState.md @@ -0,0 +1,142 @@ +--- +id: MutationState +title: MutationState +--- + +Defined in: [packages/query-core/src/mutation.ts:30](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L30) + +The raw state stored on a `Mutation` instance. This is the underlying state +that observer results (e.g. `MutationObserverResult`) are derived from. + +## Extended by + +- [`MutationObserverBaseResult`](MutationObserverBaseResult.md) + +## Type Parameters + +### TData + +`TData` = `unknown` + +### TError + +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) + +### TVariables + +`TVariables` = `unknown` + +### TOnMutateResult + +`TOnMutateResult` = `unknown` + +## Properties + +### context + +```ts +context: TOnMutateResult | undefined; +``` + +Defined in: [packages/query-core/src/mutation.ts:40](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L40) + +The value returned by `onMutate`, if defined. Passed to `onSuccess`, +`onError` and `onSettled` as the mutation's context. + +*** + +### data + +```ts +data: TData | undefined; +``` + +Defined in: [packages/query-core/src/mutation.ts:44](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L44) + +The last successfully resolved data for the mutation. + +*** + +### error + +```ts +error: TError | null; +``` + +Defined in: [packages/query-core/src/mutation.ts:49](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L49) + +The error object for the mutation, if the last attempt resulted in an error. +- Defaults to `null`. + +*** + +### failureCount + +```ts +failureCount: number; +``` + +Defined in: [packages/query-core/src/mutation.ts:53](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L53) + +The number of times the mutation function has failed for the current attempt. + +*** + +### failureReason + +```ts +failureReason: TError | null; +``` + +Defined in: [packages/query-core/src/mutation.ts:57](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L57) + +The reason the current attempt failed, as reported by the retryer. + +*** + +### isPaused + +```ts +isPaused: boolean; +``` + +Defined in: [packages/query-core/src/mutation.ts:62](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L62) + +Whether the mutation is currently paused (see network mode), or is +waiting for another mutation with the same `scope` to finish. + +*** + +### status + +```ts +status: MutationStatus; +``` + +Defined in: [packages/query-core/src/mutation.ts:66](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L66) + +The status of the mutation. + +*** + +### submittedAt + +```ts +submittedAt: number; +``` + +Defined in: [packages/query-core/src/mutation.ts:74](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L74) + +The timestamp for when the mutation was submitted. + +*** + +### variables + +```ts +variables: TVariables | undefined; +``` + +Defined in: [packages/query-core/src/mutation.ts:70](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutation.ts#L70) + +The variables the mutation was last called with. diff --git a/docs/framework/vue/reference/interfaces/NotifyEvent.md b/docs/framework/vue/reference/interfaces/NotifyEvent.md new file mode 100644 index 00000000000..4f5b023f49a --- /dev/null +++ b/docs/framework/vue/reference/interfaces/NotifyEvent.md @@ -0,0 +1,16 @@ +--- +id: NotifyEvent +title: NotifyEvent +--- + +Defined in: [packages/query-core/src/types.ts:1539](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1539) + +## Properties + +### type + +```ts +type: NotifyEventType; +``` + +Defined in: [packages/query-core/src/types.ts:1540](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1540) diff --git a/docs/framework/vue/reference/interfaces/OnlineManager.md b/docs/framework/vue/reference/interfaces/OnlineManager.md new file mode 100644 index 00000000000..1a936c91ed9 --- /dev/null +++ b/docs/framework/vue/reference/interfaces/OnlineManager.md @@ -0,0 +1,214 @@ +--- +id: OnlineManager +title: OnlineManager +--- + +Defined in: [packages/query-core/src/onlineManager.ts:15](https://github.com/TanStack/query/blob/main/packages/query-core/src/onlineManager.ts#L15) + +The `OnlineManager` manages the online state within TanStack Query. It can +be used to change the default event listeners or to manually change the +online state. + +By default, the `onlineManager` assumes an active network connection, and +listens to the `online` and `offline` events on the `window` object to +detect changes. + +## Extends + +- `Subscribable`\<`Listener`\> + +## Properties + +### listeners + +```ts +protected listeners: Set; +``` + +Defined in: [packages/query-core/src/subscribable.ts:2](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L2) + +#### Inherited from + +```ts +Subscribable.listeners +``` + +## Methods + +### hasListeners() + +```ts +hasListeners(): boolean; +``` + +Defined in: [packages/query-core/src/subscribable.ts:19](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L19) + +#### Returns + +`boolean` + +#### Inherited from + +```ts +Subscribable.hasListeners +``` + +*** + +### isOnline() + +```ts +isOnline(): boolean; +``` + +Defined in: [packages/query-core/src/onlineManager.ts:109](https://github.com/TanStack/query/blob/main/packages/query-core/src/onlineManager.ts#L109) + +`isOnline` can be used to get the current online state. + +#### Returns + +`boolean` + +*** + +### onSubscribe() + +```ts +protected onSubscribe(): void; +``` + +Defined in: [packages/query-core/src/onlineManager.ts:44](https://github.com/TanStack/query/blob/main/packages/query-core/src/onlineManager.ts#L44) + +#### Returns + +`void` + +#### Overrides + +```ts +Subscribable.onSubscribe +``` + +*** + +### onUnsubscribe() + +```ts +protected onUnsubscribe(): void; +``` + +Defined in: [packages/query-core/src/onlineManager.ts:50](https://github.com/TanStack/query/blob/main/packages/query-core/src/onlineManager.ts#L50) + +#### Returns + +`void` + +#### Overrides + +```ts +Subscribable.onUnsubscribe +``` + +*** + +### setEventListener() + +```ts +setEventListener(setup): void; +``` + +Defined in: [packages/query-core/src/onlineManager.ts:75](https://github.com/TanStack/query/blob/main/packages/query-core/src/onlineManager.ts#L75) + +`setEventListener` can be used to set a custom event listener that will +be used to determine the online state. The provided `setup` function +receives a `setOnline` callback that should be called with a `boolean` +whenever the online state changes. + +#### Parameters + +##### setup + +`SetupFn` + +#### Returns + +`void` + +#### Example + +```ts +import NetInfo from '@react-native-community/netinfo' +import { onlineManager } from '@tanstack/query-core' + +onlineManager.setEventListener((setOnline) => { + return NetInfo.addEventListener((state) => { + setOnline(!!state.isConnected) + }) +}) +``` + +*** + +### setOnline() + +```ts +setOnline(online): void; +``` + +Defined in: [packages/query-core/src/onlineManager.ts:95](https://github.com/TanStack/query/blob/main/packages/query-core/src/onlineManager.ts#L95) + +`setOnline` can be used to manually set the online state. + +#### Parameters + +##### online + +`boolean` + +#### Returns + +`void` + +#### Example + +```ts +import { onlineManager } from '@tanstack/query-core' + +// Set to online +onlineManager.setOnline(true) + +// Set to offline +onlineManager.setOnline(false) +``` + +*** + +### subscribe() + +```ts +subscribe(listener): () => void; +``` + +Defined in: [packages/query-core/src/subscribable.ts:8](https://github.com/TanStack/query/blob/main/packages/query-core/src/subscribable.ts#L8) + +#### Parameters + +##### listener + +`Listener` + +#### Returns + +```ts +(): void; +``` + +##### Returns + +`void` + +#### Inherited from + +```ts +Subscribable.subscribe +``` diff --git a/docs/framework/vue/reference/interfaces/QueriesObserverOptions.md b/docs/framework/vue/reference/interfaces/QueriesObserverOptions.md new file mode 100644 index 00000000000..68e7913885d --- /dev/null +++ b/docs/framework/vue/reference/interfaces/QueriesObserverOptions.md @@ -0,0 +1,29 @@ +--- +id: QueriesObserverOptions +title: QueriesObserverOptions +--- + +Defined in: [packages/query-core/src/queriesObserver.ts:23](https://github.com/TanStack/query/blob/main/packages/query-core/src/queriesObserver.ts#L23) + +## Type Parameters + +### TCombinedResult + +`TCombinedResult` = [`QueryObserverResult`](../type-aliases/QueryObserverResult.md)[] + +## Properties + +### combine? + +```ts +optional combine: CombineFn; +``` + +Defined in: [packages/query-core/src/queriesObserver.ts:34](https://github.com/TanStack/query/blob/main/packages/query-core/src/queriesObserver.ts#L34) + +A function that combines the array of `QueryObserverResult`s (one per +observed query) into a single value. The combined value is memoized and +only recomputed when one of the underlying results, the query hashes, or +the `combine` function itself changes. + +Defaults to returning the array of `QueryObserverResult`s unchanged. diff --git a/docs/framework/vue/reference/interfaces/QueryCacheConfig.md b/docs/framework/vue/reference/interfaces/QueryCacheConfig.md new file mode 100644 index 00000000000..3c6aebe496f --- /dev/null +++ b/docs/framework/vue/reference/interfaces/QueryCacheConfig.md @@ -0,0 +1,93 @@ +--- +id: QueryCacheConfig +title: QueryCacheConfig +--- + +Defined in: [packages/query-core/src/queryCache.ts:25](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryCache.ts#L25) + +Global callbacks that fire for every query handled by a `QueryCache`, regardless of which +component or observer triggered it. Unlike `QueryClient`'s `defaultOptions`, which a query can +override, these callbacks are always called. Unlike `MutationCacheConfig`'s callbacks, these +are fire-and-forget: their return value is not awaited before the query settles. + +## Properties + +### onError()? + +```ts +optional onError: (error, query) => void; +``` + +Defined in: [packages/query-core/src/queryCache.ts:27](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryCache.ts#L27) + +Called when any query in the cache encounters an error. + +#### Parameters + +##### error + +`Error` + +##### query + +[`Query`](../classes/Query.md)\<`unknown`, `unknown`, `unknown`\> + +#### Returns + +`void` + +*** + +### onSettled()? + +```ts +optional onSettled: (data, error, query) => void; +``` + +Defined in: [packages/query-core/src/queryCache.ts:34](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryCache.ts#L34) + +Called when any query in the cache is settled, either successfully or with an error. + +#### Parameters + +##### data + +`unknown` + +##### error + +`Error` | `null` + +##### query + +[`Query`](../classes/Query.md)\<`unknown`, `unknown`, `unknown`\> + +#### Returns + +`void` + +*** + +### onSuccess()? + +```ts +optional onSuccess: (data, query) => void; +``` + +Defined in: [packages/query-core/src/queryCache.ts:32](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryCache.ts#L32) + +Called when any query in the cache is successful. + +#### Parameters + +##### data + +`unknown` + +##### query + +[`Query`](../classes/Query.md)\<`unknown`, `unknown`, `unknown`\> + +#### Returns + +`void` diff --git a/docs/framework/vue/reference/interfaces/QueryClientConfig.md b/docs/framework/vue/reference/interfaces/QueryClientConfig.md new file mode 100644 index 00000000000..070e249491f --- /dev/null +++ b/docs/framework/vue/reference/interfaces/QueryClientConfig.md @@ -0,0 +1,43 @@ +--- +id: QueryClientConfig +title: QueryClientConfig +--- + +Defined in: [packages/query-core/src/types.ts:1495](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1495) + +## Properties + +### defaultOptions? + +```ts +optional defaultOptions: DefaultOptions; +``` + +Defined in: [packages/query-core/src/types.ts:1504](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1504) + +Default options for all queries and mutations created through this client. + +*** + +### mutationCache? + +```ts +optional mutationCache: MutationCache; +``` + +Defined in: [packages/query-core/src/types.ts:1502](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1502) + +The mutation cache this client is connected to. A new `MutationCache` is created if not +provided. + +*** + +### queryCache? + +```ts +optional queryCache: QueryCache; +``` + +Defined in: [packages/query-core/src/types.ts:1497](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1497) + +The query cache this client is connected to. A new `QueryCache` is created if not provided. diff --git a/docs/framework/vue/reference/interfaces/QueryExecuteOptions.md b/docs/framework/vue/reference/interfaces/QueryExecuteOptions.md new file mode 100644 index 00000000000..b16474c4999 --- /dev/null +++ b/docs/framework/vue/reference/interfaces/QueryExecuteOptions.md @@ -0,0 +1,382 @@ +--- +id: QueryExecuteOptions +title: QueryExecuteOptions +--- + +Defined in: [packages/query-core/src/types.ts:574](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L574) + +## Extends + +- [`WithRequired`](../type-aliases/WithRequired.md)\<`QueryOptions`\<`TQueryFnData`, `TError`, `TQueryData`, `TQueryKey`, `TPageParam`\>, `"queryKey"`\> + +## Type Parameters + +### TQueryFnData + +`TQueryFnData` = `unknown` + +### TError + +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) + +### TData + +`TData` = `TQueryFnData` + +### TQueryData + +`TQueryData` = `TQueryFnData` + +### TQueryKey + +`TQueryKey` *extends* [`QueryKey`](../type-aliases/QueryKey.md) = [`QueryKey`](../type-aliases/QueryKey.md) + +### TPageParam + +`TPageParam` = `never` + +## Properties + +### gcTime? + +```ts +optional gcTime: number; +``` + +Defined in: [packages/query-core/src/types.ts:277](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L277) + +The time in milliseconds that unused/inactive cache data remains in memory. +When a query's cache becomes unused or inactive, that cache data will be garbage collected after this duration. +When different garbage collection times are specified, the longest one will be used. +Setting it to `Infinity` will disable garbage collection. + +Defaults to `5 * 60 * 1000` (5 minutes), or `Infinity` during SSR. + +Note: the maximum allowed time is about 24 days, imposed by `setTimeout`'s 32-bit signed integer delay — see +`timeoutManager.setTimeoutProvider` for a workaround. + +#### Inherited from + +```ts +WithRequired.gcTime +``` + +*** + +### initialData? + +```ts +optional initialData: + | TQueryData +| InitialDataFunction; +``` + +Defined in: [packages/query-core/src/types.ts:317](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L317) + +If set, this value will be used as the initial data for the query cache (as long as the query hasn't been +created or cached yet). +If set to a function, the function will be called **once** during the shared/root query initialization, and be +expected to synchronously return the initial data. +Initial data is considered stale by default unless a `staleTime` has been set. +`initialData` **is persisted** to the cache. + +#### Inherited from + +```ts +WithRequired.initialData +``` + +*** + +### initialDataUpdatedAt? + +```ts +optional initialDataUpdatedAt: number | () => number | undefined; +``` + +Defined in: [packages/query-core/src/types.ts:321](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L321) + +If set, this value will be used as the time (in milliseconds) of when the `initialData` itself was last updated. + +#### Inherited from + +```ts +WithRequired.initialDataUpdatedAt +``` + +*** + +### initialPageParam? + +```ts +optional initialPageParam: undefined; +``` + +Defined in: [packages/query-core/src/types.ts:585](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L585) + +*** + +### maxPages? + +```ts +optional maxPages: number; +``` + +Defined in: [packages/query-core/src/types.ts:345](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L345) + +Maximum number of pages to store in the data of an infinite query. + +#### Inherited from + +```ts +WithRequired.maxPages +``` + +*** + +### meta? + +```ts +optional meta: Record; +``` + +Defined in: [packages/query-core/src/types.ts:341](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L341) + +Additional payload to be stored on each query. +Use this property to pass information that can be used in other places. + +#### Inherited from + +```ts +WithRequired.meta +``` + +*** + +### networkMode? + +```ts +optional networkMode: NetworkMode; +``` + +Defined in: [packages/query-core/src/types.ts:265](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L265) + +Controls whether a query is allowed to run based on the current network connectivity. + +Defaults to `'online'`. + +#### See + +[Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. + +#### Inherited from + +```ts +WithRequired.networkMode +``` + +*** + +### persister? + +```ts +optional persister: QueryPersister, TPageParam>; +``` + +Defined in: [packages/query-core/src/types.ts:290](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L290) + +This option can be used to persist the result of a query to an external storage, bypassing the need to actually +call the `queryFn`. Useful for persisting a query's data across e.g. server/client boundaries. + +#### Inherited from + +```ts +WithRequired.persister +``` + +*** + +### queryFn? + +```ts +optional queryFn: + | typeof skipToken +| QueryFunction; +``` + +Defined in: [packages/query-core/src/types.ts:285](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L285) + +The function that the query will use to request data. +Required, unless a default query function has been set via `queryClient.setQueryDefaults` or +`queryClient.setDefaultOptions`. +Receives a [QueryFunctionContext](../type-aliases/QueryFunctionContext.md). +Must return a promise that will either resolve data or throw an error. The data cannot be `undefined`. + +#### Inherited from + +```ts +WithRequired.queryFn +``` + +*** + +### queryHash? + +```ts +optional queryHash: string; +``` + +Defined in: [packages/query-core/src/types.ts:295](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L295) + +The hashed form of `queryKey`, computed with `queryKeyHashFn` (or the default hashing function otherwise). Used +as the actual cache key internally. + +#### Inherited from + +```ts +WithRequired.queryHash +``` + +*** + +### queryKey + +```ts +queryKey: TQueryKey & object; +``` + +Defined in: [packages/query-core/src/types.ts:304](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L304) + +The query key to use for this query. + +The query key will be hashed into a stable hash. See [Query Keys](https://tanstack.com/query/latest/docs/framework/react/guides/query-keys) +for more information. + +The query will automatically update when this key changes (as long as `enabled` is not set to `false`). + +#### Inherited from + +```ts +WithRequired.queryKey +``` + +*** + +### queryKeyHashFn? + +```ts +optional queryKeyHashFn: QueryKeyHashFunction; +``` + +Defined in: [packages/query-core/src/types.ts:308](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L308) + +If specified, this function is used to hash the `queryKey` to a string. + +#### Inherited from + +```ts +WithRequired.queryKeyHashFn +``` + +*** + +### retry? + +```ts +optional retry: RetryValue; +``` + +Defined in: [packages/query-core/src/types.ts:246](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L246) + +If `false`, failed queries will not retry by default. +If `true`, failed queries will retry infinitely. +If set to an integer number, e.g. 3, failed queries will retry until the failed query count meets that number. +If set to a function `(failureCount, error) => boolean` failed queries will retry until the function returns false. + +Defaults to `3` on the client and `0` on the server. + +#### Inherited from + +```ts +WithRequired.retry +``` + +*** + +### retryDelay? + +```ts +optional retryDelay: RetryDelayValue; +``` + +Defined in: [packages/query-core/src/types.ts:258](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L258) + +This function receives a `retryAttempt` integer and the actual Error and returns the delay to apply before the +next attempt in milliseconds. + +A function like `attempt => Math.min(attempt > 1 ? 2 ** attempt * 1000 : 1000, 30 * 1000)` applies exponential +backoff. + +A function like `attempt => attempt * 1000` applies linear backoff. + +Defaults to a function that applies exponential backoff, capped at 30 seconds. + +#### Inherited from + +```ts +WithRequired.retryDelay +``` + +*** + +### select()? + +```ts +optional select: (data) => TData; +``` + +Defined in: [packages/query-core/src/types.ts:586](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L586) + +#### Parameters + +##### data + +`TQueryData` + +#### Returns + +`TData` + +*** + +### staleTime? + +```ts +optional staleTime: StaleTimeFunction; +``` + +Defined in: [packages/query-core/src/types.ts:591](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L591) + +The time in milliseconds after data is considered stale. +If the data is fresh it will be returned from the cache. + +*** + +### structuralSharing? + +```ts +optional structuralSharing: boolean | (oldData, newData) => unknown; +``` + +Defined in: [packages/query-core/src/types.ts:330](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L330) + +Set this to `false` to disable structural sharing between query results. +Set this to a function which accepts the old and new data and returns resolved data of the same type to implement custom structural sharing logic. + +Defaults to `true`. + +#### Inherited from + +```ts +WithRequired.structuralSharing +``` diff --git a/docs/framework/vue/reference/interfaces/QueryObserverBaseResult.md b/docs/framework/vue/reference/interfaces/QueryObserverBaseResult.md new file mode 100644 index 00000000000..ef5fe0ad757 --- /dev/null +++ b/docs/framework/vue/reference/interfaces/QueryObserverBaseResult.md @@ -0,0 +1,358 @@ +--- +id: QueryObserverBaseResult +title: QueryObserverBaseResult +--- + +Defined in: [packages/query-core/src/types.ts:764](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L764) + +## Extended by + +- [`QueryObserverPendingResult`](QueryObserverPendingResult.md) +- [`QueryObserverLoadingResult`](QueryObserverLoadingResult.md) +- [`QueryObserverLoadingErrorResult`](QueryObserverLoadingErrorResult.md) +- [`QueryObserverRefetchErrorResult`](QueryObserverRefetchErrorResult.md) +- [`QueryObserverSuccessResult`](QueryObserverSuccessResult.md) +- [`QueryObserverPlaceholderResult`](QueryObserverPlaceholderResult.md) +- [`InfiniteQueryObserverBaseResult`](InfiniteQueryObserverBaseResult.md) + +## Type Parameters + +### TData + +`TData` = `unknown` + +### TError + +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) + +## Properties + +### data + +```ts +data: TData | undefined; +``` + +Defined in: [packages/query-core/src/types.ts:771](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L771) + +The last successfully resolved data for the query. + +*** + +### dataUpdatedAt + +```ts +dataUpdatedAt: number; +``` + +Defined in: [packages/query-core/src/types.ts:775](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L775) + +The timestamp for when the query most recently returned the `status` as `"success"`. + +*** + +### error + +```ts +error: TError | null; +``` + +Defined in: [packages/query-core/src/types.ts:780](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L780) + +The error object for the query, if an error was thrown. +- Defaults to `null`. + +*** + +### errorUpdateCount + +```ts +errorUpdateCount: number; +``` + +Defined in: [packages/query-core/src/types.ts:799](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L799) + +The sum of all errors. + +*** + +### errorUpdatedAt + +```ts +errorUpdatedAt: number; +``` + +Defined in: [packages/query-core/src/types.ts:784](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L784) + +The timestamp for when the query most recently returned the `status` as `"error"`. + +*** + +### failureCount + +```ts +failureCount: number; +``` + +Defined in: [packages/query-core/src/types.ts:790](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L790) + +The failure count for the query. +- Incremented every time the query fails. +- Reset to `0` when the query succeeds. + +*** + +### failureReason + +```ts +failureReason: TError | null; +``` + +Defined in: [packages/query-core/src/types.ts:795](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L795) + +The failure reason for the query retry. +- Reset to `null` when the query succeeds. + +*** + +### fetchStatus + +```ts +fetchStatus: FetchStatus; +``` + +Defined in: [packages/query-core/src/types.ts:889](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L889) + +The fetch status of the query. +- `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. +- `paused`: The query wanted to fetch, but has been `paused`. +- `idle`: The query is not fetching. +- See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. + +*** + +### isEnabled + +```ts +isEnabled: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:867](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L867) + +`true` if this observer is enabled, `false` otherwise. + +*** + +### isError + +```ts +isError: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:804](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L804) + +A derived boolean from the `status` variable, provided for convenience. +- `true` if the query attempt resulted in an error. + +*** + +### isFetched + +```ts +isFetched: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:808](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L808) + +Will be `true` if the query has been fetched. + +*** + +### isFetchedAfterMount + +```ts +isFetchedAfterMount: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:813](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L813) + +Will be `true` if the query has been fetched after the component mounted. +- This property can be used to not show any previously cached data. + +*** + +### isFetching + +```ts +isFetching: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:818](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L818) + +A derived boolean from the `fetchStatus` variable, provided for convenience. +- `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. + +*** + +### ~~isInitialLoading~~ + +```ts +isInitialLoading: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:836](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L836) + +#### Deprecated + +`isInitialLoading` is being deprecated in favor of `isLoading` +and will be removed in the next major version. + +*** + +### isLoading + +```ts +isLoading: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:823](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L823) + +Is `true` whenever the first fetch for a query is in-flight. +- Is the same as `isFetching && isPending`. + +*** + +### isLoadingError + +```ts +isLoadingError: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:831](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L831) + +Will be `true` if the query failed while fetching for the first time. + +*** + +### isPaused + +```ts +isPaused: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:841](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L841) + +A derived boolean from the `fetchStatus` variable, provided for convenience. +- The query wanted to fetch, but has been `paused`. + +*** + +### isPending + +```ts +isPending: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:827](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L827) + +Will be `pending` if there's no cached data and no query attempt was finished yet. + +*** + +### isPlaceholderData + +```ts +isPlaceholderData: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:845](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L845) + +Will be `true` if the data shown is the placeholder data. + +*** + +### isRefetchError + +```ts +isRefetchError: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:849](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L849) + +Will be `true` if the query failed while refetching. + +*** + +### isRefetching + +```ts +isRefetching: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:854](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L854) + +Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. +- Is the same as `isFetching && !isPending`. + +*** + +### isStale + +```ts +isStale: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:858](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L858) + +Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. + +*** + +### isSuccess + +```ts +isSuccess: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:863](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L863) + +A derived boolean from the `status` variable, provided for convenience. +- `true` if the query has received a response with no errors and is ready to display its data. + +*** + +### refetch() + +```ts +refetch: (options?) => Promise>; +``` + +Defined in: [packages/query-core/src/types.ts:871](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L871) + +A function to manually refetch the query. + +#### Parameters + +##### options? + +[`RefetchOptions`](RefetchOptions.md) + +#### Returns + +`Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> + +*** + +### status + +```ts +status: QueryStatus; +``` + +Defined in: [packages/query-core/src/types.ts:881](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L881) + +The status of the query. +- Will be: + - `pending` if there's no cached data and no query attempt was finished yet. + - `error` if the query attempt resulted in an error. + - `success` if the query has received a response with no errors and is ready to display its data. diff --git a/docs/framework/vue/reference/interfaces/QueryObserverLoadingErrorResult.md b/docs/framework/vue/reference/interfaces/QueryObserverLoadingErrorResult.md new file mode 100644 index 00000000000..21b39fbffe3 --- /dev/null +++ b/docs/framework/vue/reference/interfaces/QueryObserverLoadingErrorResult.md @@ -0,0 +1,452 @@ +--- +id: QueryObserverLoadingErrorResult +title: QueryObserverLoadingErrorResult +--- + +Defined in: [packages/query-core/src/types.ts:923](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L923) + +## Extends + +- [`QueryObserverBaseResult`](QueryObserverBaseResult.md)\<`TData`, `TError`\> + +## Type Parameters + +### TData + +`TData` = `unknown` + +### TError + +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) + +## Properties + +### data + +```ts +data: undefined; +``` + +Defined in: [packages/query-core/src/types.ts:927](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L927) + +The last successfully resolved data for the query. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`data`](QueryObserverBaseResult.md#data) + +*** + +### dataUpdatedAt + +```ts +dataUpdatedAt: number; +``` + +Defined in: [packages/query-core/src/types.ts:775](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L775) + +The timestamp for when the query most recently returned the `status` as `"success"`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`dataUpdatedAt`](QueryObserverBaseResult.md#dataupdatedat) + +*** + +### error + +```ts +error: TError; +``` + +Defined in: [packages/query-core/src/types.ts:928](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L928) + +The error object for the query, if an error was thrown. +- Defaults to `null`. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`error`](QueryObserverBaseResult.md#error) + +*** + +### errorUpdateCount + +```ts +errorUpdateCount: number; +``` + +Defined in: [packages/query-core/src/types.ts:799](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L799) + +The sum of all errors. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`errorUpdateCount`](QueryObserverBaseResult.md#errorupdatecount) + +*** + +### errorUpdatedAt + +```ts +errorUpdatedAt: number; +``` + +Defined in: [packages/query-core/src/types.ts:784](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L784) + +The timestamp for when the query most recently returned the `status` as `"error"`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`errorUpdatedAt`](QueryObserverBaseResult.md#errorupdatedat) + +*** + +### failureCount + +```ts +failureCount: number; +``` + +Defined in: [packages/query-core/src/types.ts:790](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L790) + +The failure count for the query. +- Incremented every time the query fails. +- Reset to `0` when the query succeeds. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`failureCount`](QueryObserverBaseResult.md#failurecount) + +*** + +### failureReason + +```ts +failureReason: TError | null; +``` + +Defined in: [packages/query-core/src/types.ts:795](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L795) + +The failure reason for the query retry. +- Reset to `null` when the query succeeds. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`failureReason`](QueryObserverBaseResult.md#failurereason) + +*** + +### fetchStatus + +```ts +fetchStatus: FetchStatus; +``` + +Defined in: [packages/query-core/src/types.ts:889](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L889) + +The fetch status of the query. +- `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. +- `paused`: The query wanted to fetch, but has been `paused`. +- `idle`: The query is not fetching. +- See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`fetchStatus`](QueryObserverBaseResult.md#fetchstatus) + +*** + +### isEnabled + +```ts +isEnabled: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:867](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L867) + +`true` if this observer is enabled, `false` otherwise. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isEnabled`](QueryObserverBaseResult.md#isenabled) + +*** + +### isError + +```ts +isError: true; +``` + +Defined in: [packages/query-core/src/types.ts:929](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L929) + +A derived boolean from the `status` variable, provided for convenience. +- `true` if the query attempt resulted in an error. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isError`](QueryObserverBaseResult.md#iserror) + +*** + +### isFetched + +```ts +isFetched: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:808](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L808) + +Will be `true` if the query has been fetched. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isFetched`](QueryObserverBaseResult.md#isfetched) + +*** + +### isFetchedAfterMount + +```ts +isFetchedAfterMount: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:813](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L813) + +Will be `true` if the query has been fetched after the component mounted. +- This property can be used to not show any previously cached data. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isFetchedAfterMount`](QueryObserverBaseResult.md#isfetchedaftermount) + +*** + +### isFetching + +```ts +isFetching: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:818](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L818) + +A derived boolean from the `fetchStatus` variable, provided for convenience. +- `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isFetching`](QueryObserverBaseResult.md#isfetching) + +*** + +### ~~isInitialLoading~~ + +```ts +isInitialLoading: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:836](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L836) + +#### Deprecated + +`isInitialLoading` is being deprecated in favor of `isLoading` +and will be removed in the next major version. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isInitialLoading`](QueryObserverBaseResult.md#isinitialloading) + +*** + +### isLoading + +```ts +isLoading: false; +``` + +Defined in: [packages/query-core/src/types.ts:931](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L931) + +Is `true` whenever the first fetch for a query is in-flight. +- Is the same as `isFetching && isPending`. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoading`](QueryObserverBaseResult.md#isloading) + +*** + +### isLoadingError + +```ts +isLoadingError: true; +``` + +Defined in: [packages/query-core/src/types.ts:932](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L932) + +Will be `true` if the query failed while fetching for the first time. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoadingError`](QueryObserverBaseResult.md#isloadingerror) + +*** + +### isPaused + +```ts +isPaused: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:841](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L841) + +A derived boolean from the `fetchStatus` variable, provided for convenience. +- The query wanted to fetch, but has been `paused`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPaused`](QueryObserverBaseResult.md#ispaused) + +*** + +### isPending + +```ts +isPending: false; +``` + +Defined in: [packages/query-core/src/types.ts:930](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L930) + +Will be `pending` if there's no cached data and no query attempt was finished yet. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPending`](QueryObserverBaseResult.md#ispending) + +*** + +### isPlaceholderData + +```ts +isPlaceholderData: false; +``` + +Defined in: [packages/query-core/src/types.ts:935](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L935) + +Will be `true` if the data shown is the placeholder data. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPlaceholderData`](QueryObserverBaseResult.md#isplaceholderdata) + +*** + +### isRefetchError + +```ts +isRefetchError: false; +``` + +Defined in: [packages/query-core/src/types.ts:933](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L933) + +Will be `true` if the query failed while refetching. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetchError`](QueryObserverBaseResult.md#isrefetcherror) + +*** + +### isRefetching + +```ts +isRefetching: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:854](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L854) + +Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. +- Is the same as `isFetching && !isPending`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetching`](QueryObserverBaseResult.md#isrefetching) + +*** + +### isStale + +```ts +isStale: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:858](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L858) + +Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isStale`](QueryObserverBaseResult.md#isstale) + +*** + +### isSuccess + +```ts +isSuccess: false; +``` + +Defined in: [packages/query-core/src/types.ts:934](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L934) + +A derived boolean from the `status` variable, provided for convenience. +- `true` if the query has received a response with no errors and is ready to display its data. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isSuccess`](QueryObserverBaseResult.md#issuccess) + +*** + +### refetch() + +```ts +refetch: (options?) => Promise>; +``` + +Defined in: [packages/query-core/src/types.ts:871](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L871) + +A function to manually refetch the query. + +#### Parameters + +##### options? + +[`RefetchOptions`](RefetchOptions.md) + +#### Returns + +`Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`refetch`](QueryObserverBaseResult.md#refetch) + +*** + +### status + +```ts +status: "error"; +``` + +Defined in: [packages/query-core/src/types.ts:936](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L936) + +The status of the query. +- Will be: + - `pending` if there's no cached data and no query attempt was finished yet. + - `error` if the query attempt resulted in an error. + - `success` if the query has received a response with no errors and is ready to display its data. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`status`](QueryObserverBaseResult.md#status) diff --git a/docs/framework/vue/reference/interfaces/QueryObserverLoadingResult.md b/docs/framework/vue/reference/interfaces/QueryObserverLoadingResult.md new file mode 100644 index 00000000000..4966390127f --- /dev/null +++ b/docs/framework/vue/reference/interfaces/QueryObserverLoadingResult.md @@ -0,0 +1,452 @@ +--- +id: QueryObserverLoadingResult +title: QueryObserverLoadingResult +--- + +Defined in: [packages/query-core/src/types.ts:907](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L907) + +## Extends + +- [`QueryObserverBaseResult`](QueryObserverBaseResult.md)\<`TData`, `TError`\> + +## Type Parameters + +### TData + +`TData` = `unknown` + +### TError + +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) + +## Properties + +### data + +```ts +data: undefined; +``` + +Defined in: [packages/query-core/src/types.ts:911](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L911) + +The last successfully resolved data for the query. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`data`](QueryObserverBaseResult.md#data) + +*** + +### dataUpdatedAt + +```ts +dataUpdatedAt: number; +``` + +Defined in: [packages/query-core/src/types.ts:775](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L775) + +The timestamp for when the query most recently returned the `status` as `"success"`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`dataUpdatedAt`](QueryObserverBaseResult.md#dataupdatedat) + +*** + +### error + +```ts +error: null; +``` + +Defined in: [packages/query-core/src/types.ts:912](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L912) + +The error object for the query, if an error was thrown. +- Defaults to `null`. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`error`](QueryObserverBaseResult.md#error) + +*** + +### errorUpdateCount + +```ts +errorUpdateCount: number; +``` + +Defined in: [packages/query-core/src/types.ts:799](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L799) + +The sum of all errors. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`errorUpdateCount`](QueryObserverBaseResult.md#errorupdatecount) + +*** + +### errorUpdatedAt + +```ts +errorUpdatedAt: number; +``` + +Defined in: [packages/query-core/src/types.ts:784](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L784) + +The timestamp for when the query most recently returned the `status` as `"error"`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`errorUpdatedAt`](QueryObserverBaseResult.md#errorupdatedat) + +*** + +### failureCount + +```ts +failureCount: number; +``` + +Defined in: [packages/query-core/src/types.ts:790](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L790) + +The failure count for the query. +- Incremented every time the query fails. +- Reset to `0` when the query succeeds. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`failureCount`](QueryObserverBaseResult.md#failurecount) + +*** + +### failureReason + +```ts +failureReason: TError | null; +``` + +Defined in: [packages/query-core/src/types.ts:795](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L795) + +The failure reason for the query retry. +- Reset to `null` when the query succeeds. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`failureReason`](QueryObserverBaseResult.md#failurereason) + +*** + +### fetchStatus + +```ts +fetchStatus: FetchStatus; +``` + +Defined in: [packages/query-core/src/types.ts:889](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L889) + +The fetch status of the query. +- `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. +- `paused`: The query wanted to fetch, but has been `paused`. +- `idle`: The query is not fetching. +- See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`fetchStatus`](QueryObserverBaseResult.md#fetchstatus) + +*** + +### isEnabled + +```ts +isEnabled: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:867](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L867) + +`true` if this observer is enabled, `false` otherwise. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isEnabled`](QueryObserverBaseResult.md#isenabled) + +*** + +### isError + +```ts +isError: false; +``` + +Defined in: [packages/query-core/src/types.ts:913](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L913) + +A derived boolean from the `status` variable, provided for convenience. +- `true` if the query attempt resulted in an error. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isError`](QueryObserverBaseResult.md#iserror) + +*** + +### isFetched + +```ts +isFetched: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:808](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L808) + +Will be `true` if the query has been fetched. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isFetched`](QueryObserverBaseResult.md#isfetched) + +*** + +### isFetchedAfterMount + +```ts +isFetchedAfterMount: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:813](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L813) + +Will be `true` if the query has been fetched after the component mounted. +- This property can be used to not show any previously cached data. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isFetchedAfterMount`](QueryObserverBaseResult.md#isfetchedaftermount) + +*** + +### isFetching + +```ts +isFetching: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:818](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L818) + +A derived boolean from the `fetchStatus` variable, provided for convenience. +- `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isFetching`](QueryObserverBaseResult.md#isfetching) + +*** + +### ~~isInitialLoading~~ + +```ts +isInitialLoading: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:836](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L836) + +#### Deprecated + +`isInitialLoading` is being deprecated in favor of `isLoading` +and will be removed in the next major version. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isInitialLoading`](QueryObserverBaseResult.md#isinitialloading) + +*** + +### isLoading + +```ts +isLoading: true; +``` + +Defined in: [packages/query-core/src/types.ts:915](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L915) + +Is `true` whenever the first fetch for a query is in-flight. +- Is the same as `isFetching && isPending`. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoading`](QueryObserverBaseResult.md#isloading) + +*** + +### isLoadingError + +```ts +isLoadingError: false; +``` + +Defined in: [packages/query-core/src/types.ts:916](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L916) + +Will be `true` if the query failed while fetching for the first time. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoadingError`](QueryObserverBaseResult.md#isloadingerror) + +*** + +### isPaused + +```ts +isPaused: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:841](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L841) + +A derived boolean from the `fetchStatus` variable, provided for convenience. +- The query wanted to fetch, but has been `paused`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPaused`](QueryObserverBaseResult.md#ispaused) + +*** + +### isPending + +```ts +isPending: true; +``` + +Defined in: [packages/query-core/src/types.ts:914](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L914) + +Will be `pending` if there's no cached data and no query attempt was finished yet. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPending`](QueryObserverBaseResult.md#ispending) + +*** + +### isPlaceholderData + +```ts +isPlaceholderData: false; +``` + +Defined in: [packages/query-core/src/types.ts:919](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L919) + +Will be `true` if the data shown is the placeholder data. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPlaceholderData`](QueryObserverBaseResult.md#isplaceholderdata) + +*** + +### isRefetchError + +```ts +isRefetchError: false; +``` + +Defined in: [packages/query-core/src/types.ts:917](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L917) + +Will be `true` if the query failed while refetching. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetchError`](QueryObserverBaseResult.md#isrefetcherror) + +*** + +### isRefetching + +```ts +isRefetching: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:854](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L854) + +Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. +- Is the same as `isFetching && !isPending`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetching`](QueryObserverBaseResult.md#isrefetching) + +*** + +### isStale + +```ts +isStale: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:858](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L858) + +Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isStale`](QueryObserverBaseResult.md#isstale) + +*** + +### isSuccess + +```ts +isSuccess: false; +``` + +Defined in: [packages/query-core/src/types.ts:918](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L918) + +A derived boolean from the `status` variable, provided for convenience. +- `true` if the query has received a response with no errors and is ready to display its data. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isSuccess`](QueryObserverBaseResult.md#issuccess) + +*** + +### refetch() + +```ts +refetch: (options?) => Promise>; +``` + +Defined in: [packages/query-core/src/types.ts:871](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L871) + +A function to manually refetch the query. + +#### Parameters + +##### options? + +[`RefetchOptions`](RefetchOptions.md) + +#### Returns + +`Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`refetch`](QueryObserverBaseResult.md#refetch) + +*** + +### status + +```ts +status: "pending"; +``` + +Defined in: [packages/query-core/src/types.ts:920](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L920) + +The status of the query. +- Will be: + - `pending` if there's no cached data and no query attempt was finished yet. + - `error` if the query attempt resulted in an error. + - `success` if the query has received a response with no errors and is ready to display its data. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`status`](QueryObserverBaseResult.md#status) diff --git a/docs/framework/vue/reference/interfaces/QueryObserverOptions.md b/docs/framework/vue/reference/interfaces/QueryObserverOptions.md new file mode 100644 index 00000000000..8b31eca49b1 --- /dev/null +++ b/docs/framework/vue/reference/interfaces/QueryObserverOptions.md @@ -0,0 +1,560 @@ +--- +id: QueryObserverOptions +title: QueryObserverOptions +--- + +Defined in: [packages/query-core/src/types.ts:380](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L380) + +## Extends + +- [`WithRequired`](../type-aliases/WithRequired.md)\<`QueryOptions`\<`TQueryFnData`, `TError`, `TQueryData`, `TQueryKey`, `TPageParam`\>, `"queryKey"`\> + +## Extended by + +- [`InfiniteQueryObserverOptions`](InfiniteQueryObserverOptions.md) + +## Type Parameters + +### TQueryFnData + +`TQueryFnData` = `unknown` + +### TError + +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) + +### TData + +`TData` = `TQueryFnData` + +### TQueryData + +`TQueryData` = `TQueryFnData` + +### TQueryKey + +`TQueryKey` *extends* [`QueryKey`](../type-aliases/QueryKey.md) = [`QueryKey`](../type-aliases/QueryKey.md) + +### TPageParam + +`TPageParam` = `never` + +## Properties + +### enabled? + +```ts +optional enabled: QueryBooleanOption; +``` + +Defined in: [packages/query-core/src/types.ts:398](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L398) + +Set this to `false` or a function that returns `false` to disable automatic refetching when the query mounts or changes query keys. +To refetch the query, use the `refetch` method returned from the `useQuery` instance. +Accepts a boolean or function that returns a boolean. + +Defaults to `true`. + +*** + +### gcTime? + +```ts +optional gcTime: number; +``` + +Defined in: [packages/query-core/src/types.ts:277](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L277) + +The time in milliseconds that unused/inactive cache data remains in memory. +When a query's cache becomes unused or inactive, that cache data will be garbage collected after this duration. +When different garbage collection times are specified, the longest one will be used. +Setting it to `Infinity` will disable garbage collection. + +Defaults to `5 * 60 * 1000` (5 minutes), or `Infinity` during SSR. + +Note: the maximum allowed time is about 24 days, imposed by `setTimeout`'s 32-bit signed integer delay — see +`timeoutManager.setTimeoutProvider` for a workaround. + +#### Inherited from + +```ts +WithRequired.gcTime +``` + +*** + +### initialData? + +```ts +optional initialData: + | TQueryData +| InitialDataFunction; +``` + +Defined in: [packages/query-core/src/types.ts:317](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L317) + +If set, this value will be used as the initial data for the query cache (as long as the query hasn't been +created or cached yet). +If set to a function, the function will be called **once** during the shared/root query initialization, and be +expected to synchronously return the initial data. +Initial data is considered stale by default unless a `staleTime` has been set. +`initialData` **is persisted** to the cache. + +#### Inherited from + +```ts +WithRequired.initialData +``` + +*** + +### initialDataUpdatedAt? + +```ts +optional initialDataUpdatedAt: number | () => number | undefined; +``` + +Defined in: [packages/query-core/src/types.ts:321](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L321) + +If set, this value will be used as the time (in milliseconds) of when the `initialData` itself was last updated. + +#### Inherited from + +```ts +WithRequired.initialDataUpdatedAt +``` + +*** + +### maxPages? + +```ts +optional maxPages: number; +``` + +Defined in: [packages/query-core/src/types.ts:345](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L345) + +Maximum number of pages to store in the data of an infinite query. + +#### Inherited from + +```ts +WithRequired.maxPages +``` + +*** + +### meta? + +```ts +optional meta: Record; +``` + +Defined in: [packages/query-core/src/types.ts:341](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L341) + +Additional payload to be stored on each query. +Use this property to pass information that can be used in other places. + +#### Inherited from + +```ts +WithRequired.meta +``` + +*** + +### networkMode? + +```ts +optional networkMode: NetworkMode; +``` + +Defined in: [packages/query-core/src/types.ts:265](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L265) + +Controls whether a query is allowed to run based on the current network connectivity. + +Defaults to `'online'`. + +#### See + +[Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. + +#### Inherited from + +```ts +WithRequired.networkMode +``` + +*** + +### notifyOnChangeProps? + +```ts +optional notifyOnChangeProps: NotifyOnChangeProps; +``` + +Defined in: [packages/query-core/src/types.ts:484](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L484) + +If set, the component will only re-render if any of the listed properties change. +When set to `['data', 'error']`, the component will only re-render when the `data` or `error` properties change. +When set to `'all'`, the component will re-render whenever a query is updated. +When set to a function, the function will be executed to compute the list of properties. + +Defaults to `undefined`, in which case property access is tracked automatically, and the +component only re-renders when one of the tracked properties changes. + +*** + +### persister? + +```ts +optional persister: QueryPersister, TPageParam>; +``` + +Defined in: [packages/query-core/src/types.ts:290](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L290) + +This option can be used to persist the result of a query to an external storage, bypassing the need to actually +call the `queryFn`. Useful for persisting a query's data across e.g. server/client boundaries. + +#### Inherited from + +```ts +WithRequired.persister +``` + +*** + +### placeholderData? + +```ts +optional placeholderData: + | NonFunctionGuard +| PlaceholderDataFunction, TError, NonFunctionGuard, TQueryKey>; +``` + +Defined in: [packages/query-core/src/types.ts:511](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L511) + +If set, this value will be used as the placeholder data for this particular query observer while the query is still in the `loading` data and no initialData has been provided. + +*** + +### queryFn? + +```ts +optional queryFn: + | typeof skipToken +| QueryFunction; +``` + +Defined in: [packages/query-core/src/types.ts:285](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L285) + +The function that the query will use to request data. +Required, unless a default query function has been set via `queryClient.setQueryDefaults` or +`queryClient.setDefaultOptions`. +Receives a [QueryFunctionContext](../type-aliases/QueryFunctionContext.md). +Must return a promise that will either resolve data or throw an error. The data cannot be `undefined`. + +#### Inherited from + +```ts +WithRequired.queryFn +``` + +*** + +### queryHash? + +```ts +optional queryHash: string; +``` + +Defined in: [packages/query-core/src/types.ts:295](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L295) + +The hashed form of `queryKey`, computed with `queryKeyHashFn` (or the default hashing function otherwise). Used +as the actual cache key internally. + +#### Inherited from + +```ts +WithRequired.queryHash +``` + +*** + +### queryKey + +```ts +queryKey: TQueryKey & object; +``` + +Defined in: [packages/query-core/src/types.ts:304](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L304) + +The query key to use for this query. + +The query key will be hashed into a stable hash. See [Query Keys](https://tanstack.com/query/latest/docs/framework/react/guides/query-keys) +for more information. + +The query will automatically update when this key changes (as long as `enabled` is not set to `false`). + +#### Inherited from + +```ts +WithRequired.queryKey +``` + +*** + +### queryKeyHashFn? + +```ts +optional queryKeyHashFn: QueryKeyHashFunction; +``` + +Defined in: [packages/query-core/src/types.ts:308](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L308) + +If specified, this function is used to hash the `queryKey` to a string. + +#### Inherited from + +```ts +WithRequired.queryKeyHashFn +``` + +*** + +### refetchInterval? + +```ts +optional refetchInterval: number | false | (query) => number | false | undefined; +``` + +Defined in: [packages/query-core/src/types.ts:414](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L414) + +If set to a number, the query will continuously refetch at this frequency in milliseconds. +If set to a function, the function will be executed with the latest data and query to compute a frequency + +Defaults to `false`. + +*** + +### refetchIntervalInBackground? + +```ts +optional refetchIntervalInBackground: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:425](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L425) + +If set to `true`, the query will continue to refetch while their tab/window is in the background. + +Defaults to `false`. + +*** + +### refetchOnMount? + +```ts +optional refetchOnMount: boolean | "always" | (query) => boolean | "always"; +``` + +Defined in: [packages/query-core/src/types.ts:462](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L462) + +If set to `true`, the query will refetch on mount if the data is stale. +If set to `false`, will disable additional instances of a query to trigger background refetch. +If set to `'always'`, the query will always refetch on mount (except when `staleTime: 'static'` is used). +If set to a function, the function will be executed with the latest data and query to compute the value + +Defaults to `true`. + +*** + +### refetchOnReconnect? + +```ts +optional refetchOnReconnect: boolean | "always" | (query) => boolean | "always"; +``` + +Defined in: [packages/query-core/src/types.ts:448](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L448) + +If set to `true`, the query will refetch on reconnect if the data is stale. +If set to `false`, the query will not refetch on reconnect. +If set to `'always'`, the query will always refetch on reconnect (except when `staleTime: 'static'` is used). +If set to a function, the function will be executed with the latest data and query to compute the value. + +Defaults to `true` unless `networkMode` is `'always'`. + +*** + +### refetchOnWindowFocus? + +```ts +optional refetchOnWindowFocus: boolean | "always" | (query) => boolean | "always"; +``` + +Defined in: [packages/query-core/src/types.ts:434](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L434) + +If set to `true`, the query will refetch on window focus if the data is stale. +If set to `false`, the query will not refetch on window focus. +If set to `'always'`, the query will always refetch on window focus (except when `staleTime: 'static'` is used). +If set to a function, the function will be executed with the latest data and query to compute the value. + +Defaults to `true`. + +*** + +### retry? + +```ts +optional retry: RetryValue; +``` + +Defined in: [packages/query-core/src/types.ts:246](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L246) + +If `false`, failed queries will not retry by default. +If `true`, failed queries will retry infinitely. +If set to an integer number, e.g. 3, failed queries will retry until the failed query count meets that number. +If set to a function `(failureCount, error) => boolean` failed queries will retry until the function returns false. + +Defaults to `3` on the client and `0` on the server. + +#### Inherited from + +```ts +WithRequired.retry +``` + +*** + +### retryDelay? + +```ts +optional retryDelay: RetryDelayValue; +``` + +Defined in: [packages/query-core/src/types.ts:258](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L258) + +This function receives a `retryAttempt` integer and the actual Error and returns the delay to apply before the +next attempt in milliseconds. + +A function like `attempt => Math.min(attempt > 1 ? 2 ** attempt * 1000 : 1000, 30 * 1000)` applies exponential +backoff. + +A function like `attempt => attempt * 1000` applies linear backoff. + +Defaults to a function that applies exponential backoff, capped at 30 seconds. + +#### Inherited from + +```ts +WithRequired.retryDelay +``` + +*** + +### retryOnMount? + +```ts +optional retryOnMount: QueryBooleanOption; +``` + +Defined in: [packages/query-core/src/types.ts:474](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L474) + +If set to `false`, the query will not be retried on mount if it contains an error. +If set to a function, the function will be executed with the query to compute the value. + +Defaults to `true`. + +*** + +### select()? + +```ts +optional select: (data) => TData; +``` + +Defined in: [packages/query-core/src/types.ts:500](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L500) + +This option can be used to transform or select a part of the data returned by the query function. It affects +the returned `data` value, but does not affect what gets stored in the query cache. +The `select` function will only run if `data` changed, or if the reference to the `select` function itself +changes. To optimize, memoize the function so its reference stays stable across calls. + +#### Parameters + +##### data + +`TQueryData` + +#### Returns + +`TData` + +*** + +### staleTime? + +```ts +optional staleTime: StaleTimeFunction; +``` + +Defined in: [packages/query-core/src/types.ts:407](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L407) + +The time in milliseconds after data is considered stale. +If set to `Infinity`, the data will never be considered stale. +If set to `'static'`, the data will never be considered stale. +If set to a function, the function will be executed with the query to compute a `staleTime`. + +Defaults to `0`. + +*** + +### structuralSharing? + +```ts +optional structuralSharing: boolean | (oldData, newData) => unknown; +``` + +Defined in: [packages/query-core/src/types.ts:330](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L330) + +Set this to `false` to disable structural sharing between query results. +Set this to a function which accepts the old and new data and returns resolved data of the same type to implement custom structural sharing logic. + +Defaults to `true`. + +#### Inherited from + +```ts +WithRequired.structuralSharing +``` + +*** + +### suspense? + +```ts +optional suspense: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:507](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L507) + +If set to `true`, the query will suspend when `status === 'pending'` +and throw errors when `status === 'error'`. + +Defaults to `false`. + +*** + +### throwOnError? + +```ts +optional throwOnError: ThrowOnError; +``` + +Defined in: [packages/query-core/src/types.ts:493](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L493) + +Whether errors should be thrown instead of setting the `error` property. +If set to `true` or `suspense` is `true`, all errors will be thrown to the error boundary. +If set to `false` and `suspense` is `false`, errors are returned as state. +If set to a function, it will be passed the error and the query, and it should return a boolean indicating whether to show the error in an error boundary (`true`) or return the error as state (`false`). + +Defaults to `false`. diff --git a/docs/framework/vue/reference/interfaces/QueryObserverPendingResult.md b/docs/framework/vue/reference/interfaces/QueryObserverPendingResult.md new file mode 100644 index 00000000000..8f00c426b64 --- /dev/null +++ b/docs/framework/vue/reference/interfaces/QueryObserverPendingResult.md @@ -0,0 +1,452 @@ +--- +id: QueryObserverPendingResult +title: QueryObserverPendingResult +--- + +Defined in: [packages/query-core/src/types.ts:892](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L892) + +## Extends + +- [`QueryObserverBaseResult`](QueryObserverBaseResult.md)\<`TData`, `TError`\> + +## Type Parameters + +### TData + +`TData` = `unknown` + +### TError + +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) + +## Properties + +### data + +```ts +data: undefined; +``` + +Defined in: [packages/query-core/src/types.ts:896](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L896) + +The last successfully resolved data for the query. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`data`](QueryObserverBaseResult.md#data) + +*** + +### dataUpdatedAt + +```ts +dataUpdatedAt: number; +``` + +Defined in: [packages/query-core/src/types.ts:775](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L775) + +The timestamp for when the query most recently returned the `status` as `"success"`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`dataUpdatedAt`](QueryObserverBaseResult.md#dataupdatedat) + +*** + +### error + +```ts +error: null; +``` + +Defined in: [packages/query-core/src/types.ts:897](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L897) + +The error object for the query, if an error was thrown. +- Defaults to `null`. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`error`](QueryObserverBaseResult.md#error) + +*** + +### errorUpdateCount + +```ts +errorUpdateCount: number; +``` + +Defined in: [packages/query-core/src/types.ts:799](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L799) + +The sum of all errors. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`errorUpdateCount`](QueryObserverBaseResult.md#errorupdatecount) + +*** + +### errorUpdatedAt + +```ts +errorUpdatedAt: number; +``` + +Defined in: [packages/query-core/src/types.ts:784](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L784) + +The timestamp for when the query most recently returned the `status` as `"error"`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`errorUpdatedAt`](QueryObserverBaseResult.md#errorupdatedat) + +*** + +### failureCount + +```ts +failureCount: number; +``` + +Defined in: [packages/query-core/src/types.ts:790](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L790) + +The failure count for the query. +- Incremented every time the query fails. +- Reset to `0` when the query succeeds. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`failureCount`](QueryObserverBaseResult.md#failurecount) + +*** + +### failureReason + +```ts +failureReason: TError | null; +``` + +Defined in: [packages/query-core/src/types.ts:795](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L795) + +The failure reason for the query retry. +- Reset to `null` when the query succeeds. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`failureReason`](QueryObserverBaseResult.md#failurereason) + +*** + +### fetchStatus + +```ts +fetchStatus: FetchStatus; +``` + +Defined in: [packages/query-core/src/types.ts:889](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L889) + +The fetch status of the query. +- `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. +- `paused`: The query wanted to fetch, but has been `paused`. +- `idle`: The query is not fetching. +- See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`fetchStatus`](QueryObserverBaseResult.md#fetchstatus) + +*** + +### isEnabled + +```ts +isEnabled: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:867](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L867) + +`true` if this observer is enabled, `false` otherwise. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isEnabled`](QueryObserverBaseResult.md#isenabled) + +*** + +### isError + +```ts +isError: false; +``` + +Defined in: [packages/query-core/src/types.ts:898](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L898) + +A derived boolean from the `status` variable, provided for convenience. +- `true` if the query attempt resulted in an error. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isError`](QueryObserverBaseResult.md#iserror) + +*** + +### isFetched + +```ts +isFetched: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:808](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L808) + +Will be `true` if the query has been fetched. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isFetched`](QueryObserverBaseResult.md#isfetched) + +*** + +### isFetchedAfterMount + +```ts +isFetchedAfterMount: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:813](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L813) + +Will be `true` if the query has been fetched after the component mounted. +- This property can be used to not show any previously cached data. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isFetchedAfterMount`](QueryObserverBaseResult.md#isfetchedaftermount) + +*** + +### isFetching + +```ts +isFetching: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:818](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L818) + +A derived boolean from the `fetchStatus` variable, provided for convenience. +- `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isFetching`](QueryObserverBaseResult.md#isfetching) + +*** + +### ~~isInitialLoading~~ + +```ts +isInitialLoading: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:836](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L836) + +#### Deprecated + +`isInitialLoading` is being deprecated in favor of `isLoading` +and will be removed in the next major version. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isInitialLoading`](QueryObserverBaseResult.md#isinitialloading) + +*** + +### isLoading + +```ts +isLoading: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:823](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L823) + +Is `true` whenever the first fetch for a query is in-flight. +- Is the same as `isFetching && isPending`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoading`](QueryObserverBaseResult.md#isloading) + +*** + +### isLoadingError + +```ts +isLoadingError: false; +``` + +Defined in: [packages/query-core/src/types.ts:900](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L900) + +Will be `true` if the query failed while fetching for the first time. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoadingError`](QueryObserverBaseResult.md#isloadingerror) + +*** + +### isPaused + +```ts +isPaused: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:841](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L841) + +A derived boolean from the `fetchStatus` variable, provided for convenience. +- The query wanted to fetch, but has been `paused`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPaused`](QueryObserverBaseResult.md#ispaused) + +*** + +### isPending + +```ts +isPending: true; +``` + +Defined in: [packages/query-core/src/types.ts:899](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L899) + +Will be `pending` if there's no cached data and no query attempt was finished yet. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPending`](QueryObserverBaseResult.md#ispending) + +*** + +### isPlaceholderData + +```ts +isPlaceholderData: false; +``` + +Defined in: [packages/query-core/src/types.ts:903](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L903) + +Will be `true` if the data shown is the placeholder data. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPlaceholderData`](QueryObserverBaseResult.md#isplaceholderdata) + +*** + +### isRefetchError + +```ts +isRefetchError: false; +``` + +Defined in: [packages/query-core/src/types.ts:901](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L901) + +Will be `true` if the query failed while refetching. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetchError`](QueryObserverBaseResult.md#isrefetcherror) + +*** + +### isRefetching + +```ts +isRefetching: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:854](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L854) + +Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. +- Is the same as `isFetching && !isPending`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetching`](QueryObserverBaseResult.md#isrefetching) + +*** + +### isStale + +```ts +isStale: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:858](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L858) + +Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isStale`](QueryObserverBaseResult.md#isstale) + +*** + +### isSuccess + +```ts +isSuccess: false; +``` + +Defined in: [packages/query-core/src/types.ts:902](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L902) + +A derived boolean from the `status` variable, provided for convenience. +- `true` if the query has received a response with no errors and is ready to display its data. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isSuccess`](QueryObserverBaseResult.md#issuccess) + +*** + +### refetch() + +```ts +refetch: (options?) => Promise>; +``` + +Defined in: [packages/query-core/src/types.ts:871](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L871) + +A function to manually refetch the query. + +#### Parameters + +##### options? + +[`RefetchOptions`](RefetchOptions.md) + +#### Returns + +`Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`refetch`](QueryObserverBaseResult.md#refetch) + +*** + +### status + +```ts +status: "pending"; +``` + +Defined in: [packages/query-core/src/types.ts:904](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L904) + +The status of the query. +- Will be: + - `pending` if there's no cached data and no query attempt was finished yet. + - `error` if the query attempt resulted in an error. + - `success` if the query has received a response with no errors and is ready to display its data. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`status`](QueryObserverBaseResult.md#status) diff --git a/docs/framework/vue/reference/interfaces/QueryObserverPlaceholderResult.md b/docs/framework/vue/reference/interfaces/QueryObserverPlaceholderResult.md new file mode 100644 index 00000000000..bbf3da387f9 --- /dev/null +++ b/docs/framework/vue/reference/interfaces/QueryObserverPlaceholderResult.md @@ -0,0 +1,452 @@ +--- +id: QueryObserverPlaceholderResult +title: QueryObserverPlaceholderResult +--- + +Defined in: [packages/query-core/src/types.ts:971](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L971) + +## Extends + +- [`QueryObserverBaseResult`](QueryObserverBaseResult.md)\<`TData`, `TError`\> + +## Type Parameters + +### TData + +`TData` = `unknown` + +### TError + +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) + +## Properties + +### data + +```ts +data: TData; +``` + +Defined in: [packages/query-core/src/types.ts:975](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L975) + +The last successfully resolved data for the query. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`data`](QueryObserverBaseResult.md#data) + +*** + +### dataUpdatedAt + +```ts +dataUpdatedAt: number; +``` + +Defined in: [packages/query-core/src/types.ts:775](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L775) + +The timestamp for when the query most recently returned the `status` as `"success"`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`dataUpdatedAt`](QueryObserverBaseResult.md#dataupdatedat) + +*** + +### error + +```ts +error: null; +``` + +Defined in: [packages/query-core/src/types.ts:977](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L977) + +The error object for the query, if an error was thrown. +- Defaults to `null`. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`error`](QueryObserverBaseResult.md#error) + +*** + +### errorUpdateCount + +```ts +errorUpdateCount: number; +``` + +Defined in: [packages/query-core/src/types.ts:799](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L799) + +The sum of all errors. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`errorUpdateCount`](QueryObserverBaseResult.md#errorupdatecount) + +*** + +### errorUpdatedAt + +```ts +errorUpdatedAt: number; +``` + +Defined in: [packages/query-core/src/types.ts:784](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L784) + +The timestamp for when the query most recently returned the `status` as `"error"`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`errorUpdatedAt`](QueryObserverBaseResult.md#errorupdatedat) + +*** + +### failureCount + +```ts +failureCount: number; +``` + +Defined in: [packages/query-core/src/types.ts:790](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L790) + +The failure count for the query. +- Incremented every time the query fails. +- Reset to `0` when the query succeeds. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`failureCount`](QueryObserverBaseResult.md#failurecount) + +*** + +### failureReason + +```ts +failureReason: TError | null; +``` + +Defined in: [packages/query-core/src/types.ts:795](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L795) + +The failure reason for the query retry. +- Reset to `null` when the query succeeds. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`failureReason`](QueryObserverBaseResult.md#failurereason) + +*** + +### fetchStatus + +```ts +fetchStatus: FetchStatus; +``` + +Defined in: [packages/query-core/src/types.ts:889](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L889) + +The fetch status of the query. +- `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. +- `paused`: The query wanted to fetch, but has been `paused`. +- `idle`: The query is not fetching. +- See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`fetchStatus`](QueryObserverBaseResult.md#fetchstatus) + +*** + +### isEnabled + +```ts +isEnabled: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:867](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L867) + +`true` if this observer is enabled, `false` otherwise. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isEnabled`](QueryObserverBaseResult.md#isenabled) + +*** + +### isError + +```ts +isError: false; +``` + +Defined in: [packages/query-core/src/types.ts:976](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L976) + +A derived boolean from the `status` variable, provided for convenience. +- `true` if the query attempt resulted in an error. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isError`](QueryObserverBaseResult.md#iserror) + +*** + +### isFetched + +```ts +isFetched: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:808](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L808) + +Will be `true` if the query has been fetched. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isFetched`](QueryObserverBaseResult.md#isfetched) + +*** + +### isFetchedAfterMount + +```ts +isFetchedAfterMount: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:813](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L813) + +Will be `true` if the query has been fetched after the component mounted. +- This property can be used to not show any previously cached data. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isFetchedAfterMount`](QueryObserverBaseResult.md#isfetchedaftermount) + +*** + +### isFetching + +```ts +isFetching: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:818](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L818) + +A derived boolean from the `fetchStatus` variable, provided for convenience. +- `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isFetching`](QueryObserverBaseResult.md#isfetching) + +*** + +### ~~isInitialLoading~~ + +```ts +isInitialLoading: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:836](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L836) + +#### Deprecated + +`isInitialLoading` is being deprecated in favor of `isLoading` +and will be removed in the next major version. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isInitialLoading`](QueryObserverBaseResult.md#isinitialloading) + +*** + +### isLoading + +```ts +isLoading: false; +``` + +Defined in: [packages/query-core/src/types.ts:979](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L979) + +Is `true` whenever the first fetch for a query is in-flight. +- Is the same as `isFetching && isPending`. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoading`](QueryObserverBaseResult.md#isloading) + +*** + +### isLoadingError + +```ts +isLoadingError: false; +``` + +Defined in: [packages/query-core/src/types.ts:980](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L980) + +Will be `true` if the query failed while fetching for the first time. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoadingError`](QueryObserverBaseResult.md#isloadingerror) + +*** + +### isPaused + +```ts +isPaused: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:841](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L841) + +A derived boolean from the `fetchStatus` variable, provided for convenience. +- The query wanted to fetch, but has been `paused`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPaused`](QueryObserverBaseResult.md#ispaused) + +*** + +### isPending + +```ts +isPending: false; +``` + +Defined in: [packages/query-core/src/types.ts:978](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L978) + +Will be `pending` if there's no cached data and no query attempt was finished yet. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPending`](QueryObserverBaseResult.md#ispending) + +*** + +### isPlaceholderData + +```ts +isPlaceholderData: true; +``` + +Defined in: [packages/query-core/src/types.ts:983](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L983) + +Will be `true` if the data shown is the placeholder data. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPlaceholderData`](QueryObserverBaseResult.md#isplaceholderdata) + +*** + +### isRefetchError + +```ts +isRefetchError: false; +``` + +Defined in: [packages/query-core/src/types.ts:981](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L981) + +Will be `true` if the query failed while refetching. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetchError`](QueryObserverBaseResult.md#isrefetcherror) + +*** + +### isRefetching + +```ts +isRefetching: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:854](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L854) + +Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. +- Is the same as `isFetching && !isPending`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetching`](QueryObserverBaseResult.md#isrefetching) + +*** + +### isStale + +```ts +isStale: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:858](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L858) + +Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isStale`](QueryObserverBaseResult.md#isstale) + +*** + +### isSuccess + +```ts +isSuccess: true; +``` + +Defined in: [packages/query-core/src/types.ts:982](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L982) + +A derived boolean from the `status` variable, provided for convenience. +- `true` if the query has received a response with no errors and is ready to display its data. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isSuccess`](QueryObserverBaseResult.md#issuccess) + +*** + +### refetch() + +```ts +refetch: (options?) => Promise>; +``` + +Defined in: [packages/query-core/src/types.ts:871](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L871) + +A function to manually refetch the query. + +#### Parameters + +##### options? + +[`RefetchOptions`](RefetchOptions.md) + +#### Returns + +`Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`refetch`](QueryObserverBaseResult.md#refetch) + +*** + +### status + +```ts +status: "success"; +``` + +Defined in: [packages/query-core/src/types.ts:984](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L984) + +The status of the query. +- Will be: + - `pending` if there's no cached data and no query attempt was finished yet. + - `error` if the query attempt resulted in an error. + - `success` if the query has received a response with no errors and is ready to display its data. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`status`](QueryObserverBaseResult.md#status) diff --git a/docs/framework/vue/reference/interfaces/QueryObserverRefetchErrorResult.md b/docs/framework/vue/reference/interfaces/QueryObserverRefetchErrorResult.md new file mode 100644 index 00000000000..345ecab35e1 --- /dev/null +++ b/docs/framework/vue/reference/interfaces/QueryObserverRefetchErrorResult.md @@ -0,0 +1,452 @@ +--- +id: QueryObserverRefetchErrorResult +title: QueryObserverRefetchErrorResult +--- + +Defined in: [packages/query-core/src/types.ts:939](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L939) + +## Extends + +- [`QueryObserverBaseResult`](QueryObserverBaseResult.md)\<`TData`, `TError`\> + +## Type Parameters + +### TData + +`TData` = `unknown` + +### TError + +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) + +## Properties + +### data + +```ts +data: TData; +``` + +Defined in: [packages/query-core/src/types.ts:943](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L943) + +The last successfully resolved data for the query. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`data`](QueryObserverBaseResult.md#data) + +*** + +### dataUpdatedAt + +```ts +dataUpdatedAt: number; +``` + +Defined in: [packages/query-core/src/types.ts:775](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L775) + +The timestamp for when the query most recently returned the `status` as `"success"`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`dataUpdatedAt`](QueryObserverBaseResult.md#dataupdatedat) + +*** + +### error + +```ts +error: TError; +``` + +Defined in: [packages/query-core/src/types.ts:944](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L944) + +The error object for the query, if an error was thrown. +- Defaults to `null`. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`error`](QueryObserverBaseResult.md#error) + +*** + +### errorUpdateCount + +```ts +errorUpdateCount: number; +``` + +Defined in: [packages/query-core/src/types.ts:799](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L799) + +The sum of all errors. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`errorUpdateCount`](QueryObserverBaseResult.md#errorupdatecount) + +*** + +### errorUpdatedAt + +```ts +errorUpdatedAt: number; +``` + +Defined in: [packages/query-core/src/types.ts:784](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L784) + +The timestamp for when the query most recently returned the `status` as `"error"`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`errorUpdatedAt`](QueryObserverBaseResult.md#errorupdatedat) + +*** + +### failureCount + +```ts +failureCount: number; +``` + +Defined in: [packages/query-core/src/types.ts:790](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L790) + +The failure count for the query. +- Incremented every time the query fails. +- Reset to `0` when the query succeeds. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`failureCount`](QueryObserverBaseResult.md#failurecount) + +*** + +### failureReason + +```ts +failureReason: TError | null; +``` + +Defined in: [packages/query-core/src/types.ts:795](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L795) + +The failure reason for the query retry. +- Reset to `null` when the query succeeds. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`failureReason`](QueryObserverBaseResult.md#failurereason) + +*** + +### fetchStatus + +```ts +fetchStatus: FetchStatus; +``` + +Defined in: [packages/query-core/src/types.ts:889](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L889) + +The fetch status of the query. +- `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. +- `paused`: The query wanted to fetch, but has been `paused`. +- `idle`: The query is not fetching. +- See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`fetchStatus`](QueryObserverBaseResult.md#fetchstatus) + +*** + +### isEnabled + +```ts +isEnabled: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:867](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L867) + +`true` if this observer is enabled, `false` otherwise. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isEnabled`](QueryObserverBaseResult.md#isenabled) + +*** + +### isError + +```ts +isError: true; +``` + +Defined in: [packages/query-core/src/types.ts:945](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L945) + +A derived boolean from the `status` variable, provided for convenience. +- `true` if the query attempt resulted in an error. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isError`](QueryObserverBaseResult.md#iserror) + +*** + +### isFetched + +```ts +isFetched: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:808](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L808) + +Will be `true` if the query has been fetched. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isFetched`](QueryObserverBaseResult.md#isfetched) + +*** + +### isFetchedAfterMount + +```ts +isFetchedAfterMount: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:813](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L813) + +Will be `true` if the query has been fetched after the component mounted. +- This property can be used to not show any previously cached data. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isFetchedAfterMount`](QueryObserverBaseResult.md#isfetchedaftermount) + +*** + +### isFetching + +```ts +isFetching: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:818](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L818) + +A derived boolean from the `fetchStatus` variable, provided for convenience. +- `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isFetching`](QueryObserverBaseResult.md#isfetching) + +*** + +### ~~isInitialLoading~~ + +```ts +isInitialLoading: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:836](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L836) + +#### Deprecated + +`isInitialLoading` is being deprecated in favor of `isLoading` +and will be removed in the next major version. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isInitialLoading`](QueryObserverBaseResult.md#isinitialloading) + +*** + +### isLoading + +```ts +isLoading: false; +``` + +Defined in: [packages/query-core/src/types.ts:947](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L947) + +Is `true` whenever the first fetch for a query is in-flight. +- Is the same as `isFetching && isPending`. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoading`](QueryObserverBaseResult.md#isloading) + +*** + +### isLoadingError + +```ts +isLoadingError: false; +``` + +Defined in: [packages/query-core/src/types.ts:948](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L948) + +Will be `true` if the query failed while fetching for the first time. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoadingError`](QueryObserverBaseResult.md#isloadingerror) + +*** + +### isPaused + +```ts +isPaused: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:841](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L841) + +A derived boolean from the `fetchStatus` variable, provided for convenience. +- The query wanted to fetch, but has been `paused`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPaused`](QueryObserverBaseResult.md#ispaused) + +*** + +### isPending + +```ts +isPending: false; +``` + +Defined in: [packages/query-core/src/types.ts:946](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L946) + +Will be `pending` if there's no cached data and no query attempt was finished yet. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPending`](QueryObserverBaseResult.md#ispending) + +*** + +### isPlaceholderData + +```ts +isPlaceholderData: false; +``` + +Defined in: [packages/query-core/src/types.ts:951](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L951) + +Will be `true` if the data shown is the placeholder data. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPlaceholderData`](QueryObserverBaseResult.md#isplaceholderdata) + +*** + +### isRefetchError + +```ts +isRefetchError: true; +``` + +Defined in: [packages/query-core/src/types.ts:949](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L949) + +Will be `true` if the query failed while refetching. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetchError`](QueryObserverBaseResult.md#isrefetcherror) + +*** + +### isRefetching + +```ts +isRefetching: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:854](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L854) + +Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. +- Is the same as `isFetching && !isPending`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetching`](QueryObserverBaseResult.md#isrefetching) + +*** + +### isStale + +```ts +isStale: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:858](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L858) + +Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isStale`](QueryObserverBaseResult.md#isstale) + +*** + +### isSuccess + +```ts +isSuccess: false; +``` + +Defined in: [packages/query-core/src/types.ts:950](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L950) + +A derived boolean from the `status` variable, provided for convenience. +- `true` if the query has received a response with no errors and is ready to display its data. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isSuccess`](QueryObserverBaseResult.md#issuccess) + +*** + +### refetch() + +```ts +refetch: (options?) => Promise>; +``` + +Defined in: [packages/query-core/src/types.ts:871](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L871) + +A function to manually refetch the query. + +#### Parameters + +##### options? + +[`RefetchOptions`](RefetchOptions.md) + +#### Returns + +`Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`refetch`](QueryObserverBaseResult.md#refetch) + +*** + +### status + +```ts +status: "error"; +``` + +Defined in: [packages/query-core/src/types.ts:952](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L952) + +The status of the query. +- Will be: + - `pending` if there's no cached data and no query attempt was finished yet. + - `error` if the query attempt resulted in an error. + - `success` if the query has received a response with no errors and is ready to display its data. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`status`](QueryObserverBaseResult.md#status) diff --git a/docs/framework/vue/reference/interfaces/QueryObserverSuccessResult.md b/docs/framework/vue/reference/interfaces/QueryObserverSuccessResult.md new file mode 100644 index 00000000000..3942655c627 --- /dev/null +++ b/docs/framework/vue/reference/interfaces/QueryObserverSuccessResult.md @@ -0,0 +1,452 @@ +--- +id: QueryObserverSuccessResult +title: QueryObserverSuccessResult +--- + +Defined in: [packages/query-core/src/types.ts:955](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L955) + +## Extends + +- [`QueryObserverBaseResult`](QueryObserverBaseResult.md)\<`TData`, `TError`\> + +## Type Parameters + +### TData + +`TData` = `unknown` + +### TError + +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) + +## Properties + +### data + +```ts +data: TData; +``` + +Defined in: [packages/query-core/src/types.ts:959](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L959) + +The last successfully resolved data for the query. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`data`](QueryObserverBaseResult.md#data) + +*** + +### dataUpdatedAt + +```ts +dataUpdatedAt: number; +``` + +Defined in: [packages/query-core/src/types.ts:775](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L775) + +The timestamp for when the query most recently returned the `status` as `"success"`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`dataUpdatedAt`](QueryObserverBaseResult.md#dataupdatedat) + +*** + +### error + +```ts +error: null; +``` + +Defined in: [packages/query-core/src/types.ts:960](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L960) + +The error object for the query, if an error was thrown. +- Defaults to `null`. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`error`](QueryObserverBaseResult.md#error) + +*** + +### errorUpdateCount + +```ts +errorUpdateCount: number; +``` + +Defined in: [packages/query-core/src/types.ts:799](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L799) + +The sum of all errors. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`errorUpdateCount`](QueryObserverBaseResult.md#errorupdatecount) + +*** + +### errorUpdatedAt + +```ts +errorUpdatedAt: number; +``` + +Defined in: [packages/query-core/src/types.ts:784](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L784) + +The timestamp for when the query most recently returned the `status` as `"error"`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`errorUpdatedAt`](QueryObserverBaseResult.md#errorupdatedat) + +*** + +### failureCount + +```ts +failureCount: number; +``` + +Defined in: [packages/query-core/src/types.ts:790](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L790) + +The failure count for the query. +- Incremented every time the query fails. +- Reset to `0` when the query succeeds. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`failureCount`](QueryObserverBaseResult.md#failurecount) + +*** + +### failureReason + +```ts +failureReason: TError | null; +``` + +Defined in: [packages/query-core/src/types.ts:795](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L795) + +The failure reason for the query retry. +- Reset to `null` when the query succeeds. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`failureReason`](QueryObserverBaseResult.md#failurereason) + +*** + +### fetchStatus + +```ts +fetchStatus: FetchStatus; +``` + +Defined in: [packages/query-core/src/types.ts:889](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L889) + +The fetch status of the query. +- `fetching`: Is `true` whenever the queryFn is executing, which includes initial `pending` as well as background refetch. +- `paused`: The query wanted to fetch, but has been `paused`. +- `idle`: The query is not fetching. +- See [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`fetchStatus`](QueryObserverBaseResult.md#fetchstatus) + +*** + +### isEnabled + +```ts +isEnabled: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:867](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L867) + +`true` if this observer is enabled, `false` otherwise. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isEnabled`](QueryObserverBaseResult.md#isenabled) + +*** + +### isError + +```ts +isError: false; +``` + +Defined in: [packages/query-core/src/types.ts:961](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L961) + +A derived boolean from the `status` variable, provided for convenience. +- `true` if the query attempt resulted in an error. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isError`](QueryObserverBaseResult.md#iserror) + +*** + +### isFetched + +```ts +isFetched: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:808](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L808) + +Will be `true` if the query has been fetched. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isFetched`](QueryObserverBaseResult.md#isfetched) + +*** + +### isFetchedAfterMount + +```ts +isFetchedAfterMount: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:813](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L813) + +Will be `true` if the query has been fetched after the component mounted. +- This property can be used to not show any previously cached data. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isFetchedAfterMount`](QueryObserverBaseResult.md#isfetchedaftermount) + +*** + +### isFetching + +```ts +isFetching: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:818](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L818) + +A derived boolean from the `fetchStatus` variable, provided for convenience. +- `true` whenever the `queryFn` is executing, which includes initial `pending` as well as background refetch. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isFetching`](QueryObserverBaseResult.md#isfetching) + +*** + +### ~~isInitialLoading~~ + +```ts +isInitialLoading: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:836](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L836) + +#### Deprecated + +`isInitialLoading` is being deprecated in favor of `isLoading` +and will be removed in the next major version. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isInitialLoading`](QueryObserverBaseResult.md#isinitialloading) + +*** + +### isLoading + +```ts +isLoading: false; +``` + +Defined in: [packages/query-core/src/types.ts:963](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L963) + +Is `true` whenever the first fetch for a query is in-flight. +- Is the same as `isFetching && isPending`. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoading`](QueryObserverBaseResult.md#isloading) + +*** + +### isLoadingError + +```ts +isLoadingError: false; +``` + +Defined in: [packages/query-core/src/types.ts:964](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L964) + +Will be `true` if the query failed while fetching for the first time. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isLoadingError`](QueryObserverBaseResult.md#isloadingerror) + +*** + +### isPaused + +```ts +isPaused: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:841](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L841) + +A derived boolean from the `fetchStatus` variable, provided for convenience. +- The query wanted to fetch, but has been `paused`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPaused`](QueryObserverBaseResult.md#ispaused) + +*** + +### isPending + +```ts +isPending: false; +``` + +Defined in: [packages/query-core/src/types.ts:962](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L962) + +Will be `pending` if there's no cached data and no query attempt was finished yet. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPending`](QueryObserverBaseResult.md#ispending) + +*** + +### isPlaceholderData + +```ts +isPlaceholderData: false; +``` + +Defined in: [packages/query-core/src/types.ts:967](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L967) + +Will be `true` if the data shown is the placeholder data. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isPlaceholderData`](QueryObserverBaseResult.md#isplaceholderdata) + +*** + +### isRefetchError + +```ts +isRefetchError: false; +``` + +Defined in: [packages/query-core/src/types.ts:965](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L965) + +Will be `true` if the query failed while refetching. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetchError`](QueryObserverBaseResult.md#isrefetcherror) + +*** + +### isRefetching + +```ts +isRefetching: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:854](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L854) + +Is `true` whenever a background refetch is in-flight, which _does not_ include initial `pending`. +- Is the same as `isFetching && !isPending`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isRefetching`](QueryObserverBaseResult.md#isrefetching) + +*** + +### isStale + +```ts +isStale: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:858](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L858) + +Will be `true` if the data in the cache is invalidated or if the data is older than the given `staleTime`. + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isStale`](QueryObserverBaseResult.md#isstale) + +*** + +### isSuccess + +```ts +isSuccess: true; +``` + +Defined in: [packages/query-core/src/types.ts:966](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L966) + +A derived boolean from the `status` variable, provided for convenience. +- `true` if the query has received a response with no errors and is ready to display its data. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`isSuccess`](QueryObserverBaseResult.md#issuccess) + +*** + +### refetch() + +```ts +refetch: (options?) => Promise>; +``` + +Defined in: [packages/query-core/src/types.ts:871](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L871) + +A function to manually refetch the query. + +#### Parameters + +##### options? + +[`RefetchOptions`](RefetchOptions.md) + +#### Returns + +`Promise`\<[`QueryObserverResult`](../type-aliases/QueryObserverResult.md)\<`TData`, `TError`\>\> + +#### Inherited from + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`refetch`](QueryObserverBaseResult.md#refetch) + +*** + +### status + +```ts +status: "success"; +``` + +Defined in: [packages/query-core/src/types.ts:968](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L968) + +The status of the query. +- Will be: + - `pending` if there's no cached data and no query attempt was finished yet. + - `error` if the query attempt resulted in an error. + - `success` if the query has received a response with no errors and is ready to display its data. + +#### Overrides + +[`QueryObserverBaseResult`](QueryObserverBaseResult.md).[`status`](QueryObserverBaseResult.md#status) diff --git a/docs/framework/vue/reference/interfaces/QueryState.md b/docs/framework/vue/reference/interfaces/QueryState.md new file mode 100644 index 00000000000..7dce476d743 --- /dev/null +++ b/docs/framework/vue/reference/interfaces/QueryState.md @@ -0,0 +1,175 @@ +--- +id: QueryState +title: QueryState +--- + +Defined in: [packages/query-core/src/query.ts:52](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L52) + +The raw state stored on a `Query` instance. This is the underlying state +that observer results (e.g. `QueryObserverResult`) are derived from. + +## Type Parameters + +### TData + +`TData` = `unknown` + +### TError + +`TError` = [`DefaultError`](../type-aliases/DefaultError.md) + +## Properties + +### data + +```ts +data: TData | undefined; +``` + +Defined in: [packages/query-core/src/query.ts:56](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L56) + +The last successfully resolved data for the query. + +*** + +### dataUpdateCount + +```ts +dataUpdateCount: number; +``` + +Defined in: [packages/query-core/src/query.ts:60](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L60) + +The number of times the query has successfully resolved. + +*** + +### dataUpdatedAt + +```ts +dataUpdatedAt: number; +``` + +Defined in: [packages/query-core/src/query.ts:64](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L64) + +The timestamp for when the query most recently returned the `status` as `"success"`. + +*** + +### error + +```ts +error: TError | null; +``` + +Defined in: [packages/query-core/src/query.ts:69](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L69) + +The error object for the query, if the last attempt resulted in an error. +- Defaults to `null`. + +*** + +### errorUpdateCount + +```ts +errorUpdateCount: number; +``` + +Defined in: [packages/query-core/src/query.ts:73](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L73) + +The sum of all errors, incremented every time the query resolves with an error. + +*** + +### errorUpdatedAt + +```ts +errorUpdatedAt: number; +``` + +Defined in: [packages/query-core/src/query.ts:77](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L77) + +The timestamp for when the query most recently returned the `status` as `"error"`. + +*** + +### fetchFailureCount + +```ts +fetchFailureCount: number; +``` + +Defined in: [packages/query-core/src/query.ts:83](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L83) + +The failure count for the current fetch. +- Incremented every time the fetch fails. +- Reset to `0` when the fetch succeeds. + +*** + +### fetchFailureReason + +```ts +fetchFailureReason: TError | null; +``` + +Defined in: [packages/query-core/src/query.ts:88](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L88) + +The reason the current fetch failed, as reported by the retryer. +- Reset to `null` when the fetch succeeds. + +*** + +### fetchMeta + +```ts +fetchMeta: FetchMeta | null; +``` + +Defined in: [packages/query-core/src/query.ts:93](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L93) + +Metadata passed to the currently in-flight (or most recent) fetch, e.g. the +`fetchMore` direction for infinite queries. + +*** + +### fetchStatus + +```ts +fetchStatus: FetchStatus; +``` + +Defined in: [packages/query-core/src/query.ts:112](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L112) + +The fetch status of the query. +- `fetching`: the `queryFn` is currently executing. +- `paused`: a fetch wanted to run but has been paused (see network mode). +- `idle`: the query is not fetching. + +*** + +### isInvalidated + +```ts +isInvalidated: boolean; +``` + +Defined in: [packages/query-core/src/query.ts:98](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L98) + +Whether the query has been marked as invalidated via `invalidate()`. +- Reset to `false` whenever the query resolves successfully. + +*** + +### status + +```ts +status: QueryStatus; +``` + +Defined in: [packages/query-core/src/query.ts:105](https://github.com/TanStack/query/blob/main/packages/query-core/src/query.ts#L105) + +The status of the query. +- `pending` if there's no cached data and no attempt was finished yet. +- `error` if the last attempt resulted in an error. +- `success` if the query has data. diff --git a/docs/framework/vue/reference/interfaces/RefetchOptions.md b/docs/framework/vue/reference/interfaces/RefetchOptions.md new file mode 100644 index 00000000000..cfcc0498799 --- /dev/null +++ b/docs/framework/vue/reference/interfaces/RefetchOptions.md @@ -0,0 +1,50 @@ +--- +id: RefetchOptions +title: RefetchOptions +--- + +Defined in: [packages/query-core/src/types.ts:704](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L704) + +## Extends + +- [`ResultOptions`](ResultOptions.md) + +## Extended by + +- [`InvalidateOptions`](InvalidateOptions.md) +- [`ResetOptions`](ResetOptions.md) + +## Properties + +### cancelRefetch? + +```ts +optional cancelRefetch: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:712](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L712) + +If set to `true`, a currently running request will be cancelled before a new request is made + +If set to `false`, no refetch will be made if there is already a request running. + +Defaults to `true`. + +*** + +### throwOnError? + +```ts +optional throwOnError: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:701](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L701) + +If set to `true`, the method throws if any of the underlying query refetch tasks fail. + +Defaults to `false`, in which case failed refetches are swallowed and not surfaced to the +caller. + +#### Inherited from + +[`ResultOptions`](ResultOptions.md).[`throwOnError`](ResultOptions.md#throwonerror) diff --git a/docs/framework/vue/reference/interfaces/RefetchQueryFilters.md b/docs/framework/vue/reference/interfaces/RefetchQueryFilters.md new file mode 100644 index 00000000000..e3fcaae638f --- /dev/null +++ b/docs/framework/vue/reference/interfaces/RefetchQueryFilters.md @@ -0,0 +1,136 @@ +--- +id: RefetchQueryFilters +title: RefetchQueryFilters +--- + +Defined in: [packages/query-core/src/types.ts:730](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L730) + +## Extends + +- `QueryFilters`\<`TQueryKey`\> + +## Type Parameters + +### TQueryKey + +`TQueryKey` *extends* [`QueryKey`](../type-aliases/QueryKey.md) = [`QueryKey`](../type-aliases/QueryKey.md) + +## Properties + +### exact? + +```ts +optional exact: boolean; +``` + +Defined in: [packages/query-core/src/utils.ts:41](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L41) + +Match query key exactly + +#### Inherited from + +```ts +QueryFilters.exact +``` + +*** + +### fetchStatus? + +```ts +optional fetchStatus: FetchStatus; +``` + +Defined in: [packages/query-core/src/utils.ts:57](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L57) + +Include queries matching their fetchStatus + +#### Inherited from + +```ts +QueryFilters.fetchStatus +``` + +*** + +### predicate()? + +```ts +optional predicate: (query) => boolean; +``` + +Defined in: [packages/query-core/src/utils.ts:45](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L45) + +Include queries matching this predicate function + +#### Parameters + +##### query + +[`Query`](../classes/Query.md) + +#### Returns + +`boolean` + +#### Inherited from + +```ts +QueryFilters.predicate +``` + +*** + +### queryKey? + +```ts +optional queryKey: TQueryKey | TuplePrefixes; +``` + +Defined in: [packages/query-core/src/utils.ts:49](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L49) + +Include queries matching this query key + +#### Inherited from + +```ts +QueryFilters.queryKey +``` + +*** + +### stale? + +```ts +optional stale: boolean; +``` + +Defined in: [packages/query-core/src/utils.ts:53](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L53) + +Include or exclude stale queries + +#### Inherited from + +```ts +QueryFilters.stale +``` + +*** + +### type? + +```ts +optional type: QueryTypeFilter; +``` + +Defined in: [packages/query-core/src/utils.ts:37](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L37) + +Filter to active queries, inactive queries or all queries + +Defaults to `'all'`. + +#### Inherited from + +```ts +QueryFilters.type +``` diff --git a/docs/framework/vue/reference/interfaces/Register.md b/docs/framework/vue/reference/interfaces/Register.md new file mode 100644 index 00000000000..4f442442b48 --- /dev/null +++ b/docs/framework/vue/reference/interfaces/Register.md @@ -0,0 +1,6 @@ +--- +id: Register +title: Register +--- + +Defined in: [packages/query-core/src/types.ts:37](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L37) diff --git a/docs/framework/vue/reference/interfaces/ResetOptions.md b/docs/framework/vue/reference/interfaces/ResetOptions.md new file mode 100644 index 00000000000..9f12324ba27 --- /dev/null +++ b/docs/framework/vue/reference/interfaces/ResetOptions.md @@ -0,0 +1,49 @@ +--- +id: ResetOptions +title: ResetOptions +--- + +Defined in: [packages/query-core/src/types.ts:735](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L735) + +## Extends + +- [`RefetchOptions`](RefetchOptions.md) + +## Properties + +### cancelRefetch? + +```ts +optional cancelRefetch: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:712](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L712) + +If set to `true`, a currently running request will be cancelled before a new request is made + +If set to `false`, no refetch will be made if there is already a request running. + +Defaults to `true`. + +#### Inherited from + +[`RefetchOptions`](RefetchOptions.md).[`cancelRefetch`](RefetchOptions.md#cancelrefetch) + +*** + +### throwOnError? + +```ts +optional throwOnError: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:701](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L701) + +If set to `true`, the method throws if any of the underlying query refetch tasks fail. + +Defaults to `false`, in which case failed refetches are swallowed and not surfaced to the +caller. + +#### Inherited from + +[`RefetchOptions`](RefetchOptions.md).[`throwOnError`](RefetchOptions.md#throwonerror) diff --git a/docs/framework/vue/reference/interfaces/ResultOptions.md b/docs/framework/vue/reference/interfaces/ResultOptions.md new file mode 100644 index 00000000000..42917f20bf0 --- /dev/null +++ b/docs/framework/vue/reference/interfaces/ResultOptions.md @@ -0,0 +1,27 @@ +--- +id: ResultOptions +title: ResultOptions +--- + +Defined in: [packages/query-core/src/types.ts:694](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L694) + +## Extended by + +- [`RefetchOptions`](RefetchOptions.md) +- [`FetchNextPageOptions`](FetchNextPageOptions.md) +- [`FetchPreviousPageOptions`](FetchPreviousPageOptions.md) + +## Properties + +### throwOnError? + +```ts +optional throwOnError: boolean; +``` + +Defined in: [packages/query-core/src/types.ts:701](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L701) + +If set to `true`, the method throws if any of the underlying query refetch tasks fail. + +Defaults to `false`, in which case failed refetches are swallowed and not surfaced to the +caller. diff --git a/docs/framework/vue/reference/interfaces/SetDataOptions.md b/docs/framework/vue/reference/interfaces/SetDataOptions.md new file mode 100644 index 00000000000..bb668fbf162 --- /dev/null +++ b/docs/framework/vue/reference/interfaces/SetDataOptions.md @@ -0,0 +1,16 @@ +--- +id: SetDataOptions +title: SetDataOptions +--- + +Defined in: [packages/query-core/src/types.ts:1526](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1526) + +## Properties + +### updatedAt? + +```ts +optional updatedAt: number; +``` + +Defined in: [packages/query-core/src/types.ts:1527](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1527) diff --git a/docs/framework/vue/reference/interfaces/TimeoutManager.md b/docs/framework/vue/reference/interfaces/TimeoutManager.md new file mode 100644 index 00000000000..95ff07b2ccc --- /dev/null +++ b/docs/framework/vue/reference/interfaces/TimeoutManager.md @@ -0,0 +1,246 @@ +--- +id: TimeoutManager +title: TimeoutManager +--- + +Defined in: [packages/query-core/src/timeoutManager.ts:70](https://github.com/TanStack/query/blob/main/packages/query-core/src/timeoutManager.ts#L70) + +Allows customization of how timeouts are created. + +@tanstack/query-core makes liberal use of timeouts to implement `staleTime` +and `gcTime`. The default TimeoutManager provider uses the platform's global +`setTimeout` implementation, which is known to have scalability issues with +thousands of timeouts on the event loop. + +If you hit this limitation, consider providing a custom TimeoutProvider that +coalesces timeouts. + +## Implements + +- `Omit`\<[`TimeoutProvider`](../type-aliases/TimeoutProvider.md), `"name"`\> + +## Methods + +### clearInterval() + +```ts +clearInterval(intervalId): void; +``` + +Defined in: [packages/query-core/src/timeoutManager.ts:224](https://github.com/TanStack/query/blob/main/packages/query-core/src/timeoutManager.ts#L224) + +`clearInterval` can be used to cancel an interval, like the global +`clearInterval` function. It should be called with an interval ID +returned by `setInterval`. + +#### Parameters + +##### intervalId + +[`ManagedTimerId`](../type-aliases/ManagedTimerId.md) | `undefined` + +#### Returns + +`void` + +#### Example + +```ts +import { timeoutManager } from '@tanstack/query-core' + +const intervalId = timeoutManager.setInterval( + () => console.log('ran at:', new Date()), + 1000, +) + +timeoutManager.clearInterval(intervalId) +``` + +#### Implementation of + +[`TimeoutProvider`](../type-aliases/TimeoutProvider.md).[`clearInterval`](../type-aliases/TimeoutProvider.md#clearinterval) + +*** + +### clearTimeout() + +```ts +clearTimeout(timeoutId): void; +``` + +Defined in: [packages/query-core/src/timeoutManager.ts:179](https://github.com/TanStack/query/blob/main/packages/query-core/src/timeoutManager.ts#L179) + +`clearTimeout` cancels a timeout callback scheduled with `setTimeout`, +like the global `clearTimeout` function. It should be called with a +timer ID returned by `setTimeout`. + +#### Parameters + +##### timeoutId + +[`ManagedTimerId`](../type-aliases/ManagedTimerId.md) | `undefined` + +#### Returns + +`void` + +#### Example + +```ts +import { timeoutManager } from '@tanstack/query-core' + +const timeoutId = timeoutManager.setTimeout( + () => console.log('ran at:', new Date()), + 1000, +) + +timeoutManager.clearTimeout(timeoutId) +``` + +#### Implementation of + +[`TimeoutProvider`](../type-aliases/TimeoutProvider.md).[`clearTimeout`](../type-aliases/TimeoutProvider.md#cleartimeout) + +*** + +### setInterval() + +```ts +setInterval(callback, delay): ManagedTimerId; +``` + +Defined in: [packages/query-core/src/timeoutManager.ts:200](https://github.com/TanStack/query/blob/main/packages/query-core/src/timeoutManager.ts#L200) + +`setInterval` schedules a callback to be called approximately every +`delay` milliseconds, like the global `setInterval` function. + +Like `setTimeout`, it returns a timer ID, which may be a number or an +object that can be coerced to a number via `Symbol.toPrimitive`. + +#### Parameters + +##### callback + +[`TimeoutCallback`](../type-aliases/TimeoutCallback.md) + +##### delay + +`number` + +#### Returns + +[`ManagedTimerId`](../type-aliases/ManagedTimerId.md) + +#### Example + +```ts +import { timeoutManager } from '@tanstack/query-core' + +const intervalId = timeoutManager.setInterval( + () => console.log('ran at:', new Date()), + 1000, +) +``` + +#### Implementation of + +[`TimeoutProvider`](../type-aliases/TimeoutProvider.md).[`setInterval`](../type-aliases/TimeoutProvider.md#setinterval) + +*** + +### setTimeout() + +```ts +setTimeout(callback, delay): ManagedTimerId; +``` + +Defined in: [packages/query-core/src/timeoutManager.ts:155](https://github.com/TanStack/query/blob/main/packages/query-core/src/timeoutManager.ts#L155) + +`setTimeout` schedules a callback to run after approximately `delay` +milliseconds, like the global `setTimeout` function. The callback can be +canceled with `clearTimeout`. + +It returns a timer ID, which may be a number or an object that can be +coerced to a number via `Symbol.toPrimitive`. + +#### Parameters + +##### callback + +[`TimeoutCallback`](../type-aliases/TimeoutCallback.md) + +##### delay + +`number` + +#### Returns + +[`ManagedTimerId`](../type-aliases/ManagedTimerId.md) + +#### Example + +```ts +import { timeoutManager } from '@tanstack/query-core' + +const timeoutId = timeoutManager.setTimeout( + () => console.log('ran at:', new Date()), + 1000, +) + +const timeoutIdNumber: number = Number(timeoutId) +``` + +#### Implementation of + +[`TimeoutProvider`](../type-aliases/TimeoutProvider.md).[`setTimeout`](../type-aliases/TimeoutProvider.md#settimeout) + +*** + +### setTimeoutProvider() + +```ts +setTimeoutProvider(provider): void; +``` + +Defined in: [packages/query-core/src/timeoutManager.ts:106](https://github.com/TanStack/query/blob/main/packages/query-core/src/timeoutManager.ts#L106) + +`setTimeoutProvider` can be used to set a custom implementation of the +`setTimeout`, `clearTimeout`, `setInterval`, `clearInterval` functions, +called a `TimeoutProvider`. + +This may be useful if you notice event loop performance issues with +thousands of queries. A custom TimeoutProvider could also support timer +delays longer than the global `setTimeout` maximum delay value of about +24 days. + +It is important to call `setTimeoutProvider` before creating a +QueryClient or queries, so that the same provider is used consistently +for all timers in the application, since different TimeoutProviders +cannot cancel each others' timers. + +#### Type Parameters + +##### TTimerId + +`TTimerId` *extends* [`ManagedTimerId`](../type-aliases/ManagedTimerId.md) + +#### Parameters + +##### provider + +[`TimeoutProvider`](../type-aliases/TimeoutProvider.md)\<`TTimerId`\> + +#### Returns + +`void` + +#### Example + +```ts +import { timeoutManager, QueryClient } from '@tanstack/query-core' +import { CustomTimeoutProvider } from './CustomTimeoutProvider' + +timeoutManager.setTimeoutProvider(new CustomTimeoutProvider()) + +export const queryClient = new QueryClient() +``` diff --git a/docs/framework/vue/reference/type-aliases/AnyDataTag.md b/docs/framework/vue/reference/type-aliases/AnyDataTag.md new file mode 100644 index 00000000000..d3d5e33bb3e --- /dev/null +++ b/docs/framework/vue/reference/type-aliases/AnyDataTag.md @@ -0,0 +1,30 @@ +--- +id: AnyDataTag +title: AnyDataTag +--- + +```ts +type AnyDataTag = object; +``` + +Defined in: [packages/query-core/src/types.ts:67](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L67) + +## Properties + +### \[dataTagErrorSymbol\] + +```ts +[dataTagErrorSymbol]: any; +``` + +Defined in: [packages/query-core/src/types.ts:69](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L69) + +*** + +### \[dataTagSymbol\] + +```ts +[dataTagSymbol]: any; +``` + +Defined in: [packages/query-core/src/types.ts:68](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L68) diff --git a/docs/framework/vue/reference/type-aliases/DataTag.md b/docs/framework/vue/reference/type-aliases/DataTag.md new file mode 100644 index 00000000000..904ca124464 --- /dev/null +++ b/docs/framework/vue/reference/type-aliases/DataTag.md @@ -0,0 +1,24 @@ +--- +id: DataTag +title: DataTag +--- + +```ts +type DataTag = TType extends AnyDataTag ? TType : TType & object; +``` + +Defined in: [packages/query-core/src/types.ts:71](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L71) + +## Type Parameters + +### TType + +`TType` + +### TValue + +`TValue` + +### TError + +`TError` = [`UnsetMarker`](UnsetMarker.md) diff --git a/docs/framework/vue/reference/type-aliases/DefaultError.md b/docs/framework/vue/reference/type-aliases/DefaultError.md new file mode 100644 index 00000000000..da9f615482f --- /dev/null +++ b/docs/framework/vue/reference/type-aliases/DefaultError.md @@ -0,0 +1,10 @@ +--- +id: DefaultError +title: DefaultError +--- + +```ts +type DefaultError = Register extends object ? TError : Error; +``` + +Defined in: [packages/query-core/src/types.ts:45](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L45) diff --git a/docs/framework/vue/reference/type-aliases/DefaultedInfiniteQueryObserverOptions.md b/docs/framework/vue/reference/type-aliases/DefaultedInfiniteQueryObserverOptions.md new file mode 100644 index 00000000000..82c7ddbb886 --- /dev/null +++ b/docs/framework/vue/reference/type-aliases/DefaultedInfiniteQueryObserverOptions.md @@ -0,0 +1,32 @@ +--- +id: DefaultedInfiniteQueryObserverOptions +title: DefaultedInfiniteQueryObserverOptions +--- + +```ts +type DefaultedInfiniteQueryObserverOptions = WithRequired, "throwOnError" | "refetchOnReconnect" | "queryHash">; +``` + +Defined in: [packages/query-core/src/types.ts:557](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L557) + +## Type Parameters + +### TQueryFnData + +`TQueryFnData` = `unknown` + +### TError + +`TError` = [`DefaultError`](DefaultError.md) + +### TData + +`TData` = `TQueryFnData` + +### TQueryKey + +`TQueryKey` *extends* [`QueryKey`](QueryKey.md) = [`QueryKey`](QueryKey.md) + +### TPageParam + +`TPageParam` = `unknown` diff --git a/docs/framework/vue/reference/type-aliases/DefaultedQueryObserverOptions.md b/docs/framework/vue/reference/type-aliases/DefaultedQueryObserverOptions.md new file mode 100644 index 00000000000..7687d8c24f6 --- /dev/null +++ b/docs/framework/vue/reference/type-aliases/DefaultedQueryObserverOptions.md @@ -0,0 +1,32 @@ +--- +id: DefaultedQueryObserverOptions +title: DefaultedQueryObserverOptions +--- + +```ts +type DefaultedQueryObserverOptions = WithRequired, "throwOnError" | "refetchOnReconnect" | "queryHash">; +``` + +Defined in: [packages/query-core/src/types.ts:528](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L528) + +## Type Parameters + +### TQueryFnData + +`TQueryFnData` = `unknown` + +### TError + +`TError` = [`DefaultError`](DefaultError.md) + +### TData + +`TData` = `TQueryFnData` + +### TQueryData + +`TQueryData` = `TQueryFnData` + +### TQueryKey + +`TQueryKey` *extends* [`QueryKey`](QueryKey.md) = [`QueryKey`](QueryKey.md) diff --git a/docs/framework/vue/reference/type-aliases/DefinedInfiniteQueryObserverResult.md b/docs/framework/vue/reference/type-aliases/DefinedInfiniteQueryObserverResult.md new file mode 100644 index 00000000000..38dac7cfe2b --- /dev/null +++ b/docs/framework/vue/reference/type-aliases/DefinedInfiniteQueryObserverResult.md @@ -0,0 +1,22 @@ +--- +id: DefinedInfiniteQueryObserverResult +title: DefinedInfiniteQueryObserverResult +--- + +```ts +type DefinedInfiniteQueryObserverResult = + | InfiniteQueryObserverRefetchErrorResult +| InfiniteQueryObserverSuccessResult; +``` + +Defined in: [packages/query-core/src/types.ts:1148](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1148) + +## Type Parameters + +### TData + +`TData` = `unknown` + +### TError + +`TError` = [`DefaultError`](DefaultError.md) diff --git a/docs/framework/vue/reference/type-aliases/DefinedInitialDataInfiniteOptions.md b/docs/framework/vue/reference/type-aliases/DefinedInitialDataInfiniteOptions.md index 03b1ffdd63c..f812ea8d2d8 100644 --- a/docs/framework/vue/reference/type-aliases/DefinedInitialDataInfiniteOptions.md +++ b/docs/framework/vue/reference/type-aliases/DefinedInitialDataInfiniteOptions.md @@ -7,7 +7,7 @@ title: DefinedInitialDataInfiniteOptions type DefinedInitialDataInfiniteOptions = UseInfiniteQueryOptions & object; ``` -Defined in: [vue-query/src/infiniteQueryOptions.ts:48](https://github.com/TanStack/query/blob/main/packages/vue-query/src/infiniteQueryOptions.ts#L48) +Defined in: [packages/vue-query/src/infiniteQueryOptions.ts:48](https://github.com/TanStack/query/blob/main/packages/vue-query/src/infiniteQueryOptions.ts#L48) The options accepted by the `infiniteQueryOptions` overload selected when `initialData` is set — `data` is never `undefined`. @@ -38,20 +38,20 @@ The type of a single page, as your `queryFn` resolves it. ### TError -`TError` = `DefaultError` +`TError` = [`DefaultError`](DefaultError.md) The type of errors your `queryFn` may throw. ### TData -`TData` = `InfiniteData`\<`TQueryFnData`\> +`TData` = [`InfiniteData`](../interfaces/InfiniteData.md)\<`TQueryFnData`\> The type `data` ends up as after `select` runs — defaults to `InfiniteData`, the shape of all fetched pages plus their page params. ### TQueryKey -`TQueryKey` *extends* `QueryKey` = `QueryKey` +`TQueryKey` *extends* [`QueryKey`](QueryKey.md) = [`QueryKey`](QueryKey.md) The type of your `queryKey`. diff --git a/docs/framework/vue/reference/type-aliases/DefinedInitialQueryOptions.md b/docs/framework/vue/reference/type-aliases/DefinedInitialQueryOptions.md index fd07af0e22d..149f939f4de 100644 --- a/docs/framework/vue/reference/type-aliases/DefinedInitialQueryOptions.md +++ b/docs/framework/vue/reference/type-aliases/DefinedInitialQueryOptions.md @@ -7,7 +7,7 @@ title: DefinedInitialQueryOptions type DefinedInitialQueryOptions = UseQueryOptions & object; ``` -Defined in: [vue-query/src/useQuery.ts:79](https://github.com/TanStack/query/blob/main/packages/vue-query/src/useQuery.ts#L79) +Defined in: [packages/vue-query/src/useQuery.ts:79](https://github.com/TanStack/query/blob/main/packages/vue-query/src/useQuery.ts#L79) ## Type Declaration @@ -27,7 +27,7 @@ initialData: ### TError -`TError` = `DefaultError` +`TError` = [`DefaultError`](DefaultError.md) ### TData @@ -35,4 +35,4 @@ initialData: ### TQueryKey -`TQueryKey` *extends* `QueryKey` = `QueryKey` +`TQueryKey` *extends* [`QueryKey`](QueryKey.md) = [`QueryKey`](QueryKey.md) diff --git a/docs/framework/vue/reference/type-aliases/DefinedInitialQueryOptionsWithDataTag.md b/docs/framework/vue/reference/type-aliases/DefinedInitialQueryOptionsWithDataTag.md index 048fb5dec4f..634caa6b0b2 100644 --- a/docs/framework/vue/reference/type-aliases/DefinedInitialQueryOptionsWithDataTag.md +++ b/docs/framework/vue/reference/type-aliases/DefinedInitialQueryOptionsWithDataTag.md @@ -7,7 +7,7 @@ title: DefinedInitialQueryOptionsWithDataTag type DefinedInitialQueryOptionsWithDataTag = DefinedInitialQueryOptions & QueryKeyWithDataTag; ``` -Defined in: [vue-query/src/queryOptions.ts:131](https://github.com/TanStack/query/blob/main/packages/vue-query/src/queryOptions.ts#L131) +Defined in: [packages/vue-query/src/queryOptions.ts:131](https://github.com/TanStack/query/blob/main/packages/vue-query/src/queryOptions.ts#L131) ## Type Parameters @@ -17,7 +17,7 @@ Defined in: [vue-query/src/queryOptions.ts:131](https://github.com/TanStack/quer ### TError -`TError` = `DefaultError` +`TError` = [`DefaultError`](DefaultError.md) ### TData @@ -25,4 +25,4 @@ Defined in: [vue-query/src/queryOptions.ts:131](https://github.com/TanStack/quer ### TQueryKey -`TQueryKey` *extends* `QueryKey` = `QueryKey` +`TQueryKey` *extends* [`QueryKey`](QueryKey.md) = [`QueryKey`](QueryKey.md) diff --git a/docs/framework/vue/reference/type-aliases/DefinedQueryObserverResult.md b/docs/framework/vue/reference/type-aliases/DefinedQueryObserverResult.md new file mode 100644 index 00000000000..ae77ddcc22d --- /dev/null +++ b/docs/framework/vue/reference/type-aliases/DefinedQueryObserverResult.md @@ -0,0 +1,22 @@ +--- +id: DefinedQueryObserverResult +title: DefinedQueryObserverResult +--- + +```ts +type DefinedQueryObserverResult = + | QueryObserverRefetchErrorResult +| QueryObserverSuccessResult; +``` + +Defined in: [packages/query-core/src/types.ts:987](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L987) + +## Type Parameters + +### TData + +`TData` = `unknown` + +### TError + +`TError` = [`DefaultError`](DefaultError.md) diff --git a/docs/framework/vue/reference/type-aliases/DistributiveOmit.md b/docs/framework/vue/reference/type-aliases/DistributiveOmit.md new file mode 100644 index 00000000000..33b87a5cd6e --- /dev/null +++ b/docs/framework/vue/reference/type-aliases/DistributiveOmit.md @@ -0,0 +1,20 @@ +--- +id: DistributiveOmit +title: DistributiveOmit +--- + +```ts +type DistributiveOmit = TObject extends any ? Omit : never; +``` + +Defined in: [packages/query-core/src/types.ts:14](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L14) + +## Type Parameters + +### TObject + +`TObject` + +### TKey + +`TKey` *extends* keyof `TObject` diff --git a/docs/framework/vue/reference/type-aliases/EnsureInfiniteQueryDataOptions.md b/docs/framework/vue/reference/type-aliases/EnsureInfiniteQueryDataOptions.md new file mode 100644 index 00000000000..7648331fca2 --- /dev/null +++ b/docs/framework/vue/reference/type-aliases/EnsureInfiniteQueryDataOptions.md @@ -0,0 +1,42 @@ +--- +id: EnsureInfiniteQueryDataOptions +title: EnsureInfiniteQueryDataOptions +--- + +```ts +type EnsureInfiniteQueryDataOptions = FetchInfiniteQueryOptions & object; +``` + +Defined in: [packages/query-core/src/types.ts:631](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L631) + +## Type Declaration + +### ~~revalidateIfStale?~~ + +```ts +optional revalidateIfStale: boolean; +``` + +## Type Parameters + +### TQueryFnData + +`TQueryFnData` = `unknown` + +### TError + +`TError` = [`DefaultError`](DefaultError.md) + +### TData + +`TData` = `TQueryFnData` + +### TQueryKey + +`TQueryKey` *extends* [`QueryKey`](QueryKey.md) = [`QueryKey`](QueryKey.md) + +### TPageParam + +`TPageParam` = `unknown` + +## Deprecated diff --git a/docs/framework/vue/reference/type-aliases/FetchInfiniteQueryOptions.md b/docs/framework/vue/reference/type-aliases/FetchInfiniteQueryOptions.md new file mode 100644 index 00000000000..d00a2455889 --- /dev/null +++ b/docs/framework/vue/reference/type-aliases/FetchInfiniteQueryOptions.md @@ -0,0 +1,34 @@ +--- +id: FetchInfiniteQueryOptions +title: FetchInfiniteQueryOptions +--- + +```ts +type FetchInfiniteQueryOptions = Omit, TQueryKey, TPageParam>, "initialPageParam"> & InitialPageParam & InfiniteQueryPages; +``` + +Defined in: [packages/query-core/src/types.ts:675](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L675) + +## Type Parameters + +### TQueryFnData + +`TQueryFnData` = `unknown` + +### TError + +`TError` = [`DefaultError`](DefaultError.md) + +### TData + +`TData` = `TQueryFnData` + +### TQueryKey + +`TQueryKey` *extends* [`QueryKey`](QueryKey.md) = [`QueryKey`](QueryKey.md) + +### TPageParam + +`TPageParam` = `unknown` + +## Deprecated diff --git a/docs/framework/vue/reference/type-aliases/FetchStatus.md b/docs/framework/vue/reference/type-aliases/FetchStatus.md new file mode 100644 index 00000000000..d50002355ca --- /dev/null +++ b/docs/framework/vue/reference/type-aliases/FetchStatus.md @@ -0,0 +1,10 @@ +--- +id: FetchStatus +title: FetchStatus +--- + +```ts +type FetchStatus = "fetching" | "paused" | "idle"; +``` + +Defined in: [packages/query-core/src/types.ts:762](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L762) diff --git a/docs/framework/vue/reference/type-aliases/GetNextPageParamFunction.md b/docs/framework/vue/reference/type-aliases/GetNextPageParamFunction.md new file mode 100644 index 00000000000..81d1a1544ab --- /dev/null +++ b/docs/framework/vue/reference/type-aliases/GetNextPageParamFunction.md @@ -0,0 +1,42 @@ +--- +id: GetNextPageParamFunction +title: GetNextPageParamFunction +--- + +```ts +type GetNextPageParamFunction = (lastPage, allPages, lastPageParam, allPageParams) => TPageParam | undefined | null; +``` + +Defined in: [packages/query-core/src/types.ts:203](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L203) + +## Type Parameters + +### TPageParam + +`TPageParam` + +### TQueryFnData + +`TQueryFnData` = `unknown` + +## Parameters + +### lastPage + +`TQueryFnData` + +### allPages + +`TQueryFnData`[] + +### lastPageParam + +`TPageParam` + +### allPageParams + +`TPageParam`[] + +## Returns + +`TPageParam` \| `undefined` \| `null` diff --git a/docs/framework/vue/reference/type-aliases/GetPreviousPageParamFunction.md b/docs/framework/vue/reference/type-aliases/GetPreviousPageParamFunction.md new file mode 100644 index 00000000000..5a6d9b93d7e --- /dev/null +++ b/docs/framework/vue/reference/type-aliases/GetPreviousPageParamFunction.md @@ -0,0 +1,42 @@ +--- +id: GetPreviousPageParamFunction +title: GetPreviousPageParamFunction +--- + +```ts +type GetPreviousPageParamFunction = (firstPage, allPages, firstPageParam, allPageParams) => TPageParam | undefined | null; +``` + +Defined in: [packages/query-core/src/types.ts:196](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L196) + +## Type Parameters + +### TPageParam + +`TPageParam` + +### TQueryFnData + +`TQueryFnData` = `unknown` + +## Parameters + +### firstPage + +`TQueryFnData` + +### allPages + +`TQueryFnData`[] + +### firstPageParam + +`TPageParam` + +### allPageParams + +`TPageParam`[] + +## Returns + +`TPageParam` \| `undefined` \| `null` diff --git a/docs/framework/vue/reference/type-aliases/InferDataFromTag.md b/docs/framework/vue/reference/type-aliases/InferDataFromTag.md new file mode 100644 index 00000000000..09a15ca4b1c --- /dev/null +++ b/docs/framework/vue/reference/type-aliases/InferDataFromTag.md @@ -0,0 +1,20 @@ +--- +id: InferDataFromTag +title: InferDataFromTag +--- + +```ts +type InferDataFromTag = TTaggedQueryKey extends DataTag ? TaggedValue : TQueryFnData; +``` + +Defined in: [packages/query-core/src/types.ts:90](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L90) + +## Type Parameters + +### TQueryFnData + +`TQueryFnData` + +### TTaggedQueryKey + +`TTaggedQueryKey` *extends* [`QueryKey`](QueryKey.md) diff --git a/docs/framework/vue/reference/type-aliases/InferErrorFromTag.md b/docs/framework/vue/reference/type-aliases/InferErrorFromTag.md new file mode 100644 index 00000000000..cd94e4b5c3f --- /dev/null +++ b/docs/framework/vue/reference/type-aliases/InferErrorFromTag.md @@ -0,0 +1,20 @@ +--- +id: InferErrorFromTag +title: InferErrorFromTag +--- + +```ts +type InferErrorFromTag = TTaggedQueryKey extends DataTag ? TaggedError extends UnsetMarker ? TError : TaggedError : TError; +``` + +Defined in: [packages/query-core/src/types.ts:95](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L95) + +## Type Parameters + +### TError + +`TError` + +### TTaggedQueryKey + +`TTaggedQueryKey` *extends* [`QueryKey`](QueryKey.md) diff --git a/docs/framework/vue/reference/type-aliases/InfiniteQueryExecuteOptions.md b/docs/framework/vue/reference/type-aliases/InfiniteQueryExecuteOptions.md new file mode 100644 index 00000000000..259c97c96bb --- /dev/null +++ b/docs/framework/vue/reference/type-aliases/InfiniteQueryExecuteOptions.md @@ -0,0 +1,32 @@ +--- +id: InfiniteQueryExecuteOptions +title: InfiniteQueryExecuteOptions +--- + +```ts +type InfiniteQueryExecuteOptions = Omit, TQueryKey, TPageParam>, "initialPageParam"> & InitialPageParam & InfiniteQueryPages; +``` + +Defined in: [packages/query-core/src/types.ts:654](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L654) + +## Type Parameters + +### TQueryFnData + +`TQueryFnData` = `unknown` + +### TError + +`TError` = [`DefaultError`](DefaultError.md) + +### TData + +`TData` = [`InfiniteData`](../interfaces/InfiniteData.md)\<`TQueryFnData`\> + +### TQueryKey + +`TQueryKey` *extends* [`QueryKey`](QueryKey.md) = [`QueryKey`](QueryKey.md) + +### TPageParam + +`TPageParam` = `unknown` diff --git a/docs/framework/vue/reference/type-aliases/InfiniteQueryObserverResult.md b/docs/framework/vue/reference/type-aliases/InfiniteQueryObserverResult.md new file mode 100644 index 00000000000..aa27563b9cd --- /dev/null +++ b/docs/framework/vue/reference/type-aliases/InfiniteQueryObserverResult.md @@ -0,0 +1,25 @@ +--- +id: InfiniteQueryObserverResult +title: InfiniteQueryObserverResult +--- + +```ts +type InfiniteQueryObserverResult = + | DefinedInfiniteQueryObserverResult + | InfiniteQueryObserverLoadingErrorResult + | InfiniteQueryObserverLoadingResult + | InfiniteQueryObserverPendingResult +| InfiniteQueryObserverPlaceholderResult; +``` + +Defined in: [packages/query-core/src/types.ts:1155](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1155) + +## Type Parameters + +### TData + +`TData` = `unknown` + +### TError + +`TError` = [`DefaultError`](DefaultError.md) diff --git a/docs/framework/vue/reference/type-aliases/InitialDataFunction.md b/docs/framework/vue/reference/type-aliases/InitialDataFunction.md new file mode 100644 index 00000000000..6ba4aaabe61 --- /dev/null +++ b/docs/framework/vue/reference/type-aliases/InitialDataFunction.md @@ -0,0 +1,20 @@ +--- +id: InitialDataFunction +title: InitialDataFunction +--- + +```ts +type InitialDataFunction = () => T | undefined; +``` + +Defined in: [packages/query-core/src/types.ts:173](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L173) + +## Type Parameters + +### T + +`T` + +## Returns + +`T` \| `undefined` diff --git a/docs/framework/vue/reference/type-aliases/ManagedTimerId.md b/docs/framework/vue/reference/type-aliases/ManagedTimerId.md new file mode 100644 index 00000000000..d7833e3e4f0 --- /dev/null +++ b/docs/framework/vue/reference/type-aliases/ManagedTimerId.md @@ -0,0 +1,19 @@ +--- +id: ManagedTimerId +title: ManagedTimerId +--- + +```ts +type ManagedTimerId = + | number + | { + [toPrimitive]: () => number; +}; +``` + +Defined in: [packages/query-core/src/timeoutManager.ts:17](https://github.com/TanStack/query/blob/main/packages/query-core/src/timeoutManager.ts#L17) + +Wrapping `setTimeout` is awkward from a typing perspective because platform +typings may extend the return type of `setTimeout`. For example, NodeJS +typings add `NodeJS.Timeout`; but a non-default `timeoutManager` may not be +able to return such a type. diff --git a/docs/framework/vue/reference/type-aliases/MutateFunction.md b/docs/framework/vue/reference/type-aliases/MutateFunction.md new file mode 100644 index 00000000000..e12b7a80291 --- /dev/null +++ b/docs/framework/vue/reference/type-aliases/MutateFunction.md @@ -0,0 +1,38 @@ +--- +id: MutateFunction +title: MutateFunction +--- + +```ts +type MutateFunction = (...rest) => Promise; +``` + +Defined in: [packages/query-core/src/types.ts:1326](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1326) + +## Type Parameters + +### TData + +`TData` = `unknown` + +### TError + +`TError` = [`DefaultError`](DefaultError.md) + +### TVariables + +`TVariables` = `void` + +### TOnMutateResult + +`TOnMutateResult` = `unknown` + +## Parameters + +### rest + +...[`MutateFunctionRest`](MutateFunctionRest.md)\<`TData`, `TError`, `TVariables`, `TOnMutateResult`\> + +## Returns + +`Promise`\<`TData`\> diff --git a/docs/framework/vue/reference/type-aliases/MutateFunctionRest.md b/docs/framework/vue/reference/type-aliases/MutateFunctionRest.md new file mode 100644 index 00000000000..3902f1082f9 --- /dev/null +++ b/docs/framework/vue/reference/type-aliases/MutateFunctionRest.md @@ -0,0 +1,28 @@ +--- +id: MutateFunctionRest +title: MutateFunctionRest +--- + +```ts +type MutateFunctionRest = undefined extends TVariables ? [TVariables, MutateOptions] : [TVariables, MutateOptions]; +``` + +Defined in: [packages/query-core/src/types.ts:1311](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1311) + +## Type Parameters + +### TData + +`TData` = `unknown` + +### TError + +`TError` = [`DefaultError`](DefaultError.md) + +### TVariables + +`TVariables` = `void` + +### TOnMutateResult + +`TOnMutateResult` = `unknown` diff --git a/docs/framework/vue/reference/type-aliases/MutationCacheNotifyEvent.md b/docs/framework/vue/reference/type-aliases/MutationCacheNotifyEvent.md new file mode 100644 index 00000000000..aa5e196bc72 --- /dev/null +++ b/docs/framework/vue/reference/type-aliases/MutationCacheNotifyEvent.md @@ -0,0 +1,20 @@ +--- +id: MutationCacheNotifyEvent +title: MutationCacheNotifyEvent +--- + +```ts +type MutationCacheNotifyEvent = + | NotifyEventMutationAdded + | NotifyEventMutationRemoved + | NotifyEventMutationObserverAdded + | NotifyEventMutationObserverRemoved + | NotifyEventMutationObserverOptionsUpdated + | NotifyEventMutationUpdated; +``` + +Defined in: [packages/query-core/src/mutationCache.ts:98](https://github.com/TanStack/query/blob/main/packages/query-core/src/mutationCache.ts#L98) + +The event passed to a `MutationCache` subscriber. Fired whenever a mutation is added or removed +from the cache, its state is updated, or one of its observers is added, removed, or has its +options updated. diff --git a/docs/framework/vue/reference/type-aliases/MutationFilters.md b/docs/framework/vue/reference/type-aliases/MutationFilters.md index cceadab3c02..f390b33f78c 100644 --- a/docs/framework/vue/reference/type-aliases/MutationFilters.md +++ b/docs/framework/vue/reference/type-aliases/MutationFilters.md @@ -7,4 +7,4 @@ title: MutationFilters type MutationFilters = MaybeRefDeep; ``` -Defined in: [vue-query/src/useMutationState.ts:21](https://github.com/TanStack/query/blob/main/packages/vue-query/src/useMutationState.ts#L21) +Defined in: [packages/vue-query/src/useMutationState.ts:21](https://github.com/TanStack/query/blob/main/packages/vue-query/src/useMutationState.ts#L21) diff --git a/docs/framework/vue/reference/type-aliases/MutationFunction.md b/docs/framework/vue/reference/type-aliases/MutationFunction.md new file mode 100644 index 00000000000..9bafb3db56b --- /dev/null +++ b/docs/framework/vue/reference/type-aliases/MutationFunction.md @@ -0,0 +1,34 @@ +--- +id: MutationFunction +title: MutationFunction +--- + +```ts +type MutationFunction = (variables, context) => Promise; +``` + +Defined in: [packages/query-core/src/types.ts:1195](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1195) + +## Type Parameters + +### TData + +`TData` = `unknown` + +### TVariables + +`TVariables` = `unknown` + +## Parameters + +### variables + +`TVariables` + +### context + +[`MutationFunctionContext`](MutationFunctionContext.md) + +## Returns + +`Promise`\<`TData`\> diff --git a/docs/framework/vue/reference/type-aliases/MutationFunctionContext.md b/docs/framework/vue/reference/type-aliases/MutationFunctionContext.md new file mode 100644 index 00000000000..0207256c702 --- /dev/null +++ b/docs/framework/vue/reference/type-aliases/MutationFunctionContext.md @@ -0,0 +1,40 @@ +--- +id: MutationFunctionContext +title: MutationFunctionContext +--- + +```ts +type MutationFunctionContext = object; +``` + +Defined in: [packages/query-core/src/types.ts:1189](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1189) + +## Properties + +### client + +```ts +client: QueryClient; +``` + +Defined in: [packages/query-core/src/types.ts:1190](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1190) + +*** + +### meta + +```ts +meta: MutationMeta | undefined; +``` + +Defined in: [packages/query-core/src/types.ts:1191](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1191) + +*** + +### mutationKey? + +```ts +optional mutationKey: MutationKey; +``` + +Defined in: [packages/query-core/src/types.ts:1192](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1192) diff --git a/docs/framework/vue/reference/type-aliases/MutationKey.md b/docs/framework/vue/reference/type-aliases/MutationKey.md new file mode 100644 index 00000000000..9d1d7f0f77b --- /dev/null +++ b/docs/framework/vue/reference/type-aliases/MutationKey.md @@ -0,0 +1,10 @@ +--- +id: MutationKey +title: MutationKey +--- + +```ts +type MutationKey = Register extends object ? TMutationKey extends ReadonlyArray ? TMutationKey : TMutationKey extends unknown[] ? TMutationKey : ReadonlyArray : ReadonlyArray; +``` + +Defined in: [packages/query-core/src/types.ts:1165](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1165) diff --git a/docs/framework/vue/reference/type-aliases/MutationMeta.md b/docs/framework/vue/reference/type-aliases/MutationMeta.md new file mode 100644 index 00000000000..ff1f9b4bf94 --- /dev/null +++ b/docs/framework/vue/reference/type-aliases/MutationMeta.md @@ -0,0 +1,10 @@ +--- +id: MutationMeta +title: MutationMeta +--- + +```ts +type MutationMeta = Register extends object ? TMutationMeta extends Record ? TMutationMeta : Record : Record; +``` + +Defined in: [packages/query-core/src/types.ts:1181](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1181) diff --git a/docs/framework/vue/reference/type-aliases/MutationObserverResult.md b/docs/framework/vue/reference/type-aliases/MutationObserverResult.md new file mode 100644 index 00000000000..c21fc3ac591 --- /dev/null +++ b/docs/framework/vue/reference/type-aliases/MutationObserverResult.md @@ -0,0 +1,32 @@ +--- +id: MutationObserverResult +title: MutationObserverResult +--- + +```ts +type MutationObserverResult = + | MutationObserverIdleResult + | MutationObserverLoadingResult + | MutationObserverErrorResult +| MutationObserverSuccessResult; +``` + +Defined in: [packages/query-core/src/types.ts:1484](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1484) + +## Type Parameters + +### TData + +`TData` = `unknown` + +### TError + +`TError` = [`DefaultError`](DefaultError.md) + +### TVariables + +`TVariables` = `void` + +### TOnMutateResult + +`TOnMutateResult` = `unknown` diff --git a/docs/framework/vue/reference/type-aliases/MutationOptions.md b/docs/framework/vue/reference/type-aliases/MutationOptions.md index 6932ca0f394..c71ea9581b3 100644 --- a/docs/framework/vue/reference/type-aliases/MutationOptions.md +++ b/docs/framework/vue/reference/type-aliases/MutationOptions.md @@ -7,7 +7,7 @@ title: MutationOptions type MutationOptions = OmitKeyof, "_defaulted"> & ShallowOption; ``` -Defined in: [vue-query/src/types.ts:85](https://github.com/TanStack/query/blob/main/packages/vue-query/src/types.ts#L85) +Defined in: [packages/vue-query/src/types.ts:85](https://github.com/TanStack/query/blob/main/packages/vue-query/src/types.ts#L85) ## Type Parameters @@ -17,7 +17,7 @@ Defined in: [vue-query/src/types.ts:85](https://github.com/TanStack/query/blob/m ### TError -`TError` = `DefaultError` +`TError` = [`DefaultError`](DefaultError.md) ### TVariables diff --git a/docs/framework/vue/reference/type-aliases/MutationScope.md b/docs/framework/vue/reference/type-aliases/MutationScope.md new file mode 100644 index 00000000000..1d6a91bd434 --- /dev/null +++ b/docs/framework/vue/reference/type-aliases/MutationScope.md @@ -0,0 +1,20 @@ +--- +id: MutationScope +title: MutationScope +--- + +```ts +type MutationScope = object; +``` + +Defined in: [packages/query-core/src/types.ts:1177](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1177) + +## Properties + +### id + +```ts +id: string; +``` + +Defined in: [packages/query-core/src/types.ts:1178](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1178) diff --git a/docs/framework/vue/reference/type-aliases/MutationStateOptions.md b/docs/framework/vue/reference/type-aliases/MutationStateOptions.md index c320b78c94a..bbd9864dc2b 100644 --- a/docs/framework/vue/reference/type-aliases/MutationStateOptions.md +++ b/docs/framework/vue/reference/type-aliases/MutationStateOptions.md @@ -7,17 +7,17 @@ title: MutationStateOptions type MutationStateOptions = object; ``` -Defined in: [vue-query/src/useMutationState.ts:88](https://github.com/TanStack/query/blob/main/packages/vue-query/src/useMutationState.ts#L88) +Defined in: [packages/vue-query/src/useMutationState.ts:88](https://github.com/TanStack/query/blob/main/packages/vue-query/src/useMutationState.ts#L88) ## Type Parameters ### TResult -`TResult` = `MutationState` +`TResult` = [`MutationState`](../interfaces/MutationState.md) ### TMutation -`TMutation` *extends* `Mutation`\<`any`, `any`, `any`, `any`\> = `MutationTypeFromResult`\<`TResult`\> +`TMutation` *extends* [`Mutation`](../classes/Mutation.md)\<`any`, `any`, `any`, `any`\> = `MutationTypeFromResult`\<`TResult`\> ## Properties @@ -27,7 +27,7 @@ Defined in: [vue-query/src/useMutationState.ts:88](https://github.com/TanStack/q optional filters: MutationFilters; ``` -Defined in: [vue-query/src/useMutationState.ts:93](https://github.com/TanStack/query/blob/main/packages/vue-query/src/useMutationState.ts#L93) +Defined in: [packages/vue-query/src/useMutationState.ts:93](https://github.com/TanStack/query/blob/main/packages/vue-query/src/useMutationState.ts#L93) *** @@ -37,7 +37,7 @@ Defined in: [vue-query/src/useMutationState.ts:93](https://github.com/TanStack/q optional select: (mutation) => TResult; ``` -Defined in: [vue-query/src/useMutationState.ts:94](https://github.com/TanStack/query/blob/main/packages/vue-query/src/useMutationState.ts#L94) +Defined in: [packages/vue-query/src/useMutationState.ts:94](https://github.com/TanStack/query/blob/main/packages/vue-query/src/useMutationState.ts#L94) #### Parameters diff --git a/docs/framework/vue/reference/type-aliases/MutationStatus.md b/docs/framework/vue/reference/type-aliases/MutationStatus.md new file mode 100644 index 00000000000..cf12d3d3ee3 --- /dev/null +++ b/docs/framework/vue/reference/type-aliases/MutationStatus.md @@ -0,0 +1,10 @@ +--- +id: MutationStatus +title: MutationStatus +--- + +```ts +type MutationStatus = "idle" | "pending" | "success" | "error"; +``` + +Defined in: [packages/query-core/src/types.ts:1175](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1175) diff --git a/docs/framework/vue/reference/type-aliases/NetworkMode.md b/docs/framework/vue/reference/type-aliases/NetworkMode.md new file mode 100644 index 00000000000..94ae0ba76ed --- /dev/null +++ b/docs/framework/vue/reference/type-aliases/NetworkMode.md @@ -0,0 +1,10 @@ +--- +id: NetworkMode +title: NetworkMode +--- + +```ts +type NetworkMode = "online" | "always" | "offlineFirst"; +``` + +Defined in: [packages/query-core/src/types.ts:223](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L223) diff --git a/docs/framework/vue/reference/type-aliases/NonUndefinedGuard.md b/docs/framework/vue/reference/type-aliases/NonUndefinedGuard.md new file mode 100644 index 00000000000..4aaf208013b --- /dev/null +++ b/docs/framework/vue/reference/type-aliases/NonUndefinedGuard.md @@ -0,0 +1,16 @@ +--- +id: NonUndefinedGuard +title: NonUndefinedGuard +--- + +```ts +type NonUndefinedGuard = T extends undefined ? never : T; +``` + +Defined in: [packages/query-core/src/types.ts:12](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L12) + +## Type Parameters + +### T + +`T` diff --git a/docs/framework/vue/reference/type-aliases/NotifyEventType.md b/docs/framework/vue/reference/type-aliases/NotifyEventType.md new file mode 100644 index 00000000000..ffa60b016e3 --- /dev/null +++ b/docs/framework/vue/reference/type-aliases/NotifyEventType.md @@ -0,0 +1,17 @@ +--- +id: NotifyEventType +title: NotifyEventType +--- + +```ts +type NotifyEventType = + | "added" + | "removed" + | "updated" + | "observerAdded" + | "observerRemoved" + | "observerResultsUpdated" + | "observerOptionsUpdated"; +``` + +Defined in: [packages/query-core/src/types.ts:1530](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L1530) diff --git a/docs/framework/vue/reference/type-aliases/NotifyOnChangeProps.md b/docs/framework/vue/reference/type-aliases/NotifyOnChangeProps.md new file mode 100644 index 00000000000..7de194fa10b --- /dev/null +++ b/docs/framework/vue/reference/type-aliases/NotifyOnChangeProps.md @@ -0,0 +1,17 @@ +--- +id: NotifyOnChangeProps +title: NotifyOnChangeProps +--- + +```ts +type NotifyOnChangeProps = + | keyof InfiniteQueryObserverResult[] + | "all" + | undefined + | () => + | keyof InfiniteQueryObserverResult[] + | "all" + | undefined; +``` + +Defined in: [packages/query-core/src/types.ts:225](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L225) diff --git a/docs/framework/vue/reference/type-aliases/OmitKeyof.md b/docs/framework/vue/reference/type-aliases/OmitKeyof.md new file mode 100644 index 00000000000..690a7b0a5d2 --- /dev/null +++ b/docs/framework/vue/reference/type-aliases/OmitKeyof.md @@ -0,0 +1,28 @@ +--- +id: OmitKeyof +title: OmitKeyof +--- + +```ts +type OmitKeyof = Omit; +``` + +Defined in: [packages/query-core/src/types.ts:19](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L19) + +## Type Parameters + +### TObject + +`TObject` + +### TKey + +`TKey` *extends* `TStrictly` *extends* `"safely"` ? + \| keyof `TObject` + \| `string` & `Record`\<`never`, `never`\> + \| `number` & `Record`\<`never`, `never`\> + \| `symbol` & `Record`\<`never`, `never`\> : keyof `TObject` + +### TStrictly + +`TStrictly` *extends* `"strictly"` \| `"safely"` = `"strictly"` diff --git a/docs/framework/vue/reference/type-aliases/Override.md b/docs/framework/vue/reference/type-aliases/Override.md new file mode 100644 index 00000000000..8abcecd1e1b --- /dev/null +++ b/docs/framework/vue/reference/type-aliases/Override.md @@ -0,0 +1,20 @@ +--- +id: Override +title: Override +--- + +```ts +type Override = { [AKey in keyof TTargetA]: AKey extends keyof TTargetB ? TTargetB[AKey] : TTargetA[AKey] }; +``` + +Defined in: [packages/query-core/src/types.ts:31](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L31) + +## Type Parameters + +### TTargetA + +`TTargetA` + +### TTargetB + +`TTargetB` diff --git a/docs/framework/vue/reference/type-aliases/PlaceholderDataFunction.md b/docs/framework/vue/reference/type-aliases/PlaceholderDataFunction.md new file mode 100644 index 00000000000..cd40f28b41e --- /dev/null +++ b/docs/framework/vue/reference/type-aliases/PlaceholderDataFunction.md @@ -0,0 +1,42 @@ +--- +id: PlaceholderDataFunction +title: PlaceholderDataFunction +--- + +```ts +type PlaceholderDataFunction = (previousData, previousQuery) => TQueryData | undefined; +``` + +Defined in: [packages/query-core/src/types.ts:177](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L177) + +## Type Parameters + +### TQueryFnData + +`TQueryFnData` = `unknown` + +### TError + +`TError` = [`DefaultError`](DefaultError.md) + +### TQueryData + +`TQueryData` = `TQueryFnData` + +### TQueryKey + +`TQueryKey` *extends* [`QueryKey`](QueryKey.md) = [`QueryKey`](QueryKey.md) + +## Parameters + +### previousData + +`TQueryData` | `undefined` + +### previousQuery + +[`Query`](../classes/Query.md)\<`TQueryFnData`, `TError`, `TQueryData`, `TQueryKey`\> | `undefined` + +## Returns + +`TQueryData` \| `undefined` diff --git a/docs/framework/vue/reference/type-aliases/QueriesPlaceholderDataFunction.md b/docs/framework/vue/reference/type-aliases/QueriesPlaceholderDataFunction.md new file mode 100644 index 00000000000..5d3fca8c9e0 --- /dev/null +++ b/docs/framework/vue/reference/type-aliases/QueriesPlaceholderDataFunction.md @@ -0,0 +1,30 @@ +--- +id: QueriesPlaceholderDataFunction +title: QueriesPlaceholderDataFunction +--- + +```ts +type QueriesPlaceholderDataFunction = (previousData, previousQuery) => TQueryData | undefined; +``` + +Defined in: [packages/query-core/src/types.ts:187](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L187) + +## Type Parameters + +### TQueryData + +`TQueryData` + +## Parameters + +### previousData + +`undefined` + +### previousQuery + +`undefined` + +## Returns + +`TQueryData` \| `undefined` diff --git a/docs/framework/vue/reference/type-aliases/QueryBooleanOption.md b/docs/framework/vue/reference/type-aliases/QueryBooleanOption.md new file mode 100644 index 00000000000..9759e3ddb42 --- /dev/null +++ b/docs/framework/vue/reference/type-aliases/QueryBooleanOption.md @@ -0,0 +1,28 @@ +--- +id: QueryBooleanOption +title: QueryBooleanOption +--- + +```ts +type QueryBooleanOption = boolean | (query) => boolean; +``` + +Defined in: [packages/query-core/src/types.ts:119](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L119) + +## Type Parameters + +### TQueryFnData + +`TQueryFnData` = `unknown` + +### TError + +`TError` = [`DefaultError`](DefaultError.md) + +### TData + +`TData` = `TQueryFnData` + +### TQueryKey + +`TQueryKey` *extends* [`QueryKey`](QueryKey.md) = [`QueryKey`](QueryKey.md) diff --git a/docs/framework/vue/reference/type-aliases/QueryCacheNotifyEvent.md b/docs/framework/vue/reference/type-aliases/QueryCacheNotifyEvent.md new file mode 100644 index 00000000000..b92c76fb826 --- /dev/null +++ b/docs/framework/vue/reference/type-aliases/QueryCacheNotifyEvent.md @@ -0,0 +1,21 @@ +--- +id: QueryCacheNotifyEvent +title: QueryCacheNotifyEvent +--- + +```ts +type QueryCacheNotifyEvent = + | NotifyEventQueryAdded + | NotifyEventQueryRemoved + | NotifyEventQueryUpdated + | NotifyEventQueryObserverAdded + | NotifyEventQueryObserverRemoved + | NotifyEventQueryObserverResultsUpdated + | NotifyEventQueryObserverOptionsUpdated; +``` + +Defined in: [packages/query-core/src/queryCache.ts:85](https://github.com/TanStack/query/blob/main/packages/query-core/src/queryCache.ts#L85) + +The event passed to a `QueryCache` subscriber. Fired whenever a query is added or removed from +the cache, its state is updated (e.g. via `query.setState` or `queryClient.removeQueries`), or +one of its observers is added, removed, or has its results or options updated. diff --git a/docs/framework/vue/reference/type-aliases/QueryFilters.md b/docs/framework/vue/reference/type-aliases/QueryFilters.md index d8d3f13d56b..0032552ec39 100644 --- a/docs/framework/vue/reference/type-aliases/QueryFilters.md +++ b/docs/framework/vue/reference/type-aliases/QueryFilters.md @@ -7,4 +7,4 @@ title: QueryFilters type QueryFilters = MaybeRefDeep | () => MaybeRefDeep; ``` -Defined in: [vue-query/src/useIsFetching.ts:9](https://github.com/TanStack/query/blob/main/packages/vue-query/src/useIsFetching.ts#L9) +Defined in: [packages/vue-query/src/useIsFetching.ts:9](https://github.com/TanStack/query/blob/main/packages/vue-query/src/useIsFetching.ts#L9) diff --git a/docs/framework/vue/reference/type-aliases/QueryFunction.md b/docs/framework/vue/reference/type-aliases/QueryFunction.md new file mode 100644 index 00000000000..306367388a1 --- /dev/null +++ b/docs/framework/vue/reference/type-aliases/QueryFunction.md @@ -0,0 +1,34 @@ +--- +id: QueryFunction +title: QueryFunction +--- + +```ts +type QueryFunction = (context) => T | Promise; +``` + +Defined in: [packages/query-core/src/types.ts:102](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L102) + +## Type Parameters + +### T + +`T` = `unknown` + +### TQueryKey + +`TQueryKey` *extends* [`QueryKey`](QueryKey.md) = [`QueryKey`](QueryKey.md) + +### TPageParam + +`TPageParam` = `never` + +## Parameters + +### context + +[`QueryFunctionContext`](QueryFunctionContext.md)\<`TQueryKey`, `TPageParam`\> + +## Returns + +`T` \| `Promise`\<`T`\> diff --git a/docs/framework/vue/reference/type-aliases/QueryFunctionContext.md b/docs/framework/vue/reference/type-aliases/QueryFunctionContext.md new file mode 100644 index 00000000000..d2c9fe3e2b2 --- /dev/null +++ b/docs/framework/vue/reference/type-aliases/QueryFunctionContext.md @@ -0,0 +1,20 @@ +--- +id: QueryFunctionContext +title: QueryFunctionContext +--- + +```ts +type QueryFunctionContext = [TPageParam] extends [never] ? object : object; +``` + +Defined in: [packages/query-core/src/types.ts:144](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L144) + +## Type Parameters + +### TQueryKey + +`TQueryKey` *extends* [`QueryKey`](QueryKey.md) = [`QueryKey`](QueryKey.md) + +### TPageParam + +`TPageParam` = `never` diff --git a/docs/framework/vue/reference/type-aliases/QueryKey.md b/docs/framework/vue/reference/type-aliases/QueryKey.md new file mode 100644 index 00000000000..1a3f34cde18 --- /dev/null +++ b/docs/framework/vue/reference/type-aliases/QueryKey.md @@ -0,0 +1,10 @@ +--- +id: QueryKey +title: QueryKey +--- + +```ts +type QueryKey = Register extends object ? TQueryKey extends ReadonlyArray ? TQueryKey : TQueryKey extends unknown[] ? TQueryKey : ReadonlyArray : ReadonlyArray; +``` + +Defined in: [packages/query-core/src/types.ts:51](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L51) diff --git a/docs/framework/vue/reference/type-aliases/QueryKeyHashFunction.md b/docs/framework/vue/reference/type-aliases/QueryKeyHashFunction.md new file mode 100644 index 00000000000..feda96373cc --- /dev/null +++ b/docs/framework/vue/reference/type-aliases/QueryKeyHashFunction.md @@ -0,0 +1,26 @@ +--- +id: QueryKeyHashFunction +title: QueryKeyHashFunction +--- + +```ts +type QueryKeyHashFunction = (queryKey) => string; +``` + +Defined in: [packages/query-core/src/types.ts:192](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L192) + +## Type Parameters + +### TQueryKey + +`TQueryKey` *extends* [`QueryKey`](QueryKey.md) + +## Parameters + +### queryKey + +`TQueryKey` + +## Returns + +`string` diff --git a/docs/framework/vue/reference/type-aliases/QueryKeyWithDataTag.md b/docs/framework/vue/reference/type-aliases/QueryKeyWithDataTag.md new file mode 100644 index 00000000000..6613f74be9e --- /dev/null +++ b/docs/framework/vue/reference/type-aliases/QueryKeyWithDataTag.md @@ -0,0 +1,34 @@ +--- +id: QueryKeyWithDataTag +title: QueryKeyWithDataTag +--- + +```ts +type QueryKeyWithDataTag = object; +``` + +Defined in: [packages/query-core/src/types.ts:82](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L82) + +## Type Parameters + +### TQueryKey + +`TQueryKey` *extends* [`QueryKey`](QueryKey.md) = [`QueryKey`](QueryKey.md) + +### TQueryFnData + +`TQueryFnData` = `unknown` + +### TError + +`TError` = [`DefaultError`](DefaultError.md) + +## Properties + +### queryKey + +```ts +queryKey: DataTag; +``` + +Defined in: [packages/query-core/src/types.ts:87](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L87) diff --git a/docs/framework/vue/reference/type-aliases/QueryMeta.md b/docs/framework/vue/reference/type-aliases/QueryMeta.md new file mode 100644 index 00000000000..c12917b2cce --- /dev/null +++ b/docs/framework/vue/reference/type-aliases/QueryMeta.md @@ -0,0 +1,10 @@ +--- +id: QueryMeta +title: QueryMeta +--- + +```ts +type QueryMeta = Register extends object ? TQueryMeta extends Record ? TQueryMeta : Record : Record; +``` + +Defined in: [packages/query-core/src/types.ts:215](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L215) diff --git a/docs/framework/vue/reference/type-aliases/QueryObserverResult.md b/docs/framework/vue/reference/type-aliases/QueryObserverResult.md new file mode 100644 index 00000000000..5138b635f2c --- /dev/null +++ b/docs/framework/vue/reference/type-aliases/QueryObserverResult.md @@ -0,0 +1,25 @@ +--- +id: QueryObserverResult +title: QueryObserverResult +--- + +```ts +type QueryObserverResult = + | DefinedQueryObserverResult + | QueryObserverLoadingErrorResult + | QueryObserverLoadingResult + | QueryObserverPendingResult +| QueryObserverPlaceholderResult; +``` + +Defined in: [packages/query-core/src/types.ts:994](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L994) + +## Type Parameters + +### TData + +`TData` = `unknown` + +### TError + +`TError` = [`DefaultError`](DefaultError.md) diff --git a/docs/framework/vue/reference/type-aliases/QueryOptions.md b/docs/framework/vue/reference/type-aliases/QueryOptions.md index 5ef9644fef2..42502ad378a 100644 --- a/docs/framework/vue/reference/type-aliases/QueryOptions.md +++ b/docs/framework/vue/reference/type-aliases/QueryOptions.md @@ -7,7 +7,7 @@ title: QueryOptions type QueryOptions = { [Property in keyof QueryObserverOptions]: Property extends "enabled" ? MaybeRefOrGetter | (() => QueryBooleanOption>) : Property extends "queryKey" ? MaybeRefOrGetter : QueryObserverOptions>[Property] } & ShallowOption; ``` -Defined in: [vue-query/src/queryOptions.ts:35](https://github.com/TanStack/query/blob/main/packages/vue-query/src/queryOptions.ts#L35) +Defined in: [packages/vue-query/src/queryOptions.ts:35](https://github.com/TanStack/query/blob/main/packages/vue-query/src/queryOptions.ts#L35) The options accepted by `queryOptions`, `useQuery`, and the other query hooks. `enabled` tracks reactive dependencies automatically as a `ref`, a plain value, or a reactive getter (`() => ...`). `queryKey` reacts @@ -34,7 +34,7 @@ The type your `queryFn` resolves to. ### TError -`TError` = `DefaultError` +`TError` = [`DefaultError`](DefaultError.md) The type of errors your `queryFn` may throw. @@ -53,6 +53,6 @@ The type of data stored in the cache, before `select` runs. Defaults to ### TQueryKey -`TQueryKey` *extends* `QueryKey` = `QueryKey` +`TQueryKey` *extends* [`QueryKey`](QueryKey.md) = [`QueryKey`](QueryKey.md) The type of your `queryKey`. diff --git a/docs/framework/vue/reference/type-aliases/QueryPersister.md b/docs/framework/vue/reference/type-aliases/QueryPersister.md new file mode 100644 index 00000000000..72e80165b0d --- /dev/null +++ b/docs/framework/vue/reference/type-aliases/QueryPersister.md @@ -0,0 +1,24 @@ +--- +id: QueryPersister +title: QueryPersister +--- + +```ts +type QueryPersister = [TPageParam] extends [never] ? (queryFn, context, query) => T | Promise : (queryFn, context, query) => T | Promise; +``` + +Defined in: [packages/query-core/src/types.ts:128](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L128) + +## Type Parameters + +### T + +`T` = `unknown` + +### TQueryKey + +`TQueryKey` *extends* [`QueryKey`](QueryKey.md) = [`QueryKey`](QueryKey.md) + +### TPageParam + +`TPageParam` = `never` diff --git a/docs/framework/vue/reference/type-aliases/QueryStatus.md b/docs/framework/vue/reference/type-aliases/QueryStatus.md new file mode 100644 index 00000000000..bab00f6f423 --- /dev/null +++ b/docs/framework/vue/reference/type-aliases/QueryStatus.md @@ -0,0 +1,10 @@ +--- +id: QueryStatus +title: QueryStatus +--- + +```ts +type QueryStatus = "pending" | "error" | "success"; +``` + +Defined in: [packages/query-core/src/types.ts:761](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L761) diff --git a/docs/framework/vue/reference/type-aliases/SkipToken.md b/docs/framework/vue/reference/type-aliases/SkipToken.md new file mode 100644 index 00000000000..3a5791b982e --- /dev/null +++ b/docs/framework/vue/reference/type-aliases/SkipToken.md @@ -0,0 +1,12 @@ +--- +id: SkipToken +title: SkipToken +--- + +```ts +type SkipToken = typeof skipToken; +``` + +Defined in: [packages/query-core/src/utils.ts:526](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L526) + +The type of the [skipToken](../variables/skipToken.md) sentinel value. diff --git a/docs/framework/vue/reference/type-aliases/StaleTime.md b/docs/framework/vue/reference/type-aliases/StaleTime.md new file mode 100644 index 00000000000..3e7e21608be --- /dev/null +++ b/docs/framework/vue/reference/type-aliases/StaleTime.md @@ -0,0 +1,10 @@ +--- +id: StaleTime +title: StaleTime +--- + +```ts +type StaleTime = number | "static"; +``` + +Defined in: [packages/query-core/src/types.ts:108](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L108) diff --git a/docs/framework/vue/reference/type-aliases/StaleTimeFunction.md b/docs/framework/vue/reference/type-aliases/StaleTimeFunction.md new file mode 100644 index 00000000000..b1c541fa64e --- /dev/null +++ b/docs/framework/vue/reference/type-aliases/StaleTimeFunction.md @@ -0,0 +1,28 @@ +--- +id: StaleTimeFunction +title: StaleTimeFunction +--- + +```ts +type StaleTimeFunction = StaleTime | (query) => StaleTime; +``` + +Defined in: [packages/query-core/src/types.ts:110](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L110) + +## Type Parameters + +### TQueryFnData + +`TQueryFnData` = `unknown` + +### TError + +`TError` = [`DefaultError`](DefaultError.md) + +### TData + +`TData` = `TQueryFnData` + +### TQueryKey + +`TQueryKey` *extends* [`QueryKey`](QueryKey.md) = [`QueryKey`](QueryKey.md) diff --git a/docs/framework/vue/reference/type-aliases/ThrowOnError.md b/docs/framework/vue/reference/type-aliases/ThrowOnError.md new file mode 100644 index 00000000000..134683388ef --- /dev/null +++ b/docs/framework/vue/reference/type-aliases/ThrowOnError.md @@ -0,0 +1,28 @@ +--- +id: ThrowOnError +title: ThrowOnError +--- + +```ts +type ThrowOnError = boolean | (error, query) => boolean; +``` + +Defined in: [packages/query-core/src/types.ts:368](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L368) + +## Type Parameters + +### TQueryFnData + +`TQueryFnData` + +### TError + +`TError` + +### TQueryData + +`TQueryData` + +### TQueryKey + +`TQueryKey` *extends* [`QueryKey`](QueryKey.md) diff --git a/docs/framework/vue/reference/type-aliases/TimeoutCallback.md b/docs/framework/vue/reference/type-aliases/TimeoutCallback.md new file mode 100644 index 00000000000..773b5fdaeb9 --- /dev/null +++ b/docs/framework/vue/reference/type-aliases/TimeoutCallback.md @@ -0,0 +1,27 @@ +--- +id: TimeoutCallback +title: TimeoutCallback +--- + +```ts +type TimeoutCallback = (_) => void; +``` + +Defined in: [packages/query-core/src/timeoutManager.ts:9](https://github.com/TanStack/query/blob/main/packages/query-core/src/timeoutManager.ts#L9) + +[TimeoutManager](../interfaces/TimeoutManager.md) does not support passing arguments to the callback. + +`(_: void)` is the argument type inferred by TypeScript's default typings for +`setTimeout(cb, number)`. +If we don't accept a single void argument, then +`new Promise(resolve => timeoutManager.setTimeout(resolve, N))` is a type error. + +## Parameters + +### \_ + +`void` + +## Returns + +`void` diff --git a/docs/framework/vue/reference/type-aliases/TimeoutProvider.md b/docs/framework/vue/reference/type-aliases/TimeoutProvider.md new file mode 100644 index 00000000000..3509105bcd1 --- /dev/null +++ b/docs/framework/vue/reference/type-aliases/TimeoutProvider.md @@ -0,0 +1,112 @@ +--- +id: TimeoutProvider +title: TimeoutProvider +--- + +```ts +type TimeoutProvider = object; +``` + +Defined in: [packages/query-core/src/timeoutManager.ts:28](https://github.com/TanStack/query/blob/main/packages/query-core/src/timeoutManager.ts#L28) + +Backend for timer functions. + +Timers are performance-sensitive: short-lived timers (delays under a few seconds) tend to be +latency-sensitive, while long-lived ones may benefit more from coalescing — batching timers +with similar deadlines together — which the default provider (backed by the platform's global +`setTimeout`/`setInterval`) does not do. A custom provider can implement coalescing, and can +also support delays longer than the ~24-day maximum of the global `setTimeout`. + +## Type Parameters + +### TTimerId + +`TTimerId` *extends* [`ManagedTimerId`](ManagedTimerId.md) = [`ManagedTimerId`](ManagedTimerId.md) + +## Properties + +### clearInterval() + +```ts +readonly clearInterval: (intervalId) => void; +``` + +Defined in: [packages/query-core/src/timeoutManager.ts:34](https://github.com/TanStack/query/blob/main/packages/query-core/src/timeoutManager.ts#L34) + +#### Parameters + +##### intervalId + +`TTimerId` | `undefined` + +#### Returns + +`void` + +*** + +### clearTimeout() + +```ts +readonly clearTimeout: (timeoutId) => void; +``` + +Defined in: [packages/query-core/src/timeoutManager.ts:31](https://github.com/TanStack/query/blob/main/packages/query-core/src/timeoutManager.ts#L31) + +#### Parameters + +##### timeoutId + +`TTimerId` | `undefined` + +#### Returns + +`void` + +*** + +### setInterval() + +```ts +readonly setInterval: (callback, delay) => TTimerId; +``` + +Defined in: [packages/query-core/src/timeoutManager.ts:33](https://github.com/TanStack/query/blob/main/packages/query-core/src/timeoutManager.ts#L33) + +#### Parameters + +##### callback + +[`TimeoutCallback`](TimeoutCallback.md) + +##### delay + +`number` + +#### Returns + +`TTimerId` + +*** + +### setTimeout() + +```ts +readonly setTimeout: (callback, delay) => TTimerId; +``` + +Defined in: [packages/query-core/src/timeoutManager.ts:30](https://github.com/TanStack/query/blob/main/packages/query-core/src/timeoutManager.ts#L30) + +#### Parameters + +##### callback + +[`TimeoutCallback`](TimeoutCallback.md) + +##### delay + +`number` + +#### Returns + +`TTimerId` diff --git a/docs/framework/vue/reference/type-aliases/UndefinedInitialDataInfiniteOptions.md b/docs/framework/vue/reference/type-aliases/UndefinedInitialDataInfiniteOptions.md index c4dc849c2a5..b92014e908c 100644 --- a/docs/framework/vue/reference/type-aliases/UndefinedInitialDataInfiniteOptions.md +++ b/docs/framework/vue/reference/type-aliases/UndefinedInitialDataInfiniteOptions.md @@ -7,7 +7,7 @@ title: UndefinedInitialDataInfiniteOptions type UndefinedInitialDataInfiniteOptions = UseInfiniteQueryOptions & object; ``` -Defined in: [vue-query/src/infiniteQueryOptions.ts:21](https://github.com/TanStack/query/blob/main/packages/vue-query/src/infiniteQueryOptions.ts#L21) +Defined in: [packages/vue-query/src/infiniteQueryOptions.ts:21](https://github.com/TanStack/query/blob/main/packages/vue-query/src/infiniteQueryOptions.ts#L21) The options accepted by the `infiniteQueryOptions` overload selected when no `initialData` is set — `data` may be `undefined` while the query is `pending`. @@ -30,20 +30,20 @@ The type of a single page, as your `queryFn` resolves it. ### TError -`TError` = `DefaultError` +`TError` = [`DefaultError`](DefaultError.md) The type of errors your `queryFn` may throw. ### TData -`TData` = `InfiniteData`\<`TQueryFnData`\> +`TData` = [`InfiniteData`](../interfaces/InfiniteData.md)\<`TQueryFnData`\> The type `data` ends up as after `select` runs — defaults to `InfiniteData`, the shape of all fetched pages plus their page params. ### TQueryKey -`TQueryKey` *extends* `QueryKey` = `QueryKey` +`TQueryKey` *extends* [`QueryKey`](QueryKey.md) = [`QueryKey`](QueryKey.md) The type of your `queryKey`. diff --git a/docs/framework/vue/reference/type-aliases/UndefinedInitialQueryOptions.md b/docs/framework/vue/reference/type-aliases/UndefinedInitialQueryOptions.md index 96a4386cdf6..7d45fc7c8b4 100644 --- a/docs/framework/vue/reference/type-aliases/UndefinedInitialQueryOptions.md +++ b/docs/framework/vue/reference/type-aliases/UndefinedInitialQueryOptions.md @@ -7,7 +7,7 @@ title: UndefinedInitialQueryOptions type UndefinedInitialQueryOptions = UseQueryOptions & object; ``` -Defined in: [vue-query/src/useQuery.ts:67](https://github.com/TanStack/query/blob/main/packages/vue-query/src/useQuery.ts#L67) +Defined in: [packages/vue-query/src/useQuery.ts:67](https://github.com/TanStack/query/blob/main/packages/vue-query/src/useQuery.ts#L67) ## Type Declaration @@ -27,7 +27,7 @@ optional initialData: ### TError -`TError` = `DefaultError` +`TError` = [`DefaultError`](DefaultError.md) ### TData @@ -35,4 +35,4 @@ optional initialData: ### TQueryKey -`TQueryKey` *extends* `QueryKey` = `QueryKey` +`TQueryKey` *extends* [`QueryKey`](QueryKey.md) = [`QueryKey`](QueryKey.md) diff --git a/docs/framework/vue/reference/type-aliases/UndefinedInitialQueryOptionsWithDataTag.md b/docs/framework/vue/reference/type-aliases/UndefinedInitialQueryOptionsWithDataTag.md index e62b049c1c6..9467eb094ff 100644 --- a/docs/framework/vue/reference/type-aliases/UndefinedInitialQueryOptionsWithDataTag.md +++ b/docs/framework/vue/reference/type-aliases/UndefinedInitialQueryOptionsWithDataTag.md @@ -7,7 +7,7 @@ title: UndefinedInitialQueryOptionsWithDataTag type UndefinedInitialQueryOptionsWithDataTag = UndefinedInitialQueryOptions & QueryKeyWithDataTag; ``` -Defined in: [vue-query/src/queryOptions.ts:123](https://github.com/TanStack/query/blob/main/packages/vue-query/src/queryOptions.ts#L123) +Defined in: [packages/vue-query/src/queryOptions.ts:123](https://github.com/TanStack/query/blob/main/packages/vue-query/src/queryOptions.ts#L123) ## Type Parameters @@ -17,7 +17,7 @@ Defined in: [vue-query/src/queryOptions.ts:123](https://github.com/TanStack/quer ### TError -`TError` = `DefaultError` +`TError` = [`DefaultError`](DefaultError.md) ### TData @@ -25,4 +25,4 @@ Defined in: [vue-query/src/queryOptions.ts:123](https://github.com/TanStack/quer ### TQueryKey -`TQueryKey` *extends* `QueryKey` = `QueryKey` +`TQueryKey` *extends* [`QueryKey`](QueryKey.md) = [`QueryKey`](QueryKey.md) diff --git a/docs/framework/vue/reference/type-aliases/UnsetMarker.md b/docs/framework/vue/reference/type-aliases/UnsetMarker.md new file mode 100644 index 00000000000..8b9c14e1907 --- /dev/null +++ b/docs/framework/vue/reference/type-aliases/UnsetMarker.md @@ -0,0 +1,10 @@ +--- +id: UnsetMarker +title: UnsetMarker +--- + +```ts +type UnsetMarker = typeof unsetMarker; +``` + +Defined in: [packages/query-core/src/types.ts:66](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L66) diff --git a/docs/framework/vue/reference/type-aliases/Updater.md b/docs/framework/vue/reference/type-aliases/Updater.md new file mode 100644 index 00000000000..7a0c2f30503 --- /dev/null +++ b/docs/framework/vue/reference/type-aliases/Updater.md @@ -0,0 +1,35 @@ +--- +id: Updater +title: Updater +--- + +```ts +type Updater = TOutput | (input) => TOutput; +``` + +Defined in: [packages/query-core/src/utils.ts:105](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L105) + +Either a plain value of type `TOutput`, or a function that receives `TInput` and returns `TOutput`. +Used for example by `setQueryData`-style updaters, which accept either the new data directly or a +function that computes it from the previous data. See functionalUpdate. + +## Type Parameters + +### TInput + +`TInput` + +### TOutput + +`TOutput` + +## Example + +```ts +queryClient.setQueryData(['posts'], newPosts) + +// Or, using an updater function that receives the current data: +queryClient.setQueryData(['posts'], (oldPosts) => + oldPosts ? [...oldPosts, newPost] : oldPosts, +) +``` diff --git a/docs/framework/vue/reference/type-aliases/UseInfiniteQueryOptions.md b/docs/framework/vue/reference/type-aliases/UseInfiniteQueryOptions.md index 84008107bd2..339888b2926 100644 --- a/docs/framework/vue/reference/type-aliases/UseInfiniteQueryOptions.md +++ b/docs/framework/vue/reference/type-aliases/UseInfiniteQueryOptions.md @@ -7,7 +7,7 @@ title: UseInfiniteQueryOptions type UseInfiniteQueryOptions = MaybeRef<{ [Property in keyof InfiniteQueryObserverOptions]: Property extends "enabled" ? MaybeRefOrGetter, TPageParam>[Property]> : MaybeRefDeep, TPageParam>[Property]> } & ShallowOption>; ``` -Defined in: [vue-query/src/useInfiniteQuery.ts:27](https://github.com/TanStack/query/blob/main/packages/vue-query/src/useInfiniteQuery.ts#L27) +Defined in: [packages/vue-query/src/useInfiniteQuery.ts:27](https://github.com/TanStack/query/blob/main/packages/vue-query/src/useInfiniteQuery.ts#L27) ## Type Parameters @@ -17,7 +17,7 @@ Defined in: [vue-query/src/useInfiniteQuery.ts:27](https://github.com/TanStack/q ### TError -`TError` = `DefaultError` +`TError` = [`DefaultError`](DefaultError.md) ### TData @@ -25,7 +25,7 @@ Defined in: [vue-query/src/useInfiniteQuery.ts:27](https://github.com/TanStack/q ### TQueryKey -`TQueryKey` *extends* `QueryKey` = `QueryKey` +`TQueryKey` *extends* [`QueryKey`](QueryKey.md) = [`QueryKey`](QueryKey.md) ### TPageParam diff --git a/docs/framework/vue/reference/type-aliases/UseInfiniteQueryReturnType.md b/docs/framework/vue/reference/type-aliases/UseInfiniteQueryReturnType.md index 8e8040cead3..d20d3262153 100644 --- a/docs/framework/vue/reference/type-aliases/UseInfiniteQueryReturnType.md +++ b/docs/framework/vue/reference/type-aliases/UseInfiniteQueryReturnType.md @@ -7,7 +7,7 @@ title: UseInfiniteQueryReturnType type UseInfiniteQueryReturnType = UseBaseQueryReturnType>; ``` -Defined in: [vue-query/src/useInfiniteQuery.ts:63](https://github.com/TanStack/query/blob/main/packages/vue-query/src/useInfiniteQuery.ts#L63) +Defined in: [packages/vue-query/src/useInfiniteQuery.ts:63](https://github.com/TanStack/query/blob/main/packages/vue-query/src/useInfiniteQuery.ts#L63) ## Type Parameters diff --git a/docs/framework/vue/reference/type-aliases/UseMutationOptions.md b/docs/framework/vue/reference/type-aliases/UseMutationOptions.md index bd2d6da1012..c00317b956e 100644 --- a/docs/framework/vue/reference/type-aliases/UseMutationOptions.md +++ b/docs/framework/vue/reference/type-aliases/UseMutationOptions.md @@ -9,7 +9,7 @@ type UseMutationOptions = | () => MaybeRefDeep>; ``` -Defined in: [vue-query/src/useMutation.ts:31](https://github.com/TanStack/query/blob/main/packages/vue-query/src/useMutation.ts#L31) +Defined in: [packages/vue-query/src/useMutation.ts:31](https://github.com/TanStack/query/blob/main/packages/vue-query/src/useMutation.ts#L31) ## Type Parameters @@ -19,7 +19,7 @@ Defined in: [vue-query/src/useMutation.ts:31](https://github.com/TanStack/query/ ### TError -`TError` = `DefaultError` +`TError` = [`DefaultError`](DefaultError.md) ### TVariables diff --git a/docs/framework/vue/reference/type-aliases/UseMutationReturnType.md b/docs/framework/vue/reference/type-aliases/UseMutationReturnType.md index 1c19828e046..a16b79b33d6 100644 --- a/docs/framework/vue/reference/type-aliases/UseMutationReturnType.md +++ b/docs/framework/vue/reference/type-aliases/UseMutationReturnType.md @@ -7,7 +7,7 @@ title: UseMutationReturnType type UseMutationReturnType = ToRefs> & object; ``` -Defined in: [vue-query/src/useMutation.ts:53](https://github.com/TanStack/query/blob/main/packages/vue-query/src/useMutation.ts#L53) +Defined in: [packages/vue-query/src/useMutation.ts:53](https://github.com/TanStack/query/blob/main/packages/vue-query/src/useMutation.ts#L53) ## Type Declaration diff --git a/docs/framework/vue/reference/type-aliases/UsePrefetchInfiniteQueryOptions.md b/docs/framework/vue/reference/type-aliases/UsePrefetchInfiniteQueryOptions.md index 6453240fbd1..1a0493ab1c9 100644 --- a/docs/framework/vue/reference/type-aliases/UsePrefetchInfiniteQueryOptions.md +++ b/docs/framework/vue/reference/type-aliases/UsePrefetchInfiniteQueryOptions.md @@ -7,7 +7,7 @@ title: UsePrefetchInfiniteQueryOptions type UsePrefetchInfiniteQueryOptions = DistributiveOmit, "queryFn"> & object; ``` -Defined in: [vue-query/src/usePrefetchInfiniteQuery.ts:16](https://github.com/TanStack/query/blob/main/packages/vue-query/src/usePrefetchInfiniteQuery.ts#L16) +Defined in: [packages/vue-query/src/usePrefetchInfiniteQuery.ts:16](https://github.com/TanStack/query/blob/main/packages/vue-query/src/usePrefetchInfiniteQuery.ts#L16) ## Type Declaration @@ -33,7 +33,7 @@ optional queryFn: Exclude = OmitKeyof, "queryFn"> & object; ``` -Defined in: [vue-query/src/usePrefetchQuery.ts:15](https://github.com/TanStack/query/blob/main/packages/vue-query/src/usePrefetchQuery.ts#L15) +Defined in: [packages/vue-query/src/usePrefetchQuery.ts:15](https://github.com/TanStack/query/blob/main/packages/vue-query/src/usePrefetchQuery.ts#L15) ## Type Declaration @@ -37,4 +37,4 @@ optional queryFn: Exclude = TDepth["length"] extends MAXIMUM_DEPTH ? UseQueryOptionsForUseQueries[] : T extends [] ? [] : T extends [infer Head] ? [...TResults, GetUseQueryOptionsForUseQueries] : T extends [infer Head, ...(infer Tails)] ? UseQueriesOptions<[...Tails], [...TResults, GetUseQueryOptionsForUseQueries], [...TDepth, 1]> : ReadonlyArray extends T ? T : T extends UseQueryOptionsForUseQueries[] ? UseQueryOptionsForUseQueries[] : UseQueryOptionsForUseQueries[]; ``` -Defined in: [vue-query/src/useQueries.ts:170](https://github.com/TanStack/query/blob/main/packages/vue-query/src/useQueries.ts#L170) +Defined in: [packages/vue-query/src/useQueries.ts:170](https://github.com/TanStack/query/blob/main/packages/vue-query/src/useQueries.ts#L170) UseQueriesOptions reducer recursively unwraps function arguments to infer/enforce type param diff --git a/docs/framework/vue/reference/type-aliases/UseQueriesResults.md b/docs/framework/vue/reference/type-aliases/UseQueriesResults.md index 69659a1c8af..2cfa764c2c5 100644 --- a/docs/framework/vue/reference/type-aliases/UseQueriesResults.md +++ b/docs/framework/vue/reference/type-aliases/UseQueriesResults.md @@ -7,7 +7,7 @@ title: UseQueriesResults type UseQueriesResults = TDepth["length"] extends MAXIMUM_DEPTH ? QueryObserverResult[] : T extends [] ? [] : T extends [infer Head] ? [...TResults, GetUseQueryResult] : T extends [infer Head, ...(infer Tails)] ? UseQueriesResults<[...Tails], [...TResults, GetUseQueryResult], [...TDepth, 1]> : { [K in keyof T]: GetUseQueryResult }; ``` -Defined in: [vue-query/src/useQueries.ts:212](https://github.com/TanStack/query/blob/main/packages/vue-query/src/useQueries.ts#L212) +Defined in: [packages/vue-query/src/useQueries.ts:212](https://github.com/TanStack/query/blob/main/packages/vue-query/src/useQueries.ts#L212) UseQueriesResults reducer recursively maps type param to results diff --git a/docs/framework/vue/reference/type-aliases/UseQueryDefinedReturnType.md b/docs/framework/vue/reference/type-aliases/UseQueryDefinedReturnType.md index b55e4985742..47238aef1b2 100644 --- a/docs/framework/vue/reference/type-aliases/UseQueryDefinedReturnType.md +++ b/docs/framework/vue/reference/type-aliases/UseQueryDefinedReturnType.md @@ -7,7 +7,7 @@ title: UseQueryDefinedReturnType type UseQueryDefinedReturnType = UseBaseQueryReturnType>; ``` -Defined in: [vue-query/src/useQuery.ts:95](https://github.com/TanStack/query/blob/main/packages/vue-query/src/useQuery.ts#L95) +Defined in: [packages/vue-query/src/useQuery.ts:95](https://github.com/TanStack/query/blob/main/packages/vue-query/src/useQuery.ts#L95) ## Type Parameters diff --git a/docs/framework/vue/reference/type-aliases/UseQueryOptions.md b/docs/framework/vue/reference/type-aliases/UseQueryOptions.md index 6a240ccbf6c..0aadddad555 100644 --- a/docs/framework/vue/reference/type-aliases/UseQueryOptions.md +++ b/docs/framework/vue/reference/type-aliases/UseQueryOptions.md @@ -7,7 +7,7 @@ title: UseQueryOptions type UseQueryOptions = MaybeRef<{ [Property in keyof QueryObserverOptions]: Property extends "enabled" ? MaybeRefOrGetter | (() => QueryBooleanOption>) : Property extends "queryKey" ? MaybeRef[Property]> : MaybeRefDeep>[Property]> } & ShallowOption>; ``` -Defined in: [vue-query/src/useQuery.ts:22](https://github.com/TanStack/query/blob/main/packages/vue-query/src/useQuery.ts#L22) +Defined in: [packages/vue-query/src/useQuery.ts:22](https://github.com/TanStack/query/blob/main/packages/vue-query/src/useQuery.ts#L22) ## Type Parameters @@ -17,7 +17,7 @@ Defined in: [vue-query/src/useQuery.ts:22](https://github.com/TanStack/query/blo ### TError -`TError` = `DefaultError` +`TError` = [`DefaultError`](DefaultError.md) ### TData @@ -29,4 +29,4 @@ Defined in: [vue-query/src/useQuery.ts:22](https://github.com/TanStack/query/blo ### TQueryKey -`TQueryKey` *extends* `QueryKey` = `QueryKey` +`TQueryKey` *extends* [`QueryKey`](QueryKey.md) = [`QueryKey`](QueryKey.md) diff --git a/docs/framework/vue/reference/type-aliases/UseQueryReturnType.md b/docs/framework/vue/reference/type-aliases/UseQueryReturnType.md index a9272507e8c..ab1849e9b9a 100644 --- a/docs/framework/vue/reference/type-aliases/UseQueryReturnType.md +++ b/docs/framework/vue/reference/type-aliases/UseQueryReturnType.md @@ -7,7 +7,7 @@ title: UseQueryReturnType type UseQueryReturnType = UseBaseQueryReturnType; ``` -Defined in: [vue-query/src/useQuery.ts:90](https://github.com/TanStack/query/blob/main/packages/vue-query/src/useQuery.ts#L90) +Defined in: [packages/vue-query/src/useQuery.ts:90](https://github.com/TanStack/query/blob/main/packages/vue-query/src/useQuery.ts#L90) ## Type Parameters diff --git a/docs/framework/vue/reference/type-aliases/VueQueryPluginOptions.md b/docs/framework/vue/reference/type-aliases/VueQueryPluginOptions.md index 5e8508f30b4..2bbbb106849 100644 --- a/docs/framework/vue/reference/type-aliases/VueQueryPluginOptions.md +++ b/docs/framework/vue/reference/type-aliases/VueQueryPluginOptions.md @@ -7,4 +7,4 @@ title: VueQueryPluginOptions type VueQueryPluginOptions = ConfigOptions | ClientOptions; ``` -Defined in: [vue-query/src/vueQueryPlugin.ts:38](https://github.com/TanStack/query/blob/main/packages/vue-query/src/vueQueryPlugin.ts#L38) +Defined in: [packages/vue-query/src/vueQueryPlugin.ts:38](https://github.com/TanStack/query/blob/main/packages/vue-query/src/vueQueryPlugin.ts#L38) diff --git a/docs/framework/vue/reference/type-aliases/WithRequired.md b/docs/framework/vue/reference/type-aliases/WithRequired.md new file mode 100644 index 00000000000..a40a48c865b --- /dev/null +++ b/docs/framework/vue/reference/type-aliases/WithRequired.md @@ -0,0 +1,20 @@ +--- +id: WithRequired +title: WithRequired +--- + +```ts +type WithRequired = TTarget & { [_ in TKey]: {} }; +``` + +Defined in: [packages/query-core/src/types.ts:524](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L524) + +## Type Parameters + +### TTarget + +`TTarget` + +### TKey + +`TKey` *extends* keyof `TTarget` diff --git a/docs/framework/vue/reference/type-aliases/dataTagErrorSymbol.md b/docs/framework/vue/reference/type-aliases/dataTagErrorSymbol.md new file mode 100644 index 00000000000..26148a94d6e --- /dev/null +++ b/docs/framework/vue/reference/type-aliases/dataTagErrorSymbol.md @@ -0,0 +1,10 @@ +--- +id: dataTagErrorSymbol +title: dataTagErrorSymbol +--- + +```ts +type dataTagErrorSymbol = typeof dataTagErrorSymbol; +``` + +Defined in: [packages/query-core/src/types.ts:63](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L63) diff --git a/docs/framework/vue/reference/type-aliases/dataTagSymbol.md b/docs/framework/vue/reference/type-aliases/dataTagSymbol.md new file mode 100644 index 00000000000..0012c108cc5 --- /dev/null +++ b/docs/framework/vue/reference/type-aliases/dataTagSymbol.md @@ -0,0 +1,10 @@ +--- +id: dataTagSymbol +title: dataTagSymbol +--- + +```ts +type dataTagSymbol = typeof dataTagSymbol; +``` + +Defined in: [packages/query-core/src/types.ts:61](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L61) diff --git a/docs/framework/vue/reference/variables/VueQueryPlugin.md b/docs/framework/vue/reference/variables/VueQueryPlugin.md index 735e850b403..e9e86acf38e 100644 --- a/docs/framework/vue/reference/variables/VueQueryPlugin.md +++ b/docs/framework/vue/reference/variables/VueQueryPlugin.md @@ -7,7 +7,7 @@ title: VueQueryPlugin const VueQueryPlugin: object; ``` -Defined in: [vue-query/src/vueQueryPlugin.ts:74](https://github.com/TanStack/query/blob/main/packages/vue-query/src/vueQueryPlugin.ts#L74) +Defined in: [packages/vue-query/src/vueQueryPlugin.ts:74](https://github.com/TanStack/query/blob/main/packages/vue-query/src/vueQueryPlugin.ts#L74) Installs a `QueryClient` on the Vue app, making it available to every descendant component through `useQueryClient` — the Vue equivalent of React's `QueryClientProvider`, but wired up as an app-level plugin diff --git a/docs/framework/vue/reference/variables/dataTagErrorSymbol.md b/docs/framework/vue/reference/variables/dataTagErrorSymbol.md new file mode 100644 index 00000000000..20bab62fb01 --- /dev/null +++ b/docs/framework/vue/reference/variables/dataTagErrorSymbol.md @@ -0,0 +1,10 @@ +--- +id: dataTagErrorSymbol +title: dataTagErrorSymbol +--- + +```ts +const dataTagErrorSymbol: typeof dataTagErrorSymbol; +``` + +Defined in: [packages/query-core/src/types.ts:63](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L63) diff --git a/docs/framework/vue/reference/variables/dataTagSymbol.md b/docs/framework/vue/reference/variables/dataTagSymbol.md new file mode 100644 index 00000000000..83dd68a56e9 --- /dev/null +++ b/docs/framework/vue/reference/variables/dataTagSymbol.md @@ -0,0 +1,10 @@ +--- +id: dataTagSymbol +title: dataTagSymbol +--- + +```ts +const dataTagSymbol: typeof dataTagSymbol; +``` + +Defined in: [packages/query-core/src/types.ts:61](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L61) diff --git a/docs/framework/vue/reference/variables/defaultScheduler.md b/docs/framework/vue/reference/variables/defaultScheduler.md new file mode 100644 index 00000000000..70e14d3f846 --- /dev/null +++ b/docs/framework/vue/reference/variables/defaultScheduler.md @@ -0,0 +1,13 @@ +--- +id: defaultScheduler +title: defaultScheduler +--- + +```ts +const defaultScheduler: ScheduleFunction = systemSetTimeoutZero; +``` + +Defined in: [packages/query-core/src/notifyManager.ts:19](https://github.com/TanStack/query/blob/main/packages/query-core/src/notifyManager.ts#L19) + +Default scheduling function used by the notify manager. +Schedules the callback with the system's `setTimeout(callback, 0)`. diff --git a/docs/framework/vue/reference/variables/environmentManager.md b/docs/framework/vue/reference/variables/environmentManager.md new file mode 100644 index 00000000000..ed333b8747b --- /dev/null +++ b/docs/framework/vue/reference/variables/environmentManager.md @@ -0,0 +1,59 @@ +--- +id: environmentManager +title: environmentManager +--- + +```ts +const environmentManager: object; +``` + +Defined in: [packages/query-core/src/environmentManager.ts:29](https://github.com/TanStack/query/blob/main/packages/query-core/src/environmentManager.ts#L29) + +Manages how TanStack Query detects whether the current runtime should be treated as +server-side, which disables scheduling refetch timers and changes the default `retry` count +and `gcTime`. By default, the detection treats a missing `window` (or the presence of a +`Deno` global) as server. + +Override this for runtimes where that default detection would give the wrong answer — for +example, a Service Worker, where `window` is undefined even though the environment should +behave like a client. + +## Type Declaration + +### isServer() + +```ts +isServer: () => boolean; +``` + +Returns whether the current runtime should be treated as a server environment. + +#### Returns + +`boolean` + +### setIsServer() + +```ts +setIsServer(isServerValue): void; +``` + +Overrides the server check globally. + +#### Parameters + +##### isServerValue + +`IsServerValue` + +#### Returns + +`void` + +## Example + +```ts +import { environmentManager } from '@tanstack/query-core' + +environmentManager.setIsServer(() => false) +``` diff --git a/docs/framework/vue/reference/variables/focusManager.md b/docs/framework/vue/reference/variables/focusManager.md new file mode 100644 index 00000000000..86477849e06 --- /dev/null +++ b/docs/framework/vue/reference/variables/focusManager.md @@ -0,0 +1,12 @@ +--- +id: focusManager +title: focusManager +--- + +```ts +const focusManager: FocusManager; +``` + +Defined in: [packages/query-core/src/focusManager.ts:142](https://github.com/TanStack/query/blob/main/packages/query-core/src/focusManager.ts#L142) + +Singleton instance of [FocusManager](../interfaces/FocusManager.md), used to manage and observe the focus state within TanStack Query. diff --git a/docs/framework/vue/reference/variables/isServer.md b/docs/framework/vue/reference/variables/isServer.md new file mode 100644 index 00000000000..16aa39d1244 --- /dev/null +++ b/docs/framework/vue/reference/variables/isServer.md @@ -0,0 +1,14 @@ +--- +id: isServer +title: isServer +--- + +```ts +const isServer: boolean; +``` + +Defined in: [packages/query-core/src/utils.ts:114](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L114) + +## Deprecated + +use `environmentManager.isServer()` instead. diff --git a/docs/framework/vue/reference/variables/notifyManager.md b/docs/framework/vue/reference/variables/notifyManager.md new file mode 100644 index 00000000000..4bdf3478be0 --- /dev/null +++ b/docs/framework/vue/reference/variables/notifyManager.md @@ -0,0 +1,166 @@ +--- +id: notifyManager +title: notifyManager +--- + +```ts +const notifyManager: object; +``` + +Defined in: [packages/query-core/src/notifyManager.ts:144](https://github.com/TanStack/query/blob/main/packages/query-core/src/notifyManager.ts#L144) + +Handles scheduling and batching callbacks in TanStack Query. + +## Type Declaration + +### batch() + +```ts +readonly batch: (callback) => T; +``` + +Batches all updates scheduled inside the passed callback. +This is mainly used internally to optimize query client updating. +Batches can be nested; the queue is only flushed once the outermost `batch` call finishes. +The return value of `callback` is passed through. + +#### Type Parameters + +##### T + +`T` + +#### Parameters + +##### callback + +() => `T` + +#### Returns + +`T` + +### batchCalls() + +```ts +readonly batchCalls: (callback) => BatchCallsCallback; +``` + +All calls to the wrapped function will be batched. + +#### Type Parameters + +##### T + +`T` *extends* `unknown`[] + +#### Parameters + +##### callback + +`BatchCallsCallback`\<`T`\> + +#### Returns + +`BatchCallsCallback`\<`T`\> + +### schedule() + +```ts +schedule: (callback) => void; +``` + +Schedules a function to be run on the next batch. +By default, the batch is run with a `setTimeout`, but this can be configured via `setScheduler`. + +#### Parameters + +##### callback + +`NotifyCallback` + +#### Returns + +`void` + +### setBatchNotifyFunction() + +```ts +readonly setBatchNotifyFunction: (fn) => void; +``` + +Use this method to set a custom function to batch notifications together into a single tick. +Framework adapters use this to plug in their own batching primitive, so that a single query +update only triggers one re-render instead of one per subscriber. + +#### Parameters + +##### fn + +`BatchNotifyFunction` + +#### Returns + +`void` + +#### Example + +```ts +import { notifyManager } from '@tanstack/query-core' +import { batch } from 'solid-js' + +notifyManager.setBatchNotifyFunction(batch) +``` + +### setNotifyFunction() + +```ts +readonly setNotifyFunction: (fn) => void; +``` + +Use this method to set a custom notify function. +This can be used to for example wrap notifications with `React.act` while running tests. + +#### Parameters + +##### fn + +`NotifyFunction` + +#### Returns + +`void` + +### setScheduler() + +```ts +readonly setScheduler: (fn) => void; +``` + +Configures a custom callback that schedules when the next batch runs. +The default behavior is `setTimeout(callback, 0)`. + +#### Parameters + +##### fn + +`ScheduleFunction` + +#### Returns + +`void` + +#### Example + +```ts +import { notifyManager } from '@tanstack/query-core' + +// Schedule batches in the next microtask +notifyManager.setScheduler(queueMicrotask) + +// Schedule batches before the next frame is rendered +notifyManager.setScheduler(requestAnimationFrame) + +// Schedule batches some time in the future +notifyManager.setScheduler((cb) => setTimeout(cb, 10)) +``` diff --git a/docs/framework/vue/reference/variables/onlineManager.md b/docs/framework/vue/reference/variables/onlineManager.md new file mode 100644 index 00000000000..2eeec5385d8 --- /dev/null +++ b/docs/framework/vue/reference/variables/onlineManager.md @@ -0,0 +1,12 @@ +--- +id: onlineManager +title: onlineManager +--- + +```ts +const onlineManager: OnlineManager; +``` + +Defined in: [packages/query-core/src/onlineManager.ts:117](https://github.com/TanStack/query/blob/main/packages/query-core/src/onlineManager.ts#L117) + +Singleton instance of [OnlineManager](../interfaces/OnlineManager.md), used to manage and observe the online state within TanStack Query. diff --git a/docs/framework/vue/reference/variables/skipToken.md b/docs/framework/vue/reference/variables/skipToken.md new file mode 100644 index 00000000000..a390d0b7b66 --- /dev/null +++ b/docs/framework/vue/reference/variables/skipToken.md @@ -0,0 +1,23 @@ +--- +id: skipToken +title: skipToken +--- + +```ts +const skipToken: typeof skipToken; +``` + +Defined in: [packages/query-core/src/utils.ts:522](https://github.com/TanStack/query/blob/main/packages/query-core/src/utils.ts#L522) + +Sentinel value that can be passed as a query's `queryFn` to conditionally disable the query (equivalent +to `enabled: false`) while preserving full type inference for the query's data. Unlike `enabled: false`, +a query disabled via `skipToken` cannot be triggered with `refetch`. + +## Example + +```ts +new QueryObserver(queryClient, { + queryKey: ['post', postId], + queryFn: postId != null ? () => fetchPost(postId) : skipToken, +}) +``` diff --git a/docs/framework/vue/reference/variables/timeoutManager.md b/docs/framework/vue/reference/variables/timeoutManager.md new file mode 100644 index 00000000000..1eca1a5f343 --- /dev/null +++ b/docs/framework/vue/reference/variables/timeoutManager.md @@ -0,0 +1,12 @@ +--- +id: timeoutManager +title: timeoutManager +--- + +```ts +const timeoutManager: TimeoutManager; +``` + +Defined in: [packages/query-core/src/timeoutManager.ts:232](https://github.com/TanStack/query/blob/main/packages/query-core/src/timeoutManager.ts#L232) + +Singleton instance of [TimeoutManager](../interfaces/TimeoutManager.md), used throughout TanStack Query to schedule and cancel timers. diff --git a/docs/framework/vue/reference/variables/unsetMarker.md b/docs/framework/vue/reference/variables/unsetMarker.md new file mode 100644 index 00000000000..d19ee65b38e --- /dev/null +++ b/docs/framework/vue/reference/variables/unsetMarker.md @@ -0,0 +1,10 @@ +--- +id: unsetMarker +title: unsetMarker +--- + +```ts +const unsetMarker: typeof unsetMarker; +``` + +Defined in: [packages/query-core/src/types.ts:65](https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L65) diff --git a/docs/reference/InfiniteQueryObserver.md b/docs/reference/InfiniteQueryObserver.md deleted file mode 100644 index 7001f06c59e..00000000000 --- a/docs/reference/InfiniteQueryObserver.md +++ /dev/null @@ -1,26 +0,0 @@ ---- -id: InfiniteQueryObserver -title: InfiniteQueryObserver -redirect_from: - - framework/react/reference/InfiniteQueryObserver ---- - -The `InfiniteQueryObserver` can be used to observe and switch between infinite queries. - -```tsx -const observer = new InfiniteQueryObserver(queryClient, { - queryKey: ['posts'], - queryFn: fetchPosts, - getNextPageParam: (lastPage, allPages) => lastPage.nextCursor, - getPreviousPageParam: (firstPage, allPages) => firstPage.prevCursor, -}) - -const unsubscribe = observer.subscribe((result) => { - console.log(result) - unsubscribe() -}) -``` - -**Options** - -The options for the `InfiniteQueryObserver` are exactly the same as those of [`useInfiniteQuery`](../framework/react/reference/functions/useInfiniteQuery.md). diff --git a/docs/reference/MutationCache.md b/docs/reference/MutationCache.md deleted file mode 100644 index e0a3b4a104c..00000000000 --- a/docs/reference/MutationCache.md +++ /dev/null @@ -1,100 +0,0 @@ ---- -id: MutationCache -title: MutationCache -redirect_from: - - framework/react/reference/MutationCache ---- - -The `MutationCache` is the storage for mutations. - -**Normally, you will not interact with the MutationCache directly and instead use the `QueryClient`.** - -```tsx -import { MutationCache } from '@tanstack/react-query' - -const mutationCache = new MutationCache({ - onError: (error) => { - console.log(error) - }, - onSuccess: (data) => { - console.log(data) - }, -}) -``` - -Its available methods are: - -- [`getAll`](#mutationcache-getall) -- [`subscribe`](#mutationcache-subscribe) -- [`clear`](#mutationcache-clear) - -**Options** - -- `onError?: (error: unknown, variables: unknown, onMutateResult: unknown, mutation: Mutation, mutationFnContext: MutationFunctionContext) => Promise | unknown` - - Optional - - This function will be called if some mutation encounters an error. - - If you return a Promise from it, it will be awaited -- `onSuccess?: (data: unknown, variables: unknown, onMutateResult: unknown, mutation: Mutation, mutationFnContext: MutationFunctionContext) => Promise | unknown` - - Optional - - This function will be called if some mutation is successful. - - If you return a Promise from it, it will be awaited -- `onSettled?: (data: unknown | undefined, error: unknown | null, variables: unknown, onMutateResult: unknown, mutation: Mutation, mutationFnContext: MutationFunctionContext) => Promise | unknown` - - Optional - - This function will be called if some mutation is settled (either successful or errored). - - If you return a Promise from it, it will be awaited -- `onMutate?: (variables: unknown, mutation: Mutation, mutationFnContext: MutationFunctionContext) => Promise | unknown` - - Optional - - This function will be called before some mutation executes. - - If you return a Promise from it, it will be awaited - -## Global callbacks - -The `onError`, `onSuccess`, `onSettled` and `onMutate` callbacks on the MutationCache can be used to handle these events on a global level. They are different to `defaultOptions` provided to the QueryClient because: - -- `defaultOptions` can be overridden by each Mutation - the global callbacks will **always** be called. -- `onMutate` does not allow returning a result. - -## `mutationCache.getAll` - -`getAll` returns all mutations within the cache. - -> Note: This is not typically needed for most applications, but can come in handy when needing more information about a mutation in rare scenarios - -```tsx -const mutations = mutationCache.getAll() -``` - -**Returns** - -- `Mutation[]` - - Mutation instances from the cache - -## `mutationCache.subscribe` - -The `subscribe` method can be used to subscribe to the mutation cache as a whole and be informed of safe/known updates to the cache like mutation states changing or mutations being updated, added or removed. - -```tsx -const callback = (event) => { - console.log(event.type, event.mutation) -} - -const unsubscribe = mutationCache.subscribe(callback) -``` - -**Options** - -- `callback: (mutation?: MutationCacheNotifyEvent) => void` - - This function will be called with the mutation cache any time it is updated. - -**Returns** - -- `unsubscribe: Function => void` - - This function will unsubscribe the callback from the mutation cache. - -## `mutationCache.clear` - -The `clear` method can be used to clear the cache entirely and start fresh. - -```tsx -mutationCache.clear() -``` diff --git a/docs/reference/QueriesObserver.md b/docs/reference/QueriesObserver.md deleted file mode 100644 index 705c6eb2df3..00000000000 --- a/docs/reference/QueriesObserver.md +++ /dev/null @@ -1,24 +0,0 @@ ---- -id: QueriesObserver -title: QueriesObserver -redirect_from: - - framework/react/reference/QueriesObserver ---- - -The `QueriesObserver` can be used to observe multiple queries. - -```tsx -const observer = new QueriesObserver(queryClient, [ - { queryKey: ['post', 1], queryFn: fetchPost }, - { queryKey: ['post', 2], queryFn: fetchPost }, -]) - -const unsubscribe = observer.subscribe((result) => { - console.log(result) - unsubscribe() -}) -``` - -**Options** - -The options for the `QueriesObserver` are exactly the same as those of [`useQueries`](../framework/react/reference/functions/useQueries.md). diff --git a/docs/reference/QueryCache.md b/docs/reference/QueryCache.md deleted file mode 100644 index 91562117762..00000000000 --- a/docs/reference/QueryCache.md +++ /dev/null @@ -1,125 +0,0 @@ ---- -id: QueryCache -title: QueryCache -redirect_from: - - framework/react/reference/QueryCache ---- - -The `QueryCache` is the storage mechanism for TanStack Query. It stores all the data, meta information and state of queries it contains. - -**Normally, you will not interact with the QueryCache directly and instead use the `QueryClient` for a specific cache.** - -```tsx -import { QueryCache } from '@tanstack/react-query' - -const queryCache = new QueryCache({ - onError: (error) => { - console.log(error) - }, - onSuccess: (data) => { - console.log(data) - }, - onSettled: (data, error) => { - console.log(data, error) - }, -}) - -const query = queryCache.find({ queryKey: ['posts'] }) -``` - -Its available methods are: - -- [`queryCache.find`](#querycache-find) -- [`queryCache.findAll`](#querycache-findall) -- [`queryCache.subscribe`](#querycache-subscribe) -- [`queryCache.clear`](#querycache-clear) -- [Further reading](#further-reading) - -**Options** - -- `onError?: (error: unknown, query: Query) => void` - - Optional - - This function will be called if some query encounters an error. -- `onSuccess?: (data: unknown, query: Query) => void` - - Optional - - This function will be called if some query is successful. -- `onSettled?: (data: unknown | undefined, error: unknown | null, query: Query) => void` - - Optional - - This function will be called if some query is settled (either successful or errored). - -## `queryCache.find` - -`find` is a slightly more advanced synchronous method that can be used to get an existing query instance from the cache. This instance not only contains **all** the state for the query, but all of the instances, and underlying guts of the query as well. If the query does not exist, `undefined` will be returned. - -> Note: This is not typically needed for most applications, but can come in handy when needing more information about a query in rare scenarios (eg. Looking at the query.state.dataUpdatedAt timestamp to decide whether a query is fresh enough to be used as an initial value) - -```tsx -const query = queryCache.find({ queryKey }) -``` - -**Options** - -- `filters: QueryFilters`: [Query Filters](../framework/react/guides/filters#query-filters) - - `queryKey: QueryKey`: [Query Keys](../framework/react/guides/query-keys.md) - -**Returns** - -- `Query` - - The query instance from the cache - -## `queryCache.findAll` - -`findAll` is even more advanced synchronous method that can be used to get existing query instances from the cache that partially match query key. If queries do not exist, empty array will be returned. - -> Note: This is not typically needed for most applications, but can come in handy when needing more information about a query in rare scenarios - -```tsx -const queries = queryCache.findAll({ queryKey }) -``` - -**Options** - -- `filters?: QueryFilters`: [Query Filters](../framework/react/guides/filters.md#query-filters) - -**Returns** - -- `Query[]` - - Query instances from the cache - -## `queryCache.subscribe` - -The `subscribe` method can be used to subscribe to the query cache as a whole and be informed of safe/known updates to the cache like query states changing or queries being updated, added or removed - -```tsx -const callback = (event) => { - console.log(event.type, event.query) -} - -const unsubscribe = queryCache.subscribe(callback) -``` - -**Options** - -- `callback: (event: QueryCacheNotifyEvent) => void` - - This function will be called with the query cache any time it is updated via its tracked update mechanisms (eg, `query.setState`, `queryClient.removeQueries`, etc). Out of scope mutations to the cache are not encouraged and will not fire subscription callbacks - -**Returns** - -- `unsubscribe: Function => void` - - This function will unsubscribe the callback from the query cache. - -## `queryCache.clear` - -The `clear` method can be used to clear the cache entirely and start fresh. - -```tsx -queryCache.clear() -``` - -[//]: # 'Materials' - -## Further reading - -To get a better understanding how the QueryCache works internally, have a look at [the Inside React Query article by TkDodo](https://tkdodo.eu/blog/inside-react-query). - -[//]: # 'Materials' diff --git a/docs/reference/QueryClient.md b/docs/reference/QueryClient.md deleted file mode 100644 index 7b174727b35..00000000000 --- a/docs/reference/QueryClient.md +++ /dev/null @@ -1,521 +0,0 @@ ---- -id: QueryClient -title: QueryClient -redirect_from: - - framework/react/reference/QueryClient ---- - -The `QueryClient` can be used to interact with a cache: - -```tsx -import { QueryClient } from '@tanstack/react-query' - -const queryClient = new QueryClient({ - defaultOptions: { - queries: { - staleTime: Infinity, - }, - }, -}) - -await queryClient.query({ queryKey: ['posts'], queryFn: fetchPosts }) -``` - -Its available methods are: - -- [`queryClient.query`](#queryclient-query) -- [`queryClient.infiniteQuery`](#queryclient-infinitequery) -- [`queryClient.getQueryData`](#queryclient-getquerydata) -- [`queryClient.getQueriesData`](#queryclient-getqueriesdata) -- [`queryClient.setQueryData`](#queryclient-setquerydata) -- [`queryClient.getQueryState`](#queryclient-getquerystate) -- [`queryClient.setQueriesData`](#queryclient-setqueriesdata) -- [`queryClient.invalidateQueries`](#queryclient-invalidatequeries) -- [`queryClient.refetchQueries`](#queryclient-refetchqueries) -- [`queryClient.cancelQueries`](#queryclient-cancelqueries) -- [`queryClient.removeQueries`](#queryclient-removequeries) -- [`queryClient.resetQueries`](#queryclient-resetqueries) -- [`queryClient.isFetching`](#queryclient-isfetching) -- [`queryClient.isMutating`](#queryclient-ismutating) -- [`queryClient.getDefaultOptions`](#queryclient-getdefaultoptions) -- [`queryClient.setDefaultOptions`](#queryclient-setdefaultoptions) -- [`queryClient.getQueryDefaults`](#queryclient-getquerydefaults) -- [`queryClient.setQueryDefaults`](#queryclient-setquerydefaults) -- [`queryClient.getMutationDefaults`](#queryclient-getmutationdefaults) -- [`queryClient.setMutationDefaults`](#queryclient-setmutationdefaults) -- [`queryClient.getQueryCache`](#queryclient-getquerycache) -- [`queryClient.getMutationCache`](#queryclient-getmutationcache) -- [`queryClient.clear`](#queryclient-clear) -- [`queryClient.resumePausedMutations`](#queryclient-resumepausedmutations) - -**Options** - -- `queryCache?: QueryCache` - - Optional - - The query cache this client is connected to. -- `mutationCache?: MutationCache` - - Optional - - The mutation cache this client is connected to. -- `defaultOptions?: DefaultOptions` - - Optional - - Define defaults for all queries and mutations using this queryClient. - - You can also define defaults to be used for [hydration](../framework/react/guides/ssr.md) - -## `queryClient.query` - -`query` is an asynchronous method that can be used to fetch and cache a query. It will either resolve with the data or throw with an error. - -If the query exists and the data is not invalidated or older than the given `staleTime`, then the data from the cache will be returned. Otherwise it will try to fetch the latest data. - -```tsx -try { - const data = await queryClient.query({ queryKey, queryFn }) -} catch (error) { - console.log(error) -} -``` - -Specify a `staleTime` to only fetch when the data is older than a certain amount of time: - -```tsx -try { - const data = await queryClient.query({ - queryKey, - queryFn, - staleTime: 10000, - select: (data) => data.items, - }) -} catch (error) { - console.log(error) -} -``` - -**Options** - -The options for `query` are exactly the same as those of [`useQuery`](../framework/react/reference/functions/useQuery.md), except the following: `enabled, refetchInterval, refetchIntervalInBackground, refetchOnWindowFocus, refetchOnReconnect, refetchOnMount, notifyOnChangeProps, throwOnError, suspense, placeholderData`; which are strictly for useQuery and useInfiniteQuery. You can check the [source code](https://github.com/TanStack/query/blob/7cd2d192e6da3df0b08e334ea1cf04cd70478827/packages/query-core/src/types.ts#L119) for more clarity. - -**Returns** - -- `Promise` - -## `queryClient.infiniteQuery` - -`infiniteQuery` is similar to `query` but can be used to fetch and cache an infinite query. - -```tsx -try { - const data = await queryClient.infiniteQuery({ queryKey, queryFn }) - console.log(data.pages) -} catch (error) { - console.log(error) -} -``` - -**Options** - -The options for `infiniteQuery` are exactly the same as those of [`query`](#queryclient-query), with the addition of `initialPageParam`, `pages` and `getNextPageParam` options from [`useInfiniteQuery`](../framework/react/reference/functions/useInfiniteQuery.md). - -**Returns** - -- `Promise>` - -## `queryClient.getQueriesData` - -`getQueriesData` is a synchronous function that can be used to get the cached data of multiple queries. Only queries that match the passed queryKey or queryFilter will be returned. If there are no matching queries, an empty array will be returned. - -```tsx -const data = queryClient.getQueriesData(filters) -``` - -**Options** - -- `filters: QueryFilters`: [Query Filters](../framework/react/guides/filters.md#query-filters) - - if a filter is passed, the data with queryKeys matching the filter will be returned - -**Returns** - -- `[queryKey: QueryKey, data: TQueryFnData | undefined][]` - - An array of tuples for the matched query keys, or `[]` if there are no matches. The tuples are the query key and its associated data. - -**Caveats** - -Because the returned data in each tuple can be of varying structures (i.e. using a filter to return "active" queries can return different data types), the `TData` generic defaults to `unknown`. If you provide a more specific type to `TData` it is assumed that you are certain each tuple's data entry is all the same type. - -This distinction is more a "convenience" for ts devs that know which structure will be returned. - -## `queryClient.setQueryData` - -`setQueryData` is a synchronous function that can be used to immediately update a query's cached data. If the query does not exist, it will be created. **If the query is not utilized by a query hook within the default `gcTime`, the query will be garbage collected. If the default `gcTime` has not been configured, it defaults to 5 minutes.** To update multiple queries at once and match query keys partially, you need to use [`queryClient.setQueriesData`](#queryclient-setqueriesdata) instead. - -> The difference between using `setQueryData` and `query` is that `setQueryData` is sync and assumes that you already synchronously have the data available. If you need to fetch the data asynchronously, it's suggested that you either refetch the query key or use `query` to handle the asynchronous fetch. - -```tsx -queryClient.setQueryData(queryKey, updater) -``` - -**Options** - -- `queryKey: QueryKey`: [Query Keys](../framework/react/guides/query-keys.md) -- `updater: TQueryFnData | undefined | ((oldData: TQueryFnData | undefined) => TQueryFnData | undefined)` - - If non-function is passed, the data will be updated to this value - - If a function is passed, it will receive the old data value and be expected to return a new one. - -**Using an updater value** - -```tsx -setQueryData(queryKey, newData) -``` - -If the value is `undefined`, the query data is not updated. - -**Using an updater function** - -For convenience in syntax, you can also pass an updater function which receives the current data value and returns the new one: - -```tsx -setQueryData(queryKey, (oldData) => newData) -``` - -If the updater function returns `undefined`, the query data will not be updated. If the updater function receives `undefined` as input, you can return `undefined` to bail out of the update and thus _not_ create a new cache entry. - -**Immutability** - -Updates via `setQueryData` must be performed in an _immutable_ way. **DO NOT** attempt to write directly to the cache by mutating `oldData` or data that you retrieved via `getQueryData` in place. - -## `queryClient.getQueryState` - -`getQueryState` is a synchronous function that can be used to get an existing query's state. If the query does not exist, `undefined` will be returned. - -```tsx -const state = queryClient.getQueryState(queryKey) -console.log(state.dataUpdatedAt) -``` - -**Options** - -- `queryKey: QueryKey`: [Query Keys](../framework/react/guides/query-keys.md) - -## `queryClient.setQueriesData` - -`setQueriesData` is a synchronous function that can be used to immediately update cached data of multiple queries by using filter function or partially matching the query key. Only queries that match the passed queryKey or queryFilter will be updated - no new cache entries will be created. Under the hood, [`setQueryData`](#queryclient-setquerydata) is called for each existing query. - -```tsx -queryClient.setQueriesData(filters, updater) -``` - -**Options** - -- `filters: QueryFilters`: [Query Filters](../framework/react/guides/filters.md#query-filters) - - if a filter is passed, queryKeys matching the filter will be updated -- `updater: TQueryFnData | (oldData: TQueryFnData | undefined) => TQueryFnData` - - the [setQueryData](#queryclient-setquerydata) updater function or new data, will be called for each matching queryKey - -## `queryClient.invalidateQueries` - -The `invalidateQueries` method can be used to invalidate and refetch single or multiple queries in the cache based on their query keys or any other functionally accessible property/state of the query. By default, all matching queries are immediately marked as invalid and active queries are refetched in the background. - -- If you **do not want active queries to refetch**, and simply be marked as invalid, you can use the `refetchType: 'none'` option. -- If you **want inactive queries to refetch** as well, use the `refetchType: 'all'` option -- For refetching, [queryClient.refetchQueries](#queryclient-refetchqueries) is called. - -```tsx -await queryClient.invalidateQueries( - { - queryKey: ['posts'], - exact, - refetchType: 'active', - }, - { throwOnError, cancelRefetch }, -) -``` - -**Options** - -- `filters?: QueryFilters`: [Query Filters](../framework/react/guides/filters.md#query-filters) - - `queryKey?: QueryKey`: [Query Keys](../framework/react/guides/query-keys.md) - - `refetchType?: 'active' | 'inactive' | 'all' | 'none'` - - Defaults to `'active'` - - When set to `active`, only queries that match the refetch predicate and are actively being rendered via `useQuery` and friends will be refetched in the background. - - When set to `inactive`, only queries that match the refetch predicate and are NOT actively being rendered via `useQuery` and friends will be refetched in the background. - - When set to `all`, all queries that match the refetch predicate will be refetched in the background. - - When set to `none`, no queries will be refetched, and those that match the refetch predicate will be marked as invalid only. -- `options?: InvalidateOptions`: - - `throwOnError?: boolean` - - When set to `true`, this method will throw if any of the query refetch tasks fail. - - `cancelRefetch?: boolean` - - Defaults to `true` - - Per default, a currently running request will be cancelled before a new request is made - - When set to `false`, no refetch will be made if there is already a request running. - -**Notes** - -- Unlike [`refetchQueries`](#queryclient-refetchqueries), `invalidateQueries` marks matching queries as invalidated and then refetches `active` queries (unless otherwise specified with the `refetchType` option). -- Unlike [`removeQueries`](#queryclient-removequeries), `invalidateQueries` keeps matching queries in the cache. - -## `queryClient.refetchQueries` - -The `refetchQueries` method can be used to refetch queries based on certain conditions. - -Examples: - -```tsx -// refetch all queries: -await queryClient.refetchQueries() - -// refetch all stale queries: -await queryClient.refetchQueries({ stale: true }) - -// refetch all active queries partially matching a query key: -await queryClient.refetchQueries({ queryKey: ['posts'], type: 'active' }) - -// refetch all active queries exactly matching a query key: -await queryClient.refetchQueries({ - queryKey: ['posts', 1], - type: 'active', - exact: true, -}) -``` - -**Options** - -- `filters?: QueryFilters`: [Query Filters](../framework/react/guides/filters.md#query-filters) -- `options?: RefetchOptions`: - - `throwOnError?: boolean` - - When set to `true`, this method will throw if any of the query refetch tasks fail. - - `cancelRefetch?: boolean` - - Defaults to `true` - - Per default, a currently running request will be cancelled before a new request is made - - When set to `false`, no refetch will be made if there is already a request running. - -**Returns** - -This function returns a promise that will resolve when all of the queries are done being refetched. By default, it **will not** throw an error if any of those queries refetches fail, but this can be configured by setting the `throwOnError` option to `true` - -**Notes** - -- Queries that are "disabled" because they only have disabled Observers will never be refetched. -- Queries that are "static" because they only have Observers with a Static StaleTime will never be refetched. -- Unlike [`invalidateQueries`](#queryclient-invalidatequeries), `refetchQueries` refetches all matching queries. - -## `queryClient.cancelQueries` - -The `cancelQueries` method can be used to cancel outgoing queries based on their query keys or any other functionally accessible property/state of the query. - -This is most useful when performing optimistic updates since you will likely need to cancel any outgoing query refetches so they don't clobber your optimistic update when they resolve. - -```tsx -await queryClient.cancelQueries( - { queryKey: ['posts'], exact: true }, - { silent: true }, -) -``` - -**Options** - -- `filters?: QueryFilters`: [Query Filters](../framework/react/guides/filters.md#query-filters) -- `cancelOptions?: CancelOptions`: [Cancel Options](../framework/react/guides/query-cancellation.md#cancel-options) - -**Returns** - -This method does not return anything - -## `queryClient.removeQueries` - -The `removeQueries` method can be used to remove queries from the cache based on their query keys or any other functionally accessible property/state of the query. - -```tsx -queryClient.removeQueries({ queryKey, exact: true }) -``` - -**Options** - -- `filters?: QueryFilters`: [Query Filters](../framework/react/guides/filters.md#query-filters) - -**Returns** - -This method does not return anything - -**Notes** - -- Unlike [`invalidateQueries`](#queryclient-invalidatequeries) or [`refetchQueries`](#queryclient-refetchqueries), `removeQueries` removes matching queries from the cache instead of refetching them. - -## `queryClient.resetQueries` - -The `resetQueries` method can be used to reset queries in the cache to their -initial state based on their query keys or any other functionally accessible -property/state of the query. - -This will notify subscribers — unlike `clear`, which removes all -subscribers — and reset the query to its pre-loaded state — unlike -`invalidateQueries`. If a query has `initialData`, the query's data will be -reset to that. If a query is active, it will be refetched. - -```tsx -queryClient.resetQueries({ queryKey, exact: true }) -``` - -**Options** - -- `filters?: QueryFilters`: [Query Filters](../framework/react/guides/filters.md#query-filters) -- `options?: ResetOptions`: - - `throwOnError?: boolean` - - When set to `true`, this method will throw if any of the query refetch tasks fail. - - `cancelRefetch?: boolean` - - Defaults to `true` - - Per default, a currently running request will be cancelled before a new request is made - - When set to `false`, no refetch will be made if there is already a request running. - -**Returns** - -This method returns a promise that resolves when all active queries have been refetched. - -## `queryClient.isFetching` - -This `isFetching` method returns an `integer` representing how many queries, if any, in the cache are currently fetching (including background-fetching, loading new pages, or loading more infinite query results) - -```tsx -if (queryClient.isFetching()) { - console.log('At least one query is fetching!') -} -``` - -TanStack Query also exports a handy [`useIsFetching`](../framework/react/reference/functions/useIsFetching.md) hook that will let you subscribe to this state in your components without creating a manual subscription to the query cache. - -**Options** - -- `filters?: QueryFilters`: [Query Filters](../framework/react/guides/filters.md#query-filters) - -**Returns** - -This method returns the number of fetching queries. - -## `queryClient.isMutating` - -This `isMutating` method returns an `integer` representing how many mutations, if any, in the cache are currently fetching. - -```tsx -if (queryClient.isMutating()) { - console.log('At least one mutation is fetching!') -} -``` - -TanStack Query also exports a handy [`useIsMutating`](../framework/react/reference/functions/useIsMutating.md) hook that will let you subscribe to this state in your components without creating a manual subscription to the mutation cache. - -**Options** - -- `filters: MutationFilters`: [Mutation Filters](../framework/react/guides/filters.md#mutation-filters) - -**Returns** - -This method returns the number of fetching mutations. - -## `queryClient.getDefaultOptions` - -The `getDefaultOptions` method returns the default options which have been set when creating the client or with `setDefaultOptions`. - -```tsx -const defaultOptions = queryClient.getDefaultOptions() -``` - -## `queryClient.setDefaultOptions` - -The `setDefaultOptions` method can be used to dynamically set the default options for this queryClient. Previously defined default options will be overwritten. - -```tsx -queryClient.setDefaultOptions({ - queries: { - staleTime: Infinity, - }, -}) -``` - -## `queryClient.getQueryDefaults` - -The `getQueryDefaults` method returns the default options which have been set for specific queries: - -```tsx -const defaultOptions = queryClient.getQueryDefaults(['posts']) -``` - -> Note that if several query defaults match the given query key, they will be merged together based on the order of registration. -> See [`setQueryDefaults`](#queryclient-setquerydefaults). - -## `queryClient.setQueryDefaults` - -`setQueryDefaults` can be used to set default options for specific queries: - -```tsx -queryClient.setQueryDefaults(['posts'], { queryFn: fetchPosts }) - -function Component() { - const { data } = useQuery({ queryKey: ['posts'] }) -} -``` - -**Options** - -- `queryKey: QueryKey`: [Query Keys](../framework/react/guides/query-keys.md) -- `options: QueryOptions` - -> As stated in [`getQueryDefaults`](#queryclient-getquerydefaults), the order of registration of query defaults does matter. -> Since the matching defaults are merged by `getQueryDefaults`, the registration should be made in the following order: from the **most generic key** to the **least generic one** . -> This way, more specific defaults will override more generic defaults. - -## `queryClient.getMutationDefaults` - -The `getMutationDefaults` method returns the default options which have been set for specific mutations: - -```tsx -const defaultOptions = queryClient.getMutationDefaults(['addPost']) -``` - -## `queryClient.setMutationDefaults` - -`setMutationDefaults` can be used to set default options for specific mutations: - -```tsx -queryClient.setMutationDefaults(['addPost'], { mutationFn: addPost }) - -function Component() { - const { data } = useMutation({ mutationKey: ['addPost'] }) -} -``` - -**Options** - -- `mutationKey: unknown[]` -- `options: MutationOptions` - -> Similar to [`setQueryDefaults`](#queryclient-setquerydefaults), the order of registration does matter here. - -## `queryClient.getQueryCache` - -The `getQueryCache` method returns the query cache this client is connected to. - -```tsx -const queryCache = queryClient.getQueryCache() -``` - -## `queryClient.getMutationCache` - -The `getMutationCache` method returns the mutation cache this client is connected to. - -```tsx -const mutationCache = queryClient.getMutationCache() -``` - -## `queryClient.clear` - -The `clear` method clears all connected caches. - -```tsx -queryClient.clear() -``` - -## `queryClient.resumePausedMutations` - -Can be used to resume mutations that have been paused because there was no network connection. - -```tsx -queryClient.resumePausedMutations() -``` diff --git a/docs/reference/QueryObserver.md b/docs/reference/QueryObserver.md deleted file mode 100644 index da291efa9fc..00000000000 --- a/docs/reference/QueryObserver.md +++ /dev/null @@ -1,21 +0,0 @@ ---- -id: QueryObserver -title: QueryObserver -redirect_from: - - framework/react/reference/QueryObserver ---- - -The `QueryObserver` can be used to observe and switch between queries. - -```tsx -const observer = new QueryObserver(queryClient, { queryKey: ['posts'] }) - -const unsubscribe = observer.subscribe((result) => { - console.log(result) - unsubscribe() -}) -``` - -**Options** - -The options for the `QueryObserver` are exactly the same as those of [`useQuery`](../framework/react/reference/functions/useQuery.md). diff --git a/docs/reference/environmentManager.md b/docs/reference/environmentManager.md deleted file mode 100644 index 04dd25ace7c..00000000000 --- a/docs/reference/environmentManager.md +++ /dev/null @@ -1,50 +0,0 @@ ---- -id: EnvironmentManager -title: environmentManager ---- - -The `environmentManager` manages how TanStack Query detects whether the current runtime should be treated as server-side. - -By default, it uses the same server detection as the exported `isServer` utility from query-core. - -Use this manager to override server detection globally for runtimes that are not traditional browser/server environments (for example, extension workers). - -Its available methods are: - -- [`isServer`](#environmentmanager-isserver) -- [`setIsServer`](#environmentmanager-setisserver) - -## `environmentManager.isServer` - -Returns whether the current runtime is treated as a server environment. - -```tsx -import { environmentManager } from '@tanstack/react-query' - -const server = environmentManager.isServer() -``` - -## `environmentManager.setIsServer` - -Overrides the server check globally. - -```tsx -import { environmentManager } from '@tanstack/react-query' - -// Override -environmentManager.setIsServer(() => { - return typeof window === 'undefined' && !('chrome' in globalThis) -}) -``` - -**Options** - -- `isServerValue: () => boolean` - -To restore the default behavior, set the function back to query-core's `isServer` utility: - -```tsx -import { environmentManager, isServer } from '@tanstack/react-query' - -environmentManager.setIsServer(() => isServer) -``` diff --git a/docs/reference/focusManager.md b/docs/reference/focusManager.md deleted file mode 100644 index 4eb4dd82fd4..00000000000 --- a/docs/reference/focusManager.md +++ /dev/null @@ -1,78 +0,0 @@ ---- -id: FocusManager -title: FocusManager -redirect_from: - - framework/react/reference/focusManager ---- - -The `FocusManager` manages the focus state within TanStack Query. - -It can be used to change the default event listeners or to manually change the focus state. - -Its available methods are: - -- [`setEventListener`](#focusmanager-seteventlistener) -- [`subscribe`](#focusmanager-subscribe) -- [`setFocused`](#focusmanager-setfocused) -- [`isFocused`](#focusmanager-isfocused) - -## `focusManager.setEventListener` - -`setEventListener` can be used to set a custom event listener: - -```tsx -import { focusManager } from '@tanstack/react-query' - -focusManager.setEventListener((handleFocus) => { - // Listen to visibilitychange - if (typeof window !== 'undefined' && window.addEventListener) { - window.addEventListener('visibilitychange', handleFocus, false) - } - - return () => { - // Be sure to unsubscribe if a new handler is set - window.removeEventListener('visibilitychange', handleFocus) - } -}) -``` - -## `focusManager.subscribe` - -`subscribe` can be used to subscribe to changes in the visibility state. It returns an unsubscribe function: - -```tsx -import { focusManager } from '@tanstack/react-query' - -const unsubscribe = focusManager.subscribe((isVisible) => { - console.log('isVisible', isVisible) -}) -``` - -## `focusManager.setFocused` - -`setFocused` can be used to manually set the focus state. Set `undefined` to fall back to the default focus check. - -```tsx -import { focusManager } from '@tanstack/react-query' - -// Set focused -focusManager.setFocused(true) - -// Set unfocused -focusManager.setFocused(false) - -// Fallback to the default focus check -focusManager.setFocused(undefined) -``` - -**Options** - -- `focused: boolean | undefined` - -## `focusManager.isFocused` - -`isFocused` can be used to get the current focus state. - -```tsx -const isFocused = focusManager.isFocused() -``` diff --git a/docs/reference/notifyManager.md b/docs/reference/notifyManager.md deleted file mode 100644 index fdb8c83bb3c..00000000000 --- a/docs/reference/notifyManager.md +++ /dev/null @@ -1,95 +0,0 @@ ---- -id: NotifyManager -title: NotifyManager -redirect_from: - - framework/react/reference/notifyManager ---- - -The `notifyManager` handles scheduling and batching callbacks in TanStack Query. - -It exposes the following methods: - -- [batch](#notifymanager-batch) -- [batchCalls](#notifymanager-batchcalls) -- [schedule](#notifymanager-schedule) -- [setNotifyFunction](#notifymanager-setnotifyfunction) -- [setBatchNotifyFunction](#notifymanager-setbatchnotifyfunction) -- [setScheduler](#notifymanager-setscheduler) - -## `notifyManager.batch` - -`batch` can be used to batch all updates scheduled inside the passed callback. -This is mainly used internally to optimize queryClient updating. - -```ts -function batch(callback: () => T): T -``` - -## `notifyManager.batchCalls` - -`batchCalls` is a higher-order function that takes a callback and wraps it. -All calls to the wrapped function schedule the callback to be run on the next batch. - -```ts -type BatchCallsCallback> = (...args: T) => void - -function batchCalls>( - callback: BatchCallsCallback, -): BatchCallsCallback -``` - -## `notifyManager.schedule` - -`schedule` schedules a function to be run on the next batch. By default, the batch is run -with a setTimeout, but this can be configured. - -```ts -function schedule(callback: () => void): void -``` - -## `notifyManager.setNotifyFunction` - -`setNotifyFunction` overrides the notify function. This function is passed the -callback when it should be executed. The default notifyFunction just calls it. - -This can be used to for example wrap notifications with `React.act` while running tests: - -```ts -import { notifyManager } from '@tanstack/react-query' -import { act } from 'react-dom/test-utils' - -notifyManager.setNotifyFunction(act) -``` - -## `notifyManager.setBatchNotifyFunction` - -`setBatchNotifyFunction` sets the function to use for batched updates - -If your framework supports a custom batching function, you can let TanStack Query know about it by calling notifyManager.setBatchNotifyFunction. - -For example, this is how the batch function is set in solid-query: - -```ts -import { notifyManager } from '@tanstack/query-core' -import { batch } from 'solid-js' - -notifyManager.setBatchNotifyFunction(batch) -``` - -## `notifyManager.setScheduler` - -`setScheduler` configures a custom callback that should schedules when the next -batch runs. The default behaviour is `setTimeout(callback, 0)`. - -```ts -import { notifyManager } from '@tanstack/react-query' - -// Schedule batches in the next microtask -notifyManager.setScheduler(queueMicrotask) - -// Schedule batches before the next frame is rendered -notifyManager.setScheduler(requestAnimationFrame) - -// Schedule batches some time in the future -notifyManager.setScheduler((cb) => setTimeout(cb, 10)) -``` diff --git a/docs/reference/onlineManager.md b/docs/reference/onlineManager.md deleted file mode 100644 index d64d54f2e8e..00000000000 --- a/docs/reference/onlineManager.md +++ /dev/null @@ -1,76 +0,0 @@ ---- -id: OnlineManager -title: OnlineManager -redirect_from: - - framework/react/reference/onlineManager ---- - -The `OnlineManager` manages the online state within TanStack Query. It can be used to change the default event listeners or to manually change the online state. - -> Per default, the `onlineManager` assumes an active network connection, and listens to the `online` and `offline` events on the `window` object to detect changes. - -> In previous versions, `navigator.onLine` was used to determine the network status. However, it doesn't work well in Chromium based browsers. There are [a lot of issues](https://bugs.chromium.org/p/chromium/issues/list?q=navigator.online) around false negatives, which lead to Queries being wrongfully marked as `offline`. - -> To circumvent this, we now always start with `online: true` and only listen to `online` and `offline` events to update the status. - -> This should reduce the likelihood of false negatives, however, it might mean false positives for offline apps that load via serviceWorkers, which can work even without an internet connection. - -Its available methods are: - -- [`setEventListener`](#onlinemanager-seteventlistener) -- [`subscribe`](#onlinemanager-subscribe) -- [`setOnline`](#onlinemanager-setonline) -- [`isOnline`](#onlinemanager-isonline) - -## `onlineManager.setEventListener` - -`setEventListener` can be used to set a custom event listener: - -```tsx -import NetInfo from '@react-native-community/netinfo' -import { onlineManager } from '@tanstack/react-query' - -onlineManager.setEventListener((setOnline) => { - return NetInfo.addEventListener((state) => { - setOnline(!!state.isConnected) - }) -}) -``` - -## `onlineManager.subscribe` - -`subscribe` can be used to subscribe to changes in the online state. It returns an unsubscribe function: - -```tsx -import { onlineManager } from '@tanstack/react-query' - -const unsubscribe = onlineManager.subscribe((isOnline) => { - console.log('isOnline', isOnline) -}) -``` - -## `onlineManager.setOnline` - -`setOnline` can be used to manually set the online state. - -```tsx -import { onlineManager } from '@tanstack/react-query' - -// Set to online -onlineManager.setOnline(true) - -// Set to offline -onlineManager.setOnline(false) -``` - -**Options** - -- `online: boolean` - -## `onlineManager.isOnline` - -`isOnline` can be used to get the current online state. - -```tsx -const isOnline = onlineManager.isOnline() -``` diff --git a/docs/reference/streamedQuery.md b/docs/reference/streamedQuery.md deleted file mode 100644 index c708288fae4..00000000000 --- a/docs/reference/streamedQuery.md +++ /dev/null @@ -1,45 +0,0 @@ ---- -id: streamedQuery -title: streamedQuery ---- - -`streamedQuery` is a helper function to create a query function that streams data from an [AsyncIterable](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/AsyncIterator). Data will be an Array of all the chunks received. The query will be in a `pending` state until the first chunk of data is received, but will go to `success` after that. The query will stay in fetchStatus `fetching` until the stream ends. - -To see `streamedQuery` in action, take a look at our chat example in the [examples/react/chat directory on GitHub](https://github.com/TanStack/query/tree/main/examples/react/chat). - -```tsx -import { experimental_streamedQuery as streamedQuery } from '@tanstack/react-query' - -const query = queryOptions({ - queryKey: ['data'], - queryFn: streamedQuery({ - streamFn: fetchDataInChunks, - }), -}) -``` - -> Note: `streamedQuery` is currently marked as `experimental` because we want to gather feedback from the community. If you've tried out the API and have feedback for us, please provide it in this [GitHub discussion](https://github.com/TanStack/query/discussions/9065). - -**Options** - -- `streamFn: (context: QueryFunctionContext) => Promise>` - - **Required** - - The function that returns a Promise of an AsyncIterable with data to stream in. - - Receives a [QueryFunctionContext](../framework/react/guides/query-functions.md#queryfunctioncontext) -- `refetchMode?: 'append' | 'reset' | 'replace'` - - Optional - - Defines how refetches are handled. - - Defaults to `'reset'` - - When set to `'reset'`, the query will erase all data and go back into `pending` state. - - When set to `'append'`, data will be appended to existing data. - - When set to `'replace'`, all data will be written to the cache once the stream ends. -- `reducer?: (accumulator: TData, chunk: TQueryFnData) => TData` - - Optional - - Reduces streamed chunks (`TQueryFnData`) into the final data shape (`TData`). - - Default: appends each chunk to the end of the accumulator when `TData` is an array. - - If `TData` is not an array, you must provide a custom `reducer`. -- `initialValue?: TData = TQueryFnData` - - Optional - - Defines the initial data to be used while the first chunk is being fetched, and it is also returned when the stream yields no values. - - It is mandatory when custom `reducer` is provided. - - Defaults to an empty array. diff --git a/docs/reference/timeoutManager.md b/docs/reference/timeoutManager.md deleted file mode 100644 index 12f1d0eee2c..00000000000 --- a/docs/reference/timeoutManager.md +++ /dev/null @@ -1,119 +0,0 @@ ---- -id: TimeoutManager -title: TimeoutManager ---- - -The `TimeoutManager` handles `setTimeout` and `setInterval` timers in TanStack Query. - -TanStack Query uses timers to implement features like query `staleTime` and `gcTime`, as well as retries, throttling, and debouncing. - -By default, TimeoutManager uses the global `setTimeout` and `setInterval`, but it can be configured to use custom implementations instead. - -Its available methods are: - -- [`timeoutManager.setTimeoutProvider`](#timeoutmanager-settimeoutprovider) - - [`TimeoutProvider`](#timeoutprovider) -- [`timeoutManager.setTimeout`](#timeoutmanager-settimeout) -- [`timeoutManager.clearTimeout`](#timeoutmanager-cleartimeout) -- [`timeoutManager.setInterval`](#timeoutmanager-setinterval) -- [`timeoutManager.clearInterval`](#timeoutmanager-clearinterval) - -## `timeoutManager.setTimeoutProvider` - -`setTimeoutProvider` can be used to set a custom implementation of the `setTimeout`, `clearTimeout`, `setInterval`, `clearInterval` functions, called a `TimeoutProvider`. - -This may be useful if you notice event loop performance issues with thousands of queries. A custom TimeoutProvider could also support timer delays longer than the global `setTimeout` maximum delay value of about [24 days](https://developer.mozilla.org/en-US/docs/Web/API/Window/setTimeout#maximum_delay_value). - -It is important to call `setTimeoutProvider` before creating a QueryClient or queries, so that the same provider is used consistently for all timers in the application, since different TimeoutProviders cannot cancel each others' timers. - -```tsx -import { timeoutManager, QueryClient } from '@tanstack/react-query' -import { CustomTimeoutProvider } from './CustomTimeoutProvider' - -timeoutManager.setTimeoutProvider(new CustomTimeoutProvider()) - -export const queryClient = new QueryClient() -``` - -### `TimeoutProvider` - -Timers are very performance sensitive. Short term timers (such as those with delays less than 5 seconds) tend to be latency sensitive, where long-term timers may benefit more from [timer coalescing](https://en.wikipedia.org/wiki/Timer_coalescing) - batching timers with similar deadlines together - using a data structure like a [hierarchical time wheel](https://www.npmjs.com/package/timer-wheel). - -The `TimeoutProvider` type requires that implementations handle timer ID objects that can be converted to `number` via [Symbol.toPrimitive][toPrimitive] because runtimes like NodeJS return [objects][nodejs-timeout] from their global `setTimeout` and `setInterval` functions. TimeoutProvider implementations are free to coerce timer IDs to number internally, or to return their own custom object type that implements `{ [Symbol.toPrimitive]: () => number }`. - -[nodejs-timeout]: https://nodejs.org/api/timers.html#class-timeout -[toPrimitive]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/toPrimitive - -```tsx -type ManagedTimerId = number | { [Symbol.toPrimitive]: () => number } - -type TimeoutProvider = { - readonly setTimeout: (callback: TimeoutCallback, delay: number) => TTimerId - readonly clearTimeout: (timeoutId: TTimerId | undefined) => void - - readonly setInterval: (callback: TimeoutCallback, delay: number) => TTimerId - readonly clearInterval: (intervalId: TTimerId | undefined) => void -} -``` - -## `timeoutManager.setTimeout` - -`setTimeout(callback, delayMs)` schedules a callback to run after approximately `delay` milliseconds, like the global [setTimeout function](https://developer.mozilla.org/en-US/docs/Web/API/Window/setTimeout).The callback can be canceled with `timeoutManager.clearTimeout`. - -It returns a timer ID, which may be a number or an object that can be coerced to a number via [Symbol.toPrimitive][toPrimitive]. - -```tsx -import { timeoutManager } from '@tanstack/react-query' - -const timeoutId = timeoutManager.setTimeout( - () => console.log('ran at:', new Date()), - 1000, -) - -const timeoutIdNumber: number = Number(timeoutId) -``` - -## `timeoutManager.clearTimeout` - -`clearTimeout(timerId)` cancels a timeout callback scheduled with `setTimeout`, like the global [clearTimeout function](https://developer.mozilla.org/en-US/docs/Web/API/Window/clearTimeout). It should be called with a timer ID returned by `timeoutManager.setTimeout`. - -```tsx -import { timeoutManager } from '@tanstack/react-query' - -const timeoutId = timeoutManager.setTimeout( - () => console.log('ran at:', new Date()), - 1000, -) - -timeoutManager.clearTimeout(timeoutId) -``` - -## `timeoutManager.setInterval` - -`setInterval(callback, intervalMs)` schedules a callback to be called approximately every `intervalMs`, like the global [setInterval function](https://developer.mozilla.org/en-US/docs/Web/API/Window/setInterval). - -Like `setTimeout`, it returns a timer ID, which may be a number or an object that can be coerced to a number via [Symbol.toPrimitive](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/toPrimitive). - -```tsx -import { timeoutManager } from '@tanstack/react-query' - -const intervalId = timeoutManager.setInterval( - () => console.log('ran at:', new Date()), - 1000, -) -``` - -## `timeoutManager.clearInterval` - -`clearInterval(intervalId)` can be used to cancel an interval, like the global [clearInterval function](https://developer.mozilla.org/en-US/docs/Web/API/Window/clearInterval). It should be called with an interval ID returned by `timeoutManager.setInterval`. - -```tsx -import { timeoutManager } from '@tanstack/react-query' - -const intervalId = timeoutManager.setInterval( - () => console.log('ran at:', new Date()), - 1000, -) - -timeoutManager.clearInterval(intervalId) -``` diff --git a/packages/angular-query-experimental/tsconfig.json b/packages/angular-query-experimental/tsconfig.json index bcf51c2ffe5..3699e26689d 100644 --- a/packages/angular-query-experimental/tsconfig.json +++ b/packages/angular-query-experimental/tsconfig.json @@ -22,5 +22,5 @@ "*.config.js", "package.json" ], - "references": [{ "path": "../query-core" }, { "path": "../query-devtools" }] + "references": [{ "path": "../query-devtools" }] } diff --git a/packages/lit-query/tsconfig.json b/packages/lit-query/tsconfig.json index e143f207f38..15d8fec4c82 100644 --- a/packages/lit-query/tsconfig.json +++ b/packages/lit-query/tsconfig.json @@ -5,6 +5,5 @@ "rootDir": ".", "lib": ["ES2022", "DOM"] }, - "include": ["src", "*.config.ts", "*.config.js", "package.json"], - "references": [{ "path": "../query-core" }] + "include": ["src", "*.config.ts", "*.config.js", "package.json"] } diff --git a/packages/query-core/src/environmentManager.ts b/packages/query-core/src/environmentManager.ts index 91ef6797230..b8adefd0e7d 100644 --- a/packages/query-core/src/environmentManager.ts +++ b/packages/query-core/src/environmentManager.ts @@ -10,7 +10,21 @@ let isServerFn: IsServerValue = () => defaultIsServer export const isServer = (): boolean => isServerFn() /** - * Manages environment detection used by TanStack Query internals. + * Manages how TanStack Query detects whether the current runtime should be treated as + * server-side, which disables scheduling refetch timers and changes the default `retry` count + * and `gcTime`. By default, the detection treats a missing `window` (or the presence of a + * `Deno` global) as server. + * + * Override this for runtimes where that default detection would give the wrong answer — for + * example, a Service Worker, where `window` is undefined even though the environment should + * behave like a client. + * + * @example + * ```ts + * import { environmentManager } from '@tanstack/query-core' + * + * environmentManager.setIsServer(() => false) + * ``` */ export const environmentManager = { isServer, diff --git a/packages/query-core/src/focusManager.ts b/packages/query-core/src/focusManager.ts index 21be2612d3a..ff1c50b5989 100644 --- a/packages/query-core/src/focusManager.ts +++ b/packages/query-core/src/focusManager.ts @@ -6,6 +6,11 @@ type SetupFn = ( setFocused: (focused?: boolean) => void, ) => (() => void) | undefined +/** + * The `FocusManager` manages the focus state within TanStack Query. + * + * It can be used to change the default event listeners or to manually change the focus state. + */ export class FocusManager extends Subscribable { #focused?: boolean #cleanup?: () => void @@ -44,6 +49,31 @@ export class FocusManager extends Subscribable { } } + /** + * `setEventListener` can be used to set a custom event listener that will + * be used to determine the focus state. The provided `setup` function + * receives a `setFocused` callback: call it with a `boolean` to manually + * set the focus state, or with no arguments to re-evaluate the current + * focus state and notify subscribers. + * + * @example + * ```ts + * import { focusManager } from '@tanstack/query-core' + * + * focusManager.setEventListener((handleFocus) => { + * const listener = () => handleFocus() + * // Listen to visibilitychange + * if (typeof window !== 'undefined' && window.addEventListener) { + * window.addEventListener('visibilitychange', listener, false) + * } + * + * return () => { + * // Be sure to unsubscribe if a new handler is set + * window.removeEventListener('visibilitychange', listener) + * } + * }) + * ``` + */ setEventListener(setup: SetupFn): void { this.#setup = setup this.#cleanup?.() @@ -56,6 +86,24 @@ export class FocusManager extends Subscribable { }) } + /** + * `setFocused` can be used to manually set the focus state. Set `undefined` + * to fall back to the default focus check. + * + * @example + * ```ts + * import { focusManager } from '@tanstack/query-core' + * + * // Set focused + * focusManager.setFocused(true) + * + * // Set unfocused + * focusManager.setFocused(false) + * + * // Fallback to the default focus check + * focusManager.setFocused(undefined) + * ``` + */ setFocused(focused?: boolean): void { const changed = this.#focused !== focused if (changed) { @@ -64,6 +112,9 @@ export class FocusManager extends Subscribable { } } + /** + * `onFocus` notifies all subscribed listeners with the current focus state. + */ onFocus(): void { const isFocused = this.isFocused() this.listeners.forEach((listener) => { @@ -71,6 +122,9 @@ export class FocusManager extends Subscribable { }) } + /** + * `isFocused` can be used to get the current focus state. + */ isFocused(): boolean { if (typeof this.#focused === 'boolean') { return this.#focused @@ -82,4 +136,7 @@ export class FocusManager extends Subscribable { } } +/** + * Singleton instance of {@link FocusManager}, used to manage and observe the focus state within TanStack Query. + */ export const focusManager = new FocusManager() diff --git a/packages/query-core/src/hydration.ts b/packages/query-core/src/hydration.ts index a796c574f95..e8069624a69 100644 --- a/packages/query-core/src/hydration.ts +++ b/packages/query-core/src/hydration.ts @@ -35,17 +35,36 @@ function tryResolveSync(promise: PromiseLike) { return undefined } +/** + * Options for `dehydrate`, controlling which queries/mutations are included in the resulting `DehydratedState` and + * how their data/errors are transformed before being serialized (e.g. for embedding in server-rendered markup). + */ export interface DehydrateOptions { + /** Transforms a query's `data` before it is dehydrated. Useful for non-JSON-serializable data. */ serializeData?: TransformerFn + /** Predicate to decide whether a given `Mutation` should be dehydrated. Defaults to `defaultShouldDehydrateMutation`. */ shouldDehydrateMutation?: (mutation: Mutation) => boolean + /** Predicate to decide whether a given `Query` should be dehydrated. Defaults to `defaultShouldDehydrateQuery`. */ shouldDehydrateQuery?: (query: Query) => boolean + /** + * Predicate to decide whether a query's error should be redacted before dehydration. Errors are redacted + * (replaced with a generic `Error('redacted')`) unless this function is provided and returns `false` for the + * given error, in which case the original error is kept. + */ shouldRedactErrors?: (error: unknown) => boolean } +/** + * Options for `hydrate`, controlling the default options applied to queries/mutations restored from a + * `DehydratedState`, and how to reverse any transformation applied by `DehydrateOptions.serializeData`. + */ export interface HydrateOptions { defaultOptions?: { + /** Transforms a query's `data` after it is read from the dehydrated state, reversing `serializeData`. */ deserializeData?: TransformerFn + /** Default options merged into every query restored from the dehydrated state. */ queries?: QueryOptions + /** Default options merged into every mutation restored from the dehydrated state. */ mutations?: MutationOptions } } @@ -67,6 +86,11 @@ interface DehydratedQuery { queryType?: 'infinite' } +/** + * A serializable snapshot of a `QueryClient`'s cache, as produced by `dehydrate` and consumed by `hydrate`. Typically + * transported from server to client (e.g. embedded in server-rendered markup) to seed the client's cache with data + * that has already been fetched, avoiding a redundant fetch on the client. + */ export interface DehydratedState { mutations: Array queries: Array @@ -111,10 +135,16 @@ function dehydratePromise( return promise } -// Most config is not dehydrated but instead meant to configure again when -// consuming the de/rehydrated data, typically with useQuery on the client. -// Sometimes it might make sense to prefetch data on the server and include -// in the html-payload, but not consume it on the initial render. +/** + * Dehydrates a single `Query` into a serializable `DehydratedQuery` snapshot. Note that most query config (e.g. + * `queryFn`, `staleTime`) is not dehydrated but instead meant to be configured again when consuming the + * de/rehydrated data, typically with `useQuery` on the client. If the query is still `pending`, its in-flight + * promise is dehydrated too so it can be resumed on the other side instead of re-fetched. + * @param query - The query to dehydrate. + * @param serializeData - Optional transform applied to `query.state.data` before it is included in the snapshot. + * @param shouldRedactErrors - Optional predicate; if it returns `false` for the promise's rejection error, that + * error is kept as-is instead of being redacted. + */ export function dehydrateQuery( query: Query, serializeData?: TransformerFn, @@ -140,14 +170,40 @@ export function dehydrateQuery( } } +/** + * The default `shouldDehydrateMutation` predicate used by `dehydrate`. Only dehydrates mutations that are + * currently paused (e.g. paused by `networkMode` while offline). + */ export function defaultShouldDehydrateMutation(mutation: Mutation) { return mutation.state.isPaused } +/** + * The default `shouldDehydrateQuery` predicate used by `dehydrate`. Only dehydrates queries whose status is + * `'success'`. + */ export function defaultShouldDehydrateQuery(query: Query) { return query.state.status === 'success' } +/** + * Dehydrates a `QueryClient`'s cache (queries and mutations) into a plain, serializable `DehydratedState`, + * typically to embed in server-rendered markup and later restore into a client-side `QueryClient` via `hydrate`. + * Which queries/mutations are included, and how their data/errors are transformed, is controlled by `options`, + * falling back to the client's `dehydrate` default options, and finally to `defaultShouldDehydrateQuery` / + * `defaultShouldDehydrateMutation`. + * @example + * ```ts + * const queryClient = new QueryClient() + * + * await queryClient.prefetchQuery({ + * queryKey: ['posts'], + * queryFn: getPosts, + * }) + * + * const dehydratedState = dehydrate(queryClient) + * ``` + */ export function dehydrate( client: QueryClient, options: DehydrateOptions = {}, @@ -188,6 +244,23 @@ export function dehydrate( return { mutations, queries } } +/** + * Restores a `DehydratedState` (as produced by `dehydrate`) into a `QueryClient`'s cache, typically to seed the + * client with data already fetched on the server. `mutations` and `queries` are each optional on `dehydratedState`. + * Queries not yet in the cache are built from the dehydrated snapshot; queries that already exist are only updated + * when the dehydrated data is newer than what's already cached. Newly built queries have their `fetchStatus` reset + * to `'idle'` so they don't hydrate stuck in a fetching state. If a dehydrated query still had an in-flight + * promise, it is resumed via `query.fetch()` (reusing that promise as `initialPromise`) rather than re-invoking + * `queryFn`. + * @example + * ```ts + * // dehydratedState was produced by `dehydrate` on the server + * // and sent to the client, e.g. embedded in server-rendered markup. + * const queryClient = new QueryClient() + * + * hydrate(queryClient, dehydratedState) + * ``` + */ export function hydrate( client: QueryClient, dehydratedState: Partial, diff --git a/packages/query-core/src/index.ts b/packages/query-core/src/index.ts index e25e16b4246..7d9dd23379f 100644 --- a/packages/query-core/src/index.ts +++ b/packages/query-core/src/index.ts @@ -1,6 +1,7 @@ /* istanbul ignore file */ export { focusManager } from './focusManager' +export type { FocusManager } from './focusManager' export { environmentManager } from './environmentManager' export { defaultShouldDehydrateMutation, @@ -15,6 +16,7 @@ export type { MutationCacheNotifyEvent } from './mutationCache' export { MutationObserver } from './mutationObserver' export { defaultScheduler, notifyManager } from './notifyManager' export { onlineManager } from './onlineManager' +export type { OnlineManager } from './onlineManager' export { QueriesObserver } from './queriesObserver' export { QueryCache } from './queryCache' export type { QueryCacheNotifyEvent } from './queryCache' @@ -25,6 +27,7 @@ export { timeoutManager, type ManagedTimerId, type TimeoutCallback, + type TimeoutManager, type TimeoutProvider, } from './timeoutManager' export { diff --git a/packages/query-core/src/infiniteQueryObserver.ts b/packages/query-core/src/infiniteQueryObserver.ts index 1cdd32a8859..ed854b60ba0 100644 --- a/packages/query-core/src/infiniteQueryObserver.ts +++ b/packages/query-core/src/infiniteQueryObserver.ts @@ -19,6 +19,25 @@ type InfiniteQueryObserverListener = ( result: InfiniteQueryObserverResult, ) => void +/** + * An `InfiniteQueryObserver` extends `QueryObserver` to observe and switch + * between infinite queries. It augments the base `QueryObserverResult` with + * infinite-query-specific fields and methods, such as `hasNextPage` and + * `fetchNextPage`, and is the primitive that framework adapters (e.g. + * `useInfiniteQuery`) build their hooks on top of. + * + * @example + * ```ts + * const observer = new InfiniteQueryObserver(queryClient, { + * queryKey: ['projects'], + * queryFn: ({ pageParam }) => fetchProjects(pageParam), + * initialPageParam: 0, + * getNextPageParam: (lastPage) => lastPage.nextCursor, + * }) + * + * const unsubscribe = observer.subscribe((result) => console.log(result)) + * ``` + */ export class InfiniteQueryObserver< TQueryFnData = unknown, TError = DefaultError, @@ -80,6 +99,12 @@ export class InfiniteQueryObserver< this.fetchPreviousPage = this.fetchPreviousPage.bind(this) } + /** + * Updates the observer's options. Behaves the same as + * `QueryObserver.setOptions`, additionally marking the options as + * belonging to an infinite query before delegating to the base + * implementation. + */ setOptions( options: InfiniteQueryObserverOptions< TQueryFnData, @@ -93,6 +118,12 @@ export class InfiniteQueryObserver< super.setOptions(options) } + /** + * The infinite-query counterpart of {@link QueryObserver#getOptimisticResult}, marking the + * options as an infinite query before delegating to it. Called by framework adapters (e.g. + * `useInfiniteQuery`) ahead of subscribing, to compute the current `InfiniteQueryObserverResult` + * synchronously. + */ getOptimisticResult( options: DefaultedInfiniteQueryObserverOptions< TQueryFnData, @@ -109,6 +140,24 @@ export class InfiniteQueryObserver< > } + /** + * Fetches the next page of the infinite query and returns a promise that + * resolves with the resulting `InfiniteQueryObserverResult`. The page + * param used for the fetch is determined by `getNextPageParam`, which + * receives the current pages/page params and whose result also determines + * `hasNextPage`. + * + * @example + * ```ts + * const { hasNextPage } = observer.getCurrentResult() + * + * if (hasNextPage) { + * await observer.fetchNextPage() + * } + * ``` + * + * @see {@link InfiniteQueryObserver#fetchPreviousPage} + */ fetchNextPage( options?: FetchNextPageOptions, ): Promise> { @@ -120,6 +169,24 @@ export class InfiniteQueryObserver< }) } + /** + * Fetches the previous page of the infinite query and returns a promise + * that resolves with the resulting `InfiniteQueryObserverResult`. The page + * param used for the fetch is determined by `getPreviousPageParam`, which + * receives the current pages/page params and whose result also determines + * `hasPreviousPage`. + * + * @example + * ```ts + * const { hasPreviousPage } = observer.getCurrentResult() + * + * if (hasPreviousPage) { + * await observer.fetchPreviousPage() + * } + * ``` + * + * @see {@link InfiniteQueryObserver#fetchNextPage} + */ fetchPreviousPage( options?: FetchPreviousPageOptions, ): Promise> { diff --git a/packages/query-core/src/mutation.ts b/packages/query-core/src/mutation.ts index 6682ce3cce4..fd74ba97efa 100644 --- a/packages/query-core/src/mutation.ts +++ b/packages/query-core/src/mutation.ts @@ -23,20 +23,54 @@ interface MutationConfig { state?: MutationState } +/** + * The raw state stored on a `Mutation` instance. This is the underlying state + * that observer results (e.g. `MutationObserverResult`) are derived from. + */ export interface MutationState< TData = unknown, TError = DefaultError, TVariables = unknown, TOnMutateResult = unknown, > { + /** + * The value returned by `onMutate`, if defined. Passed to `onSuccess`, + * `onError` and `onSettled` as the mutation's context. + */ context: TOnMutateResult | undefined + /** + * The last successfully resolved data for the mutation. + */ data: TData | undefined + /** + * The error object for the mutation, if the last attempt resulted in an error. + * - Defaults to `null`. + */ error: TError | null + /** + * The number of times the mutation function has failed for the current attempt. + */ failureCount: number + /** + * The reason the current attempt failed, as reported by the retryer. + */ failureReason: TError | null + /** + * Whether the mutation is currently paused (see network mode), or is + * waiting for another mutation with the same `scope` to finish. + */ isPaused: boolean + /** + * The status of the mutation. + */ status: MutationStatus + /** + * The variables the mutation was last called with. + */ variables: TVariables | undefined + /** + * The timestamp for when the mutation was submitted. + */ submittedAt: number } @@ -81,6 +115,23 @@ export type Action = // CLASS +/** + * Represents a single mutation attempt. A `Mutation` holds the mutation's + * options, state (data/error/status), and the `MutationObserver`s currently + * subscribed to it. + * + * Instances are created and managed internally by `MutationCache`; application + * code typically interacts with mutations indirectly through `QueryClient` or + * a framework hook like `useMutation`. Direct access to a `Mutation` instance + * is possible via `mutationCache.find()`/`getAll()` for inspecting cache state. + * + * @example + * ```ts + * const mutationCache = queryClient.getMutationCache() + * + * const mutation = mutationCache.find({ mutationKey: ['addPost'] }) + * ``` + */ export class Mutation< TData = unknown, TError = DefaultError, @@ -113,6 +164,7 @@ export class Mutation< this.scheduleGc() } + /** @internal */ setOptions( options: MutationOptions, ): void { @@ -121,10 +173,14 @@ export class Mutation< this.updateGcTime(this.options.gcTime) } + /** + * The `meta` object passed in the mutation's options, if any. + */ get meta(): MutationMeta | undefined { return this.options.meta } + /** @internal */ addObserver(observer: MutationObserver): void { if (!this.#observers.includes(observer)) { this.#observers.push(observer) @@ -140,6 +196,7 @@ export class Mutation< } } + /** @internal */ removeObserver(observer: MutationObserver): void { this.#observers = this.#observers.filter((x) => x !== observer) @@ -162,6 +219,27 @@ export class Mutation< } } + /** + * Resumes a mutation that is currently paused or was restored from a + * dehydrated, still-`pending` state. + * + * - If this mutation has an active retryer (it paused mid-attempt, e.g. due + * to the network mode or scope-based queuing), its retryer is resumed. + * - Otherwise, if the mutation's status is still `pending` (e.g. it was + * dehydrated while an attempt was in flight and never got a retryer in + * this instance), `execute` is called again with the last known variables. + * - Otherwise the mutation has already settled and this resolves immediately + * without running anything again. + * + * @example + * ```ts + * // typically driven by reconnect handling, e.g. queryClient.resumePausedMutations() + * const mutation = mutationCache.find({ mutationKey: ['addPost'] }) + * await mutation?.continue() + * ``` + * + * @see {@link Mutation#execute} + */ continue(): Promise { return ( this.#retryer?.continue() ?? @@ -173,6 +251,36 @@ export class Mutation< ) } + /** + * Runs the mutation function for the given variables through a retryer, and + * drives the mutation's state and lifecycle callbacks through to settlement. + * + * If this mutation's state is already `pending` when `execute` is called + * (i.e. it was restored, still in-flight, from a dehydrated state), the + * `onMutate` step is skipped and a `continue` action is dispatched to + * unpause it; otherwise a `pending` action is dispatched first, then the + * mutation cache's `onMutate` and the mutation's own `onMutate` option are + * awaited in that order, and the resulting context is stored. + * + * The mutation function is then run (subject to `retry`/`retryDelay`/ + * `networkMode`, and to the mutation cache's scope-based serialization). + * On success, the cache's `onSuccess`/`onSettled` callbacks run before the + * mutation's own `onSuccess`/`onSettled` options, a `success` action is + * dispatched, and the resolved data is returned. On failure, the same + * cache-then-option ordering is used for `onError`/`onSettled`, but each of + * those four callbacks is individually caught so that a throwing callback + * cannot mask the original error; an `error` action is then dispatched and + * the original error is re-thrown. + * + * @example + * ```ts + * // Called internally by `MutationObserver.mutate` and `Mutation.continue` — + * // applications normally trigger mutations through those, not this method. + * const data = await mutation.execute(variables) + * ``` + * + * @see {@link Mutation#continue} + */ async execute(variables: TVariables): Promise { const onContinue = () => { this.#dispatch({ type: 'continue' }) diff --git a/packages/query-core/src/mutationCache.ts b/packages/query-core/src/mutationCache.ts index 109e9a94b44..106e50fe033 100644 --- a/packages/query-core/src/mutationCache.ts +++ b/packages/query-core/src/mutationCache.ts @@ -15,7 +15,16 @@ import type { MutationFilters } from './utils' // TYPES +/** + * Global callbacks that fire for every mutation handled by a `MutationCache`, regardless of which + * component or observer triggered it. They differ from the `defaultOptions` provided to a + * `QueryClient` in two ways: `defaultOptions` can be overridden by each mutation, while these + * callbacks are always called, and `onMutate` here does not allow returning a result. + * + * If a callback returns a promise, it will be awaited before the mutation continues. + */ export interface MutationCacheConfig { + /** Called when any mutation in the cache encounters an error. */ onError?: ( error: DefaultError, variables: unknown, @@ -23,6 +32,7 @@ export interface MutationCacheConfig { mutation: Mutation, context: MutationFunctionContext, ) => Promise | unknown + /** Called when any mutation in the cache is successful. */ onSuccess?: ( data: unknown, variables: unknown, @@ -30,11 +40,13 @@ export interface MutationCacheConfig { mutation: Mutation, context: MutationFunctionContext, ) => Promise | unknown + /** Called before any mutation in the cache executes. */ onMutate?: ( variables: unknown, mutation: Mutation, context: MutationFunctionContext, ) => Promise | unknown + /** Called when any mutation in the cache is settled, either successfully or with an error. */ onSettled?: ( data: unknown | undefined, error: DefaultError | null, @@ -78,6 +90,11 @@ interface NotifyEventMutationUpdated extends NotifyEvent { action: Action } +/** + * The event passed to a `MutationCache` subscriber. Fired whenever a mutation is added or removed + * from the cache, its state is updated, or one of its observers is added, removed, or has its + * options updated. + */ export type MutationCacheNotifyEvent = | NotifyEventMutationAdded | NotifyEventMutationRemoved @@ -90,6 +107,20 @@ type MutationCacheListener = (event: MutationCacheNotifyEvent) => void // CLASS +/** + * The `MutationCache` is the storage for mutations. + * + * Normally, you will not interact with the `MutationCache` directly and instead use a + * `QueryClient`. You can subscribe to it (inherited from `Subscribable`) to be informed of + * safe/known updates to the cache, such as mutations being added, removed, or updated. + * + * @example + * ```ts + * const unsubscribe = mutationCache.subscribe((event) => { + * console.log(event.type, event.mutation) + * }) + * ``` + */ export class MutationCache extends Subscribable { #mutations: Set> #scopes: Map>> @@ -102,6 +133,7 @@ export class MutationCache extends Subscribable { this.#mutationId = 0 } + /** @internal */ build( client: QueryClient, options: MutationOptions, @@ -120,6 +152,7 @@ export class MutationCache extends Subscribable { return mutation } + /** @internal */ add(mutation: Mutation): void { this.#mutations.add(mutation) const scope = scopeFor(mutation) @@ -134,6 +167,7 @@ export class MutationCache extends Subscribable { this.notify({ type: 'added', mutation }) } + /** @internal */ remove(mutation: Mutation): void { if (this.#mutations.delete(mutation)) { const scope = scopeFor(mutation) @@ -157,6 +191,7 @@ export class MutationCache extends Subscribable { this.notify({ type: 'removed', mutation }) } + /** @internal */ canRun(mutation: Mutation): boolean { const scope = scopeFor(mutation) if (typeof scope === 'string') { @@ -174,6 +209,7 @@ export class MutationCache extends Subscribable { } } + /** @internal */ runNext(mutation: Mutation): Promise { const scope = scopeFor(mutation) if (typeof scope === 'string') { @@ -187,6 +223,16 @@ export class MutationCache extends Subscribable { } } + /** + * Removes all mutations from the cache. + * + * @example + * ```ts + * const mutationCache = queryClient.getMutationCache() + * + * mutationCache.clear() + * ``` + */ clear(): void { notifyManager.batch(() => { this.#mutations.forEach((mutation) => { @@ -197,10 +243,38 @@ export class MutationCache extends Subscribable { }) } + /** + * Returns all mutations within the cache. + * + * This is not typically needed for most applications, but can come in handy when needing more + * information about a mutation in rare scenarios. + * + * @example + * ```ts + * const mutationCache = queryClient.getMutationCache() + * + * const mutations = mutationCache.getAll() + * ``` + */ getAll(): Array { return Array.from(this.#mutations) } + /** + * A slightly more advanced method that can be used to get an existing mutation instance from + * the cache. If the mutation does not exist, `undefined` is returned. + * + * This is not typically needed for most applications, but can come in handy when needing more + * information about a mutation in rare scenarios. + * + * @see {@link MutationCache#findAll} + * @example + * ```ts + * const mutationCache = queryClient.getMutationCache() + * + * const mutation = mutationCache.find({ mutationKey: ['addPost'] }) + * ``` + */ find< TData = unknown, TError = DefaultError, @@ -216,10 +290,26 @@ export class MutationCache extends Subscribable { ) as Mutation | undefined } + /** + * An even more advanced method that can be used to get existing mutation instances from the + * cache that match the given filters. If no mutations match, an empty array is returned. + * + * This is not typically needed for most applications, but can come in handy when needing more + * information about mutations in rare scenarios. + * + * @see {@link MutationCache#find} + * @example + * ```ts + * const mutationCache = queryClient.getMutationCache() + * + * const mutations = mutationCache.findAll({ mutationKey: ['addPost'] }) + * ``` + */ findAll(filters: MutationFilters = {}): Array { return this.getAll().filter((mutation) => matchMutation(filters, mutation)) } + /** @internal */ notify(event: MutationCacheNotifyEvent) { notifyManager.batch(() => { this.listeners.forEach((listener) => { @@ -228,6 +318,7 @@ export class MutationCache extends Subscribable { }) } + /** @internal */ resumePausedMutations(): Promise { const pausedMutations = this.getAll().filter((x) => x.state.isPaused) diff --git a/packages/query-core/src/mutationObserver.ts b/packages/query-core/src/mutationObserver.ts index 8164e2ad024..b91157abd0a 100644 --- a/packages/query-core/src/mutationObserver.ts +++ b/packages/query-core/src/mutationObserver.ts @@ -20,6 +20,21 @@ type MutationObserverListener = ( // CLASS +/** + * Observes a single mutation and derives a `MutationObserverResult` from it. + * A framework hook like `useMutation` creates one `MutationObserver` per hook + * call, keeps it stable across re-renders, calls `setOptions` when the options + * passed to the hook change, subscribes to it to re-render on updates, and + * reads `getCurrentResult()` for the value to return. Calling `mutate()` + * builds a new underlying `Mutation` in the `MutationCache` and executes it. + * + * @example + * ```ts + * const observer = new MutationObserver(queryClient, { + * mutationFn: (variables: { title: string }) => addPost(variables), + * }) + * ``` + */ export class MutationObserver< TData = unknown, TError = DefaultError, @@ -62,6 +77,22 @@ export class MutationObserver< this.reset = this.reset.bind(this) } + /** + * Updates the observer's options. + * + * If the new `mutationKey` differs from the previous one (and both were + * defined), the observer is reset, detaching it from the mutation it was + * observing. Otherwise, if the currently observed mutation is still + * `pending`, its options are updated in place as well. + * + * @example + * ```ts + * observer.setOptions({ + * mutationFn: (variables: { title: string }) => addPost(variables), + * onSuccess: (data) => console.log(data), + * }) + * ``` + */ setOptions( options: MutationObserverOptions< TData, @@ -107,6 +138,7 @@ export class MutationObserver< } } + /** @internal */ onMutationUpdate( action: Action, ): void { @@ -115,6 +147,11 @@ export class MutationObserver< this.#notify(action) } + /** + * Returns the observer's current result, derived from the observed + * mutation's state (or the default, `idle` state if no mutation has been + * built yet, e.g. before the first `mutate()` call or after `reset()`). + */ getCurrentResult(): MutationObserverResult< TData, TError, @@ -124,6 +161,22 @@ export class MutationObserver< return this.#currentResult } + /** + * Detaches the observer from the mutation it is currently observing (if + * any) and resets the observed result back to its default, `idle` state. + * + * This does not cancel an in-flight mutation; the mutation itself keeps + * running to completion and its own callbacks still fire, but this + * observer stops reflecting its state and a subsequent `mutate()` call + * will build a brand new mutation. + * + * @example + * ```ts + * observer.reset() + * ``` + * + * @see {@link MutationObserver#mutate} + */ reset(): void { // reset needs to remove the observer from the mutation because there is no way to "get it back" // another mutate call will yield a new mutation! @@ -133,6 +186,24 @@ export class MutationObserver< this.#notify() } + /** + * Builds a new `Mutation` in the `MutationCache` using the observer's + * current options, detaches this observer from any previously observed + * mutation, attaches it to the new one, and executes it with the given + * variables. + * + * The optional per-call `options` (`onSuccess`/`onError`/`onSettled`) are + * invoked once the mutation settles, in addition to any callbacks defined + * on the observer's own options. + * + * @example + * ```ts + * await observer.mutate( + * { title: 'New post' }, + * { onSuccess: (data) => console.log(data) }, + * ) + * ``` + */ mutate( variables: TVariables, options?: MutateOptions, diff --git a/packages/query-core/src/notifyManager.ts b/packages/query-core/src/notifyManager.ts index f4deb73194b..38c2b10f570 100644 --- a/packages/query-core/src/notifyManager.ts +++ b/packages/query-core/src/notifyManager.ts @@ -12,6 +12,10 @@ type BatchCallsCallback> = (...args: T) => void type ScheduleFunction = (callback: () => void) => void +/** + * Default scheduling function used by the notify manager. + * Schedules the callback with the system's `setTimeout(callback, 0)`. + */ export const defaultScheduler: ScheduleFunction = systemSetTimeoutZero export function createNotifyManager() { @@ -49,6 +53,12 @@ export function createNotifyManager() { } return { + /** + * Batches all updates scheduled inside the passed callback. + * This is mainly used internally to optimize query client updating. + * Batches can be nested; the queue is only flushed once the outermost `batch` call finishes. + * The return value of `callback` is passed through. + */ batch: (callback: () => T): T => { let result transactions++ @@ -74,6 +84,10 @@ export function createNotifyManager() { }) } }, + /** + * Schedules a function to be run on the next batch. + * By default, the batch is run with a `setTimeout`, but this can be configured via `setScheduler`. + */ schedule, /** * Use this method to set a custom notify function. @@ -84,11 +98,38 @@ export function createNotifyManager() { }, /** * Use this method to set a custom function to batch notifications together into a single tick. - * By default React Query will use the batch function provided by ReactDOM or React Native. + * Framework adapters use this to plug in their own batching primitive, so that a single query + * update only triggers one re-render instead of one per subscriber. + * + * @example + * ```ts + * import { notifyManager } from '@tanstack/query-core' + * import { batch } from 'solid-js' + * + * notifyManager.setBatchNotifyFunction(batch) + * ``` */ setBatchNotifyFunction: (fn: BatchNotifyFunction) => { batchNotifyFn = fn }, + /** + * Configures a custom callback that schedules when the next batch runs. + * The default behavior is `setTimeout(callback, 0)`. + * + * @example + * ```ts + * import { notifyManager } from '@tanstack/query-core' + * + * // Schedule batches in the next microtask + * notifyManager.setScheduler(queueMicrotask) + * + * // Schedule batches before the next frame is rendered + * notifyManager.setScheduler(requestAnimationFrame) + * + * // Schedule batches some time in the future + * notifyManager.setScheduler((cb) => setTimeout(cb, 10)) + * ``` + */ setScheduler: (fn: ScheduleFunction) => { scheduleFn = fn }, @@ -96,4 +137,8 @@ export function createNotifyManager() { } // SINGLETON + +/** + * Handles scheduling and batching callbacks in TanStack Query. + */ export const notifyManager = createNotifyManager() diff --git a/packages/query-core/src/onlineManager.ts b/packages/query-core/src/onlineManager.ts index 6c59a14b908..7a0c9b665d7 100644 --- a/packages/query-core/src/onlineManager.ts +++ b/packages/query-core/src/onlineManager.ts @@ -3,6 +3,15 @@ import { Subscribable } from './subscribable' type Listener = (online: boolean) => void type SetupFn = (setOnline: Listener) => (() => void) | undefined +/** + * The `OnlineManager` manages the online state within TanStack Query. It can + * be used to change the default event listeners or to manually change the + * online state. + * + * By default, the `onlineManager` assumes an active network connection, and + * listens to the `online` and `offline` events on the `window` object to + * detect changes. + */ export class OnlineManager extends Subscribable { #online = true #cleanup?: () => void @@ -45,12 +54,44 @@ export class OnlineManager extends Subscribable { } } + /** + * `setEventListener` can be used to set a custom event listener that will + * be used to determine the online state. The provided `setup` function + * receives a `setOnline` callback that should be called with a `boolean` + * whenever the online state changes. + * + * @example + * ```ts + * import NetInfo from '@react-native-community/netinfo' + * import { onlineManager } from '@tanstack/query-core' + * + * onlineManager.setEventListener((setOnline) => { + * return NetInfo.addEventListener((state) => { + * setOnline(!!state.isConnected) + * }) + * }) + * ``` + */ setEventListener(setup: SetupFn): void { this.#setup = setup this.#cleanup?.() this.#cleanup = setup(this.setOnline.bind(this)) } + /** + * `setOnline` can be used to manually set the online state. + * + * @example + * ```ts + * import { onlineManager } from '@tanstack/query-core' + * + * // Set to online + * onlineManager.setOnline(true) + * + * // Set to offline + * onlineManager.setOnline(false) + * ``` + */ setOnline(online: boolean): void { const changed = this.#online !== online @@ -62,9 +103,15 @@ export class OnlineManager extends Subscribable { } } + /** + * `isOnline` can be used to get the current online state. + */ isOnline(): boolean { return this.#online } } +/** + * Singleton instance of {@link OnlineManager}, used to manage and observe the online state within TanStack Query. + */ export const onlineManager = new OnlineManager() diff --git a/packages/query-core/src/queriesObserver.ts b/packages/query-core/src/queriesObserver.ts index ce348c9ca52..cbffcfc830f 100644 --- a/packages/query-core/src/queriesObserver.ts +++ b/packages/query-core/src/queriesObserver.ts @@ -23,9 +23,36 @@ type CombineFn = ( export interface QueriesObserverOptions< TCombinedResult = Array, > { + /** + * A function that combines the array of `QueryObserverResult`s (one per + * observed query) into a single value. The combined value is memoized and + * only recomputed when one of the underlying results, the query hashes, or + * the `combine` function itself changes. + * + * Defaults to returning the array of `QueryObserverResult`s unchanged. + */ combine?: CombineFn } +/** + * A `QueriesObserver` watches an array of queries at once, exposing them as + * a single array of `QueryObserverResult`s (or, when a `combine` option is + * given, as a combined value derived from that array). It manages one + * internal `QueryObserver` per query, and is the primitive that framework + * adapters (e.g. `useQueries`) build their hooks on top of. + * + * @example + * ```ts + * const observer = new QueriesObserver(queryClient, [ + * { queryKey: ['post', 1], queryFn: fetchPost }, + * { queryKey: ['post', 2], queryFn: fetchPost }, + * ]) + * + * const unsubscribe = observer.subscribe((result) => { + * console.log(result) + * }) + * ``` + */ export class QueriesObserver< TCombinedResult = Array, > extends Subscribable { @@ -72,6 +99,10 @@ export class QueriesObserver< } } + /** + * Stops observing all queries: clears all listeners and destroys every + * underlying `QueryObserver` this observer manages. + */ destroy(): void { this.listeners = new Set() this.#observers.forEach((observer) => { @@ -79,6 +110,20 @@ export class QueriesObserver< }) } + /** + * Replaces the set of queries being observed. Existing `QueryObserver`s + * are reused for queries that match an already-observed query hash; + * observers for queries that are no longer present are destroyed, and new + * observers are created and subscribed to for newly added queries. + * + * @example + * ```ts + * observer.setQueries([ + * { queryKey: ['post', 1], queryFn: fetchPost }, + * { queryKey: ['post', 3], queryFn: fetchPost }, + * ]) + * ``` + */ setQueries( queries: Array, options?: QueriesObserverOptions, @@ -151,18 +196,45 @@ export class QueriesObserver< }) } + /** + * Returns the most recently computed array of `QueryObserverResult`s, one + * per observed query, in the same order as the queries passed to the + * constructor or `setQueries`. + * + * @example + * ```ts + * const results = observer.getCurrentResult() + * const data = results.map((result) => result.data) + * ``` + */ getCurrentResult(): Array { return this.#result } + /** + * Returns the underlying `Query` instances currently being observed, in + * the same order as the queries passed to the constructor or `setQueries`. + */ getQueries() { return this.#observers.map((observer) => observer.getCurrentQuery()) } + /** + * Returns the underlying `QueryObserver` instances this observer manages, + * in the same order as the queries passed to the constructor or + * `setQueries`. + */ getObservers() { return this.#observers } + /** + * The `QueriesObserver` counterpart of {@link QueryObserver#getOptimisticResult} — computes + * the result for the given (already-defaulted) queries right now, synchronously. Called by + * framework adapters (e.g. `useQueries`) ahead of subscribing, returning a tuple of the raw + * per-query results, a function to compute the combined result from them, and a function to + * wrap the results for property-access tracking. + */ getOptimisticResult( queries: Array, combine: CombineFn | undefined, diff --git a/packages/query-core/src/query.ts b/packages/query-core/src/query.ts index aa18e975af7..bc35f0fceb2 100644 --- a/packages/query-core/src/query.ts +++ b/packages/query-core/src/query.ts @@ -45,18 +45,70 @@ interface QueryConfig< state?: QueryState } +/** + * The raw state stored on a `Query` instance. This is the underlying state + * that observer results (e.g. `QueryObserverResult`) are derived from. + */ export interface QueryState { + /** + * The last successfully resolved data for the query. + */ data: TData | undefined + /** + * The number of times the query has successfully resolved. + */ dataUpdateCount: number + /** + * The timestamp for when the query most recently returned the `status` as `"success"`. + */ dataUpdatedAt: number + /** + * The error object for the query, if the last attempt resulted in an error. + * - Defaults to `null`. + */ error: TError | null + /** + * The sum of all errors, incremented every time the query resolves with an error. + */ errorUpdateCount: number + /** + * The timestamp for when the query most recently returned the `status` as `"error"`. + */ errorUpdatedAt: number + /** + * The failure count for the current fetch. + * - Incremented every time the fetch fails. + * - Reset to `0` when the fetch succeeds. + */ fetchFailureCount: number + /** + * The reason the current fetch failed, as reported by the retryer. + * - Reset to `null` when the fetch succeeds. + */ fetchFailureReason: TError | null + /** + * Metadata passed to the currently in-flight (or most recent) fetch, e.g. the + * `fetchMore` direction for infinite queries. + */ fetchMeta: FetchMeta | null + /** + * Whether the query has been marked as invalidated via `invalidate()`. + * - Reset to `false` whenever the query resolves successfully. + */ isInvalidated: boolean + /** + * The status of the query. + * - `pending` if there's no cached data and no attempt was finished yet. + * - `error` if the last attempt resulted in an error. + * - `success` if the query has data. + */ status: QueryStatus + /** + * The fetch status of the query. + * - `fetching`: the `queryFn` is currently executing. + * - `paused`: a fetch wanted to run but has been paused (see network mode). + * - `idle`: the query is not fetching. + */ fetchStatus: FetchStatus } @@ -151,6 +203,25 @@ export type Action = // CLASS +/** + * Represents a single cached query. A `Query` holds the query's key, options, + * state (data/error/status), and the observers currently subscribed to it. + * + * Instances are created and managed internally by `QueryCache`; application + * code typically interacts with queries indirectly through `QueryClient` or + * a framework hook like `useQuery`. Direct access to a `Query` instance is + * possible via `queryCache.find()`/`findAll()` for inspecting cache state. + * + * @example + * ```ts + * const queryCache = queryClient.getQueryCache() + * const query = queryCache.find({ queryKey: ['posts'] }) + * + * if (query) { + * console.log(query.state.dataUpdatedAt) + * } + * ``` + */ export class Query< TQueryFnData = unknown, TError = DefaultError, @@ -187,18 +258,27 @@ export class Query< this.state = config.state ?? this.#initialState this.scheduleGc() } + /** + * The `meta` object passed in the query's options, if any. + */ get meta(): QueryMeta | undefined { return this.options.meta } + /** @internal */ get queryType() { return this.#queryType } + /** + * The promise for the currently in-flight fetch, if the query is fetching. + * `undefined` when the query is not fetching. + */ get promise(): Promise | undefined { return this.#retryer?.promise } + /** @internal */ setOptions( options?: QueryOptions, ): void { @@ -228,6 +308,7 @@ export class Query< } } + /** @internal */ setData( newData: TData, options?: SetDataOptions & { manual: boolean }, @@ -245,37 +326,77 @@ export class Query< return data } + /** + * Merges the given partial state directly into this query's state, notifying observers. Used + * by persistence and broadcast plugins to restore a state snapshot, and by devtools to let a + * user manually trigger a loading/error state or edit the cached data. + */ setState(state: Partial>): void { this.#dispatch({ type: 'setState', state }) } + /** + * Cancels the query's currently in-flight fetch, if any. + * - Returns a promise that resolves once the cancellation has settled. + * - If no fetch is in progress, resolves immediately. + * + * @example + * ```ts + * await query.cancel() + * ``` + */ cancel(options?: CancelOptions): Promise { const promise = this.#retryer?.promise this.#retryer?.cancel(options) return promise ? promise.then(noop).catch(noop) : Promise.resolve() } + /** + * Clears the query's garbage collection timeout and silently cancels any + * in-flight fetch. Called by `QueryCache` when the query is removed from + * the cache. + * + * @see {@link Query#cancel} + */ destroy(): void { super.destroy() this.cancel({ silent: true }) } + /** @internal */ get resetState(): QueryState { return this.#initialState } + /** + * Resets the query back to its initial state (the state it had when it was + * first created, e.g. any `initialData`), destroying it first to cancel any + * in-flight fetch. + */ reset(): void { this.destroy() this.setState(this.resetState) } + /** + * Returns `true` if the query has at least one observer for which `enabled` + * does not resolve to `false`. + */ isActive(): boolean { return this.observers.some( (observer) => resolveQueryValue(observer.options.enabled, this) !== false, ) } + /** + * Returns `true` if the query is disabled, meaning it will not fetch + * automatically. + * - If the query has observers, it is disabled when none of them are active + * (see `isActive`). + * - If the query has no observers, it is disabled when its `queryFn` is + * `skipToken` or it has never been fetched. + */ isDisabled(): boolean { if (this.getObserversCount() > 0) { return !this.isActive() @@ -284,10 +405,18 @@ export class Query< return this.options.queryFn === skipToken || !this.isFetched() } + /** + * Returns `true` if the query has been fetched, i.e. it has resolved with + * either data or an error at least once. + */ isFetched() { return this.state.dataUpdateCount + this.state.errorUpdateCount > 0 } + /** + * Returns `true` if the query has at least one observer configured with + * `staleTime: 'static'`, meaning it is treated as never stale. + */ isStatic(): boolean { if (this.getObserversCount() > 0) { return this.observers.some( @@ -299,6 +428,22 @@ export class Query< return false } + /** + * Returns `true` if the query is stale. + * - If the query has observers, defers to whether any observer's current + * result reports `isStale` (which accounts for each observer's own + * `staleTime` and `enabled` state). + * - If the query has no observers, it is considered stale when it has no + * data or has been invalidated. + * + * @see {@link Query#isStaleByTime} + * @example + * ```ts + * if (query.isStale()) { + * // refetch or otherwise treat the cached data as outdated + * } + * ``` + */ isStale(): boolean { // check observers first, their `isStale` has the source of truth // calculated with `isStaleByTime` and it takes `enabled` into account @@ -311,6 +456,20 @@ export class Query< return this.state.data === undefined || this.state.isInvalidated } + /** + * Returns `true` if the query's data is stale relative to the given + * `staleTime` (defaults to `0`). + * - A query with no data is always stale. + * - `staleTime: 'static'` is never stale. + * - An invalidated query is always stale. + * - Otherwise, staleness is based on elapsed time since `dataUpdatedAt`. + * + * @see {@link Query#isStale} + * @example + * ```ts + * const isStale = query.isStaleByTime(1000 * 60) + * ``` + */ isStaleByTime(staleTime: StaleTime = 0): boolean { // no data is always stale if (this.state.data === undefined) { @@ -328,6 +487,7 @@ export class Query< return !timeUntilStale(this.state.dataUpdatedAt, staleTime) } + /** @internal */ onFocus(): void { const observer = this.observers.find((x) => x.shouldFetchOnWindowFocus()) @@ -337,6 +497,7 @@ export class Query< this.#retryer?.continue() } + /** @internal */ onOnline(): void { const observer = this.observers.find((x) => x.shouldFetchOnReconnect()) @@ -346,6 +507,7 @@ export class Query< this.#retryer?.continue() } + /** @internal */ addObserver(observer: QueryObserver): void { if (!this.observers.includes(observer)) { this.observers.push(observer) @@ -357,6 +519,7 @@ export class Query< } } + /** @internal */ removeObserver(observer: QueryObserver): void { const index = this.observers.indexOf(observer) if (index !== -1) { @@ -384,16 +547,46 @@ export class Query< } } + /** + * Returns the number of observers currently subscribed to this query. + * + * @example + * ```ts + * if (query.getObserversCount() === 0) { + * // no component is currently watching this query + * } + * ``` + */ getObserversCount(): number { return this.observers.length } + /** + * Marks the query as invalidated, unless it is already invalidated. This + * updates `state.isInvalidated` and notifies observers, but does not by + * itself trigger a refetch. + * + * @example + * ```ts + * query.invalidate() + * ``` + */ invalidate(): void { if (!this.state.isInvalidated) { this.#dispatch({ type: 'invalidate' }) } } + /** + * Fetches the query, i.e. runs its `queryFn` (through any configured + * retryer/behavior) and updates the query's state with the result. + * - If a fetch is already in flight, returns its promise instead of + * starting a new one, unless `fetchOptions.cancelRefetch` is set and the + * query already has data, in which case the current fetch is silently + * cancelled first. + * - If `options` is passed, it replaces the query's current options + * before fetching. + */ async fetch( options?: QueryOptions, fetchOptions?: FetchOptions, diff --git a/packages/query-core/src/queryCache.ts b/packages/query-core/src/queryCache.ts index 030f0920427..84de5fa8259 100644 --- a/packages/query-core/src/queryCache.ts +++ b/packages/query-core/src/queryCache.ts @@ -16,12 +16,21 @@ import type { QueryObserver } from './queryObserver' // TYPES +/** + * Global callbacks that fire for every query handled by a `QueryCache`, regardless of which + * component or observer triggered it. Unlike `QueryClient`'s `defaultOptions`, which a query can + * override, these callbacks are always called. Unlike `MutationCacheConfig`'s callbacks, these + * are fire-and-forget: their return value is not awaited before the query settles. + */ export interface QueryCacheConfig { + /** Called when any query in the cache encounters an error. */ onError?: ( error: DefaultError, query: Query, ) => void + /** Called when any query in the cache is successful. */ onSuccess?: (data: unknown, query: Query) => void + /** Called when any query in the cache is settled, either successfully or with an error. */ onSettled?: ( data: unknown | undefined, error: DefaultError | null, @@ -68,6 +77,11 @@ interface NotifyEventQueryObserverOptionsUpdated extends NotifyEvent { observer: QueryObserver } +/** + * The event passed to a `QueryCache` subscriber. Fired whenever a query is added or removed from + * the cache, its state is updated (e.g. via `query.setState` or `queryClient.removeQueries`), or + * one of its observers is added, removed, or has its results or options updated. + */ export type QueryCacheNotifyEvent = | NotifyEventQueryAdded | NotifyEventQueryRemoved @@ -89,6 +103,23 @@ export interface QueryStore { // CLASS +/** + * The `QueryCache` is the storage mechanism for TanStack Query. It stores all the data, meta + * information, and state of the queries it contains. + * + * Normally, you will not interact with the `QueryCache` directly and instead use a `QueryClient` + * for a specific cache. You can subscribe to it (inherited from `Subscribable`) to be informed of + * safe/known updates to the cache, such as queries being added, removed, or updated — updates made + * outside of the cache's own tracked mechanisms (e.g. mutating a query's state object directly) do + * not notify subscribers. + * + * @example + * ```ts + * const unsubscribe = queryCache.subscribe((event) => { + * console.log(event.type, event.query) + * }) + * ``` + */ export class QueryCache extends Subscribable { #queries: QueryStore @@ -97,6 +128,22 @@ export class QueryCache extends Subscribable { this.#queries = new Map() } + /** + * Returns the existing `Query` instance for the given options' `queryKey`/`queryHash`, or + * builds and adds a new one to the cache if none exists yet. Used by framework adapters and + * plugins (e.g. broadcast/persistence) that need to get-or-create a `Query` directly, bypassing + * the reactive `QueryObserver` machinery. + * + * @example + * ```ts + * const queryCache = queryClient.getQueryCache() + * + * const query = queryCache.build(queryClient, { + * queryKey: ['posts'], + * queryFn: fetchPosts, + * }) + * ``` + */ build< TQueryFnData = unknown, TError = DefaultError, @@ -130,6 +177,7 @@ export class QueryCache extends Subscribable { return query } + /** @internal */ add(query: Query): void { if (!this.#queries.has(query.queryHash)) { this.#queries.set(query.queryHash, query) @@ -141,6 +189,22 @@ export class QueryCache extends Subscribable { } } + /** + * Destroys the given `Query` and removes it from the cache, notifying subscribers with a + * `'removed'` event. A no-op if the query is no longer the one currently stored under its hash + * (e.g. it was already replaced). Used by plugins (e.g. the broadcast client) that mirror + * removals across `QueryCache` instances. + * + * @example + * ```ts + * const queryCache = queryClient.getQueryCache() + * const query = queryCache.find({ queryKey: ['posts'] }) + * + * if (query) { + * queryCache.remove(query) + * } + * ``` + */ remove(query: Query): void { const queryInMap = this.#queries.get(query.queryHash) @@ -155,6 +219,16 @@ export class QueryCache extends Subscribable { } } + /** + * Removes all queries from the cache. + * + * @example + * ```ts + * const queryCache = queryClient.getQueryCache() + * + * queryCache.clear() + * ``` + */ clear(): void { notifyManager.batch(() => { this.getAll().forEach((query) => { @@ -163,6 +237,20 @@ export class QueryCache extends Subscribable { }) } + /** + * Returns the `Query` instance stored under the given `queryHash`, or `undefined` if none + * exists. Unlike {@link QueryCache#find}, this looks up by the already-computed hash rather + * than by `QueryFilters`. Used by plugins (e.g. broadcast/hydration) that already have a hash + * to look up directly. + * + * @example + * ```ts + * const queryCache = queryClient.getQueryCache() + * const queryHash = hashKey(['posts']) + * + * const query = queryCache.get(queryHash) + * ``` + */ get< TQueryFnData = unknown, TError = DefaultError, @@ -176,10 +264,38 @@ export class QueryCache extends Subscribable { | undefined } + /** + * Returns all queries within the cache. + * + * @example + * ```ts + * const queryCache = queryClient.getQueryCache() + * + * const queries = queryCache.getAll() + * ``` + */ getAll(): Array { return [...this.#queries.values()] } + /** + * A slightly more advanced method that can be used to get an existing query instance from the + * cache. This instance not only contains all the state for the query, but all of the instances, + * and underlying guts of the query as well. If the query does not exist, `undefined` is + * returned. + * + * This is not typically needed for most applications, but can come in handy when needing more + * information about a query in rare scenarios (e.g. looking at `query.state.dataUpdatedAt` to + * decide whether a query is fresh enough to be used as an initial value). + * + * @see {@link QueryCache#findAll} + * @example + * ```ts + * const queryCache = queryClient.getQueryCache() + * + * const query = queryCache.find({ queryKey: ['posts'] }) + * ``` + */ find( filters: WithRequired, ): Query | undefined { @@ -190,6 +306,21 @@ export class QueryCache extends Subscribable { ) as Query | undefined } + /** + * An even more advanced method that can be used to get existing query instances from the cache + * that partially match a query key. If no queries match, an empty array is returned. + * + * This is not typically needed for most applications, but can come in handy when needing more + * information about queries in rare scenarios. + * + * @see {@link QueryCache#find} + * @example + * ```ts + * const queryCache = queryClient.getQueryCache() + * + * const queries = queryCache.findAll({ queryKey: ['posts'] }) + * ``` + */ findAll(filters: QueryFilters = {}): Array { const queries = this.getAll() return Object.keys(filters).length > 0 @@ -197,6 +328,7 @@ export class QueryCache extends Subscribable { : queries } + /** @internal */ notify(event: QueryCacheNotifyEvent): void { notifyManager.batch(() => { this.listeners.forEach((listener) => { @@ -205,6 +337,7 @@ export class QueryCache extends Subscribable { }) } + /** @internal */ onFocus(): void { notifyManager.batch(() => { this.getAll().forEach((query) => { @@ -213,6 +346,7 @@ export class QueryCache extends Subscribable { }) } + /** @internal */ onOnline(): void { notifyManager.batch(() => { this.getAll().forEach((query) => { diff --git a/packages/query-core/src/queryClient.ts b/packages/query-core/src/queryClient.ts index 03dbcadb55c..32867984209 100644 --- a/packages/query-core/src/queryClient.ts +++ b/packages/query-core/src/queryClient.ts @@ -58,6 +58,24 @@ interface MutationDefaults { // CLASS +/** + * `QueryClient` is used to interact with a cache of queries and mutations. It owns a + * `QueryCache` and a `MutationCache` (creating default ones if none are passed in) and holds + * the default options that are applied to queries and mutations created through it. + * + * @example + * ```ts + * const queryClient = new QueryClient({ + * defaultOptions: { + * queries: { + * staleTime: Infinity, + * }, + * }, + * }) + * + * await queryClient.query({ queryKey: ['posts'], queryFn: fetchPosts }) + * ``` + */ export class QueryClient { #queryCache: QueryCache #mutationCache: MutationCache @@ -77,6 +95,12 @@ export class QueryClient { this.#mountCount = 0 } + /** + * Called by a framework adapter's `QueryClientProvider`-equivalent when it mounts, to start + * listening for focus/online events and resume paused mutations. Ref-counted via an internal + * mount count, so nested or multiple providers sharing the same `QueryClient` don't tear down + * the shared listeners until the last one unmounts. + */ mount(): void { this.#mountCount++ if (this.#mountCount !== 1) return @@ -95,6 +119,11 @@ export class QueryClient { }) } + /** + * The inverse of {@link QueryClient#mount} — called by a framework adapter's + * `QueryClientProvider`-equivalent when it unmounts. Only tears down the focus/online + * listeners once the mount count returns to `0`. + */ unmount(): void { this.#mountCount-- if (this.#mountCount !== 0) return @@ -106,6 +135,18 @@ export class QueryClient { this.#unsubscribeOnline = undefined } + /** + * Returns the number of queries in the cache that are currently fetching, optionally + * matching a set of filters. This includes background-fetching, loading new pages, and + * loading more infinite query results. + * + * @example + * ```ts + * if (queryClient.isFetching()) { + * console.log('At least one query is fetching!') + * } + * ``` + */ isFetching = QueryFilters>( filters?: TQueryFilters, ): number { @@ -113,6 +154,17 @@ export class QueryClient { .length } + /** + * Returns the number of mutations in the cache that are currently pending, optionally + * matching a set of filters. + * + * @example + * ```ts + * if (queryClient.isMutating()) { + * console.log('At least one mutation is pending!') + * } + * ``` + */ isMutating< TMutationFilters extends MutationFilters = MutationFilters, >(filters?: TMutationFilters): number { @@ -125,6 +177,8 @@ export class QueryClient { * * Hint: Do not use this function inside a component, because it won't receive updates. * Use `useQuery` to create a `QueryObserver` that subscribes to changes. + * + * @see {@link QueryClient#getQueriesData} */ getQueryData< TQueryFnData = unknown, @@ -166,6 +220,23 @@ export class QueryClient { return Promise.resolve(cachedData) } + /** + * Imperative (non-reactive) way to retrieve the cached data of multiple queries at once. + * Only queries matching the given filters are returned; if none match, an empty array is + * returned. + * + * Because the matched queries can hold data of different shapes (e.g. a broad filter can match + * queries with unrelated data types), the `TQueryFnData` generic defaults to `unknown` rather + * than being inferred. Passing a more specific type is a convenience for call sites that know + * every matched query holds the same shape — it is not checked against the actual cache + * contents. + * + * @see {@link QueryClient#getQueryData} + * @example + * ```ts + * const data = queryClient.getQueriesData({ queryKey: ['posts'] }) + * ``` + */ getQueriesData< TQueryFnData = unknown, TQueryFilters extends QueryFilters = QueryFilters, @@ -176,6 +247,27 @@ export class QueryClient { }) } + /** + * Synchronous way to immediately update a query's cached data. If the updater (or the value + * passed) resolves to `undefined`, the cache is left untouched and no query is created; + * otherwise, if the query does not exist yet, it will be created. To update multiple queries + * at once by partially matching query keys, use {@link QueryClient#setQueriesData} instead. + * + * Updates must be performed immutably: do not mutate `oldData`, or data previously retrieved + * via {@link QueryClient#getQueryData}, in place. + * + * @param queryKey - The query key to set data for. + * @param updater - Either the new data, or a function that receives the current data (which + * may be `undefined`) and returns the new data. + * + * @example + * ```ts + * queryClient.setQueryData(['posts'], newPosts) + * + * // Or, using an updater function that receives the current data: + * queryClient.setQueryData(['posts'], (oldPosts) => [...oldPosts, newPost]) + * ``` + */ setQueryData< TQueryFnData = unknown, TTaggedQueryKey extends QueryKey = QueryKey, @@ -211,6 +303,19 @@ export class QueryClient { .setData(data, { ...options, manual: true }) } + /** + * Synchronous way to immediately update the cached data of multiple queries at once, using + * filters or partial query key matching. Only queries that already exist and match the given + * filters are updated; no new cache entries are created. Internally this calls + * {@link QueryClient#setQueryData} for each matching query. + * + * @example + * ```ts + * queryClient.setQueriesData({ queryKey: ['posts'] }, (oldPosts) => + * oldPosts ? oldPosts.filter((post) => post.id !== deletedId) : oldPosts, + * ) + * ``` + */ setQueriesData< TQueryFnData, TQueryFilters extends QueryFilters = QueryFilters, @@ -232,6 +337,16 @@ export class QueryClient { ) } + /** + * Imperative (non-reactive) way to retrieve an existing query's state. If the query does not + * exist, `undefined` is returned. + * + * @example + * ```ts + * const state = queryClient.getQueryState(['posts']) + * console.log(state?.dataUpdatedAt) + * ``` + */ getQueryState< TQueryFnData = unknown, TError = DefaultError, @@ -247,6 +362,17 @@ export class QueryClient { )?.state } + /** + * Removes queries from the cache that match the given filters. Unlike + * {@link QueryClient#invalidateQueries} or {@link QueryClient#refetchQueries}, this removes + * matching queries from the cache instead of refetching them. Without filters, every query in + * the cache is removed. + * + * @example + * ```ts + * queryClient.removeQueries({ queryKey: ['posts'], exact: true }) + * ``` + */ removeQueries( filters?: QueryFilters, ): void { @@ -258,6 +384,16 @@ export class QueryClient { }) } + /** + * Resets queries matching the given filters back to their initial state (e.g. any + * `initialData`), notifying subscribers rather than removing them. Active queries among the + * matched set are then refetched, and the returned promise resolves once that refetch settles. + * + * @example + * ```ts + * await queryClient.resetQueries({ queryKey: ['posts'], exact: true }) + * ``` + */ resetQueries( filters?: QueryFilters, options?: ResetOptions, @@ -280,6 +416,19 @@ export class QueryClient { }) } + /** + * Cancels outgoing fetches for queries matching the given filters. Most useful when performing + * optimistic updates, since any outgoing refetch that resolves afterwards would otherwise + * overwrite the optimistic update. By default (`revert: true`), a cancelled query's data is + * reverted to its state before the outgoing fetch started. + * + * The returned promise never rejects, even if individual cancellations fail. + * + * @example + * ```ts + * await queryClient.cancelQueries({ queryKey: ['posts'], exact: true }) + * ``` + */ cancelQueries( filters?: QueryFilters, cancelOptions: CancelOptions = {}, @@ -295,6 +444,19 @@ export class QueryClient { return Promise.all(promises).then(noop).catch(noop) } + /** + * Marks queries matching the given filters as invalidated. Unlike + * {@link QueryClient#removeQueries}, invalidated queries stay in the cache. + * + * Unless `filters.refetchType` is `'none'`, matching queries are then refetched via + * {@link QueryClient#refetchQueries}, using `filters.refetchType` if set, otherwise + * `filters.type`, otherwise `'active'`. + * + * @example + * ```ts + * await queryClient.invalidateQueries({ queryKey: ['posts'], refetchType: 'active' }) + * ``` + */ invalidateQueries( filters?: InvalidateQueryFilters, options: InvalidateOptions = {}, @@ -317,6 +479,21 @@ export class QueryClient { }) } + /** + * Refetches queries matching the given filters, regardless of whether they are stale. Without + * filters, every query in the cache is refetched. Queries that are disabled, or static (only + * have observers with a static `staleTime`), are never refetched. + * + * By default (`cancelRefetch: true`), a currently running fetch is cancelled before the new + * one starts. The returned promise resolves once all matching queries have settled; it does + * not reject on individual query failures unless `throwOnError` is set. + * + * @example + * ```ts + * // refetch all active queries partially matching a query key: + * await queryClient.refetchQueries({ queryKey: ['posts'], type: 'active' }) + * ``` + */ refetchQueries( filters?: RefetchQueryFilters, options: RefetchOptions = {}, @@ -343,6 +520,37 @@ export class QueryClient { return Promise.all(promises).then(noop) } + /** + * Asynchronous method to fetch and cache a query, resolving with the data or throwing with + * the error. + * + * If the query already exists in the cache and its data is not stale (per the given + * `staleTime`), the cached data is returned without fetching. Otherwise, the query is fetched + * and the promise resolves once the fetch settles. If a `select` function is provided, it is + * applied to the data in both cases (cached or freshly fetched) before it is returned. + * + * Unlike a reactive observer, retries are disabled by default here (`retry: false`) unless + * explicitly configured, since there is no component to catch a thrown error and retry through + * re-render. + * + * The accepted options are `QueryObserverOptions` minus the fields that only make sense for a + * reactive observer — `enabled`, `refetchInterval`, `refetchIntervalInBackground`, + * `refetchOnWindowFocus`, `refetchOnReconnect`, `refetchOnMount`, `retryOnMount`, + * `notifyOnChangeProps`, `throwOnError`, `suspense`, and `placeholderData` are not part of this + * method's options. + * + * This method replaces the deprecated `fetchQuery`, and — combined with + * `{ staleTime: 'static' }` — the deprecated `ensureQueryData`. + * + * @example + * ```ts + * try { + * const data = await queryClient.query({ queryKey, queryFn, staleTime: 10000 }) + * } catch (error) { + * console.log(error) + * } + * ``` + */ async query< TQueryFnData, TError = DefaultError, @@ -434,6 +642,27 @@ export class QueryClient { return this.fetchQuery(options).then(noop).catch(noop) } + /** + * Asynchronous method to fetch and cache an infinite query, resolving with an + * {@link InfiniteData} object or throwing with the error. + * + * Behaves like {@link QueryClient#query}, accepting the same options (minus + * `initialPageParam`), plus the required `initialPageParam`, and an optional `pages` / + * `getNextPageParam` pair used to refetch a fixed number of pages from the start. + * + * This method replaces the deprecated `fetchInfiniteQuery`, and — combined with + * `{ staleTime: 'static' }` — the deprecated `ensureInfiniteQueryData`. + * + * @example + * ```ts + * try { + * const data = await queryClient.infiniteQuery({ queryKey, queryFn, initialPageParam: 0 }) + * console.log(data.pages) + * } catch (error) { + * console.log(error) + * } + * ``` + */ infiniteQuery< TQueryFnData, TError = DefaultError, @@ -523,6 +752,18 @@ export class QueryClient { return this.ensureQueryData(options as any) } + /** + * Resumes mutations that were paused because there was no network connection. Does nothing + * (resolving immediately) if the client is currently offline. + * + * @example + * ```ts + * import { QueryClient } from '@tanstack/query-core' + * + * const queryClient = new QueryClient() + * await queryClient.resumePausedMutations() + * ``` + */ resumePausedMutations(): Promise { if (onlineManager.isOnline()) { return this.#mutationCache.resumePausedMutations() @@ -530,22 +771,90 @@ export class QueryClient { return Promise.resolve() } + /** + * Returns the query cache this client is connected to. + * + * @example + * ```ts + * import { QueryClient } from '@tanstack/query-core' + * + * const queryClient = new QueryClient() + * const queryCache = queryClient.getQueryCache() + * const queries = queryCache.findAll({ queryKey: ['posts'] }) + * ``` + */ getQueryCache(): QueryCache { return this.#queryCache } + /** + * Returns the mutation cache this client is connected to. + * + * @example + * ```ts + * import { QueryClient } from '@tanstack/query-core' + * + * const queryClient = new QueryClient() + * const mutationCache = queryClient.getMutationCache() + * const mutations = mutationCache.findAll({ status: 'pending' }) + * ``` + */ getMutationCache(): MutationCache { return this.#mutationCache } + /** + * Returns the default options that were set when creating the client, or via + * {@link QueryClient#setDefaultOptions}. + * + * @example + * ```ts + * import { QueryClient } from '@tanstack/query-core' + * + * const queryClient = new QueryClient() + * const defaultOptions = queryClient.getDefaultOptions() + * ``` + */ getDefaultOptions(): DefaultOptions { return this.#defaultOptions } + /** + * Dynamically sets the default options for this client, overwriting any previously defined + * default options. + * + * @see {@link QueryClient#getDefaultOptions} + * @example + * ```ts + * import { QueryClient } from '@tanstack/query-core' + * + * const queryClient = new QueryClient() + * queryClient.setDefaultOptions({ + * queries: { + * staleTime: Infinity, + * }, + * }) + * ``` + */ setDefaultOptions(options: DefaultOptions): void { this.#defaultOptions = options } + /** + * Sets default options for queries whose query key partially matches the given `queryKey`. + * + * If several registered query defaults match a given query key, they are merged together in + * registration order by {@link QueryClient#getQueryDefaults}, so register defaults from the + * most generic key to the least generic one — more specific defaults should be registered + * after more generic ones so they take precedence. + * + * @example + * ```ts + * queryClient.setQueryDefaults(['posts'], { queryFn: fetchPosts }) + * + * await queryClient.query({ queryKey: ['posts'] }) + * ``` + */ setQueryDefaults< TQueryFnData = unknown, TError = DefaultError, @@ -566,6 +875,16 @@ export class QueryClient { }) } + /** + * Returns the default options registered for queries whose query key partially matches the + * given `queryKey`, via {@link QueryClient#setQueryDefaults}. If multiple registered defaults + * match, they are merged together in registration order. + * + * @example + * ```ts + * const defaultOptions = queryClient.getQueryDefaults(['posts']) + * ``` + */ getQueryDefaults( queryKey: QueryKey, ): OmitKeyof, 'queryKey'> { @@ -584,6 +903,17 @@ export class QueryClient { return result } + /** + * Sets default options for mutations whose mutation key partially matches the given + * `mutationKey`. As with {@link QueryClient#setQueryDefaults}, the order of registration + * matters when several registered defaults match the same mutation key. + * + * @see {@link QueryClient#getMutationDefaults} + * @example + * ```ts + * queryClient.setMutationDefaults(['addPost'], { mutationFn: addPost }) + * ``` + */ setMutationDefaults< TData = unknown, TError = DefaultError, @@ -602,6 +932,16 @@ export class QueryClient { }) } + /** + * Returns the default options registered for mutations whose mutation key partially matches + * the given `mutationKey`, via {@link QueryClient#setMutationDefaults}. If multiple registered + * defaults match, they are merged together in registration order. + * + * @example + * ```ts + * const defaultOptions = queryClient.getMutationDefaults(['addPost']) + * ``` + */ getMutationDefaults( mutationKey: MutationKey, ): OmitKeyof, 'mutationKey'> { @@ -621,6 +961,12 @@ export class QueryClient { return result } + /** + * Called by framework adapters (e.g. inside `useQuery`) to resolve the options passed by the + * caller into their final, defaulted form: merging `queryClient.setQueryDefaults` for the + * given `queryKey`, then the client's own `defaultOptions.queries`, then the caller's options + * on top. A no-op if the options are already defaulted (`_defaulted: true`). + */ defaultQueryOptions< TQueryFnData = unknown, TError = DefaultError, @@ -702,6 +1048,12 @@ export class QueryClient { > } + /** + * The mutation counterpart of {@link QueryClient#defaultQueryOptions}. Called by framework + * adapters (e.g. inside `useMutation`) to merge `queryClient.setMutationDefaults` for the + * given `mutationKey`, then the client's `defaultOptions.mutations`, then the caller's options + * on top. A no-op if the options are already defaulted (`_defaulted: true`). + */ defaultMutationOptions>( options?: T, ): T { @@ -717,6 +1069,17 @@ export class QueryClient { } as T } + /** + * Clears both the query cache and the mutation cache this client is connected to. + * + * @example + * ```ts + * import { QueryClient } from '@tanstack/query-core' + * + * const queryClient = new QueryClient() + * queryClient.clear() + * ``` + */ clear(): void { this.#queryCache.clear() this.#mutationCache.clear() diff --git a/packages/query-core/src/queryObserver.ts b/packages/query-core/src/queryObserver.ts index c86b6fa29bf..beb3a2370bc 100644 --- a/packages/query-core/src/queryObserver.ts +++ b/packages/query-core/src/queryObserver.ts @@ -34,6 +34,26 @@ interface ObserverFetchOptions extends FetchOptions { throwOnError?: boolean } +/** + * A `QueryObserver` watches a single query in the `QueryCache` and computes a + * `QueryObserverResult` from its state, recomputing and notifying subscribers + * whenever the underlying query (or the observer's options) changes. It is + * the primitive that framework adapters (e.g. `useQuery`) build their hooks + * on top of, but it can also be used directly to observe and switch between + * queries outside of any framework. + * + * @example + * ```ts + * const observer = new QueryObserver(queryClient, { + * queryKey: ['posts'], + * queryFn: fetchPosts, + * }) + * + * const unsubscribe = observer.subscribe((result) => { + * console.log(result.data) + * }) + * ``` + */ export class QueryObserver< TQueryFnData = unknown, TError = DefaultError, @@ -107,6 +127,11 @@ export class QueryObserver< } } + /** + * Returns whether the observed query is currently stale and configured + * (via the `refetchOnReconnect` option) to refetch when the network + * reconnects. + */ shouldFetchOnReconnect(): boolean { return shouldFetchOn( this.#currentQuery, @@ -115,6 +140,11 @@ export class QueryObserver< ) } + /** + * Returns whether the observed query is currently stale and configured + * (via the `refetchOnWindowFocus` option) to refetch when the window + * regains focus. + */ shouldFetchOnWindowFocus(): boolean { return shouldFetchOn( this.#currentQuery, @@ -123,6 +153,11 @@ export class QueryObserver< ) } + /** + * Stops observing the current query: clears all listeners, cancels the + * stale and refetch-interval timers, and removes this observer from the + * query it was observing. + */ destroy(): void { this.listeners = new Set() this.#clearStaleTimeout() @@ -130,6 +165,20 @@ export class QueryObserver< this.#currentQuery.removeObserver(this) } + /** + * Updates the observer's options. This will re-resolve the query being + * observed (switching to a different query if the `queryKey` changed), + * trigger a fetch if the new options require one and the observer has + * subscribers, recompute the current result, and reschedule the stale and + * refetch-interval timers as needed. + * + * @example + * ```ts + * observer.setOptions({ queryKey: ['posts', 1], queryFn: () => fetchPost(1) }) + * // later: switch to a different query, reusing the same observer + * observer.setOptions({ queryKey: ['posts', 2], queryFn: () => fetchPost(2) }) + * ``` + */ setOptions( options: QueryObserverOptions< TQueryFnData, @@ -214,6 +263,12 @@ export class QueryObserver< } } + /** + * Computes the result the observer would produce for the given (already-defaulted) options + * right now, building the underlying `Query` if it doesn't exist yet, without waiting for a + * subscription callback. Called by framework adapters on every render (e.g. `useQuery`) so the + * returned value is available synchronously, ahead of `setOptions` triggering an actual fetch. + */ getOptimisticResult( options: DefaultedQueryObserverOptions< TQueryFnData, @@ -251,10 +306,28 @@ export class QueryObserver< return result } + /** + * Returns the most recently computed `QueryObserverResult` for the + * observed query. This is a point-in-time read; to be notified of updates + * as they happen, subscribe to the observer instead (its inherited + * `subscribe` method). + * + * @example + * ```ts + * const result = observer.getCurrentResult() + * console.log(result.status, result.data) + * ``` + */ getCurrentResult(): QueryObserverResult { return this.#currentResult } + /** + * Wraps a `QueryObserverResult` in a `Proxy` that records which properties are read, via + * {@link QueryObserver#trackProp} (and an optional `onPropTracked` callback). Used by framework + * adapters when `notifyOnChangeProps` is not set, to implement its default "only re-render on + * properties you actually read" behavior. + */ trackResult( result: QueryObserverResult, onPropTracked?: (key: keyof QueryObserverResult) => void, @@ -268,14 +341,33 @@ export class QueryObserver< }) } + /** + * Records that the given `QueryObserverResult` property was read, so a subsequent update only + * notifies this observer if a tracked property actually changed. Normally called indirectly via + * {@link QueryObserver#trackResult}'s proxy; exposed directly for adapters that track property + * access themselves (e.g. through their own reactivity system) instead of via the proxy. + */ trackProp(key: keyof QueryObserverResult) { this.#trackedProps.add(key) } + /** + * Returns the `Query` instance this observer is currently observing. + */ getCurrentQuery(): Query { return this.#currentQuery } + /** + * Refetches the observed query and returns a promise that resolves with + * the resulting `QueryObserverResult`. + * + * @example + * ```ts + * const result = await observer.refetch({ cancelRefetch: false }) + * console.log(result.data) + * ``` + */ refetch({ ...options }: RefetchOptions = {}): Promise< QueryObserverResult > { @@ -284,6 +376,22 @@ export class QueryObserver< }) } + /** + * Fetches a query defined by the given options without affecting this + * observer's own tracked query or result, and returns a promise that + * resolves with the `QueryObserverResult` for that fetch. This is useful + * for prefetching data that another observer (e.g. a query about to be + * navigated to) will need, ahead of time. + * + * @example + * ```ts + * const result = await observer.fetchOptimistic({ + * queryKey: ['posts', 2], + * queryFn: () => fetchPost(2), + * }) + * console.log(result.data) + * ``` + */ fetchOptimistic( options: QueryObserverOptions< TQueryFnData, @@ -619,6 +727,11 @@ export class QueryObserver< return nextResult } + /** + * Recomputes and stores the current result from the current query/options, notifying listeners + * if it changed. Framework adapters call this right after subscribing to make sure no query + * update was missed in the gap between creating the observer and subscribing to it. + */ updateResult(): void { const prevResult = this.#currentResult as | QueryObserverResult @@ -711,6 +824,7 @@ export class QueryObserver< } } + /** @internal */ onQueryUpdate(): void { this.updateResult() diff --git a/packages/query-core/src/retryer.ts b/packages/query-core/src/retryer.ts index 73fa0746d4b..c951833e5db 100644 --- a/packages/query-core/src/retryer.ts +++ b/packages/query-core/src/retryer.ts @@ -56,6 +56,24 @@ export function canFetch(networkMode: NetworkMode | undefined): boolean { : true } +/** + * The error thrown by a `Retryer` (and surfaced to `query.promise`/`mutation`) when a fetch is cancelled, e.g. via + * `query.cancel()`. `revert`, if `true`, tells the caller to restore the state the query was in before the fetch + * started instead of surfacing the error. `silent`, if `true`, tells the caller to suppress this error and instead + * resolve with the promise of the fetch that triggered the cancellation. + * @example + * ```ts + * query.cancel() + * + * try { + * await query.promise + * } catch (error) { + * if (error instanceof CancelledError) { + * // the fetch was cancelled, e.g. via `query.cancel()` + * } + * } + * ``` + */ export class CancelledError extends Error { revert?: boolean silent?: boolean diff --git a/packages/query-core/src/streamedQuery.ts b/packages/query-core/src/streamedQuery.ts index 534ee47c092..6680747a153 100644 --- a/packages/query-core/src/streamedQuery.ts +++ b/packages/query-core/src/streamedQuery.ts @@ -7,9 +7,16 @@ import type { } from './types' type BaseStreamedQueryParams = { + /** The function that returns an `AsyncIterable` to stream data from. */ streamFn: ( context: QueryFunctionContext, ) => AsyncIterable | Promise> + /** + * Defines how refetches are handled. + * - `'reset'` (default): erases all data and puts the query back into `pending` state. + * - `'append'`: appends new data to the existing data. + * - `'replace'`: writes all data to the cache once the stream ends. + */ refetchMode?: 'append' | 'reset' | 'replace' } @@ -26,7 +33,15 @@ type ReducibleStreamedQueryParams< TData, TQueryKey extends QueryKey, > = BaseStreamedQueryParams & { + /** + * Reduces streamed chunks into the final data shape. Required whenever `TData` is not an + * array, since there is no default way to accumulate non-array chunks. + */ reducer: (acc: TData, chunk: TQueryFnData) => TData + /** + * The value used while the first chunk is being fetched, and returned if the stream yields no + * values. Required together with a custom `reducer`. + */ initialValue: TData } @@ -39,7 +54,7 @@ type StreamedQueryParams = * Data will be an Array of all the chunks received. * The query will be in a 'pending' state until the first chunk of data is received, but will go to 'success' after that. * The query will stay in fetchStatus 'fetching' until the stream ends. - * @param queryFn - The function that returns an AsyncIterable to stream data from. + * @param streamFn - The function that returns an AsyncIterable to stream data from. * @param refetchMode - Defines how re-fetches are handled. * Defaults to `'reset'`, erases all data and puts the query back into `pending` state. * Set to `'append'` to append new data to the existing data. @@ -47,6 +62,15 @@ type StreamedQueryParams = * @param reducer - A function to reduce the streamed chunks into the final data. * Defaults to a function that appends chunks to the end of the array. * @param initialValue - Initial value to be used while the first chunk is being fetched, and returned if the stream yields no values. + * @example + * ```ts + * await queryClient.query({ + * queryKey: ['data'], + * queryFn: streamedQuery({ + * streamFn: fetchDataInChunks, + * }), + * }) + * ``` */ export function streamedQuery< TQueryFnData = unknown, diff --git a/packages/query-core/src/timeoutManager.ts b/packages/query-core/src/timeoutManager.ts index 6f74050b04c..acccbaa4d60 100644 --- a/packages/query-core/src/timeoutManager.ts +++ b/packages/query-core/src/timeoutManager.ts @@ -18,6 +18,12 @@ export type ManagedTimerId = number | { [Symbol.toPrimitive]: () => number } /** * Backend for timer functions. + * + * Timers are performance-sensitive: short-lived timers (delays under a few seconds) tend to be + * latency-sensitive, while long-lived ones may benefit more from coalescing — batching timers + * with similar deadlines together — which the default provider (backed by the platform's global + * `setTimeout`/`setInterval`) does not do. A custom provider can implement coalescing, and can + * also support delays longer than the ~24-day maximum of the global `setTimeout`. */ export type TimeoutProvider = { @@ -72,6 +78,31 @@ export class TimeoutManager implements Omit { #provider: TimeoutProvider = defaultTimeoutProvider #providerCalled = false + /** + * `setTimeoutProvider` can be used to set a custom implementation of the + * `setTimeout`, `clearTimeout`, `setInterval`, `clearInterval` functions, + * called a `TimeoutProvider`. + * + * This may be useful if you notice event loop performance issues with + * thousands of queries. A custom TimeoutProvider could also support timer + * delays longer than the global `setTimeout` maximum delay value of about + * 24 days. + * + * It is important to call `setTimeoutProvider` before creating a + * QueryClient or queries, so that the same provider is used consistently + * for all timers in the application, since different TimeoutProviders + * cannot cancel each others' timers. + * + * @example + * ```ts + * import { timeoutManager, QueryClient } from '@tanstack/query-core' + * import { CustomTimeoutProvider } from './CustomTimeoutProvider' + * + * timeoutManager.setTimeoutProvider(new CustomTimeoutProvider()) + * + * export const queryClient = new QueryClient() + * ``` + */ setTimeoutProvider( provider: TimeoutProvider, ): void { @@ -101,6 +132,26 @@ export class TimeoutManager implements Omit { } } + /** + * `setTimeout` schedules a callback to run after approximately `delay` + * milliseconds, like the global `setTimeout` function. The callback can be + * canceled with `clearTimeout`. + * + * It returns a timer ID, which may be a number or an object that can be + * coerced to a number via `Symbol.toPrimitive`. + * + * @example + * ```ts + * import { timeoutManager } from '@tanstack/query-core' + * + * const timeoutId = timeoutManager.setTimeout( + * () => console.log('ran at:', new Date()), + * 1000, + * ) + * + * const timeoutIdNumber: number = Number(timeoutId) + * ``` + */ setTimeout(callback: TimeoutCallback, delay: number): ManagedTimerId { if (process.env.NODE_ENV !== 'production') { this.#providerCalled = true @@ -108,10 +159,44 @@ export class TimeoutManager implements Omit { return this.#provider.setTimeout(callback, delay) } + /** + * `clearTimeout` cancels a timeout callback scheduled with `setTimeout`, + * like the global `clearTimeout` function. It should be called with a + * timer ID returned by `setTimeout`. + * + * @example + * ```ts + * import { timeoutManager } from '@tanstack/query-core' + * + * const timeoutId = timeoutManager.setTimeout( + * () => console.log('ran at:', new Date()), + * 1000, + * ) + * + * timeoutManager.clearTimeout(timeoutId) + * ``` + */ clearTimeout(timeoutId: ManagedTimerId | undefined): void { this.#provider.clearTimeout(timeoutId) } + /** + * `setInterval` schedules a callback to be called approximately every + * `delay` milliseconds, like the global `setInterval` function. + * + * Like `setTimeout`, it returns a timer ID, which may be a number or an + * object that can be coerced to a number via `Symbol.toPrimitive`. + * + * @example + * ```ts + * import { timeoutManager } from '@tanstack/query-core' + * + * const intervalId = timeoutManager.setInterval( + * () => console.log('ran at:', new Date()), + * 1000, + * ) + * ``` + */ setInterval(callback: TimeoutCallback, delay: number): ManagedTimerId { if (process.env.NODE_ENV !== 'production') { this.#providerCalled = true @@ -119,11 +204,31 @@ export class TimeoutManager implements Omit { return this.#provider.setInterval(callback, delay) } + /** + * `clearInterval` can be used to cancel an interval, like the global + * `clearInterval` function. It should be called with an interval ID + * returned by `setInterval`. + * + * @example + * ```ts + * import { timeoutManager } from '@tanstack/query-core' + * + * const intervalId = timeoutManager.setInterval( + * () => console.log('ran at:', new Date()), + * 1000, + * ) + * + * timeoutManager.clearInterval(intervalId) + * ``` + */ clearInterval(intervalId: ManagedTimerId | undefined): void { this.#provider.clearInterval(intervalId) } } +/** + * Singleton instance of {@link TimeoutManager}, used throughout TanStack Query to schedule and cancel timers. + */ export const timeoutManager = new TimeoutManager() /** diff --git a/packages/query-core/src/types.ts b/packages/query-core/src/types.ts index ad29a77f506..08e254885a3 100644 --- a/packages/query-core/src/types.ts +++ b/packages/query-core/src/types.ts @@ -240,34 +240,99 @@ export interface QueryOptions< * If `true`, failed queries will retry infinitely. * If set to an integer number, e.g. 3, failed queries will retry until the failed query count meets that number. * If set to a function `(failureCount, error) => boolean` failed queries will retry until the function returns false. + * + * Defaults to `3` on the client and `0` on the server. */ retry?: RetryValue + /** + * This function receives a `retryAttempt` integer and the actual Error and returns the delay to apply before the + * next attempt in milliseconds. + * + * A function like `attempt => Math.min(attempt > 1 ? 2 ** attempt * 1000 : 1000, 30 * 1000)` applies exponential + * backoff. + * + * A function like `attempt => attempt * 1000` applies linear backoff. + * + * Defaults to a function that applies exponential backoff, capped at 30 seconds. + */ retryDelay?: RetryDelayValue + /** + * Controls whether a query is allowed to run based on the current network connectivity. + * + * Defaults to `'online'`. + * @see [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. + */ networkMode?: NetworkMode /** * The time in milliseconds that unused/inactive cache data remains in memory. * When a query's cache becomes unused or inactive, that cache data will be garbage collected after this duration. * When different garbage collection times are specified, the longest one will be used. * Setting it to `Infinity` will disable garbage collection. + * + * Defaults to `5 * 60 * 1000` (5 minutes), or `Infinity` during SSR. + * + * Note: the maximum allowed time is about 24 days, imposed by `setTimeout`'s 32-bit signed integer delay — see + * `timeoutManager.setTimeoutProvider` for a workaround. */ gcTime?: number + /** + * The function that the query will use to request data. + * Required, unless a default query function has been set via `queryClient.setQueryDefaults` or + * `queryClient.setDefaultOptions`. + * Receives a {@link QueryFunctionContext}. + * Must return a promise that will either resolve data or throw an error. The data cannot be `undefined`. + */ queryFn?: QueryFunction | SkipToken + /** + * This option can be used to persist the result of a query to an external storage, bypassing the need to actually + * call the `queryFn`. Useful for persisting a query's data across e.g. server/client boundaries. + */ persister?: QueryPersister, TPageParam> + /** + * The hashed form of `queryKey`, computed with `queryKeyHashFn` (or the default hashing function otherwise). Used + * as the actual cache key internally. + */ queryHash?: string + /** + * The query key to use for this query. + * + * The query key will be hashed into a stable hash. See [Query Keys](https://tanstack.com/query/latest/docs/framework/react/guides/query-keys) + * for more information. + * + * The query will automatically update when this key changes (as long as `enabled` is not set to `false`). + */ queryKey?: TQueryKey + /** + * If specified, this function is used to hash the `queryKey` to a string. + */ queryKeyHashFn?: QueryKeyHashFunction + /** + * If set, this value will be used as the initial data for the query cache (as long as the query hasn't been + * created or cached yet). + * If set to a function, the function will be called **once** during the shared/root query initialization, and be + * expected to synchronously return the initial data. + * Initial data is considered stale by default unless a `staleTime` has been set. + * `initialData` **is persisted** to the cache. + */ initialData?: TData | InitialDataFunction + /** + * If set, this value will be used as the time (in milliseconds) of when the `initialData` itself was last updated. + */ initialDataUpdatedAt?: number | (() => number | undefined) + /** @internal */ behavior?: QueryBehavior /** * Set this to `false` to disable structural sharing between query results. * Set this to a function which accepts the old and new data and returns resolved data of the same type to implement custom structural sharing logic. + * * Defaults to `true`. */ structuralSharing?: | boolean | ((oldData: unknown | undefined, newData: unknown) => unknown) + /** @internal */ _defaulted?: boolean + /** @internal */ _type?: 'infinite' /** * Additional payload to be stored on each query. @@ -327,19 +392,23 @@ export interface QueryObserverOptions< * Set this to `false` or a function that returns `false` to disable automatic refetching when the query mounts or changes query keys. * To refetch the query, use the `refetch` method returned from the `useQuery` instance. * Accepts a boolean or function that returns a boolean. + * * Defaults to `true`. */ enabled?: QueryBooleanOption /** * The time in milliseconds after data is considered stale. * If set to `Infinity`, the data will never be considered stale. + * If set to `'static'`, the data will never be considered stale. * If set to a function, the function will be executed with the query to compute a `staleTime`. + * * Defaults to `0`. */ staleTime?: StaleTimeFunction /** * If set to a number, the query will continuously refetch at this frequency in milliseconds. * If set to a function, the function will be executed with the latest data and query to compute a frequency + * * Defaults to `false`. */ refetchInterval?: @@ -350,14 +419,16 @@ export interface QueryObserverOptions< ) => number | false | undefined) /** * If set to `true`, the query will continue to refetch while their tab/window is in the background. + * * Defaults to `false`. */ refetchIntervalInBackground?: boolean /** * If set to `true`, the query will refetch on window focus if the data is stale. * If set to `false`, the query will not refetch on window focus. - * If set to `'always'`, the query will always refetch on window focus. + * If set to `'always'`, the query will always refetch on window focus (except when `staleTime: 'static'` is used). * If set to a function, the function will be executed with the latest data and query to compute the value. + * * Defaults to `true`. */ refetchOnWindowFocus?: @@ -369,8 +440,9 @@ export interface QueryObserverOptions< /** * If set to `true`, the query will refetch on reconnect if the data is stale. * If set to `false`, the query will not refetch on reconnect. - * If set to `'always'`, the query will always refetch on reconnect. + * If set to `'always'`, the query will always refetch on reconnect (except when `staleTime: 'static'` is used). * If set to a function, the function will be executed with the latest data and query to compute the value. + * * Defaults to `true` unless `networkMode` is `'always'`. */ refetchOnReconnect?: @@ -382,8 +454,9 @@ export interface QueryObserverOptions< /** * If set to `true`, the query will refetch on mount if the data is stale. * If set to `false`, will disable additional instances of a query to trigger background refetch. - * If set to `'always'`, the query will always refetch on mount. + * If set to `'always'`, the query will always refetch on mount (except when `staleTime: 'static'` is used). * If set to a function, the function will be executed with the latest data and query to compute the value + * * Defaults to `true`. */ refetchOnMount?: @@ -395,6 +468,7 @@ export interface QueryObserverOptions< /** * If set to `false`, the query will not be retried on mount if it contains an error. * If set to a function, the function will be executed with the query to compute the value. + * * Defaults to `true`. */ retryOnMount?: QueryBooleanOption @@ -403,7 +477,9 @@ export interface QueryObserverOptions< * When set to `['data', 'error']`, the component will only re-render when the `data` or `error` properties change. * When set to `'all'`, the component will re-render whenever a query is updated. * When set to a function, the function will be executed to compute the list of properties. - * By default, access to properties will be tracked, and the component will only re-render when one of the tracked properties change. + * + * Defaults to `undefined`, in which case property access is tracked automatically, and the + * component only re-renders when one of the tracked properties changes. */ notifyOnChangeProps?: NotifyOnChangeProps /** @@ -411,16 +487,21 @@ export interface QueryObserverOptions< * If set to `true` or `suspense` is `true`, all errors will be thrown to the error boundary. * If set to `false` and `suspense` is `false`, errors are returned as state. * If set to a function, it will be passed the error and the query, and it should return a boolean indicating whether to show the error in an error boundary (`true`) or return the error as state (`false`). + * * Defaults to `false`. */ throwOnError?: ThrowOnError /** - * This option can be used to transform or select a part of the data returned by the query function. + * This option can be used to transform or select a part of the data returned by the query function. It affects + * the returned `data` value, but does not affect what gets stored in the query cache. + * The `select` function will only run if `data` changed, or if the reference to the `select` function itself + * changes. To optimize, memoize the function so its reference stays stable across calls. */ select?: (data: TQueryData) => TData /** * If set to `true`, the query will suspend when `status === 'pending'` * and throw errors when `status === 'error'`. + * * Defaults to `false`. */ suspense?: boolean @@ -436,6 +517,7 @@ export interface QueryObserverOptions< TQueryKey > + /** @internal */ _optimisticResults?: 'optimistic' | 'isRestoring' } @@ -610,6 +692,12 @@ export type FetchInfiniteQueryOptions< InfiniteQueryPages export interface ResultOptions { + /** + * If set to `true`, the method throws if any of the underlying query refetch tasks fail. + * + * Defaults to `false`, in which case failed refetches are swallowed and not surfaced to the + * caller. + */ throwOnError?: boolean } @@ -627,6 +715,15 @@ export interface RefetchOptions extends ResultOptions { export interface InvalidateQueryFilters< TQueryKey extends QueryKey = QueryKey, > extends QueryFilters { + /** + * Controls which of the matched (now-invalidated) queries are refetched in the background. + * + * Defaults to `'active'`. + * - `'active'`: only queries with at least one active observer are refetched. + * - `'inactive'`: only queries with no active observer are refetched. + * - `'all'`: every matched query is refetched, active or not. + * - `'none'`: no query is refetched; matched queries are only marked as invalidated. + */ refetchType?: QueryTypeFilter | 'none' } @@ -1131,10 +1228,37 @@ export interface MutationOptions< onMutateResult: TOnMutateResult | undefined, context: MutationFunctionContext, ) => Promise | unknown + /** + * If `false`, failed mutations will not retry by default. + * If `true`, failed mutations will retry infinitely. + * If set to an integer number, e.g. 3, failed mutations will retry until the failed mutation count meets that number. + * If set to a function `(failureCount, error) => boolean` failed mutations will retry until the function returns false. + * + * Defaults to `0`. + */ retry?: RetryValue + /** + * This function receives a `retryAttempt` integer and the actual Error and returns the delay to apply before the + * next attempt in milliseconds. + * + * Defaults to a function that applies exponential backoff, capped at 30 seconds. + */ retryDelay?: RetryDelayValue + /** + * Controls whether a mutation is allowed to run based on the current network connectivity. + * + * Defaults to `'online'`. + * @see [Network Mode](https://tanstack.com/query/latest/docs/framework/react/guides/network-mode) for more information. + */ networkMode?: NetworkMode + /** + * The time in milliseconds that an unused/inactive mutation remains in memory before it is + * garbage collected. + * + * Defaults to `5 * 60 * 1000` (5 minutes), or `Infinity` during SSR. + */ gcTime?: number + /** @internal */ _defaulted?: boolean meta?: MutationMeta scope?: MutationScope @@ -1146,6 +1270,14 @@ export interface MutationObserverOptions< TVariables = void, TOnMutateResult = unknown, > extends MutationOptions { + /** + * Whether errors should be thrown instead of setting the `error` property. + * If set to `true`, all errors will be thrown to the nearest error boundary. + * If set to a function, it will be passed the error and should return a boolean indicating whether to throw the + * error (`true`) or return it as state (`false`). + * + * Defaults to `false`. + */ throwOnError?: boolean | ((error: TError) => boolean) } @@ -1361,18 +1493,28 @@ export type MutationObserverResult< | MutationObserverSuccessResult export interface QueryClientConfig { + /** The query cache this client is connected to. A new `QueryCache` is created if not provided. */ queryCache?: QueryCache + /** + * The mutation cache this client is connected to. A new `MutationCache` is created if not + * provided. + */ mutationCache?: MutationCache + /** Default options for all queries and mutations created through this client. */ defaultOptions?: DefaultOptions } export interface DefaultOptions { + /** Default options applied to every query, unless overridden per-query. */ queries?: OmitKeyof< QueryObserverOptions, 'suspense' | 'queryKey' > + /** Default options applied to every mutation, unless overridden per-mutation. */ mutations?: MutationObserverOptions + /** Default options used when hydrating queries; see {@link HydrateOptions}. */ hydrate?: HydrateOptions['defaultOptions'] + /** Default options used when dehydrating the client's caches; see {@link DehydrateOptions}. */ dehydrate?: DehydrateOptions } diff --git a/packages/query-core/src/utils.ts b/packages/query-core/src/utils.ts index 629115e8fae..4d40399eb20 100644 --- a/packages/query-core/src/utils.ts +++ b/packages/query-core/src/utils.ts @@ -24,9 +24,15 @@ type TuplePrefixes> = T extends readonly [] ? readonly [] : TuplePrefixes> | T +/** + * Filters used to select queries, for example in `queryClient.getQueriesData` or `queryClient.invalidateQueries`. + * All provided filters must match; filters that are left unspecified are ignored. + */ export interface QueryFilters { /** * Filter to active queries, inactive queries or all queries + * + * Defaults to `'all'`. */ type?: QueryTypeFilter /** @@ -51,6 +57,10 @@ export interface QueryFilters { fetchStatus?: FetchStatus } +/** + * Filters used to select mutations, for example in `mutationCache.findAll` or `queryClient.isMutating`. + * All provided filters must match; filters that are left unspecified are ignored. + */ export interface MutationFilters< TData = unknown, TError = DefaultError, @@ -77,6 +87,21 @@ export interface MutationFilters< status?: MutationStatus } +/** + * Either a plain value of type `TOutput`, or a function that receives `TInput` and returns `TOutput`. + * Used for example by `setQueryData`-style updaters, which accept either the new data directly or a + * function that computes it from the previous data. See {@link functionalUpdate}. + * + * @example + * ```ts + * queryClient.setQueryData(['posts'], newPosts) + * + * // Or, using an updater function that receives the current data: + * queryClient.setQueryData(['posts'], (oldPosts) => + * oldPosts ? [...oldPosts, newPost] : oldPosts, + * ) + * ``` + */ export type Updater = TOutput | ((input: TInput) => TOutput) export type QueryTypeFilter = 'all' | 'active' | 'inactive' @@ -88,6 +113,9 @@ export type QueryTypeFilter = 'all' | 'active' | 'inactive' */ export const isServer = typeof window === 'undefined' || 'Deno' in globalThis +/** + * A function that does nothing. + */ export function noop(): void export function noop(): undefined export function noop() {} @@ -131,6 +159,19 @@ export function resolveQueryValue< : value } +/** + * Checks whether a query matches the given {@link QueryFilters}. + * Every filter that is specified must match; filters that are left unspecified are ignored. + * + * @example + * ```ts + * const queryCache = queryClient.getQueryCache() + * + * const matchingQueries = queryCache + * .getAll() + * .filter((query) => matchQuery({ queryKey: ['posts'] }, query)) + * ``` + */ export function matchQuery( filters: QueryFilters, query: Query, @@ -179,6 +220,20 @@ export function matchQuery( return true } +/** + * Checks whether a mutation matches the given {@link MutationFilters}. + * Every filter that is specified must match; filters that are left unspecified are ignored. + * If a `mutationKey` filter is provided but the mutation has no `mutationKey` of its own, it does not match. + * + * @example + * ```ts + * const mutationCache = queryClient.getMutationCache() + * + * const matchingMutations = mutationCache + * .getAll() + * .filter((mutation) => matchMutation({ mutationKey: ['addPost'] }, mutation)) + * ``` + */ export function matchMutation( filters: MutationFilters, mutation: Mutation, @@ -219,6 +274,12 @@ export function hashQueryKeyByOptions( /** * Default query & mutation keys hash function. * Hashes the value into a stable hash. + * + * @example + * ```ts + * // Object keys are sorted, so key order doesn't affect the hash: + * hashKey(['todos', { page: 1, filter: 'done' }]) // === '["todos",{"filter":"done","page":1}]' + * ``` */ export function hashKey(queryKey: QueryKey | MutationKey): string { return JSON.stringify(queryKey, (_, val) => @@ -415,6 +476,20 @@ export function replaceData< return data } +/** + * Intended to be passed as a query's `placeholderData` option, for example + * `placeholderData: keepPreviousData`. Instead of resetting the query's data to `undefined` while a new + * query key is fetching, it keeps displaying the previously fetched data until the new data arrives. + * + * @example + * ```ts + * new QueryObserver(queryClient, { + * queryKey: ['posts', page], + * queryFn: () => fetchPosts(page), + * placeholderData: keepPreviousData, + * }) + * ``` + */ export function keepPreviousData( previousData: T | undefined, ): T | undefined { @@ -431,7 +506,23 @@ export function addToStart(items: Array, item: T, max = 0): Array { return max && newItems.length > max ? newItems.slice(0, -1) : newItems } +/** + * Sentinel value that can be passed as a query's `queryFn` to conditionally disable the query (equivalent + * to `enabled: false`) while preserving full type inference for the query's data. Unlike `enabled: false`, + * a query disabled via `skipToken` cannot be triggered with `refetch`. + * + * @example + * ```ts + * new QueryObserver(queryClient, { + * queryKey: ['post', postId], + * queryFn: postId != null ? () => fetchPost(postId) : skipToken, + * }) + * ``` + */ export const skipToken = Symbol() +/** + * The type of the {@link skipToken} sentinel value. + */ export type SkipToken = typeof skipToken export function ensureQueryFn< @@ -467,6 +558,21 @@ export function ensureQueryFn< return options.queryFn } +/** + * Resolves a `throwOnError` option to a boolean. + * If `throwOnError` is a function, it is called with `params` (e.g. the error and, depending on the caller, + * additional context such as the query or mutation) and its result is returned, allowing the throwing + * behavior to be decided per error. Otherwise, `throwOnError` itself is coerced to a boolean (`undefined` + * resolves to `false`). + * + * @example + * ```ts + * const throwOnError = + * query.state.error && typeof options.throwOnError === 'function' + * ? shouldThrowError(options.throwOnError, [query.state.error, query]) + * : options.throwOnError + * ``` + */ export function shouldThrowError) => boolean>( throwOnError: boolean | T | undefined, params: Parameters, diff --git a/packages/query-devtools/tsconfig.json b/packages/query-devtools/tsconfig.json index 7f3c629b174..126986ae135 100644 --- a/packages/query-devtools/tsconfig.json +++ b/packages/query-devtools/tsconfig.json @@ -12,6 +12,5 @@ "*.config.ts", "*.config.js", "package.json" - ], - "references": [{ "path": "../query-core" }] + ] } diff --git a/packages/solid-query/tsconfig.json b/packages/solid-query/tsconfig.json index 7f3c629b174..126986ae135 100644 --- a/packages/solid-query/tsconfig.json +++ b/packages/solid-query/tsconfig.json @@ -12,6 +12,5 @@ "*.config.ts", "*.config.js", "package.json" - ], - "references": [{ "path": "../query-core" }] + ] } diff --git a/packages/svelte-query/tsconfig.json b/packages/svelte-query/tsconfig.json index 25d5b262726..305714920cf 100644 --- a/packages/svelte-query/tsconfig.json +++ b/packages/svelte-query/tsconfig.json @@ -4,6 +4,5 @@ "outDir": "./dist-ts", "rootDir": "." }, - "include": ["src", "tests", "*.config.ts", "*.config.js", "package.json"], - "references": [{ "path": "../query-core" }] + "include": ["src", "tests", "*.config.ts", "*.config.js", "package.json"] } diff --git a/packages/vue-query/tsconfig.json b/packages/vue-query/tsconfig.json index f2244eacf3a..3d82a764dc5 100644 --- a/packages/vue-query/tsconfig.json +++ b/packages/vue-query/tsconfig.json @@ -10,6 +10,5 @@ "*.config.ts", "*.config.js", "package.json" - ], - "references": [{ "path": "../query-core" }] + ] } diff --git a/scripts/generate-docs.ts b/scripts/generate-docs.ts index be0f9baadee..cb434c61969 100644 --- a/scripts/generate-docs.ts +++ b/scripts/generate-docs.ts @@ -163,7 +163,7 @@ async function generatePackageReferenceDocs(pkg: PackageReferenceDocsConfig) { gitRevision: 'main', entryPoints: pkg.entryPoints, tsconfig: pkg.tsconfig, - exclude: pkg.exclude, + ...(pkg.exclude && { exclude: pkg.exclude }), out: outputDir, }) @@ -196,19 +196,16 @@ const packages: Array = [ '../packages/angular-query-experimental/tsconfig.json', ), outputDir: resolve(__dirname, '../docs/framework/angular/reference'), - exclude: ['./packages/query-core/**/*'], }, { entryPoints: [resolve(__dirname, '../packages/svelte-query/src/index.ts')], tsconfig: resolve(__dirname, '../packages/svelte-query/tsconfig.json'), outputDir: resolve(__dirname, '../docs/framework/svelte/reference'), - exclude: ['./packages/query-core/**/*'], }, { entryPoints: [resolve(__dirname, '../packages/solid-query/src/index.ts')], tsconfig: resolve(__dirname, '../packages/solid-query/tsconfig.json'), outputDir: resolve(__dirname, '../docs/framework/solid/reference'), - exclude: ['./packages/query-core/**/*'], redirectFrom: { 'functions/infiniteQueryOptions': [ 'framework/solid/reference/infiniteQueryOptions', @@ -234,13 +231,11 @@ const packages: Array = [ entryPoints: [resolve(__dirname, '../packages/vue-query/src/index.ts')], tsconfig: resolve(__dirname, '../packages/vue-query/tsconfig.json'), outputDir: resolve(__dirname, '../docs/framework/vue/reference'), - exclude: ['./packages/query-core/**/*'], }, { entryPoints: [resolve(__dirname, '../packages/react-query/src/index.ts')], tsconfig: resolve(__dirname, '../packages/react-query/tsconfig.json'), outputDir: resolve(__dirname, '../docs/framework/react/reference'), - exclude: ['./packages/query-core/**/*'], redirectFrom: { 'functions/infiniteQueryOptions': [ 'framework/react/reference/infiniteQueryOptions', @@ -285,19 +280,61 @@ const packages: Array = [ 'functions/useSuspenseQuery': [ 'framework/react/reference/useSuspenseQuery', ], + // Redirects from the legacy hand-written docs/reference/*.md pages, removed in favor of + // this generated reference. + 'classes/QueryClient': [ + 'reference/QueryClient', + 'framework/react/reference/QueryClient', + ], + 'classes/QueryCache': [ + 'reference/QueryCache', + 'framework/react/reference/QueryCache', + ], + 'classes/MutationCache': [ + 'reference/MutationCache', + 'framework/react/reference/MutationCache', + ], + 'classes/QueryObserver': [ + 'reference/QueryObserver', + 'framework/react/reference/QueryObserver', + ], + 'classes/InfiniteQueryObserver': [ + 'reference/InfiniteQueryObserver', + 'framework/react/reference/InfiniteQueryObserver', + ], + 'classes/QueriesObserver': [ + 'reference/QueriesObserver', + 'framework/react/reference/QueriesObserver', + ], + // focusManager/onlineManager/timeoutManager are class instances, not object literals, so + // TypeDoc can't inline their methods onto the `variables/*` instance page — the method docs + // that the legacy pages covered now live on the `interfaces/*` page for the class itself. + 'interfaces/FocusManager': [ + 'reference/focusManager', + 'framework/react/reference/focusManager', + ], + 'interfaces/OnlineManager': [ + 'reference/onlineManager', + 'framework/react/reference/onlineManager', + ], + 'interfaces/TimeoutManager': ['reference/timeoutManager'], + 'variables/notifyManager': [ + 'reference/notifyManager', + 'framework/react/reference/notifyManager', + ], + 'variables/environmentManager': ['reference/environmentManager'], + 'functions/experimental_streamedQuery': ['reference/streamedQuery'], }, }, { entryPoints: [resolve(__dirname, '../packages/preact-query/src/index.ts')], tsconfig: resolve(__dirname, '../packages/preact-query/tsconfig.json'), outputDir: resolve(__dirname, '../docs/framework/preact/reference'), - exclude: ['./packages/query-core/**/*'], }, { entryPoints: [resolve(__dirname, '../packages/lit-query/src/index.ts')], tsconfig: resolve(__dirname, '../packages/lit-query/tsconfig.json'), outputDir: resolve(__dirname, '../docs/framework/lit/reference'), - exclude: ['./packages/query-core/**/*'], excludeExternals: true, simplifyLitQueriesControllerTypes: true, trimGeneratedMarkdown: true,