Create On-call schedules via GraphQL
What does this MR do?
Contributes to #262847 (closed)
Feature flag roll-out issue #283914 (closed)
- Creates an OncallSchedule model to persist Incident Management on-call schedules
- Adds a GraphQL query to fetch on-call schedules
- Adds a GraphQL mutation to create an on-call schedule
- Permissions (for details: #262847 (comment 447339235))
- Maintainers have manage permissions (read/create/modify/delete)
- Developers and reporters have read permissions
- Adds a changelog entry for new database table
- Doesn't add a change entry for GraphQL endpoints because they are behind a feature flag
We ended up with a big MR because I was trying to follow a vertical slicing approach (described here gitlab-com/www-gitlab-com!58851 (merged)).
Enable feature flag on localhost
Feature.enable(:oncall_schedules_mvc, Project.find_by_full_path('<PROJECT-FULL-PATH>'))
GraphQL mutation example
Use http://127.0.0.1:3000/-/graphql-explorer to test
mutation($oncallScheduleCreateInput: OncallScheduleCreateInput!) {
oncallScheduleCreate(input: $oncallScheduleCreateInput) {
clientMutationId
errors
oncallSchedule {
iid
name
description
timezone
}
}
}
query variables
{
"oncallScheduleCreateInput": {
"projectPath": "<PROJECT-FULL-PATH>",
"name": "New on-call schedule",
"description": "on-call schedule description",
"timezone": "Europe/Berlin"
}
}
GraphQL query example
Use http://127.0.0.1:3000/-/graphql-explorer to test
query {
project(fullPath: "<PROJECT-FULL-PATH>") {
incidentManagementOncallSchedules {
nodes {
iid
name
description
timezone
}
}
}
}
rails db:migrate
output
Click this to collapse/fold.
→ be rake db:migrate
== 20201111115414 CreateIncidentManagementOncallSchedules: migrating ==========
-- table_exists?(:incident_management_oncall_schedules)
-> 0.0004s
-- create_table(:incident_management_oncall_schedules)
-> 0.0198s
-- transaction_open?()
-> 0.0000s
-- current_schema()
-> 0.0002s
-- execute("ALTER TABLE incident_management_oncall_schedules\nADD CONSTRAINT check_e6ef43a664\nCHECK ( char_length(name) <= 200 )\nNOT VALID;\n")
-> 0.0008s
-- current_schema()
-> 0.0002s
-- execute("SET statement_timeout TO 0")
-> 0.0002s
-- execute("ALTER TABLE incident_management_oncall_schedules VALIDATE CONSTRAINT check_e6ef43a664;")
-> 0.0005s
-- execute("RESET ALL")
-> 0.0002s
-- transaction_open?()
-> 0.0000s
-- current_schema()
-> 0.0002s
-- execute("ALTER TABLE incident_management_oncall_schedules\nADD CONSTRAINT check_7ed1fd5aa7\nCHECK ( char_length(description) <= 1000 )\nNOT VALID;\n")
-> 0.0003s
-- current_schema()
-> 0.0001s
-- execute("ALTER TABLE incident_management_oncall_schedules VALIDATE CONSTRAINT check_7ed1fd5aa7;")
-> 0.0004s
-- transaction_open?()
-> 0.0000s
-- current_schema()
-> 0.0002s
-- execute("ALTER TABLE incident_management_oncall_schedules\nADD CONSTRAINT check_cc77cbb103\nCHECK ( char_length(timezone) <= 100 )\nNOT VALID;\n")
-> 0.0003s
-- current_schema()
-> 0.0001s
-- execute("ALTER TABLE incident_management_oncall_schedules VALIDATE CONSTRAINT check_cc77cbb103;")
-> 0.0005s
== 20201111115414 CreateIncidentManagementOncallSchedules: migrated (0.0384s) =
rails db:rollback
output
Click this to collapse/fold.
→ be rails db:rollback
== 20201111115414 CreateIncidentManagementOncallSchedules: reverting ==========
-- drop_table(:incident_management_oncall_schedules)
-> 0.0049s
== 20201111115414 CreateIncidentManagementOncallSchedules: reverted (0.0208s) =
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