Create GraphQL Query for a list of GitLab Runners
Background
Depends on #327008 (closed) where we define the fields in the runner entity.
This task is the first iteration of a list of runners connected to an instances, this is partly a port of our Runner API, and it will be used in a our Runner Enterprise Management .
Proposal
To make a first iteration, this task would include fetching a list of runner, with the query:
query getRunners {
runners {
edges {
node {
# ... RunnerType
id
shortSha
name
description
webUrl # NEW! Please see question below!
# ... RunnerType
}
}
pageInfo{
hasNextPage
hasPreviousPage
startCursor
endCursor
}
}
}
Questions before implementation
👉 The rest API provides 2 options /runners
for all users and runners/all
for administrators. I am not sure if this should be ported to this new API.
While runners/all
would be what we use in the admin section this API should scale to consider the Group and Project scopes.
- The
project
GraphQL API offers amembership
flag that acts similarly to differentiate the two lists.- We should think about the model of ownership of Groups and Projects relevant to the GraphQL API.
Resolved:: This API will be a port of runners/all
as other APIs below will cover the use cases for groups and projects.
👉 Do we extend this global query to filter by a specific group/project or do we add new properties to the groups/projects
The project details page list runners in different sections:
- Available shared runners (active shared runners:
::Ci::Runner.instance_type.active
) - Available specific runners(Paginated @project.runners)
- Available group runners (
::Ci::Runner.belonging_to_parent_group_of_project(@project.id)
) - Assignable runners (
current_user.ci_owned_runners.assignable_for(project)
)
The groups details page lists runners in only one section:
To achieve these different filtering options, should our next Queries looks like:
-
group { runners { ... } }
vs.runners( group: 'my-group' ) {}
or -
project { runners { ... } }
vs.project( group: 'my-group' ) {}
Resolved:: group { runners { ... } }
and project { runners { ... } }
will be used as they are most natural way to express this data in GraphQL. (Note this is no in the scope of this issue)
👉 How do we define a webUrl
for the runner?
The “Runner” entity can be viewed by admin, groups owners and project owners. If we have a webUrl
that will be used to render links to the entity, how do we have multiple URLs to each of these views?
For example all these links exist for the same runner, but in different contexts, they all could be webUrl
:
- http://gdk.test:3000/admin/runners/9
- http://gdk.test:3000/groups/h5bp/-/runners/9
- http://gdk.test:3000/h5bp/html5-boilerplate/runners/9 (edited)
Resolved: We can pass parameters to the webUrl
field to ask for the relevant webPath
of a runner.
👉 We should decide on a pagination method that supports complex sorting/filters
- Sorted by: Created Date / Last contact
- Filter by: Status / Type / Tag
👉 Things to take into consideration during implementation
Appendix: Current API
- List owned runners: https://docs.gitlab.com/ee/api/runners.html#list-owned-runners
- List all runners: https://docs.gitlab.com/ee/api/runners.html#list-all-runners