graphql-python / graphql-python/graphene-sqlalchemy

object of type 'SQLAlchemyConnectionField' has no len()

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

描述

Hello,

I am implementing a connection field.

The excerpts from the code are:

```
# Classes:
class Common(graphene_sqlalchemy.SQLAlchemyObjectType):
class Meta:
abstract = True
...

class MyGraphQLModel(Common):
class Meta:
model = MyModel
interfaces = (graphene.relay.Node, )

# Fields:
mymodels = graphene.List(MyGraphQLModel)
def mymodels(p,i):
query = MyGraphQLModel.get_query(i)
return query.all()

connection_mymodels = graphene_sqlalchemy.SQLAlchemyConnectionField(MyGraphQLModel)
```

The first field (`mymodels`) which is an array without a connection works fine.
The second field which is a connection gives error:

```
"message": "object of type 'SQLAlchemyConnectionField' has no len()",
```

Any ideas? Thanks.

貢獻指南

開啟貢獻指南

研究方向

Start with the SQLAlchemyConnectionField implementation and the traceback for the reported len() error, then reproduce it using the MyGraphQLModel schema and connection_mymodels field shown here. Done means the connection field resolves without raising the TypeError and the existing list field remains working.

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

評估

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

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

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