React Apollo: One request, several arguments - How to cache?

I am puzzled by this.

Suppose I have the following query:

export const getPokemon = gql`
  query getPokemon($filters: AssetFilters) {
    pokemon(filters: $filters) {
      name,
      generation,
      exp
    }
  }`;

By default, filters are not passed, so everything is returned.

Now I would like to restore using a filter as such:

this.props.refetch({
  filters: {
    generation: '3rd'
  }
});

The above looks like overriding the local cache of the original request !

I am writing an offline-first application, and I would like these different filtering permutations to be cached separately, rather than overriding the original cache.

How can I overcome this caching complexity and have Apollo cache these requests with different arguments separately?

+4
source share
1 answer

Apollo , . , .

Apollo Devtools, . , , , Apollo Client GitHub .

+3

Source: https://habr.com/ru/post/1676618/


All Articles