aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/github.com/graphql-go/graphql/gqlerrors/located.go
diff options
context:
space:
mode:
authorMichael Muré <batolettre@gmail.com>2018-07-19 14:15:50 +0200
committerMichael Muré <batolettre@gmail.com>2018-07-19 14:15:50 +0200
commita2a50f3de0c428c5a61e6a449191be3c4ded86ac (patch)
tree5ecf4f5f1f26933b42a606b741963fa5f66c85aa /vendor/github.com/graphql-go/graphql/gqlerrors/located.go
parent25fb88d7497b00bbe3dda540efde22ffd3de6e49 (diff)
downloadgit-bug-a2a50f3de0c428c5a61e6a449191be3c4ded86ac.tar.gz
webui: add a primitive graphql handler
Diffstat (limited to 'vendor/github.com/graphql-go/graphql/gqlerrors/located.go')
-rw-r--r--vendor/github.com/graphql-go/graphql/gqlerrors/located.go39
1 files changed, 39 insertions, 0 deletions
diff --git a/vendor/github.com/graphql-go/graphql/gqlerrors/located.go b/vendor/github.com/graphql-go/graphql/gqlerrors/located.go
new file mode 100644
index 00000000..b02fcd8a
--- /dev/null
+++ b/vendor/github.com/graphql-go/graphql/gqlerrors/located.go
@@ -0,0 +1,39 @@
+package gqlerrors
+
+import (
+ "errors"
+ "github.com/graphql-go/graphql/language/ast"
+)
+
+// NewLocatedError creates a graphql.Error with location info
+// @deprecated 0.4.18
+// Already exists in `graphql.NewLocatedError()`
+func NewLocatedError(err interface{}, nodes []ast.Node) *Error {
+ var origError error
+ message := "An unknown error occurred."
+ if err, ok := err.(error); ok {
+ message = err.Error()
+ origError = err
+ }
+ if err, ok := err.(string); ok {
+ message = err
+ origError = errors.New(err)
+ }
+ stack := message
+ return NewError(
+ message,
+ nodes,
+ stack,
+ nil,
+ []int{},
+ origError,
+ )
+}
+
+func FieldASTsToNodeASTs(fieldASTs []*ast.Field) []ast.Node {
+ nodes := []ast.Node{}
+ for _, fieldAST := range fieldASTs {
+ nodes = append(nodes, fieldAST)
+ }
+ return nodes
+}