Skip to content

Commit 929480f

Browse files
committed
graphql: expose the name of Repository
1 parent b70b4ba commit 929480f

File tree

4 files changed

+77
-3
lines changed

4 files changed

+77
-3
lines changed

cache/repo_cache.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,9 @@ type RepoCache struct {
5858
// the underlying repo
5959
repo repository.ClockedRepo
6060

61+
// the name of the repository, as defined in the MultiRepoCache
62+
name string
63+
6164
muBug sync.RWMutex
6265
// excerpt of bugs data for all bugs
6366
bugExcerpts map[entity.Id]*BugExcerpt
@@ -75,8 +78,13 @@ type RepoCache struct {
7578
}
7679

7780
func NewRepoCache(r repository.ClockedRepo) (*RepoCache, error) {
81+
return NewNamedRepoCache(r, "")
82+
}
83+
84+
func NewNamedRepoCache(r repository.ClockedRepo, name string) (*RepoCache, error) {
7885
c := &RepoCache{
7986
repo: r,
87+
name: name,
8088
bugs: make(map[entity.Id]*BugCache),
8189
identities: make(map[entity.Id]*IdentityCache),
8290
}
@@ -102,6 +110,10 @@ func NewRepoCache(r repository.ClockedRepo) (*RepoCache, error) {
102110
return c, c.write()
103111
}
104112

113+
func (c *RepoCache) Name() string {
114+
return c.name
115+
}
116+
105117
// LocalConfig give access to the repository scoped configuration
106118
func (c *RepoCache) LocalConfig() repository.Config {
107119
return c.repo.LocalConfig()

graphql/graph/gen_graph.go

Lines changed: 55 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

graphql/resolvers/repo.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@ var _ graph.RepositoryResolver = &repoResolver{}
1515

1616
type repoResolver struct{}
1717

18+
func (repoResolver) Name(_ context.Context, obj *models.Repository) (*string, error) {
19+
name := obj.Repo.Name()
20+
return &name, nil
21+
}
22+
1823
func (repoResolver) AllBugs(_ context.Context, obj *models.Repository, after *string, before *string, first *int, last *int, queryStr *string) (*models.BugConnection, error) {
1924
input := models.ConnectionInput{
2025
Before: before,
@@ -153,7 +158,7 @@ func (repoResolver) UserIdentity(_ context.Context, obj *models.Repository) (mod
153158
return models.NewLazyIdentity(obj.Repo, excerpt), nil
154159
}
155160

156-
func (resolver repoResolver) ValidLabels(_ context.Context, obj *models.Repository, after *string, before *string, first *int, last *int) (*models.LabelConnection, error) {
161+
func (repoResolver) ValidLabels(_ context.Context, obj *models.Repository, after *string, before *string, first *int, last *int) (*models.LabelConnection, error) {
157162
input := models.ConnectionInput{
158163
Before: before,
159164
After: after,

graphql/schema/repository.graphql

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11

22
type Repository {
3+
"""The name of the repository"""
4+
name: String
5+
36
"""All the bugs"""
47
allBugs(
58
"""Returns the elements in the list that come after the specified cursor."""
@@ -10,7 +13,7 @@ type Repository {
1013
first: Int
1114
"""Returns the last _n_ elements from the list."""
1215
last: Int
13-
"""A query to select and order bugs"""
16+
"""A query to select and order bugs."""
1417
query: String
1518
): BugConnection!
1619

0 commit comments

Comments
 (0)