UNPKG

@atlaskit/profilecard

Version:

A React component to display a card with user information.

32 lines 899 B
import { AGGQuery } from './graphqlUtils'; const ORG_ID_FROM_CLOUD_ID_QUERY = `query OrgIdFromCloudId($cloudId: ID!) { tenantContexts(cloudIds: [$cloudId]) { orgId } }`; const addHeaders = headers => { headers.append('atl-client-name', "@atlaskit/profilecard"); headers.append('atl-client-version', "24.44.17"); return headers; }; export async function getOrgIdForCloudIdFromAGG(url, cloudId) { const query = { query: ORG_ID_FROM_CLOUD_ID_QUERY, variables: { cloudId } }; try { const { tenantContexts } = await AGGQuery(url, query, addHeaders); if (!tenantContexts || tenantContexts.length === 0 || tenantContexts[0] === null) { return null; } return tenantContexts[0].orgId; } catch (err) { // don't bubble up the error, and let consumers handle it as if the cloud ID // doesn't resolve to an org ID return null; } }