Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

usePonderInfiniteQuery() with built-in pagination #1506

Open
kyscott18 opened this issue Feb 11, 2025 · 0 comments
Open

usePonderInfiniteQuery() with built-in pagination #1506

kyscott18 opened this issue Feb 11, 2025 · 0 comments

Comments

@kyscott18
Copy link
Collaborator

Problem / use case

Ponder's GraphQL interface provides a convenient method for paginating, but nothing exists like this in @ponder/client or @ponder/react.

This feature is useful for many frontend applications that have large underlying tables they are trying to display without querying the full result set.

Proposed solution

Luckily, React Query already has a popular, easy-to-use pattern for solving this problem. useInfiniteQuery() allows for querying data in pages and programmatically fetching new pages in bi-directional manner. This can be combined with dynamic query building to automatically apply cursor pagination.

const { data, hasNextPage, fetchNextPage, }) = usePonderInfiniteQuery({
  queryFn: (db) => db.select().from(schema.account),
  limit: 100,
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant