Hi, I'm new to graphql and I'd like to build a tod...
# prisma-whats-new
e
Hi, I'm new to graphql and I'd like to build a todo-list with many-to-many relations, where I could for example have data as follows: "title": "work", "childrenTasks": [ { "title": "projects", "childrenTasks": [ { "title": "typic.bid", "childrenTasks": [ { "title": "Marketing", "childrenTasks": [] … How could I query for all tasks with the parent projects, and no childTasks? Is GraphQL even a tool that would allow this easily? Thanks in advance
n
@emil do you know the depth beforehand? šŸ™‚
e
No, I don't Could be anything
@nilan is there a way to do this without somehow indexing the relations?
n
What do you mean with indexing? You could have an int field
level
and then query the different levels like this:
ah so you could store the data like this:
Copy code
parent: id: c1 level 0 root: null
child: id: c2 level 1 root: c1
child: id: c3 level 1 root c1
  child: id c4 level 2 root c1
  child: id c6 level 2 root c1
      child: id c7 level 3 root c1
child: id: c5 level 1 root c1
Copy code
query {
  Task(id: "c1") {
    id
    children {
      id
      level
    }
  }
}
e
@nilan The solution I'm aiming for would also support children with many different parents, I don't see how that would be possible with your suggested solution Am I getting something wrong? Thanks