graphql-python / graphql-python/graphene
How to address inheritance chain changes between Graphene 2 and 3?
- Lenguaje dominante
- Python
- Estrellas
- 8.2k
- Forks
- 818
- Métricas de merge de PR
- Sin PR fusionados en 30 d
Descripción
* **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
(
>,
>,
,
,
,
)
```
Guía de contribución
No hay ninguna guía de contribución indexada para este repositorio
Línea de trabajo
El issue menciona ObjectTypeWithID, ObjectTypeMeta, InterObjectType y las distintas MRO de Python, pero no incluye archivos ni tests del repositorio. Empieza reproduciendo el ejemplo de herencia en Graphene 2.x y 3.x y, a continuación, inspecciona la MRO generada y el comportamiento del constructor. Se considera terminado cuando se haya establecido el comportamiento de herencia previsto y el issue tenga una resolución documentada o probada.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- python
- Área
- api, backend-api-design
- Tipo de issue
- Error
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Estado de actividad
- Estancado
- Claridad
- Necesita aclaración
- Aptitud para principiantes
- 25/100