Skip to content
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

Merged
merged 6 commits into from
Nov 8, 2024

Conversation

minnakt
Copy link
Contributor

@minnakt minnakt commented Nov 4, 2024

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

  • Added GraphQL tests
  • Failing Spruce e2e test is expected given changes and will need to be fixed by UI PR

@minnakt minnakt marked this pull request as ready for review November 7, 2024 02:37
@minnakt minnakt requested review from a team November 7, 2024 02:37
Copy link
Contributor

@Kimchelly Kimchelly left a 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")
}
Copy link
Contributor

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.

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")
Copy link
Contributor

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.

@minnakt minnakt changed the title DEVPROD-6472: Create isRepo and repoPermissions resolvers DEVPROD-6472: Create isRepo and repoPermissions resolvers Nov 8, 2024
@minnakt minnakt merged commit 4be9ce2 into evergreen-ci:main Nov 8, 2024
10 checks passed
@minnakt minnakt deleted the DEVPROD-6472 branch November 8, 2024 02:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants