graphql-python / graphql-python/graphene

Default value for custom input object type

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

説明

I have a custom input object type

```
class Filters(graphene.InputObjectType):
name = graphene.String()
type = graphene.List(graphene.String)
```

and the query definition

```
class Query(graphene.ObjectType):
search = graphene.Field(
SearchResult, query=graphene.String(required=True),
filters=graphene.Argument(Filters, default_value=None)
)
```

I want to be able to provide an empty default value for the `filters` argument. With the above definition, the argument is not set as optional and I'm getting this error message:

```
{
"errors": [
{
"message": "resolve_search() missing 1 required positional argument: 'filters'",
"locations": [
{
"line": 15,
"column": 3
}
],
"path": [
"search"
]
}
],
"data": {
"search": null
}
}
```

What is the correct way to provide an empty default value for the argument of custom object type? I'm at these package versions:

`graphene==2.1.3`
`graphql-core==2.1`
`graphql-server-core==1.1.1`

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

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

評価

この issue はまだ評価されていません。

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

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