I have a schema like this:
type PersonExists {
id: Int!
exists: Boolean!
}
type Query {
people(ids: [Int!]!): [PersonExists!]!
}
Essentially, if I request people(ids: [1, 2, 3])
I am guaranteed to get back Person(id: 1)
, Person(id: 2)
and Person(id: 3)
.
Therefore, if I have people(ids: [1, 2, 3])
cached and I then query people(ids: [1, 2, 3, 4])
what I would like to do is only fetch people(ids: [4])
from the server and merge the results, as that is the only ID not cached. Likewise, people(ids: [3, 2, 1])
would be cached as all of the Person
s are cached.
Happy to clarify if I haven’t illustrated this well. Basically caching on a per argument array value basis, rather than all together.
I was hoping to do this through InMemoryCache
or similiar, rather than fiddling with the reading from the cache and changing the query manually. Is such a thing possible?