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
Suppose we have a forum where users can reply to comments recursively:
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