As stated over here link, it query for ‘Alice’ and it results for all the information for ‘Alice’.
What if I have ‘n’ dynamic inputs (size of ‘n’ isn’t fixed) in order to get all information say n=2, ‘Alice’, ‘Bob’
What would be the query? I tried to define variables_1 = {'$b': 'Alice, Bob'} and defining $b: list in query list or array but not working.
I tried with defining list instead of string on the query but not working.
You do not necessarily need to use GraphQL Variables. You are using a Dgraph (py) client. So you can do the “templating” of the query and model you as need. GraphQL Variables are more for those who need to fit into GraphQL (my opinion).
In fact, GraphQL Variables does not expand multiple values in brackets. So what you want to do would not work. However, you could use “anyofterms” instead of “eq”. If indexing is appropriate.
e.g:
{
data(func: anyofterms(name, "Alice Bob")) {
name
rated @facets(r as rating) {
name
}
avg(val(r))
}
}
As I said earlier, it would be interesting to do our tour before. GraphQL Variables are somewhat specific for some uses. You can do several things without GraphQL Variables. https://tour.dgraph.io
Another thing you can do instead of using Graphql Variables. You would model the query according to usage. Queries are just “text”. In JavaScript we do things like “Templating” that exists in several languages. I do not know how it would work in Py, but certainly there are.
Thanks alot @MichelDiz,
it is showing error for anyofterm grpc._channel._Rendezvous: <_Rendezvous of RPC that terminated with (StatusCode.UNKNOWN, : Attribute name is not indexed with type term)>