GraphQL result conversion to Dict in Python

In python I’m querying a graphql API and getting a GraphQLResult datatype back.

I want to be able to iterate through the results to then feed back through the API within a mutation.

I thought I could dict(result) and bring back a dictionary but this just brings back a nicely formatted GraphQLResult result as a dict datatype!

result = client.graphql(
{
    'query': {
        'agent': {
            'id'
        }
    }
}
)

dres = (result)

print(dres)

print(dict(dres))

Which brings back this:

{'data': {
"agent": [
    {
        "id": "123"
    }
]
}}

I want to extract that ID and use it but know how/the best way, any ideas?

Read more here: Source link