Goal:
I want to pass a query as an input to a module without triggering it beforehand. Instead, the module should trigger the query itself when it actually needs the data. This approach helps avoid loading potentially large datasets unnecessarily early.
Issue:
Inside the module, I'm trying to trigger the parent query (passed as input) using an additional scope. The parent query is indeed triggered, but the module fails to retrieve the data on the first attempt. However, once the parent query has been triggered and has fetched the data, rerunning the module query works as expected and retrieves the data successfully.
Additional info: Self-hosted
Thank you for your help in advance
// filtered_report_data : input query in the module
// data : additional scope to a query below in the module. it is sent on onClick event of an object as filtered_report_data.data which is expected null in the first click
let report_filtered_data_source = data ;
if(_.isEmpty(report_filtered_data_source))
{
const newTriggeredObject = await filtered_report_data.trigger();
report_filtered_data_source = newTriggeredObject.data;
console.log(report_filtered_data_source) // undefined
}```
That is some very quirky behavior that the query is able to be passed in but that it fails to return data on its first run, then succeeds on following runs
Are you able to get an error message in the debug panel from the first run? I wonder if that might have any clues.
Ideally this query should work the first and every time. Have you tried importing the query in from the Query Library instead of passing it in as an input?
It sounds like you found a serviceable work around where you get the initial 'dud' call out of the way by triggering the query right away. The only other option I can think of to get the query working all the time is to build it inside the module instead of importing it.
Are there any more details you can share about this issue? I do not think module inputs were meant to have functions passed in
You may need to instantiate the query within the module first and then it should run. When you pass the module in from outside it seems to not register the query but will then save and run after the first run fails to execute