title: Apollo Graphql mutation and refetch queries returning empty data
body: <p>Currently working on an app where we have a contact list with id and list name. Clicking on the contact list name will bring to a detailed page listing all contacts within the said contact listname. </p>
  
  <p>On this page a button is set to show input fields to add more contacts. These contacts are then added using mutations. </p>
  
  <p>Once the mutation is done, the contact list detail component failed to render and causing error of undefined (for map operators), however refreshing the page clearly shows the contact is successfully added. Here are the code snippets:</p>
  
  <p>ManageContact component, access via /contacts/manage/:id route</p>
  
  <pre><code>....
  
  class ManageContact extends Component {
    state = {
      showAddForm: false
    };
  
    handleAddContactBtn = () =&gt; {
      this.setState({ showAddForm: !this.state.showAddForm });
    };
  
    render() {
      const { showAddForm } = this.state;
  
      return (
        &lt;Query
          query={findContactList}
          variables={{ id: this.props.match.params.id }}
        &gt;
          {({ loading, error, data:{findContactList} }) =&gt; {
            if (loading) return "loading";
            if (error) return "error";
            console.log(findContactList)
            const renderContacts = findContactList =&gt; {
              const { contacts } = findContactList;
              return contacts.map((contact, index) =&gt; {
                return (
                  &lt;Row key={contact._id}&gt;
                    &lt;Col s={3}&gt;{contact.firstName}&lt;/Col&gt;
                    &lt;Col s={3}&gt;{contact.lastName}&lt;/Col&gt;
                    &lt;Col s={3}&gt;{contact.email}&lt;/Col&gt;
                    &lt;Col s={3}&gt;
                      &lt;Button&gt;
                        &lt;Icon&gt;edit&lt;/Icon&gt;
                      &lt;/Button&gt;
                      &lt;Button&gt;
                        &lt;Icon&gt;delete_forever&lt;/Icon&gt;
                      &lt;/Button&gt;
                    &lt;/Col&gt;
                  &lt;/Row&gt;
                );
              });
            };
            return (
              &lt;Fragment&gt;
                &lt;h3&gt;{findContactList.listName}&lt;/h3&gt;
                &lt;Row&gt;
                  &lt;Button onClick={this.handleAddContactBtn} className="right"&gt;
                    &lt;Icon&gt;{showAddForm ? "close" : "person_add"}&lt;/Icon&gt;
                  &lt;/Button&gt;
                &lt;/Row&gt;
                {renderContacts(findContactList)}
                {showAddForm ? (
                  &lt;RecipientList contactListID={findContactList._id} onFinishCreateContact={() =&gt; this.handleAddContactBtn()}/&gt;
                ) : null}
              &lt;/Fragment&gt;
            );
          }}
        &lt;/Query&gt;
      );
    }
  }
  
  export default ManageContact;
  </code></pre>
  
  <p>And here is the RecipientList component, where mutation to add contacts are performed:</p>
  
  <pre><code>...
  import {
    createContactMutation,
    findContactList,
    userContactListQuery
  } from "../../../graphql";
  
  class RecipientList extends Component {
    state = {
      firstName: "",
      lastName: "",
      email: ""
    };
  
    createContact = async () =&gt; {
      const {
        createContactMutation,
        contactListID,
        onFinishCreateContact
      } = this.props;
      const { firstName, lastName, email } = this.state;
      onFinishCreateContact()
      try {
        await createContactMutation({
          variables: {
            contactListID,
            firstName,
            lastName,
            email
          },
          refetchQueries: [
            { query: userContactListQuery },
            { query: findContactList, variables:{ id: contactListID }}
          ]
        });
  
  
      } catch (err) {
        console.log(err);
      }
  
    };
  
    handleInputChange = e =&gt; {
      this.setState({ [e.target.name]: e.target.value });
    };
  
    renderRecipientAddForm = () =&gt; {
      const { firstName, lastName, email } = this.state;
      return (
        &lt;Row&gt;
          &lt;Col s={3}&gt;
            &lt;Input
              label="First Name"
              name="firstName"
              value={`${firstName}`}
              onChange={this.handleInputChange}
            /&gt;
          &lt;/Col&gt;
          &lt;Col s={3}&gt;
            &lt;Input
              label="Last Name"
              name="lastName"
              value={`${lastName}`}
              onChange={this.handleInputChange}
            /&gt;
          &lt;/Col&gt;
          &lt;Col s={3}&gt;
            &lt;Input
              label="Email"
              name="email"
              value={`${email}`}
              onChange={this.handleInputChange}
            /&gt;
          &lt;/Col&gt;
          &lt;Col s={3}&gt;
            &lt;Button onClick={this.createContact}&gt;+&lt;/Button&gt;
          &lt;/Col&gt;
        &lt;/Row&gt;
      );
    };
  
    render() {
      return &lt;span&gt;{this.renderRecipientAddForm()}&lt;/span&gt;;
    }
  }
  
  export default graphql(createContactMutation, {
    name: "createContactMutation"
  })(RecipientList);
  </code></pre>
  
  <p>I have been trying to use refetchqueries but it keeps failing. I know when i console log after the mutation, i get the data being undefined, which is needed for the map operator within ManageContact component.</p>
  
  <p>Any ideas on what i did wrong?</p>