Error Messages for Missing Values in Query Transformer

As the title says, I have a query that returns data that I am then filtering using the transformer.

This is what the filtering in the transformer looks like:

let newData = => _.includes(String({{selectModelYear.value}}), d.vehicle_year)).filter(d => _.includes({{nlohMakes.value}}, d.make.toUpperCase())).filter(d => _.includes({{nlohModel.value}}, d.model.toUpperCase()));

return newData;

And these are the selects that we get those values from:

Whenever I change the values in the selects, I get these errors:

I know this is coming from the transformer attempting to filter the value of data before the query has even ran to retrieve the data. My question is, seeing how this appears to be a widely applicable reason and way to use transformers for queries, how do I avoid those error messages? Or bar that option, make it so those error messages stop showing on the screen, since the code is working how I want it to anyway.

Thanks in advance.

Hey @shane_d_gray!

Happy to help with this. Would it be alright if I logged into your app to take a look (mostly want to look at your query's original data return)? If so, DM'ing me a link to your app would be best! If not, no worries at all. Instead, could you share a screenshot of your property (as shown in the left panel's State tab) with the transformer disabled?

Thank you!

That's absolutely fine! Let me go ahead and send you that link.

Thank you for sending me that link! I have a couple quick questions for you.

1. When do you want your getTurnRateData query to run? After every dropdown change?

2. When do you want the filtering to happen? After every getTurnRateData query run?

3. What would make your getTurnRateData query ever not return data?

1.) I only want it to run when we click the Get Data button.

2.) I would like the filtering to happen after every time it runs. Which really just needs to be once. I like how the transformer basically works as a live filter, so keeping that functionality.

3.) The only time it shouldn't return data is if the currently logged in user doesn't have any records tied to them, which should seldom happen.

Taking a look at your app, it actually seems like it's set up well!

You have a button to run the query (which takes care of your first point), your attached transformer will indeed only run once the query runs (which takes care of your second point) and your third point should be taken care of by the way you set up your query.

Are you still running into the same error message?

Yeah, I'm still getting the "Could not evaluate transformer in getTurnRateData: Error: Cannot read properties of null (reading 'data')" error message.

Ah, so that error generally only appears when the query itself doesn't return data. I can't really test this query since I'm either not authenticated or I'm not the right user, but if you disable the query's transformer, would you mind sharing a screenshot of the data returned? Ideally a screenshot of the State tab in your left panel!

Hey @shane_d_gray! So sorry for the delay here, just getting back into my inbox after some PTO.

I can't seem to get my examples to break in the same way.

Here's a very simple example that's working for me:

Out of curiosity, are you intentionally doing the filtering after pulling in all 23,550 items? I wonder if the transformer is acting before the data is finished returning. If that's the case, then our best bet would be to have a separate query that runs on success of this getTurnRateData query. Something like this:

If this doesn't work, might you be able to do the filtering in the request directly?

Let me know, and apologies again for the delay here!