Skip to content

Commit

Permalink
Some updates to docs, frames sorted alphabetically by name
Browse files Browse the repository at this point in the history
  • Loading branch information
retrodaredevil committed Feb 25, 2024
1 parent 3cc3c0d commit 3ab5cf7
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 16 deletions.
22 changes: 17 additions & 5 deletions DEVELOPMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,23 @@ https://grafana.com/developers/plugin-tools/create-a-plugin/develop-a-plugin/bes
https://grafana.com/developers/plugin-tools/tutorials/build-a-data-source-backend-plugin


## Installing via grafana-cli

If you want to test a released, but unsigned plugin, follow this.

https://grafana.com/docs/grafana/latest/cli/#override-default-plugin-zip-url

```shell
grafana cli --pluginUrl https://github.com/wildmountainfarms/wild-graphql-datasource/releases/download/v0.0.2/retrodaredevil-wildgraphql-datasource-0.0.2.zip plugins install retrodaredevil-wildgraphql-datasource
```

Then update `grafana.ini` with

```ini
[plugins]
allow_loading_unsigned_plugins = retrodaredevil-wildgraphql-datasource
```

## Building and Development

### Setup your system
Expand Down Expand Up @@ -106,11 +123,6 @@ This section contains notes about dependencies.

## To-Do

* Queries that result in errors should display nice errors messages on the frontend
* Add ability to have multiple parsing options
* Add "advanced options" section that has "Partition by" and "Alias by"
* Including these might be necessary as you may want to partition by and alias by different things for different parts of a GraphQL query
* Advances options can also include the ability to add custom labels to the response - this allows different parsing options to be distinguished by Grafana
* Add support for secure variable data defined in the data source configuration
* The variables defined here cannot be overridden for any request - this is for security
* Also add support for secure HTTP headers
Expand Down
14 changes: 8 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
# Wild GraphQL Datasource

**This plugin is in early development. Breaking changes may happen at any time.**

This is a Grafana datasource that aims to make requesting time series data via a GraphQL endpoint easy.
This datasource is similar to https://github.com/fifemon/graphql-datasource, but is not compatible.
This datasource tries to reimagine how GraphQL queries should be made from Grafana.
The query editor uses [GraphiQL](https://github.com/graphql/graphiql) to provide an intuitive editor with autocompletion.
Requests are made in the backend allowing support for alerting.

Requests are made in the backend. Results are consistent between queries and alerting.

## Features

* Complex GraphQL responses can be turned into timeseries data, or a simple table
* Includes [GraphiQL](https://github.com/graphql/graphiql) query editor. Autocompletion and documentation for the GraphQL schema available inside Grafana!
* This is a backend plugin, so alerting is supported
* Documentation explorer can be opened from the query editor
* Prettify the query with the click of a button
* `from` and `to` variables are given to the query via [native GraphQL variables](https://graphql.org/learn/queries/#variables)
* Variables section of the query editor supports interpolation of string values using [Grafana variables](https://grafana.com/docs/grafana/latest/dashboards/variables/add-template-variables/). (\*not supported in alerting or other backend-only queries)
* Multiple parsing options are supported allowing for a single GraphQL query to return many different data point with different formats.
* Each parsing option has its own labels, which can be populated by a field in the response. These labels are used to group the response into different data frames.
* Labels can be used to change the display name by using `${__field.labels["displayName"]}` under Standard options > Display name.
* This is a backend plugin, so alerting is supported
* [Annotation support](https://grafana.com/docs/grafana/latest/dashboards/build-dashboards/annotate-visualizations/)


Expand Down
4 changes: 4 additions & 0 deletions pkg/plugin/parsing/framemap/framemap.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"github.com/grafana/grafana-plugin-sdk-go/data"
"hash/fnv"
"slices"
"sort"
)

type FrameAndLabels struct {
Expand Down Expand Up @@ -109,5 +110,8 @@ func (f *FrameMap) ToFrames() []*data.Frame {
r = append(r, frame)
}
}
sort.Slice(r, func(i, j int) bool {
return r[i].Name < r[j].Name // sort alphabetically by name
})
return r
}
2 changes: 1 addition & 1 deletion src/img/logo.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/img/screenshot-query-editor.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 12 additions & 3 deletions src/plugin.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,24 @@
"info": {
"description": "Grafana datasource to interpret GraphQL query results as timeseries data",
"author": {
"name": "Lavender Shannon"
"name": "Lavender Shannon",
"url": "https://github.com/retrodaredevil"
},
"keywords": ["datasource"],
"keywords": [
"datasource",
"graphql"
],
"logos": {
"small": "img/logo.svg",
"large": "img/logo.svg"
},
"links": [],
"screenshots": [],
"screenshots": [
{
"name": "Query Editor",
"path": "img/screenshot-query-editor.png"
}
],
"version": "%VERSION%",
"updated": "%TODAY%"
},
Expand Down
2 changes: 1 addition & 1 deletion src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ export const DEFAULT_QUERY: Partial<WildGraphQLMainQuery> = {
queryStatus(sourceId: $sourceId, from: $from, to: $to) {
batteryVoltage {
dateMillis
fragmentId
fragmentIdString
packet {
batteryVoltage
identifier {
Expand Down

0 comments on commit 3ab5cf7

Please sign in to comment.