@@ -1590,7 +1590,7 @@ class ApiGateway {
15901590 * result object.
15911591 * @internal
15921592 */
1593- private getResultInternal (
1593+ private async getResultInternal (
15941594 context : RequestContext ,
15951595 queryType : QueryType ,
15961596 normalizedQuery : NormalizedQuery ,
@@ -1627,13 +1627,14 @@ class ApiGateway {
16271627 // We postpone data transformation until the last minute
16281628 // in case when all responses are native - we process them in native part
16291629 const dataCb : TransformDataResponseCb = response . data . isNative ?
1630- ( ) => JSON . parse (
1631- transformDataNative (
1630+ async ( ) => {
1631+ const jsonData = await transformDataNative (
16321632 JSON . stringify ( transformDataParams ) , response . data . getNativeRef ( )
1633- ) . result
1634- ) as TransformDataResponse
1633+ ) ;
1634+ return JSON . parse ( jsonData . result ) as TransformDataResponse ;
1635+ }
16351636 :
1636- ( ) => transformData ( {
1637+ async ( ) => transformData ( {
16371638 ...transformDataParams ,
16381639 data : response . data ,
16391640 } ) ;
@@ -1844,20 +1845,20 @@ class ApiGateway {
18441845 } ;
18451846 const resultDataJson = JSON . stringify ( responseDataObj ) ;
18461847
1847- res ( getFinalCubestoreResultMulti ( transformDataJson , rawDataRef , resultDataJson ) ) ;
1848+ res ( await getFinalCubestoreResultMulti ( transformDataJson , rawDataRef , resultDataJson ) ) ;
18481849 } else {
18491850 // if we have mixed query results (there are js and native)
18501851 // we prepare results separately: on js and native sides
18511852 // and serve final response from JS side
18521853 res ( {
18531854 queryType,
1854- results : results . map ( r => {
1855- const data = r . dataCb ( ) ;
1855+ results : await Promise . all ( results . map ( async ( r ) => {
1856+ const data = await r . dataCb ( ) ;
18561857 return {
18571858 ...cleanupResult ( r ) ,
18581859 data,
18591860 } ;
1860- } ) ,
1861+ } ) ) ,
18611862 pivotQuery : getPivotQuery ( queryType , normalizedQueries ) ,
18621863 slowQuery
18631864 } ) ;
@@ -1868,9 +1869,9 @@ class ApiGateway {
18681869 const transformDataJson = JSON . stringify ( r . transformDataParams ) ;
18691870 const rawDataRef = r . rawData . getNativeRef ( ) ;
18701871 const resultDataJson = JSON . stringify ( cleanupResult ( r ) ) ;
1871- res ( getFinalCubestoreResult ( transformDataJson , rawDataRef , resultDataJson ) ) ;
1872+ res ( await getFinalCubestoreResult ( transformDataJson , rawDataRef , resultDataJson ) ) ;
18721873 } else {
1873- const data = results [ 0 ] . dataCb ( ) ;
1874+ const data = await results [ 0 ] . dataCb ( ) ;
18741875 res ( {
18751876 ...cleanupResult ( results [ 0 ] ) ,
18761877 data,
@@ -2023,19 +2024,19 @@ class ApiGateway {
20232024 [ [ ] , [ ] , [ ] ]
20242025 ) ;
20252026
2026- res ( getFinalCubestoreResultArray ( transformDataJson , rawDataRef , resultDataJson ) ) ;
2027+ res ( await getFinalCubestoreResultArray ( transformDataJson , rawDataRef , resultDataJson ) ) ;
20272028 } else {
20282029 // if we have mixed query results (there are js and native)
20292030 // we prepare results separately: on js and native sides
20302031 // and serve final response from JS side
20312032 res ( {
2032- results : results . map ( r => {
2033- const data = r . dataCb ( ) ;
2033+ results : await Promise . all ( results . map ( async ( r ) => {
2034+ const data = await r . dataCb ( ) ;
20342035 return {
20352036 ...cleanupResult ( r ) ,
20362037 data,
20372038 } ;
2038- } ) ,
2039+ } ) ) ,
20392040 } ) ;
20402041 }
20412042 } else {
0 commit comments