Graphql enum search error

Dgraph Version: v20.07.1

I had a problem when I try to search enum. I follow the graphql doc to learn graphql, and I make a schema like this:

enum Tag {
    GraphQL
    Database
    Question
}

type Review {
    id: ID!
    tags: [Tag!]! @search
}

Than I run a mutation:

mutation{
   addReview(input:[{tags:[Question]}]) {
        review {
            tags
        }
    }
}

The query:

query {
    queryReview(filter: { tags: { eq: Question } } ) { 
        tags 
     }
}

But I get error bellow:

{
    "errors": [
        {
            "message": "Value provided Question is incompatible with expected type [Tag!]!",
            "locations": [
                {
                    "line": 2,
                    "column": 39
                }
            ]
        }
    ]
}

Then I try:

query {
    queryReview(filter: { tags: { eq: [Question] } } ) { 
        tags 
    }
}

I got the right result!

But the doc tells me to query like this:

query {
    queryPost(filter: { tags: { eq: GraphQL } } ) { ... }
}

Is the doc wrong?

Thanks for reporting this issue.

There was a bug with how filters were generated for a list of enums.
This has been fixed in master branch few days back by @minhaj over here, fix(GraphQL): handle filters for enum properly by minhaj-shakeel · Pull Request #6887 · dgraph-io/dgraph · GitHub and will be part of 20.11 .

1 Like