【发布时间】:2021-10-29 09:03:55
【问题描述】:
我想知道,是否有办法在石墨烯 GraphQl 解析器中传递更多要查询的参数。
因此,此代码仅适用于 wgr_bez:
class GraphqlService(graphene.ObjectType):
get_single_article = graphene.Field(ArticleGrapheneModel, wgr_bez=graphene.String)
@staticmethod
async def resolve_get_single_article(parent, info, **kwargs):
article = await info.context['request'].state.db.select_article_with_filter(kwargs)
return article[0][0].to_json()
使用 **kwargs 我可以从请求中获取任何列:值对,但是如何传递任何列:值,我不明白。
我希望能够用更通用的东西或至少是字典来替换它。我在文档中看到了它,但是当我这样做时出现错误:
get_single_article = graphene.Field(ArticleGrapheneModel, {'wgr_bez': graphene.String, 'id': graphene.Int})
ValueError: Unknown argument "wgr_bez".
【问题讨论】: