graphql-python / graphql-python/graphene-sqlalchemy

ORMField batching results in null result

未關閉
#401 1 則留言 5 個 reaction 已指派 0 人 在 GitHub 檢視
主要語言
Python
星號
985
分支
223
PR 合併指標
30 天內沒有已合併 PR

描述

I'm trying to get batching set up on a 1:N relationship. Suppose a `Foo` has many `Bar`s

```python
class FooObject(SQLAlchemyObjectType):
class Meta:
model = Foo
interfaces = (graphene.relay.Node,)

bars = ORMField(batching=True)
```
(I've also tried doing `batching=True` in the `Meta`)

```python
class Query(graphene.ObjectType):
test_query_batching = graphene.Field(
lambda: graphene.List(FooObject),
)

def resolve_test_foo_query_batching(self, info):
return Foo.query.limit(5).all()
```

Querying this resolver as such

```graphql
query TestQueryBatching {
testQueryBatching {
id
bars {
edges {
node {
id
}
}
}
}
}
```

results in `Cannot return null for non-nullable field BarObjectConnection.edges`. This query succeeds if `batching` is disabled. I'm unsure as to why we'd be getting null for `BarObjectConnection.edges`, though. Any ideas as to what might be leading to this?

Versions:
- SQLAlchemy==1.4.51
- Flask-SQLAlchemy==2.5.1
- graphene-sqlalchemy==3.0.0rc1

貢獻指南

開啟貢獻指南

研究方向

使用列出的 SQLAlchemy、Flask-SQLAlchemy 和 graphene-sqlalchemy 版本,重現 FooObject ORMField、test_query_batching resolver 與 BarObjectConnection.edges query 中回報的行為。追蹤 batching 路徑,並與停用 batching 時進行比較;當 query 回傳已填入的 edges 且沒有 non-null 違規,同時保留現有的非 batching 行為時,即表示完成。

由索引模型根據 Issue 內容生成。

評估

技術堆疊
graphql, python, sqlalchemy
領域
backend-api-design, database
Issue 類型
缺陷
難度
4/5
預估耗時
3-5 天
活躍度
停滯
描述清晰度
需要釐清
新手友好度
35/100

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。