graphql-python / graphql-python/graphene
Allow setting a default JSON Encoder and JSON Decoder
- 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ả
**Is your feature request related to a problem? Please describe.**
I'm using graphene_django, which auto-converts model fields to `JSONString`, which doesn't allow customizing the JSONEncoder class. I'm doing this for some semi-hacky code where I just want to store a big blob-o-stuff, using a custom encoder to convert enums and datetimes.
PS - I'm happy to implement this! Just looking for feedback on what are reasonable modifications to API for this (if any) or if I should give up on this thread :)
**Describe the solution you'd like**
Allow me to specify a custom JSON encoder via some setting or a global.
**Describe alternatives you've considered**
1. In my ideal world, I'd be able to pass custom encoders to specific JSON fields. (realistically, you can always merge all the JSONEncoders, so being able to specify just one is fine).
2. `serialize()` no longer a static method (seems like overkill for small change)
3. Make graphene-django create custom JSONString fields based upon jsonencoder / decoder (possible, slightly more goofy perhaps)
**Additional context**
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
Bắt đầu bằng việc xem xét trường JSONString và phương thức serialize() của nó, sau đó so sánh các tùy chọn encoder toàn cục, dựa trên cấu hình và theo từng trường được yêu cầu với hành vi hiện có của graphene-django. Công việc được xem là hoàn tất khi có một API được tài liệu hóa cho phép sử dụng encoder và decoder JSON tùy chỉnh, cùng với phần kiểm thử bao phủ cấu hình dự kiến.
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, backend
- Loại issue
- Tính năng
- Độ khó
- 5/5
- Thời gian dự kiến
- Hơn một tuần
- 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
- 35/100