How can I expand only UID predicates from nodes?

I have learnt Dgraph for serveral weeks . I find GraphQL± is powerful if you are clear about what data the Dgraph stores and what data you want. But if you don’t know what data the Dgraph stores , things become difficult. For example, I want to get all relative nodes of the current nodes. But I don’t know what predicates there are and which are of UID type. How can I do that?

(moved to here)

In latest version of Dgraph is mandatory to have a Type Schema - So Dgraph is aware of the edges. If you have the Type Schema and add <0x1> <dgraph.type> "Person" . in your data set, you gonna be able to perform expand all queries.

If you need to add the types use this tips in this topic Has some problem when Upgrade Database from 1.0.15 to 1.1.0

Very thankful for reply! I have another question (Apology for my bad English , I’m not an English speaker). If I define type Person { name: string } and type Student { name: string , class: string} , and set <0x1> <dgraph.type> Person . <0x1> <dgraph.type> Student . Then I use expand(all), I will get name and class of 0x1. What if I only what name of 0x1 as a Person, not a Student? Must I query like this : { person( func: uid (0x1) ) { name } } ?

Well, your node has two types. There’s no logic separation when you have multiple types as far I know. But you could try this to check it.

  q(func:  type(Student) ) { 

Right now we still improving the type system. So I’m not 100% sure if there is a logic separation on multiple types. I’ll check too.


yep, there’s no logic separation.

  set {
    <_:a> <name> "Lucas" .
    <_:a> <class> "Geology" .
    <_:a> <dgraph.type> "Person" .
    <_:a> <dgraph.type> "Student" .

The result for q(func: type(Student) ) was

  "data": {
    "q": [
        "name": "Lucas",
        "class": "Geology"

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.