-
Notifications
You must be signed in to change notification settings - Fork 768
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Updated deprecated variable name from format_error to GraphQLFormattedError #1320
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tested the change on my side and it is working on my updated project
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi tested again the your commit in my project and it is not OK. i get an error on the change you made.
'GraphQLError' object is not iterable
.
.
.
graphene_django/views.py", line 389, in format_error
return format_graphql_error(error)
File "/usr/lib/python3.8/typing.py", line 1709, in _dict_new
return dict(*args, **kwargs)
Exception Type: TypeError at /openapiql
Exception Value: 'GraphQLError' object is not iterable
look at the following code in the python graphql package to take into consideration
python3.8/site-packages/graphql/error/graphql_error.py
def format_error(error: GraphQLError) -> GraphQLFormattedError:
"""Format a GraphQL error.
Given a GraphQLError, format it according to the rules described by the "Response
Format, Errors" section of the GraphQL Specification.
.. deprecated:: 3.2
Please use ``error.formatted`` instead. Will be removed in v3.3.
"""
if not isinstance(error, GraphQLError):
raise TypeError("Expected a GraphQLError.")
return error.formatted
so GraphQLError
instances which are to be formatted should be error.formatted
Can you review your changes? Thanks
It might make sense to restrict the graphql-core dependency to the minor version as they have mentioned that the minor versions are not compatible with another.
|
I honestly don't understand why they removed it from the init because the from graphql.error import format_error as format_graphql_error to from graphql.error.graphql_error import format_error as format_graphql_error |
Fixed in #1327 |
While using
graphene-django
, I ran into the followingImportError
:ImportError: cannot import name 'format_error' from 'graphql.error'
Looking into
graphql.error
, here is an excerpt ofgraphql-core
's/error/__init__.py
file:I believe
graphene_django/views.py
'sformat_error
variable name is most likely deprecated, so locally, I replacedformat_error
withGraphQLFormattedError
from the excerpt above, and it is now working locally.Here is
graphql-core
's commit that deprecated theformat_error
variable name