graphql-python / graphql-python/graphene
How to address inheritance chain changes between Graphene 2 and 3?
- 主要言語
- Python
- スター
- 8.2k
- フォーク
- 818
- PR マージ指標
- 30日以内にマージされた PR はありません
説明
* **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
(
>,
>,
,
,
,
)
```
コントリビューションガイド
このリポジトリのコントリビューションガイドは索引されていません
調査の方向性
この issue では ObjectTypeWithID、ObjectTypeMeta、InterObjectType、および異なる Python MRO について述べられていますが、リポジトリのファイルやテストはありません。まず Graphene 2.x と 3.x で継承の例を再現し、その後、生成された MRO とコンストラクターの動作を調べてください。意図された継承動作が確立され、issue に文書化またはテスト済みの解決策がある状態を完了とします。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- python
- 領域
- api, backend-api-design
- issue の種類
- バグ
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 活発さ
- 停滞
- 明瞭さ
- 説明が足りない
- 初心者へのやさしさ
- 25/100