Apollo cache updates list when querying item details

53 Views Asked by At

I have a problem with Apollo GraphQL:

  1. I have a list categories and every category has a list of items.
  2. Every category has its id and every item has its id.
  3. When I pull the list of categories with their items, I pull only these items which are available.
  4. When I click an available item, I need to pull the category details with its items, also the unavailable ones.
  5. This unfortunately updates the categories list with unavailable items.

I don't know how to separate list cache from the details cache. Unfortunately the objects are always updated.

1

There are 1 best solutions below

0
Michel Floyd On

Your type definitions have an ambiguity that the cache cannot deal with automatically. You can either (a) directly manipulate the cache to get the behavior you want (hard here actually) or (b) define a new field called availableItems under categories that only has available items.