Giter Site home page Giter Site logo

Comments (8)

atomboulian avatar atomboulian commented on August 13, 2024 1

I'm an idiot. 😄

from graphene-django-extras.

eamigo86 avatar eamigo86 commented on August 13, 2024

Thanks for notifying, could you explain better what this bug consists of? Thank you

from graphene-django-extras.

atomboulian avatar atomboulian commented on August 13, 2024

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.

from graphene-django-extras.

atomboulian avatar atomboulian commented on August 13, 2024

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.

from graphene-django-extras.

atomboulian avatar atomboulian commented on August 13, 2024

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.

from graphene-django-extras.

eamigo86 avatar eamigo86 commented on August 13, 2024

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

from graphene-django-extras.

atomboulian avatar atomboulian commented on August 13, 2024

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.

from graphene-django-extras.

Alir3z4 avatar Alir3z4 commented on August 13, 2024

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:

  • If a a choice field has blank field, just return None (it can lead to confusion for sure.)
  • silent graphene when seeing a Field.blank=True while being a choice-field/enum. (much better route to solve the issue.)

from graphene-django-extras.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.