aboutsummaryrefslogtreecommitdiffstats
path: root/graphql
diff options
context:
space:
mode:
authorMichael Muré <batolettre@gmail.com>2018-07-22 10:06:40 +0200
committerGitHub <noreply@github.com>2018-07-22 10:06:40 +0200
commite1f597639bfc2f796f74afa87e41581087f0b26e (patch)
tree4bf2bcb127924ed3265c68bd9beb4baa24def432 /graphql
parent94623b2a82485e573005fc52441dcdbe79f8d026 (diff)
parent6d8559048f9dcbac4ee9f65de54bda4cd1a7431c (diff)
downloadgit-bug-e1f597639bfc2f796f74afa87e41581087f0b26e.tar.gz
Merge pull request #3 from MichaelMure/ui
WIP: Web UI
Diffstat (limited to 'graphql')
-rw-r--r--graphql/schema.go26
-rw-r--r--graphql/types.go3
2 files changed, 29 insertions, 0 deletions
diff --git a/graphql/schema.go b/graphql/schema.go
index 4cb893fe..7419e98a 100644
--- a/graphql/schema.go
+++ b/graphql/schema.go
@@ -28,6 +28,32 @@ func graphqlSchema() (graphql.Schema, error) {
return snapshot, nil
},
},
+ // TODO: provide a relay-like schema with pagination
+ "allBugs": &graphql.Field{
+ Type: graphql.NewList(bugType),
+ Resolve: func(p graphql.ResolveParams) (interface{}, error) {
+ repo := p.Context.Value("repo").(repository.Repo)
+ ids, err := repo.ListRefs(bug.BugsRefPattern)
+
+ if err != nil {
+ return nil, err
+ }
+
+ var snapshots []bug.Snapshot
+
+ for _, ref := range ids {
+ bug, err := bug.ReadBug(repo, bug.BugsRefPattern+ref)
+
+ if err != nil {
+ return nil, err
+ }
+
+ snapshots = append(snapshots, bug.Compile())
+ }
+
+ return snapshots, nil
+ },
+ },
}
rootQuery := graphql.ObjectConfig{Name: "RootQuery", Fields: fields}
schemaConfig := graphql.SchemaConfig{Query: graphql.NewObject(rootQuery)}
diff --git a/graphql/types.go b/graphql/types.go
index a320ca39..f1161687 100644
--- a/graphql/types.go
+++ b/graphql/types.go
@@ -43,6 +43,9 @@ var bugType = graphql.NewObject(graphql.ObjectConfig{
"status": &graphql.Field{
Type: graphql.String,
},
+ "title": &graphql.Field{
+ Type: graphql.String,
+ },
"comments": &graphql.Field{
Type: graphql.NewList(commentType),
},