Have you tried reproducing the issue with the latest release?
yes on dgraph dgraph v21.12.0 , and on dgraph cloud.
Steps to reproduce the issue
Schema
type Delta @auth(
query: {rule: """query ($NAMES: [String]) {
queryDelta(filter: {mode: {eq: Public}, or:{name: {in: $NAMES}}}) { id }
}""" }
){
id: ID!
name: String! @search(by: [hash])
mode: DeltaMode! @search
}
enum DeltaMode {
Public
Private
}
# Dgraph.Authorization {"VerificationKey":"powned","Header":"X-My-App-Auth","Namespace":"yolo","Algo":"HS256"}
Add an object
mutation {
addDelta(input: {name: "hey", mode: Public})
}
set the following token and try to query the data
{ "yolo":"{\"NAMES\": [] }"}
token: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ5b2xvIjoie1wiTkFNRVNcIjogW10gfSJ9.Z0ZfzcQoKaJ1nyWc4lUgYs-Ftsv-PPEDfGBlBsv5GaA
try agin with the following token:
{ "yolo":"{}"}
token: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ5b2xvIjoie30ifQ.IPV1jlul6mkpf29bCj_ZJEkSZUhNEBhmu_Ggybn-bCU
Expected behaviour and actual result.
With the first case (empty list), dgraph returns no data but the following error
"errors": [
{
"message": "Dgraph query failed because Dgraph execution failed because : eq expects atleast 1 argument.",
"path": [
"queryDelta"
]
}
]
And the second case (empty claims), dgraph returns no data and no errors.
In both cases, as the variable Names is given as not mandatory, I believe it should return the object as it satisfies the first condition of the @auth rule.
Current workaround
Set the list with an empty string [""]
in case where the claims is empty in the Business Logic Layer.