Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

Interfaces are ignored when define Mutation.

オープン
#1,361 コメント 0 件 リアクション 2 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
45/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
停滞
技術スタック
python
領域
api, backend

調査の方向性

graphene/types/mutation.py の init_subclass_with_meta から始め、報告された CreatePlan の例を再現してください。明示的な output が指定されていない場合にそれらを破棄するのではなく、interfaces を持つ mutation を定義したときに interface fields がその output に保持されれば、修正は完了です。

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

説明

🐛 bug

Hello.
First of all, thanks for all graphene developers and contributors.

  • What is the current behavior?
    Interface is ignored when define mutation. This is my code.
class CreatePlan(Mutation):
    class Meta:
        interfaces = (PlanInterface, )

    class Arguments:
        name = String(required=True)
        comment = String(default_value='')
        goal = String(required=True)
        start_date = DateTime(required=True)
        end_date = DateTime(required=True)

    def mutate(parent, info, **kwargs):
        ~~~
# this raises AssertionError:
# CreatePlan fields must be a mapping (dict / OrderedDict)
# with field names as keys or a function which returns such a mapping.
  • What is the expected behavior?
    I think Mutation should includes all interfaces and fields together.

  • Please tell us about your environment:
    Here is my environment.

    • Version: 2.1.9
    • Platform: Mac OS
  • Other information (e.g. detailed explanation, stacktraces, related issues, suggestions how to fix, links for us to have context, eg. stackoverflow)
    I think removing just a line can resolve this problem.
    branch v2, graphene/types/mutation.py line 69

    @classmethod
    def __init_subclass_with_meta__(
        cls,
        interfaces=(),
        resolver=None,
        output=None,
        arguments=None,
        _meta=None,
        **options
    ):
        if not _meta:
            _meta = MutationOptions(cls)

        output = output or getattr(cls, "Output", None)
        fields = {}

        for interface in interfaces:
            assert issubclass(interface, Interface), (
                'All interfaces of {} must be a subclass of Interface. Received "{}".'
            ).format(cls.__name__, interface)
            fields.update(interface._meta.fields)

        if not output:
            # If output is defined, we don't need to get the fields
            fields = OrderedDict().  # This ignores interfaces. Remove this.
            for base in reversed(cls.__mro__):
                fields.update(yank_fields_from_attrs(base.__dict__, _as=Field))
            output = cls

Also, I found same problem on master branch.

    @classmethod
    def __init_subclass_with_meta__(
        cls,
        interfaces=(),
        resolver=None,
        output=None,
        arguments=None,
        _meta=None,
        **options,
    ):
        if not _meta:
            _meta = MutationOptions(cls)
        output = output or getattr(cls, "Output", None)
        fields = {}

        for interface in interfaces:
            assert issubclass(
                interface, Interface
            ), f'All interfaces of {cls.__name__} must be a subclass of Interface. Received "{interface}".'
            fields.update(interface._meta.fields)
        if not output:
            # If output is defined, we don't need to get the fields
            fields = {}. # This ignores interfaces. Remove this.
            for base in reversed(cls.__mro__):
                fields.update(yank_fields_from_attrs(base.__dict__, _as=Field))
            output = cls
主要言語
Python
スター
8.2k
フォーク
818
PR マージ指標
30日以内にマージされた PR はありません

環境構築

このプロジェクトの環境構築ファイルはまだ確認していません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

graphql-python/graphene のほかの issue

graphql-python/graphene の issue をすべて見る

似ている issue

Python の issue をもっと見る

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

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