Skip to content

Add support for __str__ in ExecutionResult #250

Closed
@jnduli

Description

@jnduli

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())

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions