graphql-python / graphql-python/graphene

Cannot use an enum as a graphene.List named argument

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

説明

When defining this query:
```
class Episode(graphene.Enum):
NEWHOPE = 4
EMPIRE = 5
JEDI = 6

class ListAvailableSubscriptionPlans(graphene.ObjectType):

available_subscription_plans = graphene.List(
graphene.NonNull(graphql.SubscriptionPlanObject),
subscriber_id=graphene.Int(required=True),
subscriber_type=Episode,
target_currency=graphene.String(required=True),
)

def resolve_available_subscription_plans(
self, info, subscriber_id, subscriber_type, target_currency
):
```
And running the python module, we get the error:
```
File "/app/subscription_management/subscriptions/api.py", line 16, in
class ListAvailableSubscriptionPlans(graphene.ObjectType):
File "/app/virtualenv/lib/python3.8/site-packages/graphene/utils/subclass_with_meta.py", line 52, in __init_subclass__
super_class.__init_subclass_with_meta__(**options)
File "/app/virtualenv/lib/python3.8/site-packages/graphene/types/objecttype.py", line 112, in __init_subclass_with_meta__
fields.update(yank_fields_from_attrs(base.__dict__, _as=Field))
File "/app/virtualenv/lib/python3.8/site-packages/graphene/types/utils.py", line 31, in yank_fields_from_attrs
field = get_field_as(value, _as)
File "/app/virtualenv/lib/python3.8/site-packages/graphene/types/utils.py", line 21, in get_field_as
return _as.mounted(value)
File "/app/virtualenv/lib/python3.8/site-packages/graphene/types/mountedtype.py", line 15, in mounted
return cls(
File "/app/virtualenv/lib/python3.8/site-packages/graphene/types/field.py", line 103, in __init__
self.args = to_arguments(args or OrderedDict(), extra_args)
File "/app/virtualenv/lib/python3.8/site-packages/graphene/types/argument.py", line 80, in to_arguments
extra_args = sorted(extra_args.items(), key=lambda f: f[1])
TypeError: '<' not supported between instances of 'EnumMeta' and 'Int'
```
Because this line does not work:
**subscriber_type=Episode**

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

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

調査の方向性

まず例を再現し、traceback の graphene/types/argument.py パスを調査します。特に extra_args の処理を確認してください。enum 値の名前付き引数が Int と併用して受け入れられ、示されているスキーマ定義を TypeError なしで作成できれば完了です。

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

評価

技術スタック
python
領域
api
issue の種類
バグ
難易度
3/5
見積もり時間
1〜2日
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
45/100

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

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