wildmountainfarms / wild-graphql-datasource

Grafana data source to interpret GraphQL queries as timeseries data. Includes a GraphiQL query editor with autocomplete!
https://grafana.com/grafana/plugins/retrodaredevil-wildgraphql-datasource/
MIT License
4 stars 1 forks source link

Show arrays as additional rows instead of columns #6

Open cedeerwe opened 4 days ago

cedeerwe commented 4 days ago

First of all, thanks for the great plugin, the idea with embedding Graphiql is very neat!

Example I am using: https://countries.trevorblades.com/ Query:

query {
  countries {
    name,
    languages {
      name
    }
  }
}

Data Path: countries Visualization: Table

I am getting a table with many columns, one for each index of the languages array. A much more intuitive and usable representation would be to have the first column repeated and the language column changing, i.e. instead of this:

+-------------+-----------------+-----------------+-----------------+
| name        | language.0.name | language.1.name | language.2.name |
+-------------+-----------------+-----------------+-----------------+
| Andorra     | Catalan         |                 |                 |
+-------------+-----------------+-----------------+-----------------+
| Afghanistan | Pashto          | Uzbek           | Turkmen         |
+-------------+-----------------+-----------------+-----------------+

To have this:

+-------------+---------------+
| name        | language.name |
+-------------+---------------+
| Andorra     | Catalan       |
+-------------+---------------+
| Afghanistan | Pashto        |
+-------------+---------------+
| Afghanistan | Uzbek         |
+-------------+---------------+
| Afghanistan | Turkmen       |
+-------------+---------------+

I understand that this might not be everybody's need (mine is 😂) and therefore having this as an optional parsing method for arrays would also make sense.

WDYT?

retrodaredevil commented 4 days ago

Yeah I agree this would be useful. I'll have to think of the best way to implement this. Maybe the query could have a list of "expand array" paths that would expand the array like you've shown.

Not sure when I'll be able to get around to this, but it will be on my to-do list.