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-12399: Introduce Repo GQL query #8717

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
225 changes: 225 additions & 0 deletions graphql/generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 17 additions & 0 deletions graphql/query_resolver.go
Original file line number Diff line number Diff line change
Expand Up @@ -490,6 +490,23 @@ func (r *queryResolver) ProjectSettings(ctx context.Context, projectIdentifier s
return res, nil
}

// Repo is the resolver for the repo fild.
func (r *queryResolver) Repo(ctx context.Context, repoID string) (*restModel.APIProjectRef, error) {
repoRef, err := model.FindOneRepoRef(repoID)
if err != nil {
return nil, InternalServerError.Send(ctx, fmt.Sprintf("looking in repo collection: %s", err.Error()))
}
if repoRef == nil {
return nil, ResourceNotFound.Send(ctx, "repo doesn't exist")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit. we could add the repoID here for more information

}
res := restModel.APIProjectRef{}
if err = res.BuildFromService(repoRef.ProjectRef); err != nil {
return nil, InternalServerError.Send(ctx, fmt.Sprintf("building APIProjectRef from service: %s", err.Error()))
}
res.DefaultUnsetBooleans()
return &res, nil
}

// RepoEvents is the resolver for the repoEvents field.
func (r *queryResolver) RepoEvents(ctx context.Context, repoID string, limit *int, before *time.Time) (*ProjectEvents, error) {
timestamp := time.Now()
Expand Down
1 change: 1 addition & 0 deletions graphql/schema/query.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ type Query {
before: Time
): ProjectEvents!
projectSettings(projectIdentifier: String! @requireProjectAccess(permission: SETTINGS, access:VIEW)): ProjectSettings!
repo(repoId: String! @requireProjectAccess(permission: TASKS, access: VIEW)): RepoRef!
Copy link
Contributor

@minnakt minnakt Feb 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

okay now that I'm thinking about it, I feel like we don't have any built-in support for the condition "If user has task permission for a project, they should also have task permission for the repo" and we would have to write code to support it.

it is kind of a weird condition but I think we need to have the permission restriction to block access to restricted projects

repoEvents(repoId: String! @requireProjectAccess(permission: SETTINGS, access: VIEW), limit: Int = 0, before: Time): ProjectEvents!
repoSettings(repoId: String! @requireProjectAccess(permission: SETTINGS, access: VIEW)): RepoSettings!
viewableProjectRefs: [GroupedProjects!]!
Expand Down
70 changes: 70 additions & 0 deletions graphql/tests/query/repo/data.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
{
"repo_ref": [
{
"_id": "sandbox_repo_id",
"display_name": "Sandbox",
"enabled": null,
"owner_name": "evergreen-ci",
"repo_name": "commit-queue-sandbox",
"branch_name": "main",
"remote_path": "evergreen.yml",
"patching_disabled": false,
"pr_testing_enabled": true,
"stepback_disabled": false,
"batch_time": 2,
"deactivate_previous": true,
"triggers": [],
"commit_queue": {
"enabled": true,
"require_signed": false,
"merge_method": "squash",
"message": "hmmm"
},
"admins": ["annie.black"],
"spawn_host_script_path": "",
"tracks_push_events": true,
"perf_enabled": true,
"build_baron_settings": {
"ticket_create_project": "EVG",
"ticket_search_projects": ["EVG"],
"bf_suggestion_server": "",
"bf_suggestion_username": "",
"bf_suggestion_password": "",
"bf_suggestion_timeout_secs": 0,
"bf_suggestion_features_url": ""
},
"task_annotation_settings": {
"web_hook": {
"endpoint": "endpoint",
"secret": "shh"
}
},
"container_size_definitions": [
{
"name": "size1",
"cpu": 1,
"memory_mb": 1024
},
{
"name": "size2",
"cpu": 2,
"memory_mb": 2048
}
],
"git_tag_authorized_users": ["ablack12"],
"workstation_config": {
"setup_commands": null,
"git_clone": false
},
"hidden": false
}
],
"github_hooks": [
{
"owner": "evergreen-ci",
"repo": "commit-queue-sandbox",
"app_id": 1234,
"installation_id": 5678
}
]
}
Loading
Loading