title: Apollo Client Query Deduplication on Cached Object
body: <p>I recently read an article about Apollo Client Caching on the <a href="https://blog.apollographql.com/the-concepts-of-graphql-bc68bd819be3" rel="nofollow noreferrer">official blog</a>, with a <a href="https://i.stack.imgur.com/obH1Y.png" rel="nofollow noreferrer">screenshot</a>
  here. </p>
  
  <p>According to the article, if the current query contains a cached object, along with other objects, the query will be deduplicated to only query the rest of the objects.</p>
  
  <p>However, I did some testing by logging out queries on the server, which suggested that the query had not been partially deduplicated. Instead, the entire query got sent to the server. </p>
  
  <p>Can anyone provide any insight on this. Thanks very much.</p>
  
  <p><strong>Test</strong>: </p>
  
  <p>First query:</p>
  
  <pre><code>{
     post(_id: 1) {
        _id
        title
     }
  }
  </code></pre>
  
  <p>Second query:</p>
  
  <pre><code>{
     post(_id: 1) {
        _id
        title
     }
     author(_id: 1) {
        _id
        firstName
     }
  }
  </code></pre>
  
  <p><strong>Intended outcome:</strong>
  The secomd query received by the server only contains </p>
  
  <pre><code>author(_id: 1) {
     _id
     firstName
  }
  </code></pre>
  
  <p>since <code>post(_id: 1)</code> has been cached after the first query is sent, according to the blog. </p>
  
  <p><strong>Actual outcome:</strong>
  Server log: (the second query has <strong>NOT</strong> been deduplicated)</p>
  
  <pre><code>{
     "operationName": null,
     "variables": {},
     "query": "{\n  post(_id: 1) {\n    _id\n    title\n    __typename\n  
     }\n}\n"
  } /graphql 200 81 - 0.520 ms
  
  {
     "operationName": null,
     "variables": {},
     "query": "{\n  post(_id: 1) {\n    _id\n    title\n    __typename\n  
     }\n  author(_id: 1) {\n    _id\n    firstName\n    __typename\n  }\n}\n"
  } /graphql 200 140 - 0.726 ms
  </code></pre>