graphql-python / graphql-python/graphene

Default value for custom input object type

Đang mở
#856 14 bình luận 0 reaction 0 người được giao Xem trên GitHub
✨ enhancement good first issue
Ngôn ngữ chính
Python
Star
8.2k
Fork
818
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

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`

Hướng dẫn đóng góp

Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.