diff options
Diffstat (limited to 'app/graphql/mutations')
106 files changed, 487 insertions, 321 deletions
diff --git a/app/graphql/mutations/admin/sidekiq_queues/delete_jobs.rb b/app/graphql/mutations/admin/sidekiq_queues/delete_jobs.rb index ea1502d4b62..d943816089f 100644 --- a/app/graphql/mutations/admin/sidekiq_queues/delete_jobs.rb +++ b/app/graphql/mutations/admin/sidekiq_queues/delete_jobs.rb @@ -10,15 +10,15 @@ module Mutations Gitlab::ApplicationContext::KNOWN_KEYS.each do |key| argument key, - GraphQL::STRING_TYPE, + GraphQL::Types::String, required: false, description: "Delete jobs matching #{key} in the context metadata" end argument :queue_name, - GraphQL::STRING_TYPE, + GraphQL::Types::String, required: true, - description: 'The name of the queue to delete jobs from.' + description: 'Name of the queue to delete jobs from.' field :result, Types::Admin::SidekiqQueues::DeleteJobsResponseType, diff --git a/app/graphql/mutations/alert_management/alerts/set_assignees.rb b/app/graphql/mutations/alert_management/alerts/set_assignees.rb index 517c20a85d0..c986111d290 100644 --- a/app/graphql/mutations/alert_management/alerts/set_assignees.rb +++ b/app/graphql/mutations/alert_management/alerts/set_assignees.rb @@ -7,14 +7,14 @@ module Mutations graphql_name 'AlertSetAssignees' argument :assignee_usernames, - [GraphQL::STRING_TYPE], + [GraphQL::Types::String], required: true, - description: 'The usernames to assign to the alert. Replaces existing assignees by default.' + description: 'Usernames to assign to the alert. Replaces existing assignees by default.' argument :operation_mode, Types::MutationOperationModeEnum, required: false, - description: 'The operation to perform. Defaults to REPLACE.' + description: 'Operation to perform. Defaults to REPLACE.' def resolve(args) alert = authorized_find!(project_path: args[:project_path], iid: args[:iid]) diff --git a/app/graphql/mutations/alert_management/base.rb b/app/graphql/mutations/alert_management/base.rb index 86908c1449c..d01f200107c 100644 --- a/app/graphql/mutations/alert_management/base.rb +++ b/app/graphql/mutations/alert_management/base.rb @@ -5,28 +5,28 @@ module Mutations class Base < BaseMutation include Gitlab::Utils::UsageData - argument :project_path, GraphQL::ID_TYPE, + argument :project_path, GraphQL::Types::ID, required: true, - description: "The project the alert to mutate is in." + description: "Project the alert to mutate is in." - argument :iid, GraphQL::STRING_TYPE, + argument :iid, GraphQL::Types::String, required: true, - description: "The IID of the alert to mutate." + description: "IID of the alert to mutate." field :alert, Types::AlertManagement::AlertType, null: true, - description: "The alert after mutation." + description: "Alert after mutation." field :todo, Types::TodoType, null: true, - description: "The to-do item after mutation." + description: "To-do item after mutation." field :issue, Types::IssueType, null: true, - description: "The issue created after mutation." + description: "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 54803855bcf..04840ac43bd 100644 --- a/app/graphql/mutations/alert_management/http_integration/create.rb +++ b/app/graphql/mutations/alert_management/http_integration/create.rb @@ -8,15 +8,15 @@ module Mutations graphql_name 'HttpIntegrationCreate' - argument :project_path, GraphQL::ID_TYPE, + argument :project_path, GraphQL::Types::ID, required: true, - description: 'The project to create the integration in.' + description: 'Project to create the integration in.' - argument :name, GraphQL::STRING_TYPE, + argument :name, GraphQL::Types::String, required: true, - description: 'The name of the integration.' + description: 'Name of the integration.' - argument :active, GraphQL::BOOLEAN_TYPE, + argument :active, GraphQL::Types::Boolean, required: true, description: 'Whether the integration is receiving alerts.' diff --git a/app/graphql/mutations/alert_management/http_integration/destroy.rb b/app/graphql/mutations/alert_management/http_integration/destroy.rb index d0420e2bcb5..dc5c73ecff6 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: "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 efa92bfe895..2f25d315d2e 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: "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 bf73a9eaae7..83ad7762408 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: "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 4e6e7995c10..78424e317b8 100644 --- a/app/graphql/mutations/alert_management/http_integration/update.rb +++ b/app/graphql/mutations/alert_management/http_integration/update.rb @@ -8,13 +8,13 @@ module Mutations argument :id, Types::GlobalIDType[::AlertManagement::HttpIntegration], required: true, - description: "The ID of the integration to mutate." + description: "ID of the integration to mutate." - argument :name, GraphQL::STRING_TYPE, + argument :name, GraphQL::Types::String, required: false, - description: "The name of the integration." + description: "Name of the integration." - argument :active, GraphQL::BOOLEAN_TYPE, + argument :active, GraphQL::Types::Boolean, required: false, description: "Whether the integration is receiving alerts." diff --git a/app/graphql/mutations/alert_management/prometheus_integration/create.rb b/app/graphql/mutations/alert_management/prometheus_integration/create.rb index 4d0a5a5cb13..0153bd0e42a 100644 --- a/app/graphql/mutations/alert_management/prometheus_integration/create.rb +++ b/app/graphql/mutations/alert_management/prometheus_integration/create.rb @@ -8,15 +8,15 @@ module Mutations graphql_name 'PrometheusIntegrationCreate' - argument :project_path, GraphQL::ID_TYPE, + argument :project_path, GraphQL::Types::ID, required: true, - description: 'The project to create the integration in.' + description: 'Project to create the integration in.' - argument :active, GraphQL::BOOLEAN_TYPE, + argument :active, GraphQL::Types::Boolean, required: true, description: 'Whether the integration is receiving alerts.' - argument :api_url, GraphQL::STRING_TYPE, + argument :api_url, GraphQL::Types::String, required: true, description: 'Endpoint at which Prometheus can be queried.' 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 d8678ea4d61..29834d63f35 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: "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 33a12405583..71c02efdc03 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[::Integrations::Prometheus], required: true, - description: "The ID of the integration to mutate." + description: "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 ddab1af908c..50aafdc26a6 100644 --- a/app/graphql/mutations/alert_management/prometheus_integration/update.rb +++ b/app/graphql/mutations/alert_management/prometheus_integration/update.rb @@ -8,13 +8,13 @@ module Mutations argument :id, Types::GlobalIDType[::Integrations::Prometheus], required: true, - description: "The ID of the integration to mutate." + description: "ID of the integration to mutate." - argument :active, GraphQL::BOOLEAN_TYPE, + argument :active, GraphQL::Types::Boolean, required: false, description: "Whether the integration is receiving alerts." - argument :api_url, GraphQL::STRING_TYPE, + argument :api_url, GraphQL::Types::String, required: false, description: "Endpoint at which Prometheus can be queried." diff --git a/app/graphql/mutations/alert_management/update_alert_status.rb b/app/graphql/mutations/alert_management/update_alert_status.rb index 67f8ba9118f..21566c7d66f 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: '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 4f41a9cafd8..ce73f2083f2 100644 --- a/app/graphql/mutations/award_emojis/base.rb +++ b/app/graphql/mutations/award_emojis/base.rb @@ -12,17 +12,17 @@ module Mutations argument :awardable_id, ::Types::GlobalIDType[::Awardable], required: true, - description: 'The global ID of the awardable resource.' + description: 'Global ID of the awardable resource.' argument :name, - GraphQL::STRING_TYPE, + GraphQL::Types::String, required: true, description: copy_field_description(Types::AwardEmojis::AwardEmojiType, :name) field :award_emoji, Types::AwardEmojis::AwardEmojiType, null: true, - description: 'The award emoji after mutation.' + description: 'Award emoji after mutation.' private diff --git a/app/graphql/mutations/award_emojis/toggle.rb b/app/graphql/mutations/award_emojis/toggle.rb index e741f972b1b..5da2731d562 100644 --- a/app/graphql/mutations/award_emojis/toggle.rb +++ b/app/graphql/mutations/award_emojis/toggle.rb @@ -5,7 +5,7 @@ module Mutations class Toggle < Base graphql_name 'AwardEmojiToggle' - field :toggled_on, GraphQL::BOOLEAN_TYPE, null: false, + field :toggled_on, GraphQL::Types::Boolean, null: false, description: 'Indicates the status of the emoji. ' \ 'True if the toggle awarded the emoji, and false if the toggle removed the emoji.' diff --git a/app/graphql/mutations/base_mutation.rb b/app/graphql/mutations/base_mutation.rb index da658e1f108..5de042f78d6 100644 --- a/app/graphql/mutations/base_mutation.rb +++ b/app/graphql/mutations/base_mutation.rb @@ -11,7 +11,7 @@ module Mutations field_class ::Types::BaseField argument_class ::Types::BaseArgument - field :errors, [GraphQL::STRING_TYPE], + field :errors, [GraphQL::Types::String], null: false, description: 'Errors encountered during execution of the mutation.' @@ -31,6 +31,12 @@ module Mutations def ready?(**args) raise_resource_not_available_error! ERROR_MESSAGE if Gitlab::Database.read_only? + missing_args = self.class.arguments.values + .reject { |arg| arg.accepts?(args.fetch(arg.keyword, :not_given)) } + .map(&:graphql_name) + + raise ArgumentError, "Arguments must be provided: #{missing_args.join(", ")}" if missing_args.any? + true end diff --git a/app/graphql/mutations/boards/common_mutation_arguments.rb b/app/graphql/mutations/boards/common_mutation_arguments.rb index c4f8d299318..aedb7c9c725 100644 --- a/app/graphql/mutations/boards/common_mutation_arguments.rb +++ b/app/graphql/mutations/boards/common_mutation_arguments.rb @@ -7,15 +7,15 @@ module Mutations included do argument :name, - GraphQL::STRING_TYPE, + GraphQL::Types::String, required: false, - description: 'The board name.' + description: 'Board name.' argument :hide_backlog_list, - GraphQL::BOOLEAN_TYPE, + GraphQL::Types::Boolean, required: false, description: copy_field_description(Types::BoardType, :hide_backlog_list) argument :hide_closed_list, - GraphQL::BOOLEAN_TYPE, + GraphQL::Types::Boolean, required: false, description: copy_field_description(Types::BoardType, :hide_closed_list) end diff --git a/app/graphql/mutations/boards/create.rb b/app/graphql/mutations/boards/create.rb index 44fc22cf883..080bf7c6e79 100644 --- a/app/graphql/mutations/boards/create.rb +++ b/app/graphql/mutations/boards/create.rb @@ -12,7 +12,7 @@ module Mutations field :board, Types::BoardType, null: true, - description: 'The board after mutation.' + description: 'Board after mutation.' authorize :admin_issue_board diff --git a/app/graphql/mutations/boards/destroy.rb b/app/graphql/mutations/boards/destroy.rb index 4a0068edee2..61e0c95f8d3 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: 'Board after mutation.' argument :id, ::Types::GlobalIDType[::Board], required: true, - description: 'The global ID of the board to destroy.' + description: 'Global ID of the board to destroy.' authorize :admin_issue_board diff --git a/app/graphql/mutations/boards/issues/issue_move_list.rb b/app/graphql/mutations/boards/issues/issue_move_list.rb index b73657ea0c8..14fe9714f99 100644 --- a/app/graphql/mutations/boards/issues/issue_move_list.rb +++ b/app/graphql/mutations/boards/issues/issue_move_list.rb @@ -6,19 +6,19 @@ module Mutations class IssueMoveList < Mutations::Issues::Base graphql_name 'IssueMoveList' BoardGID = ::Types::GlobalIDType[::Board] - ListID = ::GraphQL::ID_TYPE - IssueID = ::GraphQL::ID_TYPE + ListID = ::GraphQL::Types::ID + IssueID = ::GraphQL::Types::ID argument :board_id, BoardGID, required: true, loads: Types::BoardType, description: 'Global ID of the board that the issue is in.' - argument :project_path, GraphQL::ID_TYPE, + argument :project_path, GraphQL::Types::ID, required: true, description: 'Project the issue to mutate is in.' - argument :iid, GraphQL::STRING_TYPE, + argument :iid, GraphQL::Types::String, required: true, description: 'IID of the issue to mutate.' @@ -56,11 +56,11 @@ module Mutations issue = authorized_find!(project_path: project_path, iid: iid) move_params = { id: issue.id, board_id: board.id }.merge(move_arguments(args)) - move_issue(board, issue, move_params) + result = move_issue(board, issue, move_params) { issue: issue.reset, - errors: issue.errors.full_messages + errors: error_for(result) } end @@ -79,6 +79,12 @@ module Mutations def move_arguments(args) args.slice(:from_list_id, :to_list_id, :move_after_id, :move_before_id) end + + def error_for(result) + return [] unless result.error? + + [result.message] + end end end end diff --git a/app/graphql/mutations/boards/lists/base_create.rb b/app/graphql/mutations/boards/lists/base_create.rb index a21c7feece3..a2d849848e0 100644 --- a/app/graphql/mutations/boards/lists/base_create.rb +++ b/app/graphql/mutations/boards/lists/base_create.rb @@ -4,7 +4,7 @@ module Mutations module Boards module Lists class BaseCreate < BaseMutation - argument :backlog, GraphQL::BOOLEAN_TYPE, + argument :backlog, GraphQL::Types::Boolean, required: false, description: 'Create the backlog list.' diff --git a/app/graphql/mutations/boards/lists/base_update.rb b/app/graphql/mutations/boards/lists/base_update.rb index b06cb3b1e32..7962d9c85d4 100644 --- a/app/graphql/mutations/boards/lists/base_update.rb +++ b/app/graphql/mutations/boards/lists/base_update.rb @@ -4,11 +4,11 @@ module Mutations module Boards module Lists class BaseUpdate < BaseMutation - argument :position, GraphQL::INT_TYPE, + argument :position, GraphQL::Types::Int, required: false, description: 'Position of list within the board.' - argument :collapsed, GraphQL::BOOLEAN_TYPE, + argument :collapsed, GraphQL::Types::Boolean, required: false, description: 'Indicates if the list is collapsed for this user.' diff --git a/app/graphql/mutations/boards/lists/destroy.rb b/app/graphql/mutations/boards/lists/destroy.rb index a50b5f73455..4ffb95abe64 100644 --- a/app/graphql/mutations/boards/lists/destroy.rb +++ b/app/graphql/mutations/boards/lists/destroy.rb @@ -9,7 +9,7 @@ module Mutations field :list, Types::BoardListType, null: true, - description: 'The list after mutation.' + description: 'List after mutation.' argument :list_id, ::Types::GlobalIDType[::List], required: true, diff --git a/app/graphql/mutations/boards/update.rb b/app/graphql/mutations/boards/update.rb index f1a1d57306b..40ab5a5ba7d 100644 --- a/app/graphql/mutations/boards/update.rb +++ b/app/graphql/mutations/boards/update.rb @@ -10,12 +10,12 @@ module Mutations argument :id, ::Types::GlobalIDType[::Board], required: true, - description: 'The board global ID.' + description: 'Board global ID.' field :board, Types::BoardType, null: true, - description: 'The board after mutation.' + description: 'Board after mutation.' authorize :admin_issue_board diff --git a/app/graphql/mutations/branches/create.rb b/app/graphql/mutations/branches/create.rb index a94d3966258..078c84bcdc0 100644 --- a/app/graphql/mutations/branches/create.rb +++ b/app/graphql/mutations/branches/create.rb @@ -7,16 +7,16 @@ module Mutations graphql_name 'CreateBranch' - argument :project_path, GraphQL::ID_TYPE, + argument :project_path, GraphQL::Types::ID, required: true, description: 'Project full path the branch is associated with.' - argument :name, GraphQL::STRING_TYPE, + argument :name, GraphQL::Types::String, required: true, description: 'Name of the branch.' argument :ref, - GraphQL::STRING_TYPE, + GraphQL::Types::String, required: true, description: 'Branch name or commit SHA to create branch from.' diff --git a/app/graphql/mutations/ci/ci_cd_settings_update.rb b/app/graphql/mutations/ci/ci_cd_settings_update.rb index 0973e9beae3..7bd38bc2998 100644 --- a/app/graphql/mutations/ci/ci_cd_settings_update.rb +++ b/app/graphql/mutations/ci/ci_cd_settings_update.rb @@ -9,22 +9,22 @@ module Mutations authorize :admin_project - argument :full_path, GraphQL::ID_TYPE, + argument :full_path, GraphQL::Types::ID, required: true, description: 'Full Path of the project the settings belong to.' - argument :keep_latest_artifact, GraphQL::BOOLEAN_TYPE, + argument :keep_latest_artifact, GraphQL::Types::Boolean, required: false, description: 'Indicates if the latest artifact should be kept for this project.' - argument :job_token_scope_enabled, GraphQL::BOOLEAN_TYPE, + argument :job_token_scope_enabled, GraphQL::Types::Boolean, required: false, description: 'Indicates CI job tokens generated in this project have restricted access to resources.' field :ci_cd_settings, Types::Ci::CiCdSettingType, null: false, - description: 'The CI/CD settings after mutation.' + description: 'CI/CD settings after mutation.' def resolve(full_path:, **args) project = authorized_find!(full_path) diff --git a/app/graphql/mutations/ci/job/base.rb b/app/graphql/mutations/ci/job/base.rb index 3359def159a..a9fe26226d9 100644 --- a/app/graphql/mutations/ci/job/base.rb +++ b/app/graphql/mutations/ci/job/base.rb @@ -8,7 +8,7 @@ module Mutations argument :id, JobID, required: true, - description: 'The ID of the job to mutate.' + description: 'ID of the job to mutate.' def find_object(id: ) # TODO: remove this line when the compatibility layer is removed diff --git a/app/graphql/mutations/ci/job/cancel.rb b/app/graphql/mutations/ci/job/cancel.rb new file mode 100644 index 00000000000..dc9f4d19779 --- /dev/null +++ b/app/graphql/mutations/ci/job/cancel.rb @@ -0,0 +1,28 @@ +# frozen_string_literal: true + +module Mutations + module Ci + module Job + class Cancel < Base + graphql_name 'JobCancel' + + field :job, + Types::Ci::JobType, + null: true, + description: 'Job after the mutation.' + + authorize :update_build + + def resolve(id:) + job = authorized_find!(id: id) + + ::Ci::BuildCancelService.new(job, current_user).execute + { + job: job, + errors: errors_on_object(job) + } + end + end + end + end +end diff --git a/app/graphql/mutations/ci/job/play.rb b/app/graphql/mutations/ci/job/play.rb index f87904f8b25..99f62ea3e70 100644 --- a/app/graphql/mutations/ci/job/play.rb +++ b/app/graphql/mutations/ci/job/play.rb @@ -9,7 +9,7 @@ module Mutations field :job, Types::Ci::JobType, null: true, - description: 'The job after the mutation.' + description: 'Job after the mutation.' authorize :update_build diff --git a/app/graphql/mutations/ci/job/retry.rb b/app/graphql/mutations/ci/job/retry.rb index a61d5dddb40..9af357ab216 100644 --- a/app/graphql/mutations/ci/job/retry.rb +++ b/app/graphql/mutations/ci/job/retry.rb @@ -9,7 +9,7 @@ module Mutations field :job, Types::Ci::JobType, null: true, - description: 'The job after the mutation.' + description: 'Job after the mutation.' authorize :update_build diff --git a/app/graphql/mutations/ci/job/unschedule.rb b/app/graphql/mutations/ci/job/unschedule.rb new file mode 100644 index 00000000000..07b1896bd2c --- /dev/null +++ b/app/graphql/mutations/ci/job/unschedule.rb @@ -0,0 +1,28 @@ +# frozen_string_literal: true + +module Mutations + module Ci + module Job + class Unschedule < Base + graphql_name 'JobUnschedule' + + field :job, + Types::Ci::JobType, + null: true, + description: 'Job after the mutation.' + + authorize :update_build + + def resolve(id:) + job = authorized_find!(id: id) + + ::Ci::BuildUnscheduleService.new(job, current_user).execute + { + job: job, + errors: errors_on_object(job) + } + end + end + end + end +end diff --git a/app/graphql/mutations/ci/job_token_scope/add_project.rb b/app/graphql/mutations/ci/job_token_scope/add_project.rb index 30f98a537b5..41adcae2c82 100644 --- a/app/graphql/mutations/ci/job_token_scope/add_project.rb +++ b/app/graphql/mutations/ci/job_token_scope/add_project.rb @@ -10,18 +10,18 @@ module Mutations authorize :admin_project - argument :project_path, GraphQL::ID_TYPE, + argument :project_path, GraphQL::Types::ID, required: true, - description: 'The project that the CI job token scope belongs to.' + description: 'Project that the CI job token scope belongs to.' - argument :target_project_path, GraphQL::ID_TYPE, + argument :target_project_path, GraphQL::Types::ID, required: true, - description: 'The project to be added to the CI job token scope.' + description: 'Project to be added to the CI job token scope.' field :ci_job_token_scope, Types::Ci::JobTokenScopeType, null: true, - description: "The CI job token's scope of access." + description: "CI job token's scope of access." def resolve(project_path:, target_project_path:) project = authorized_find!(project_path) diff --git a/app/graphql/mutations/ci/job_token_scope/remove_project.rb b/app/graphql/mutations/ci/job_token_scope/remove_project.rb index 71c9083bef8..dd6b2358dd5 100644 --- a/app/graphql/mutations/ci/job_token_scope/remove_project.rb +++ b/app/graphql/mutations/ci/job_token_scope/remove_project.rb @@ -10,18 +10,18 @@ module Mutations authorize :admin_project - argument :project_path, GraphQL::ID_TYPE, + argument :project_path, GraphQL::Types::ID, required: true, - description: 'The project that the CI job token scope belongs to.' + description: 'Project that the CI job token scope belongs to.' - argument :target_project_path, GraphQL::ID_TYPE, + argument :target_project_path, GraphQL::Types::ID, required: true, - description: 'The project to be removed from the CI job token scope.' + description: 'Project to be removed from the CI job token scope.' field :ci_job_token_scope, Types::Ci::JobTokenScopeType, null: true, - description: "The CI job token's scope of access." + description: "CI job token's scope of access." def resolve(project_path:, target_project_path:) project = authorized_find!(project_path) diff --git a/app/graphql/mutations/ci/pipeline/base.rb b/app/graphql/mutations/ci/pipeline/base.rb index ebfab56e743..aed8035a52a 100644 --- a/app/graphql/mutations/ci/pipeline/base.rb +++ b/app/graphql/mutations/ci/pipeline/base.rb @@ -8,7 +8,7 @@ module Mutations argument :id, PipelineID, required: true, - description: 'The ID of the pipeline to mutate.' + description: 'ID of the pipeline to mutate.' private diff --git a/app/graphql/mutations/ci/pipeline/retry.rb b/app/graphql/mutations/ci/pipeline/retry.rb index a12330470f0..ee93f99703e 100644 --- a/app/graphql/mutations/ci/pipeline/retry.rb +++ b/app/graphql/mutations/ci/pipeline/retry.rb @@ -9,7 +9,7 @@ module Mutations field :pipeline, Types::Ci::PipelineType, null: true, - description: 'The pipeline after mutation.' + description: 'Pipeline after mutation.' authorize :update_pipeline diff --git a/app/graphql/mutations/ci/runner/update.rb b/app/graphql/mutations/ci/runner/update.rb index 4cdfa1fb1bd..e37ab1081f9 100644 --- a/app/graphql/mutations/ci/runner/update.rb +++ b/app/graphql/mutations/ci/runner/update.rb @@ -14,11 +14,11 @@ module Mutations required: true, description: 'ID of the runner to update.' - argument :description, GraphQL::STRING_TYPE, + argument :description, GraphQL::Types::String, required: false, description: 'Description of the runner.' - argument :maximum_timeout, GraphQL::INT_TYPE, + argument :maximum_timeout, GraphQL::Types::Int, required: false, description: 'Maximum timeout (in seconds) for jobs processed by the runner.' @@ -26,24 +26,24 @@ module Mutations required: false, description: 'Access level of the runner.' - argument :active, GraphQL::BOOLEAN_TYPE, + argument :active, GraphQL::Types::Boolean, required: false, description: 'Indicates the runner is allowed to receive jobs.' - argument :locked, GraphQL::BOOLEAN_TYPE, required: false, + argument :locked, GraphQL::Types::Boolean, required: false, description: 'Indicates the runner is locked.' - argument :run_untagged, GraphQL::BOOLEAN_TYPE, + argument :run_untagged, GraphQL::Types::Boolean, required: false, description: 'Indicates the runner is able to run untagged jobs.' - argument :tag_list, [GraphQL::STRING_TYPE], required: false, + argument :tag_list, [GraphQL::Types::String], required: false, description: 'Tags associated with the runner.' field :runner, Types::Ci::RunnerType, null: true, - description: 'The runner after mutation.' + description: 'Runner after mutation.' def resolve(id:, **runner_attrs) runner = authorized_find!(id) diff --git a/app/graphql/mutations/ci/runners_registration_token/reset.rb b/app/graphql/mutations/ci/runners_registration_token/reset.rb index e1cdd9a22a5..7976e8fb70d 100644 --- a/app/graphql/mutations/ci/runners_registration_token/reset.rb +++ b/app/graphql/mutations/ci/runners_registration_token/reset.rb @@ -8,7 +8,7 @@ module Mutations authorize :update_runners_registration_token - ScopeID = ::GraphQL::ID_TYPE + ScopeID = ::GraphQL::Types::ID argument :type, ::Types::Ci::RunnerTypeEnum, required: true, @@ -19,9 +19,9 @@ module Mutations description: 'ID of the project or group to reset the token for. Omit if resetting instance runner token.' field :token, - GraphQL::STRING_TYPE, + GraphQL::Types::String, null: true, - description: 'The runner token after mutation.' + description: 'Runner token after mutation.' def resolve(**args) { diff --git a/app/graphql/mutations/commits/create.rb b/app/graphql/mutations/commits/create.rb index f432f679909..3eb1912dbc4 100644 --- a/app/graphql/mutations/commits/create.rb +++ b/app/graphql/mutations/commits/create.rb @@ -12,20 +12,20 @@ module Mutations graphql_name 'CommitCreate' - argument :project_path, GraphQL::ID_TYPE, + argument :project_path, GraphQL::Types::ID, required: true, description: 'Project full path the branch is associated with.' - argument :branch, GraphQL::STRING_TYPE, + argument :branch, GraphQL::Types::String, required: true, description: 'Name of the branch to commit into, it can be a new branch.' - argument :start_branch, GraphQL::STRING_TYPE, + argument :start_branch, GraphQL::Types::String, required: false, description: 'If on a new branch, name of the original branch.' argument :message, - GraphQL::STRING_TYPE, + GraphQL::Types::String, required: true, description: copy_field_description(Types::CommitType, :message) @@ -35,17 +35,17 @@ module Mutations description: 'Array of action hashes to commit as a batch.' field :commit_pipeline_path, - GraphQL::STRING_TYPE, + GraphQL::Types::String, null: true, description: "ETag path for the commit's pipeline." field :commit, Types::CommitType, null: true, - description: 'The commit after mutation.' + description: 'Commit after mutation.' field :content, - [GraphQL::STRING_TYPE], + [GraphQL::Types::String], null: true, description: 'Contents of the commit.' diff --git a/app/graphql/mutations/concerns/mutations/assignable.rb b/app/graphql/mutations/concerns/mutations/assignable.rb index e214a57500c..86f37207a2d 100644 --- a/app/graphql/mutations/concerns/mutations/assignable.rb +++ b/app/graphql/mutations/concerns/mutations/assignable.rb @@ -6,15 +6,15 @@ module Mutations included do argument :assignee_usernames, - [GraphQL::STRING_TYPE], + [GraphQL::Types::String], required: true, - description: 'The usernames to assign to the resource. Replaces existing assignees by default.' + description: 'Usernames to assign to the resource. Replaces existing assignees by default.' argument :operation_mode, Types::MutationOperationModeEnum, required: false, default_value: Types::MutationOperationModeEnum.default_mode, - description: 'The operation to perform. Defaults to REPLACE.' + description: 'Operation to perform. Defaults to REPLACE.' end def resolve(project_path:, iid:, assignee_usernames:, operation_mode:) diff --git a/app/graphql/mutations/concerns/mutations/can_mutate_spammable.rb b/app/graphql/mutations/concerns/mutations/can_mutate_spammable.rb index 3c5f077110c..f1ae54aa014 100644 --- a/app/graphql/mutations/concerns/mutations/can_mutate_spammable.rb +++ b/app/graphql/mutations/concerns/mutations/can_mutate_spammable.rb @@ -13,39 +13,39 @@ module Mutations }.freeze included do - argument :captcha_response, GraphQL::STRING_TYPE, + argument :captcha_response, GraphQL::Types::String, required: false, deprecated: DEPRECATION_NOTICE, - description: 'A valid CAPTCHA response value obtained by using the provided captchaSiteKey with a CAPTCHA API to present a challenge to be solved on the client. Required to resubmit if the previous operation returned "NeedsCaptchaResponse: true".' + description: 'Valid CAPTCHA response value obtained by using the provided captchaSiteKey with a CAPTCHA API to present a challenge to be solved on the client. Required to resubmit if the previous operation returned "NeedsCaptchaResponse: true".' - argument :spam_log_id, GraphQL::INT_TYPE, + argument :spam_log_id, GraphQL::Types::Int, required: false, deprecated: DEPRECATION_NOTICE, - description: 'The spam log ID which must be passed along with a valid CAPTCHA response for the operation to be completed. Required to resubmit if the previous operation returned "NeedsCaptchaResponse: true".' + description: 'Spam log ID which must be passed along with a valid CAPTCHA response for the operation to be completed. Required to resubmit if the previous operation returned "NeedsCaptchaResponse: true".' field :spam, - GraphQL::BOOLEAN_TYPE, + GraphQL::Types::Boolean, null: true, deprecated: DEPRECATION_NOTICE, description: 'Indicates whether the operation was detected as definite spam. There is no option to resubmit the request with a CAPTCHA response.' field :needs_captcha_response, - GraphQL::BOOLEAN_TYPE, + GraphQL::Types::Boolean, null: true, deprecated: DEPRECATION_NOTICE, description: 'Indicates whether the operation was detected as possible spam and not completed. If CAPTCHA is enabled, the request must be resubmitted with a valid CAPTCHA response and spam_log_id included for the operation to be completed. Included only when an operation was not completed because "NeedsCaptchaResponse" is true.' field :spam_log_id, - GraphQL::INT_TYPE, + GraphQL::Types::Int, null: true, deprecated: DEPRECATION_NOTICE, - description: 'The spam log ID which must be passed along with a valid CAPTCHA response for an operation to be completed. Included only when an operation was not completed because "NeedsCaptchaResponse" is true.' + description: 'Spam log ID which must be passed along with a valid CAPTCHA response for an operation to be completed. Included only when an operation was not completed because "NeedsCaptchaResponse" is true.' field :captcha_site_key, - GraphQL::STRING_TYPE, + GraphQL::Types::String, null: true, deprecated: DEPRECATION_NOTICE, - description: 'The CAPTCHA site key which must be used to render a challenge for the user to solve to obtain a valid captchaResponse value. Included only when an operation was not completed because "NeedsCaptchaResponse" is true.' + description: 'CAPTCHA site key which must be used to render a challenge for the user to solve to obtain a valid captchaResponse value. Included only when an operation was not completed because "NeedsCaptchaResponse" is true.' 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 b8ef675c3d4..a05884f189c 100644 --- a/app/graphql/mutations/concerns/mutations/resolves_resource_parent.rb +++ b/app/graphql/mutations/concerns/mutations/resolves_resource_parent.rb @@ -7,11 +7,11 @@ module Mutations include ResolvesProject included do - argument :project_path, GraphQL::ID_TYPE, + argument :project_path, GraphQL::Types::ID, required: false, description: 'Full path of the project with which the resource is associated.' - argument :group_path, GraphQL::ID_TYPE, + argument :group_path, GraphQL::Types::ID, required: false, description: 'Full path of the group with which the resource is associated.' end diff --git a/app/graphql/mutations/concerns/mutations/resolves_subscription.rb b/app/graphql/mutations/concerns/mutations/resolves_subscription.rb index ed9fb5fceb0..1c9e8f311e4 100644 --- a/app/graphql/mutations/concerns/mutations/resolves_subscription.rb +++ b/app/graphql/mutations/concerns/mutations/resolves_subscription.rb @@ -6,9 +6,9 @@ module Mutations included do argument :subscribed_state, - GraphQL::BOOLEAN_TYPE, + GraphQL::Types::Boolean, required: true, - description: 'The desired state of the subscription.' + description: 'Desired state of the subscription.' end def resolve(project_path:, iid:, subscribed_state:) diff --git a/app/graphql/mutations/container_expiration_policies/update.rb b/app/graphql/mutations/container_expiration_policies/update.rb index f61d852bb6c..db4acadfc38 100644 --- a/app/graphql/mutations/container_expiration_policies/update.rb +++ b/app/graphql/mutations/container_expiration_policies/update.rb @@ -10,12 +10,12 @@ module Mutations authorize :destroy_container_image argument :project_path, - GraphQL::ID_TYPE, + GraphQL::Types::ID, required: true, - description: 'The project path where the container expiration policy is located.' + description: 'Project path where the container expiration policy is located.' argument :enabled, - GraphQL::BOOLEAN_TYPE, + GraphQL::Types::Boolean, required: false, description: copy_field_description(Types::ContainerExpirationPolicyType, :enabled) @@ -47,7 +47,7 @@ module Mutations field :container_expiration_policy, Types::ContainerExpirationPolicyType, null: true, - description: 'The container expiration policy after mutation.' + description: 'Container expiration policy after mutation.' def resolve(project_path:, **args) project = authorized_find!(project_path) diff --git a/app/graphql/mutations/container_repositories/destroy.rb b/app/graphql/mutations/container_repositories/destroy.rb index 90fba66e7b3..1d8f7b22f88 100644 --- a/app/graphql/mutations/container_repositories/destroy.rb +++ b/app/graphql/mutations/container_repositories/destroy.rb @@ -15,7 +15,7 @@ module Mutations field :container_repository, Types::ContainerRepositoryType, null: false, - description: 'The container repository policy after scheduling the deletion.' + description: 'Container repository policy after scheduling the deletion.' def resolve(id:) container_repository = authorized_find!(id: id) diff --git a/app/graphql/mutations/container_repositories/destroy_tags.rb b/app/graphql/mutations/container_repositories/destroy_tags.rb index 12d65f604b8..c2737820d22 100644 --- a/app/graphql/mutations/container_repositories/destroy_tags.rb +++ b/app/graphql/mutations/container_repositories/destroy_tags.rb @@ -17,7 +17,7 @@ module Mutations description: 'ID of the container repository.' argument :tag_names, - [GraphQL::STRING_TYPE], + [GraphQL::Types::String], required: true, description: "Container repository tag(s) to delete. Total number can't be greater than #{LIMIT}", prepare: ->(tag_names, _) do @@ -27,7 +27,7 @@ module Mutations end field :deleted_tag_names, - [GraphQL::STRING_TYPE], + [GraphQL::Types::String], description: 'Deleted container repository tags.', null: false diff --git a/app/graphql/mutations/custom_emoji/create.rb b/app/graphql/mutations/custom_emoji/create.rb index 5cf54f8f877..ad392d6c814 100644 --- a/app/graphql/mutations/custom_emoji/create.rb +++ b/app/graphql/mutations/custom_emoji/create.rb @@ -12,17 +12,17 @@ module Mutations field :custom_emoji, Types::CustomEmojiType, null: true, - description: 'The new custom emoji.' + description: 'New custom emoji.' - argument :group_path, GraphQL::ID_TYPE, + argument :group_path, GraphQL::Types::ID, required: true, description: 'Namespace full path the emoji is associated with.' - argument :name, GraphQL::STRING_TYPE, + argument :name, GraphQL::Types::String, required: true, description: 'Name of the emoji.' - argument :url, GraphQL::STRING_TYPE, + argument :url, GraphQL::Types::String, required: true, as: :file, description: 'Location of the emoji file.' diff --git a/app/graphql/mutations/design_management/base.rb b/app/graphql/mutations/design_management/base.rb index 14d85885793..a6b498c380c 100644 --- a/app/graphql/mutations/design_management/base.rb +++ b/app/graphql/mutations/design_management/base.rb @@ -5,13 +5,13 @@ module Mutations class Base < ::Mutations::BaseMutation include Mutations::ResolvesIssuable - argument :project_path, GraphQL::ID_TYPE, + argument :project_path, GraphQL::Types::ID, required: true, - description: "The project where the issue is to upload designs for." + description: "Project where the issue is to upload designs for." - argument :iid, GraphQL::ID_TYPE, + argument :iid, GraphQL::Types::ID, required: true, - description: "The IID of the issue to modify designs for." + description: "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 f604542edef..4e9f0aad934 100644 --- a/app/graphql/mutations/design_management/delete.rb +++ b/app/graphql/mutations/design_management/delete.rb @@ -7,16 +7,16 @@ module Mutations graphql_name "DesignManagementDelete" - argument :filenames, [GraphQL::STRING_TYPE], + argument :filenames, [GraphQL::Types::String], required: true, - description: "The filenames of the designs to delete.", + description: "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: '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 fe280e926d2..1ca03f22880 100644 --- a/app/graphql/mutations/design_management/move.rb +++ b/app/graphql/mutations/design_management/move.rb @@ -18,7 +18,7 @@ module Mutations field :design_collection, Types::DesignManagement::DesignCollectionType, null: true, - description: "The current state of the collection." + description: "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 2ccf2ef8ff5..f5cb828bae7 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: "Files to upload." authorize :create_design field :designs, [Types::DesignManagement::DesignType], null: false, - description: "The designs that were uploaded by the mutation." + description: "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 6639252ec67..2005c9e54e0 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: 'Global ID of the discussion.' argument :resolve, - GraphQL::BOOLEAN_TYPE, + GraphQL::Types::Boolean, required: true, 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: 'Discussion after mutation.' def resolve(id:, resolve:) discussion = authorized_find_discussion!(id: id) diff --git a/app/graphql/mutations/echo.rb b/app/graphql/mutations/echo.rb index 61d39009ba4..a953a9489e7 100644 --- a/app/graphql/mutations/echo.rb +++ b/app/graphql/mutations/echo.rb @@ -11,18 +11,18 @@ module Mutations DOC argument :errors, - type: [::GraphQL::STRING_TYPE], + type: [::GraphQL::Types::String], required: false, description: 'Errors to return to the user.' argument :messages, - type: [::GraphQL::STRING_TYPE], + type: [::GraphQL::Types::String], as: :echoes, required: false, description: 'Messages to return to the user.' field :echoes, - type: [::GraphQL::STRING_TYPE], + type: [::GraphQL::Types::String], null: true, description: 'Messages returned to the user.' diff --git a/app/graphql/mutations/environments/canary_ingress/update.rb b/app/graphql/mutations/environments/canary_ingress/update.rb index 45dcc8314a0..e4ba08e6dcc 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: 'Global ID of the environment to update.' argument :weight, - GraphQL::INT_TYPE, + GraphQL::Types::Int, required: true, - description: 'The weight of the Canary Ingress.' + description: 'Weight of the Canary Ingress.' def resolve(id:, **kwargs) environment = authorized_find!(id: id) diff --git a/app/graphql/mutations/groups/update.rb b/app/graphql/mutations/groups/update.rb new file mode 100644 index 00000000000..9c5628a57cd --- /dev/null +++ b/app/graphql/mutations/groups/update.rb @@ -0,0 +1,40 @@ +# frozen_string_literal: true + +module Mutations + module Groups + class Update < Mutations::BaseMutation + include Mutations::ResolvesGroup + + graphql_name 'GroupUpdate' + + authorize :admin_group + + field :group, Types::GroupType, + null: true, + description: 'Group after update.' + + argument :full_path, GraphQL::Types::ID, + required: true, + description: 'Full path of the group that will be updated.' + argument :shared_runners_setting, Types::Namespace::SharedRunnersSettingEnum, + required: true, + description: copy_field_description(Types::GroupType, :shared_runners_setting) + + def resolve(full_path:, **args) + group = authorized_find!(full_path: full_path) + + unless ::Groups::UpdateService.new(group, current_user, args).execute + return { group: nil, errors: group.errors.full_messages } + end + + { group: group, errors: [] } + end + + private + + def find_object(full_path:) + resolve_group(full_path: full_path) + end + end + end +end diff --git a/app/graphql/mutations/issues/base.rb b/app/graphql/mutations/issues/base.rb index b25987a43f6..2a61e8918a8 100644 --- a/app/graphql/mutations/issues/base.rb +++ b/app/graphql/mutations/issues/base.rb @@ -5,18 +5,18 @@ module Mutations class Base < BaseMutation include Mutations::ResolvesIssuable - argument :project_path, GraphQL::ID_TYPE, + argument :project_path, GraphQL::Types::ID, required: true, - description: "The project the issue to mutate is in." + description: "Project the issue to mutate is in." - argument :iid, GraphQL::STRING_TYPE, + argument :iid, GraphQL::Types::String, required: true, - description: "The IID of the issue to mutate." + description: "IID of the issue to mutate." field :issue, Types::IssueType, null: true, - description: "The issue after mutation." + description: "Issue after mutation." authorize :update_issue diff --git a/app/graphql/mutations/issues/common_mutation_arguments.rb b/app/graphql/mutations/issues/common_mutation_arguments.rb index 65768b85d14..36fd94716a6 100644 --- a/app/graphql/mutations/issues/common_mutation_arguments.rb +++ b/app/graphql/mutations/issues/common_mutation_arguments.rb @@ -6,7 +6,7 @@ module Mutations extend ActiveSupport::Concern included do - argument :description, GraphQL::STRING_TYPE, + argument :description, GraphQL::Types::String, required: false, description: copy_field_description(Types::IssueType, :description) @@ -14,11 +14,11 @@ module Mutations required: false, description: copy_field_description(Types::IssueType, :due_date) - argument :confidential, GraphQL::BOOLEAN_TYPE, + argument :confidential, GraphQL::Types::Boolean, required: false, description: copy_field_description(Types::IssueType, :confidential) - argument :locked, GraphQL::BOOLEAN_TYPE, + argument :locked, GraphQL::Types::Boolean, as: :discussion_locked, required: false, description: copy_field_description(Types::IssueType, :discussion_locked) diff --git a/app/graphql/mutations/issues/create.rb b/app/graphql/mutations/issues/create.rb index 7c4a851f8aa..32f96f1bfe6 100644 --- a/app/graphql/mutations/issues/create.rb +++ b/app/graphql/mutations/issues/create.rb @@ -10,29 +10,29 @@ module Mutations include CommonMutationArguments - argument :project_path, GraphQL::ID_TYPE, + argument :project_path, GraphQL::Types::ID, required: true, description: 'Project full path the issue is associated with.' - argument :iid, GraphQL::INT_TYPE, + argument :iid, GraphQL::Types::Int, required: false, - description: 'The IID (internal ID) of a project issue. Only admins and project owners can modify.' + description: 'IID (internal ID) of a project issue. Only admins and project owners can modify.' - argument :title, GraphQL::STRING_TYPE, + argument :title, GraphQL::Types::String, required: true, description: copy_field_description(Types::IssueType, :title) 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: 'ID of the milestone to assign to the issue. On update milestone will be removed if set to null.' - argument :labels, [GraphQL::STRING_TYPE], + argument :labels, [GraphQL::Types::String], required: false, description: copy_field_description(Types::IssueType, :labels) argument :label_ids, [::Types::GlobalIDType[::Label]], required: false, - description: 'The IDs of labels to be added to the issue.' + description: 'IDs of labels to be added to the issue.' argument :created_at, Types::TimeType, required: false, @@ -40,20 +40,20 @@ module Mutations 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: 'IID of a merge request for which to resolve discussions.' - argument :discussion_to_resolve, GraphQL::STRING_TYPE, + argument :discussion_to_resolve, GraphQL::Types::String, required: false, - description: 'The ID of a discussion to resolve. Also pass `merge_request_to_resolve_discussions_of`.' + description: '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: 'Array of user IDs to assign to the issue.' field :issue, Types::IssueType, null: true, - description: 'The issue after mutation.' + description: '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 cb4f0f42b38..fb22a2d891c 100644 --- a/app/graphql/mutations/issues/move.rb +++ b/app/graphql/mutations/issues/move.rb @@ -6,9 +6,9 @@ module Mutations graphql_name 'IssueMove' argument :target_project_path, - GraphQL::ID_TYPE, + GraphQL::Types::ID, required: true, - description: 'The project to move the issue to.' + description: 'Project to move the issue to.' def resolve(project_path:, iid:, target_project_path:) Gitlab::QueryLimiting.disable!('https://gitlab.com/gitlab-org/gitlab/-/issues/20816') diff --git a/app/graphql/mutations/issues/set_confidential.rb b/app/graphql/mutations/issues/set_confidential.rb index cfee2420ee0..35e629ddc90 100644 --- a/app/graphql/mutations/issues/set_confidential.rb +++ b/app/graphql/mutations/issues/set_confidential.rb @@ -8,7 +8,7 @@ module Mutations graphql_name 'IssueSetConfidential' argument :confidential, - GraphQL::BOOLEAN_TYPE, + GraphQL::Types::Boolean, required: true, description: 'Whether or not to set the issue as a confidential.' diff --git a/app/graphql/mutations/issues/set_due_date.rb b/app/graphql/mutations/issues/set_due_date.rb index 9cefac96b25..70b76da4fcb 100644 --- a/app/graphql/mutations/issues/set_due_date.rb +++ b/app/graphql/mutations/issues/set_due_date.rb @@ -7,17 +7,8 @@ module Mutations argument :due_date, Types::TimeType, - required: false, - description: 'The desired due date for the issue, ' \ - 'due date will be removed if absent or set to null' - - def ready?(**args) - unless args.key?(:due_date) - raise Gitlab::Graphql::Errors::ArgumentError, 'Argument dueDate must be provided (`null` accepted)' - end - - super - end + required: :nullable, + description: 'Desired due date for the issue. Due date is removed if null.' 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 3a696a64dad..93b31350bbf 100644 --- a/app/graphql/mutations/issues/set_locked.rb +++ b/app/graphql/mutations/issues/set_locked.rb @@ -6,7 +6,7 @@ module Mutations graphql_name 'IssueSetLocked' argument :locked, - GraphQL::BOOLEAN_TYPE, + GraphQL::Types::Boolean, required: true, description: 'Whether or not to lock discussion on the issue.' diff --git a/app/graphql/mutations/issues/set_subscription.rb b/app/graphql/mutations/issues/set_subscription.rb index 55c9049b7cf..1d4fa0eefd8 100644 --- a/app/graphql/mutations/issues/set_subscription.rb +++ b/app/graphql/mutations/issues/set_subscription.rb @@ -8,18 +8,18 @@ module Mutations include ResolvesSubscription include Mutations::ResolvesIssuable - argument :project_path, GraphQL::ID_TYPE, + argument :project_path, GraphQL::Types::ID, required: true, - description: "The project the issue to mutate is in." + description: "Project the issue to mutate is in." - argument :iid, GraphQL::STRING_TYPE, + argument :iid, GraphQL::Types::String, required: true, - description: "The IID of the issue to mutate." + description: "IID of the issue to mutate." field :issue, Types::IssueType, null: true, - description: "The issue after mutation." + description: "Issue after mutation." authorize :update_subscription diff --git a/app/graphql/mutations/issues/update.rb b/app/graphql/mutations/issues/update.rb index 1ceed868a6c..6cab1214d24 100644 --- a/app/graphql/mutations/issues/update.rb +++ b/app/graphql/mutations/issues/update.rb @@ -7,21 +7,25 @@ module Mutations include CommonMutationArguments - argument :title, GraphQL::STRING_TYPE, + argument :title, GraphQL::Types::String, required: false, description: copy_field_description(Types::IssueType, :title) - argument :milestone_id, GraphQL::ID_TYPE, # rubocop: disable Graphql/IDType + argument :milestone_id, GraphQL::Types::ID, # 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: '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], + argument :add_label_ids, [GraphQL::Types::ID], required: false, - description: 'The IDs of labels to be added to the issue.' + description: 'IDs of labels to be added to the issue.' - argument :remove_label_ids, [GraphQL::ID_TYPE], + argument :remove_label_ids, [GraphQL::Types::ID], required: false, - description: 'The IDs of labels to be removed from the issue.' + description: 'IDs of labels to be removed from the issue.' + + argument :label_ids, [GraphQL::Types::ID], + required: false, + description: 'IDs of labels to be set. Replaces existing issue labels.' argument :state_event, Types::IssueStateEventEnum, description: 'Close or reopen an issue.', @@ -31,6 +35,8 @@ module Mutations issue = authorized_find!(project_path: project_path, iid: iid) project = issue.project + args = parse_arguments(args) + spam_params = ::Spam::SpamParams.new_from_request(request: context[:request]) ::Issues::UpdateService.new(project: project, current_user: current_user, params: args, spam_params: spam_params).execute(issue) @@ -39,6 +45,32 @@ module Mutations errors: errors_on_object(issue) } end + + def ready?(label_ids: [], add_label_ids: [], remove_label_ids: [], **args) + if label_ids.any? && (add_label_ids.any? || remove_label_ids.any?) + raise Gitlab::Graphql::Errors::ArgumentError, 'labelIds is mutually exclusive with any of addLabelIds or removeLabelIds' + end + + super + end + + private + + def parse_arguments(args) + args[:add_label_ids] = parse_label_ids(args[:add_label_ids]) + args[:remove_label_ids] = parse_label_ids(args[:remove_label_ids]) + args[:label_ids] = parse_label_ids(args[:label_ids]) + + args + end + + def parse_label_ids(ids) + ids&.map do |gid| + GitlabSchema.parse_gid(gid, expected_type: ::Label).model_id + rescue Gitlab::Graphql::Errors::ArgumentError + gid + end + end end end end diff --git a/app/graphql/mutations/jira_import/import_users.rb b/app/graphql/mutations/jira_import/import_users.rb index af2bb18161f..8d82a058dd0 100644 --- a/app/graphql/mutations/jira_import/import_users.rb +++ b/app/graphql/mutations/jira_import/import_users.rb @@ -14,12 +14,12 @@ module Mutations null: true, description: 'Users returned from Jira, matched by email and name if possible.' - argument :project_path, GraphQL::ID_TYPE, + argument :project_path, GraphQL::Types::ID, required: true, - description: 'The project to import the Jira users into.' - argument :start_at, GraphQL::INT_TYPE, + description: 'Project to import the Jira users into.' + argument :start_at, GraphQL::Types::Int, required: false, - description: 'The index of the record the import should started at, default 0 (50 records returned).' + description: 'Index of the record the import should started at, default 0 (50 records returned).' def resolve(project_path:, start_at: 0) project = authorized_find!(project_path) diff --git a/app/graphql/mutations/jira_import/start.rb b/app/graphql/mutations/jira_import/start.rb index e31aaf53a09..143a9558e38 100644 --- a/app/graphql/mutations/jira_import/start.rb +++ b/app/graphql/mutations/jira_import/start.rb @@ -12,21 +12,21 @@ module Mutations field :jira_import, Types::JiraImportType, null: true, - description: 'The Jira import data after mutation.' + description: 'Jira import data after mutation.' - argument :project_path, GraphQL::ID_TYPE, + argument :project_path, GraphQL::Types::ID, required: true, - description: 'The project to import the Jira project into.' - argument :jira_project_key, GraphQL::STRING_TYPE, + description: 'Project to import the Jira project into.' + argument :jira_project_key, GraphQL::Types::String, required: true, description: 'Project key of the importer Jira project.' - argument :jira_project_name, GraphQL::STRING_TYPE, + argument :jira_project_name, GraphQL::Types::String, required: false, description: 'Project name of the importer Jira project.' argument :users_mapping, [Types::JiraUsersMappingInputType], required: false, - description: 'The mapping of Jira to GitLab users.' + description: 'Mapping of Jira to GitLab users.' def resolve(project_path:, jira_project_key:, users_mapping:) project = authorized_find!(project_path) diff --git a/app/graphql/mutations/labels/create.rb b/app/graphql/mutations/labels/create.rb index 683d0b44586..cb3ba7939ae 100644 --- a/app/graphql/mutations/labels/create.rb +++ b/app/graphql/mutations/labels/create.rb @@ -10,17 +10,17 @@ module Mutations field :label, Types::LabelType, null: true, - description: 'The label after mutation.' + description: 'Label after mutation.' - argument :title, GraphQL::STRING_TYPE, + argument :title, GraphQL::Types::String, required: true, description: 'Title of the label.' - argument :description, GraphQL::STRING_TYPE, + argument :description, GraphQL::Types::String, required: false, description: 'Description of the label.' - argument :color, GraphQL::STRING_TYPE, + argument :color, GraphQL::Types::String, required: false, default_value: Label::DEFAULT_COLOR, see: { diff --git a/app/graphql/mutations/merge_requests/accept.rb b/app/graphql/mutations/merge_requests/accept.rb index 9994f793a01..d16b2327f2d 100644 --- a/app/graphql/mutations/merge_requests/accept.rb +++ b/app/graphql/mutations/merge_requests/accept.rb @@ -23,20 +23,20 @@ module Mutations as: :auto_merge_strategy, description: 'How to merge this merge request.' - argument :commit_message, ::GraphQL::STRING_TYPE, + argument :commit_message, ::GraphQL::Types::String, required: false, description: 'Custom merge commit message.' - argument :squash_commit_message, ::GraphQL::STRING_TYPE, + argument :squash_commit_message, ::GraphQL::Types::String, required: false, description: 'Custom squash commit message (if squash is true).' - argument :sha, ::GraphQL::STRING_TYPE, + argument :sha, ::GraphQL::Types::String, required: true, - description: 'The HEAD SHA at the time when this merge was requested.' + description: 'HEAD SHA at the time when this merge was requested.' - argument :should_remove_source_branch, ::GraphQL::BOOLEAN_TYPE, + argument :should_remove_source_branch, ::GraphQL::Types::Boolean, required: false, description: 'Should the source branch be removed.' - argument :squash, ::GraphQL::BOOLEAN_TYPE, + argument :squash, ::GraphQL::Types::Boolean, required: false, default_value: false, description: 'Squash commits on the source branch before merge.' diff --git a/app/graphql/mutations/merge_requests/base.rb b/app/graphql/mutations/merge_requests/base.rb index cd919a19ba2..c4bbbf550d9 100644 --- a/app/graphql/mutations/merge_requests/base.rb +++ b/app/graphql/mutations/merge_requests/base.rb @@ -5,18 +5,18 @@ module Mutations class Base < BaseMutation include Mutations::ResolvesIssuable - argument :project_path, GraphQL::ID_TYPE, + argument :project_path, GraphQL::Types::ID, required: true, - description: "The project the merge request to mutate is in." + description: "Project the merge request to mutate is in." - argument :iid, GraphQL::STRING_TYPE, + argument :iid, GraphQL::Types::String, required: true, - description: "The IID of the merge request to mutate." + description: "IID of the merge request to mutate." field :merge_request, Types::MergeRequestType, null: true, - description: "The merge request after mutation." + description: "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 4849c198677..dc1d5a22bc9 100644 --- a/app/graphql/mutations/merge_requests/create.rb +++ b/app/graphql/mutations/merge_requests/create.rb @@ -7,34 +7,34 @@ module Mutations graphql_name 'MergeRequestCreate' - argument :project_path, GraphQL::ID_TYPE, + argument :project_path, GraphQL::Types::ID, required: true, description: 'Project full path the merge request is associated with.' - argument :title, GraphQL::STRING_TYPE, + argument :title, GraphQL::Types::String, required: true, description: copy_field_description(Types::MergeRequestType, :title) - argument :source_branch, GraphQL::STRING_TYPE, + argument :source_branch, GraphQL::Types::String, required: true, description: copy_field_description(Types::MergeRequestType, :source_branch) - argument :target_branch, GraphQL::STRING_TYPE, + argument :target_branch, GraphQL::Types::String, required: true, description: copy_field_description(Types::MergeRequestType, :target_branch) - argument :description, GraphQL::STRING_TYPE, + argument :description, GraphQL::Types::String, required: false, description: copy_field_description(Types::MergeRequestType, :description) - argument :labels, [GraphQL::STRING_TYPE], + argument :labels, [GraphQL::Types::String], required: false, description: copy_field_description(Types::MergeRequestType, :labels) field :merge_request, Types::MergeRequestType, null: true, - description: 'The merge request after mutation.' + description: 'Merge request after mutation.' authorize :create_merge_request_from diff --git a/app/graphql/mutations/merge_requests/reviewer_rereview.rb b/app/graphql/mutations/merge_requests/reviewer_rereview.rb index d1d5118e271..74f8e282cdd 100644 --- a/app/graphql/mutations/merge_requests/reviewer_rereview.rb +++ b/app/graphql/mutations/merge_requests/reviewer_rereview.rb @@ -9,7 +9,7 @@ module Mutations loads: Types::UserType, required: true, description: <<~DESC - The user ID for the user that has been requested for a new review. + User ID for the user that has been requested for a new review. DESC def resolve(project_path:, iid:, user:) diff --git a/app/graphql/mutations/merge_requests/set_draft.rb b/app/graphql/mutations/merge_requests/set_draft.rb index 80006c6f70e..ab4ca73e5dc 100644 --- a/app/graphql/mutations/merge_requests/set_draft.rb +++ b/app/graphql/mutations/merge_requests/set_draft.rb @@ -6,7 +6,7 @@ module Mutations graphql_name 'MergeRequestSetDraft' argument :draft, - GraphQL::BOOLEAN_TYPE, + GraphQL::Types::Boolean, required: true, description: <<~DESC Whether or not to set the merge request as a draft. diff --git a/app/graphql/mutations/merge_requests/set_labels.rb b/app/graphql/mutations/merge_requests/set_labels.rb index a77c2731a05..0b40d6c5c5e 100644 --- a/app/graphql/mutations/merge_requests/set_labels.rb +++ b/app/graphql/mutations/merge_requests/set_labels.rb @@ -9,7 +9,7 @@ module Mutations [::Types::GlobalIDType[Label]], required: true, description: <<~DESC - The Label IDs to set. Replaces existing labels by default. + Label IDs to set. Replaces existing labels by default. DESC argument :operation_mode, diff --git a/app/graphql/mutations/merge_requests/set_locked.rb b/app/graphql/mutations/merge_requests/set_locked.rb index e9e607551a6..8f7b39be777 100644 --- a/app/graphql/mutations/merge_requests/set_locked.rb +++ b/app/graphql/mutations/merge_requests/set_locked.rb @@ -6,7 +6,7 @@ module Mutations graphql_name 'MergeRequestSetLocked' argument :locked, - GraphQL::BOOLEAN_TYPE, + GraphQL::Types::Boolean, required: true, description: <<~DESC Whether or not to lock the merge request. diff --git a/app/graphql/mutations/merge_requests/set_milestone.rb b/app/graphql/mutations/merge_requests/set_milestone.rb index ed5139c4af9..bf40c12aec5 100644 --- a/app/graphql/mutations/merge_requests/set_milestone.rb +++ b/app/graphql/mutations/merge_requests/set_milestone.rb @@ -10,7 +10,7 @@ module Mutations required: false, loads: Types::MilestoneType, description: <<~DESC - The milestone to assign to the merge request. + Milestone to assign to the merge request. DESC def resolve(project_path:, iid:, milestone: nil) diff --git a/app/graphql/mutations/merge_requests/set_subscription.rb b/app/graphql/mutations/merge_requests/set_subscription.rb index 981daa81c28..9d6a54a84fd 100644 --- a/app/graphql/mutations/merge_requests/set_subscription.rb +++ b/app/graphql/mutations/merge_requests/set_subscription.rb @@ -8,18 +8,18 @@ module Mutations include ResolvesSubscription include Mutations::ResolvesIssuable - argument :project_path, GraphQL::ID_TYPE, + argument :project_path, GraphQL::Types::ID, required: true, - description: "The project the merge request to mutate is in." + description: "Project the merge request to mutate is in." - argument :iid, GraphQL::STRING_TYPE, + argument :iid, GraphQL::Types::String, required: true, - description: "The IID of the merge request to mutate." + description: "IID of the merge request to mutate." field :merge_request, Types::MergeRequestType, null: true, - description: "The merge request after mutation." + description: "Merge request after mutation." authorize :update_subscription diff --git a/app/graphql/mutations/merge_requests/set_wip.rb b/app/graphql/mutations/merge_requests/set_wip.rb index 6f52b240840..9b6b67d4b4f 100644 --- a/app/graphql/mutations/merge_requests/set_wip.rb +++ b/app/graphql/mutations/merge_requests/set_wip.rb @@ -6,7 +6,7 @@ module Mutations graphql_name 'MergeRequestSetWip' argument :wip, - GraphQL::BOOLEAN_TYPE, + GraphQL::Types::Boolean, required: true, description: <<~DESC Whether or not to set the merge request as a draft. diff --git a/app/graphql/mutations/merge_requests/update.rb b/app/graphql/mutations/merge_requests/update.rb index 246e468c34c..0f4923e15a1 100644 --- a/app/graphql/mutations/merge_requests/update.rb +++ b/app/graphql/mutations/merge_requests/update.rb @@ -7,22 +7,22 @@ module Mutations description 'Update attributes of a merge request' - argument :title, GraphQL::STRING_TYPE, + argument :title, GraphQL::Types::String, required: false, description: copy_field_description(Types::MergeRequestType, :title) - argument :target_branch, GraphQL::STRING_TYPE, + argument :target_branch, GraphQL::Types::String, required: false, description: copy_field_description(Types::MergeRequestType, :target_branch) - argument :description, GraphQL::STRING_TYPE, + argument :description, GraphQL::Types::String, required: false, description: copy_field_description(Types::MergeRequestType, :description) argument :state, ::Types::MergeRequestStateEventEnum, required: false, as: :state_event, - description: 'The action to perform to change the state.' + description: 'Action to perform to change the state.' def resolve(project_path:, iid:, **args) merge_request = authorized_find!(project_path: project_path, iid: iid) diff --git a/app/graphql/mutations/metrics/dashboard/annotations/create.rb b/app/graphql/mutations/metrics/dashboard/annotations/create.rb index 85937809eb8..2eb48c9029d 100644 --- a/app/graphql/mutations/metrics/dashboard/annotations/create.rb +++ b/app/graphql/mutations/metrics/dashboard/annotations/create.rb @@ -15,17 +15,17 @@ module Mutations field :annotation, Types::Metrics::Dashboards::AnnotationType, null: true, - description: 'The created annotation.' + description: 'Created annotation.' argument :environment_id, ::Types::GlobalIDType[::Environment], required: false, - description: 'The global ID of the environment to add an annotation to.' + description: '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: 'Global ID of the cluster to add an annotation to.' argument :starting_at, Types::TimeType, required: true, @@ -36,14 +36,14 @@ module Mutations description: 'Timestamp indicating ending moment to which the annotation relates.' argument :dashboard_path, - GraphQL::STRING_TYPE, + GraphQL::Types::String, required: true, - description: 'The path to a file defining the dashboard on which the annotation should be added.' + description: 'Path to a file defining the dashboard on which the annotation should be added.' argument :description, - GraphQL::STRING_TYPE, + GraphQL::Types::String, required: true, - description: 'The description of the annotation.' + description: 'Description of the annotation.' AnnotationSource = Struct.new(:object, keyword_init: true) do def type_keys diff --git a/app/graphql/mutations/namespace/package_settings/update.rb b/app/graphql/mutations/namespace/package_settings/update.rb index 75c80cfbd3e..400169d6b64 100644 --- a/app/graphql/mutations/namespace/package_settings/update.rb +++ b/app/graphql/mutations/namespace/package_settings/update.rb @@ -11,12 +11,12 @@ module Mutations authorize :create_package_settings argument :namespace_path, - GraphQL::ID_TYPE, + GraphQL::Types::ID, required: true, - description: 'The namespace path where the namespace package setting is located.' + description: 'Namespace path where the namespace package setting is located.' argument :maven_duplicates_allowed, - GraphQL::BOOLEAN_TYPE, + GraphQL::Types::Boolean, required: false, description: copy_field_description(Types::Namespace::PackageSettingsType, :maven_duplicates_allowed) @@ -26,7 +26,7 @@ module Mutations description: copy_field_description(Types::Namespace::PackageSettingsType, :maven_duplicate_exception_regex) argument :generic_duplicates_allowed, - GraphQL::BOOLEAN_TYPE, + GraphQL::Types::Boolean, required: false, description: copy_field_description(Types::Namespace::PackageSettingsType, :generic_duplicates_allowed) @@ -38,7 +38,7 @@ module Mutations field :package_settings, Types::Namespace::PackageSettingsType, null: true, - description: 'The namespace package setting after mutation.' + description: 'Namespace package setting after mutation.' def resolve(namespace_path:, **args) namespace = authorized_find!(namespace_path: namespace_path) diff --git a/app/graphql/mutations/notes/base.rb b/app/graphql/mutations/notes/base.rb index ff401167ba1..d6c8121eee7 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: 'Note after mutation.' private diff --git a/app/graphql/mutations/notes/create/base.rb b/app/graphql/mutations/notes/create/base.rb index a157a5abdf2..e13a51c6862 100644 --- a/app/graphql/mutations/notes/create/base.rb +++ b/app/graphql/mutations/notes/create/base.rb @@ -11,17 +11,17 @@ module Mutations argument :noteable_id, ::Types::GlobalIDType[::Noteable], required: true, - description: 'The global ID of the resource to add a note to.' + description: 'Global ID of the resource to add a note to.' argument :body, - GraphQL::STRING_TYPE, + GraphQL::Types::String, required: true, description: copy_field_description(Types::Notes::NoteType, :body) argument :confidential, - GraphQL::BOOLEAN_TYPE, + GraphQL::Types::Boolean, required: false, - description: 'The confidentiality flag of a note. Default is false.' + description: 'Confidentiality flag of a note. Default is false.' def resolve(args) noteable = authorized_find!(id: args[:noteable_id]) diff --git a/app/graphql/mutations/notes/create/note.rb b/app/graphql/mutations/notes/create/note.rb index 7af93521e0d..5a5d62a8c20 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: '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 21b2cd15a7e..43a69021aaf 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: '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 31d3b7c9bb0..ec68f077c84 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: '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 571001981a4..2dfa7b815a1 100644 --- a/app/graphql/mutations/notes/update/base.rb +++ b/app/graphql/mutations/notes/update/base.rb @@ -17,7 +17,7 @@ module Mutations argument :id, ::Types::GlobalIDType[::Note], required: true, - description: 'The global ID of the note to update.' + description: 'Global ID of the note to update.' def resolve(args) note = authorized_find!(id: args[:id]) diff --git a/app/graphql/mutations/notes/update/image_diff_note.rb b/app/graphql/mutations/notes/update/image_diff_note.rb index 6160ee03f4e..284c0f1bb20 100644 --- a/app/graphql/mutations/notes/update/image_diff_note.rb +++ b/app/graphql/mutations/notes/update/image_diff_note.rb @@ -11,7 +11,7 @@ module Mutations DESC argument :body, - GraphQL::STRING_TYPE, + GraphQL::Types::String, required: false, description: copy_field_description(Types::Notes::NoteType, :body) diff --git a/app/graphql/mutations/notes/update/note.rb b/app/graphql/mutations/notes/update/note.rb index 11d8c6e2cb9..c7ee0148f94 100644 --- a/app/graphql/mutations/notes/update/note.rb +++ b/app/graphql/mutations/notes/update/note.rb @@ -8,14 +8,14 @@ module Mutations description "Updates a Note.\n#{QUICK_ACTION_ONLY_WARNING}" argument :body, - GraphQL::STRING_TYPE, + GraphQL::Types::String, required: false, description: copy_field_description(Types::Notes::NoteType, :body) argument :confidential, - GraphQL::BOOLEAN_TYPE, + GraphQL::Types::Boolean, required: false, - description: 'The confidentiality flag of a note. Default is false.' + description: 'Confidentiality flag of a note. Default is false.' private diff --git a/app/graphql/mutations/packages/destroy_file.rb b/app/graphql/mutations/packages/destroy_file.rb new file mode 100644 index 00000000000..35a486666d5 --- /dev/null +++ b/app/graphql/mutations/packages/destroy_file.rb @@ -0,0 +1,35 @@ +# frozen_string_literal: true + +module Mutations + module Packages + class DestroyFile < ::Mutations::BaseMutation + graphql_name 'DestroyPackageFile' + + authorize :destroy_package + + argument :id, + ::Types::GlobalIDType[::Packages::PackageFile], + required: true, + description: 'ID of the Package file.' + + def resolve(id:) + package_file = authorized_find!(id: id) + + if package_file.destroy + return { errors: [] } + end + + { errors: package_file.errors.full_messages } + 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 + id = ::Types::GlobalIDType[::Packages::PackageFile].coerce_isolated_input(id) + GitlabSchema.find_by_gid(id) + end + end + end +end diff --git a/app/graphql/mutations/release_asset_links/create.rb b/app/graphql/mutations/release_asset_links/create.rb index ff9d98d2c0f..db486640507 100644 --- a/app/graphql/mutations/release_asset_links/create.rb +++ b/app/graphql/mutations/release_asset_links/create.rb @@ -11,18 +11,18 @@ module Mutations include Types::ReleaseAssetLinkSharedInputArguments - argument :project_path, GraphQL::ID_TYPE, + argument :project_path, GraphQL::Types::ID, required: true, description: 'Full path of the project the asset link is associated with.' - argument :tag_name, GraphQL::STRING_TYPE, + argument :tag_name, GraphQL::Types::String, required: true, as: :tag, description: "Name of the associated release's tag." field :link, Types::ReleaseAssetLinkType, null: true, - description: 'The asset link after mutation.' + description: 'Asset link after mutation.' def resolve(project_path:, tag:, **link_attrs) project = authorized_find!(project_path) diff --git a/app/graphql/mutations/release_asset_links/delete.rb b/app/graphql/mutations/release_asset_links/delete.rb index dd450f36cdd..d8f0946670b 100644 --- a/app/graphql/mutations/release_asset_links/delete.rb +++ b/app/graphql/mutations/release_asset_links/delete.rb @@ -16,7 +16,7 @@ module Mutations field :link, Types::ReleaseAssetLinkType, null: true, - description: 'The deleted release asset link.' + description: 'Deleted release asset link.' def resolve(id:) link = authorized_find!(id) diff --git a/app/graphql/mutations/release_asset_links/update.rb b/app/graphql/mutations/release_asset_links/update.rb index 1d9460bde78..18d92cd82ae 100644 --- a/app/graphql/mutations/release_asset_links/update.rb +++ b/app/graphql/mutations/release_asset_links/update.rb @@ -13,26 +13,26 @@ module Mutations required: true, description: 'ID of the release asset link to update.' - argument :name, GraphQL::STRING_TYPE, + argument :name, GraphQL::Types::String, required: false, description: 'Name of the asset link.' - argument :url, GraphQL::STRING_TYPE, + argument :url, GraphQL::Types::String, required: false, description: 'URL of the asset link.' - argument :direct_asset_path, GraphQL::STRING_TYPE, + argument :direct_asset_path, GraphQL::Types::String, required: false, as: :filepath, description: 'Relative path for a direct asset link.' argument :link_type, Types::ReleaseAssetLinkTypeEnum, required: false, - description: 'The type of the asset link.' + description: 'Type of the asset link.' field :link, Types::ReleaseAssetLinkType, null: true, - description: 'The asset link after mutation.' + description: 'Asset link after mutation.' def ready?(**args) if args.key?(:link_type) && args[:link_type].nil? diff --git a/app/graphql/mutations/releases/base.rb b/app/graphql/mutations/releases/base.rb index 610e9cd9cde..a161dd73bdd 100644 --- a/app/graphql/mutations/releases/base.rb +++ b/app/graphql/mutations/releases/base.rb @@ -5,7 +5,7 @@ module Mutations class Base < BaseMutation include FindsProject - argument :project_path, GraphQL::ID_TYPE, + argument :project_path, GraphQL::Types::ID, required: true, description: 'Full path of the project the release is associated with.' end diff --git a/app/graphql/mutations/releases/create.rb b/app/graphql/mutations/releases/create.rb index 914c1302094..037ade2589c 100644 --- a/app/graphql/mutations/releases/create.rb +++ b/app/graphql/mutations/releases/create.rb @@ -8,31 +8,31 @@ module Mutations field :release, Types::ReleaseType, null: true, - description: 'The release after mutation.' + description: 'Release after mutation.' - argument :tag_name, GraphQL::STRING_TYPE, + argument :tag_name, GraphQL::Types::String, required: true, as: :tag, description: 'Name of the tag to associate with the release.' - argument :ref, GraphQL::STRING_TYPE, + argument :ref, GraphQL::Types::String, required: false, - description: 'The commit SHA or branch name to use if creating a new tag.' + description: 'Commit SHA or branch name to use if creating a new tag.' - argument :name, GraphQL::STRING_TYPE, + argument :name, GraphQL::Types::String, required: false, description: 'Name of the release.' - argument :description, GraphQL::STRING_TYPE, + argument :description, GraphQL::Types::String, required: false, description: 'Description (also known as "release notes") of the release.' argument :released_at, Types::TimeType, required: false, - description: 'The date when the release will be/was ready. Defaults to the current time.' + description: 'Date and time for the release. Defaults to the current date and time.' - argument :milestones, [GraphQL::STRING_TYPE], + argument :milestones, [GraphQL::Types::String], required: false, - description: 'The title of each milestone the release is associated with. GitLab Premium customers can specify group milestones.' + description: 'Title of each milestone the release is associated with. GitLab Premium customers can specify group milestones.' argument :assets, Types::ReleaseAssetsInputType, required: false, diff --git a/app/graphql/mutations/releases/delete.rb b/app/graphql/mutations/releases/delete.rb index 020c9133b58..70f12577054 100644 --- a/app/graphql/mutations/releases/delete.rb +++ b/app/graphql/mutations/releases/delete.rb @@ -8,9 +8,9 @@ module Mutations field :release, Types::ReleaseType, null: true, - description: 'The deleted release.' + description: 'Deleted release.' - argument :tag_name, GraphQL::STRING_TYPE, + argument :tag_name, GraphQL::Types::String, required: true, as: :tag, description: 'Name of the tag associated with the release to delete.' diff --git a/app/graphql/mutations/releases/update.rb b/app/graphql/mutations/releases/update.rb index 35f2a7b3d4b..549600f7653 100644 --- a/app/graphql/mutations/releases/update.rb +++ b/app/graphql/mutations/releases/update.rb @@ -8,27 +8,27 @@ module Mutations field :release, Types::ReleaseType, null: true, - description: 'The release after mutation.' + description: 'Release after mutation.' - argument :tag_name, GraphQL::STRING_TYPE, + argument :tag_name, GraphQL::Types::String, required: true, as: :tag, description: 'Name of the tag associated with the release.' - argument :name, GraphQL::STRING_TYPE, + argument :name, GraphQL::Types::String, required: false, description: 'Name of the release.' - argument :description, GraphQL::STRING_TYPE, + argument :description, GraphQL::Types::String, required: false, description: 'Description (release notes) of the release.' argument :released_at, Types::TimeType, required: false, - description: 'The release date.' + description: 'Release date.' - argument :milestones, [GraphQL::STRING_TYPE], + argument :milestones, [GraphQL::Types::String], required: false, - description: 'The title of each milestone the release is associated with. GitLab Premium customers can specify group milestones.' + description: 'Title of each milestone the release is associated with. GitLab Premium customers can specify group milestones.' authorize :update_release diff --git a/app/graphql/mutations/security/ci_configuration/base_security_analyzer.rb b/app/graphql/mutations/security/ci_configuration/base_security_analyzer.rb index 090a9a4e0ef..e5bb5b6d573 100644 --- a/app/graphql/mutations/security/ci_configuration/base_security_analyzer.rb +++ b/app/graphql/mutations/security/ci_configuration/base_security_analyzer.rb @@ -6,14 +6,14 @@ module Mutations class BaseSecurityAnalyzer < BaseMutation include FindsProject - argument :project_path, GraphQL::ID_TYPE, + argument :project_path, GraphQL::Types::ID, required: true, description: 'Full path of the project.' - field :success_path, GraphQL::STRING_TYPE, null: true, + field :success_path, GraphQL::Types::String, null: true, description: 'Redirect path to use when the response is successful.' - field :branch, GraphQL::STRING_TYPE, null: true, + field :branch, GraphQL::Types::String, null: true, description: 'Branch that has the new/modified `.gitlab-ci.yml` file.' authorize :push_code diff --git a/app/graphql/mutations/snippets/base.rb b/app/graphql/mutations/snippets/base.rb index 5196bc5c7ed..acaa7b80843 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: 'Snippet after mutation.' private diff --git a/app/graphql/mutations/snippets/create.rb b/app/graphql/mutations/snippets/create.rb index 765163e73a1..c01b0e4a01b 100644 --- a/app/graphql/mutations/snippets/create.rb +++ b/app/graphql/mutations/snippets/create.rb @@ -14,27 +14,27 @@ module Mutations field :snippet, Types::SnippetType, null: true, - description: 'The snippet after mutation.' + description: 'Snippet after mutation.' - argument :title, GraphQL::STRING_TYPE, + argument :title, GraphQL::Types::String, required: true, description: 'Title of the snippet.' - argument :description, GraphQL::STRING_TYPE, + argument :description, GraphQL::Types::String, required: false, description: 'Description of the snippet.' argument :visibility_level, Types::VisibilityLevelsEnum, - description: 'The visibility level of the snippet.', + description: 'Visibility level of the snippet.', required: true - argument :project_path, GraphQL::ID_TYPE, + argument :project_path, GraphQL::Types::ID, required: false, - description: 'The project full path the snippet is associated with.' + description: 'Full path of the project the snippet is associated with.' - argument :uploaded_files, [GraphQL::STRING_TYPE], + argument :uploaded_files, [GraphQL::Types::String], required: false, - description: 'The paths to files uploaded in the snippet description.' + description: 'Paths to files uploaded in the snippet description.' argument :blob_actions, [Types::Snippets::BlobActionInputType], description: 'Actions to perform over the snippet repository and blobs.', diff --git a/app/graphql/mutations/snippets/destroy.rb b/app/graphql/mutations/snippets/destroy.rb index 9b00f62e2f9..29358df3de5 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: '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 d6e3e131b81..e4626cff3e5 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: 'Global ID of the snippet to update.' def resolve(id:) snippet = authorized_find!(id: id) @@ -23,7 +23,7 @@ module Mutations private def mark_as_spam(snippet) - Spam::MarkAsSpamService.new(target: snippet).execute + Spam::AkismetMarkAsSpamService.new(target: snippet).execute end def authorized_resource?(snippet) diff --git a/app/graphql/mutations/snippets/update.rb b/app/graphql/mutations/snippets/update.rb index 792c631e5ca..9ecaa8d4bf2 100644 --- a/app/graphql/mutations/snippets/update.rb +++ b/app/graphql/mutations/snippets/update.rb @@ -11,18 +11,18 @@ module Mutations argument :id, ::Types::GlobalIDType[::Snippet], required: true, - description: 'The global ID of the snippet to update.' + description: 'Global ID of the snippet to update.' - argument :title, GraphQL::STRING_TYPE, + argument :title, GraphQL::Types::String, required: false, description: 'Title of the snippet.' - argument :description, GraphQL::STRING_TYPE, + argument :description, GraphQL::Types::String, required: false, description: 'Description of the snippet.' argument :visibility_level, Types::VisibilityLevelsEnum, - description: 'The visibility level of the snippet.', + description: 'Visibility level of the snippet.', required: false argument :blob_actions, [Types::Snippets::BlobActionInputType], diff --git a/app/graphql/mutations/todos/create.rb b/app/graphql/mutations/todos/create.rb index b6250b0228c..ccc3d0b61e4 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: "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 item created.' + description: 'To-do item created.' def resolve(target_id:) id = ::Types::GlobalIDType[Todoable].coerce_isolated_input(target_id) diff --git a/app/graphql/mutations/todos/mark_done.rb b/app/graphql/mutations/todos/mark_done.rb index a78cc91da68..4fecba55242 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 to-do item to mark as done.' + description: 'Global ID of the to-do item to mark as done.' field :todo, Types::TodoType, null: false, - description: 'The requested to-do item.' + description: 'Requested to-do item.' 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 70c33c439c4..def24cb71bc 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 to-do item to restore.' + description: 'Global ID of the to-do item to restore.' field :todo, Types::TodoType, null: false, - description: 'The requested to-do item.' + description: 'Requested to-do item.' 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 b09c59a3435..3453645000b 100644 --- a/app/graphql/mutations/todos/restore_many.rb +++ b/app/graphql/mutations/todos/restore_many.rb @@ -10,7 +10,7 @@ module Mutations argument :ids, [::Types::GlobalIDType[::Todo]], required: true, - description: 'The global IDs of the to-do items to restore (a maximum of 50 is supported at once).' + description: 'Global IDs of the to-do items to restore (a maximum of 50 is supported at once).' field :todos, [::Types::TodoType], null: false, diff --git a/app/graphql/mutations/user_callouts/create.rb b/app/graphql/mutations/user_callouts/create.rb index 0d3dcacda41..ff6e5cd28dd 100644 --- a/app/graphql/mutations/user_callouts/create.rb +++ b/app/graphql/mutations/user_callouts/create.rb @@ -6,13 +6,13 @@ module Mutations graphql_name 'UserCalloutCreate' argument :feature_name, - GraphQL::STRING_TYPE, + GraphQL::Types::String, required: true, - description: "The feature name you want to dismiss the callout for." + description: "Feature name you want to dismiss the callout for." field :user_callout, Types::UserCalloutType, null: false, - description: 'The user callout dismissed.' + description: 'User callout dismissed.' def resolve(feature_name:) callout = Users::DismissUserCalloutService.new( |