|
| 1 | +type inifiniteQueryFunctionContext<'queryKey, 'pageParam> = { |
| 2 | + queryKey: array<'queryKey>, |
| 3 | + pageParam: option<'pageParam>, |
| 4 | +} |
| 5 | + |
| 6 | +@deriving(abstract) |
| 7 | +type infiniteQueryOptions<'queryKey, 'queryData, 'queryError, 'pageParam> = { |
| 8 | + @optional queryKey: 'queryKey, |
| 9 | + @optional |
| 10 | + queryFn: inifiniteQueryFunctionContext<'queryKey, 'pageParam> => Js.Promise.t<'queryData>, |
| 11 | + @optional enabled: bool, |
| 12 | + @optional retry: ReactQuery_Types.retryValue<'queryError>, |
| 13 | + @optional retryOnMount: bool, |
| 14 | + @optional retryDelay: ReactQuery_Types.retryDelayValue<'queryError>, |
| 15 | + @optional staleTime: ReactQuery_Types.timeValue, |
| 16 | + @optional queryKeyHashFn: 'queryKey => string, |
| 17 | + @optional refetchInterval: ReactQuery_Types.refetchIntervalValue, |
| 18 | + @optional refetchIntervalInBackground: bool, |
| 19 | + @optional refetchOnMount: ReactQuery_Types.boolOrAlwaysValue, |
| 20 | + @optional refetchOnWindowFocus: ReactQuery_Types.boolOrAlwaysValue, |
| 21 | + @optional refetchOnReconnect: ReactQuery_Types.boolOrAlwaysValue, |
| 22 | + @optional notifyOnChangeProps: ReactQuery_Types.notifyOnChangePropsValue, |
| 23 | + @optional notifyOnChangePropsExclusions: array<string>, |
| 24 | + @optional onSuccess: 'queryData => unit, |
| 25 | + @optional onError: 'queryError => unit, |
| 26 | + @optional onSettled: ('queryData, 'queryError) => unit, |
| 27 | + @optional select: 'queryData => 'queryData, |
| 28 | + @optional suspense: bool, |
| 29 | + @optional keepPreviousData: bool, |
| 30 | + @optional structuralSharing: bool, |
| 31 | + @optional useErrorBoundary: bool, |
| 32 | + @optional initialData: 'queryData => 'queryData, |
| 33 | + @optional initialDataUpdatedAt: unit => int, |
| 34 | + @optional placeholderData: unit => 'queryData, |
| 35 | + @optional getNextPageParam: ('pageParam, array<'pageParam>) => option<'pageParam>, |
| 36 | + @optional getPreviousPageParam: ('pageParam, array<'pageParam>) => option<'pageParam>, |
| 37 | +} |
| 38 | + |
| 39 | +type rec infiniteQueryResult<'queryError, 'queryData, 'pageParam> = { |
| 40 | + status: ReactQuery_Types.queryStatus, |
| 41 | + isIdle: bool, |
| 42 | + isError: bool, |
| 43 | + isFetched: bool, |
| 44 | + isFetchedAfterMount: bool, |
| 45 | + isFetching: bool, |
| 46 | + isLoading: bool, |
| 47 | + isLoadingError: bool, |
| 48 | + isPlaceholderData: bool, |
| 49 | + isPreviousData: bool, |
| 50 | + isRefetchError: bool, |
| 51 | + isStale: bool, |
| 52 | + isSuccess: bool, |
| 53 | + dataUpdatedAt: int, |
| 54 | + error: Js.Nullable.t<'queryError>, |
| 55 | + errorUpdatedAt: int, |
| 56 | + failureCount: int, |
| 57 | + refetch: ReactQuery_Types.refetchOptions => Js.Promise.t< |
| 58 | + infiniteQueryResult<'queryError, 'queryData, 'pageParam>, |
| 59 | + >, |
| 60 | + remove: unit => unit, |
| 61 | + data: ReactQuery_Types.infiniteData<'queryData, 'pageParam>, |
| 62 | + isFetchingNextPage: bool, |
| 63 | + isFetchingPreviousPage: bool, |
| 64 | + //fetchNextPage: (options?: FetchNextPageOptions) => Promise<UseInfiniteQueryResult> |
| 65 | + //fetchPreviousPage: (options?: FetchPreviousPageOptions) => Promise<UseInfiniteQueryResult> |
| 66 | + hasNextPage: bool, |
| 67 | + hasPreviousPage: bool, |
| 68 | +} |
| 69 | + |
| 70 | +@module("react-query") |
| 71 | +external useQuery: infiniteQueryOptions< |
| 72 | + 'queryKey, |
| 73 | + 'queryData, |
| 74 | + 'queryError, |
| 75 | + 'pageParam, |
| 76 | +> => infiniteQueryResult<'queryError, 'queryData, 'pageParam> = "useInfiniteQuery" |
0 commit comments