query.invalidateCache is not a function

Hello!

I am running into an issue with the invalidateCache function.
I have the following code


function clearMediaPageCache() {
  const queries = [
    select_allMedia_me,
    select_allAppearence_me,
    add_mediaAppearence_me,
    delete_mediaAppearence_me,
    select_allActivities_me,
    Select_allMediaActivity_me,
    determine_addedMediaActivity_me,
    determine_deletedMediaActivity_me
  ];
  
  queries.forEach(query => query.invalidateCache());
}

return clearMediaPageCache();

and it ran fine. Now when I run the code, it throws the error 'query.invalidateCache is not a function'.
This also only happens on one page, on all the others its fine. Can anyone help me?

Thank you in advance!

Hi @Katunga, based on your error, it seems like one of those query references is not able to access the query. If all of those queries are global scoped then it could be a typo (maybe the one that is capitalized?)

One way you could check for sure is to just modify the function to console log the queries, and then you can see which one is failing. Ex:

queries.forEach(query => {
    console.log(query.id);
    query.invalidateCache();
})