Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Grafana Variables #63

Open
magaton opened this issue Jun 28, 2021 · 3 comments
Open

Grafana Variables #63

magaton opened this issue Jun 28, 2021 · 3 comments
Labels
question Further information is requested

Comments

@magaton
Copy link

magaton commented Jun 28, 2021

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.

@magaton magaton added the question Further information is requested label Jun 28, 2021
@retzkek
Copy link
Contributor

retzkek commented Jun 28, 2021

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).

@magaton
Copy link
Author

magaton commented Jul 7, 2021

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?

@retzkek
Copy link
Contributor

retzkek commented Jul 7, 2021

Try setting refresh to "On time range change", making the variable not hidden, selecting "All", then hiding it again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants