graphql-python / graphql-python/graphene

Allow setting a default JSON Encoder and JSON Decoder

Ouverte
#1,322 1 commentaire 4 réactions 0 personnes assignées Voir sur GitHub
✨ enhancement
Langage dominant
Python
Étoiles
8.2k
Forks
818
Métriques de merge des PR
Aucune PR mergée en 30 j

Description

**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**

Guide de contribution

Aucun guide de contribution indexé pour ce dépôt

Piste de recherche

Commencez par examiner le champ JSONString et sa méthode serialize(), puis comparez les options d’encodeur globales, fondées sur les paramètres et par champ demandées avec le comportement existant de graphene-django. Le travail est considéré comme terminé lorsqu’une API documentée permet d’utiliser un encodeur et un décodeur JSON personnalisés, avec une couverture pour la configuration prévue.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Évaluation

Stack technique
python
Domaine
api, backend
Type d'issue
Fonctionnalité
Difficulté
5/5
Temps estimé
Plus d'une semaine
Activité
À l'abandon
Clarté
Plutôt claire
Accessibilité débutants
35/100

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.