Well I made it all work except for the part where the cache actually gets invalidated. Somehow I still get cached results after invalidating the query.
It might be caused by this:
I’m not able to push to latest version. So it’s annoying that I can’t check if my code works or not.
Clearing the cache using the three dots on the query window works. But with JavaScript does not.