Bugs or missuse - Attaching new node from previous query var uid

I have this schema:

mutation {
  schema {
    graph: string @index(exact,term) .
    dummy_param: string @index(exact,term) .
    edge: uid @count .
    name: string @index(exact,term) .
  }
}

Then I create a root node:

mutation {
  set {
    _:root <graph> "graph1" .
    _:root <entry_point> "graph1" .
    _:root <name> "root" .
  }
}

Then I try to add a node to the root node by running:

{
  root as var(func:eq(name, "root"))@filter(eq(graph, "graph1")) {}
}
mutation {
   set {
    uid(root) <edge> _:node .
    _:node <name> "node1" .
    _:node <graph> "graph1" .
  }
}

But if I query like this:

{
  recurse(func:eq(name, "root")){
    name
    graph
    edge
  }
}

I get what I put as “first” in the attached image.
Shouldn’t the result be more like what I put as “second” in the attached image?

I think the first mutation in the example above should be should be

_:root <graph> "graph1" .

Irrespective of that, this is a bug with the recurse feature.

Thank you Pawan.

Yes, I had a mistake in “graph_name” it is “graph” :slight_smile: . Despite of that the bug remains.
But to be honest it doesn’t seems to be a “recurse error”, the thing is that I found a work around by repeating the first func filter in the “@filter” section. So, if I add a node like this:

{
  root as var(func:eq(name, "root"))@filter(eq(graph,"graph1") and eq(name,"root"))
}

mutation{
  set{
    uid(root) <link> _:node .
    _:node <name> "node1" .
    _:node <graph> "graph1" .
  }
}

The extra loop in the new node goes away and also any other extra link that used to appear using the past query (it used to return all the nodes in “graph1” instead of returning only the one with the “root” name, like if it was ignoring the first “func filter”).

You are right, it’s not a bug with recurse and you are right again about filter overriding the root function. There is a issue for this Filter may override root query in v0.8.1 · Issue #1455 · dgraph-io/dgraph · GitHub a fix for which will be merged today and will be part of the next release.

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