Cannot query by multiple IDs on GraphQL

I have an array of ids and I want to know if they are already stored on Dgraph. I’m using the following query:

query {
  queryAuthor(filter: {id: ["id1", "id2", "id3"] }) {
    id
    name
  }
}

Error:

{
  "errors": [
    {
      "message": "Expected type StringHashFilter, found [\"id1\",\"id2\",\"id3\"].",
      "locations": [
        {
          "line": 80,
          "column": 28
        }
      ]
    }
  ]
}

I went through this path because of the example in this page: https://dgraph.io/docs/graphql/queries/search-filtering/#query-list-of-objects. But I got the error above when running the query.

Currently in 20.07 this list filter is only supported when the predicate is of the type ID. I believe you are using String! @id for your type though.

Good news is that this is being supported with more filter functions in the upcoming 20.11.

Ref: Proposal: more filter functions

1 Like