Query a list of objects using DQL is not possible

Query a list of objects using DQL is not possible.
The in function that supports multiple value filtering that is documented here:
https://dgraph.io/docs/graphql/queries/search-filtering/
is not available with DQL queries.
either in func term or @filter term it would be nice to have IN function to filter out multiple values at once.
The only workaround I have found is to combine multiple eq() functions with OR operator.

{
  profile(func: in(name,["a","b","c"]))
  {
       uid
       name
  }  
}

Hi Ahmed,

Hum, I don’t have a clue why we have that function ‘in’ in GraphQL - I feel that the inequality should do the job pretty fine without a new function. I’m not 100% aware of GraphQL features. But I can help you with DQL, which I have some experience with.

Follow me on this syntax https://dgraph.io/docs/query-language/functions/#equal-to
The syntax eq(predicate, [val1, val2, ..., valN]) says you can input several values as a param of the function for that X predicate. You can simply use values there instead of variables. e.g: eq(predicate, ["a","b","c"]). Since the last time I have used that feature, it was working fine. Can you check if it works for you?

Try this query at http://play.dgraph.io/ (you can play around with other names)

{
  me(func:eq(name@en, ["James", "Jobs"]) ) {
    name@en
    genre {
      name@en
    }
  }
}

Cheers.

1 Like

Great! This absolutely works. Thank you for really quick answer. I missed that function definition.