Is it possible to filter recurse query paths?

The recurse query as well as the shortest path query return graphs of nodes and edges. Is it possible to filter the traversed paths before returning?
For example, when executing a recurse query is it possible to only return paths which have a certain leaf node?
I am aware that I can assign variables to predicates which are part of a recurse query and filter them after the fact. What I want is to operate on the graph or paths returned by a recurse query.

You can create a var block and filter the results coming via a variable.

In the recurse query itself, you can add filters. But you can do it in steps using the var block.

Not sure precisely what you want. But the only way to do such thing is via variables and multiple blocks. Dgraph can’t work on results, just create them - if it was that what you mean.

How does that work? I am aware that I can filter the results of a recurse query and add some additional information like in the following:

var(func: uid(some_uid)) @recurse{
		p1 as predicate1@filter(eq(predicate3, "some_text"))
		predicate2
	}

filter(func: uid(p1)) {
       predicate4
}

But how can I filter the paths? To be clear, I want to filter the resulting graph of the recurse query by some criteria and have as a result a sub graph or an amount of paths.

This is the filtering.

p1 as predicate1@filter(eq(predicate3, "some_text"))

You are applying a rule recursively beforehand.

It is not clear to me what you want. But Dgraph doesn’t work with results. It doesn’t store the result in the memory to do some sanitation or operation by the user(you). That you have to do on the client’s end.

If maybe I’m missing something from your explanation. Please, make an example. Use JSON and flows.

e.g:

  1. This is what I get.
  2. This is what I want.