-
Notifications
You must be signed in to change notification settings - Fork 35
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
Support GraphQL query variables #12
Comments
An easy way to implement this is to use two distinct fields in the query configuration, one with the query, another with the variables as a JSON string. The variable string can easily be appended in the POST request to the graphql server. The expressions (e.g. Grafana global variables) could then be replaced in the variable string instead of the query string (or in both if relevant). |
That's a good idea @Totalus, and is how graphiql does it, making it easy for one to copy-paste queries. We'll need to be careful about quoting, can we do any better than raw substitution and leaving quoting up to the user?
This is also tricky - do we make a breaking change and only do interpolation in the variable document, or do we risk doing unintended substitutions in the query body (since both Grafana and GraphQL use $var syntax)? |
I didn't mean to "quote" the expressions to replace, sorry for the confusion. As you say it should be raw substitution and quoting of the variables left to the user. As for the breaking change, if Grafana 7.0 implies some breaking changes in this plugin (not sure about that, you would know more than I do), we could possibly make the change at the same time. |
Sorry, I wasn't referring specifically to anything you said, just thinking out loud.
I've started working on upgrading to Grafana v7 libraries. Some components have moved around (as usual...) but I don't think there's anything that will require a user-facing change. |
Did this ever get implemented? |
Since GraphQL has first-class variables we should use those rather than directly interpolating in the query string.
The text was updated successfully, but these errors were encountered: