Skip to content

Commit

Permalink
fix(hogql): Make all queries go the same way to provide async if enab…
Browse files Browse the repository at this point in the history
…led (#20128)
  • Loading branch information
webjunkie authored Feb 5, 2024
1 parent 4f1850f commit 315cd7b
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions frontend/src/queries/query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,9 @@ export function queryExportContext<N extends DataNode = DataNode>(
throw new Error(`Unsupported query: ${query.kind}`)
}

/**
* Execute a query node and return the response, use async query if enabled
*/
async function executeQuery<N extends DataNode = DataNode>(
queryNode: N,
methodOptions?: ApiMethodOptions,
Expand Down Expand Up @@ -226,7 +229,7 @@ export async function query<N extends DataNode = DataNode>(
const legacyFunction = legacyUrl ? fetchLegacyUrl : fetchLegacyInsights
let legacyResponse: any
;[response, legacyResponse] = await Promise.all([
api.query(queryNode, methodOptions, queryId, refresh),
executeQuery(queryNode, methodOptions, refresh, queryId),
legacyFunction(),
])

Expand Down Expand Up @@ -353,7 +356,7 @@ export async function query<N extends DataNode = DataNode>(
: {}),
})
} else {
response = await api.query(queryNode, methodOptions, queryId, refresh)
response = await executeQuery(queryNode, methodOptions, refresh, queryId)
}
} else {
response = await fetchLegacyInsights()
Expand Down

0 comments on commit 315cd7b

Please sign in to comment.