# Comment

**Kind:** Graphql Type

**Source:** [`atloria-monorepo/apps/parser-orchestrator/test/fixtures/sample-projects/fullstack-nextjs-nestjs/backend/api/schema.graphql`](https://github.com/sherkety/atloria/blob/main/atloria-monorepo/apps/parser-orchestrator/test/fixtures/sample-projects/fullstack-nextjs-nestjs/backend/api/schema.graphql#L1)

Comment on a post

`Comment` represents a user-authored message attached to a post. It supports threaded discussions through an optional `parent` comment and a collection of nested `replies`, while tracking creation and update timestamps.

## Diagram

```mermaid
graph LR
  Comment[Comment]
  User[User]
  Post[Post]
  Parent[Parent Comment]
  Replies[Reply Comments]

  Comment -->|author| User
  Comment -->|post| Post
  Comment -->|parent: optional| Parent
  Comment -->|replies| Replies
```

## Usage

```ts
import { gql } from "@apollo/client";

const GET_POST_COMMENTS = gql`
  query GetPostComments($postId: ID!) {
    post(id: $postId) {
      id
      title
      comments {
        id
        content
        createdAt
        updatedAt
        author {
          id
          name
        }
        replies {
          id
          content
          createdAt
          author {
            id
            name
          }
        }
      }
    }
  }
`;

// Example response shape:
// Comment includes its author, post relationship, optional parent,
// and recursively nested replies.
```

## AI Coding Instructions

- Query `author` when rendering comments, since `Comment` only stores the relationship rather than author display details.
- Treat `parent` as nullable; top-level comments do not have a parent comment.
- Request `replies` explicitly when implementing threaded discussion views, and limit nesting depth where needed to avoid overly large responses.
- Use `createdAt` and `updatedAt` as `DateTime` values; convert them to local display formats in the client.
- Associate new comments with a `Post`, and provide a parent comment identifier only when creating a reply.

## Relationships

- TYPE_OF → `User`
- TYPE_OF → `Post`
- TYPE_OF → `Comment`
- TYPE_OF → `Comment`
- TYPE_OF → `DateTime`
- TYPE_OF → `DateTime`

## Referenced By

- `addComment` (TYPE_OF)
- `newComment` (TYPE_OF)
- `Post` (TYPE_OF)
- `Comment` (TYPE_OF)
- `Comment` (TYPE_OF)
