Use Graph beta for beta-only endpoints
All checks were successful
Trigger Cloudarix Deploy / call-webhook (push) Successful in 4s

This commit is contained in:
Ahmed Darrazi 2025-12-09 21:56:38 +01:00
parent b6d69295aa
commit 2eaf325770

View File

@ -3,6 +3,19 @@ import { withRetry, isTransientError } from '../utils/retry';
type GraphRecord = Record<string, unknown>;
// Certain Intune resources exist only on the beta Graph surface.
const BETA_ENDPOINTS = new Set([
'/deviceManagement/configurationPolicies',
'/deviceManagement/intents',
]);
function baseUrlFor(endpoint: string) {
for (const beta of BETA_ENDPOINTS) {
if (endpoint.startsWith(beta)) return 'https://graph.microsoft.com/beta';
}
return 'https://graph.microsoft.com/v1.0';
}
/**
* Fetch a Graph endpoint with pagination support for @odata.nextLink
* Returns an array of items aggregated across pages.
@ -71,7 +84,8 @@ export async function fetchWithPagination(
*/
export async function fetchFromGraph(endpoint: string) {
const token = await getGraphAccessToken();
return fetchWithPagination(endpoint, token);
const baseUrl = baseUrlFor(endpoint);
return fetchWithPagination(endpoint, token, baseUrl);
}
export default fetchFromGraph;