graphql-python / graphql-python/graphene

How to address inheritance chain changes between Graphene 2 and 3?

Aperta
#1,592 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub
🐛 bug
Lingua principale
Python
Stelle
8.2k
Fork
818
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

* **What is the current behavior?**

In order for us to have consistent IDs and unique IDs for all our entities we made all entities were inheriting from this class:

```python
class ObjectTypeWithID(ObjectType):
id = ID(required=True, description="globally unique identifier")
entity_id = String(required=True, description="identifier for the entity")
model_id = String(required=True, description="identifier for the entity model")

def __init__(self, id):
print('!!!ObjectTypeWithID.__init__')
self.id = generate_global_id(self.__class__.__name__, id)
self.entity_id = id
self.model_id = id

# usage
class User(ObjectTypeWithID)
def __init__:
super().__init__(user_id)
```

This worked fine in Graphene 2.x but once we tried to upgrade to Graphene 3.x it seems like `super().__init__` does not trigger `ObjectTypeWithID`

I checked the mro and I noticed there's now InterObjectType between User and it's parent ObjectTypeWithID and I suspect it's getting in the way when call `super()`

`user.__class__.__mro__` in Graphene 3.x
```python
(
>,
.InterObjectType'>,
>,
.InterObjectType'>,
,
.InterObjectType'>,
,
,
)
```

`user.__class__.__mro__` in Graphene 2.x
```python
(
>,
>,
,
,
,

)
```

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Direzione di ricerca

La issue cita ObjectTypeWithID, ObjectTypeMeta, InterObjectType e i diversi MRO di Python, ma non contiene file o test del repository. Inizia riproducendo l’esempio di ereditarietà su Graphene 2.x e 3.x, quindi esamina l’MRO generato e il comportamento del costruttore. Il lavoro è completato quando il comportamento di ereditarietà previsto è stato stabilito e la issue dispone di una risoluzione documentata o testata.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
python
Ambito
api, backend-api-design
Tipo di issue
Bug
Difficoltà
4/5
Tempo stimato
3-5 giorni
Stato di attività
Ferma
Chiarezza
Da chiarire
Idoneità per principianti
25/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.