Skip to content

Commit 16ccdbb

Browse files
committed
return back cache as public prop in query
1 parent 55a0d60 commit 16ccdbb

File tree

3 files changed

+6
-3
lines changed

3 files changed

+6
-3
lines changed

packages/cubejs-api-gateway/src/gateway.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -592,17 +592,18 @@ class ApiGateway {
592592
private normalizeQueryCacheMode(query: Query, cacheMode: CacheMode | undefined): Query {
593593
if (cacheMode !== undefined) {
594594
query.cacheMode = cacheMode;
595-
} else if (!query.cacheMode && query?.renewQuery !== undefined) {
595+
} else if (!query.cache && query?.renewQuery !== undefined) {
596596
// TODO: Drop this when renewQuery will be removed
597597
query.cacheMode = query.renewQuery === true
598598
? 'must-revalidate'
599599
: 'stale-if-slow';
600-
} else if (!query.cacheMode) {
600+
} else if (!query.cache) {
601601
query.cacheMode = 'stale-if-slow';
602602
}
603603

604604
// TODO: Drop this when renewQuery will be removed
605605
query.renewQuery = undefined;
606+
query.cache = undefined;
606607

607608
return query;
608609
}

packages/cubejs-api-gateway/src/query.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,7 @@ const querySchema = Joi.object().keys({
190190
// @deprecated
191191
renewQuery: Joi.boolean(),
192192
cacheMode: Joi.valid('stale-if-slow', 'stale-while-revalidate', 'must-revalidate', 'no-cache'),
193+
cache: Joi.valid('stale-if-slow', 'stale-while-revalidate', 'must-revalidate', 'no-cache'),
193194
ungrouped: Joi.boolean(),
194195
responseFormat: Joi.valid('default', 'compact'),
195196
subqueryJoins: Joi.array().items(subqueryJoin),

packages/cubejs-api-gateway/src/types/query.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,8 @@ interface Query {
142142
timezone?: string;
143143
// @deprecated
144144
renewQuery?: boolean;
145-
cacheMode?: CacheMode;
145+
cacheMode?: CacheMode; // used after query normalization
146+
cache?: CacheMode; // Used in public interface
146147
ungrouped?: boolean;
147148
responseFormat?: ResultType;
148149

0 commit comments

Comments
 (0)