mirror of
https://github.com/grafana/grafana.git
synced 2025-02-11 08:05:43 -06:00
22 lines
604 B
TypeScript
22 lines
604 B
TypeScript
import { isExpressionReference } from '@grafana/runtime/src/utils/DataSourceWithBackend';
|
|
import { DataQuery } from '@grafana/schema';
|
|
|
|
import { ExpressionQuery, ExpressionQueryType } from './types';
|
|
|
|
export const isExpressionQuery = (dataQuery?: DataQuery): dataQuery is ExpressionQuery => {
|
|
if (!dataQuery) {
|
|
return false;
|
|
}
|
|
|
|
if (isExpressionReference(dataQuery.datasource)) {
|
|
return true;
|
|
}
|
|
|
|
const expression = dataQuery as ExpressionQuery;
|
|
|
|
if (typeof expression.type !== 'string') {
|
|
return false;
|
|
}
|
|
return Object.values(ExpressionQueryType).includes(expression.type);
|
|
};
|