django - `graphene_django` 的`op_name` 参数
问题描述
django 石墨烯文档显示了一个这样的测试示例:
class MyFancyTestCase(GraphQLTestCase):
def test_some_query(self):
response = self.query(
'''
query {
myModel {
id
name
}
}
''',
op_name='myModel'
)
content = json.loads(response.content)
# This validates the status code and if you get errors
self.assertResponseNoErrors(response)
# Add some more asserts if you like
...
他们没有任何关于什么op_name
是什么以及我们应该将其设置为什么的 API 文档。我试图将其设置为我的查询名称,但得到错误:
[{'message': 'Unknown operation named "myQuery".'}]
解决方案
仅当查询字符串中有多个操作时才需要操作名称。您只有一项操作,因此默认(无)就可以了。
https://docs.graphene-python.org/en/latest/execution/execute/#operation-name
推荐阅读
- angularjs - 对资源的 DELETE 方法调用引发 401(未经授权)错误。Angularjs
- python - 格式化多维数组 Numpy Python
- json - 有没有办法以编程方式读取 Reddit 图库中的所有图像 URL?
- c# - 带有 C# 应用程序的 Microchip Harmony CRYPT ECC 公钥
- scala - 为什么 checkpoint() 比 persist() 快
- excel - ClearContents 会影响其旁边的其他单元格中的公式
- python - 使用数据帧时如何在python中返回元组列表?
- javascript - 如何确定是什么工具创建了如下所示的 javascript 代码?
- azure - Azure Logic App Customer Connector 无法使用 oAuth2(震惊!) - 这次使用 Pinterest
- javascript - 为什么输入值是这种形式的空字符串?