graphql-datasource
graphql-datasource copied to clipboard
Grafana Variables
Hello, I have a graphql api that looks like this
promoPeriod(logins: [String]!, stores: [String]!): [Month]
Month is a graphql defined type with fields: id, name, type, etc. logins and stores are the multi-option variables defined on the same dashboard
I would like to define a variable promotionMonths (hidden) as Query above, that is using selected $logins and $stores which I can later use in other graphql queries on the dashboard.
Any idea how to do this? I was not able to find any docs wrt this topic (chaining variables with this datasource). Apologies if I am missing something obvious.
I believe chained variables should work fine, have you tried? The complexity I see here is that the variables are lists, but that should just be a matter of picking the right format for the variable expansion (try json
).
So, the first part is working fine:
I am able to correctly resolve the hidden variable promoPeriod
with the query:
promoPeriod(login: String!, period: String!, store: String!): [Month]
where $login, $period, and $store parameters are properly resolved from the other variables.
But, my chart needs to always take ALL values from the hidden variable promoPeriod
. Example: If it got resolved to 3 months, I need to pass ALL 3 months to the chart.
I cannot make this work.
Problems: When I want to change the $period, my values in promoPeriod
are not refreshed.
Even if they are refreshed, how could I automatically select the "All" option in promoPeriod
?
Try setting refresh to "On time range change", making the variable not hidden, selecting "All", then hiding it again.