Implementing the pagination
1-Set and adapt your query
export const getUsers = (
numberPerPage?: number,
offset?: number,
searchQuery?: string,
): Promise<any> => {
const pagination = numberPerPage ? 'first: ' + numberPerPage + ', skip: ' + offset : '';
let condition = ', where: {';
condition += searchQuery ? `, handle_contains_nocase: "${searchQuery}"` : '';
condition += '}';
const query = `
{
users(orderBy: rating, orderDirection: desc ${pagination} ${condition}) {
id
address
handle
userStats {
numReceivedReviews
}
rating
}
}
`;
return processRequest(query);
};Other type of query for pagination
2-Adapt your hook
3-Set up the pagination in your component
Last updated