title: GraphQL queries with tables join using Node.js
body: <p>I am learning <code>GraphQL</code> so I built a little project. Let's say I have 2 models, <code>User</code> and <code>Comment</code>.</p>
  <pre><code>const Comment = Model.define('Comment', {
    content: {
      type: DataType.TEXT,
      allowNull: false,
      validate: {
        notEmpty: true,
      },
    },
  });
  
  const User = Model.define('User', {
    name: {
      type: DataType.STRING,
      allowNull: false,
      validate: {
        notEmpty: true,
      },
    },
    phone: DataType.STRING,
    picture: DataType.STRING,
  });
  </code></pre>
  <p>The relations are <code>one-to-many</code>, where a user can have many comments.<br />
  I have built the schema like this:</p>
  <pre><code>const UserType = new GraphQLObjectType({
    name: 'User',
    fields: () =&gt; ({
      id: {
        type: GraphQLString
      },
      name: {
        type: GraphQLString
      },
      phone: {
        type: GraphQLString
      },
      comments: {
        type: new GraphQLList(CommentType),
        resolve: user =&gt; user.getComments()
      }
    })
  });
  </code></pre>
  <p>And the query:</p>
  <pre><code>const user = {
    type: UserType,
    args: {
      id: {
        type: new GraphQLNonNull(GraphQLString)
      }
    },
    resolve(_, {id}) =&gt; User.findById(id)
  };
  </code></pre>
  <p>Executing the query for a user and his comments is done with 1 request, like so:</p>
  <pre><code>{
    User(id:&quot;1&quot;){
      Comments{
        content
      }
    }
  }
  </code></pre>
  <p>As I understand, the client will get the results using 1 query, this is the benefit using <code>GraphQL</code>. But the server will execute 2 queries, one for the user and another one for his comments.</p>
  <p>My question is, what are the best practices for building the <code>GraphQL</code> schema and types and combining join between tables, so that the server could also execute the query with 1 request?</p>