【发布时间】:2021-06-25 02:26:24
【问题描述】:
所以我有一个 GraphQL API,我写了一个查询,它可以工作并用 GraphiQL 向我发回数据。
query dishes {
dishes {
name
recipeNote
description
}
}
这是我对我所拥有的东西的石墨烯翻译
class Dish(ObjectType):
name = String()
recipeNote = String()
description = String()
class Query(ObjectType):
first = Field(Dish)
def resolve_first(parent, info):
return parent
query_string = "{ first { dishes { name recipeNote description } } }"
result = schema.execute(
query_string)
print(result)
print(result.data)
但是这给了我一个错误{'errors': [{'message': 'Cannot query field "dishes" on type "Dish".', 'locations': [{'line': 1, 'column': 11}]}]}
【问题讨论】:
-
您的石墨烯翻译以及查询不正确。我假设您正在尝试取所有盘子。检查我的答案。
标签: python-3.x graphql graphene-python graphene-django