console: have better time and payload size estimation in graphiql

PR-URL: https://github.com/hasura/graphql-engine-mono/pull/9243
GitOrigin-RevId: 74ab50ed908da659246c4fada3742d33e0fa3cd2
This commit is contained in:
Nicolas Beaussart 2023-05-25 13:00:54 +02:00 committed by hasura-bot
parent 3492484034
commit e7f0a521b8

View File

@ -72,7 +72,9 @@ const requestAction = <T = any>(
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 = <T = any>(
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 = <T = any>(
url,
requestOptions.body
);
const responseSize = JSON.stringify(results).length * 2;
dispatch(
processResponseDetails(
responseTimeMs,