Skip to content

Commit dfa0d09

Browse files
committed
Interpolate custom parameters
1 parent 427bd1e commit dfa0d09

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

.github/workflows/main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ jobs:
2424
run: yarn build
2525

2626
- name: Sign plugin
27-
run: npx @grafana/toolkit plugin:sign
27+
run: yarn run grafana-toolkit plugin:sign
2828
env:
2929
GRAFANA_API_KEY: ${{ secrets.GRAFANA_API_KEY }} # Requires a Grafana API key from Grafana.com.
3030

src/DataSource.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,18 @@ export class DataSource extends DataSourceApi<JsonApiQuery, JsonApiDataSourceOpt
2525
}
2626

2727
async query(request: DataQueryRequest<JsonApiQuery>): Promise<DataQueryResponse> {
28+
const templateSrv = getTemplateSrv();
29+
2830
const promises = request.targets.map(async query => {
29-
const response = await this.api.cachedGet(query.cacheDurationSeconds, query.queryParams);
31+
const queryParamsTreated = templateSrv.replace(query.queryParams, request.scopedVars);
32+
33+
const response = await this.api.cachedGet(query.cacheDurationSeconds, queryParamsTreated);
3034

3135
const fields = query.fields
3236
.filter(field => field.jsonPath)
3337
.map(field => {
34-
const jsonPathTreated = getTemplateSrv().replace(field.jsonPath, request.scopedVars);
35-
const nameTreated = getTemplateSrv().replace(field.name, request.scopedVars);
38+
const jsonPathTreated = templateSrv.replace(field.jsonPath, request.scopedVars);
39+
const nameTreated = templateSrv.replace(field.name, request.scopedVars);
3640

3741
const values = JSONPath({ path: jsonPathTreated, json: response });
3842

0 commit comments

Comments
 (0)