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

Root Value example doesn't work

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

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

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
55/100
issue の種類
ドキュメント
明瞭さ
明確に書かれている
活発さ
停滞
技術スタック
python
領域
documentation

調査の方向性

ドキュメント内のリンクされた「Root Value」セクションから始め、その周辺にある完全な例を確認してください。User の定義、フィールド名、resolver 名、クエリされたフィールド、サンプル値に一貫性を持たせ、例が自己完結して実行可能になるようにしてください。編集後にドキュメント化された例を検証してください。

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

説明

🐛 bug

The Root Value example in the documentation:

from graphene import ObjectType, Field, Schema

class Query(ObjectType):
    me = Field(User)

    def resolve_user(root, info):
        return {'id': root.id, 'firstName': root.name}

schema = Schema(Query)
user_root = User(id=12, name='bob')
result = schema.execute(
    '''
    query getUser {
        user {
            id
            firstName
            lastName
        }
    }
    ''',
    root=user_root
)
assert result.data['user']['id'] == user_root.id

doesn't work. Throws NameError: name 'User' is not defined.

What's not clear is:

  • Where User is defined -- is it defined somewhere else in the documentation? (hyperlink/inline)
  • The Query field is named me yet the resolver function is named resolve_user.
  • The executed query asks for user (not me).
  • The created User object (assigned to user_root) is constructed to have a name field, yet the query asks for the firstName and lastName fields. Sure, resolve_user returns a dict with id, and firstName, but this adds to the confusion.

Having various combinations of name, firstName and lastName is confusing, especially in an example that doesn't work.

主要言語
Python
スター
8.2k
フォーク
818
PR マージ指標
30日以内にマージされた PR はありません

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

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

はじめの一歩

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

graphql-python/graphene のほかの issue

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

似ている issue

Python の issue をもっと見る

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

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