aboutsummaryrefslogtreecommitdiffstats
path: root/graphql
diff options
context:
space:
mode:
Diffstat (limited to 'graphql')
-rw-r--r--graphql/gqlgen.yml2
-rw-r--r--graphql/graph/gen_graph.go135
-rw-r--r--graphql/resolvers/mutation.go9
-rw-r--r--graphql/schema.graphql10
4 files changed, 138 insertions, 18 deletions
diff --git a/graphql/gqlgen.yml b/graphql/gqlgen.yml
index 51c53b62..9be33ef7 100644
--- a/graphql/gqlgen.yml
+++ b/graphql/gqlgen.yml
@@ -17,6 +17,8 @@ models:
model: github.com/MichaelMure/git-bug/bug.Person
Label:
model: github.com/MichaelMure/git-bug/bug.Label
+ Hash:
+ model: github.com/MichaelMure/git-bug/util.Hash
Operation:
model: github.com/MichaelMure/git-bug/bug.Operation
CreateOperation:
diff --git a/graphql/graph/gen_graph.go b/graphql/graph/gen_graph.go
index 63a0c9b5..a9c40e1f 100644
--- a/graphql/graph/gen_graph.go
+++ b/graphql/graph/gen_graph.go
@@ -12,6 +12,7 @@ import (
bug "github.com/MichaelMure/git-bug/bug"
operations "github.com/MichaelMure/git-bug/bug/operations"
models "github.com/MichaelMure/git-bug/graphql/models"
+ util "github.com/MichaelMure/git-bug/util"
graphql "github.com/vektah/gqlgen/graphql"
introspection "github.com/vektah/gqlgen/neelance/introspection"
query "github.com/vektah/gqlgen/neelance/query"
@@ -40,8 +41,8 @@ type Resolvers interface {
LabelChangeOperation_date(ctx context.Context, obj *operations.LabelChangeOperation) (time.Time, error)
- Mutation_newBug(ctx context.Context, repoRef *string, title string, message string) (bug.Snapshot, error)
- Mutation_addComment(ctx context.Context, repoRef *string, prefix string, message string) (bug.Snapshot, error)
+ Mutation_newBug(ctx context.Context, repoRef *string, title string, message string, files []util.Hash) (bug.Snapshot, error)
+ Mutation_addComment(ctx context.Context, repoRef *string, prefix string, message string, files []util.Hash) (bug.Snapshot, error)
Mutation_changeLabels(ctx context.Context, repoRef *string, prefix string, added []string, removed []string) (bug.Snapshot, error)
Mutation_open(ctx context.Context, repoRef *string, prefix string) (bug.Snapshot, error)
Mutation_close(ctx context.Context, repoRef *string, prefix string) (bug.Snapshot, error)
@@ -87,8 +88,8 @@ type LabelChangeOperationResolver interface {
Date(ctx context.Context, obj *operations.LabelChangeOperation) (time.Time, error)
}
type MutationResolver interface {
- NewBug(ctx context.Context, repoRef *string, title string, message string) (bug.Snapshot, error)
- AddComment(ctx context.Context, repoRef *string, prefix string, message string) (bug.Snapshot, error)
+ NewBug(ctx context.Context, repoRef *string, title string, message string, files []util.Hash) (bug.Snapshot, error)
+ AddComment(ctx context.Context, repoRef *string, prefix string, message string, files []util.Hash) (bug.Snapshot, error)
ChangeLabels(ctx context.Context, repoRef *string, prefix string, added []string, removed []string) (bug.Snapshot, error)
Open(ctx context.Context, repoRef *string, prefix string) (bug.Snapshot, error)
Close(ctx context.Context, repoRef *string, prefix string) (bug.Snapshot, error)
@@ -139,12 +140,12 @@ func (s shortMapper) LabelChangeOperation_date(ctx context.Context, obj *operati
return s.r.LabelChangeOperation().Date(ctx, obj)
}
-func (s shortMapper) Mutation_newBug(ctx context.Context, repoRef *string, title string, message string) (bug.Snapshot, error) {
- return s.r.Mutation().NewBug(ctx, repoRef, title, message)
+func (s shortMapper) Mutation_newBug(ctx context.Context, repoRef *string, title string, message string, files []util.Hash) (bug.Snapshot, error) {
+ return s.r.Mutation().NewBug(ctx, repoRef, title, message, files)
}
-func (s shortMapper) Mutation_addComment(ctx context.Context, repoRef *string, prefix string, message string) (bug.Snapshot, error) {
- return s.r.Mutation().AddComment(ctx, repoRef, prefix, message)
+func (s shortMapper) Mutation_addComment(ctx context.Context, repoRef *string, prefix string, message string, files []util.Hash) (bug.Snapshot, error) {
+ return s.r.Mutation().AddComment(ctx, repoRef, prefix, message, files)
}
func (s shortMapper) Mutation_changeLabels(ctx context.Context, repoRef *string, prefix string, added []string, removed []string) (bug.Snapshot, error) {
@@ -264,6 +265,8 @@ func (ec *executionContext) _AddCommentOperation(ctx context.Context, sel []quer
out.Values[i] = ec._AddCommentOperation_date(ctx, field, obj)
case "message":
out.Values[i] = ec._AddCommentOperation_message(ctx, field, obj)
+ case "files":
+ out.Values[i] = ec._AddCommentOperation_files(ctx, field, obj)
default:
panic("unknown field " + strconv.Quote(field.Name))
}
@@ -324,6 +327,26 @@ func (ec *executionContext) _AddCommentOperation_message(ctx context.Context, fi
return graphql.MarshalString(res)
}
+func (ec *executionContext) _AddCommentOperation_files(ctx context.Context, field graphql.CollectedField, obj *operations.AddCommentOperation) graphql.Marshaler {
+ rctx := graphql.GetResolverContext(ctx)
+ rctx.Object = "AddCommentOperation"
+ rctx.Args = nil
+ rctx.Field = field
+ rctx.PushField(field.Alias)
+ defer rctx.Pop()
+ res := obj.Files()
+ arr1 := graphql.Array{}
+ for idx1 := range res {
+ arr1 = append(arr1, func() graphql.Marshaler {
+ rctx := graphql.GetResolverContext(ctx)
+ rctx.PushIndex(idx1)
+ defer rctx.Pop()
+ return res[idx1]
+ }())
+ }
+ return arr1
+}
+
var bugImplementors = []string{"Bug"}
// nolint: gocyclo, errcheck, gas, goconst
@@ -818,6 +841,8 @@ func (ec *executionContext) _Comment(ctx context.Context, sel []query.Selection,
out.Values[i] = ec._Comment_author(ctx, field, obj)
case "message":
out.Values[i] = ec._Comment_message(ctx, field, obj)
+ case "files":
+ out.Values[i] = ec._Comment_files(ctx, field, obj)
default:
panic("unknown field " + strconv.Quote(field.Name))
}
@@ -848,6 +873,26 @@ func (ec *executionContext) _Comment_message(ctx context.Context, field graphql.
return graphql.MarshalString(res)
}
+func (ec *executionContext) _Comment_files(ctx context.Context, field graphql.CollectedField, obj *bug.Comment) graphql.Marshaler {
+ rctx := graphql.GetResolverContext(ctx)
+ rctx.Object = "Comment"
+ rctx.Args = nil
+ rctx.Field = field
+ rctx.PushField(field.Alias)
+ defer rctx.Pop()
+ res := obj.Files
+ arr1 := graphql.Array{}
+ for idx1 := range res {
+ arr1 = append(arr1, func() graphql.Marshaler {
+ rctx := graphql.GetResolverContext(ctx)
+ rctx.PushIndex(idx1)
+ defer rctx.Pop()
+ return res[idx1]
+ }())
+ }
+ return arr1
+}
+
var commentConnectionImplementors = []string{"CommentConnection"}
// nolint: gocyclo, errcheck, gas, goconst
@@ -1007,6 +1052,8 @@ func (ec *executionContext) _CreateOperation(ctx context.Context, sel []query.Se
out.Values[i] = ec._CreateOperation_title(ctx, field, obj)
case "message":
out.Values[i] = ec._CreateOperation_message(ctx, field, obj)
+ case "files":
+ out.Values[i] = ec._CreateOperation_files(ctx, field, obj)
default:
panic("unknown field " + strconv.Quote(field.Name))
}
@@ -1078,6 +1125,26 @@ func (ec *executionContext) _CreateOperation_message(ctx context.Context, field
return graphql.MarshalString(res)
}
+func (ec *executionContext) _CreateOperation_files(ctx context.Context, field graphql.CollectedField, obj *operations.CreateOperation) graphql.Marshaler {
+ rctx := graphql.GetResolverContext(ctx)
+ rctx.Object = "CreateOperation"
+ rctx.Args = nil
+ rctx.Field = field
+ rctx.PushField(field.Alias)
+ defer rctx.Pop()
+ res := obj.Files()
+ arr1 := graphql.Array{}
+ for idx1 := range res {
+ arr1 = append(arr1, func() graphql.Marshaler {
+ rctx := graphql.GetResolverContext(ctx)
+ rctx.PushIndex(idx1)
+ defer rctx.Pop()
+ return res[idx1]
+ }())
+ }
+ return arr1
+}
+
var labelChangeOperationImplementors = []string{"LabelChangeOperation", "Operation", "Authored"}
// nolint: gocyclo, errcheck, gas, goconst
@@ -1264,6 +1331,25 @@ func (ec *executionContext) _Mutation_newBug(ctx context.Context, field graphql.
}
}
args["message"] = arg2
+ var arg3 []util.Hash
+ if tmp, ok := field.Args["files"]; ok {
+ var err error
+ var rawIf1 []interface{}
+ if tmp != nil {
+ if tmp1, ok := tmp.([]interface{}); ok {
+ rawIf1 = tmp1
+ }
+ }
+ arg3 = make([]util.Hash, len(rawIf1))
+ for idx1 := range rawIf1 {
+ err = (&arg3[idx1]).UnmarshalGQL(rawIf1[idx1])
+ }
+ if err != nil {
+ ec.Error(ctx, err)
+ return graphql.Null
+ }
+ }
+ args["files"] = arg3
rctx := graphql.GetResolverContext(ctx)
rctx.Object = "Mutation"
rctx.Args = args
@@ -1271,7 +1357,7 @@ func (ec *executionContext) _Mutation_newBug(ctx context.Context, field graphql.
rctx.PushField(field.Alias)
defer rctx.Pop()
resTmp, err := ec.ResolverMiddleware(ctx, func(ctx context.Context) (interface{}, error) {
- return ec.resolvers.Mutation_newBug(ctx, args["repoRef"].(*string), args["title"].(string), args["message"].(string))
+ return ec.resolvers.Mutation_newBug(ctx, args["repoRef"].(*string), args["title"].(string), args["message"].(string), args["files"].([]util.Hash))
})
if err != nil {
ec.Error(ctx, err)
@@ -1321,6 +1407,25 @@ func (ec *executionContext) _Mutation_addComment(ctx context.Context, field grap
}
}
args["message"] = arg2
+ var arg3 []util.Hash
+ if tmp, ok := field.Args["files"]; ok {
+ var err error
+ var rawIf1 []interface{}
+ if tmp != nil {
+ if tmp1, ok := tmp.([]interface{}); ok {
+ rawIf1 = tmp1
+ }
+ }
+ arg3 = make([]util.Hash, len(rawIf1))
+ for idx1 := range rawIf1 {
+ err = (&arg3[idx1]).UnmarshalGQL(rawIf1[idx1])
+ }
+ if err != nil {
+ ec.Error(ctx, err)
+ return graphql.Null
+ }
+ }
+ args["files"] = arg3
rctx := graphql.GetResolverContext(ctx)
rctx.Object = "Mutation"
rctx.Args = args
@@ -1328,7 +1433,7 @@ func (ec *executionContext) _Mutation_addComment(ctx context.Context, field grap
rctx.PushField(field.Alias)
defer rctx.Pop()
resTmp, err := ec.ResolverMiddleware(ctx, func(ctx context.Context) (interface{}, error) {
- return ec.resolvers.Mutation_addComment(ctx, args["repoRef"].(*string), args["prefix"].(string), args["message"].(string))
+ return ec.resolvers.Mutation_addComment(ctx, args["repoRef"].(*string), args["prefix"].(string), args["message"].(string), args["files"].([]util.Hash))
})
if err != nil {
ec.Error(ctx, err)
@@ -3108,6 +3213,7 @@ func (ec *executionContext) introspectType(name string) *introspection.Type {
var parsedSchema = schema.MustParse(`scalar Time
scalar Label
+scalar Hash
# Information about pagination in a connection.
type PageInfo {
@@ -3149,6 +3255,9 @@ type Comment implements Authored {
# The message of this comment.
message: String!
+
+ # All media's hash referenced in this comment
+ files: [Hash!]!
}
enum Status {
@@ -3188,6 +3297,7 @@ type CreateOperation implements Operation, Authored {
title: String!
message: String!
+ files: [Hash!]!
}
type SetTitleOperation implements Operation, Authored {
@@ -3202,6 +3312,7 @@ type AddCommentOperation implements Operation, Authored {
date: Time!
message: String!
+ files: [Hash!]!
}
type SetStatusOperation implements Operation, Authored {
@@ -3291,9 +3402,9 @@ type Query {
}
type Mutation {
- newBug(repoRef: String, title: String!, message: String!): Bug!
+ newBug(repoRef: String, title: String!, message: String!, files: [Hash!]): Bug!
- addComment(repoRef: String, prefix: String!, message: String!): Bug!
+ addComment(repoRef: String, prefix: String!, message: String!, files: [Hash!]): Bug!
changeLabels(repoRef: String, prefix: String!, added: [String!], removed: [String!]): Bug!
open(repoRef: String, prefix: String!): Bug!
close(repoRef: String, prefix: String!): Bug!
diff --git a/graphql/resolvers/mutation.go b/graphql/resolvers/mutation.go
index a85459f2..2a81716c 100644
--- a/graphql/resolvers/mutation.go
+++ b/graphql/resolvers/mutation.go
@@ -5,6 +5,7 @@ import (
"github.com/MichaelMure/git-bug/bug"
"github.com/MichaelMure/git-bug/cache"
+ "github.com/MichaelMure/git-bug/util"
)
type mutationResolver struct {
@@ -19,13 +20,13 @@ func (r mutationResolver) getRepo(repoRef *string) (cache.RepoCacher, error) {
return r.cache.DefaultRepo()
}
-func (r mutationResolver) NewBug(ctx context.Context, repoRef *string, title string, message string) (bug.Snapshot, error) {
+func (r mutationResolver) NewBug(ctx context.Context, repoRef *string, title string, message string, files []util.Hash) (bug.Snapshot, error) {
repo, err := r.getRepo(repoRef)
if err != nil {
return bug.Snapshot{}, err
}
- b, err := repo.NewBug(title, message)
+ b, err := repo.NewBugWithFiles(title, message, files)
if err != nil {
return bug.Snapshot{}, err
}
@@ -56,7 +57,7 @@ func (r mutationResolver) Commit(ctx context.Context, repoRef *string, prefix st
return *snap, nil
}
-func (r mutationResolver) AddComment(ctx context.Context, repoRef *string, prefix string, message string) (bug.Snapshot, error) {
+func (r mutationResolver) AddComment(ctx context.Context, repoRef *string, prefix string, message string, files []util.Hash) (bug.Snapshot, error) {
repo, err := r.getRepo(repoRef)
if err != nil {
return bug.Snapshot{}, err
@@ -67,7 +68,7 @@ func (r mutationResolver) AddComment(ctx context.Context, repoRef *string, prefi
return bug.Snapshot{}, err
}
- err = b.AddComment(message)
+ err = b.AddCommentWithFiles(message, files)
if err != nil {
return bug.Snapshot{}, err
}
diff --git a/graphql/schema.graphql b/graphql/schema.graphql
index 410ecde9..d4364262 100644
--- a/graphql/schema.graphql
+++ b/graphql/schema.graphql
@@ -1,5 +1,6 @@
scalar Time
scalar Label
+scalar Hash
# Information about pagination in a connection.
type PageInfo {
@@ -41,6 +42,9 @@ type Comment implements Authored {
# The message of this comment.
message: String!
+
+ # All media's hash referenced in this comment
+ files: [Hash!]!
}
enum Status {
@@ -80,6 +84,7 @@ type CreateOperation implements Operation, Authored {
title: String!
message: String!
+ files: [Hash!]!
}
type SetTitleOperation implements Operation, Authored {
@@ -94,6 +99,7 @@ type AddCommentOperation implements Operation, Authored {
date: Time!
message: String!
+ files: [Hash!]!
}
type SetStatusOperation implements Operation, Authored {
@@ -183,9 +189,9 @@ type Query {
}
type Mutation {
- newBug(repoRef: String, title: String!, message: String!): Bug!
+ newBug(repoRef: String, title: String!, message: String!, files: [Hash!]): Bug!
- addComment(repoRef: String, prefix: String!, message: String!): Bug!
+ addComment(repoRef: String, prefix: String!, message: String!, files: [Hash!]): Bug!
changeLabels(repoRef: String, prefix: String!, added: [String!], removed: [String!]): Bug!
open(repoRef: String, prefix: String!): Bug!
close(repoRef: String, prefix: String!): Bug!