useApolloPagination
A hook to assist with paginating data from Apollo.
Import
import { useApolloPagination } from '@krakentech/utils';Usage
import { useApolloPagination, mergeResults } from '@krakentech/utils';
const { data, loading, error, fetchMore } = useQuery(QUERY, {
variables: { accountNumber },
});
const { onLoadMore, hasNextPage } = useApolloPagination({
fetchMore,
pageInfo: data.pageInfo,
mergeData: mergeResults,
});Args
| Name | Description | Type | Default | Required |
|---|---|---|---|---|
fetchMore | The function that fetches more pages using the apollo client | FetchMoreCallback | true | |
pageInfo | PageInfo | true | ||
mergeData | The function to merge new data into old data | MergeResultsCallback | true | |
variables | Any updated variables | QueryVariables | false |
Returns
| Name | Type | Description | Example |
|---|---|---|---|
onLoadMore | Function | ||
hasNextPage | boolean |
Last updated on