【问题标题】:finding the return value of ExecutionResult - python-graphene查找 ExecutionResult 的返回值 - python-graphene
【发布时间】:2019-09-11 20:05:47
【问题描述】:

我是 python 新手(javascript 开发人员

我正在关注一个关于使用 python 和石墨烯的教程(这不是很好地解释原因)

我的问题是当我打印 result 我收到时

<graphql.execution.base.ExecutionResult object at 0x1071ad410>

在 javascript 中,当您控制台日志时,您可以看到结果变量中包含的内容,

但不知道为什么我不能在 python 中做同样的事情,除非我做错了?

从谷歌搜索,它看起来像返回数据,但实际记录并在终端中查看它会很有用,

import graphene
import json

class Query(graphene.ObjectType):
    hello = graphene.String()
    is_admin = graphene.Boolean()

    def resolve_hello(self, info):
        return "world"

    def resolve_is_admin(self, info):
        return True


schema = graphene.Schema(query=Query)

result = schema.execute(
     '''
    {
      isAdmin
    }
     '''
)

print(type(result))

print(result)


i would expect to see the what is the result of the variable `result`

【问题讨论】:

    标签: python graphene-python


    【解决方案1】:

    执行此操作以在控制台中查看数据:

    print(result.data)
    

    【讨论】:

      猜你喜欢
      • 2021-02-28
      • 2019-11-17
      • 2020-03-22
      • 2019-01-16
      • 1970-01-01
      • 1970-01-01
      • 2016-05-14
      • 2020-08-26
      • 1970-01-01
      相关资源
      最近更新 更多