fifemon / graphql-datasource

Grafana datasource plugin to query data from a GraphQL API
https://grafana.com/grafana/plugins/fifemon-graphql-datasource
Other
63 stars 33 forks source link

Supported graphql cursor style apis #84

Open alisters opened 1 year ago

alisters commented 1 year ago

The gitlab api graphql appears to implement the conventions of the graph ql cursor specification https://relay.dev/graphql/connections.htm and discussed here https://graphql.org/learn/pagination/ . It's schema can be browsed here https://gitlab.gbcloud.com.au/-/graphql-explorer and an example is

{ group(fullPath: "apps") { name projects (includeSubgroups:true, search:"digispike") { nodes { nameWithNamespace pipelines(updatedAfter: "2020-10-01") { nodes { id jobs { nodes { id name status duration startedAt stage { name } } } status } } } } } }

I was using this example to attempt to build a pipeline status dashboard in grafana, which is hopefully better than gitlabs own operations dashboard. Gitlabs own dashboard doesn't show you what stage a pipeline got to, nor any history - how long has it been failing for.

If we assume that gitlab, written in ruby, is using https://graphql-ruby.org/, this also supports pagination, then it's likely that supporting pagination in this datasource will

Describe the solution you'd like Data, grouping and time selection paths that allow better slicing of this style of graph into time series. I'm not an expert on graph algorithms but it seems like the resulting data graph needs to be able to be split, potentially multiple times, at points in the tree where the tree presents a value or an array. Options include JSONPath, JSON Match etc for doing this

Potentially, sub paths that select pageInfo objects to consume additional pages

Describe alternatives you've considered None, my brain is full. Open to ideas

Additional context Since this appears to be done client side it's performance is a consideration This would either be a breaking change, or need to live alongside the current format for paths (a drop down to select the style) If a data path then results in the time or grouping paths being relative to that prior path, we may need to indicate that https://grafana.com/docs/grafana/latest/developers/plugins/data-frames/#long-format - data frame formats may play a part in this e.g we may need to limit the array size that we select into each data frame ?

alisters commented 1 year ago

https://github.com/sanity-io/go-jsonmatch - since it supports extended unions, may allow a better extraction of fields, but is in go https://www.npmjs.com/package/node-jq - wraps jq, which looks like what may have been considered in the abandoned graphana graphql datasource