Hi Ewan, thank you for your response. After some research on how to do nested replies generally, this is the solution I came up with and it works. I created a recursive UDF and called it on the FQL query.
Query(
Lambda(
["array"],
Let(
{
replies: Map(
Var("array"),
Lambda(
"x",
Let(
{
id: Select(["ref", "id"], Get(Var("x"))),
authorID: Select(['data', 'userID', 'id'], Get(Var('x'))),
author: Select(["data", "username"], Get(Match(Index('getUserByID'), Var("authorID")))),
content: Select(["data", "content"], Get(Var("x"))),
repliedToCommentID: Select(
["data", "repliedToCommentID", "id"],
Get(Var("x"))
),
created_at: Select(['data', 'created'], Get(Var('x'))),
replies: Call("LoopArray", [
Select(["data", "replies"], Get(Var("x")), [])
]),
},
{
ts: Select(['ts'], Get(Var('x'))),
commentID: Var("id"),
owner: Var('author'),
ownerID: Var('authorID'),
content: Var("content"),
repliedToCommentID: Var("repliedToCommentID"),
replies: Var("replies"),
created: ToMillis(Var('created_at'))
}
)
)
)
},
Var("replies")
)
)
)
PS: I used Paginate in the FQL query instead.