diff options
author | Michael Muré <batolettre@gmail.com> | 2018-07-29 18:58:42 +0200 |
---|---|---|
committer | Michael Muré <batolettre@gmail.com> | 2018-07-29 18:58:42 +0200 |
commit | 8fa0b258ac89781dae269790a4bde09cbcd2f324 (patch) | |
tree | b9bcf0826f5739f128de52123447cede23291c02 /graphql/types.go | |
parent | 6363518c85cbd8247a5f6507b8a1dd3903cfb71d (diff) | |
download | git-bug-8fa0b258ac89781dae269790a4bde09cbcd2f324.tar.gz |
cleaning
Diffstat (limited to 'graphql/types.go')
-rw-r--r-- | graphql/types.go | 85 |
1 files changed, 0 insertions, 85 deletions
diff --git a/graphql/types.go b/graphql/types.go deleted file mode 100644 index f1161687..00000000 --- a/graphql/types.go +++ /dev/null @@ -1,85 +0,0 @@ -package graphql - -import ( - "fmt" - - "github.com/graphql-go/graphql" - "github.com/graphql-go/graphql/language/ast" - - "github.com/MichaelMure/git-bug/bug" -) - -func coerceString(value interface{}) interface{} { - if v, ok := value.(*string); ok { - return *v - } - return fmt.Sprintf("%v", value) -} - -var bugIdScalar = graphql.NewScalar(graphql.ScalarConfig{ - Name: "BugID", - Description: "TODO", - Serialize: coerceString, - ParseValue: coerceString, - ParseLiteral: func(valueAST ast.Value) interface{} { - switch valueAST := valueAST.(type) { - case *ast.StringValue: - return valueAST.Value - } - return nil - }, -}) - -// Internally, it's the Snapshot -var bugType = graphql.NewObject(graphql.ObjectConfig{ - Name: "Bug", - Fields: graphql.Fields{ - "id": &graphql.Field{ - Type: bugIdScalar, - Resolve: func(p graphql.ResolveParams) (interface{}, error) { - return p.Source.(bug.Snapshot).Id(), nil - }, - }, - "status": &graphql.Field{ - Type: graphql.String, - }, - "title": &graphql.Field{ - Type: graphql.String, - }, - "comments": &graphql.Field{ - Type: graphql.NewList(commentType), - }, - "labels": &graphql.Field{ - Type: graphql.NewList(graphql.String), - Resolve: func(p graphql.ResolveParams) (interface{}, error) { - return p.Source.(bug.Snapshot).Labels, nil - }, - }, - // TODO: operations - }, -}) - -var commentType = graphql.NewObject(graphql.ObjectConfig{ - Name: "Comment", - Fields: graphql.Fields{ - "author": &graphql.Field{ - Type: personType, - }, - "message": &graphql.Field{ - Type: graphql.String, - }, - // TODO: time - }, -}) - -var personType = graphql.NewObject(graphql.ObjectConfig{ - Name: "Person", - Fields: graphql.Fields{ - "name": &graphql.Field{ - Type: graphql.String, - }, - "email": &graphql.Field{ - Type: graphql.String, - }, - }, -}) |