How to find nodes given an array of values

Hi Michel,

I’m trying to do a similar thing using the Python client pydgraph that you demonstrated in a previous JS code snippet but running into an unexpected result/error.

Your JS snippet:

const many_emails = [e1@domain1.com, e2@domain2.com, ..., eN@domainN.com]

const query = `
    {
  me(func: eq(predicate, ${many_ emails})) {
    name@en
    genre {
    	name@en
    }
  }
}

What I’m trying using pydgraph:

    query = """query all($a: string) {
                all(func: eq(samplePred, $a)) {
                        uid
                    }
                }
            """

    variables = {'$a': '["val1", "val2"]'}

    res = client.txn(read_only=True).query(query, variables=variables)

When the query is executed, the following exception is thrown:

'Traceback (most recent call last):\n  File "../.vscode/extensions/ms-python.python-2020.11.371526539/pythonFiles/lib/python/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_resolver.py", line 193, in _get_py_dictionary\n    attr = getattr(var, name)\nAttributeError: Extensions\n'

Am I doing something wrong? I have success writing the same exact query without the use of variables (also tested using ratel UI) but that doesn’t satisfy my use case where the values I’m passing to the eq function are dynamic and passed in as an argument to a function.

Working without the use of a graphql variable

    query = """query all() {
                all(func: eq(samplePred, ["val1", "val2"])) {
                        uid
                    }
                }
            """
    res = client.txn(read_only=True).query(query)

Using v20.7.0 of pydgraph