File tree Expand file tree Collapse file tree 2 files changed +6
-3
lines changed Expand file tree Collapse file tree 2 files changed +6
-3
lines changed Original file line number Diff line number Diff line change @@ -232,6 +232,8 @@ class ApiGateway {
232
232
this . logger = logger ;
233
233
this . checkAuthMiddleware = options . checkAuthMiddleware || this . checkAuth . bind ( this ) ;
234
234
this . basePath = options . basePath || '/cubejs-api' ;
235
+ // eslint-disable-next-line no-unused-vars
236
+ this . queryTransformer = options . queryTransformer || ( async ( query , context ) => query ) ;
235
237
}
236
238
237
239
initApp ( app ) {
@@ -245,7 +247,7 @@ class ApiGateway {
245
247
type : 'Load Request' ,
246
248
query : req . query . query
247
249
} ) ;
248
- const normalizedQuery = normalizeQuery ( query ) ;
250
+ const normalizedQuery = await this . queryTransformer ( normalizeQuery ( query ) , this . contextByReq ( req ) ) ;
249
251
const [ compilerSqlResult , metaConfigResult ] = await Promise . all ( [
250
252
this . getCompilerApi ( req ) . getSql ( coerceForSqlQuery ( normalizedQuery , req ) ) ,
251
253
this . getCompilerApi ( req ) . metaConfig ( )
@@ -287,7 +289,7 @@ class ApiGateway {
287
289
throw new UserError ( `query param is required` ) ;
288
290
}
289
291
const query = JSON . parse ( req . query . query ) ;
290
- const normalizedQuery = normalizeQuery ( query ) ;
292
+ const normalizedQuery = await this . queryTransformer ( normalizeQuery ( query ) , this . contextByReq ( req ) ) ;
291
293
const sqlQuery = await this . getCompilerApi ( req ) . getSql ( coerceForSqlQuery ( normalizedQuery , req ) ) ;
292
294
res . json ( {
293
295
sql : sqlQuery
Original file line number Diff line number Diff line change @@ -174,7 +174,8 @@ class CubejsServerCore {
174
174
this . getOrchestratorApi . bind ( this ) ,
175
175
this . logger , {
176
176
basePath : this . options . basePath ,
177
- checkAuthMiddleware : this . options . checkAuthMiddleware
177
+ checkAuthMiddleware : this . options . checkAuthMiddleware ,
178
+ queryTransformer : this . options . queryTransformer
178
179
}
179
180
) ;
180
181
apiGateway . initApp ( app ) ;
You can’t perform that action at this time.
0 commit comments