Multiple labels/kinds for a type?

I’m transitioning from neo4j to Dgraph. One thing in neo4j is the notion of node labels. Or “kinds”. So, a node can be a “Person”, for example. That’s easy enough to do in Dgraph by creating a type “Person”. But is there a way to give a node more than one label? For example… a “Person” can also be a “Father”.

Just curious.


Yes, a Dgraph Type can be a Scalar string-list (it is automatically). You can just mutate new values to the same node. e.g:

<0x1> <dgraph.type> "Person" .
<0x1> <dgraph.type> "Father" .

Cool! Next question… Can I do this via GraphQL or do I need to use GraphQL+?

Just DQL, GraphQL isn’t that flexible. Maybe there is away, but I personally have no idea. But, following the GraphQL Specs, I can’t see how it would be possible there.

@abhimanyusinghgaur do you know how?

It’s not a huge deal… just basically another way to apply a property.

To do the same in GraphQL, you can make use of interfaces.

interface Person {
  id: ID!
  name: String!
type Father implements Person {
  hasChildren: [Person!]

That way, when you add a Father, the dgraph.type edge for that node will have both Father and Person as values.