From 418be2fdb558bb5c85d7be491945935b44cad681 Mon Sep 17 00:00:00 2001 From: Laura Beatris <48022589+LauraBeatris@users.noreply.github.com> Date: Tue, 24 Sep 2024 06:53:51 -0300 Subject: [PATCH] chore(backend): Introduce `include_members_count` parameter to `getOrganization` (#4196) --- .changeset/light-geckos-allow.md | 5 +++++ packages/backend/src/api/endpoints/OrganizationApi.ts | 8 +++++++- 2 files changed, 12 insertions(+), 1 deletion(-) create mode 100644 .changeset/light-geckos-allow.md diff --git a/.changeset/light-geckos-allow.md b/.changeset/light-geckos-allow.md new file mode 100644 index 0000000000..1255b13f9f --- /dev/null +++ b/.changeset/light-geckos-allow.md @@ -0,0 +1,5 @@ +--- +"@clerk/backend": patch +--- + +Introduce `includeMembersCount` parameter to `getOrganization`, allowing to retrieve an organization with `membersCount`. diff --git a/packages/backend/src/api/endpoints/OrganizationApi.ts b/packages/backend/src/api/endpoints/OrganizationApi.ts index 020eb200f0..b11b4d0657 100644 --- a/packages/backend/src/api/endpoints/OrganizationApi.ts +++ b/packages/backend/src/api/endpoints/OrganizationApi.ts @@ -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; @@ -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({ method: 'GET', path: joinPaths(basePath, organizationIdOrSlug), + queryParams: { + includeMembersCount, + }, }); }