考虑以下枚举类:
import enum
class CoverTitleColor(enum.Enum):
YELLOW = "yellow"
RED = "red"
BLUE = "blue"
ORANGE = "orange"
WHITE = "white"
PURPLE = "purple"
设置为SQLAlchemy ORM字段,如下所示:
^{pr2}$通过以下方式暴露于石墨烯中:
^{3}$但是,当通过GraphQL通过以下查询自省TypeBook
时:
{
__type(name: "TypeBook") {
name
fields {
name
type {
name
kind
ofType {
name
kind
}
}
}
}
}
coverTitleColor
字段被解释为字符串:
{
"name": "coverTitleColor",
"type": {
"name": null,
"kind": "NON_NULL",
"ofType": {
"name": "String",
"kind": "SCALAR"
}
}
},
当查询出该字段时,例如,通过:
query {
books(year: 1990) {
coverTitleColor
}
}
结果确实是这样的字符串:
{
"data": {
"books": [
{
"coverTitleColor": "CoverTitleColor.YELLOW"
},
{
"coverTitleColor": "CoverTitleColor.RED"
}
]
}
}
我错过什么了吗?这是预期的行为吗?在
The full working code can be found under https://github.com/somada141/demo-graphql-sqlalchemy-falcon/tree/issue-graphene-sqlalchemy-135
This question has also been posted as a GH issue under https://github.com/graphql-python/graphene-sqlalchemy/issues/135
目前没有回答
相关问题 更多 >
编程相关推荐