grafana / scenes

Build Grafana dashboards directly in your Grafana app plugins.
https://grafana.com/developers/scenes
Apache License 2.0
145 stars 25 forks source link

Types: Allow using datasource types in scenes #293

Open gjulianm opened 1 year ago

gjulianm commented 1 year ago

Hello,

We're testing Grafana Scenes and we're finding incredibly useful. We've gotten to the point of building some more complex queries, and it would be interesting to have access to the type definitions for queries for the different datasources, at least for the ones that are defined by default in Grafana. However, they don't seem to be exported anywhere. Would this be something easy/valuable to implement in any of the Grafana TypeScript packages, or is it better that we copy these definitions into our code?

Thanks!

dprokop commented 1 year ago

Hi @gjulianm - those types are available in grafana/schema, i.e. for Prometheus data source @grafana/schema/dist/esm/raw/composable/prometheus/dataquery/x/PrometheusDataQuery_types.gen.

But keep in mind these APIs (imports from grafana/schema/dist....) are not public and not intended to use outside of the core Grafana libraries as of now.

Long term we want to introduce query builders similar to the PanelBuilders API.

We don't have an exact timeline for this work, but we would be more than happy to welcome contributions to the library if you are thinking about building something similar.

gjulianm commented 1 year ago

Thanks, that works! I'm ok with those definitions not being public, we're just using them for type checking mostly so even if they go away it's not a big problem.

Regarding the query builders, that would be definitely helpful. Right now we're doing very ad-hoc code for our databases, but if you have an issue/branch/docs where you're tracking that work and the architecture style you're following we could contribute with our code.

dprokop commented 1 year ago

@gjulianm We are thinking about following the builder pattern, exactly the same way we built PanelBuilders.

We would welcome contributions to query builders with <3