graphql-python / graphql-python/gql-next
Issues with DateTime ISO fields
- Ngôn ngữ chính
- Python
- Star
- 78
- Fork
- 6
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Mô tả
when i run `gql_run` and the `renderer_dataclasses.py` encounters a DateTime field it generates a field:
`var_name: datetime = None`
when I run a query that returns a datetime object I get the following error:
```
File "/Users/jasper/Documents/test/test-graph-python-client/env/lib/python3.7/site-packages/dataclasses_json/core.py", line 220, in _decode_generic
res = _get_type_cons(type_)(xs)
File "/Users/jasper/Documents/test/test-graph-python-client/env/lib/python3.7/site-packages/dataclasses_json/core.py", line 260, in
for x in xs)
File "/Users/jasper/Documents/test/test-graph-python-client/env/lib/python3.7/site-packages/dataclasses_json/core.py", line 165, in _decode_dataclass
infer_missing)
File "/Users/jasper/Documents/test/test-graph-python-client/env/lib/python3.7/site-packages/dataclasses_json/core.py", line 179, in _decode_dataclass
dt = datetime.fromtimestamp(field_value, tz=tz)
TypeError: an integer is required (got type str)
```
I think this is because in:
https://github.com/graphql-python/gql-next/blob/5c81e58862c8df3a335b81bb2f77a0fab2c50570/gql/renderer_dataclasses.py#L153-L160
`suffix` is being overwritten if the field is nullable and `DATETIME_FIELD` isn't being used.
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 by inspecting gql/renderer_dataclasses.py around lines 153-160, especially how suffix is handled for nullable DateTime fields and when DATETIME_FIELD is selected. Reproduce the gql_run query with a DateTime result and verify that the generated dataclass can deserialize the returned ISO value without the reported TypeError.
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
- Khá rõ ràng
- Mức phù hợp với người mới
- 45/100