aboutsummaryrefslogtreecommitdiffstats
path: root/graphql/resolvers
diff options
context:
space:
mode:
Diffstat (limited to 'graphql/resolvers')
-rw-r--r--graphql/resolvers/identity.go44
-rw-r--r--graphql/resolvers/mutation.go10
-rw-r--r--graphql/resolvers/person.go37
-rw-r--r--graphql/resolvers/root.go4
4 files changed, 51 insertions, 44 deletions
diff --git a/graphql/resolvers/identity.go b/graphql/resolvers/identity.go
new file mode 100644
index 00000000..d4f9bba2
--- /dev/null
+++ b/graphql/resolvers/identity.go
@@ -0,0 +1,44 @@
+package resolvers
+
+import (
+ "context"
+
+ "github.com/MichaelMure/git-bug/identity"
+)
+
+type identityResolver struct{}
+
+func (identityResolver) ID(ctx context.Context, obj *identity.Interface) (string, error) {
+ return (*obj).Id(), nil
+}
+
+func (identityResolver) Name(ctx context.Context, obj *identity.Interface) (*string, error) {
+ return nilIfEmpty((*obj).Name())
+}
+
+func (identityResolver) Email(ctx context.Context, obj *identity.Interface) (*string, error) {
+ return nilIfEmpty((*obj).Email())
+}
+
+func (identityResolver) Login(ctx context.Context, obj *identity.Interface) (*string, error) {
+ return nilIfEmpty((*obj).Login())
+}
+
+func (identityResolver) DisplayName(ctx context.Context, obj *identity.Interface) (string, error) {
+ return (*obj).DisplayName(), nil
+}
+
+func (identityResolver) AvatarURL(ctx context.Context, obj *identity.Interface) (*string, error) {
+ return nilIfEmpty((*obj).AvatarUrl())
+}
+
+func (identityResolver) IsProtected(ctx context.Context, obj *identity.Interface) (bool, error) {
+ return (*obj).IsProtected(), nil
+}
+
+func nilIfEmpty(s string) (*string, error) {
+ if s == "" {
+ return nil, nil
+ }
+ return &s, nil
+}
diff --git a/graphql/resolvers/mutation.go b/graphql/resolvers/mutation.go
index ee79ce6b..be6956af 100644
--- a/graphql/resolvers/mutation.go
+++ b/graphql/resolvers/mutation.go
@@ -68,7 +68,7 @@ func (r mutationResolver) AddComment(ctx context.Context, repoRef *string, prefi
return bug.Snapshot{}, err
}
- err = b.AddCommentWithFiles(message, files)
+ _, err = b.AddCommentWithFiles(message, files)
if err != nil {
return bug.Snapshot{}, err
}
@@ -89,7 +89,7 @@ func (r mutationResolver) ChangeLabels(ctx context.Context, repoRef *string, pre
return bug.Snapshot{}, err
}
- _, err = b.ChangeLabels(added, removed)
+ _, _, err = b.ChangeLabels(added, removed)
if err != nil {
return bug.Snapshot{}, err
}
@@ -110,7 +110,7 @@ func (r mutationResolver) Open(ctx context.Context, repoRef *string, prefix stri
return bug.Snapshot{}, err
}
- err = b.Open()
+ _, err = b.Open()
if err != nil {
return bug.Snapshot{}, err
}
@@ -131,7 +131,7 @@ func (r mutationResolver) Close(ctx context.Context, repoRef *string, prefix str
return bug.Snapshot{}, err
}
- err = b.Close()
+ _, err = b.Close()
if err != nil {
return bug.Snapshot{}, err
}
@@ -152,7 +152,7 @@ func (r mutationResolver) SetTitle(ctx context.Context, repoRef *string, prefix
return bug.Snapshot{}, err
}
- err = b.SetTitle(title)
+ _, err = b.SetTitle(title)
if err != nil {
return bug.Snapshot{}, err
}
diff --git a/graphql/resolvers/person.go b/graphql/resolvers/person.go
deleted file mode 100644
index bb4bcb0d..00000000
--- a/graphql/resolvers/person.go
+++ /dev/null
@@ -1,37 +0,0 @@
-package resolvers
-
-import (
- "context"
-
- "github.com/MichaelMure/git-bug/bug"
-)
-
-type personResolver struct{}
-
-func (personResolver) Name(ctx context.Context, obj *bug.Person) (*string, error) {
- if obj.Name == "" {
- return nil, nil
- }
- return &obj.Name, nil
-}
-
-func (personResolver) Email(ctx context.Context, obj *bug.Person) (*string, error) {
- if obj.Email == "" {
- return nil, nil
- }
- return &obj.Email, nil
-}
-
-func (personResolver) Login(ctx context.Context, obj *bug.Person) (*string, error) {
- if obj.Login == "" {
- return nil, nil
- }
- return &obj.Login, nil
-}
-
-func (personResolver) AvatarURL(ctx context.Context, obj *bug.Person) (*string, error) {
- if obj.AvatarUrl == "" {
- return nil, nil
- }
- return &obj.AvatarUrl, nil
-}
diff --git a/graphql/resolvers/root.go b/graphql/resolvers/root.go
index d7bd6021..cfdfe346 100644
--- a/graphql/resolvers/root.go
+++ b/graphql/resolvers/root.go
@@ -32,8 +32,8 @@ func (RootResolver) Bug() graph.BugResolver {
return &bugResolver{}
}
-func (r RootResolver) Person() graph.PersonResolver {
- return &personResolver{}
+func (r RootResolver) Identity() graph.IdentityResolver {
+ return &identityResolver{}
}
func (RootResolver) CommentHistoryStep() graph.CommentHistoryStepResolver {