aboutsummaryrefslogtreecommitdiffstats
path: root/src/utils/hooks/use-pagination.tsx
diff options
context:
space:
mode:
authorArmand Philippot <git@armandphilippot.com>2022-08-20 21:39:51 +0200
committerArmand Philippot <git@armandphilippot.com>2022-08-20 21:39:51 +0200
commita0d00743cbbdb77b27c1a3d5711407ffed5befac (patch)
treef4caab160daf6b93c74d60ab93edd265c8edb158 /src/utils/hooks/use-pagination.tsx
parent46b158bf9d2f7fa9cc253915151e0b53c052a444 (diff)
refactor(types): move and rename GraphQL types
The api file in services was not really readable. So I move the types and I also rewrite a little the fetch function. I also rename most of the type to avoid conflict with preexisting types (like Node) and to keep consistency.
Diffstat (limited to 'src/utils/hooks/use-pagination.tsx')
-rw-r--r--src/utils/hooks/use-pagination.tsx7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/utils/hooks/use-pagination.tsx b/src/utils/hooks/use-pagination.tsx
index a80a539..f17b6ff 100644
--- a/src/utils/hooks/use-pagination.tsx
+++ b/src/utils/hooks/use-pagination.tsx
@@ -1,4 +1,5 @@
-import { type EdgesResponse, type EdgesVars } from '@services/graphql/api';
+import { GraphQLEdgesInput } from '@ts/types/graphql/generics';
+import { EdgesResponse, Search } from '@ts/types/graphql/queries';
import useSWRInfinite, { SWRInfiniteKeyLoader } from 'swr/infinite';
export type UsePaginationProps<T> = {
@@ -9,7 +10,7 @@ export type UsePaginationProps<T> = {
/**
* A function to fetch more data.
*/
- fetcher: (props: EdgesVars) => Promise<EdgesResponse<T>>;
+ fetcher: (props: GraphQLEdgesInput & Search) => Promise<EdgesResponse<T>>;
/**
* The number of results per page.
*/
@@ -74,7 +75,7 @@ const usePagination = <T extends object>({
const getKey: SWRInfiniteKeyLoader = (
pageIndex: number,
previousData: EdgesResponse<T>
- ): EdgesVars | null => {
+ ): (GraphQLEdgesInput & Search) | null => {
// Reached the end.
if (previousData && !previousData.edges.length) return null;