Generate cache id per each item in argument list

I have a schema like this:

type Product {
 uuid:string!
name: string!
}

type City {
 uuid:string!
name: string!
}


type CityProducts{
  city: City!
  products: [Product!]!
}

type Query {
  citiesProducts(cityIds: [Int!]!): [CityProducts!]!
}

If request citiesProducts(cityIds: [100, 200]) I am guaranteed to get back CityProducts(id: 100), CityProducts(id: 200). Now they are cached

Now if I query citiesProducts(ids: [100, 200, 300])
what I would like to do is only fetch citiesProducts(cityIds: [300]) from the server and merge the results, as that is the only ID not cached.

Can we do this via InMemoryCache or something similar?
It solves lot of duplicate queries in our app

Thanks