title: React Apollo first object from subscription not being merge into previous data it actually gets removed
body: <p>I have a query which gets me a list of notes and a subscription which listens and inserts new notes by altering the query. However the problem is the first note doesn't get added.</p>
  
  <p>So let me add more detail, initially the query response with an object which contains an attribute called notes which is an array of 0 length, if we try and add a note the attribute gets removed. The note is created so if I refresh my application the query will return the note then If I try and add a note again the note gets added to the array in the query object.</p>
  
  <p>Here is my notes container where I query for notes and create a new property to subscribe to more notes.</p>
  
  <pre><code>export const NotesDataContainer = component =&gt; graphql(NotesQuery,{
  
  name: 'notes',
  props: props =&gt; {
  
    console.log(props); // props.notes.notes is undefined on first note added when none exists.
  
    return {
      ...props,
      subscribeToNewNotes: () =&gt; {
  
        return props.notes.subscribeToMore({
          document: NotesAddedSubscription,
          updateQuery: (prevRes, { subscriptionData }) =&gt; {
  
            if (!subscriptionData.data.noteAdded) return prevRes;
  
            return update(prevRes, {
              notes: { $unshift: [subscriptionData.data.noteAdded] }
            });
  
          },
        })
      }
    }
  }
  
  })(component);
  </code></pre>
  
  <p>Any help would be great, thanks.</p>
  
  <p>EDIT:</p>
  
  <pre><code>export const NotesQuery = gql`
    query NotesQuery {
      notes {
        _id
        title
        desc
        shared
        favourited
      }
    }
  `;
  
  export const NotesAddedSubscription = gql`
    subscription onNoteAdded {
      noteAdded {
        _id
        title
        desc
      }
    }
  `;
  </code></pre>
  
  <p>Another EDIT</p>
  
  <pre><code>class NotesPageUI extends Component {
  
    constructor(props) {
  
      super(props);
  
      this.newNotesSubscription = null;
  
    }
  
     componentWillMount() {
  
        if (!this.newNotesSubscription) {
  
        this.newNotesSubscription = this.props.subscribeToNewNotes();
  
        }
  
     }
  
     render() {
  
       return (
          &lt;div&gt;
  
            &lt;NoteCreation onEnterRequest={this.props.createNote} /&gt;
  
              &lt;NotesList
                notes={ this.props.notes.notes }
                deleteNoteRequest={    id =&gt; this.props.deleteNote(id) }
                favouriteNoteRequest={ this.props.favouriteNote }
              /&gt;
  
          &lt;/div&gt;
       )
     }
   }
  </code></pre>
  
  <p>Another edit:</p>
  
  <p><a href="https://github.com/jakelacey2012/react-apollo-subscription-problem" rel="nofollow noreferrer">https://github.com/jakelacey2012/react-apollo-subscription-problem</a></p>