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

[BUG] useInfiniteList pagination is broken #5832

Open
rwtnb opened this issue Apr 8, 2024 · 3 comments
Open

[BUG] useInfiniteList pagination is broken #5832

rwtnb opened this issue Apr 8, 2024 · 3 comments
Labels
bug Something isn't working

Comments

@rwtnb
Copy link

rwtnb commented Apr 8, 2024

Describe the bug

At useInfiniteList is missing the default value for pageParam, setting pageParam = preferredPagination.current ?? 1 seems to fix it.

queryFn: ({ queryKey, pageParam, signal }) => {
      const paginationProperties = {
        ...prefferedPagination,
        current: pageParam,
      };

Steps To Reproduce

  1. define a useInfiniteList hook
    const {
        data,
        isError,
        isLoading,
        hasNextPage,
        fetchNextPage,
        isFetchingNextPage,
    } = useInfiniteList<ContactsPage>({
        resource: "contacts",
        meta: {
            fields: ["id", "name", "photo"],
        },
        pagination: {
            pageSize: 20,
            mode: "server"
        },
    });
  1. Test it, we are using the nestjs-query for our graphql apis
  2. You will see that the paging field is not passed as argument for the query, because paginationProperties.current is overriden by pageParam (always undefined)

Expected behavior

Pagination to work

Packages

  • @refinedev/core

Additional Context

I can make a PR, but I'm very new to Refine and Tanstack.
Just want to make sure this is the correct approach.
Thanks!

@rwtnb rwtnb added the bug Something isn't working label Apr 8, 2024
@rwtnb rwtnb changed the title [BUG] useInfiniteList server side pagination is broken [BUG] useInfiniteList pagination is broken Apr 9, 2024
@omeraplak omeraplak added this to the May Release milestone Apr 17, 2024
@alicanerdurmaz
Copy link
Member

Hello @rwtnb, Thanks for the issue.

The issue seems to be valid, your solution is good, but we want to investigate more and find the best solution that is compatible with all other packages.

We will debug and get back to you. 👍

@rwtnb
Copy link
Author

rwtnb commented Apr 17, 2024

Thanks, for the follow up.
Let me know if I can help with anything else, we're going to production next week.
Our experience with refine so far has been amazing!
You're doing a really good job over there, so good that makes me want to pay for the enterprise plan.

@BatuhanW BatuhanW removed this from the May Release milestone May 2, 2024
@aliemir
Copy link
Member

aliemir commented May 2, 2024

Pagination for the useInfiniteList is calculated internally by checking the current page parameters and the total value returned from the data provider (in this case @refinedev/nestjs-query). If total is not returned, then there will be issues with the default page params calculations. This can be overwritten by passing queryOptions.getNextPageParam.

But I guess this issue is more related with the initial requests made by useInfiniteList rather than the next pages. I investigated the useInfiniteList and @refinedev/nestjs-query and found that default pagination values are missing from the dataProvider exported from the package.

If we add the default pagination values (say current = 1 and pageSize = 10) the issue will be resolved in some kind.

But I think there's one more issue related with this. useInfiniteList is unable to pagination prop for the initial pagination values. 🤯 I'll try to investigate more to find a proper solution covering all related cases. 🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants