Need Assistance with Dgraph Query Filtering Issue

What I want to do

I want to execute a Dgraph query to fetch data from a specific block (let’s call it “l”) while applying filters, and then further filter the results from this “l” block and return only the data that matches the secondary filter conditions. I want to ensure that the data block of the query contains only data from the “l” block.

What I did

query:

query Instances($page: int, $offset: int, $state: string) {
l(func: type(“DataInstance”), first: $page, offset: $offset) @filter(regexp(state, /^saved/)) @cascade {
v as uid
instancetable @filter(regexp(name, /(.2.)/i)) {
name
}
state
}
data(func: uid(v)) @recurse(loop: false) {
uid
instancetable
name
state
}
}

result:

“data”: {
“l”: [
{
“uid”: “0x42158e”,
“instancetable”: {
“name”: “234”
},
“state”: “saved_table_deployed”
}
],
“data”: [
{
“uid”: “0x42158e”,
“instancetable”: {
“uid”: “0x42157c”,
“name”: “234”,
“state”: “”
},
“state”: “saved_table_deployed”
},
{
“uid”: “0x4261cd”,
“instancetable”: {
“uid”: “0x3cdc65”,
“name”: “WaterproofingAndDrainageAccessory”,
“state”: “”
},
“state”: “saved_table_deployed”
},
{
“uid”: “0x4261d2”,
“instancetable”: {
“uid”: “0x3cdd8f”,
“name”: “WingWall”,
“state”: “”
},
“state”: “saved_table_deployed”
}
]
}

Dgraph metadata

dgraph version

v20.07.2

could you change that to

v as var(func: type(“DataInstance”), first: $page, offset: $offset) @filter(regexp(state, /^saved/)) @cascade {
--- delete the line v as uid

and let me know. It is the correct way to build the variable based on your “I” query.

Thank you very much for your response, it resolved my issue.

However, I tried the query method I described on “https://dgraph.io/docs/query-language/query-variables/,
and it seems to give me the expected results. Can you tell me the difference between the two,

v as var(func:…)

and

var(func:…){ v as uid }

?
thank you