Skip to content

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 a membership 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:

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:

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

!59763 (comment 561641827)

Appendix: Current API

Edited by Pedro Pombeiro