aboutsummaryrefslogtreecommitdiffstats
path: root/graphql/resolvers/repo.go
diff options
context:
space:
mode:
authorLuke Granger-Brown <git@lukegb.com>2020-06-18 19:31:28 +0100
committerMichael Muré <batolettre@gmail.com>2020-06-27 22:58:22 +0200
commit766aff2b2f9db339d7c42321fe6cd37309631be3 (patch)
tree32f8f2f58e58ec7b13ee93af0374038384d5ed50 /graphql/resolvers/repo.go
parent8a38897f79876b9372715150795b9da570af5a86 (diff)
downloadgit-bug-766aff2b2f9db339d7c42321fe6cd37309631be3.tar.gz
Change graphql Go handlers to pluck identity out of context instead.
Diffstat (limited to 'graphql/resolvers/repo.go')
-rw-r--r--graphql/resolvers/repo.go16
1 files changed, 6 insertions, 10 deletions
diff --git a/graphql/resolvers/repo.go b/graphql/resolvers/repo.go
index e30b49f0..ded98636 100644
--- a/graphql/resolvers/repo.go
+++ b/graphql/resolvers/repo.go
@@ -5,16 +5,16 @@ import (
"github.com/MichaelMure/git-bug/bug"
"github.com/MichaelMure/git-bug/entity"
- "github.com/MichaelMure/git-bug/graphql/config"
"github.com/MichaelMure/git-bug/graphql/connections"
"github.com/MichaelMure/git-bug/graphql/graph"
"github.com/MichaelMure/git-bug/graphql/models"
+ "github.com/MichaelMure/git-bug/identity"
"github.com/MichaelMure/git-bug/query"
)
var _ graph.RepositoryResolver = &repoResolver{}
-type repoResolver struct{ cfg config.Config }
+type repoResolver struct{}
func (repoResolver) Name(_ context.Context, obj *models.Repository) (*string, error) {
name := obj.Repo.Name()
@@ -150,16 +150,12 @@ func (repoResolver) Identity(_ context.Context, obj *models.Repository, prefix s
return models.NewLazyIdentity(obj.Repo, excerpt), nil
}
-func (r repoResolver) UserIdentity(_ context.Context, obj *models.Repository) (models.IdentityWrapper, error) {
- if r.cfg.ReadOnly {
+func (repoResolver) UserIdentity(ctx context.Context, obj *models.Repository) (models.IdentityWrapper, error) {
+ id := identity.ForContext(ctx, obj.Repo)
+ if id == nil {
return nil, nil
}
- excerpt, err := obj.Repo.GetUserIdentityExcerpt()
- if err != nil {
- return nil, err
- }
-
- return models.NewLazyIdentity(obj.Repo, excerpt), nil
+ return models.NewLoadedIdentity(id), nil
}
func (repoResolver) ValidLabels(_ context.Context, obj *models.Repository, after *string, before *string, first *int, last *int) (*models.LabelConnection, error) {