From 6438df3a1e0fb944485cebf07976160184697d72 Mon Sep 17 00:00:00 2001 From: Robert Speicher Date: Wed, 20 Jan 2021 13:34:23 -0600 Subject: Add latest changes from gitlab-org/gitlab@13-8-stable-ee --- .../mutations/admin/sidekiq_queues/delete_jobs.rb | 4 +- app/graphql/mutations/alert_management/base.rb | 10 ++-- .../alert_management/http_integration/create.rb | 19 ++++++-- .../alert_management/http_integration/destroy.rb | 2 +- .../http_integration/http_integration_base.rb | 2 +- .../http_integration/reset_token.rb | 2 +- .../alert_management/http_integration/update.rb | 6 +-- .../prometheus_integration/create.rb | 6 +-- .../prometheus_integration_base.rb | 2 +- .../prometheus_integration/reset_token.rb | 2 +- .../prometheus_integration/update.rb | 6 +-- .../alert_management/update_alert_status.rb | 2 +- app/graphql/mutations/award_emojis/base.rb | 4 +- app/graphql/mutations/boards/destroy.rb | 4 +- .../mutations/boards/issues/issue_move_list.rb | 14 +++--- app/graphql/mutations/boards/lists/base.rb | 4 +- app/graphql/mutations/boards/lists/create.rb | 4 +- app/graphql/mutations/boards/lists/update.rb | 6 +-- app/graphql/mutations/boards/update.rb | 2 + app/graphql/mutations/branches/create.rb | 8 ++-- app/graphql/mutations/ci/base.rb | 22 --------- app/graphql/mutations/ci/ci_cd_settings_update.rb | 29 ++++++++++++ app/graphql/mutations/ci/pipeline/base.rb | 24 ++++++++++ app/graphql/mutations/ci/pipeline/cancel.rb | 24 ++++++++++ app/graphql/mutations/ci/pipeline/destroy.rb | 24 ++++++++++ app/graphql/mutations/ci/pipeline/retry.rb | 29 ++++++++++++ app/graphql/mutations/ci/pipeline_cancel.rb | 22 --------- app/graphql/mutations/ci/pipeline_destroy.rb | 22 --------- app/graphql/mutations/ci/pipeline_retry.rb | 27 ----------- app/graphql/mutations/commits/create.rb | 10 ++-- .../concerns/mutations/authorizes_project.rb | 17 ------- .../mutations/concerns/mutations/finds_project.rb | 11 +++++ .../concerns/mutations/resolves_namespace.rb | 15 ++++++ .../concerns/mutations/resolves_resource_parent.rb | 4 +- .../concerns/mutations/resolves_subscription.rb | 2 +- .../mutations/spammable_mutation_fields.rb | 2 +- .../container_expiration_policies/update.rb | 4 +- .../container_repositories/destroy_tags.rb | 2 +- app/graphql/mutations/custom_emoji/create.rb | 8 ++-- app/graphql/mutations/design_management/base.rb | 4 +- app/graphql/mutations/design_management/delete.rb | 4 +- app/graphql/mutations/design_management/move.rb | 8 ++-- app/graphql/mutations/design_management/upload.rb | 4 +- .../mutations/discussions/toggle_resolve.rb | 6 +-- .../environments/canary_ingress/update.rb | 4 +- app/graphql/mutations/issues/base.rb | 6 +-- app/graphql/mutations/issues/create.rb | 18 ++++---- app/graphql/mutations/issues/move.rb | 2 +- app/graphql/mutations/issues/set_due_date.rb | 2 +- app/graphql/mutations/issues/set_locked.rb | 2 +- app/graphql/mutations/issues/update.rb | 8 ++-- app/graphql/mutations/jira_import/import_users.rb | 4 +- app/graphql/mutations/jira_import/start.rb | 10 ++-- app/graphql/mutations/labels/create.rb | 8 ++-- app/graphql/mutations/merge_requests/base.rb | 6 +-- app/graphql/mutations/merge_requests/create.rb | 4 +- app/graphql/mutations/merge_requests/update.rb | 2 +- .../metrics/dashboard/annotations/create.rb | 14 +++--- .../metrics/dashboard/annotations/delete.rb | 2 +- .../mutations/namespace/package_settings/update.rb | 54 ++++++++++++++++++++++ app/graphql/mutations/notes/base.rb | 2 +- app/graphql/mutations/notes/create/base.rb | 2 +- app/graphql/mutations/notes/create/note.rb | 2 +- app/graphql/mutations/notes/destroy.rb | 2 +- .../mutations/notes/reposition_image_diff_note.rb | 2 +- app/graphql/mutations/notes/update/base.rb | 2 +- app/graphql/mutations/releases/base.rb | 2 +- app/graphql/mutations/releases/create.rb | 12 ++--- app/graphql/mutations/releases/update.rb | 16 +++---- app/graphql/mutations/snippets/base.rb | 2 +- app/graphql/mutations/snippets/create.rb | 14 +++--- app/graphql/mutations/snippets/destroy.rb | 2 +- app/graphql/mutations/snippets/mark_as_spam.rb | 2 +- app/graphql/mutations/snippets/update.rb | 10 ++-- app/graphql/mutations/terraform/state/base.rb | 2 +- app/graphql/mutations/todos/create.rb | 4 +- app/graphql/mutations/todos/mark_all_done.rb | 4 +- app/graphql/mutations/todos/mark_done.rb | 4 +- app/graphql/mutations/todos/restore.rb | 4 +- app/graphql/mutations/todos/restore_many.rb | 6 +-- 80 files changed, 393 insertions(+), 282 deletions(-) delete mode 100644 app/graphql/mutations/ci/base.rb create mode 100644 app/graphql/mutations/ci/ci_cd_settings_update.rb create mode 100644 app/graphql/mutations/ci/pipeline/base.rb create mode 100644 app/graphql/mutations/ci/pipeline/cancel.rb create mode 100644 app/graphql/mutations/ci/pipeline/destroy.rb create mode 100644 app/graphql/mutations/ci/pipeline/retry.rb delete mode 100644 app/graphql/mutations/ci/pipeline_cancel.rb delete mode 100644 app/graphql/mutations/ci/pipeline_destroy.rb delete mode 100644 app/graphql/mutations/ci/pipeline_retry.rb delete mode 100644 app/graphql/mutations/concerns/mutations/authorizes_project.rb create mode 100644 app/graphql/mutations/concerns/mutations/finds_project.rb create mode 100644 app/graphql/mutations/concerns/mutations/resolves_namespace.rb create mode 100644 app/graphql/mutations/namespace/package_settings/update.rb (limited to 'app/graphql/mutations') diff --git a/app/graphql/mutations/admin/sidekiq_queues/delete_jobs.rb b/app/graphql/mutations/admin/sidekiq_queues/delete_jobs.rb index 17f9b5b5637..32ca6de9b96 100644 --- a/app/graphql/mutations/admin/sidekiq_queues/delete_jobs.rb +++ b/app/graphql/mutations/admin/sidekiq_queues/delete_jobs.rb @@ -18,12 +18,12 @@ module Mutations argument :queue_name, GraphQL::STRING_TYPE, required: true, - description: 'The name of the queue to delete jobs from' + description: 'The name of the queue to delete jobs from.' field :result, Types::Admin::SidekiqQueues::DeleteJobsResponseType, null: true, - description: 'Information about the status of the deletion request' + description: 'Information about the status of the deletion request.' def ready?(**args) unless current_user&.admin? diff --git a/app/graphql/mutations/alert_management/base.rb b/app/graphql/mutations/alert_management/base.rb index 8c6b4005cf8..3a57cb9670d 100644 --- a/app/graphql/mutations/alert_management/base.rb +++ b/app/graphql/mutations/alert_management/base.rb @@ -7,26 +7,26 @@ module Mutations argument :project_path, GraphQL::ID_TYPE, required: true, - description: "The project the alert to mutate is in" + description: "The project the alert to mutate is in." argument :iid, GraphQL::STRING_TYPE, required: true, - description: "The IID of the alert to mutate" + description: "The IID of the alert to mutate." field :alert, Types::AlertManagement::AlertType, null: true, - description: "The alert after mutation" + description: "The alert after mutation." field :todo, Types::TodoType, null: true, - description: "The todo after mutation" + description: "The todo after mutation." field :issue, Types::IssueType, null: true, - description: "The issue created after mutation" + description: "The issue created after mutation." authorize :update_alert_management_alert diff --git a/app/graphql/mutations/alert_management/http_integration/create.rb b/app/graphql/mutations/alert_management/http_integration/create.rb index ddb75e66bb4..ff165d7f302 100644 --- a/app/graphql/mutations/alert_management/http_integration/create.rb +++ b/app/graphql/mutations/alert_management/http_integration/create.rb @@ -10,32 +10,41 @@ module Mutations argument :project_path, GraphQL::ID_TYPE, required: true, - description: 'The project to create the integration in' + description: 'The project to create the integration in.' argument :name, GraphQL::STRING_TYPE, required: true, - description: 'The name of the integration' + description: 'The name of the integration.' argument :active, GraphQL::BOOLEAN_TYPE, required: true, - description: 'Whether the integration is receiving alerts' + description: 'Whether the integration is receiving alerts.' def resolve(args) - project = authorized_find!(full_path: args[:project_path]) + @project = authorized_find!(full_path: args[:project_path]) response ::AlertManagement::HttpIntegrations::CreateService.new( project, current_user, - args.slice(:name, :active) + http_integration_params(args) ).execute end private + attr_reader :project + def find_object(full_path:) resolve_project(full_path: full_path) end + + # overriden in EE + def http_integration_params(args) + args.slice(:name, :active) + end end end end end + +Mutations::AlertManagement::HttpIntegration::Create.prepend_if_ee('::EE::Mutations::AlertManagement::HttpIntegration::Create') diff --git a/app/graphql/mutations/alert_management/http_integration/destroy.rb b/app/graphql/mutations/alert_management/http_integration/destroy.rb index 45d4bd778da..d0420e2bcb5 100644 --- a/app/graphql/mutations/alert_management/http_integration/destroy.rb +++ b/app/graphql/mutations/alert_management/http_integration/destroy.rb @@ -8,7 +8,7 @@ module Mutations argument :id, Types::GlobalIDType[::AlertManagement::HttpIntegration], required: true, - description: "The ID of the integration to remove" + description: "The ID of the integration to remove." def resolve(id:) integration = authorized_find!(id: id) diff --git a/app/graphql/mutations/alert_management/http_integration/http_integration_base.rb b/app/graphql/mutations/alert_management/http_integration/http_integration_base.rb index d328eabf244..147df982bec 100644 --- a/app/graphql/mutations/alert_management/http_integration/http_integration_base.rb +++ b/app/graphql/mutations/alert_management/http_integration/http_integration_base.rb @@ -7,7 +7,7 @@ module Mutations field :integration, Types::AlertManagement::HttpIntegrationType, null: true, - description: "The HTTP integration" + description: "The HTTP integration." authorize :admin_operations diff --git a/app/graphql/mutations/alert_management/http_integration/reset_token.rb b/app/graphql/mutations/alert_management/http_integration/reset_token.rb index 3938b38260e..bf73a9eaae7 100644 --- a/app/graphql/mutations/alert_management/http_integration/reset_token.rb +++ b/app/graphql/mutations/alert_management/http_integration/reset_token.rb @@ -8,7 +8,7 @@ module Mutations argument :id, Types::GlobalIDType[::AlertManagement::HttpIntegration], required: true, - description: "The ID of the integration to mutate" + description: "The ID of the integration to mutate." def resolve(id:) integration = authorized_find!(id: id) diff --git a/app/graphql/mutations/alert_management/http_integration/update.rb b/app/graphql/mutations/alert_management/http_integration/update.rb index 98e0f7eb14f..431fccaa5e5 100644 --- a/app/graphql/mutations/alert_management/http_integration/update.rb +++ b/app/graphql/mutations/alert_management/http_integration/update.rb @@ -8,15 +8,15 @@ module Mutations argument :id, Types::GlobalIDType[::AlertManagement::HttpIntegration], required: true, - description: "The ID of the integration to mutate" + description: "The ID of the integration to mutate." argument :name, GraphQL::STRING_TYPE, required: false, - description: "The name of the integration" + description: "The name of the integration." argument :active, GraphQL::BOOLEAN_TYPE, required: false, - description: "Whether the integration is receiving alerts" + description: "Whether the integration is receiving alerts." def resolve(args) integration = authorized_find!(id: args[:id]) diff --git a/app/graphql/mutations/alert_management/prometheus_integration/create.rb b/app/graphql/mutations/alert_management/prometheus_integration/create.rb index 935ec53795c..c676cde90b4 100644 --- a/app/graphql/mutations/alert_management/prometheus_integration/create.rb +++ b/app/graphql/mutations/alert_management/prometheus_integration/create.rb @@ -10,15 +10,15 @@ module Mutations argument :project_path, GraphQL::ID_TYPE, required: true, - description: 'The project to create the integration in' + description: 'The project to create the integration in.' argument :active, GraphQL::BOOLEAN_TYPE, required: true, - description: 'Whether the integration is receiving alerts' + description: 'Whether the integration is receiving alerts.' argument :api_url, GraphQL::STRING_TYPE, required: true, - description: 'Endpoint at which prometheus can be queried' + description: 'Endpoint at which prometheus can be queried.' def resolve(args) project = authorized_find!(full_path: args[:project_path]) diff --git a/app/graphql/mutations/alert_management/prometheus_integration/prometheus_integration_base.rb b/app/graphql/mutations/alert_management/prometheus_integration/prometheus_integration_base.rb index 6b690ac239a..cb243f49b33 100644 --- a/app/graphql/mutations/alert_management/prometheus_integration/prometheus_integration_base.rb +++ b/app/graphql/mutations/alert_management/prometheus_integration/prometheus_integration_base.rb @@ -7,7 +7,7 @@ module Mutations field :integration, Types::AlertManagement::PrometheusIntegrationType, null: true, - description: "The newly created integration" + description: "The newly created integration." authorize :admin_project diff --git a/app/graphql/mutations/alert_management/prometheus_integration/reset_token.rb b/app/graphql/mutations/alert_management/prometheus_integration/reset_token.rb index effecd8364d..428be091436 100644 --- a/app/graphql/mutations/alert_management/prometheus_integration/reset_token.rb +++ b/app/graphql/mutations/alert_management/prometheus_integration/reset_token.rb @@ -8,7 +8,7 @@ module Mutations argument :id, Types::GlobalIDType[::PrometheusService], required: true, - description: "The ID of the integration to mutate" + description: "The ID of the integration to mutate." def resolve(id:) integration = authorized_find!(id: id) diff --git a/app/graphql/mutations/alert_management/prometheus_integration/update.rb b/app/graphql/mutations/alert_management/prometheus_integration/update.rb index 46f4c23b739..62fb81bca5a 100644 --- a/app/graphql/mutations/alert_management/prometheus_integration/update.rb +++ b/app/graphql/mutations/alert_management/prometheus_integration/update.rb @@ -8,15 +8,15 @@ module Mutations argument :id, Types::GlobalIDType[::PrometheusService], required: true, - description: "The ID of the integration to mutate" + description: "The ID of the integration to mutate." argument :active, GraphQL::BOOLEAN_TYPE, required: false, - description: "Whether the integration is receiving alerts" + description: "Whether the integration is receiving alerts." argument :api_url, GraphQL::STRING_TYPE, required: false, - description: "Endpoint at which prometheus can be queried" + description: "Endpoint at which prometheus can be queried." def resolve(args) integration = authorized_find!(id: args[:id]) diff --git a/app/graphql/mutations/alert_management/update_alert_status.rb b/app/graphql/mutations/alert_management/update_alert_status.rb index 74185dca529..67f8ba9118f 100644 --- a/app/graphql/mutations/alert_management/update_alert_status.rb +++ b/app/graphql/mutations/alert_management/update_alert_status.rb @@ -7,7 +7,7 @@ module Mutations argument :status, Types::AlertManagement::StatusEnum, required: true, - description: 'The status to set the alert' + description: 'The status to set the alert.' def resolve(project_path:, iid:, status:) alert = authorized_find!(project_path: project_path, iid: iid) diff --git a/app/graphql/mutations/award_emojis/base.rb b/app/graphql/mutations/award_emojis/base.rb index 4bd8304c3fc..4f41a9cafd8 100644 --- a/app/graphql/mutations/award_emojis/base.rb +++ b/app/graphql/mutations/award_emojis/base.rb @@ -12,7 +12,7 @@ module Mutations argument :awardable_id, ::Types::GlobalIDType[::Awardable], required: true, - description: 'The global ID of the awardable resource' + description: 'The global ID of the awardable resource.' argument :name, GraphQL::STRING_TYPE, @@ -22,7 +22,7 @@ module Mutations field :award_emoji, Types::AwardEmojis::AwardEmojiType, null: true, - description: 'The award emoji after mutation' + description: 'The award emoji after mutation.' private diff --git a/app/graphql/mutations/boards/destroy.rb b/app/graphql/mutations/boards/destroy.rb index 7c381113d38..8ec13b885d5 100644 --- a/app/graphql/mutations/boards/destroy.rb +++ b/app/graphql/mutations/boards/destroy.rb @@ -8,11 +8,11 @@ module Mutations field :board, Types::BoardType, null: true, - description: 'The board after mutation' + description: 'The board after mutation.' argument :id, ::Types::GlobalIDType[::Board], required: true, - description: 'The global ID of the board to destroy' + description: 'The global ID of the board to destroy.' authorize :admin_board diff --git a/app/graphql/mutations/boards/issues/issue_move_list.rb b/app/graphql/mutations/boards/issues/issue_move_list.rb index 813b6d3cb2a..91dfd9fc3e9 100644 --- a/app/graphql/mutations/boards/issues/issue_move_list.rb +++ b/app/graphql/mutations/boards/issues/issue_move_list.rb @@ -9,31 +9,31 @@ module Mutations argument :board_id, GraphQL::ID_TYPE, required: true, loads: Types::BoardType, - description: 'Global ID of the board that the issue is in' + description: 'Global ID of the board that the issue is in.' argument :project_path, GraphQL::ID_TYPE, required: true, - description: 'Project the issue to mutate is in' + description: 'Project the issue to mutate is in.' argument :iid, GraphQL::STRING_TYPE, required: true, - description: 'IID of the issue to mutate' + description: 'IID of the issue to mutate.' argument :from_list_id, GraphQL::ID_TYPE, required: false, - description: 'ID of the board list that the issue will be moved from' + description: 'ID of the board list that the issue will be moved from.' argument :to_list_id, GraphQL::ID_TYPE, required: false, - description: 'ID of the board list that the issue will be moved to' + description: 'ID of the board list that the issue will be moved to.' argument :move_before_id, GraphQL::ID_TYPE, required: false, - description: 'ID of issue that should be placed before the current issue' + description: 'ID of issue that should be placed before the current issue.' argument :move_after_id, GraphQL::ID_TYPE, required: false, - description: 'ID of issue that should be placed after the current issue' + description: 'ID of issue that should be placed after the current issue.' def ready?(**args) if move_arguments(args).blank? diff --git a/app/graphql/mutations/boards/lists/base.rb b/app/graphql/mutations/boards/lists/base.rb index d244d6bf8dd..34c138bddc9 100644 --- a/app/graphql/mutations/boards/lists/base.rb +++ b/app/graphql/mutations/boards/lists/base.rb @@ -8,12 +8,12 @@ module Mutations argument :board_id, ::Types::GlobalIDType[::Board], required: true, - description: 'Global ID of the issue board to mutate' + description: 'Global ID of the issue board to mutate.' field :list, Types::BoardListType, null: true, - description: 'List of the issue board' + description: 'List of the issue board.' authorize :admin_list diff --git a/app/graphql/mutations/boards/lists/create.rb b/app/graphql/mutations/boards/lists/create.rb index f6df63365b2..9eb9a4d4b87 100644 --- a/app/graphql/mutations/boards/lists/create.rb +++ b/app/graphql/mutations/boards/lists/create.rb @@ -8,11 +8,11 @@ module Mutations argument :backlog, GraphQL::BOOLEAN_TYPE, required: false, - description: 'Create the backlog list' + description: 'Create the backlog list.' argument :label_id, ::Types::GlobalIDType[::Label], required: false, - description: 'Global ID of an existing label' + description: 'Global ID of an existing label.' def ready?(**args) if args.slice(*mutually_exclusive_args).size != 1 diff --git a/app/graphql/mutations/boards/lists/update.rb b/app/graphql/mutations/boards/lists/update.rb index 14502b5174f..d30d1d89bb2 100644 --- a/app/graphql/mutations/boards/lists/update.rb +++ b/app/graphql/mutations/boards/lists/update.rb @@ -13,16 +13,16 @@ module Mutations argument :position, GraphQL::INT_TYPE, required: false, - description: 'Position of list within the board' + description: 'Position of list within the board.' argument :collapsed, GraphQL::BOOLEAN_TYPE, required: false, - description: 'Indicates if list is collapsed for this user' + description: 'Indicates if list is collapsed for this user.' field :list, Types::BoardListType, null: true, - description: 'Mutated list' + description: 'Mutated list.' def resolve(list: nil, **args) raise_resource_not_available_error! unless can_read_list?(list) diff --git a/app/graphql/mutations/boards/update.rb b/app/graphql/mutations/boards/update.rb index 5cb434e41fd..b4f8179829e 100644 --- a/app/graphql/mutations/boards/update.rb +++ b/app/graphql/mutations/boards/update.rb @@ -30,6 +30,8 @@ module Mutations } end + private + def find_object(id:) # TODO: remove this line when the compatibility layer is removed # See: https://gitlab.com/gitlab-org/gitlab/-/issues/257883 diff --git a/app/graphql/mutations/branches/create.rb b/app/graphql/mutations/branches/create.rb index 214fead2e80..9fe9bef5403 100644 --- a/app/graphql/mutations/branches/create.rb +++ b/app/graphql/mutations/branches/create.rb @@ -9,21 +9,21 @@ module Mutations argument :project_path, GraphQL::ID_TYPE, required: true, - description: 'Project full path the branch is associated with' + description: 'Project full path the branch is associated with.' argument :name, GraphQL::STRING_TYPE, required: true, - description: 'Name of the branch' + description: 'Name of the branch.' argument :ref, GraphQL::STRING_TYPE, required: true, - description: 'Branch name or commit SHA to create branch from' + description: 'Branch name or commit SHA to create branch from.' field :branch, Types::BranchType, null: true, - description: 'Branch after mutation' + description: 'Branch after mutation.' authorize :push_code diff --git a/app/graphql/mutations/ci/base.rb b/app/graphql/mutations/ci/base.rb deleted file mode 100644 index 0ccee5661b7..00000000000 --- a/app/graphql/mutations/ci/base.rb +++ /dev/null @@ -1,22 +0,0 @@ -# frozen_string_literal: true - -module Mutations - module Ci - class Base < BaseMutation - PipelineID = ::Types::GlobalIDType[::Ci::Pipeline] - - argument :id, PipelineID, - required: true, - description: 'The ID of the pipeline to mutate' - - private - - def find_object(id:) - # TODO: remove this line when the compatibility layer is removed - # See: https://gitlab.com/gitlab-org/gitlab/-/issues/257883 - id = PipelineID.coerce_isolated_input(id) - GlobalID::Locator.locate(id) - end - end - end -end diff --git a/app/graphql/mutations/ci/ci_cd_settings_update.rb b/app/graphql/mutations/ci/ci_cd_settings_update.rb new file mode 100644 index 00000000000..6b7750ee860 --- /dev/null +++ b/app/graphql/mutations/ci/ci_cd_settings_update.rb @@ -0,0 +1,29 @@ +# frozen_string_literal: true + +module Mutations + module Ci + class CiCdSettingsUpdate < BaseMutation + include FindsProject + + graphql_name 'CiCdSettingsUpdate' + + authorize :admin_project + + argument :full_path, GraphQL::ID_TYPE, + required: true, + description: 'Full Path of the project the settings belong to.' + + argument :keep_latest_artifact, GraphQL::BOOLEAN_TYPE, + required: false, + description: 'Indicates if the latest artifact should be kept for this project.' + + def resolve(full_path:, **args) + project = authorized_find!(full_path) + settings = project.ci_cd_settings + settings.update(args) + + { errors: errors_on_object(settings) } + end + end + end +end diff --git a/app/graphql/mutations/ci/pipeline/base.rb b/app/graphql/mutations/ci/pipeline/base.rb new file mode 100644 index 00000000000..ebfab56e743 --- /dev/null +++ b/app/graphql/mutations/ci/pipeline/base.rb @@ -0,0 +1,24 @@ +# frozen_string_literal: true + +module Mutations + module Ci + module Pipeline + class Base < BaseMutation + PipelineID = ::Types::GlobalIDType[::Ci::Pipeline] + + argument :id, PipelineID, + required: true, + description: 'The ID of the pipeline to mutate.' + + private + + def find_object(id:) + # TODO: remove this line when the compatibility layer is removed + # See: https://gitlab.com/gitlab-org/gitlab/-/issues/257883 + id = PipelineID.coerce_isolated_input(id) + GlobalID::Locator.locate(id) + end + end + end + end +end diff --git a/app/graphql/mutations/ci/pipeline/cancel.rb b/app/graphql/mutations/ci/pipeline/cancel.rb new file mode 100644 index 00000000000..3fb34a37cfc --- /dev/null +++ b/app/graphql/mutations/ci/pipeline/cancel.rb @@ -0,0 +1,24 @@ +# frozen_string_literal: true + +module Mutations + module Ci + module Pipeline + class Cancel < Base + graphql_name 'PipelineCancel' + + authorize :update_pipeline + + def resolve(id:) + pipeline = authorized_find!(id: id) + + if pipeline.cancelable? + pipeline.cancel_running + { success: true, errors: [] } + else + { success: false, errors: ['Pipeline is not cancelable'] } + end + end + end + end + end +end diff --git a/app/graphql/mutations/ci/pipeline/destroy.rb b/app/graphql/mutations/ci/pipeline/destroy.rb new file mode 100644 index 00000000000..3f933818ce1 --- /dev/null +++ b/app/graphql/mutations/ci/pipeline/destroy.rb @@ -0,0 +1,24 @@ +# frozen_string_literal: true + +module Mutations + module Ci + module Pipeline + class Destroy < Base + graphql_name 'PipelineDestroy' + + authorize :destroy_pipeline + + def resolve(id:) + pipeline = authorized_find!(id: id) + project = pipeline.project + + result = ::Ci::DestroyPipelineService.new(project, current_user).execute(pipeline) + { + success: result.success?, + errors: result.errors + } + end + end + end + end +end diff --git a/app/graphql/mutations/ci/pipeline/retry.rb b/app/graphql/mutations/ci/pipeline/retry.rb new file mode 100644 index 00000000000..a12330470f0 --- /dev/null +++ b/app/graphql/mutations/ci/pipeline/retry.rb @@ -0,0 +1,29 @@ +# frozen_string_literal: true + +module Mutations + module Ci + module Pipeline + class Retry < Base + graphql_name 'PipelineRetry' + + field :pipeline, + Types::Ci::PipelineType, + null: true, + description: 'The pipeline after mutation.' + + authorize :update_pipeline + + def resolve(id:) + pipeline = authorized_find!(id: id) + project = pipeline.project + + ::Ci::RetryPipelineService.new(project, current_user).execute(pipeline) + { + pipeline: pipeline, + errors: errors_on_object(pipeline) + } + end + end + end + end +end diff --git a/app/graphql/mutations/ci/pipeline_cancel.rb b/app/graphql/mutations/ci/pipeline_cancel.rb deleted file mode 100644 index bc881e2ac02..00000000000 --- a/app/graphql/mutations/ci/pipeline_cancel.rb +++ /dev/null @@ -1,22 +0,0 @@ -# frozen_string_literal: true - -module Mutations - module Ci - class PipelineCancel < Base - graphql_name 'PipelineCancel' - - authorize :update_pipeline - - def resolve(id:) - pipeline = authorized_find!(id: id) - - if pipeline.cancelable? - pipeline.cancel_running - { success: true, errors: [] } - else - { success: false, errors: ['Pipeline is not cancelable'] } - end - end - end - end -end diff --git a/app/graphql/mutations/ci/pipeline_destroy.rb b/app/graphql/mutations/ci/pipeline_destroy.rb deleted file mode 100644 index bb24d416583..00000000000 --- a/app/graphql/mutations/ci/pipeline_destroy.rb +++ /dev/null @@ -1,22 +0,0 @@ -# frozen_string_literal: true - -module Mutations - module Ci - class PipelineDestroy < Base - graphql_name 'PipelineDestroy' - - authorize :destroy_pipeline - - def resolve(id:) - pipeline = authorized_find!(id: id) - project = pipeline.project - - result = ::Ci::DestroyPipelineService.new(project, current_user).execute(pipeline) - { - success: result.success?, - errors: result.errors - } - end - end - end -end diff --git a/app/graphql/mutations/ci/pipeline_retry.rb b/app/graphql/mutations/ci/pipeline_retry.rb deleted file mode 100644 index 0669bfc449c..00000000000 --- a/app/graphql/mutations/ci/pipeline_retry.rb +++ /dev/null @@ -1,27 +0,0 @@ -# frozen_string_literal: true - -module Mutations - module Ci - class PipelineRetry < Base - graphql_name 'PipelineRetry' - - field :pipeline, - Types::Ci::PipelineType, - null: true, - description: 'The pipeline after mutation' - - authorize :update_pipeline - - def resolve(id:) - pipeline = authorized_find!(id: id) - project = pipeline.project - - ::Ci::RetryPipelineService.new(project, current_user).execute(pipeline) - { - pipeline: pipeline, - errors: errors_on_object(pipeline) - } - end - end - end -end diff --git a/app/graphql/mutations/commits/create.rb b/app/graphql/mutations/commits/create.rb index 2b9107350fd..ae14401558b 100644 --- a/app/graphql/mutations/commits/create.rb +++ b/app/graphql/mutations/commits/create.rb @@ -9,15 +9,15 @@ module Mutations argument :project_path, GraphQL::ID_TYPE, required: true, - description: 'Project full path the branch is associated with' + description: 'Project full path the branch is associated with.' argument :branch, GraphQL::STRING_TYPE, required: true, - description: 'Name of the branch to commit into, it can be a new branch' + description: 'Name of the branch to commit into, it can be a new branch.' argument :start_branch, GraphQL::STRING_TYPE, required: false, - description: 'If on a new branch, name of the original branch' + description: 'If on a new branch, name of the original branch.' argument :message, GraphQL::STRING_TYPE, @@ -27,12 +27,12 @@ module Mutations argument :actions, [Types::CommitActionType], required: true, - description: 'Array of action hashes to commit as a batch' + description: 'Array of action hashes to commit as a batch.' field :commit, Types::CommitType, null: true, - description: 'The commit after mutation' + description: 'The commit after mutation.' authorize :push_code diff --git a/app/graphql/mutations/concerns/mutations/authorizes_project.rb b/app/graphql/mutations/concerns/mutations/authorizes_project.rb deleted file mode 100644 index 87341525d6c..00000000000 --- a/app/graphql/mutations/concerns/mutations/authorizes_project.rb +++ /dev/null @@ -1,17 +0,0 @@ -# frozen_string_literal: true - -module Mutations - module AuthorizesProject - include ResolvesProject - - def authorized_find_project!(full_path:) - authorized_find!(full_path: full_path) - end - - private - - def find_object(full_path:) - resolve_project(full_path: full_path) - end - end -end diff --git a/app/graphql/mutations/concerns/mutations/finds_project.rb b/app/graphql/mutations/concerns/mutations/finds_project.rb new file mode 100644 index 00000000000..577f9dc90f8 --- /dev/null +++ b/app/graphql/mutations/concerns/mutations/finds_project.rb @@ -0,0 +1,11 @@ +# frozen_string_literal: true + +module Mutations + module FindsProject + private + + def find_object(full_path) + Project.find_by_full_path(full_path) + end + end +end diff --git a/app/graphql/mutations/concerns/mutations/resolves_namespace.rb b/app/graphql/mutations/concerns/mutations/resolves_namespace.rb new file mode 100644 index 00000000000..35009623c69 --- /dev/null +++ b/app/graphql/mutations/concerns/mutations/resolves_namespace.rb @@ -0,0 +1,15 @@ +# frozen_string_literal: true + +module Mutations + module ResolvesNamespace + extend ActiveSupport::Concern + + def resolve_namespace(full_path:) + namespace_resolver.resolve(full_path: full_path) + end + + def namespace_resolver + Resolvers::NamespaceResolver.new(object: nil, context: context, field: nil) + end + end +end diff --git a/app/graphql/mutations/concerns/mutations/resolves_resource_parent.rb b/app/graphql/mutations/concerns/mutations/resolves_resource_parent.rb index 04a9abf9529..e2b3f4b046f 100644 --- a/app/graphql/mutations/concerns/mutations/resolves_resource_parent.rb +++ b/app/graphql/mutations/concerns/mutations/resolves_resource_parent.rb @@ -9,11 +9,11 @@ module Mutations included do argument :project_path, GraphQL::ID_TYPE, required: false, - description: 'The project full path the resource is associated with' + description: 'The project full path the resource is associated with.' argument :group_path, GraphQL::ID_TYPE, required: false, - description: 'The group full path the resource is associated with' + description: 'The group full path the resource is associated with.' end def ready?(**args) diff --git a/app/graphql/mutations/concerns/mutations/resolves_subscription.rb b/app/graphql/mutations/concerns/mutations/resolves_subscription.rb index e8c5d0d404d..e26ae7d228c 100644 --- a/app/graphql/mutations/concerns/mutations/resolves_subscription.rb +++ b/app/graphql/mutations/concerns/mutations/resolves_subscription.rb @@ -7,7 +7,7 @@ module Mutations argument :subscribed_state, GraphQL::BOOLEAN_TYPE, required: true, - description: 'The desired state of the subscription' + description: 'The desired state of the subscription.' end def resolve(project_path:, iid:, subscribed_state:) diff --git a/app/graphql/mutations/concerns/mutations/spammable_mutation_fields.rb b/app/graphql/mutations/concerns/mutations/spammable_mutation_fields.rb index 7aef55f8011..e5df8565618 100644 --- a/app/graphql/mutations/concerns/mutations/spammable_mutation_fields.rb +++ b/app/graphql/mutations/concerns/mutations/spammable_mutation_fields.rb @@ -8,7 +8,7 @@ module Mutations field :spam, GraphQL::BOOLEAN_TYPE, null: true, - description: 'Indicates whether the operation returns a record detected as spam' + description: 'Indicates whether the operation returns a record detected as spam.' end def with_spam_params(&block) diff --git a/app/graphql/mutations/container_expiration_policies/update.rb b/app/graphql/mutations/container_expiration_policies/update.rb index 4bff04bb705..37cf2fa6bf3 100644 --- a/app/graphql/mutations/container_expiration_policies/update.rb +++ b/app/graphql/mutations/container_expiration_policies/update.rb @@ -12,7 +12,7 @@ module Mutations argument :project_path, GraphQL::ID_TYPE, required: true, - description: 'The project path where the container expiration policy is located' + description: 'The project path where the container expiration policy is located.' argument :enabled, GraphQL::BOOLEAN_TYPE, @@ -47,7 +47,7 @@ module Mutations field :container_expiration_policy, Types::ContainerExpirationPolicyType, null: true, - description: 'The container expiration policy after mutation' + description: 'The container expiration policy after mutation.' def resolve(project_path:, **args) project = authorized_find!(full_path: project_path) diff --git a/app/graphql/mutations/container_repositories/destroy_tags.rb b/app/graphql/mutations/container_repositories/destroy_tags.rb index ca6a67867c3..636ceccee04 100644 --- a/app/graphql/mutations/container_repositories/destroy_tags.rb +++ b/app/graphql/mutations/container_repositories/destroy_tags.rb @@ -28,7 +28,7 @@ module Mutations field :deleted_tag_names, [GraphQL::STRING_TYPE], - description: 'Deleted container repository tags', + description: 'Deleted container repository tags.', null: false def resolve(id:, tag_names:) diff --git a/app/graphql/mutations/custom_emoji/create.rb b/app/graphql/mutations/custom_emoji/create.rb index d912a29d12e..9ec96be0f26 100644 --- a/app/graphql/mutations/custom_emoji/create.rb +++ b/app/graphql/mutations/custom_emoji/create.rb @@ -12,20 +12,20 @@ module Mutations field :custom_emoji, Types::CustomEmojiType, null: true, - description: 'The new custom emoji' + description: 'The new custom emoji.' argument :group_path, GraphQL::ID_TYPE, required: true, - description: 'Namespace full path the emoji is associated with' + description: 'Namespace full path the emoji is associated with.' argument :name, GraphQL::STRING_TYPE, required: true, - description: 'Name of the emoji' + description: 'Name of the emoji.' argument :url, GraphQL::STRING_TYPE, required: true, as: :file, - description: 'Location of the emoji file' + description: 'Location of the emoji file.' def resolve(group_path:, **args) group = authorized_find!(group_path: group_path) diff --git a/app/graphql/mutations/design_management/base.rb b/app/graphql/mutations/design_management/base.rb index 69fd22e46cd..14d85885793 100644 --- a/app/graphql/mutations/design_management/base.rb +++ b/app/graphql/mutations/design_management/base.rb @@ -7,11 +7,11 @@ module Mutations argument :project_path, GraphQL::ID_TYPE, required: true, - description: "The project where the issue is to upload designs for" + description: "The project where the issue is to upload designs for." argument :iid, GraphQL::ID_TYPE, required: true, - description: "The IID of the issue to modify designs for" + description: "The IID of the issue to modify designs for." private diff --git a/app/graphql/mutations/design_management/delete.rb b/app/graphql/mutations/design_management/delete.rb index d2ef2c9bcca..f604542edef 100644 --- a/app/graphql/mutations/design_management/delete.rb +++ b/app/graphql/mutations/design_management/delete.rb @@ -9,14 +9,14 @@ module Mutations argument :filenames, [GraphQL::STRING_TYPE], required: true, - description: "The filenames of the designs to delete", + description: "The filenames of the designs to delete.", prepare: ->(names, _ctx) do names.presence || (raise Errors::ArgumentError, 'no filenames') end field :version, Types::DesignManagement::VersionType, null: true, # null on error - description: 'The new version in which the designs are deleted' + description: 'The new version in which the designs are deleted.' authorize :destroy_design diff --git a/app/graphql/mutations/design_management/move.rb b/app/graphql/mutations/design_management/move.rb index aed4cfec0fd..fe280e926d2 100644 --- a/app/graphql/mutations/design_management/move.rb +++ b/app/graphql/mutations/design_management/move.rb @@ -8,17 +8,17 @@ module Mutations DesignID = ::Types::GlobalIDType[::DesignManagement::Design] argument :id, DesignID, required: true, as: :current_design, - description: "ID of the design to move" + description: "ID of the design to move." argument :previous, DesignID, required: false, as: :previous_design, - description: "ID of the immediately preceding design" + description: "ID of the immediately preceding design." argument :next, DesignID, required: false, as: :next_design, - description: "ID of the immediately following design" + description: "ID of the immediately following design." field :design_collection, Types::DesignManagement::DesignCollectionType, null: true, - description: "The current state of the collection" + description: "The current state of the collection." def resolve(**args) service = ::DesignManagement::MoveDesignsService.new(current_user, parameters(**args)) diff --git a/app/graphql/mutations/design_management/upload.rb b/app/graphql/mutations/design_management/upload.rb index 1ed7f8e49e6..2ccf2ef8ff5 100644 --- a/app/graphql/mutations/design_management/upload.rb +++ b/app/graphql/mutations/design_management/upload.rb @@ -7,13 +7,13 @@ module Mutations argument :files, [ApolloUploadServer::Upload], required: true, - description: "The files to upload" + description: "The files to upload." authorize :create_design field :designs, [Types::DesignManagement::DesignType], null: false, - description: "The designs that were uploaded by the mutation" + description: "The designs that were uploaded by the mutation." field :skipped_designs, [Types::DesignManagement::DesignType], null: false, diff --git a/app/graphql/mutations/discussions/toggle_resolve.rb b/app/graphql/mutations/discussions/toggle_resolve.rb index 0e3baf8d548..c9834c946b2 100644 --- a/app/graphql/mutations/discussions/toggle_resolve.rb +++ b/app/graphql/mutations/discussions/toggle_resolve.rb @@ -10,17 +10,17 @@ module Mutations argument :id, Types::GlobalIDType[Discussion], required: true, - description: 'The global ID of the discussion' + description: 'The global ID of the discussion.' argument :resolve, GraphQL::BOOLEAN_TYPE, required: true, - description: 'Will resolve the discussion when true, and unresolve the discussion when false' + description: 'Will resolve the discussion when true, and unresolve the discussion when false.' field :discussion, Types::Notes::DiscussionType, null: true, - description: 'The discussion after mutation' + description: 'The discussion after mutation.' def resolve(id:, resolve:) discussion = authorized_find_discussion!(id: id) diff --git a/app/graphql/mutations/environments/canary_ingress/update.rb b/app/graphql/mutations/environments/canary_ingress/update.rb index 1798143053a..45dcc8314a0 100644 --- a/app/graphql/mutations/environments/canary_ingress/update.rb +++ b/app/graphql/mutations/environments/canary_ingress/update.rb @@ -11,12 +11,12 @@ module Mutations argument :id, ::Types::GlobalIDType[::Environment], required: true, - description: 'The global ID of the environment to update' + description: 'The global ID of the environment to update.' argument :weight, GraphQL::INT_TYPE, required: true, - description: 'The weight of the Canary Ingress' + description: 'The weight of the Canary Ingress.' def resolve(id:, **kwargs) environment = authorized_find!(id: id) diff --git a/app/graphql/mutations/issues/base.rb b/app/graphql/mutations/issues/base.rb index 529d48f3cd0..b25987a43f6 100644 --- a/app/graphql/mutations/issues/base.rb +++ b/app/graphql/mutations/issues/base.rb @@ -7,16 +7,16 @@ module Mutations argument :project_path, GraphQL::ID_TYPE, required: true, - description: "The project the issue to mutate is in" + description: "The project the issue to mutate is in." argument :iid, GraphQL::STRING_TYPE, required: true, - description: "The IID of the issue to mutate" + description: "The IID of the issue to mutate." field :issue, Types::IssueType, null: true, - description: "The issue after mutation" + description: "The issue after mutation." authorize :update_issue diff --git a/app/graphql/mutations/issues/create.rb b/app/graphql/mutations/issues/create.rb index 1454916bc77..18b80ff1736 100644 --- a/app/graphql/mutations/issues/create.rb +++ b/app/graphql/mutations/issues/create.rb @@ -12,11 +12,11 @@ module Mutations argument :project_path, GraphQL::ID_TYPE, required: true, - description: 'Project full path the issue is associated with' + description: 'Project full path the issue is associated with.' argument :iid, GraphQL::INT_TYPE, required: false, - description: 'The IID (internal ID) of a project issue. Only admins and project owners can modify' + description: 'The IID (internal ID) of a project issue. Only admins and project owners can modify.' argument :title, GraphQL::STRING_TYPE, required: true, @@ -24,7 +24,7 @@ module Mutations argument :milestone_id, ::Types::GlobalIDType[::Milestone], required: false, - description: 'The ID of the milestone to assign to the issue. On update milestone will be removed if set to null' + description: 'The ID of the milestone to assign to the issue. On update milestone will be removed if set to null.' argument :labels, [GraphQL::STRING_TYPE], required: false, @@ -32,28 +32,28 @@ module Mutations argument :label_ids, [::Types::GlobalIDType[::Label]], required: false, - description: 'The IDs of labels to be added to the issue' + description: 'The IDs of labels to be added to the issue.' argument :created_at, Types::TimeType, required: false, - description: 'Timestamp when the issue was created. Available only for admins and project owners' + description: 'Timestamp when the issue was created. Available only for admins and project owners.' argument :merge_request_to_resolve_discussions_of, ::Types::GlobalIDType[::MergeRequest], required: false, - description: 'The IID of a merge request for which to resolve discussions' + description: 'The IID of a merge request for which to resolve discussions.' argument :discussion_to_resolve, GraphQL::STRING_TYPE, required: false, - description: 'The ID of a discussion to resolve. Also pass `merge_request_to_resolve_discussions_of`' + description: 'The ID of a discussion to resolve. Also pass `merge_request_to_resolve_discussions_of`.' argument :assignee_ids, [::Types::GlobalIDType[::User]], required: false, - description: 'The array of user IDs to assign to the issue' + description: 'The array of user IDs to assign to the issue.' field :issue, Types::IssueType, null: true, - description: 'The issue after mutation' + description: 'The issue after mutation.' def ready?(**args) if args.slice(*mutually_exclusive_label_args).size > 1 diff --git a/app/graphql/mutations/issues/move.rb b/app/graphql/mutations/issues/move.rb index e6971c9df8c..3f97325c921 100644 --- a/app/graphql/mutations/issues/move.rb +++ b/app/graphql/mutations/issues/move.rb @@ -8,7 +8,7 @@ module Mutations argument :target_project_path, GraphQL::ID_TYPE, required: true, - description: 'The project to move the issue to' + description: 'The project to move the issue to.' def resolve(project_path:, iid:, target_project_path:) Gitlab::QueryLimiting.whitelist('https://gitlab.com/gitlab-org/gitlab/-/issues/267762') diff --git a/app/graphql/mutations/issues/set_due_date.rb b/app/graphql/mutations/issues/set_due_date.rb index effd863c541..da7892f4ed4 100644 --- a/app/graphql/mutations/issues/set_due_date.rb +++ b/app/graphql/mutations/issues/set_due_date.rb @@ -8,7 +8,7 @@ module Mutations argument :due_date, Types::TimeType, required: true, - description: 'The desired due date for the issue' + description: 'The desired due date for the issue.' def resolve(project_path:, iid:, due_date:) issue = authorized_find!(project_path: project_path, iid: iid) diff --git a/app/graphql/mutations/issues/set_locked.rb b/app/graphql/mutations/issues/set_locked.rb index 63a8483067a..611226e48ad 100644 --- a/app/graphql/mutations/issues/set_locked.rb +++ b/app/graphql/mutations/issues/set_locked.rb @@ -8,7 +8,7 @@ module Mutations argument :locked, GraphQL::BOOLEAN_TYPE, required: true, - description: 'Whether or not to lock discussion on the issue' + description: 'Whether or not to lock discussion on the issue.' def resolve(project_path:, iid:, locked:) issue = authorized_find!(project_path: project_path, iid: iid) diff --git a/app/graphql/mutations/issues/update.rb b/app/graphql/mutations/issues/update.rb index d34e351b2a6..eea2cd49aa0 100644 --- a/app/graphql/mutations/issues/update.rb +++ b/app/graphql/mutations/issues/update.rb @@ -13,18 +13,18 @@ module Mutations argument :milestone_id, GraphQL::ID_TYPE, # rubocop: disable Graphql/IDType required: false, - description: 'The ID of the milestone to assign to the issue. On update milestone will be removed if set to null' + description: 'The ID of the milestone to assign to the issue. On update milestone will be removed if set to null.' argument :add_label_ids, [GraphQL::ID_TYPE], required: false, - description: 'The IDs of labels to be added to the issue' + description: 'The IDs of labels to be added to the issue.' argument :remove_label_ids, [GraphQL::ID_TYPE], required: false, - description: 'The IDs of labels to be removed from the issue' + description: 'The IDs of labels to be removed from the issue.' argument :state_event, Types::IssueStateEventEnum, - description: 'Close or reopen an issue', + description: 'Close or reopen an issue.', required: false def resolve(project_path:, iid:, **args) diff --git a/app/graphql/mutations/jira_import/import_users.rb b/app/graphql/mutations/jira_import/import_users.rb index 0d59537b903..616ef390657 100644 --- a/app/graphql/mutations/jira_import/import_users.rb +++ b/app/graphql/mutations/jira_import/import_users.rb @@ -14,10 +14,10 @@ module Mutations argument :project_path, GraphQL::ID_TYPE, required: true, - description: 'The project to import the Jira users into' + description: 'The project to import the Jira users into.' argument :start_at, GraphQL::INT_TYPE, required: false, - description: 'The index of the record the import should started at, default 0 (50 records returned)' + description: 'The index of the record the import should started at, default 0 (50 records returned).' def resolve(project_path:, start_at: 0) project = authorized_find!(full_path: project_path) diff --git a/app/graphql/mutations/jira_import/start.rb b/app/graphql/mutations/jira_import/start.rb index eda28059272..3d50ebde13a 100644 --- a/app/graphql/mutations/jira_import/start.rb +++ b/app/graphql/mutations/jira_import/start.rb @@ -10,21 +10,21 @@ module Mutations field :jira_import, Types::JiraImportType, null: true, - description: 'The Jira import data after mutation' + description: 'The Jira import data after mutation.' argument :project_path, GraphQL::ID_TYPE, required: true, - description: 'The project to import the Jira project into' + description: 'The project to import the Jira project into.' argument :jira_project_key, GraphQL::STRING_TYPE, required: true, - description: 'Project key of the importer Jira project' + description: 'Project key of the importer Jira project.' argument :jira_project_name, GraphQL::STRING_TYPE, required: false, - description: 'Project name of the importer Jira project' + description: 'Project name of the importer Jira project.' argument :users_mapping, [Types::JiraUsersMappingInputType], required: false, - description: 'The mapping of Jira to GitLab users' + description: 'The mapping of Jira to GitLab users.' def resolve(project_path:, jira_project_key:, users_mapping:) project = authorized_find!(full_path: project_path) diff --git a/app/graphql/mutations/labels/create.rb b/app/graphql/mutations/labels/create.rb index cb03651618e..ccbd1c37cbf 100644 --- a/app/graphql/mutations/labels/create.rb +++ b/app/graphql/mutations/labels/create.rb @@ -10,20 +10,20 @@ module Mutations field :label, Types::LabelType, null: true, - description: 'The label after mutation' + description: 'The label after mutation.' argument :title, GraphQL::STRING_TYPE, required: true, - description: 'Title of the label' + description: 'Title of the label.' argument :description, GraphQL::STRING_TYPE, required: false, - description: 'Description of the label' + description: 'Description of the label.' argument :color, GraphQL::STRING_TYPE, required: false, default_value: Label::DEFAULT_COLOR, - description: "The color of the label given in 6-digit hex notation with leading '#' sign (e.g. #FFAABB) or one of the CSS color names in https://developer.mozilla.org/en-US/docs/Web/CSS/color_value#Color_keywords" + description: "The color of the label given in 6-digit hex notation with leading '#' sign (e.g. #FFAABB) or one of the CSS color names in https://developer.mozilla.org/en-US/docs/Web/CSS/color_value#Color_keywords." authorize :admin_label diff --git a/app/graphql/mutations/merge_requests/base.rb b/app/graphql/mutations/merge_requests/base.rb index 57920259cf7..cd919a19ba2 100644 --- a/app/graphql/mutations/merge_requests/base.rb +++ b/app/graphql/mutations/merge_requests/base.rb @@ -7,16 +7,16 @@ module Mutations argument :project_path, GraphQL::ID_TYPE, required: true, - description: "The project the merge request to mutate is in" + description: "The project the merge request to mutate is in." argument :iid, GraphQL::STRING_TYPE, required: true, - description: "The IID of the merge request to mutate" + description: "The IID of the merge request to mutate." field :merge_request, Types::MergeRequestType, null: true, - description: "The merge request after mutation" + description: "The merge request after mutation." authorize :update_merge_request diff --git a/app/graphql/mutations/merge_requests/create.rb b/app/graphql/mutations/merge_requests/create.rb index fd2cd58a5ee..64fa8417e50 100644 --- a/app/graphql/mutations/merge_requests/create.rb +++ b/app/graphql/mutations/merge_requests/create.rb @@ -9,7 +9,7 @@ module Mutations argument :project_path, GraphQL::ID_TYPE, required: true, - description: 'Project full path the merge request is associated with' + description: 'Project full path the merge request is associated with.' argument :title, GraphQL::STRING_TYPE, required: true, @@ -34,7 +34,7 @@ module Mutations field :merge_request, Types::MergeRequestType, null: true, - description: 'The merge request after mutation' + description: 'The merge request after mutation.' authorize :create_merge_request_from diff --git a/app/graphql/mutations/merge_requests/update.rb b/app/graphql/mutations/merge_requests/update.rb index b583fdfca9b..4721ebab41b 100644 --- a/app/graphql/mutations/merge_requests/update.rb +++ b/app/graphql/mutations/merge_requests/update.rb @@ -20,7 +20,7 @@ module Mutations description: copy_field_description(Types::MergeRequestType, :description) def resolve(args) - merge_request = authorized_find!(args.slice(:project_path, :iid)) + merge_request = authorized_find!(**args.slice(:project_path, :iid)) attributes = args.slice(:title, :description, :target_branch).compact ::MergeRequests::UpdateService diff --git a/app/graphql/mutations/metrics/dashboard/annotations/create.rb b/app/graphql/mutations/metrics/dashboard/annotations/create.rb index c2ec88c68ed..85937809eb8 100644 --- a/app/graphql/mutations/metrics/dashboard/annotations/create.rb +++ b/app/graphql/mutations/metrics/dashboard/annotations/create.rb @@ -15,35 +15,35 @@ module Mutations field :annotation, Types::Metrics::Dashboards::AnnotationType, null: true, - description: 'The created annotation' + description: 'The created annotation.' argument :environment_id, ::Types::GlobalIDType[::Environment], required: false, - description: 'The global ID of the environment to add an annotation to' + description: 'The global ID of the environment to add an annotation to.' argument :cluster_id, ::Types::GlobalIDType[::Clusters::Cluster], required: false, - description: 'The global ID of the cluster to add an annotation to' + description: 'The global ID of the cluster to add an annotation to.' argument :starting_at, Types::TimeType, required: true, - description: 'Timestamp indicating starting moment to which the annotation relates' + description: 'Timestamp indicating starting moment to which the annotation relates.' argument :ending_at, Types::TimeType, required: false, - description: 'Timestamp indicating ending moment to which the annotation relates' + description: 'Timestamp indicating ending moment to which the annotation relates.' argument :dashboard_path, GraphQL::STRING_TYPE, required: true, - description: 'The path to a file defining the dashboard on which the annotation should be added' + description: 'The path to a file defining the dashboard on which the annotation should be added.' argument :description, GraphQL::STRING_TYPE, required: true, - description: 'The description of the annotation' + description: 'The description of the annotation.' AnnotationSource = Struct.new(:object, keyword_init: true) do def type_keys diff --git a/app/graphql/mutations/metrics/dashboard/annotations/delete.rb b/app/graphql/mutations/metrics/dashboard/annotations/delete.rb index 5d6763d8711..e0fadff13d4 100644 --- a/app/graphql/mutations/metrics/dashboard/annotations/delete.rb +++ b/app/graphql/mutations/metrics/dashboard/annotations/delete.rb @@ -11,7 +11,7 @@ module Mutations argument :id, ::Types::GlobalIDType[::Metrics::Dashboard::Annotation], required: true, - description: 'Global ID of the annotation to delete' + description: 'Global ID of the annotation to delete.' def resolve(id:) annotation = authorized_find!(id: id) diff --git a/app/graphql/mutations/namespace/package_settings/update.rb b/app/graphql/mutations/namespace/package_settings/update.rb new file mode 100644 index 00000000000..ca21c3418fc --- /dev/null +++ b/app/graphql/mutations/namespace/package_settings/update.rb @@ -0,0 +1,54 @@ +# frozen_string_literal: true + +module Mutations + module Namespace + module PackageSettings + class Update < Mutations::BaseMutation + include Mutations::ResolvesNamespace + + graphql_name 'UpdateNamespacePackageSettings' + + authorize :create_package_settings + + argument :namespace_path, + GraphQL::ID_TYPE, + required: true, + description: 'The namespace path where the namespace package setting is located.' + + argument :maven_duplicates_allowed, + GraphQL::BOOLEAN_TYPE, + required: false, + description: copy_field_description(Types::Namespace::PackageSettingsType, :maven_duplicates_allowed) + + argument :maven_duplicate_exception_regex, + Types::UntrustedRegexp, + required: false, + description: copy_field_description(Types::Namespace::PackageSettingsType, :maven_duplicate_exception_regex) + + field :package_settings, + Types::Namespace::PackageSettingsType, + null: true, + description: 'The namespace package setting after mutation.' + + def resolve(namespace_path:, **args) + namespace = authorized_find!(namespace_path: namespace_path) + + result = ::Namespaces::PackageSettings::UpdateService + .new(container: namespace, current_user: current_user, params: args) + .execute + + { + package_settings: result.payload[:package_settings], + errors: result.errors + } + end + + private + + def find_object(namespace_path:) + resolve_namespace(full_path: namespace_path) + end + end + end + end +end diff --git a/app/graphql/mutations/notes/base.rb b/app/graphql/mutations/notes/base.rb index f2678211335..ff401167ba1 100644 --- a/app/graphql/mutations/notes/base.rb +++ b/app/graphql/mutations/notes/base.rb @@ -6,7 +6,7 @@ module Mutations field :note, Types::Notes::NoteType, null: true, - description: 'The note after mutation' + description: 'The note after mutation.' private diff --git a/app/graphql/mutations/notes/create/base.rb b/app/graphql/mutations/notes/create/base.rb index a1d81c62d91..2351af01813 100644 --- a/app/graphql/mutations/notes/create/base.rb +++ b/app/graphql/mutations/notes/create/base.rb @@ -11,7 +11,7 @@ module Mutations argument :noteable_id, ::Types::GlobalIDType[::Noteable], required: true, - description: 'The global ID of the resource to add a note to' + description: 'The global ID of the resource to add a note to.' argument :body, GraphQL::STRING_TYPE, diff --git a/app/graphql/mutations/notes/create/note.rb b/app/graphql/mutations/notes/create/note.rb index f1cd3bddca8..7af93521e0d 100644 --- a/app/graphql/mutations/notes/create/note.rb +++ b/app/graphql/mutations/notes/create/note.rb @@ -9,7 +9,7 @@ module Mutations argument :discussion_id, ::Types::GlobalIDType[::Discussion], required: false, - description: 'The global ID of the discussion this note is in reply to' + description: 'The global ID of the discussion this note is in reply to.' private diff --git a/app/graphql/mutations/notes/destroy.rb b/app/graphql/mutations/notes/destroy.rb index 0e6a215bf00..21b2cd15a7e 100644 --- a/app/graphql/mutations/notes/destroy.rb +++ b/app/graphql/mutations/notes/destroy.rb @@ -10,7 +10,7 @@ module Mutations argument :id, ::Types::GlobalIDType[::Note], required: true, - description: 'The global ID of the note to destroy' + description: 'The global ID of the note to destroy.' def resolve(id:) note = authorized_find!(id: id) diff --git a/app/graphql/mutations/notes/reposition_image_diff_note.rb b/app/graphql/mutations/notes/reposition_image_diff_note.rb index 15bfb361b13..31d3b7c9bb0 100644 --- a/app/graphql/mutations/notes/reposition_image_diff_note.rb +++ b/app/graphql/mutations/notes/reposition_image_diff_note.rb @@ -16,7 +16,7 @@ module Mutations loads: Types::Notes::NoteType, as: :note, required: true, - description: 'The global ID of the DiffNote to update' + description: 'The global ID of the DiffNote to update.' argument :position, Types::Notes::UpdateDiffImagePositionInputType, diff --git a/app/graphql/mutations/notes/update/base.rb b/app/graphql/mutations/notes/update/base.rb index 42dac20f5d3..4edb7429b97 100644 --- a/app/graphql/mutations/notes/update/base.rb +++ b/app/graphql/mutations/notes/update/base.rb @@ -11,7 +11,7 @@ module Mutations argument :id, ::Types::GlobalIDType[::Note], required: true, - description: 'The global ID of the note to update' + description: 'The global ID of the note to update.' def resolve(args) note = authorized_find!(id: args[:id]) diff --git a/app/graphql/mutations/releases/base.rb b/app/graphql/mutations/releases/base.rb index d53cfbe6a11..dd1724fe320 100644 --- a/app/graphql/mutations/releases/base.rb +++ b/app/graphql/mutations/releases/base.rb @@ -7,7 +7,7 @@ module Mutations argument :project_path, GraphQL::ID_TYPE, required: true, - description: 'Full path of the project the release is associated with' + description: 'Full path of the project the release is associated with.' private diff --git a/app/graphql/mutations/releases/create.rb b/app/graphql/mutations/releases/create.rb index 156cd252848..91ac256033e 100644 --- a/app/graphql/mutations/releases/create.rb +++ b/app/graphql/mutations/releases/create.rb @@ -8,23 +8,23 @@ module Mutations field :release, Types::ReleaseType, null: true, - description: 'The release after mutation' + description: 'The release after mutation.' argument :tag_name, GraphQL::STRING_TYPE, required: true, as: :tag, - description: 'Name of the tag to associate with the release' + description: 'Name of the tag to associate with the release.' argument :ref, GraphQL::STRING_TYPE, required: false, - description: 'The commit SHA or branch name to use if creating a new tag' + description: 'The commit SHA or branch name to use if creating a new tag.' argument :name, GraphQL::STRING_TYPE, required: false, - description: 'Name of the release' + description: 'Name of the release.' argument :description, GraphQL::STRING_TYPE, required: false, - description: 'Description (also known as "release notes") of the release' + description: 'Description (also known as "release notes") of the release.' argument :released_at, Types::TimeType, required: false, @@ -36,7 +36,7 @@ module Mutations argument :assets, Types::ReleaseAssetsInputType, required: false, - description: 'Assets associated to the release' + description: 'Assets associated to the release.' authorize :create_release diff --git a/app/graphql/mutations/releases/update.rb b/app/graphql/mutations/releases/update.rb index bf72b907679..dff743254bd 100644 --- a/app/graphql/mutations/releases/update.rb +++ b/app/graphql/mutations/releases/update.rb @@ -12,19 +12,19 @@ module Mutations argument :tag_name, GraphQL::STRING_TYPE, required: true, as: :tag, - description: 'Name of the tag associated with the release' + description: 'Name of the tag associated with the release.' argument :name, GraphQL::STRING_TYPE, required: false, - description: 'Name of the release' + description: 'Name of the release.' argument :description, GraphQL::STRING_TYPE, required: false, - description: 'Description (release notes) of the release' + description: 'Description (release notes) of the release.' argument :released_at, Types::TimeType, required: false, - description: 'The release date' + description: 'The release date.' argument :milestones, [GraphQL::STRING_TYPE], required: false, @@ -51,17 +51,17 @@ module Mutations params = scalars.with_indifferent_access - release_result = ::Releases::UpdateService.new(project, current_user, params).execute + result = ::Releases::UpdateService.new(project, current_user, params).execute - if release_result[:status] == :success + if result[:status] == :success { - release: release_result[:release], + release: result[:release], errors: [] } else { release: nil, - errors: [release_result[:message]] + errors: [result[:message]] } end end diff --git a/app/graphql/mutations/snippets/base.rb b/app/graphql/mutations/snippets/base.rb index 023f876d035..5196bc5c7ed 100644 --- a/app/graphql/mutations/snippets/base.rb +++ b/app/graphql/mutations/snippets/base.rb @@ -6,7 +6,7 @@ module Mutations field :snippet, Types::SnippetType, null: true, - description: 'The snippet after mutation' + description: 'The snippet after mutation.' private diff --git a/app/graphql/mutations/snippets/create.rb b/app/graphql/mutations/snippets/create.rb index 56c3b398949..b4485e28c5a 100644 --- a/app/graphql/mutations/snippets/create.rb +++ b/app/graphql/mutations/snippets/create.rb @@ -12,30 +12,30 @@ module Mutations field :snippet, Types::SnippetType, null: true, - description: 'The snippet after mutation' + description: 'The snippet after mutation.' argument :title, GraphQL::STRING_TYPE, required: true, - description: 'Title of the snippet' + description: 'Title of the snippet.' argument :description, GraphQL::STRING_TYPE, required: false, - description: 'Description of the snippet' + description: 'Description of the snippet.' argument :visibility_level, Types::VisibilityLevelsEnum, - description: 'The visibility level of the snippet', + description: 'The visibility level of the snippet.', required: true argument :project_path, GraphQL::ID_TYPE, required: false, - description: 'The project full path the snippet is associated with' + description: 'The project full path the snippet is associated with.' argument :uploaded_files, [GraphQL::STRING_TYPE], required: false, - description: 'The paths to files uploaded in the snippet description' + description: 'The paths to files uploaded in the snippet description.' argument :blob_actions, [Types::Snippets::BlobActionInputType], - description: 'Actions to perform over the snippet repository and blobs', + description: 'Actions to perform over the snippet repository and blobs.', required: false def resolve(project_path: nil, **args) diff --git a/app/graphql/mutations/snippets/destroy.rb b/app/graphql/mutations/snippets/destroy.rb index bee6503372d..9b00f62e2f9 100644 --- a/app/graphql/mutations/snippets/destroy.rb +++ b/app/graphql/mutations/snippets/destroy.rb @@ -9,7 +9,7 @@ module Mutations argument :id, ::Types::GlobalIDType[::Snippet], required: true, - description: 'The global ID of the snippet to destroy' + description: 'The global ID of the snippet to destroy.' def resolve(id:) snippet = authorized_find!(id: id) diff --git a/app/graphql/mutations/snippets/mark_as_spam.rb b/app/graphql/mutations/snippets/mark_as_spam.rb index 2d6fea1f5ec..d6e3e131b81 100644 --- a/app/graphql/mutations/snippets/mark_as_spam.rb +++ b/app/graphql/mutations/snippets/mark_as_spam.rb @@ -7,7 +7,7 @@ module Mutations argument :id, ::Types::GlobalIDType[::Snippet], required: true, - description: 'The global ID of the snippet to update' + description: 'The global ID of the snippet to update.' def resolve(id:) snippet = authorized_find!(id: id) diff --git a/app/graphql/mutations/snippets/update.rb b/app/graphql/mutations/snippets/update.rb index 6df1ad6d8b9..930440fbd35 100644 --- a/app/graphql/mutations/snippets/update.rb +++ b/app/graphql/mutations/snippets/update.rb @@ -9,22 +9,22 @@ module Mutations argument :id, ::Types::GlobalIDType[::Snippet], required: true, - description: 'The global ID of the snippet to update' + description: 'The global ID of the snippet to update.' argument :title, GraphQL::STRING_TYPE, required: false, - description: 'Title of the snippet' + description: 'Title of the snippet.' argument :description, GraphQL::STRING_TYPE, required: false, - description: 'Description of the snippet' + description: 'Description of the snippet.' argument :visibility_level, Types::VisibilityLevelsEnum, - description: 'The visibility level of the snippet', + description: 'The visibility level of the snippet.', required: false argument :blob_actions, [Types::Snippets::BlobActionInputType], - description: 'Actions to perform over the snippet repository and blobs', + description: 'Actions to perform over the snippet repository and blobs.', required: false def resolve(id:, **args) diff --git a/app/graphql/mutations/terraform/state/base.rb b/app/graphql/mutations/terraform/state/base.rb index b1721c784b1..01f69934ea3 100644 --- a/app/graphql/mutations/terraform/state/base.rb +++ b/app/graphql/mutations/terraform/state/base.rb @@ -9,7 +9,7 @@ module Mutations argument :id, Types::GlobalIDType[::Terraform::State], required: true, - description: 'Global ID of the Terraform state' + description: 'Global ID of the Terraform state.' private diff --git a/app/graphql/mutations/todos/create.rb b/app/graphql/mutations/todos/create.rb index 53c88696fdd..814f7ec4fc4 100644 --- a/app/graphql/mutations/todos/create.rb +++ b/app/graphql/mutations/todos/create.rb @@ -10,11 +10,11 @@ module Mutations argument :target_id, Types::GlobalIDType[Todoable], required: true, - description: "The global ID of the to-do item's parent. Issues, merge requests, designs and epics are supported" + description: "The global ID of the to-do item's parent. Issues, merge requests, designs and epics are supported." field :todo, Types::TodoType, null: true, - description: 'The to-do created' + description: 'The to-do created.' def resolve(target_id:) id = ::Types::GlobalIDType[Todoable].coerce_isolated_input(target_id) diff --git a/app/graphql/mutations/todos/mark_all_done.rb b/app/graphql/mutations/todos/mark_all_done.rb index 97bbbeeaa2f..c8359953567 100644 --- a/app/graphql/mutations/todos/mark_all_done.rb +++ b/app/graphql/mutations/todos/mark_all_done.rb @@ -11,11 +11,11 @@ module Mutations [::Types::GlobalIDType[::Todo]], null: false, deprecated: { reason: 'Use todos', milestone: '13.2' }, - description: 'Ids of the updated todos' + description: 'Ids of the updated todos.' field :todos, [::Types::TodoType], null: false, - description: 'Updated todos' + description: 'Updated todos.' def resolve authorize!(current_user) diff --git a/app/graphql/mutations/todos/mark_done.rb b/app/graphql/mutations/todos/mark_done.rb index 2ae50846108..95144abb040 100644 --- a/app/graphql/mutations/todos/mark_done.rb +++ b/app/graphql/mutations/todos/mark_done.rb @@ -10,11 +10,11 @@ module Mutations argument :id, ::Types::GlobalIDType[::Todo], required: true, - description: 'The global ID of the todo to mark as done' + description: 'The global ID of the todo to mark as done.' field :todo, Types::TodoType, null: false, - description: 'The requested todo' + description: 'The requested todo.' def resolve(id:) todo = authorized_find!(id: id) diff --git a/app/graphql/mutations/todos/restore.rb b/app/graphql/mutations/todos/restore.rb index c532b455a16..e496627aec2 100644 --- a/app/graphql/mutations/todos/restore.rb +++ b/app/graphql/mutations/todos/restore.rb @@ -10,11 +10,11 @@ module Mutations argument :id, ::Types::GlobalIDType[::Todo], required: true, - description: 'The global ID of the todo to restore' + description: 'The global ID of the todo to restore.' field :todo, Types::TodoType, null: false, - description: 'The requested todo' + description: 'The requested todo.' def resolve(id:) todo = authorized_find!(id: id) diff --git a/app/graphql/mutations/todos/restore_many.rb b/app/graphql/mutations/todos/restore_many.rb index 59965589856..9263c1d9afe 100644 --- a/app/graphql/mutations/todos/restore_many.rb +++ b/app/graphql/mutations/todos/restore_many.rb @@ -10,16 +10,16 @@ module Mutations argument :ids, [::Types::GlobalIDType[::Todo]], required: true, - description: 'The global IDs of the todos to restore (a maximum of 50 is supported at once)' + description: 'The global IDs of the todos to restore (a maximum of 50 is supported at once).' field :updated_ids, [::Types::GlobalIDType[Todo]], null: false, - description: 'The IDs of the updated todo items', + description: 'The IDs of the updated todo items.', deprecated: { reason: 'Use todos', milestone: '13.2' } field :todos, [::Types::TodoType], null: false, - description: 'Updated todos' + description: 'Updated todos.' def resolve(ids:) check_update_amount_limit!(ids) -- cgit v1.2.3