M api/graph/schema.graphqls => api/graph/schema.graphqls +13 -9
@@ 87,6 87,18 @@ interface Entity {
"""
canonicalName: String!
+ "Returns a specific repository owned by the user."
+ repository(name: String!): Repository @access(scope: REPOSITORIES, kind: RO)
+
+ """
+ Returns repositories that the user has access to.
+
+ NOTE: in this version of the API, only repositories owned by the
+ authenticated user are returned, but in the future the default behavior
+ will be to return all repositories that the user either (1) has been given
+ explicit access to via ACLs or (2) has implicit access to either by
+ ownership or group membership.
+ """
repositories(cursor: Cursor, filter: Filter): RepositoryCursor! @access(scope: REPOSITORIES, kind: RO)
}
@@ 101,6 113,7 @@ type User implements Entity {
location: String
bio: String
+ repository(name: String!): Repository @access(scope: REPOSITORIES, kind: RO)
repositories(cursor: Cursor, filter: Filter): RepositoryCursor! @access(scope: REPOSITORIES, kind: RO)
}
@@ 471,15 484,6 @@ type Query {
"""
repositories(cursor: Cursor, filter: Filter): RepositoryCursor @access(scope: REPOSITORIES, kind: RO)
- "Returns a specific repository, owned by the authenticated user."
- repositoryByName(name: String!): Repository @access(scope: REPOSITORIES, kind: RO)
-
- """
- Returns a specific repository, owned by the given canonical name (e.g.
- "~sircmpwn").
- """
- repositoryByOwner(owner: String!, repo: String!): Repository @access(scope: REPOSITORIES, kind: RO)
-
"""
Returns a list of user webhook subscriptions. For clients
authenticated with a personal access token, this returns all webhooks
M api/graph/schema.resolvers.go => api/graph/schema.resolvers.go +5 -14
@@ 857,20 857,6 @@ func (r *queryResolver) Repositories(ctx context.Context, cursor *coremodel.Curs
return &model.RepositoryCursor{repos, cursor}, nil
}
-func (r *queryResolver) RepositoryByName(ctx context.Context, name string) (*model.Repository, error) {
- return loaders.ForContext(ctx).RepositoriesByName.Load(name)
-}
-
-func (r *queryResolver) RepositoryByOwner(ctx context.Context, owner string, repo string) (*model.Repository, error) {
- if strings.HasPrefix(owner, "~") {
- owner = owner[1:]
- } else {
- return nil, fmt.Errorf("Expected owner to be a canonical name")
- }
- return loaders.ForContext(ctx).
- RepositoriesByOwnerRepoName.Load([2]string{owner, repo})
-}
-
func (r *queryResolver) UserWebhooks(ctx context.Context, cursor *coremodel.Cursor) (*model.WebhookSubscriptionCursor, error) {
if cursor == nil {
cursor = coremodel.NewCursor(nil)
@@ 1222,6 1208,11 @@ func (r *treeResolver) Entries(ctx context.Context, obj *model.Tree, cursor *cor
return &model.TreeEntryCursor{entries, cursor}, nil
}
+func (r *userResolver) Repository(ctx context.Context, obj *model.User, name string) (*model.Repository, error) {
+ // TODO: Load repository with user ID instead of username. Needs a new loader.
+ return loaders.ForContext(ctx).RepositoriesByOwnerRepoName.Load([2]string{obj.Username, name})
+}
+
func (r *userResolver) Repositories(ctx context.Context, obj *model.User, cursor *coremodel.Cursor, filter *coremodel.Filter) (*model.RepositoryCursor, error) {
if cursor == nil {
cursor = coremodel.NewCursor(filter)