python-3.xgraphqltypeerrorgql

Python gql TypeError: Not an AST Node:


This query works when I am querying the database directly but when I use python gql, I keep getting this error. I can not find how to stop getting that error anywhere.

query = f"""query{{
   addresses(line1: "{street}", city: "{city}", zip: "{zip}", subdivision: {state}){{
     entities{{
       id
     }}
   }}
 }}"""

GraphQL = sonar.execute(query=query, variable_values=None)

Output: TypeError: Not an AST Node: 'query{\n  addresses(line1:............

Solution

  • I didn't wrap the query in gql() the above should look like:

    gql(
    """query{{
       addresses(line1: "{street}", city: "{city}", zip: "{zip}", subdivision: {state}){{
         entities{{
           id
         }}
       }}
     }}""".format(...)
    )