title: How to get around the "Missing field" warning when executing a mutation with an optimiticResponse in the apollo-client?
body: <p>I'm using aws-appsync with the apollo-client and when I try to execute a mutation without providing all fields I get a warning like "Missing field x in {...}". Do I really need to provide all (including optional) fields? How can I handle this gracefully?  </p>
  
  <p>I wonder if this is the expected behaviour or wether I'm missing something obvious. I don't want to maintain the added complexity of having to pass all optional fields and having those fields stored in the database as null values.
  I figured since they are just warnings I 'll just ignore them but I found that the updates would be executed in the database, but then the inmemorycache cache would not always update. It would sometimes show the update and other times not.</p>
  
  <pre><code>import {compose, graphql} from "react-apollo";
  import gql from "graphql-tag";
  import React from "react";
  
  export const EditCard = (props) =&gt; {
          const handleSave = () =&gt; {
              props.update({
                  givenName :'someGivenName',
                  //middleName omitted on purpose 
                  familyName :'someFamilyName',
              });
          };
      return (
          &lt;&gt;...more stuff here...&lt;/&gt;
      );
  };
  
  export const card = gql`
      fragment card on Identity{
          givenName
          middleName
          familyName
      }
  `;
  
  export const CardsGraphQL = gql`
      query GerCards {
          cards: listIdentitys(filter: {type: {eq: "CARD"}}) {
              items {
                  ...card
              }
          }
      }
      ${card}
  `;
  
  export const UpdateCardGraphQL = gql`
      mutation UpdateCard($input: UpdateIdentityInput!) {
          updateObject: updateIdentity(input: $input) {
              ...card
          }
      }
      ${card}
  `;
  
  
  export const selectConfig = () =&gt; {
      return {
          options: {
              fetchPolicy: 'cache-and-network',
          },
          props: (props) =&gt; {
              return {
                  cards: props.data.cards ? props.data.cards.items : [],
              };
          },
      };
  };
  
  export const updateConfig = (query) =&gt; {
      return {
          options: {
              update: (cache, {data: {updateObject}}) =&gt; {
  
                  // Read query from cache
                  const data = cache.readQuery({query});
  
                  // Add updated object to the cache
                  data.cards.items = data.cards.items.map(item =&gt; item.id === updateObject.id ? updateObject : item);
  
                  //Overwrite the cache with the new results
                  cache.writeQuery({query, data});
  
              },
          },
          props: (props) =&gt; {
              return {
                  update: (input) =&gt; {
                      props.mutate({
                          variables: {input},
                          optimisticResponse: () =&gt; ({
                              updateObject: input,
                          }),
                      });
                  },
              };
          },
      };
  };
  
  export default compose(
      graphql(CardsGraphQL, selectConfig),
      graphql(UpdateCardGraphQL, updateConfig(CardsGraphQL)))
  (EditCard);
  
  
  
  </code></pre>
  
  <p>For GraphQL this mutation seems to run without problems and the result in the dynamoDB is what I expect:</p>
  
  <p>{
  givenName :'someGivenName',
  familyName :'someFamilyName'
  }</p>
  
  <p>However the cache is not always updated with the mutation result and the apollo-client shows the warning:</p>
  
  <p>"Missing field middleName in {..."</p>
  
  <p>If I add the middleName field, the warning goes away and the cache updates correctly but the result in the dynamoDB is:</p>
  
  <p>{
  givenName :'someGivenName',
  middleName : null,
  familyName :'someFamilyName'
  }</p>
  
  <p>This approach results in additional complexity in my client that I would like to avoid maintaining.</p>
  
  <p>Does anyone else have this problem? How to solve this gracefully?</p>
  
  <p>Any help is appreciated.</p>