aboutsummaryrefslogtreecommitdiffstats
path: root/graphql
diff options
context:
space:
mode:
authorMichael Muré <batolettre@gmail.com>2020-02-12 21:03:20 +0100
committerMichael Muré <batolettre@gmail.com>2020-02-12 21:03:20 +0100
commit929480fa0a7fa40ba14850aed17158a20cdf6391 (patch)
tree7bc0579469f936a9378be0b4c95fc149b1df5efe /graphql
parentb70b4ba4b17d02d9744bd72494549f5cf7d980f8 (diff)
downloadgit-bug-929480fa0a7fa40ba14850aed17158a20cdf6391.tar.gz
graphql: expose the name of Repository
Diffstat (limited to 'graphql')
-rw-r--r--graphql/graph/gen_graph.go56
-rw-r--r--graphql/resolvers/repo.go7
-rw-r--r--graphql/schema/repository.graphql5
3 files changed, 65 insertions, 3 deletions
diff --git a/graphql/graph/gen_graph.go b/graphql/graph/gen_graph.go
index ba1eb7e9..e9cb2486 100644
--- a/graphql/graph/gen_graph.go
+++ b/graphql/graph/gen_graph.go
@@ -314,6 +314,7 @@ type ComplexityRoot struct {
AllIdentities func(childComplexity int, after *string, before *string, first *int, last *int) int
Bug func(childComplexity int, prefix string) int
Identity func(childComplexity int, prefix string) int
+ Name func(childComplexity int) int
UserIdentity func(childComplexity int) int
ValidLabels func(childComplexity int, after *string, before *string, first *int, last *int) int
}
@@ -454,6 +455,7 @@ type QueryResolver interface {
Repository(ctx context.Context, ref *string) (*models.Repository, error)
}
type RepositoryResolver interface {
+ Name(ctx context.Context, obj *models.Repository) (*string, error)
AllBugs(ctx context.Context, obj *models.Repository, after *string, before *string, first *int, last *int, query *string) (*models.BugConnection, error)
Bug(ctx context.Context, obj *models.Repository, prefix string) (models.BugWrapper, error)
AllIdentities(ctx context.Context, obj *models.Repository, after *string, before *string, first *int, last *int) (*models.IdentityConnection, error)
@@ -1597,6 +1599,13 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in
return e.complexity.Repository.Identity(childComplexity, args["prefix"].(string)), true
+ case "Repository.name":
+ if e.complexity.Repository.Name == nil {
+ break
+ }
+
+ return e.complexity.Repository.Name(childComplexity), true
+
case "Repository.userIdentity":
if e.complexity.Repository.UserIdentity == nil {
break
@@ -2311,6 +2320,9 @@ type LabelChangeOperation implements Operation & Authored {
`, BuiltIn: false},
&ast.Source{Name: "schema/repository.graphql", Input: `
type Repository {
+ """The name of the repository"""
+ name: String
+
"""All the bugs"""
allBugs(
"""Returns the elements in the list that come after the specified cursor."""
@@ -2321,7 +2333,7 @@ type Repository {
first: Int
"""Returns the last _n_ elements from the list."""
last: Int
- """A query to select and order bugs"""
+ """A query to select and order bugs."""
query: String
): BugConnection!
@@ -7915,6 +7927,37 @@ func (ec *executionContext) _Query___schema(ctx context.Context, field graphql.C
return ec.marshalO__Schema2ᚖgithubᚗcomᚋ99designsᚋgqlgenᚋgraphqlᚋintrospectionᚐSchema(ctx, field.Selections, res)
}
+func (ec *executionContext) _Repository_name(ctx context.Context, field graphql.CollectedField, obj *models.Repository) (ret graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ ret = graphql.Null
+ }
+ }()
+ fc := &graphql.FieldContext{
+ Object: "Repository",
+ Field: field,
+ Args: nil,
+ IsMethod: true,
+ }
+
+ ctx = graphql.WithFieldContext(ctx, fc)
+ resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) {
+ ctx = rctx // use context from middleware stack in children
+ return ec.resolvers.Repository().Name(rctx, obj)
+ })
+ if err != nil {
+ ec.Error(ctx, err)
+ return graphql.Null
+ }
+ if resTmp == nil {
+ return graphql.Null
+ }
+ res := resTmp.(*string)
+ fc.Result = res
+ return ec.marshalOString2ᚖstring(ctx, field.Selections, res)
+}
+
func (ec *executionContext) _Repository_allBugs(ctx context.Context, field graphql.CollectedField, obj *models.Repository) (ret graphql.Marshaler) {
defer func() {
if r := recover(); r != nil {
@@ -12385,6 +12428,17 @@ func (ec *executionContext) _Repository(ctx context.Context, sel ast.SelectionSe
switch field.Name {
case "__typename":
out.Values[i] = graphql.MarshalString("Repository")
+ case "name":
+ field := field
+ out.Concurrently(i, func() (res graphql.Marshaler) {
+ defer func() {
+ if r := recover(); r != nil {
+ ec.Error(ctx, ec.Recover(ctx, r))
+ }
+ }()
+ res = ec._Repository_name(ctx, field, obj)
+ return res
+ })
case "allBugs":
field := field
out.Concurrently(i, func() (res graphql.Marshaler) {
diff --git a/graphql/resolvers/repo.go b/graphql/resolvers/repo.go
index 3b0aa9a1..d090544d 100644
--- a/graphql/resolvers/repo.go
+++ b/graphql/resolvers/repo.go
@@ -15,6 +15,11 @@ var _ graph.RepositoryResolver = &repoResolver{}
type repoResolver struct{}
+func (repoResolver) Name(_ context.Context, obj *models.Repository) (*string, error) {
+ name := obj.Repo.Name()
+ return &name, nil
+}
+
func (repoResolver) AllBugs(_ context.Context, obj *models.Repository, after *string, before *string, first *int, last *int, queryStr *string) (*models.BugConnection, error) {
input := models.ConnectionInput{
Before: before,
@@ -153,7 +158,7 @@ func (repoResolver) UserIdentity(_ context.Context, obj *models.Repository) (mod
return models.NewLazyIdentity(obj.Repo, excerpt), nil
}
-func (resolver repoResolver) ValidLabels(_ context.Context, obj *models.Repository, after *string, before *string, first *int, last *int) (*models.LabelConnection, error) {
+func (repoResolver) ValidLabels(_ context.Context, obj *models.Repository, after *string, before *string, first *int, last *int) (*models.LabelConnection, error) {
input := models.ConnectionInput{
Before: before,
After: after,
diff --git a/graphql/schema/repository.graphql b/graphql/schema/repository.graphql
index 20a3cf0b..2b98fe37 100644
--- a/graphql/schema/repository.graphql
+++ b/graphql/schema/repository.graphql
@@ -1,5 +1,8 @@
type Repository {
+ """The name of the repository"""
+ name: String
+
"""All the bugs"""
allBugs(
"""Returns the elements in the list that come after the specified cursor."""
@@ -10,7 +13,7 @@ type Repository {
first: Int
"""Returns the last _n_ elements from the list."""
last: Int
- """A query to select and order bugs"""
+ """A query to select and order bugs."""
query: String
): BugConnection!