graphql-python / graphql-python/graphene
Allow setting a default JSON Encoder and JSON Decoder
- Lenguaje dominante
- Python
- Estrellas
- 8.2k
- Forks
- 818
- Métricas de merge de PR
- Sin PR fusionados en 30 d
Descripción
**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**
Guía de contribución
No hay ninguna guía de contribución indexada para este repositorio
Línea de trabajo
Start by reviewing the JSONString field and its serialize() method, then compare the requested global, setting-based, and per-field encoder options with the existing graphene-django behavior. Done means a documented API allows a custom JSON encoder and decoder, with coverage for the intended configuration.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- python
- Área
- api, backend
- Tipo de issue
- Nueva funcionalidad
- Dificultad
- 5/5
- Tiempo estimado
- Más de una semana
- Estado de actividad
- Estancado
- Claridad
- Bastante claro
- Aptitud para principiantes
- 35/100