From e7f0a521b8149eba641f7c8e0cdf485baa2d2739 Mon Sep 17 00:00:00 2001 From: Nicolas Beaussart Date: Thu, 25 May 2023 13:00:54 +0200 Subject: [PATCH] console: have better time and payload size estimation in graphiql PR-URL: https://github.com/hasura/graphql-engine-mono/pull/9243 GitOrigin-RevId: 74ab50ed908da659246c4fada3742d33e0fa3cd2 --- .../libs/console/legacy-ce/src/lib/utils/requestAction.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/frontend/libs/console/legacy-ce/src/lib/utils/requestAction.ts b/frontend/libs/console/legacy-ce/src/lib/utils/requestAction.ts index 576e731f952..4bdc95e2b7a 100644 --- a/frontend/libs/console/legacy-ce/src/lib/utils/requestAction.ts +++ b/frontend/libs/console/legacy-ce/src/lib/utils/requestAction.ts @@ -72,7 +72,9 @@ const requestAction = ( dispatch({ type: LOAD_REQUEST }); const startTime = new Date().getTime(); fetch(url, requestOptions).then( - response => { + async response => { + const endTime = new Date().getTime(); + const responseSize = (await response.clone().text()).length; const contentType = response.headers.get('Content-Type'); const isResponseJson = `${contentType}`.includes('application/json'); @@ -95,7 +97,6 @@ const requestAction = ( dispatch({ type: DONE_REQUEST }); if (requestTrackingId) { - const endTime = new Date().getTime(); const responseTimeMs = endTime - startTime; const isResponseCached = response.headers.has('Cache-Control'); const cacheWarning = getCacheRequestWarning( @@ -105,7 +106,6 @@ const requestAction = ( url, requestOptions.body ); - const responseSize = JSON.stringify(results).length * 2; dispatch( processResponseDetails( responseTimeMs,