Handling annotation queries is similar to how you'd handle a metrics query. The difference is that instead of returning [data frames]({{< relref "data-frames.md" >}}), an annotation query returns _annotation events_.
Tell Grafana that your data source plugin can return annotations events by adding `"annotations": true` to the [plugin.json]({{< relref "metadata.md" >}}) file.
```json
{
"annotations": true
}
```
### Override the `annotationQuery` method
In `DataSource.ts`, override the `annotationQuery` method from `DataSourceApi`.
[Region annotations]({{< relref "../../dashboards/annotations.md#adding-regions-events" >}}) have a start and end time. This can for example be used to annotate maintenance windows or downtime.
Let users write custom annotation queries to only display the annotation events they care about, by adding a _query editor_. You only need to build a query editor if you want to let users query or filter annotations.
> **Note:** Annotation query editors have yet to receive support for React. The instructions here are given for Angular. Fortunately, you can run Angular even in a plugin otherwise written using React. This section will be updated once React support for annotation queries editors is available.
1. Create a file called `annotations.editor.html` in the `partials` directory you just created, with the following content.
```html
<divclass="gf-form-group">
<divclass="gf-form-inline">
<divclass="gf-form gf-form--grow">
<input
class="gf-form-input"
placeholder="query expression"
ng-model="ctrl.annotation.queryText"
></input>
</div>
</div>
</div>
```
1. In your data source query—the one that extends [DataQuery]({{< relref "../../packages_api/data/dataquery.md" >}})—add the `queryText` property. The name of the property needs to correspond to the text in `ng-model`, e.g. `ctrl.annotation.<propertyName>`.
```ts
export interface MyQuery extends DataQuery {
// ...
queryText?: string;
}
```
1. In `module.ts`, add the annotation query editor to the plugin.
```ts
import { AnnotationQueryEditor } from './AnnotationQueryEditor';
export const plugin = new DataSourcePlugin<DataSource,MyQuery,MyDataSourceOptions>(DataSource)
.setConfigEditor(ConfigEditor)
.setQueryEditor(QueryEditor)
.setAnnotationQueryCtrl(AnnotationQueryEditor);
```
The `queryText` property is now available on the `options` object in the `annotationQuery` method: