Parameterized cascade fail on 20.11.1

When issuing the following query on 20.11.1:

{
  q(func:type(Tenant)) @cascade(fields:["app.cn"]) {
    ~app.tnnt @filter(eq(app.cn, "appName")) {
    	app.cn
  	}
  }
}

I get:

{
  "errors": [
    {
      "message": "line 2 column 38: Unexpected item while parsing: :",
      "extensions": {
        "code": "ErrorInvalidRequest"
      }
    }
  ],
  "data": null
}

It work as expected without the parameterized part (just @cascade)
Running docker dgraph/dgraph:v20.11.1

Hi @mbn18,

Thanks for reporting this, let me try it out and see

Best,

Hey @mbn18

You are using a GraphQL syntax in DQL, therefore you have a syntax error.

The correct query should look like this:

{
  q(func:type(Tenant)) @cascade(app.cn) {
    ~app.tnnt @filter(eq(app.cn, "appName")) {
    	app.cn
  	}
  }
}

In DQL @cascade is queried like this: @cascade(pred1, pred2, ...)

Give it a try and let us know,

Best,

Thank Omar, it works.

Please note that the DQL section in the docs missing this version.

Please compare the GraphQL section to the DQL one

Best

Thanks Miki, will address this

Best,

1 Like

Hi Omar,

Seems like this is not working. the @cascade(predicate) does not raise error but also does not effect the query by filtering out data if the predicate is missing.

Tested with both 20.11.2 and 20.11.1

Sample query:

{
  q(func:type(App)) @cascade(tnnt.cn) {
    app.cn
    app.tnnt @filter(eq(tnnt.cn, "xyz")) {
      tnnt.cn
    }
  }
}

This works:

{
  q(func:type(App)) @cascade {
    app.cn
    app.tnnt @filter(eq(tnnt.cn, "xyz")) {
      tnnt.cn
    }
  }
}

Hi @mbn18,

The parameterized cascade works on levels (e.g. on the root function or on lower levels). You need to specify @cascade(param) on the exact level you want it to be applied.

What if you try changing your query to the following one?

{
  q(func:type(App))  {
    app.cn
    app.tnnt @cascade(tnnt.cn) @filter(eq(tnnt.cn, "xyz")) {
      tnnt.cn
    }
  }
}

For further information about parametrized cascade, you can have a look at this post here

Best,

Sorry @omar,

It didn’t worked.

Nor in our more complex query when tried on the root level, 2nd level and etc. Tried @cascade(meas.id) on all levels.

Notice that in this query only one of tagv.txt / tagv.int / tagv.float exist. so general cascade will eliminate all records.
And I need to eliminate all app.tags that are not connected to meas.id at the end.

app(func:uid(app_res_uid)) {
  id: app.id
  cn: app.cn
  tags: app.tags {
    cn: tag.cn
    val: ~tagv.tag {
      s: tagv.txt
      i: tagv.int
      f: tagv.float
      ~measureTags  @filter(uid(m_res_uid)) {
        meas.id
      }
    }
  }
}

``