aboutsummaryrefslogtreecommitdiffstats
path: root/graphql/types.go
diff options
context:
space:
mode:
authorMichael Muré <batolettre@gmail.com>2018-07-29 18:58:42 +0200
committerMichael Muré <batolettre@gmail.com>2018-07-29 18:58:42 +0200
commit8fa0b258ac89781dae269790a4bde09cbcd2f324 (patch)
treeb9bcf0826f5739f128de52123447cede23291c02 /graphql/types.go
parent6363518c85cbd8247a5f6507b8a1dd3903cfb71d (diff)
downloadgit-bug-8fa0b258ac89781dae269790a4bde09cbcd2f324.tar.gz
cleaning
Diffstat (limited to 'graphql/types.go')
-rw-r--r--graphql/types.go85
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,
- },
- },
-})