graphql-python / graphql-python/graphene
Root Value example doesn't work
- 主要言語
- Python
- スター
- 8.2k
- フォーク
- 818
- PR マージ指標
- 30日以内にマージされた PR はありません
説明
The [Root Value](https://docs.graphene-python.org/en/latest/execution/execute/#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.
コントリビューションガイド
このリポジトリのコントリビューションガイドは索引されていません
調査の方向性
ドキュメント内のリンクされた「Root Value」セクションから始め、その周辺にある完全な例を確認してください。User の定義、フィールド名、resolver 名、クエリされたフィールド、サンプル値に一貫性を持たせ、例が自己完結して実行可能になるようにしてください。編集後にドキュメント化された例を検証してください。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- python
- 領域
- documentation
- issue の種類
- ドキュメント
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 活発さ
- 停滞
- 明瞭さ
- 明確に書かれている
- 初心者へのやさしさ
- 55/100