graphql-python / graphql-python/graphene

Null Boolean Scalar

Offen
#1,353 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
✨ enhancement
Vorherrschende Sprache
Python
Sterne
8.2k
Forks
818
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beschreibung

Im always frustrated when my model has a null able boolean field and the method `from graphene_django.types import construct_fields` returns a Boolean Scalar field which can only be True or False but not None

Some fields should not have a default for this types of boolean fields.

perhaps a scalar like this?

class NullBoolean(Scalar):
'''NullBoolean Scalar Description'''

@staticmethod
def serialize(dt):
return dt

@staticmethod
def parse_literal(node):
if isinstance(node, ast.StringValue):
if node.value == 'Yes':
return True
if node.value == 'No':
return False
return None

@staticmethod
def parse_value(value):
return value

Beitragsleitfaden

Für dieses Repository ist kein Beitragsleitfaden indexiert

Rechercherichtung

Start at construct_fields in graphene_django.types and trace how nullable model booleans are mapped. Confirm the expected GraphQL input and output behavior for None, True, and False, then add focused regression coverage. Done means nullable boolean fields preserve None without changing non-null boolean behavior.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
python
Bereich
api
Issue-Typ
Feature
Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Aktivitätsstatus
Veraltet
Klarheit
Muss geklärt werden
Anfängerfreundlichkeit
35/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.