graphql-python / graphql-python/graphene

Unclear documentation for ObjectType

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

説明

* **What is the current behavior?**

The current [documentation for ObjectType](https://docs.graphene-python.org/en/latest/types/objecttypes/) states the following under the "Parent Value Object" heading:

```
from graphene import ObjectType, String, Field

class Person(ObjectType):
full_name = String()

def resolve_full_name(parent, info):
return f"{parent.first_name} {parent.last_name}"

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

def resolve_me(parent, info):
# returns an object that represents a Person
return get_human(name="Luke Skywalker")
```

- **If the current behavior is a bug, please provide the steps to reproduce**

If you copy this directly into PyCharm (or any other editor I would imagine) you get an error stating that the function get_human cannot be located.

I am currently trying to write my own ObjectType which will take an argument. However, because the documentation cannot be run, I don't know how to proceed.

I have the following:

```
class RunLog(ObjectType):
status = String()
result = String()
log = List(String)

def resolve_status(self, resolve, run_id):
return r.hget("run:%i" % run_id, "status").decode('utf-8')

def resolve_result(self, resolve, run_id):
return r.hget("run:%i" % run_id, "result").decode('utf-8')

def resolve_log(self, resolve, run_id):
log_data = r.lrange("run:%i:log" % run_id, 0, -1)
log_data = [entry.decode('utf-8') for entry in log_data]

return log_data

class Query(ObjectType):
log_by_run_id = Field(RunLog, run_id=Int(required=True))

# @login_required
def resolve_log_by_run_id(root, info, run_id):
return **?????**
```

Because the documentation references an unknown function, I don't know what to put in the final line as the return value for resolve_log_by_run_id.

This type of unknown function of class seems to appear a lot in the documentation. It can be seen again under [Executing a query](https://docs.graphene-python.org/en/latest/execution/execute/#schemaexecute).

* **What is the expected behavior?**

The documentation can be clearly interoperated.

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

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

調査の方向性

ObjectType ドキュメントの「Parent Value Object」セクションと、issue でリンクされている「Executing a query」の例から始めます。ドキュメント化されていない各関数またはプレースホルダーを確認し、例を実行可能にするか、必要なアプリケーション定義の値を説明します。resolve_log_by_run_id が何を返すべきかも含めてください。読者が、未知の関数に妨げられることなく例を解釈して実行できれば完了です。

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

評価

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

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

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