Skip to Content
🎉 Coral x Panda has been released 🎉 Read the Migration Guide
DocumentationUtilsuseApolloPagination

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

NameDescriptionTypeDefaultRequired
fetchMoreThe function that fetches more pages using the apollo clientFetchMoreCallbacktrue
pageInfoPageInfotrue
mergeDataThe function to merge new data into old dataMergeResultsCallbacktrue
variablesAny updated variablesQueryVariablesfalse

Returns

NameTypeDescriptionExample
onLoadMoreFunction
hasNextPageboolean
Last updated on