title: Apollo server-side caching: What is cache keyed on?
body: <p>I'm reading the <a href="https://www.apollographql.com/docs/apollo-server/performance/caching/" rel="nofollow noreferrer">documentation for Apollo server-side caching</a>, but don't see anything that talks about how caching is keyed generally.</p>
  <p>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.</p>
  <p>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.</p>
  <pre><code>type Person {
    id: String!
    hasShortHair: Boolean!
  }
  </code></pre>
  <p>Assume that there are 2 different query types that can return a Person:</p>
  <pre><code>getPerson(id: String!): Person!
  getAllPeople: [Person!]!
  </code></pre>
  <p>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 <em>both</em> getPerson and getAllPeople queries which return that person.</p>
  <p>Will setting things up like the following achieve that? (<a href="https://www.apollographql.com/docs/apollo-server/performance/caching/#setting-entity-cache-hints" rel="nofollow noreferrer">Based on the book example in the documentation</a>)</p>
  <pre><code>type Person @key(fields: &quot;id&quot;) @cacheControl(maxAge: 30) {
    id: String!
    hasShortHair: Boolean!
  }
  </code></pre>
  <p>or would the caching for this still be keyed per-request?</p>