Skip to content

Commit dc5d1cf

Browse files
committed
pass cacheMode to getSqlResponseInternal
1 parent 0eaf24b commit dc5d1cf

File tree

3 files changed

+10
-2
lines changed

3 files changed

+10
-2
lines changed

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

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import {
1212
getRealType,
1313
parseUtcIntoLocalDate,
1414
QueryAlias,
15+
CacheMode,
1516
} from '@cubejs-backend/shared';
1617
import {
1718
ResultArrayWrapper,
@@ -317,6 +318,7 @@ class ApiGateway {
317318
context: req.context,
318319
res: this.resToResultFn(res),
319320
queryType: req.query.queryType,
321+
cacheMode: req.query.cache,
320322
});
321323
}));
322324

@@ -326,7 +328,8 @@ class ApiGateway {
326328
query: req.body.query,
327329
context: req.context,
328330
res: this.resToResultFn(res),
329-
queryType: req.body.queryType
331+
queryType: req.body.queryType,
332+
cacheMode: req.body.cache,
330333
});
331334
}));
332335

@@ -335,7 +338,8 @@ class ApiGateway {
335338
query: req.query.query,
336339
context: req.context,
337340
res: this.resToResultFn(res),
338-
queryType: req.query.queryType
341+
queryType: req.query.queryType,
342+
cacheMode: req.query.cache,
339343
});
340344
}));
341345

@@ -1642,6 +1646,7 @@ class ApiGateway {
16421646
context: RequestContext,
16431647
normalizedQuery: NormalizedQuery,
16441648
sqlQuery: any,
1649+
cacheMode: CacheMode = 'stale-if-slow',
16451650
): Promise<ResultWrapper> {
16461651
const queries = [{
16471652
...sqlQuery,

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -653,6 +653,7 @@ export function makeSchema(metaConfig: any): GraphQLSchema {
653653
apiGateway.load({
654654
query,
655655
queryType: QueryType.REGULAR_QUERY,
656+
...(query.cache ? { cacheMode: query.cache } : {}),
656657
context: req.context,
657658
res: async (message) => {
658659
if (message.error) {

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
import type { Request as ExpressRequest } from 'express';
99
import type { DataResult } from '@cubejs-backend/native';
10+
import { CacheMode } from '@cubejs-backend/shared';
1011
import { RequestType, ApiType, ResultType } from './strings';
1112
import { Query } from './query';
1213

@@ -133,6 +134,7 @@ type QueryRequest = BaseRequest & {
133134
memberExpressions?: boolean;
134135
disableExternalPreAggregations?: boolean;
135136
disableLimitEnforcing?: boolean;
137+
cacheMode?: CacheMode;
136138
};
137139

138140
type SqlApiRequest = BaseRequest & {

0 commit comments

Comments
 (0)