@@ -314,33 +314,66 @@ class ApiGateway {
314314 *************************************************************** */
315315
316316 app . get ( `${ this . basePath } /v1/load` , userMiddlewares , userAsyncHandler ( async ( req : any , res ) => {
317+ let cacheMode : CacheMode | undefined ;
318+
319+ // TODO: Drop this fallback to renewQuery when it will be removed
320+ if ( req . query . cache !== undefined ) {
321+ cacheMode = req . query . cache ;
322+ } else if ( req . query . query ?. renewQuery !== undefined ) {
323+ cacheMode = req . query . query . renewQuery === true
324+ ? 'must-revalidate'
325+ : 'stale-if-slow' ;
326+ }
327+
317328 await this . load ( {
318329 query : req . query . query ,
319330 context : req . context ,
320331 res : this . resToResultFn ( res ) ,
321332 queryType : req . query . queryType ,
322- cacheMode : req . query . cache ,
333+ cacheMode,
323334 } ) ;
324335 } ) ) ;
325336
326337 const jsonParser = bodyParser . json ( { limit : '1mb' } ) ;
327338 app . post ( `${ this . basePath } /v1/load` , jsonParser , userMiddlewares , userAsyncHandler ( async ( req , res ) => {
339+ let cacheMode : CacheMode | undefined ;
340+
341+ // TODO: Drop this fallback to renewQuery when it will be removed
342+ if ( req . query . cache !== undefined ) {
343+ cacheMode = req . body . cache ;
344+ } else if ( req . body . query ?. renewQuery !== undefined ) {
345+ cacheMode = req . body . query . renewQuery === true
346+ ? 'must-revalidate'
347+ : 'stale-if-slow' ;
348+ }
349+
328350 await this . load ( {
329351 query : req . body . query ,
330352 context : req . context ,
331353 res : this . resToResultFn ( res ) ,
332354 queryType : req . body . queryType ,
333- cacheMode : req . body . cache ,
355+ cacheMode,
334356 } ) ;
335357 } ) ) ;
336358
337359 app . get ( `${ this . basePath } /v1/subscribe` , userMiddlewares , userAsyncHandler ( async ( req : any , res ) => {
360+ let cacheMode : CacheMode | undefined ;
361+
362+ // TODO: Drop this fallback to renewQuery when it will be removed
363+ if ( req . query . cache !== undefined ) {
364+ cacheMode = req . query . cache ;
365+ } else if ( req . query . query ?. renewQuery !== undefined ) {
366+ cacheMode = req . query . query . renewQuery === true
367+ ? 'must-revalidate'
368+ : 'stale-if-slow' ;
369+ }
370+
338371 await this . load ( {
339372 query : req . query . query ,
340373 context : req . context ,
341374 res : this . resToResultFn ( res ) ,
342375 queryType : req . query . queryType ,
343- cacheMode : req . query . cache ,
376+ cacheMode,
344377 } ) ;
345378 } ) ) ;
346379
0 commit comments