Skip to content

Commit 638e04e

Browse files
committed
Add support for getting organization with members count
1 parent 99de68d commit 638e04e

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

.changeset/light-geckos-allow.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@clerk/backend": patch
3+
---
4+
5+
Introduce `includeMembersCount` parameter to `getOrganization`, allowing to retrieve an organization with `membersCount`.

packages/backend/src/api/endpoints/OrganizationApi.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,9 @@ type CreateParams = {
3434
maxAllowedMemberships?: number;
3535
} & MetadataParams;
3636

37-
type GetOrganizationParams = { organizationId: string } | { slug: string };
37+
type GetOrganizationParams = ({ organizationId: string } | { slug: string }) & {
38+
includeMembersCount?: boolean;
39+
};
3840

3941
type UpdateParams = {
4042
name?: string;
@@ -115,12 +117,16 @@ export class OrganizationAPI extends AbstractAPI {
115117
}
116118

117119
public async getOrganization(params: GetOrganizationParams) {
120+
const { includeMembersCount } = params;
118121
const organizationIdOrSlug = 'organizationId' in params ? params.organizationId : params.slug;
119122
this.requireId(organizationIdOrSlug);
120123

121124
return this.request<Organization>({
122125
method: 'GET',
123126
path: joinPaths(basePath, organizationIdOrSlug),
127+
queryParams: {
128+
includeMembersCount,
129+
},
124130
});
125131
}
126132

0 commit comments

Comments
 (0)