@@ -1588,7 +1588,7 @@ class ApiGateway {
15881588 * result object.
15891589 * @internal
15901590 */
1591- private getResultInternal (
1591+ private async getResultInternal (
15921592 context : RequestContext ,
15931593 queryType : QueryType ,
15941594 normalizedQuery : NormalizedQuery ,
@@ -1625,13 +1625,14 @@ class ApiGateway {
16251625 // We postpone data transformation until the last minute
16261626 // in case when all responses are native - we process them in native part
16271627 const dataCb : TransformDataResponseCb = response . data . isNative ?
1628- ( ) => JSON . parse (
1629- transformDataNative (
1628+ async ( ) => {
1629+ const jsonData = await transformDataNative (
16301630 JSON . stringify ( transformDataParams ) , response . data . getNativeRef ( )
1631- ) . result
1632- ) as TransformDataResponse
1631+ ) ;
1632+ return JSON . parse ( jsonData . result ) as TransformDataResponse ;
1633+ }
16331634 :
1634- ( ) => transformData ( {
1635+ async ( ) => transformData ( {
16351636 ...transformDataParams ,
16361637 data : response . data ,
16371638 } ) ;
@@ -1842,20 +1843,20 @@ class ApiGateway {
18421843 } ;
18431844 const resultDataJson = JSON . stringify ( responseDataObj ) ;
18441845
1845- res ( getFinalCubestoreResultMulti ( transformDataJson , rawDataRef , resultDataJson ) ) ;
1846+ res ( await getFinalCubestoreResultMulti ( transformDataJson , rawDataRef , resultDataJson ) ) ;
18461847 } else {
18471848 // if we have mixed query results (there are js and native)
18481849 // we prepare results separately: on js and native sides
18491850 // and serve final response from JS side
18501851 res ( {
18511852 queryType,
1852- results : results . map ( r => {
1853- const data = r . dataCb ( ) ;
1853+ results : await Promise . all ( results . map ( async ( r ) => {
1854+ const data = await r . dataCb ( ) ;
18541855 return {
18551856 ...cleanupResult ( r ) ,
18561857 data,
18571858 } ;
1858- } ) ,
1859+ } ) ) ,
18591860 pivotQuery : getPivotQuery ( queryType , normalizedQueries ) ,
18601861 slowQuery
18611862 } ) ;
@@ -1866,9 +1867,9 @@ class ApiGateway {
18661867 const transformDataJson = JSON . stringify ( r . transformDataParams ) ;
18671868 const rawDataRef = r . rawData . getNativeRef ( ) ;
18681869 const resultDataJson = JSON . stringify ( cleanupResult ( r ) ) ;
1869- res ( getFinalCubestoreResult ( transformDataJson , rawDataRef , resultDataJson ) ) ;
1870+ res ( await getFinalCubestoreResult ( transformDataJson , rawDataRef , resultDataJson ) ) ;
18701871 } else {
1871- const data = results [ 0 ] . dataCb ( ) ;
1872+ const data = await results [ 0 ] . dataCb ( ) ;
18721873 res ( {
18731874 ...cleanupResult ( results [ 0 ] ) ,
18741875 data,
@@ -2021,19 +2022,19 @@ class ApiGateway {
20212022 [ [ ] , [ ] , [ ] ]
20222023 ) ;
20232024
2024- res ( getFinalCubestoreResultArray ( transformDataJson , rawDataRef , resultDataJson ) ) ;
2025+ res ( await getFinalCubestoreResultArray ( transformDataJson , rawDataRef , resultDataJson ) ) ;
20252026 } else {
20262027 // if we have mixed query results (there are js and native)
20272028 // we prepare results separately: on js and native sides
20282029 // and serve final response from JS side
20292030 res ( {
2030- results : results . map ( r => {
2031- const data = r . dataCb ( ) ;
2031+ results : await Promise . all ( results . map ( async ( r ) => {
2032+ const data = await r . dataCb ( ) ;
20322033 return {
20332034 ...cleanupResult ( r ) ,
20342035 data,
20352036 } ;
2036- } ) ,
2037+ } ) ) ,
20372038 } ) ;
20382039 }
20392040 } else {
0 commit comments