question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ExecutionResult.formatted does not format errors

See original GitHub issue

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

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
Citocommented, Apr 28, 2021

Don’t worry. The execution results and errors are not automatically formatted. We’re only talking about the case when you access the formatted property of these objects. With other words, if you access the errors of the execution result, they will be still a list of GraphQLErrors, if you access the errors of the formatted execution result, they will be a list of formatted GraphQLErrors.

0reactions
AlecRosenbaumcommented, Apr 28, 2021

Right, sorry let me rephrase.

If GraphQLError’s are automatically formatted when being put into the result, is there any way of accessing traceback data? I had thought the accepted way was by looking at original_error.__traceback__, which would no longer be possible if this was changed.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Log error if YAPF formatting fails · Issue #12362 - GitHub
I have YAPF installed and setup to format my python files in-place on save. However, sometimes it appears to run but it doesn't...
Read more >
Error — GraphQL-core 3 3.3.0a2 documentation
The graphql.error package is responsible for creating and formatting GraphQL errors. ... A GraphQLError describes an Error found during the parse, validate, or ......
Read more >
Handling Errors - graphql-php
When the result is converted to a serializable array using its toArray() method, all errors are converted to arrays as well using default...
Read more >
Getting "Extension 'Python Language Basics' cannot format ~'/'"
When I try to use the Format Document command, I get an error that says "Python auto formatting: Extension 'Python Language Basics' cannot ......
Read more >
Data format error: We couldn't convert to Number. Details
The query that uses this Excel file loads fine, no errors. It's a different query, where I join that table with another one,...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found