-
Notifications
You must be signed in to change notification settings - Fork 126
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DEVPROD-6472: Create isRepo
and repoPermissions
resolvers
#8456
Conversation
* Reduce admin_project_access power
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM mod some non-blocking comments about error checking.
usr, err := user.FindOneById(obj.UserID) | ||
if err != nil { | ||
return nil, ResourceNotFound.Send(ctx, "user not found") | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need to nil check usr
since FindOneById
returns nil, nil when not found.
graphql/permissions_resolver.go
Outdated
func (r *permissionsResolver) RepoPermissions(ctx context.Context, obj *Permissions, options RepoPermissionsOptions) (*RepoPermissions, error) { | ||
usr, err := user.FindOneById(obj.UserID) | ||
if err != nil { | ||
return nil, ResourceNotFound.Send(ctx, "user not found") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems like an InternalServerError
since FindOneById
would only error if the DB produced an error other than not found.
isRepo
and repoPermissions
resolvers
DEVPROD-6472
Description
Creates two resolvers:
query.isRepo
: A query that we can pass an ID to determine if something is a repo. This is helpful because the UI route for repos and projects is/project/<project_or_repo_id>/settings
so it's not possible for us to easily determine if something is a repo.user.repoPermissions
: A query that returns if user has view or edit permission for a given repo. Note that the view repo role has been removed recently. A repo is instead considered to be viewable is a user has view access to any of its attached projects.I also updated the scopes / roles and reduced the power of
admin_project_access
role (to mirror what is in production already).Testing