GraphQL mutations for Devops Adoption Segment
What does this MR do?
This MR introduces GraphQL mutations for creating, updating and deleting a segment.
The MR might look big because of the auto generated GraphQL docs.
Previous MR: !46879 (merged)
What is a Segment?
A segment (maximum 20 segments) exists on the instance level and it can contain maximum 20 groups or projects (out of scope). These segments will be periodically probed to collect various metrics about the devops adoption.
Example
Create a segment called "GitLab" which contains the following groups:
gitlab-org
gitlab-com
A periodical process (not part of this MR) will look into the configured groups and stores metrics. Examples:
- Was there an issue created in the last 30 days? (store boolean flag: the segment adopted issues)
- Was there an epic created in the last 30 days? (store boolean flag: the segment adopted epics)
- ...
More info and mockups: #235421 (closed)
Testing
How to get group GIDs?
Console: puts Group.all.map(&:to_gid)
How to generate some segments?
Console:
5.times { |i| Analytics::DevopsAdoption::Segment.create!(name: "Segment #{i}", segment_selections_attributes: Group.all.shuffle.take(rand(5) + 1).map { |group| { group_id: group.id } })}
To test the mutations locally, navigate to: http://localhost:3000/-/graphql-explorer
Make sure you're logged in as admin.
Creating a Segment:
mutation {
createDevopsAdoptionSegment(input: {name:"mySegment", groupIds: ["gid://gitlab/Group/22", "gid://gitlab/Group/21"]}) {
segment {
id
name
groups {
nodes {
name
id
webUrl
}
}
}
errors
}
}
Updating a segment:
mutation updateSegment {
updateDevopsAdoptionSegment(input: {id: "gid://gitlab/Analytics::DevopsAdoption::Segment/2", name:"RenamedSegment", groupIds: ["gid://gitlab/Group/23"]}) {
segment {
id
name
groups {
nodes {
name
id
webUrl
}
}
}
errors
}
}
Deleting a segment:
mutation deleteSegment {
deleteDevopsAdoptionSegment(input: {id: "gid://gitlab/Analytics::DevopsAdoption::Segment/2"}) {
errors
}
}
Listing segments:
query getSegments {
devopsAdoptionSegments {
nodes {
id
name
groups {
nodes {
name
id
webUrl
}
}
}
}
}
Does this MR meet the acceptance criteria?
Conformity
-
Changelog entry -
Documentation (if required) -
Code review guidelines -
Merge request performance guidelines -
Style guides -
Database guides - [-] Separation of EE specific content
Availability and Testing
-
Review and add/update tests for this feature/bug. Consider all test levels. See the Test Planning Process. - [-] Tested in all supported browsers
- [-] Informed Infrastructure department of a default or new setting change, if applicable per definition of done
Security
If this MR contains changes to processing or storing of credentials or tokens, authorization and authentication methods and other items described in the security review guidelines:
- [-] Label as security and @ mention
@gitlab-com/gl-security/appsec
- [-] The MR includes necessary changes to maintain consistency between UI, API, email, or other methods
- [-] Security reports checked/validated by a reviewer from the AppSec team
Related to #262395 (closed)