# Order query

**URL:** <https://discuss.dgraph.io/t/order-query/13511>\
**Category:** Dgraph\
**Tags:** kind:question\
**Created:** [April 1, 2021, 7:12am UTC](https://discuss.dgraph.io/t/order-query/13511 "2021-04-01T07:12:42Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![hianand](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/hianand/32/7464_2.png) [@hianand](https://discuss.dgraph.io/u/hianand)\
**Post date:** [April 1, 2021, 7:12am UTC](https://discuss.dgraph.io/t/order-query/13511/1 "2021-04-01T07:12:42Z")

</div>

Hi,  
we are working on poc using dgraph.

i have following requirement to build graph layout.

we have two types of nodes OrderNode & Batch Node

```auto
type <OrderNode> {
	DocumentNo
	DocumentType
	ProductionOrder
	PurchaseOrder
	Vendor
	child
}

type <BatchNode> {
	Plant
	Material
	Batch
	DocumentType
	child
}
<child>: [uid] @reverse .

```

child is of type uid and is list with index, reverse as well.  
I have build parent and child relationship  
`OrderNode` is generally parent for Mutliple `Batch` Nodes  
` BatchNode` can be parent of Multiple Batch Nodes so on.

I want to be able to search either by Batch or orderNo,

I should be able to list child and parents.

My first use case is to list childs to detail  
I tried to query and want to list a graph in recursive manner

OrderNode → Child → BatchNode2–\> Batch Node 2

for eg) when I search with this query recursively , I don’t get lower childs (child batches of batches are not coming up)

i get only one level though depth is stated as 3

```auto
{
  var(func: eq(DocumentNo, "1800002473")) @recurse(depth:3 , loop:true) @normalize {
    u as uid
    Plant
    Material
    DocumentType
  }
  
  
  
  childs(func: uid(u)) {
    
    expand(_all_) { 
      Batch
      Material
      Plant
      
    
    }
    
    
  }
  
 
  

}

```

I have the same problem when querying batches instead of orders.

---

<div class="post-metadata">

**Author:** ![chewxy](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/chewxy/32/4339_2.png) [@chewxy](https://discuss.dgraph.io/u/chewxy)\
**Post date:** [April 1, 2021, 9:49pm UTC](https://discuss.dgraph.io/t/order-query/13511/2 "2021-04-01T21:49:25Z")

</div>

I have split this topic from a previous topic. I will answer the question shortly.

---

<div class="post-metadata">

**Author:** ![chewxy](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/chewxy/32/4339_2.png) [@chewxy](https://discuss.dgraph.io/u/chewxy)\
**Post date:** [April 1, 2021, 11:09pm UTC](https://discuss.dgraph.io/t/order-query/13511/3 "2021-04-01T23:09:14Z")

</div>

Does something like this work @hianand

```auto
{
  q(func: eq(DocumentNo, "1234") )@recurse {
    uid
    child{}
  }
}

```

---

<div class="post-metadata">

**Author:** ![hianand](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/hianand/32/7464_2.png) [@hianand](https://discuss.dgraph.io/u/hianand)\
**Post date:** [April 2, 2021, 11:35am UTC](https://discuss.dgraph.io/t/order-query/13511/4 "2021-04-02T11:35:09Z")

</div>

thanks that works, however, when i list the predicates inside the child node  
I get this error

{  
q(func: eq(DocumentNo, “1000450071”) )@recurse {  
uid  
DocumentType  
Material  
Plant  
Batch  
DocumentNo  
Quantity

```
  child {
  
  u as uid 

}

```

}

c(func: uid(u)){ Plant}  
}

or  
{  
q(func: eq(DocumentNo, “1000450071”) )@recurse {  
uid  
DocumentType  
Material  
Plant  
Batch  
DocumentNo  
Quantity

```
  child {
  
  Plant
  DocumentType

}

```

}

}

“recurse queries require that all predicates are specified in one level”
