Beignet API reference
    Preparing search index...

    Function cursorPagination

    • Infinite-query options for contracts that follow the Beignet cursor pagination convention.

      Spread the result into rq(contract).infiniteQueryOptions(...) when the contract takes an optional cursor query param and responds with a PageResult-style body whose page.nextCursor is string | null. The first page is fetched without a cursor, each next page sends lastPage.page.nextCursor, and null tells TanStack Query there is no next page.

      useInfiniteQuery(
      rq(listIssues).infiniteQueryOptions({
      query: filters,
      ...cursorPagination(),
      }),
      );

      Type safety is structural: contracts without a cursor query param or without page.nextCursor in the response fail to typecheck at the spread site. Write initialPageParam, getNextPageParam, and page(...) by hand for contracts that paginate differently.

      Returns {
          getNextPageParam: (
              lastPage: { page: { nextCursor: string | null } },
          ) => string | null;
          initialPageParam: string | null;
          page: (ctx: { pageParam: string | null }) => { query: { cursor?: string } };
      }