【发布时间】:2020-08-18 22:33:18
【问题描述】:
我浏览了 Python 石墨烯的 the documentation,它起作用了。这是代码-
from graphene import ObjectType, String, Schema
class Query(ObjectType):
hello = String(name=String(default_value="stranger"))
def resolve_hello(root, info, name):
return f'Hello {name}!'
schema = Schema(query=Query)
query = '{ hello(name: "GraphQL") }'
result = schema.execute(query)
print(result.data['hello']) # "Hello GraphQL!"
但是,将hello 更改为some_field,将resolve_hello 更改为resolve_some_field,并制作query = '{ some_field(name: "GraphQL" }' ,我得到的最终结果是None。
有没有办法处理包含下划线的字段?
【问题讨论】:
标签: python graphql graphene-python