Multi type node

Hi,

If I add to a node more than one type does it get the data from all types?
example, a node that is an animal a mammal and then a pet
also if I have a zoo can I insert this node as animal to the zoo animal list and still get the info of more specific types?

In the case you are using expand(_all_), yes.

You can also chose a type e.g expand(Mammal).

Amm, I think I didn’t explain myself well.
let’s say I have these types:

type <Animal> {
    Animal.num_of_legs #int
    Animal.eyes_color #string
}
type <Mamal> {
    Mamal.can_swim #bool
    Mamal.age #int
}
type <Pet> {
    Pet.owner_name #string
    Pet.name #string
}
type <Zoo> {
    animals #a list of animals
}

Now I want to add to the zoo a node that is a pet, a mammal, and an animal - let’s say a node of a cat named Garfield.
Will I be able to do that, and will I be able to query this node and via the zoo and still get the name of the owner
Can you supply an example?

You have to add the type in the dataset. e.g:

<0xff1a> <name> "Funky Black Cat" .
<0xff1a> <dgraph.type> "Animal" .
<0xff1a> <dgraph.type> "Mamal" .
<0xff1a> <dgraph.type> "Pet" .

The owner is another entity, it should be linked via an edge.

Ok so after you add the cat in your example you can just link it to the zoo by adding it to the animal list and query it from each one of its types right?
I mean I can search for the zoo by its name for example and filter this “Funky Black Cat”.
Then I can expand all of its fields and get the data right?
Can you show me how to add the “Funky Black Cat” node to a list of all animals in the zoo?

But why this animal would be in the zoo? (It is a pet) The link would be like this?

<%ZooUID> <animals> <0xff1a> .

Each one what? animal or type?

yeah

{
  q(func: eq(<Zoo.name>, "New York Zoo")) { 
    animals @filter(eq(<Pet.name>, "Funky Black Cat")) {
      uid
      expand(_all_)
    }
}

If all the data matches the types added in the previous list I have given as example, yes.

The first example above.

An animal mammal pet zoo’s example was to simplify the explanation of what I want to do.
I the real project, I have a type named DataSource, which is a base type, and then I have NosqlDb, File, object-store, etc. each one of them is a type with specific predicates.
I also have a type Repository, which can have multiple data sources, so I wanted to know if I can have a base type and expanding types and then use a list of the base type and gain a sort of polymorphism

you answered the rest of the questions with the query you added and the example of how to insert a new animal to the zoo