Skip to content

ExecutionResult.formatted does not format errors #129

Closed
@mlorenzana

Description

@mlorenzana

When I call formatted on an ExecutionResult, the errors portion of the dict is not formatted and instead returns a list of GraphQLErrors. GraphQLError is not serializable, but it does have a formatted property which is, why is formatted not called on the list of GraphQLErrors?

As a work around, I have to call formatted on my ExecutionResult and then rebuild the dict and format the errors:

    formatted = result.formatted

    data = formatted.get('data')
    errors = ([err.formatted for err in formatted.get('errors')] 
              if formatted.get('errors') is not None 
              else None)
    extensions = formatted.get('extensions')

    if extensions:
        body = dict(data=data, errors=errors, extensions=extensions)
    else:
        body = dict(data=data, errors=errors)

Ideally ExecutionResult.formatted would perform this error formatting for me.

Environment:
python 3.8
graphql-core 3.1.4

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions