delete* returns error after upgrade to v21.12.0
What edition and version of Dgraph are you using?
Edition:
- SlashGraphQL
- Dgraph (community edition/Dgraph Cloud)
If you are using the community edition or enterprise edition of Dgraph, please list the version:
Dgraph Version
$ dgraph version
Dgraph version : v21.12.0
Dgraph codename : zion
Dgraph SHA-256 : 078c75df9fa1057447c8c8afc10ea57cb0a29dfb22f9e61d8c334882b4b4eb37
Commit SHA-1 : d62ed5f15
Commit timestamp : 2021-12-02 21:20:09 +0530
Branch : HEAD
Go version : go1.17.3
jemalloc enabled : true
Have you tried reproducing the issue with the latest release?
Yes
Steps to reproduce the issue (paste the query/schema if possible)
For the following query:
deleteMenuItem(filter: $filter) {
menuItem(filter: $filter) {
name
__typename
}
__typename
}
}
with variable:
"filter": {"id":["0x1a7c"]}
I get the result:
{
"errors": [
{
"message": "couldn't execute query for mutation deleteMenuItem because Dgraph execution failed because Some variables are defined but not used\nDefined:[MenuItemRoot MenuItem_1 MenuItem_4 MenuItem_5 x]\nUsed:[MenuItemRoot MenuItem_1 MenuItem_4 MenuItem_5]\n",
"path": [
"deleteMenuItem"
]
}
],
"data": {
"deleteMenuItem": null
}
}
while in v21.03.01 it worked correctly.
However, the following mutation works correctly:
mutation DeleteMenuItemFixed ($id:[ID!]!) {
deleteMenuItem(filter:{id:$id}) {
numUids msg menuItem {id name}
}
}
with variable:
"id":["0x1a7c"]
Expected behaviour and actual result.
Clearly there is additional variable “x” defined and not used, probably left-over from testing/debugging.
EDIT:
Looking at the source code, it could matter that there are ACL rules defined for this type:
type MenuItem
@auth(
query:{ rule: "{$isAuthenticated:{eq:\"true\"}}" },
update:{
or:[
{rule: "{$role_admin:{eq:\"true\"}}" },
{rule: "{$role_restaurant:{eq:\"true\"}}" },
]
,}
add:{
or:[
{rule: "{$role_admin:{eq:\"true\"}}" },
{rule: "{$role_restaurant:{eq:\"true\"}}" },
]
},
delete:{
or:[
{rule: "{$role_admin:{eq:\"true\"}}" },
{rule: "{$role_restaurant:{eq:\"true\"}}" },
]
}
)
@lambdaOnMutate(add: true, update: true, delete: true)
{
id: ID!
...
}
EDIT2:
Seems to me that MutationQueryVar is defined but not used.