简体   繁体   English

找到 ExecutionResult 的返回值 - python-graphene

[英]finding the return value of ExecutionResult - python-graphene

I am new to python (javascript developer我是 python 的新手(javascript 开发人员

i am following a tutorial, (which is not very good at explaining on why) on using python & graphene我正在学习使用 python 和石墨烯的教程(不太擅长解释原因)

my question is when i print result i receive我的问题是当我打印result收到

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

in javascript, when you console log you can see what is contained in the result variable,在 javascript 中,当您控制台日志时,您可以看到结果变量中包含的内容,

but not sure why i cannot do the same in python, unless im doing it wrong?但不知道为什么我不能在 python 中做同样的事情,除非我做错了?

from googling, it looks like it returns data, but it would be useful to actually log and see it in the terminal,从谷歌搜索来看,它看起来像返回数据,但实际记录并在终端中查看它会很有用,

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`

这样做以在控制台中查看数据:

print(result.data)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM