Skip to content

Commit ac1e7ca

Browse files
committed
Execute query if empty
1 parent d63b5b4 commit ac1e7ca

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

src/datasource.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,15 @@ export class DataSource extends DataSourceWithBackend<PreqQuery, PreqDataSourceO
88
super(instanceSettings);
99
this.annotations = {
1010
getDefaultQuery() {
11-
return {
11+
const query = {
1212
...DEFAULT_QUERY,
1313
queryType: 'annotations',
1414
};
15+
// Ensure the annotation has a target property pointing to the query itself
16+
return {
17+
...query,
18+
target: query,
19+
};
1520
},
1621
};
1722
}

src/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { DataQuery } from '@grafana/schema';
33

44
export interface PreqQuery extends DataQuery {
55
queryText?: string;
6+
target?: any; // For annotation queries that need a target property
67
}
78

89
export const DEFAULT_QUERY: Partial<PreqQuery> = {

0 commit comments

Comments
 (0)