本文整理匯總了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)
}