Skip to content

Commit cc3a2c2

Browse files
committed
feat(backend): support user list cursor pagination
1 parent 2466563 commit cc3a2c2

2 files changed

Lines changed: 8 additions & 1 deletion

File tree

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@clerk/backend': minor
3+
---
4+
5+
Add `startingAfter` to `users.getUserList()` so applications can page through user lists with a cursor.

‎packages/backend/src/api/endpoints/UserApi.ts‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ export type UserCountParams = {
3838

3939
/** @generateWithEmptyComment */
4040
export type UserListParams = ClerkPaginationRequest<{
41+
/** The ID of the user after which to start returning results. Use the last user's ID from the previous page to fetch the next page. */
42+
startingAfter?: string;
4143
/** Filters users with the specified email addresses. Accepts up to 100 email addresses. */
4244
emailAddress?: string[];
4345
/** Filters users with the specified phone numbers. Accepts up to 100 phone numbers. */
@@ -435,7 +437,7 @@ export class UserAPI extends AbstractAPI {
435437
* @returns A [`PaginatedResourceResponse`](https://clerk.com/docs/reference/backend/types/paginated-resource-response) object with a `data` property that contains an array of [`User`](https://clerk.com/docs/reference/backend/types/backend-user) objects, and a `totalCount` property that indicates the total number of users in your instance.
436438
*/
437439
public async getUserList(params: UserListParams = {}) {
438-
const { limit, offset, orderBy, ...userCountParams } = params;
440+
const { limit, offset, orderBy, startingAfter, ...userCountParams } = params;
439441
// TODO(dimkl): Temporary change to populate totalCount using a 2nd BAPI call to /users/count endpoint
440442
// until we update the /users endpoint to be paginated in a next BAPI version.
441443
// In some edge cases the data.length != totalCount due to a creation of a user between the 2 api responses

0 commit comments

Comments
 (0)