title: Graphql, node.js and sql,Cannot return null for non-nullable field
body: <p>I want to return data coming from db to the api. The data is being logged but not showing on the graphql api.</p>
  
  <pre><code>const express = require('express');
  const bodyParser = require('body-parser');
  const graphqlHttp = require('express-graphql');
  const { buildSchema } = require('graphql');
  var mysql = require('mysql');
  
  const app = express();  
  
  //start mysql connection    
  var connection = mysql.createConnection({    
    host     : 'localhost', //mysql database host name    
    user     : 'root', //mysql database user name    
    password : '', //mysql database password    
    database : 'test' //mysql database name    
  });
  
  connection.connect(function(err) {    
    if (err) throw err      
  })    
  
  //end mysql connection
  
  app.use(bodyParser.json());    
  app.use(    
    '/graphql',    
    graphqlHttp({
      schema: buildSchema(`
          type users {
            id: String!
            username: String!
            password: String!
            role: String!
            name: String!
            photo: String!
          }
          type RootQuery {
              getUsers: [users!]!
          }
          type RootMutation {
            createUsers(name: String): String
          }
          schema {
              query: RootQuery
              mutation: RootMutation
          }
      `),
      rootValue: {
        getUsers: () =&gt; {
          connection.query('select * from users', function (error, results, fields) {
            if (error) throw error;
            console.log(JSON.stringify(results))
            return JSON.stringify(results) ;
          });
        },
        createUsers: (args) =&gt; {
          const eventName = args.name;
          return eventName;
        }
      },
      graphiql: true
    })
  );
  
  app.listen(3000);
  </code></pre>
  
  <p>RESULT:</p>
  
  <pre><code>query
  {
    getUsers {
      id
    }  
  }
  </code></pre>
  
  <p>OUTPUT:</p>
  
  <pre><code>{
    "errors": [
      {
        "message": "Cannot return null for non-nullable field RootQuery.getUsers.",
        "locations": [
          {
            "line": 3,
            "column": 3
          }
        ],
        "path": [
          "getUsers"
        ]
      }
    ],
    "data": null
  }
  </code></pre>