aboutsummaryrefslogtreecommitdiffstats
path: root/graphql
diff options
context:
space:
mode:
authorMichael Muré <batolettre@gmail.com>2018-10-07 18:27:23 +0200
committerMichael Muré <batolettre@gmail.com>2018-10-07 18:27:23 +0200
commit7cb7994cdae848053487d00c1730d1e865fb8623 (patch)
treebc9be185e81479d8d3e5b0fc636daea011a64e4c /graphql
parent03202fed493539c8d1fdcad7254687f951d0ca4a (diff)
downloadgit-bug-7cb7994cdae848053487d00c1730d1e865fb8623.tar.gz
github: also pull users email
Diffstat (limited to 'graphql')
-rw-r--r--graphql/gqlgen.yml11
-rw-r--r--graphql/graph/gen_graph.go149
-rw-r--r--graphql/resolvers/root.go4
-rw-r--r--graphql/schema.graphql12
4 files changed, 151 insertions, 25 deletions
diff --git a/graphql/gqlgen.yml b/graphql/gqlgen.yml
index 3932eafe..19bf686e 100644
--- a/graphql/gqlgen.yml
+++ b/graphql/gqlgen.yml
@@ -15,6 +15,15 @@ models:
model: github.com/MichaelMure/git-bug/bug.Comment
Person:
model: github.com/MichaelMure/git-bug/bug.Person
+ fields:
+ name:
+ resolver: true
+ email:
+ resolver: true
+ login:
+ resolver: true
+ avatarUrl:
+ resolver: true
Label:
model: github.com/MichaelMure/git-bug/bug.Label
Hash:
@@ -27,6 +36,8 @@ models:
model: github.com/MichaelMure/git-bug/bug.SetTitleOperation
AddCommentOperation:
model: github.com/MichaelMure/git-bug/bug.AddCommentOperation
+ EditCommentOperation:
+ model: github.com/MichaelMure/git-bug/bug.EditCommentOperation
SetStatusOperation:
model: github.com/MichaelMure/git-bug/bug.SetStatusOperation
LabelChangeOperation:
diff --git a/graphql/graph/gen_graph.go b/graphql/graph/gen_graph.go
index 7478383e..82862d69 100644
--- a/graphql/graph/gen_graph.go
+++ b/graphql/graph/gen_graph.go
@@ -45,6 +45,7 @@ type ResolverRoot interface {
LabelChangeOperation() LabelChangeOperationResolver
LabelChangeTimelineItem() LabelChangeTimelineItemResolver
Mutation() MutationResolver
+ Person() PersonResolver
Query() QueryResolver
Repository() RepositoryResolver
SetStatusOperation() SetStatusOperationResolver
@@ -200,9 +201,11 @@ type ComplexityRoot struct {
}
Person struct {
- Email func(childComplexity int) int
- Name func(childComplexity int) int
- AvatarUrl func(childComplexity int) int
+ Name func(childComplexity int) int
+ Email func(childComplexity int) int
+ Login func(childComplexity int) int
+ DisplayName func(childComplexity int) int
+ AvatarUrl func(childComplexity int) int
}
Query struct {
@@ -301,6 +304,13 @@ type MutationResolver interface {
SetTitle(ctx context.Context, repoRef *string, prefix string, title string) (bug.Snapshot, error)
Commit(ctx context.Context, repoRef *string, prefix string) (bug.Snapshot, error)
}
+type PersonResolver interface {
+ Name(ctx context.Context, obj *bug.Person) (*string, error)
+ Email(ctx context.Context, obj *bug.Person) (*string, error)
+ Login(ctx context.Context, obj *bug.Person) (*string, error)
+
+ AvatarURL(ctx context.Context, obj *bug.Person) (*string, error)
+}
type QueryResolver interface {
DefaultRepository(ctx context.Context) (*models.Repository, error)
Repository(ctx context.Context, id string) (*models.Repository, error)
@@ -1650,6 +1660,13 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in
return e.complexity.PageInfo.EndCursor(childComplexity), true
+ case "Person.name":
+ if e.complexity.Person.Name == nil {
+ break
+ }
+
+ return e.complexity.Person.Name(childComplexity), true
+
case "Person.email":
if e.complexity.Person.Email == nil {
break
@@ -1657,12 +1674,19 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in
return e.complexity.Person.Email(childComplexity), true
- case "Person.name":
- if e.complexity.Person.Name == nil {
+ case "Person.login":
+ if e.complexity.Person.Login == nil {
break
}
- return e.complexity.Person.Name(childComplexity), true
+ return e.complexity.Person.Login(childComplexity), true
+
+ case "Person.displayName":
+ if e.complexity.Person.DisplayName == nil {
+ break
+ }
+
+ return e.complexity.Person.DisplayName(childComplexity), true
case "Person.avatarUrl":
if e.complexity.Person.AvatarUrl == nil {
@@ -5280,6 +5304,7 @@ var personImplementors = []string{"Person"}
func (ec *executionContext) _Person(ctx context.Context, sel ast.SelectionSet, obj *bug.Person) graphql.Marshaler {
fields := graphql.CollectFields(ctx, sel, personImplementors)
+ var wg sync.WaitGroup
out := graphql.NewOrderedMap(len(fields))
invalid := false
for i, field := range fields {
@@ -5288,20 +5313,40 @@ func (ec *executionContext) _Person(ctx context.Context, sel ast.SelectionSet, o
switch field.Name {
case "__typename":
out.Values[i] = graphql.MarshalString("Person")
- case "email":
- out.Values[i] = ec._Person_email(ctx, field, obj)
case "name":
- out.Values[i] = ec._Person_name(ctx, field, obj)
+ wg.Add(1)
+ go func(i int, field graphql.CollectedField) {
+ out.Values[i] = ec._Person_name(ctx, field, obj)
+ wg.Done()
+ }(i, field)
+ case "email":
+ wg.Add(1)
+ go func(i int, field graphql.CollectedField) {
+ out.Values[i] = ec._Person_email(ctx, field, obj)
+ wg.Done()
+ }(i, field)
+ case "login":
+ wg.Add(1)
+ go func(i int, field graphql.CollectedField) {
+ out.Values[i] = ec._Person_login(ctx, field, obj)
+ wg.Done()
+ }(i, field)
+ case "displayName":
+ out.Values[i] = ec._Person_displayName(ctx, field, obj)
if out.Values[i] == graphql.Null {
invalid = true
}
case "avatarUrl":
- out.Values[i] = ec._Person_avatarUrl(ctx, field, obj)
+ wg.Add(1)
+ go func(i int, field graphql.CollectedField) {
+ out.Values[i] = ec._Person_avatarUrl(ctx, field, obj)
+ wg.Done()
+ }(i, field)
default:
panic("unknown field " + strconv.Quote(field.Name))
}
}
-
+ wg.Wait()
if invalid {
return graphql.Null
}
@@ -5309,6 +5354,29 @@ func (ec *executionContext) _Person(ctx context.Context, sel ast.SelectionSet, o
}
// nolint: vetshadow
+func (ec *executionContext) _Person_name(ctx context.Context, field graphql.CollectedField, obj *bug.Person) graphql.Marshaler {
+ rctx := &graphql.ResolverContext{
+ Object: "Person",
+ Args: nil,
+ Field: field,
+ }
+ ctx = graphql.WithResolverContext(ctx, rctx)
+ resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) {
+ return ec.resolvers.Person().Name(ctx, obj)
+ })
+ if resTmp == nil {
+ return graphql.Null
+ }
+ res := resTmp.(*string)
+ rctx.Result = res
+
+ if res == nil {
+ return graphql.Null
+ }
+ return graphql.MarshalString(*res)
+}
+
+// nolint: vetshadow
func (ec *executionContext) _Person_email(ctx context.Context, field graphql.CollectedField, obj *bug.Person) graphql.Marshaler {
rctx := &graphql.ResolverContext{
Object: "Person",
@@ -5317,18 +5385,22 @@ func (ec *executionContext) _Person_email(ctx context.Context, field graphql.Col
}
ctx = graphql.WithResolverContext(ctx, rctx)
resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) {
- return obj.Email, nil
+ return ec.resolvers.Person().Email(ctx, obj)
})
if resTmp == nil {
return graphql.Null
}
- res := resTmp.(string)
+ res := resTmp.(*string)
rctx.Result = res
- return graphql.MarshalString(res)
+
+ if res == nil {
+ return graphql.Null
+ }
+ return graphql.MarshalString(*res)
}
// nolint: vetshadow
-func (ec *executionContext) _Person_name(ctx context.Context, field graphql.CollectedField, obj *bug.Person) graphql.Marshaler {
+func (ec *executionContext) _Person_login(ctx context.Context, field graphql.CollectedField, obj *bug.Person) graphql.Marshaler {
rctx := &graphql.ResolverContext{
Object: "Person",
Args: nil,
@@ -5336,7 +5408,30 @@ func (ec *executionContext) _Person_name(ctx context.Context, field graphql.Coll
}
ctx = graphql.WithResolverContext(ctx, rctx)
resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) {
- return obj.Name, nil
+ return ec.resolvers.Person().Login(ctx, obj)
+ })
+ if resTmp == nil {
+ return graphql.Null
+ }
+ res := resTmp.(*string)
+ rctx.Result = res
+
+ if res == nil {
+ return graphql.Null
+ }
+ return graphql.MarshalString(*res)
+}
+
+// nolint: vetshadow
+func (ec *executionContext) _Person_displayName(ctx context.Context, field graphql.CollectedField, obj *bug.Person) graphql.Marshaler {
+ rctx := &graphql.ResolverContext{
+ Object: "Person",
+ Args: nil,
+ Field: field,
+ }
+ ctx = graphql.WithResolverContext(ctx, rctx)
+ resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) {
+ return obj.DisplayName(), nil
})
if resTmp == nil {
if !ec.HasError(rctx) {
@@ -5358,14 +5453,18 @@ func (ec *executionContext) _Person_avatarUrl(ctx context.Context, field graphql
}
ctx = graphql.WithResolverContext(ctx, rctx)
resTmp := ec.FieldMiddleware(ctx, obj, func(ctx context.Context) (interface{}, error) {
- return obj.AvatarUrl, nil
+ return ec.resolvers.Person().AvatarURL(ctx, obj)
})
if resTmp == nil {
return graphql.Null
}
- res := resTmp.(string)
+ res := resTmp.(*string)
rctx.Result = res
- return graphql.MarshalString(res)
+
+ if res == nil {
+ return graphql.Null
+ }
+ return graphql.MarshalString(*res)
}
var queryImplementors = []string{"Query"}
@@ -7922,11 +8021,17 @@ type PageInfo {
"""Represents an person in a git object."""
type Person {
- """The email of the person."""
+ """The name of the person, if known."""
+ name: String
+
+ """The email of the person, if known."""
email: String
- """The name of the person."""
- name: String!
+ """The login of the person, if known."""
+ login: String
+
+ """A string containing the either the name of the person, its login or both"""
+ displayName: String!
"""An url to an avatar"""
avatarUrl: String
diff --git a/graphql/resolvers/root.go b/graphql/resolvers/root.go
index 9b3a730b..d7bd6021 100644
--- a/graphql/resolvers/root.go
+++ b/graphql/resolvers/root.go
@@ -32,6 +32,10 @@ func (RootResolver) Bug() graph.BugResolver {
return &bugResolver{}
}
+func (r RootResolver) Person() graph.PersonResolver {
+ return &personResolver{}
+}
+
func (RootResolver) CommentHistoryStep() graph.CommentHistoryStepResolver {
return &commentHistoryStepResolver{}
}
diff --git a/graphql/schema.graphql b/graphql/schema.graphql
index c187ce49..fefe895b 100644
--- a/graphql/schema.graphql
+++ b/graphql/schema.graphql
@@ -16,11 +16,17 @@ type PageInfo {
"""Represents an person in a git object."""
type Person {
- """The email of the person."""
+ """The name of the person, if known."""
+ name: String
+
+ """The email of the person, if known."""
email: String
- """The name of the person."""
- name: String!
+ """The login of the person, if known."""
+ login: String
+
+ """A string containing the either the name of the person, its login or both"""
+ displayName: String!
"""An url to an avatar"""
avatarUrl: String