title: Unhandled Rejection (TypeError): Cannot read property 'extensions' of undefined. (GraphQL)
body: <p>I am using GraphQL along with MERNG and I am getting the following error: Unhandled Rejection (TypeError): Cannot read property 'extensions' of undefined. Please help me out. I also reinstalled graphql. This is the line where the error occurs: setErrors(err.graphQLErrors[0].extensions.exception.errors);</p>
  <p>This is my Register.js file:</p>
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>import React, {
    useState
  } from 'react'
  import {
    Button,
    Form
  } from 'semantic-ui-react'
  import gql from 'graphql-tag'
  import {
    useMutation
  } from '@apollo/react-hooks'
  
  function Register() {
    const [errors, setErrors] = useState({});
    const [values, setValues] = useState({
      username: '',
      email: '',
      password: '',
      confirmPassword: ''
    })
  
    const onChange = (event) =&gt; {
      setValues({ ...values,
        [event.target.name]: event.target.value
      });
    }
  
    const [addUser, {
      Loading
    }] = useMutation(REGISTER_USER, {
      update(proxy, result) {
        console.log(result);
      },
      onError(err) {
        console.log(err.graphQLErrors[0].extensions.exception.errors);
        setErrors(err.graphQLErrors[0].extensions.exception.errors);
      },
      variables: values
    })
  
    const onSubmit = (event) =&gt; {
      event.preventDefault();
      addUser();
    }
  
  
  
    return ( &lt;
      div className = "form-container" &gt;
      &lt;
      Form onSubmit = {
        onSubmit
      }
      noValidate &gt;
      &lt;
      h1 &gt; Register &lt; /h1&gt; &lt;
      Form.Input label = "Username"
      placeholder = "Username"
      name = 'username'
      type = "text"
      value = {
        values.username
      }
      onChange = {
        onChange
      }
      /&gt; &lt;
      Form.Input label = "Email"
      placeholder = "Email"
      name = 'email'
      type = "email"
      value = {
        values.email
      }
      onChange = {
        onChange
      }
      /&gt; &lt;
      Form.Input label = "Password"
      placeholder = "Password"
      name = 'password'
      type = "password"
      value = {
        values.password
      }
      onChange = {
        onChange
      }
      /&gt; &lt;
      Form.Input label = "Confirm Password"
      placeholder = "Confirm Password"
      name = 'confirmPassword'
      type = "password"
      value = {
        values.confirmPassword
      }
      onChange = {
        onChange
      }
      /&gt; &lt;
      Button type = "submit"
      primary &gt;
      Register &lt;
      /Button&gt; &lt;
      /Form&gt; {
        Object.keys(errors).length &gt; 0 &amp;&amp; ( &lt;
          div className = "ui error message" &gt;
          &lt;
          ul className = "list" &gt; {
            Object.values(errors).map(value =&gt; ( &lt;
              li key = {
                value
              } &gt; {
                value
              } &lt; /li&gt;
            ))
          } &lt;
          /ul&gt; &lt;
          /div&gt;
        )
      } &lt;
      /div&gt;
    )
  }
  
  const REGISTER_USER = gql `
      mutation register(
          $username: String!
          $email: String!
          $password: String!
          $confirmPassword: String!
      ){
          register(
              RegisterInput: {
                  username: $username
                  email: $email
                  password: $password
                  confirmPassword: $confirmPassword
              }
          ){
              id email username createdAt token
          }
      }
  `
  
  export default Register;</code></pre>
  </div>
  </div>
  </p>