Open atomboulian opened 6 years ago
Thanks for notifying, could you explain better what this bug consists of? Thank you
Thank you for merging this!
The bug is from the downstream dependency graphql-core, a dependency of graphql-python. The problem is every Enum that has a blank value in the database errors in responses:
"errors": [
{
"message": "Expected a value of type \"RoomAreaUnitsEnum\" but received: ",
"path": [
"room_create",
"rooms",
0,
"area_units"
]
},
{
"message": "Expected a value of type \"RoomAreaUnitsEnum\" but received: ",
"path": [
"room_create",
"rooms",
1,
"area_units"
]
},
{
"message": "Expected a value of type \"RoomAreaUnitsEnum\" but received: ",
"path": [
"room_create",
"rooms",
2,
"area_units"
]
},
{
"message": "Expected a value of type \"RoomAreaUnitsEnum\" but received: ",
"path": [
"room_create",
"rooms",
3,
"area_units"
]
},
{
"message": "Expected a value of type \"RoomAreaUnitsEnum\" but received: ",
"path": [
"room_create",
"rooms",
4,
"area_units"
]
}
],
"data": {
"room_create": {
"rooms": [
{
"id": "513c098c-0935-453d-8ae6-b0abb9283d05",
"area": 200,
"area_units": null,
"departments": [],
"level": {
"id": "dbff6c55-f7d5-467b-9bc5-47c3aa63b9d9",
"name": "Level 1"
},
"name": "Room creation (1)",
"number": "",
"need_by": "2019-01-01",
"signage": ""
},
{
"id": "dfdb4a5e-8c29-4b0e-a7a6-83f2fc5d2b2e",
"area": 200,
"area_units": null,
"departments": [],
"level": {
"id": "dbff6c55-f7d5-467b-9bc5-47c3aa63b9d9",
"name": "Level 1"
},
"name": "Room creation (2)",
"number": "",
"need_by": "2019-01-01",
"signage": ""
},
{
"id": "3f25332a-f160-4671-bbb6-d94e627843b4",
"area": 200,
"area_units": null,
"departments": [],
"level": {
"id": "dbff6c55-f7d5-467b-9bc5-47c3aa63b9d9",
"name": "Level 1"
},
"name": "Room creation (3)",
"number": "",
"need_by": "2019-01-01",
"signage": ""
},
{
"id": "9366e27d-f5f9-4776-9969-b7bd7112af37",
"area": 200,
"area_units": null,
"departments": [],
"level": {
"id": "dbff6c55-f7d5-467b-9bc5-47c3aa63b9d9",
"name": "Level 1"
},
"name": "Room creation (4)",
"number": "",
"need_by": "2019-01-01",
"signage": ""
},
{
"id": "cbebdc1b-2582-4aa7-9f3f-c6e1d9646203",
"area": 200,
"area_units": null,
"departments": [],
"level": {
"id": "dbff6c55-f7d5-467b-9bc5-47c3aa63b9d9",
"name": "Level 1"
},
"name": "Room creation (5)",
"number": "",
"need_by": "2019-01-01",
"signage": ""
}
],
"ok": true,
"errors": null
}
}
}
So for each resource that has a blank area_units, it has an error. We can still get data back but our frontend looks for the errors and displays them for us, and it's noise - before Monday of last week, the blank values were not a problem. With area_units we can create a default, but there are other enums that we want to have as blank values.
So, this pinning the packages did not actually fix the problem as expected. Not sure exactly what to do about it now. I will think on this.
I'm sorry I made a mistake. My branch I did a PR with was my half-done testing branch with examples, not the freeze packages PR I meant to send in.
I am creating another PR with the real changes that need to be made.
Oops!
Will continue the testing branch soon, but in the meantime, I will post a freeze-packages PR soon.
I'm an idiot. 😄
Hello @atomboulian, thanks again for writing, I've been absent a few days, but I plan today or tomorrow to start working on a big new version, which will contain great improvements and new features, as well as the fix of all pending bugs reported, including this one too
Wow! Please keep me posted. If there's anything that I can help with that's small, I would love love love the chance to contribute.
Specifically, we would like to do more with DRF serialization for serializers other than the ModelSerializer (and not require the model in Meta).
Thanks for writing! and thank you for the open dialogue. I would like to continue this.
I'm having the exact same issue and wasn't able to fix it with many provided solutions. This happens with any CharField with choices where graphene generates Enum for them.
However, in this case a blank/empty string will cause this error, but null
values don't.
My solution was to just to set all the blank values in database to NULL
.
To be honest it makes sense for a field that accepts a limited amount of options/choice to either have one of the options or save as NULL
, a blank is also an string, an empty one.
Anyway, such issue I think can be handled in 2 ways:
None
(it can lead to confusion for sure.)
https://github.com/graphql-python/graphql-core/issues/201
Hi, our team is experiencing issues with graphql-core 2.1 - all queries are erroring if they have a blank value in any enums in the data response. In order to stop this side effect for now, and in accordance with good practice of pinning versions until testing new versions, please pin the packages.
I have a PR with this fix here: https://github.com/eamigo86/graphene-django-extras/pull/54 Looks like you have another PR with a similar request here: https://github.com/eamigo86/graphene-django-extras/pull/53
Thanks! The sooner this is fixed the sooner I can help more.