From 28db549fa156afcd3796b4f16f9b16631d75d4b0 Mon Sep 17 00:00:00 2001 From: sunghyunkang1111 <114709653+sunghyunkang1111@users.noreply.github.com> Date: Fri, 21 Jun 2024 14:28:00 -0500 Subject: [PATCH] pagination loading of subscription and databaseaccounts (#1877) --- src/hooks/useDatabaseAccounts.tsx | 16 +++++++++++----- src/hooks/useSubscriptions.tsx | 16 +++++++++++----- 2 files changed, 22 insertions(+), 10 deletions(-) diff --git a/src/hooks/useDatabaseAccounts.tsx b/src/hooks/useDatabaseAccounts.tsx index 9a28afaad..f517b2e30 100644 --- a/src/hooks/useDatabaseAccounts.tsx +++ b/src/hooks/useDatabaseAccounts.tsx @@ -52,11 +52,17 @@ export async function fetchDatabaseAccountsFromGraph( const body = { query: databaseAccountsQuery, subscriptions: [subscriptionId], - ...(skipToken && { - options: { - $skipToken: skipToken, - } as QueryRequestOptions, - }), + ...(skipToken + ? { + options: { + $skipToken: skipToken, + } as QueryRequestOptions, + } + : { + options: { + $top: 150, + } as QueryRequestOptions, + }), }; const response = await fetch(managementResourceGraphAPIURL, { diff --git a/src/hooks/useSubscriptions.tsx b/src/hooks/useSubscriptions.tsx index 5fa7073be..a8e4addf5 100644 --- a/src/hooks/useSubscriptions.tsx +++ b/src/hooks/useSubscriptions.tsx @@ -51,11 +51,17 @@ export async function fetchSubscriptionsFromGraph(accessToken: string): Promise< do { const body = { query: subscriptionsQuery, - ...(skipToken && { - options: { - $skipToken: skipToken, - } as QueryRequestOptions, - }), + ...(skipToken + ? { + options: { + $skipToken: skipToken, + } as QueryRequestOptions, + } + : { + options: { + $top: 150, + } as QueryRequestOptions, + }), }; const response = await fetch(managementResourceGraphAPIURL, {