graphql-python / graphql-python/graphql-core-legacy

Parser raises an error for null Boolean Type

Đang mở Phù hợp với người mới
#285 0 bình luận 0 reaction 0 người được giao Xem trên GitHub
Ngôn ngữ chính
Python
Star
372
Fork
175
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

The parser is not able to handle boolean types with `null` default type.

This is handled in this line: https://github.com/graphql-python/graphql-core-legacy/blob/master/graphql/language/parser.py#L502

Following a [commit](https://github.com/octokit/graphql-schema/commit/18c40d2bb68d8f27acfc62e768d34aadfca9e8b2#diff-9fcde326d127f74194f70e563bdf2c118c51b719c308f015b8eb0204a9a552fb) GitHub introduced to their schema yesterday `gql` can no longer parse its schema, as it fails on this `null` `Boolean` type:

```
{'name': 'isVerified', 'description': 'Filter by if the domain is verified.', 'type': {'kind': 'SCALAR', 'name': 'Boolean', 'ofType': None}, 'defaultValue': 'null'}
```

GitHub claims this change is in accordance with the [GraphQL standards documentation](https://graphql.org/graphql-js/basic-types/):

> By default, every type is nullable - it's legitimate to return null as any of the scalar types. Use an exclamation point to indicate a type cannot be nullable, so String! is a non-nullable string.

> Therefore, it appears that a null default value for a boolean is valid in GraphQL.

Currently the code specifically ignores `null` values.

![image](https://user-images.githubusercontent.com/20818773/109168192-3d706b00-7787-11eb-8594-d84361c4081a.png)

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

Hướng nghiên cứu

Start at graphql/language/parser.py line 502, where null values are currently ignored, and reproduce the failure with the Boolean schema entry shown in the issue. Update the parser behavior so a nullable Boolean with a null default is accepted, then verify that the GitHub schema example parses without raising an error.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
python
Lĩnh vực
api
Loại issue
Lỗi
Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Đặc tả rõ ràng
Mức phù hợp với người mới
68/100

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.