Why am I getting a "Cannot return null for non-nullable field" error when doing a mutation? : <p>I'm trying my hand at (Apollo) GraphQL on the server side and have been having a probably silly issue. I'm trying to sign up a user, but keep getting the error shown in the linked image below. What is the problem? Ignore the very simple auth flow, as I'm just testing out the GraphQl </p>

<p><a href="https://i.stack.imgur.com/l9gUD.png" rel="noreferrer"><img src="https://i.stack.imgur.com/l9gUD.png" alt="enter image description here"></a></p>

<p>Here are the relevant code snippets:</p>

<p><strong>Schema</strong></p>

<pre><code>export default `

type User {
    id: ID!
    name: String!
    email: String!
}

type Query {
    allUsers: [User]
  currentUser: User
}

type Mutation {
    createAccount(name: String!, email: String!, password: String!): User
    loginUser(email: String!, password: String!): User
    updatePassword(email: String!, password: String!, newPassword: String!): User
    deleteAccount(email: String!, password: String!): User
}

`
</code></pre>

<p><strong>Resolvers</strong></p>

<pre><code>createAccount: async (
  parent,
  { name, email, password },
  { User },
  info
) =&gt; {
  try {
    // Check for invalid (undefined) credentials
    if (!name || !email || !password) {
      return 'Please provide valid credentials';
    }

    // Check if there is a user with the same email
    const foundUser = await User.findOne({ email });

    if (foundUser) {
      return 'Email is already in use';
    }

    // If no user with email create a new user
    const hashedPassword = await bcrypt.hash(password, 10);
    await User.insert({ name, email, password: hashedPassword });

    const savedUser = await User.findOne({ email });

    return savedUser;
  } catch (error) {
    return error.message;
  }
},
</code></pre>
