title: Apollo Client: Upsert mutation only modifies cache on update but not on create
body: <p>I have an upsert query that gets triggered on either create or update. On update, Apollo integrates the result into the cache but on create it does not.</p>
  
  <p>Here is the query:</p>
  
  <pre><code>export const UPSERT_NOTE_MUTATION = gql`
    mutation upsertNote($id: ID, $body: String) {
      upsertNote(id: $id, body: $body) {
        id
        body
      }
    }`
  </code></pre>
  
  <p>My client:</p>
  
  <pre><code>const graphqlClient = new ApolloClient({
    networkInterface,
    reduxRootSelector: 'apiStore',
    dataIdFromObject: ({ id }) =&gt; id
  });
  </code></pre>
  
  <p>The response from the server is identical: Both <code>id</code> and <code>body</code> are returned but Apollo isn't adding new ids into the <code>data</code> cache object automatically.</p>
  
  <p>Is it possible to have Apollo automatically add new Objects to <code>data</code> without triggering a subsequent fetch? </p>
  
  <p>Here is what my data store looks like:</p>
  
  <p><a href="https://i.stack.imgur.com/xZvJl.png"><img src="https://i.stack.imgur.com/xZvJl.png" alt="enter image description here"></a></p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>According to the documentation, the function <code>updateQueries</code> is supposed to allow me to push a new element to my list of assets without having to trigger my origin fetch query again.</p>
  
  <p>The function gets executed but whatever is returned by the function is completely ignored and the cache is not modified.</p>
  
  <p>Even if I do something like this:</p>
  
  <pre><code>    updateQueries: {
        getUserAssets: (previousQueryResult, { mutationResult }) =&gt; {
          return {};
        }
      }
  </code></pre>
  
  <p>Nothing changes.</p>
  
  <p><strong>UPDATE #2</strong></p>
  
  <p>Still can't get my assets list to update.</p>
  
  <p>Inside <code>updateQueries</code>, here is what my <code>previousQueryResult</code> looks like:</p>
  
  <pre><code>    updateQueries: {
        getUserAssets: (previousQueryResult, { mutationResult }) =&gt; {
          return {
            assets: []
              .concat(mutationResult.data.upsertAsset)
              .concat(previousQueryResult.assets)
          }
        }
      }
  </code></pre>
  
  <p>But regardless of what I return, the data store does not refresh:</p>
  
  <p><a href="https://i.stack.imgur.com/KYC6R.png"><img src="https://i.stack.imgur.com/KYC6R.png" alt="enter image description here"></a></p>
  
  <p>For reference, here is what each <code>asset</code> looks like:</p>
  
  <p><a href="https://i.stack.imgur.com/3pM2w.png"><img src="https://i.stack.imgur.com/3pM2w.png" alt="enter image description here"></a></p>