本文整理汇总了Golang中github.com/chris-ramon/graphql-go/types.GraphQLResult.HasErrors方法的典型用法代码示例。如果您正苦于以下问题:Golang GraphQLResult.HasErrors方法的具体用法?Golang GraphQLResult.HasErrors怎么用?Golang GraphQLResult.HasErrors使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/chris-ramon/graphql-go/types.GraphQLResult
的用法示例。
在下文中一共展示了GraphQLResult.HasErrors方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: Execute
func Execute(p ExecuteParams, resultChan chan *types.GraphQLResult) {
var errors []graphqlerrors.GraphQLFormattedError
var result types.GraphQLResult
params := BuildExecutionCtxParams{
Schema: p.Schema,
Root: p.Root,
AST: p.AST,
OperationName: p.OperationName,
Args: p.Args,
Errors: errors,
Result: &result,
ResultChan: resultChan,
}
exeContext := buildExecutionContext(params)
if result.HasErrors() {
return
}
defer func() {
if r := recover(); r != nil {
var err error
if r, ok := r.(error); ok {
err = graphqlerrors.FormatError(r)
}
exeContext.Errors = append(exeContext.Errors, graphqlerrors.FormatError(err))
result.Errors = exeContext.Errors
resultChan <- &result
}
}()
eOperationParams := ExecuteOperationParams{
ExecutionContext: exeContext,
Root: p.Root,
Operation: exeContext.Operation,
}
executeOperation(eOperationParams, resultChan)
}
示例2: Execute
func Execute(p ExecuteParams, resultChan chan *types.GraphQLResult) {
var errors []error
var result types.GraphQLResult
params := BuildExecutionCtxParams{
Schema: p.Schema,
Root: p.Root,
AST: p.AST,
OperationName: p.OperationName,
Args: p.Args,
Errors: errors,
Result: &result,
ResultChan: resultChan,
}
exeContext := buildExecutionContext(params)
if result.HasErrors() {
return
}
eOperationParams := ExecuteOperationParams{
ExecutionContext: exeContext,
Root: p.Root,
Operation: exeContext.Operation,
}
executeOperation(eOperationParams, resultChan)
}