Some questions about query

When I am writing queries, I met these questions:

  1. For this query,
{
	person(func: uid("0x59179e7")) {
		~hasCreator{
			uid
			content
			imageFile
			creationDate
			replyOf{
				uid
			}
		}
	}
}

some results contain the replyOf and some results just contain the other four properties. If I just want to ouput the results that contain replyOf, how should I write the query.
Part of the results are showed as:

{
            "uid": "0x593034e",
            "content": "",
            "imageFile": "photo824633721183.jpg",
            "creationDate": "2012-01-27T10:01:24.389Z"
          },
          {
            "uid": "0x5930fff",
            "content": "thx",
            "creationDate": "2012-06-03T11:51:59.268Z",
            "replyOf": [
              {
                "uid": "0x5bab63a"
              }
            ]
          },

I have tried the @casscade, like

{
	person(func: uid("0x59179e7")) {
		~hasCreator  @cascade{
			uid
			content
			imageFile
			creationDate
			replyOf{
				uid
			}
		}
	}
}

, but could not get any results.
2. How to transfer the value to the nested subqueries. I tries the query like this:

{
   University(func: eq(type, "University")){
   	A as uid
   	~undergraduateDegreeFrom @filter(eq(type,"GraduateStudent")){
   		memberOf @filter(eq(type, "Department")){
   			subOrganizationOf @filter(eq(type, "University") AND uid(A)))){
   				uri
   			}
   			uri
   		}
   		uri
   	}
   }
}

the inner University should be the same as the outer University. But this query got grammatical errors.
3.How to limit the number of the final results?
In Cypher or Gremlin, we can limit the number of the final results, like

MATCH (person:Person)<-[:HAS_CREATOR]-(m:Comment)-[:REPLY_OF*0..3]->(p:Post)-[:HAS_CREATOR]->(c)
WHERE id(person) == 'person_933'
RETURN
  id(m) AS commentId,
  m.content AS messageContent,
  m.creationDate AS messageCreationDate,
  id(p) AS originalPostId,
  id(c) AS originalPostAuthorId,
  c.firstName AS originalPostAuthorFirstName,
  c.lastName AS originalPostAuthorLastName
ORDER BY messageCreationDate DESC
LIMIT 10 

but DQL seems could only limit the number in a certain level, like:

{
  me(func: allofterms(name@en, "Steven Spielberg")) {
    director.film (first: -2) {
      name@en
      initial_release_date
      genre (orderasc: name@en) (first: 3) {
          name@en
      }
    }
  }
}

the number could be calculated as 2*3=6, but if I just want to get 5 results, how could I write the query.
4. For the recurse queries.

MATCH (:Person {id: $personId})<-[:HAS_CREATOR]-(m:Message)-[:REPLY_OF*0..]->(p:Post)

In cypher, we can denote the depth of a predicate, like [:REPLY_OF*0..], but in DQL how to write query like this?

Take a look at this post

This

{
	person(func: uid("0x59179e7")) {
		~hasCreator @filter(has(replyOf)) {
			uid
			content
			imageFile
			creationDate
			replyOf{
				uid
			}
		}
	}
}

You can’t. That should be done at the application level. You could potentially do using Math feature and some variables. But it works for INT only.

I’m not sure about this cypher feature. Is it a Recurse?

I tried to create some pseudo-DQL query. Based on that cypher one you’ve shared.

{
 
  q(func: type(Person)) @filter(eq(id, "person_933")) {
    <~HAS_CREATOR> @filter(type(Comment)) (orderdesc: creationDate) { #don't need this filter
      id : commentId
      content : messageContent
      creationDate : messageCreationDate
      REPLY_OF @filter(type(Post)) {
        id : originalPostId
        HAS_CREATOR {
          id : originalPostAuthorId
          firstName
          lastName
        }
        
      }
    }
    
  }
    
}
{

  
  var(func: type(Person)) @filter(eq(id, "person_933")) {
    <~HAS_CREATOR> @filter(type(Comment)) (orderdesc: creationDate) { #don't need this filter
      id : commentId
      content : messageContent
      creationDate : messageCreationDate
      REPLY_OF @filter(type(Post))  { RP as uid }
    }
  }
      q(func: uid(RP), first: 10) @recurse(depth: 3){
        id : originalPostId
        HAS_CREATOR {
          id : originalPostAuthorId
          firstName
          lastName
        }
      }
}

You have to pay attention that they are both totally different approaches in language and storing methods. You can’t replicate 100% the same behavior on DQL from Cypher.

I don’t understand this concept. In Dgraph we have the depth of hops/traversing nodes.

Thanks for your advisor, I have read the post indetail, but still don’t found the answer for my questions. Could you translate the following two Cypher queries into Dgraph. I would be great;y appreciated if could help me!

MATCH (Y1:University)<-[:undergraduateDegreeFrom]-(X:GraduateStudent)-[:memberOf]->(Z:Department)-[:subOrganizationOf]->(Y2:University)
WHERE Y1 == Y2
RETURN X,Y1,Z
MATCH (:Person {id: $personId})<-[:HAS_CREATOR]-(m:Message)-[:REPLY_OF*0..]->(p:Post)
MATCH (p)-[:HAS_CREATOR]->(c)
RETURN
  m.id AS messageId,
  coalesce(m.content, m.imageFile) AS messageContent,
  m.creationDate AS messageCreationDate,
  p.id AS originalPostId,
  c.id AS originalPostAuthorId,
  c.firstName AS originalPostAuthorFirstName,
  c.lastName AS originalPostAuthorLastName
ORDER BY messageCreationDate DESC
LIMIT 10

Schema:

type University {
  id: ID!
  name: String!
  undergraduateDegrees: [UndergraduateDegree] @hasInverse(field: "undergraduateDegreeFrom")
  departments: [Department] @hasInverse(field: "subOrganizationOf")
}
type UndergraduateDegree {
  id: ID!
  name: String!
  undergraduateDegreeFrom: University
  graduates: [GraduateStudent] @hasInverse(field: "undergraduateDegrees")
}
type GraduateStudent {
  id: ID!
  undergraduateDegrees: [UndergraduateDegree]
  name: String!
  memberOf: [Department] @hasInverse(field: "members")
}
type Department {
  id: ID!
  members: [GraduateStudent]
  subOrganizationOf: [University]
}

Query:

query {
  queryGraduateStudent {
    id
    name
    undergraduateDegrees {
      id
      name
      undergraduateDegreeFrom {
        id
        name
      }
    }
    memberOf {
      id
      name
      subOrganizationOf {
        id
        name
      }
    }
  }
}

Sorry, I don’t understand where denotes “Y1 == Y2” in Cypher query? And I load the data into Dgraph as triples, and the type was tranformed as a property of a node. Can you write the query in DQL? And how the second Cypher query writen into DQL?