Skip to content

Recursively nested objects #91

Closed
Closed
@petrbela

Description

@petrbela

Suppose we have a forum where users can reply to comments recursively:

type RootQuery {
  message(id: String): Message
  messages: [Message]
}

type Message {
  id: String!
  content: String
  comments: [Message]
}

How could the client query for the nested comments?

This only goes three levels deep:

{
  messages {
    comments {
      id
      content
      comments {
        id
        content
        comments {
          id
          content       
        }
      }
    }   
  }
}

Would a consecutive query starting at the last comment be the right solution?

{
  message as comment($commentId) {
    comments {
      id
      content
      comments {
        ...
      }
    }
  }
}

Original SO post

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions