How can I modify data received from query?

I’m executing a query that returns an array of viewed Content. I’d like to filter this array but I can’t do it on the backend with graphQL due to a bug from the library I’m using. So I’d like to filter it with javascript on the frontend as a workaround.

Correct me if I’m wrong, but I understand that I need to update the cache if I want to modify data received from a query?

Is there no easy way to do this? I tried to use updateQuery and cache.update but I can’t understand how to do it from the docs. Could I use any of those inside of the useQuery hook?