title: Laravel 8 - Light house graphql - threaded comments with all nested comments and nested comment counts
body: <p>I have two models Post and Comment</p>
  <p>Post modal :</p>
  <pre><code>&lt;?php
  
  namespace App\Models;
  
  use Illuminate\Database\Eloquent\Model;
  
  class Post extends Model
  {
      protected $fillable = [
      'user_id','community_id','topic_id','title','description','slug','url', 'image_url', 'timezone', 'image', 'news_organization_id'];
  
      public function comments()
      {
          return $this-&gt;morphMany('App\Models\Comment', 'commentable')-&gt;whereNull('parent_id');
      }
  
      public function allComments()
      {
          return $this-&gt;hasMany('App\Models\Comment', 'commentable_id');
      }
  }
  
  </code></pre>
  <p>Comment modal :</p>
  <pre><code>&lt;?php
  
  namespace App\Models;
  
  use Illuminate\Database\Eloquent\Model;
  
  class Comment extends Model
  {
      protected $fillable = ['user_id', 'parent_id', 'text', 'commentable_id', 'commentable_type'];
  
      public function user()
      {
          return $this-&gt;belongsTo(User::class);
      }
      public function commentable()
      {
          return $this-&gt;morphTo();
      }
  
      public function replies()
      {
          return $this-&gt;hasMany(Comment::class, 'parent_id');
      }
  }
  
  </code></pre>
  <p>I want to fetch all comments of post with nested comments and their count in graphql query.</p>
  <p>I have tried with the below query, it gives me a count of comments and nested comments but the count is null for nested comments. Also, there is pagination in my project.</p>
  <pre><code>
  $comments = Comment::withCount('replies')-&gt;where('commentable_id', $post-&gt;id)-&gt;where('parent_id', null)-&gt;orderBy('created_at', 'desc')-&gt;paginate($limit, ['*'], 'page', $current_page);
  
  $last_page = $comments-&gt;lastPage();
  
  </code></pre>
  <p>You can see the result in the below image</p>
  <p><a href="https://i.stack.imgur.com/zx69Z.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/zx69Z.png" alt="enter image description here" /></a></p>
  <p>Like for <strong>Parent comment 1 =&gt; replies_count is 2</strong>, but for its <strong>Child comment 3 =&gt; replies_count is null, it has to be 1</strong>.</p>