Skip to content

Commit 11f29ca

Browse files
committed
fix cache is part of query
1 parent e0ad591 commit 11f29ca

File tree

3 files changed

+5
-29
lines changed

3 files changed

+5
-29
lines changed

packages/cubejs-client-core/src/index.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,6 @@ export type LoadMethodOptions = {
5050
* AbortSignal to cancel requests
5151
*/
5252
signal?: AbortSignal;
53-
/**
54-
* Cache mode for query execution
55-
*/
56-
cache?: CacheMode;
5753
};
5854

5955
export type DeeplyReadonly<T> = {
@@ -112,6 +108,10 @@ export type CubeSqlOptions = LoadMethodOptions & {
112108
* Query timeout in milliseconds
113109
*/
114110
timeout?: number;
111+
/**
112+
* Cache mode for query execution
113+
*/
114+
cache?: CacheMode;
115115
};
116116

117117
export type CubeSqlSchemaColumn = {
@@ -574,7 +574,6 @@ class CubeApi {
574574
() => this.request('load', {
575575
query,
576576
queryType: 'multi',
577-
cache: options?.cache,
578577
signal: options?.signal,
579578
}),
580579
(response: any) => this.loadResponseInternal(response, options),

packages/cubejs-client-core/src/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ export interface Query {
115115
timezone?: string;
116116
// @deprecated
117117
renewQuery?: boolean;
118+
cache?: CacheMode;
118119
ungrouped?: boolean;
119120
responseFormat?: 'compact' | 'default';
120121
total?: boolean;

packages/cubejs-client-core/test/CubeApi.test.ts

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -217,30 +217,6 @@ describe('CubeApi with Abort Signal', () => {
217217
expect(requestSpy.mock.calls[0]?.[1]?.signal).toBe(signal);
218218
});
219219

220-
test('should pass cache from options to request', async () => {
221-
// Mock for this specific test
222-
const requestSpy = jest.spyOn(HttpTransport.prototype, 'request').mockImplementation(() => ({
223-
subscribe: (cb) => Promise.resolve(cb({
224-
status: 200,
225-
text: () => Promise.resolve('{"results":[]}'),
226-
json: () => Promise.resolve({ results: [] })
227-
} as any,
228-
async () => undefined as any))
229-
}));
230-
231-
const cubeApi = new CubeApi('token', {
232-
apiUrl: 'http://localhost:4000/cubejs-api/v1'
233-
});
234-
235-
await cubeApi.load(
236-
{ measures: ['Orders.count'] },
237-
{ cache: 'stale-if-slow' }
238-
);
239-
240-
expect(requestSpy).toHaveBeenCalled();
241-
expect(requestSpy.mock.calls[0]?.[1]?.cache).toBe('stale-if-slow');
242-
});
243-
244220
test('options signal should override constructor signal', async () => {
245221
const constructorController = new AbortController();
246222
const optionsController = new AbortController();

0 commit comments

Comments
 (0)