How to desgin a hierarchy scheam like a tree nodes?

Hi @RobinCc
There are two different approaches. You already mentioned one of them when you are using a middle node to connect two other nodes. This approach has its benefits, like easily putting extra data with different types on middle node instead of working with facets and dql and the down side of this approach is that you have lots of middle node(We use graph database to get rid of middle tables most of the time :slight_smile: ).

The second approach is to just use one type Node:

type Node {
NodeID: ID!
parent: Node
children: [Node]
}

I am not sure if hasInverse works in this case or not but you can handle that with some extra steps like a lambda resolver to insert nodes.

Also someone else had a similar situation and we had a discussion about this. You might want to take a look at that too:

1 Like