Filtering after expand()

Hi, it is related to graph database Dgraph. It probably should not be in the GraphQL category, sorry about that. How can I remove this tag?

Here is an example of what I am trying to do (don’t think too much about the logic of my example, I had to change some details in order to be able to post my problem publicly).

Consider these types:

type Person {
  person.job
  ...
  person.collaborated
}

type Company {
  company.someatr
  ...
  company.produced
  <~person.collaborated>
}

type Food {
  ...
  <~company.produced>
}

type Clothes {
  ...
  <~company.produced>
}

(Plus some other types produced by Company and other edges were omitted.)

So the relationships can be drawn like this:

(Person node) --person.collaborated edge--> (Company node) --company.produced edge--> (Food node)
                                       --company.produced edge--> (Clothes node)
                                       ...

Now what my problem is: I sometimes want to be able to do queries like the one below - and use the functionality of Types and @recurse at the same time.

{
  getProducts(func: eq(person.job, "Something")) @recurse(depth: 3, loop: true) {
    expand(_all_) (first:10)
  }
}

But what happens - e.g. the company.produced edge leads to way too many nodes and I need to be able to filter on them based on specific values of their attributes.

If the edge wasn’t part of my Type definition, I am able to do at least this:

{
  getProducts(func: eq(person.job, "Something")) @recurse(depth: 3, loop: true) {
    expand(_all_) 
    person.collaborated @filter(ge(company.someatr, 5)) 
  }
}

But I can’t use this technique on the products of a Company, because “recurse queries require that all predicates are specified in one level”. And also I need these edges in my Type definitions because they are used in other queries…

If edges are part of the Type definition and I try to use a filter like this directly, I get the “expand is only compatible with type filters” error:

{
  getProducts(func: eq(person.job, "Something")) @recurse(depth: 3, loop: true) {
    expand(_all_) @filter(ge(company.someatr, 5)) 
  }
}

Or am I missing something and a query like this can be easily written using variables? So far I was not successful. Thank you very much for your time and help in advance!