diff --git a/docs/api-reference.md b/docs/api-reference.md index cbcf29a..54cfbd0 100644 --- a/docs/api-reference.md +++ b/docs/api-reference.md @@ -1,5 +1,7 @@ # API Reference + --- + - [`Provider.createClient()`](#providercreateclient) - [`Provider.make()`](#providermake) - [`DevTools.make(...)`](#devtoolsmake) @@ -10,7 +12,6 @@ - [`useMutation`](#usemutation) - [`mutationOptions`](#mutationoptions) - ### `Provider.createClient()` The function responsible to create the query client @@ -22,7 +23,9 @@ Definition: let createClient: unit => queryClientValue } ``` + Usage: + ```rescript let client = Provider.createClient() ``` @@ -84,9 +87,11 @@ Usage: ``` ### `queryClient` + Type responsible for the return of the useQueryClient hook Definition: + ```rescript type queryClient<'queryKey, 'queryData, 'queryError, 'pageParams> = { fetchQuery: fetchQueryOptions<'queryKey, 'queryData, 'queryError, 'pageParams> => Js.Promise.t< @@ -167,9 +172,11 @@ Usage: ``` ### `queryOptions` + Type responsible for hold parameters for the useQuery hook Definition: + ```rescript type queryOptions<'queryKey, 'queryData, 'queryError, 'pageParam> = { queryKey?: array<'queryKey>, @@ -182,7 +189,7 @@ Definition: retryDelay?: ReactQuery_Types.retryDelayValue<'queryError>, staleTime?: ReactQuery_Types.timeValue, queryKeyHashFn?: array<'queryKey> => string, - refetchInterval?: ReactQuery_Types.refetchIntervalValue, + refetchInterval?: 'queryData => ReactQuery_Types.refetchIntervalValue, refetchIntervalInBackground?: bool, refetchOnMount?: ReactQuery_Types.boolOrAlwaysValue, refetchOnWindowFocus?: ReactQuery_Types.boolOrAlwaysValue, @@ -214,7 +221,6 @@ Usage: ``` - ### `useMutation` The hook responsible to mutate a query, when update/create/delete anything @@ -240,6 +246,7 @@ Usage: ``` ### `mutationOptions` + Type responsible for hold the parameters for the useMutation hook Definition: diff --git a/src/ReactQuery_Client.res b/src/ReactQuery_Client.res index ced3167..ed372b0 100644 --- a/src/ReactQuery_Client.res +++ b/src/ReactQuery_Client.res @@ -57,7 +57,7 @@ type queryObserverOptions<'error, 'data, 'queryData, 'queryKey, 'pageParam> = { _defaulted?: bool, enabled?: bool, staleTime?: int, - refetchInterval?: ReactQuery_Types.refetchIntervalValue, + refetchInterval?: 'queryData => ReactQuery_Types.refetchIntervalValue, refetchIntervalInBackground?: bool, refetchOnWindowFocus?: ReactQuery_Types.boolOrAlwaysValue, refetchOnReconnect?: ReactQuery_Types.boolOrAlwaysValue, diff --git a/src/ReactQuery_InfiniteQuery.res b/src/ReactQuery_InfiniteQuery.res index 80e24ae..c1e767d 100644 --- a/src/ReactQuery_InfiniteQuery.res +++ b/src/ReactQuery_InfiniteQuery.res @@ -9,10 +9,11 @@ type infiniteQueryOptions<'queryKey, 'queryData, 'queryError> = { enabled?: bool, retry?: ReactQuery_Types.retryValue<'queryError>, retryOnMount?: bool, + initialPageParam?: int, retryDelay?: ReactQuery_Types.retryDelayValue<'queryError>, staleTime?: ReactQuery_Types.timeValue, queryKeyHashFn?: 'queryKey => string, - refetchInterval?: ReactQuery_Types.refetchIntervalValue, + refetchInterval?: 'queryData => ReactQuery_Types.refetchIntervalValue, refetchIntervalInBackground?: bool, refetchOnMount?: ReactQuery_Types.boolOrAlwaysValue, refetchOnWindowFocus?: ReactQuery_Types.boolOrAlwaysValue, diff --git a/src/ReactQuery_Query.res b/src/ReactQuery_Query.res index c5b5235..d187441 100644 --- a/src/ReactQuery_Query.res +++ b/src/ReactQuery_Query.res @@ -9,7 +9,7 @@ type queryOptions<'queryKey, 'queryData, 'queryError, 'pageParam> = { retryDelay?: ReactQuery_Types.retryDelayValue<'queryError>, staleTime?: ReactQuery_Types.timeValue, queryKeyHashFn?: array<'queryKey> => string, - refetchInterval?: ReactQuery_Types.refetchIntervalValue, + refetchInterval?: 'queryData => ReactQuery_Types.refetchIntervalValue, refetchIntervalInBackground?: bool, refetchOnMount?: ReactQuery_Types.boolOrAlwaysValue, refetchOnWindowFocus?: ReactQuery_Types.boolOrAlwaysValue, @@ -21,7 +21,6 @@ type queryOptions<'queryKey, 'queryData, 'queryError, 'pageParam> = { onSettled?: ('queryData, 'queryError) => unit, select?: 'queryData => 'queryData, suspense?: bool, - keepPreviousData?: bool, structuralSharing?: bool, useErrorBoundary?: bool, initialData?: 'queryData => 'queryData, @@ -39,7 +38,6 @@ type rec queryResult<'queryError, 'queryData> = { isLoading: bool, isLoadingError: bool, isPlaceholderData: bool, - isPreviousData: bool, isRefetchError: bool, isStale: bool, isSuccess: bool, @@ -62,6 +60,9 @@ type queriesOptions<'queryKey, 'queryData, 'queryError, 'pageParam> = { queries: array>, } +@module("@tanstack/react-query") +external keepPreviousData: 'queryData = "keepPreviousData" + @module("@tanstack/react-query") external useQueries: queriesOptions<'queryKey, 'queryData, 'queryError, 'pageParam> => array< queryResult<'queryError, 'queryData>, diff --git a/src/ReactQuery_Types.res b/src/ReactQuery_Types.res index c76e8d8..1fe6deb 100644 --- a/src/ReactQuery_Types.res +++ b/src/ReactQuery_Types.res @@ -25,7 +25,7 @@ type infiniteData<'queryData> = { pageParams: array, } -type queryStatus = [#loading | #success | #error | #initialData] +type queryStatus = [#pending | #success | #error] type placeholderData<'queryData, 'queryResult> = [ | #data('queryData)