简体   繁体   English

Graphene 中提供的 GraphQLError() 有多大用处?

[英]How useful is GraphQLError() provided in Graphene?

The python graphene documentation does not mention anything about graphQL error. python 石墨烯文档没有提及有关 graphQL 错误的任何内容。 Under what scenarios is it useful, does it have any advantage over a simple raise Exception('Authenication Failure: User is not registered') ?在什么情况下它有用,它比简单的raise Exception('Authenication Failure: User is not registered')有什么优势吗?

I did my homework and found this in it's constructor,我做了功课,在它的构造函数中发现了这个,

def __init__(
    self,
    message,  # type: str
    nodes=None,  # type: Any
    stack=None,  # type: Optional[TracebackType]
    source=None,  # type: Optional[Any]
    positions=None,  # type: Optional[Any]
    locations=None,  # type: Optional[Any]
    path=None,  # type: Union[List[Union[int, str]], List[str], None]
    extensions=None,  # type: Optional[Dict[str, Any]]
)

But apart from message, I don't understand when the other options would be most useful.但除了消息之外,我不明白其他选项何时最有用。 Some help would be greatly appreciated.一些帮助将不胜感激。

The GraphQLError class on Graphene comes from graphql-core which is the Python implementation of GraphQL-JS, where you can find the same GraphQLError class.石墨烯上的GraphQLError class 来自graphql-core ,它是 GraphQL-JS 的 Python 实现,您可以在其中找到相同的GraphQLError ZA2F2ED4F8EBC2CBB4C21A29DC40AB61D。

This is used to get extra information about the location, the node kind and the stack trace of any validation/parsing error while executing a graphql query.这用于在执行 graphql 查询时获取有关位置、节点类型和任何验证/解析错误的堆栈跟踪的额外信息。

You can read more at the official spec doc :)您可以在官方规范文档中阅读更多内容:)

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

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