I have a paginated graphQL-Query in my react app, which can paginate thousands of rows. The pagination is processed at server.
Now I want to use fetchPolicy cache-first, to be able to load a paginationQuery from cache, if i.e. user returns from back to a visited route which uses the paginated data.
This works, but to not overload the memory, I don't want to keep every ROOT_QUERY in cache (over time, the more often the user displays his data differently (different page, different sorting, different filter, etc. ...), the cache would grow immensely). How can I achieve to keep just the last cached query.
i.e.
const { loading, error, data } = useQuery(GQL_QUERY, {
variables,
fetchPolicy: 'cache-first',
onCompleted: () => {
//clear old cached versions of my GQL_QUERY no matter what parameters
}
});
Thanks