I'm reading the documentation for Apollo server-side caching, but don't see anything that talks about how caching is keyed generally.
What I need is a cache that's keyed on the object IDs contained in a response, not keyed on something that you get from the query.
For example, imagine the below Person object is uniquely identified by the ID field, and the hasShortHair field is expensive to calculate, but changes rarely.
type Person {
id: String!
hasShortHair: Boolean!
}
Assume that there are 2 different query types that can return a Person:
getPerson(id: String!): Person!
getAllPeople: [Person!]!
Ideally, for a person with a given ID, if that person has been fetched via either getPerson or getAllPeople recently, then I'd like to cache the value of hasShortHair that was calculated for that person, and use that cache for both getPerson and getAllPeople queries which return that person.
Will setting things up like the following achieve that? (Based on the book example in the documentation)
type Person @key(fields: "id") @cacheControl(maxAge: 30) {
id: String!
hasShortHair: Boolean!
}
or would the caching for this still be keyed per-request?