graphql-python / graphql-python/graphene

Null Boolean Scalar

オープン
#1,353 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る
✨ enhancement
主要言語
Python
スター
8.2k
フォーク
818
PR マージ指標
30日以内にマージされた PR はありません

説明

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

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

調査の方向性

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.

索引モデルが issue の本文から書いたものです。

評価

技術スタック
python
領域
api
issue の種類
機能追加
難易度
4/5
見積もり時間
3〜5日
活発さ
停滞
明瞭さ
説明が足りない
初心者へのやさしさ
35/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。