# Parameterized cascade fail on 20.11.1

**URL:** <https://discuss.dgraph.io/t/parameterized-cascade-fail-on-20-11-1/12754>\
**Category:** Dgraph\
**Tags:** dql\
**Created:** [February 12, 2021, 11:09am UTC](https://discuss.dgraph.io/t/parameterized-cascade-fail-on-20-11-1/12754 "2021-02-12T11:09:53Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![mbn18](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/mbn18/32/1139_2.png) [@mbn18](https://discuss.dgraph.io/u/mbn18)\
**Post date:** [February 12, 2021, 11:09am UTC](https://discuss.dgraph.io/t/parameterized-cascade-fail-on-20-11-1/12754/1 "2021-02-12T11:09:53Z")

</div>

When issuing the following query on `20.11.1`:

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

```

I get:

```auto
{
  "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`

---

<div class="post-metadata">

**Author:** ![omar](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/omar/32/2869_2.png) [@omar](https://discuss.dgraph.io/u/omar)\
**Post date:** [February 12, 2021, 11:45am UTC](https://discuss.dgraph.io/t/parameterized-cascade-fail-on-20-11-1/12754/2 "2021-02-12T11:45:00Z")

</div>

Hi @mbn18,

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

Best,

---

<div class="post-metadata">

**Author:** ![omar](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/omar/32/2869_2.png) [@omar](https://discuss.dgraph.io/u/omar)\
**Post date:** [February 12, 2021, 11:58am UTC](https://discuss.dgraph.io/t/parameterized-cascade-fail-on-20-11-1/12754/3 "2021-02-12T11:58:51Z")

</div>

Hey @mbn18

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

The correct query should look like this:

```auto
{
  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,

---

<div class="post-metadata">

**Author:** ![mbn18](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/mbn18/32/1139_2.png) [@mbn18](https://discuss.dgraph.io/u/mbn18)\
**Post date:** [February 15, 2021, 11:59am UTC](https://discuss.dgraph.io/t/parameterized-cascade-fail-on-20-11-1/12754/4 "2021-02-15T11:59:59Z")

</div>

Thank Omar, it works.

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

Please compare the [GraphQL section](https://dgraph.io/docs/graphql/queries/cascade/#parameterized-cascade) to the [DQL one](https://dgraph.io/docs/query-language/cascade-directive/)

Best

---

<div class="post-metadata">

**Author:** ![omar](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/omar/32/2869_2.png) [@omar](https://discuss.dgraph.io/u/omar)\
**Post date:** [February 15, 2021, 2:05pm UTC](https://discuss.dgraph.io/t/parameterized-cascade-fail-on-20-11-1/12754/5 "2021-02-15T14:05:57Z")

</div>

Thanks Miki, will address this

Best,

---

<div class="post-metadata">

**Author:** ![mbn18](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/mbn18/32/1139_2.png) [@mbn18](https://discuss.dgraph.io/u/mbn18)\
**Post date:** [February 24, 2021, 7:26am UTC](https://discuss.dgraph.io/t/parameterized-cascade-fail-on-20-11-1/12754/6 "2021-02-24T07:26:41Z")

</div>

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:

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

```

This works:

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

```

---

<div class="post-metadata">

**Author:** ![omar](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/omar/32/2869_2.png) [@omar](https://discuss.dgraph.io/u/omar)\
**Post date:** [February 24, 2021, 12:51pm UTC](https://discuss.dgraph.io/t/parameterized-cascade-fail-on-20-11-1/12754/7 "2021-02-24T12:51:53Z")

</div>

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?

```auto
{
  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](http://discuss.hypermode.com/t/parameterized-cascade/7472)

Best,

---

<div class="post-metadata">

**Author:** ![mbn18](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/mbn18/32/1139_2.png) [@mbn18](https://discuss.dgraph.io/u/mbn18)\
**Post date:** [February 24, 2021, 3:01pm UTC](https://discuss.dgraph.io/t/parameterized-cascade-fail-on-20-11-1/12754/8 "2021-02-24T15:01:04Z")

</div>

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.

```auto
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
      }
    }
  }
}

``
```

---

<div class="post-metadata">

**Author:** ![abhimanyusinghgaur](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/abhimanyusinghgaur/32/2980_2.png) [@abhimanyusinghgaur](https://discuss.dgraph.io/u/abhimanyusinghgaur)\
**Post date:** [February 25, 2021, 8:14am UTC](https://discuss.dgraph.io/t/parameterized-cascade-fail-on-20-11-1/12754/9 "2021-02-25T08:14:19Z")

</div>

> [@mbn18](#):
>
> ```auto
> {
> q(func:type(App)) @cascade(tnnt.cn) {
> app.cn
> app.tnnt @filter(eq(tnnt.cn, "xyz")) {
> tnnt.cn
> }
> }
> }
> 
> ```

I think, what you are trying to achieve with this is: `Remove all Apps which are not connected to tnnt.cn`. And if you apply `@cascade` for `tnnt.cn` at root level, it won’t have any effect as `tnnt.cn` isn’t a root level predicate.  
So, maybe you are looking for this:

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

```

i.e., remove all the `app.tnnt` which don’t have a `tnnt.cn` and then also remove all `App` which don’t have an `app.tnnt`

---

<div class="post-metadata">

**Author:** ![mbn18](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/mbn18/32/1139_2.png) [@mbn18](https://discuss.dgraph.io/u/mbn18)\
**Post date:** [February 25, 2021, 11:11am UTC](https://discuss.dgraph.io/t/parameterized-cascade-fail-on-20-11-1/12754/10 "2021-02-25T11:11:53Z")

</div>

Thanks @abhimanyusinghgaur , this is what I missed.

Hope the `cascade` docs will be updated soon.  
Best

---

<div class="post-metadata">

**Author:** ![abhimanyusinghgaur](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/abhimanyusinghgaur/32/2980_2.png) [@abhimanyusinghgaur](https://discuss.dgraph.io/u/abhimanyusinghgaur)\
**Post date:** [February 25, 2021, 11:15am UTC](https://discuss.dgraph.io/t/parameterized-cascade-fail-on-20-11-1/12754/11 "2021-02-25T11:15:47Z")

</div>

[@docs](https://discuss.dgraph.io/groups/docs) could someone please update the docs to clarify the finer details discussed in this thread?

Thanks

---

<div class="post-metadata">

**Author:** ![acarey](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/acarey/32/7089_2.png) [@acarey](https://discuss.dgraph.io/u/acarey)\
**Post date:** [February 25, 2021, 12:32pm UTC](https://discuss.dgraph.io/t/parameterized-cascade-fail-on-20-11-1/12754/12 "2021-02-25T12:32:36Z")

</div>

We’ll follow-up, thanks! I filed a ticket for this.

It looks like what we are looking for is:

- DQL content that mirrors parameterized @cascade coverage of GraphQL present here: [https://dgraph.io/docs/graphql/queries/cascade/#parameterized-cascade](https://dgraph.io/docs/graphql/queries/cascade/#parameterized-cascade)
- Clarify what happens when a parameter is a predicate, but not a root-level predicate

---

<div class="post-metadata">

**Author:** ![damian](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/damian/32/4911_2.png) [@damian](https://discuss.dgraph.io/u/damian)\
**Post date:** [June 2, 2021, 1:33pm UTC](https://discuss.dgraph.io/t/parameterized-cascade-fail-on-20-11-1/12754/14 "2021-06-02T13:33:10Z")

</div>

We have updated our `@cascade` DQL docs:  
[https://dgraph.io/docs/query-language/cascade-directive/](https://dgraph.io/docs/query-language/cascade-directive/)
