Executing core query builder code outside the edit screen

Hello everyone. I have a datasource plugin that Im having a small problem with and was wondering if any of you have had this kind of experience and could shed some light into any solutions. Ok so the problem with my datasource is when you’re in the QueryBuilder view a config loads which gives me field values that I use to generate form fields that the user interacts with to build a query. Once the query is built I send that off to a backend service which returns the data. Everything is great and works properly. The issue comes in when we make updates to the config with new fields or the way we are manipulating the config data. When this happens the API usually expects these changes so when the user goes to a dashboard that the panels were built before the upgrades the panel can breaks and does not show a graph. Once the user clicks to go into edit mode of the panel then my script for the QueryBuilder runs, the updated config loads and the updated scrips “fixes” the query and the panel works again.

My question is, is there a way to run the QueryBuilder code outside edit mode and in the dashboard view? Ive tried to see if this was possible and could not find a way. I read it was to avoid performance issues. Im hoping to be able to run the QueryBuilder script when needed if the panel is broken without the user having to click into edit mode?

Any advice would be greatly appreciated.

What is the datasource you are querying against?

Its our own custom datasource. The code QueryBuilder script has the proper flow that loads in the config, fixes the data and sends out the updated query. The issue is when you view the panel in the dashboard view the QueryBuilder code does not run. Its only when you enter edit for the panel that the QueryEditor code runs and fixes everything.

1 Like

@christianramirez

is there a way to run the QueryBuilder code outside edit mode

no this is not possible.

But perhaps this is something you can do in your query method in the datasource instead of the query builder?

It looks like you have a setup that constantly introduces breaking changes to your query language so this should be handled in the query method.

@academo thanks for your input. Yeah I totally understand… I was hoping this was in a way possible but figured it would be a stretch. I do actually fire the query in the datasource. The issue is the config and all the data manipulation I do with it. Its actually a pretty large application. It’s built with a React front end. One suggestion I had was to detect the tag version of the panel the user is currently on, if the tag version is older than the latest release tag then I can “warn” the user the panel need to be updated by them opening the edit panel… This might not be accepted by the team since honestly not all our releases break the panels but only on occasion… Plus if I push out that tag version warning in my next release, every panel will have this warning… Im going to explain to the team its the nature of our app. There is a ton of functionality that I just cant cram into the datasource file… Thanks again.