Description
This seems to be a regression in the upgrade of graphql-core to 2.1 together withj graphene-django to 2.1.0.
Prior to the upgrade, I could create an optional choice field in Django, and could query the value if the value of the choice field was blank.
For example, assume that I have a Django model MyModel
with an optional choice field my_choices_field
, and a query handler that would accept a query like
{
myModel(id: 1) {
id
myChoicesField
}
}
With the updated versions, if the value of my_choices_field
is blank, this query throws a handled exception like:
Traceback (most recent call last):
File "/usr/local/lib/python3.7/site-packages/promise/promise.py", line 65, in try_catch
return (handler(*args, **kwargs), None)
File "/usr/local/lib/python3.7/site-packages/graphql/execution/executor.py", line 527, in <lambda>
exe_context, return_type, field_asts, info, path, resolved
File "/usr/local/lib/python3.7/site-packages/graphql/execution/executor.py", line 556, in complete_value
return complete_leaf_value(return_type, path, result)
File "/usr/local/lib/python3.7/site-packages/graphql/execution/executor.py", line 622, in complete_leaf_value
path=path,
graphql.error.base.GraphQLError: Expected a value of type "MyModelMyChoicesField" but received:
And the output of the query includes errors when the value of the field is blank:
{
"errors": [
{
"message": "Expected a value of type \"MyModelMyChoicesField\" but received: ",
"path": [
"myModel",
"myChoicesField"
]
}
],
"data": {
"myModel": {
"id": "1",
"myChoicesField": null
}
}
}
I imagine the issue is related to the work in graphql-core to related to enum fields
Improved GraphQLEnumType serialization allowing python Enum values 0cef6fb 24687b6