Querying child from List on Parent

What I want to do

Query child in list from Parent.

Schema made with GrapQL:

type Parent{
    nome: String! @id
    children: [Child]! @hasInverse(field: parent)
}

type Child{
    nome: String! @id 
    parent: Parent!
}

What I did

This query indeed returns all the children on a given parent.

query{
  queryParent{
    name
    children{
      name
    }
  }
}

but when I go on Ratel to visualize it, and do:

{
   q(func: has(Parent.name)){
    Parent.children
	}
}

the response is empty. It knows that Parent and Child is populated on the graph, but it doesn’t return it. How should I query it?

Dgraph metadata

dgraph version

PASTE THE RESULTS OF v21.03.1 HERE.

translated into DQL would be:

{
  queryParent(func: type(Parent)) {
    uid
    name: Parent.name
    children: Parent.children {
      uid
      name: Child.name
    }
  }
}

Note: I added the uids so that even if the name is not present the uid is still displayed. Also remapped the fields to the same names as the GraphQL query. You do have a typo in your question and should clarify whether you are using nome or name as that would make a difference.

1 Like

thanks for the answer. Yes, it was a typo, since I had to translate to English for a better presentation hahah