graphql-python / graphql-core-legacy

GraphQL base implementation for Python (legacy version – see graphql-core for the current one)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add support for __str__ in ExecutionResult

jnduli opened this issue · comments

I was writing tests for graphene-django, when one of my tests failed. I could not easily figure out why, but printing the result of the query returned:

<graphql.execution.base.ExecutionResult object at 0x7f460c744c60> 

which I think is not really helpful. The only way to figure out what was happening was to find out how the ExecutionResult object was coded, and call the to_dict function, which resulted in:

OrderedDict([('errors', [{'message': 'Schema is not configured for mutations', 'locations': [{'line': 2, 'column': 17}]}]), ('data', None)])

which is significantly better.

Suggestion

Could the str function be implemented to call this to_dict method or do something similar, for example:

def __str__(self):
    return str(self.to_dict())