GraphQL query to get a list of current user's projects

Hi there,

This (development) part of the forum seems rather dead, but I still hope I’ll get an answer here before I try to find other sources. I need to integrate the application I’m working on with GitLab and I want to use GraphQL rather than REST api, as the former is obviously the future, described as such by GitLab team as well. I also want to point out I’m rather new to GraphQL, so there may be some obvious things I’m missing.

Using GraphQL, I’d like to get a list of all projects for the current user, as it would appear when that user logs in into his/her gitlab.com account. More precisely, I’d like my query to return exactly the same list as I’d get using the REST api with endpoint URL:

GET /projects?min_access_level=40

So, something like:

query {currentUser {projects(min_access_level: 40) {...}}}

But User GraphQL type doesn’t have anything similar to projects field. I know how to query all projects within a given Namespace, but that’s not what I need, as for the current user’s namespace it returns a list of only projects the user owns.

On a related note, when using the REST api to obtain the list of projects, if a project is forked, it contains a field named forked_from_project. Looking into GraphQL specification for the Project type, I don’t see such field, nor something like parent or similar. Does that mean that information is not available if GraphQL is used? If so, how to propose api change/addition?

Thanks in advance.

Hi @milke, were you able to find a solution for this? I have only come across a gitub issue suggesting for something like this to be implemented, but no solution yet.

1 Like

This is what gives me a list of my first 10 projects using the GraphQL explorer

query {
projects(membership: true, search: "", first: 10) {
    nodes {
      name
      fullPath
    }
    pageInfo {
      endCursor
      hasNextPage
    }
  }
}
1 Like