Create a GraphQL query for contributed projects
-
Please check this box if this contribution uses AI-generated content (including content generated by GitLab Duo features) as outlined in the GitLab DCO & CLA
What does this MR do and why?
As described in #450191 (closed), I created a GraphQL query contributed_projects
as a new field
like starred_projects.
I added a sort
arg to the resolver and make latest_activity_desc
its default value.
MR acceptance checklist
Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.
How to set up and validate locally
Numbered steps to set up and validate the change are strongly suggested.
- Run gdk. There are already root user's contributed projects in the gdk.
- Open GitLab(local), and sign in.
- Open GraphQL Explorer(local).
- Input a query below in the left textarea, and click an execute button.
{
user(username: "root") {
contributedProjects {
nodes {
id
name
lastActivityAt
}
}
}
}
- Open Contributed page on GitLab(local), and confirm that the shown projects and the projects from GraphQL(No.4) are same.
Note
When a user is not logged in GitLab, GraphQL query contributed_projects
returns an error with message The resource that you are attempting to access does not exist or you don't have permission to perform this action
. This is because of authorization check in user_resolver.rb.
While REST API GET /users/:user_id/contributed_projects
returns public contributed projects for a user who is not logged in. So this point is different between GraphQL and REST API.