Skip to content

Commit

Permalink
chore(backend): Introduce include_members_count parameter to `getOr…
Browse files Browse the repository at this point in the history
…ganization` (#4196)
  • Loading branch information
LauraBeatris committed Sep 24, 2024
1 parent 99de68d commit 418be2f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/light-geckos-allow.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@clerk/backend": patch
---

Introduce `includeMembersCount` parameter to `getOrganization`, allowing to retrieve an organization with `membersCount`.
8 changes: 7 additions & 1 deletion packages/backend/src/api/endpoints/OrganizationApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ type CreateParams = {
maxAllowedMemberships?: number;
} & MetadataParams;

type GetOrganizationParams = { organizationId: string } | { slug: string };
type GetOrganizationParams = ({ organizationId: string } | { slug: string }) & {
includeMembersCount?: boolean;
};

type UpdateParams = {
name?: string;
Expand Down Expand Up @@ -115,12 +117,16 @@ export class OrganizationAPI extends AbstractAPI {
}

public async getOrganization(params: GetOrganizationParams) {
const { includeMembersCount } = params;
const organizationIdOrSlug = 'organizationId' in params ? params.organizationId : params.slug;
this.requireId(organizationIdOrSlug);

return this.request<Organization>({
method: 'GET',
path: joinPaths(basePath, organizationIdOrSlug),
queryParams: {
includeMembersCount,
},
});
}

Expand Down

0 comments on commit 418be2f

Please sign in to comment.