diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-08-19 09:08:42 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-08-19 09:08:42 +0000 |
commit | b76ae638462ab0f673e5915986070518dd3f9ad3 (patch) | |
tree | bdab0533383b52873be0ec0eb4d3c66598ff8b91 /app/graphql | |
parent | 434373eabe7b4be9593d18a585fb763f1e5f1a6f (diff) | |
download | gitlab-ce-b76ae638462ab0f673e5915986070518dd3f9ad3.tar.gz |
Add latest changes from gitlab-org/gitlab@14-2-stable-eev14.2.0-rc42
Diffstat (limited to 'app/graphql')
320 files changed, 1770 insertions, 1200 deletions
diff --git a/app/graphql/gitlab_schema.rb b/app/graphql/gitlab_schema.rb index 8e95bd501ff..38ba1611c48 100644 --- a/app/graphql/gitlab_schema.rb +++ b/app/graphql/gitlab_schema.rb @@ -3,9 +3,9 @@ class GitlabSchema < GraphQL::Schema # Currently an IntrospectionQuery has a complexity of 179. # These values will evolve over time. - DEFAULT_MAX_COMPLEXITY = 200 - AUTHENTICATED_COMPLEXITY = 250 - ADMIN_COMPLEXITY = 300 + DEFAULT_MAX_COMPLEXITY = 200 + AUTHENTICATED_MAX_COMPLEXITY = 250 + ADMIN_MAX_COMPLEXITY = 300 DEFAULT_MAX_DEPTH = 15 AUTHENTICATED_MAX_DEPTH = 20 @@ -20,9 +20,6 @@ class GitlabSchema < GraphQL::Schema query_analyzer Gitlab::Graphql::QueryAnalyzers::LoggerAnalyzer.new query_analyzer Gitlab::Graphql::QueryAnalyzers::RecursionAnalyzer.new - max_complexity DEFAULT_MAX_COMPLEXITY - max_depth DEFAULT_MAX_DEPTH - query Types::QueryType mutation Types::MutationType subscription Types::SubscriptionType @@ -36,20 +33,13 @@ class GitlabSchema < GraphQL::Schema kwargs[:max_complexity] ||= max_query_complexity(kwargs[:context]) unless kwargs.key?(:max_complexity) queries.each do |query| - query[:max_complexity] ||= max_query_complexity(kwargs[:context]) unless query.key?(:max_complexity) - query[:max_depth] = max_query_depth(kwargs[:context]) + query[:max_complexity] ||= max_query_complexity(query[:context]) unless query.key?(:max_complexity) + query[:max_depth] = max_query_depth(query[:context]) unless query.key?(:max_depth) end super(queries, **kwargs) end - def execute(query_str = nil, **kwargs) - kwargs[:max_complexity] ||= max_query_complexity(kwargs[:context]) - kwargs[:max_depth] ||= max_query_depth(kwargs[:context]) - - super(query_str, **kwargs) - end - def get_type(type_name) type_name = Gitlab::GlobalId::Deprecations.apply_to_graphql_name(type_name) @@ -142,9 +132,9 @@ class GitlabSchema < GraphQL::Schema current_user = ctx&.fetch(:current_user, nil) if current_user&.admin - ADMIN_COMPLEXITY + ADMIN_MAX_COMPLEXITY elsif current_user - AUTHENTICATED_COMPLEXITY + AUTHENTICATED_MAX_COMPLEXITY else DEFAULT_MAX_COMPLEXITY end 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( diff --git a/app/graphql/queries/design_management/get_design_list.query.graphql b/app/graphql/queries/design_management/get_design_list.query.graphql index ade03d99797..01503a9572f 100644 --- a/app/graphql/queries/design_management/get_design_list.query.graphql +++ b/app/graphql/queries/design_management/get_design_list.query.graphql @@ -32,6 +32,13 @@ query getDesignList($fullPath: ID!, $iid: String!, $atVersion: ID) { __typename id sha + createdAt + author { + __typename + id + name + avatarUrl + } } } } diff --git a/app/graphql/resolvers/admin/analytics/usage_trends/measurements_resolver.rb b/app/graphql/resolvers/admin/analytics/usage_trends/measurements_resolver.rb index a5f81149d4e..b5a19d38b9c 100644 --- a/app/graphql/resolvers/admin/analytics/usage_trends/measurements_resolver.rb +++ b/app/graphql/resolvers/admin/analytics/usage_trends/measurements_resolver.rb @@ -11,7 +11,7 @@ module Resolvers argument :identifier, Types::Admin::Analytics::UsageTrends::MeasurementIdentifierEnum, required: true, - description: 'The type of measurement/statistics to retrieve.' + description: 'Type of measurement or statistics to retrieve.' argument :recorded_after, Types::TimeType, required: false, diff --git a/app/graphql/resolvers/alert_management/alert_resolver.rb b/app/graphql/resolvers/alert_management/alert_resolver.rb index 62744e719da..899b90a94dd 100644 --- a/app/graphql/resolvers/alert_management/alert_resolver.rb +++ b/app/graphql/resolvers/alert_management/alert_resolver.rb @@ -5,7 +5,7 @@ module Resolvers class AlertResolver < BaseResolver include LooksAhead - argument :iid, GraphQL::STRING_TYPE, + argument :iid, GraphQL::Types::String, required: false, description: 'IID of the alert. For example, "1".' @@ -23,11 +23,11 @@ module Resolvers required: true, default_value: 'operations' - argument :search, GraphQL::STRING_TYPE, + argument :search, GraphQL::Types::String, description: 'Search query for title, description, service, or monitoring_tool.', required: false - argument :assignee_username, GraphQL::STRING_TYPE, + argument :assignee_username, GraphQL::Types::String, required: false, description: 'Username of a user assigned to the issue.' diff --git a/app/graphql/resolvers/alert_management/alert_status_counts_resolver.rb b/app/graphql/resolvers/alert_management/alert_status_counts_resolver.rb index 410f72cff84..568d648a95e 100644 --- a/app/graphql/resolvers/alert_management/alert_status_counts_resolver.rb +++ b/app/graphql/resolvers/alert_management/alert_status_counts_resolver.rb @@ -5,11 +5,11 @@ module Resolvers class AlertStatusCountsResolver < BaseResolver type Types::AlertManagement::AlertStatusCountsType, null: true - argument :search, GraphQL::STRING_TYPE, + argument :search, GraphQL::Types::String, description: 'Search query for title, description, service, or monitoring_tool.', required: false - argument :assignee_username, GraphQL::STRING_TYPE, + argument :assignee_username, GraphQL::Types::String, required: false, description: 'Username of a user assigned to the issue.' diff --git a/app/graphql/resolvers/blobs_resolver.rb b/app/graphql/resolvers/blobs_resolver.rb index d006769bd4b..d0eb2deaf48 100644 --- a/app/graphql/resolvers/blobs_resolver.rb +++ b/app/graphql/resolvers/blobs_resolver.rb @@ -10,13 +10,13 @@ module Resolvers alias_method :repository, :object - argument :paths, [GraphQL::STRING_TYPE], + argument :paths, [GraphQL::Types::String], required: true, description: 'Array of desired blob paths.' - argument :ref, GraphQL::STRING_TYPE, + argument :ref, GraphQL::Types::String, required: false, default_value: nil, - description: 'The commit ref to get the blobs from. Default value is HEAD.' + description: 'Commit ref to get the blobs from. Default value is HEAD.' # We fetch blobs from Gitaly efficiently but it still scales O(N) with the # number of paths being fetched, so apply a scaling limit to that. diff --git a/app/graphql/resolvers/board_resolver.rb b/app/graphql/resolvers/board_resolver.rb index 85362ab1422..24df67b7b6e 100644 --- a/app/graphql/resolvers/board_resolver.rb +++ b/app/graphql/resolvers/board_resolver.rb @@ -8,7 +8,7 @@ module Resolvers argument :id, ::Types::GlobalIDType[::Board], required: true, - description: 'The board\'s ID.' + description: 'ID of the board.' def resolve(id: nil) return unless parent diff --git a/app/graphql/resolvers/ci/config_resolver.rb b/app/graphql/resolvers/ci/config_resolver.rb index f2e33251b9c..2d74392a84c 100644 --- a/app/graphql/resolvers/ci/config_resolver.rb +++ b/app/graphql/resolvers/ci/config_resolver.rb @@ -14,19 +14,19 @@ module Resolvers authorize :read_pipeline - argument :project_path, GraphQL::ID_TYPE, + argument :project_path, GraphQL::Types::ID, required: true, - description: 'The project of the CI config.' + description: 'Project of the CI config.' - argument :sha, GraphQL::STRING_TYPE, + argument :sha, GraphQL::Types::String, required: false, description: "Sha for the pipeline." - argument :content, GraphQL::STRING_TYPE, + argument :content, GraphQL::Types::String, required: true, description: "Contents of `.gitlab-ci.yml`." - argument :dry_run, GraphQL::BOOLEAN_TYPE, + argument :dry_run, GraphQL::Types::Boolean, required: false, description: 'Run pipeline creation simulation, or only do static check.' diff --git a/app/graphql/resolvers/ci/runner_setup_resolver.rb b/app/graphql/resolvers/ci/runner_setup_resolver.rb index 9166999b400..6b21f5c3ab4 100644 --- a/app/graphql/resolvers/ci/runner_setup_resolver.rb +++ b/app/graphql/resolvers/ci/runner_setup_resolver.rb @@ -9,12 +9,12 @@ module Resolvers description 'Runner setup instructions.' argument :platform, - type: GraphQL::STRING_TYPE, + type: GraphQL::Types::String, required: true, description: 'Platform to generate the instructions for.' argument :architecture, - type: GraphQL::STRING_TYPE, + type: GraphQL::Types::String, required: true, description: 'Architecture to generate the instructions for.' diff --git a/app/graphql/resolvers/ci/runners_resolver.rb b/app/graphql/resolvers/ci/runners_resolver.rb index 5074a248e18..1957c4ec058 100644 --- a/app/graphql/resolvers/ci/runners_resolver.rb +++ b/app/graphql/resolvers/ci/runners_resolver.rb @@ -15,11 +15,11 @@ module Resolvers required: false, description: 'Filter runners by type.' - argument :tag_list, [GraphQL::STRING_TYPE], + argument :tag_list, [GraphQL::Types::String], required: false, description: 'Filter by tags associated with the runner (comma-separated or array).' - argument :search, GraphQL::STRING_TYPE, + argument :search, GraphQL::Types::String, required: false, description: 'Filter by full token or partial text in description field.' diff --git a/app/graphql/resolvers/ci/template_resolver.rb b/app/graphql/resolvers/ci/template_resolver.rb index 7f5a1a486d7..17f2668df11 100644 --- a/app/graphql/resolvers/ci/template_resolver.rb +++ b/app/graphql/resolvers/ci/template_resolver.rb @@ -5,7 +5,7 @@ module Resolvers class TemplateResolver < BaseResolver type Types::Ci::TemplateType, null: true - argument :name, GraphQL::STRING_TYPE, required: true, + argument :name, GraphQL::Types::String, required: true, description: 'Name of the CI/CD template to search for. Template must be formatted as `Name.gitlab-ci.yml`.' alias_method :project, :object diff --git a/app/graphql/resolvers/ci/test_suite_resolver.rb b/app/graphql/resolvers/ci/test_suite_resolver.rb index 90cc30b1281..5d61d9e986b 100644 --- a/app/graphql/resolvers/ci/test_suite_resolver.rb +++ b/app/graphql/resolvers/ci/test_suite_resolver.rb @@ -11,7 +11,7 @@ module Resolvers alias_method :pipeline, :object - argument :build_ids, [GraphQL::ID_TYPE], + argument :build_ids, [GraphQL::Types::ID], required: true, description: 'IDs of the builds used to run the test suite.' diff --git a/app/graphql/resolvers/concerns/group_issuable_resolver.rb b/app/graphql/resolvers/concerns/group_issuable_resolver.rb index 49a79683e9f..542ff5374ff 100644 --- a/app/graphql/resolvers/concerns/group_issuable_resolver.rb +++ b/app/graphql/resolvers/concerns/group_issuable_resolver.rb @@ -5,7 +5,7 @@ module GroupIssuableResolver class_methods do def include_subgroups(name_of_things) - argument :include_subgroups, GraphQL::BOOLEAN_TYPE, + argument :include_subgroups, GraphQL::Types::Boolean, required: false, default_value: false, description: "Include #{name_of_things} belonging to subgroups" diff --git a/app/graphql/resolvers/concerns/issue_resolver_arguments.rb b/app/graphql/resolvers/concerns/issue_resolver_arguments.rb index c24f4dedc0e..8d77c0f3a8d 100644 --- a/app/graphql/resolvers/concerns/issue_resolver_arguments.rb +++ b/app/graphql/resolvers/concerns/issue_resolver_arguments.rb @@ -6,29 +6,29 @@ module IssueResolverArguments prepended do include LooksAhead - argument :iid, GraphQL::STRING_TYPE, + argument :iid, GraphQL::Types::String, required: false, description: 'IID of the issue. For example, "1".' - argument :iids, [GraphQL::STRING_TYPE], + argument :iids, [GraphQL::Types::String], required: false, description: 'List of IIDs of issues. For example, `["1", "2"]`.' - argument :label_name, [GraphQL::STRING_TYPE, null: true], + argument :label_name, [GraphQL::Types::String, null: true], required: false, description: 'Labels applied to this issue.' - argument :milestone_title, [GraphQL::STRING_TYPE, null: true], + argument :milestone_title, [GraphQL::Types::String, null: true], required: false, description: 'Milestone applied to this issue.' - argument :author_username, GraphQL::STRING_TYPE, + argument :author_username, GraphQL::Types::String, required: false, description: 'Username of the author of the issue.' - argument :assignee_username, GraphQL::STRING_TYPE, + argument :assignee_username, GraphQL::Types::String, required: false, description: 'Username of a user assigned to the issue.', deprecated: { reason: 'Use `assigneeUsernames`', milestone: '13.11' } - argument :assignee_usernames, [GraphQL::STRING_TYPE], + argument :assignee_usernames, [GraphQL::Types::String], required: false, description: 'Usernames of users assigned to the issue.' - argument :assignee_id, GraphQL::STRING_TYPE, + argument :assignee_id, GraphQL::Types::String, required: false, description: 'ID of a user assigned to the issues, "none" and "any" values are supported.' argument :created_before, Types::TimeType, @@ -49,13 +49,16 @@ module IssueResolverArguments argument :closed_after, Types::TimeType, required: false, description: 'Issues closed after this date.' - argument :search, GraphQL::STRING_TYPE, + argument :search, GraphQL::Types::String, required: false, description: 'Search query for issue title or description.' argument :types, [Types::IssueTypeEnum], as: :issue_types, description: 'Filter issues by the given issue types.', required: false + argument :milestone_wildcard_id, ::Types::MilestoneWildcardIdEnum, + required: false, + description: 'Filter issues by milestone ID wildcard.' argument :not, Types::Issues::NegatedIssueFilterInputType, description: 'Negated arguments.', prepare: ->(negated_args, ctx) { negated_args.to_h }, @@ -82,10 +85,9 @@ module IssueResolverArguments end def ready?(**args) - if args.slice(*mutually_exclusive_assignee_username_args).compact.size > 1 - arg_str = mutually_exclusive_assignee_username_args.map { |x| x.to_s.camelize(:lower) }.join(', ') - raise Gitlab::Graphql::Errors::ArgumentError, "only one of [#{arg_str}] arguments is allowed at the same time." - end + params_not_mutually_exclusive(args, mutually_exclusive_assignee_username_args) + params_not_mutually_exclusive(args, mutually_exclusive_milestone_args) + params_not_mutually_exclusive(args.fetch(:not, {}), mutually_exclusive_milestone_args) super end @@ -106,6 +108,17 @@ module IssueResolverArguments args[:not][:assignee_username] = args[:not].delete(:assignee_usernames) if args.dig(:not, :assignee_usernames).present? end + def params_not_mutually_exclusive(args, mutually_exclusive_args) + if args.slice(*mutually_exclusive_args).compact.size > 1 + arg_str = mutually_exclusive_args.map { |x| x.to_s.camelize(:lower) }.join(', ') + raise ::Gitlab::Graphql::Errors::ArgumentError, "only one of [#{arg_str}] arguments is allowed at the same time." + end + end + + def mutually_exclusive_milestone_args + [:milestone_title, :milestone_wildcard_id] + end + def mutually_exclusive_assignee_username_args [:assignee_usernames, :assignee_username] end diff --git a/app/graphql/resolvers/concerns/resolves_ids.rb b/app/graphql/resolvers/concerns/resolves_ids.rb new file mode 100644 index 00000000000..8bf2a6b2ac9 --- /dev/null +++ b/app/graphql/resolvers/concerns/resolves_ids.rb @@ -0,0 +1,16 @@ +# frozen_string_literal: true + +module ResolvesIds + extend ActiveSupport::Concern + + def resolve_ids(ids, type) + Array.wrap(ids).map do |id| + next unless id.present? + + # TODO: remove this line when the compatibility layer is removed + # See: https://gitlab.com/gitlab-org/gitlab/-/issues/257883 + id = type.coerce_isolated_input(id) + id.model_id + end.compact + end +end diff --git a/app/graphql/resolvers/concerns/resolves_pipelines.rb b/app/graphql/resolvers/concerns/resolves_pipelines.rb index bbf33c0b5eb..77f2105db7c 100644 --- a/app/graphql/resolvers/concerns/resolves_pipelines.rb +++ b/app/graphql/resolvers/concerns/resolves_pipelines.rb @@ -10,11 +10,11 @@ module ResolvesPipelines required: false, description: "Filter pipelines by their status." argument :ref, - GraphQL::STRING_TYPE, + GraphQL::Types::String, required: false, description: "Filter pipelines by the ref they are run for." argument :sha, - GraphQL::STRING_TYPE, + GraphQL::Types::String, required: false, description: "Filter pipelines by the sha of the commit they are run for." end diff --git a/app/graphql/resolvers/concerns/resolves_snippets.rb b/app/graphql/resolvers/concerns/resolves_snippets.rb index 8de85c074ec..46d78a6a8c8 100644 --- a/app/graphql/resolvers/concerns/resolves_snippets.rb +++ b/app/graphql/resolvers/concerns/resolves_snippets.rb @@ -2,6 +2,7 @@ module ResolvesSnippets extend ActiveSupport::Concern + include ResolvesIds included do type Types::SnippetType.connection_type, null: true @@ -12,7 +13,7 @@ module ResolvesSnippets argument :visibility, Types::Snippets::VisibilityScopesEnum, required: false, - description: 'The visibility of the snippet.' + description: 'Visibility of the snippet.' end def resolve(**args) @@ -27,22 +28,11 @@ module ResolvesSnippets def snippet_finder_params(args) { - ids: resolve_ids(args[:ids]), + ids: resolve_ids(args[:ids], ::Types::GlobalIDType[::Snippet]), scope: args[:visibility] }.merge(options_by_type(args[:type])) end - def resolve_ids(ids, type = ::Types::GlobalIDType[::Snippet]) - Array.wrap(ids).map do |id| - next unless id.present? - - # TODO: remove this line when the compatibility layer is removed - # See: https://gitlab.com/gitlab-org/gitlab/-/issues/257883 - id = type.coerce_isolated_input(id) - id.model_id - end.compact - end - def options_by_type(type) case type when 'personal' diff --git a/app/graphql/resolvers/container_repositories_resolver.rb b/app/graphql/resolvers/container_repositories_resolver.rb index 17af2a2f070..1e06d4e9094 100644 --- a/app/graphql/resolvers/container_repositories_resolver.rb +++ b/app/graphql/resolvers/container_repositories_resolver.rb @@ -6,7 +6,7 @@ module Resolvers type Types::ContainerRepositoryType, null: true - argument :name, GraphQL::STRING_TYPE, + argument :name, GraphQL::Types::String, required: false, description: 'Filter the container repositories by their name.' diff --git a/app/graphql/resolvers/design_management/design_at_version_resolver.rb b/app/graphql/resolvers/design_management/design_at_version_resolver.rb index 533692e2b12..c87670bc24c 100644 --- a/app/graphql/resolvers/design_management/design_at_version_resolver.rb +++ b/app/graphql/resolvers/design_management/design_at_version_resolver.rb @@ -11,7 +11,7 @@ module Resolvers argument :id, ::Types::GlobalIDType[::DesignManagement::DesignAtVersion], required: true, - description: 'The Global ID of the design at this version.' + description: 'Global ID of the design at this version.' def resolve(id:) authorized_find!(id: id) diff --git a/app/graphql/resolvers/design_management/design_resolver.rb b/app/graphql/resolvers/design_management/design_resolver.rb index e640f57f04a..d9e5203ef0e 100644 --- a/app/graphql/resolvers/design_management/design_resolver.rb +++ b/app/graphql/resolvers/design_management/design_resolver.rb @@ -11,7 +11,7 @@ module Resolvers required: false, description: 'Find a design by its ID.' - argument :filename, GraphQL::STRING_TYPE, + argument :filename, GraphQL::Types::String, required: false, description: 'Find a design by its filename.' diff --git a/app/graphql/resolvers/design_management/designs_resolver.rb b/app/graphql/resolvers/design_management/designs_resolver.rb index c45e4d01f6e..dec778fac80 100644 --- a/app/graphql/resolvers/design_management/designs_resolver.rb +++ b/app/graphql/resolvers/design_management/designs_resolver.rb @@ -11,7 +11,7 @@ module Resolvers argument :ids, [DesignID], required: false, description: 'Filters designs by their ID.' - argument :filenames, [GraphQL::STRING_TYPE], + argument :filenames, [GraphQL::Types::String], required: false, description: 'Filters designs by their filename.' argument :at_version, VersionID, diff --git a/app/graphql/resolvers/design_management/version/design_at_version_resolver.rb b/app/graphql/resolvers/design_management/version/design_at_version_resolver.rb index fea74cbfb0b..d879c1434dc 100644 --- a/app/graphql/resolvers/design_management/version/design_at_version_resolver.rb +++ b/app/graphql/resolvers/design_management/version/design_at_version_resolver.rb @@ -19,13 +19,13 @@ module Resolvers argument :id, DesignAtVersionID, required: false, as: :design_at_version_id, - description: 'The ID of the DesignAtVersion.' + description: 'ID of the DesignAtVersion.' argument :design_id, DesignID, required: false, - description: 'The ID of a specific design.' - argument :filename, GraphQL::STRING_TYPE, + description: 'ID of a specific design.' + argument :filename, GraphQL::Types::String, required: false, - description: 'The filename of a specific design.' + description: 'Filename of a specific design.' def self.single self diff --git a/app/graphql/resolvers/design_management/version/designs_at_version_resolver.rb b/app/graphql/resolvers/design_management/version/designs_at_version_resolver.rb index 930b1b60d0e..254f1efa0a5 100644 --- a/app/graphql/resolvers/design_management/version/designs_at_version_resolver.rb +++ b/app/graphql/resolvers/design_management/version/designs_at_version_resolver.rb @@ -17,7 +17,7 @@ module Resolvers required: false, description: 'Filters designs by their ID.' argument :filenames, - [GraphQL::STRING_TYPE], + [GraphQL::Types::String], required: false, description: 'Filters designs by their filename.' diff --git a/app/graphql/resolvers/design_management/version_in_collection_resolver.rb b/app/graphql/resolvers/design_management/version_in_collection_resolver.rb index 593974beb04..80db15755d3 100644 --- a/app/graphql/resolvers/design_management/version_in_collection_resolver.rb +++ b/app/graphql/resolvers/design_management/version_in_collection_resolver.rb @@ -15,13 +15,13 @@ module Resolvers VersionID = ::Types::GlobalIDType[::DesignManagement::Version] - argument :sha, GraphQL::STRING_TYPE, + argument :sha, GraphQL::Types::String, required: false, - description: "The SHA256 of a specific version." + description: "SHA256 of a specific version." argument :id, VersionID, as: :version_id, required: false, - description: 'The Global ID of the version.' + description: 'Global ID of the version.' def resolve(version_id: nil, sha: nil) # TODO: remove this line when the compatibility layer is removed diff --git a/app/graphql/resolvers/design_management/version_resolver.rb b/app/graphql/resolvers/design_management/version_resolver.rb index 2144e588208..a6403fbd69f 100644 --- a/app/graphql/resolvers/design_management/version_resolver.rb +++ b/app/graphql/resolvers/design_management/version_resolver.rb @@ -11,7 +11,7 @@ module Resolvers argument :id, ::Types::GlobalIDType[::DesignManagement::Version], required: true, - description: 'The Global ID of the version.' + description: 'Global ID of the version.' def resolve(id:) authorized_find!(id: id) diff --git a/app/graphql/resolvers/design_management/versions_resolver.rb b/app/graphql/resolvers/design_management/versions_resolver.rb index 08b29d884b0..23ba3c86d98 100644 --- a/app/graphql/resolvers/design_management/versions_resolver.rb +++ b/app/graphql/resolvers/design_management/versions_resolver.rb @@ -11,15 +11,15 @@ module Resolvers extras [:parent] - argument :earlier_or_equal_to_sha, GraphQL::STRING_TYPE, + argument :earlier_or_equal_to_sha, GraphQL::Types::String, as: :sha, required: false, - description: 'The SHA256 of the most recent acceptable version.' + description: 'SHA256 of the most recent acceptable version.' argument :earlier_or_equal_to_id, VersionID, as: :id, required: false, - description: 'The Global ID of the most recent acceptable version.' + description: 'Global ID of the most recent acceptable version.' # This resolver has a custom singular resolver def self.single diff --git a/app/graphql/resolvers/echo_resolver.rb b/app/graphql/resolvers/echo_resolver.rb index a09b0a1fd87..856e6873a65 100644 --- a/app/graphql/resolvers/echo_resolver.rb +++ b/app/graphql/resolvers/echo_resolver.rb @@ -2,11 +2,11 @@ module Resolvers class EchoResolver < BaseResolver - type ::GraphQL::STRING_TYPE, null: false + type ::GraphQL::Types::String, null: false description 'Testing endpoint to validate the API with' argument :text, - type: GraphQL::STRING_TYPE, + type: GraphQL::Types::String, required: true, description: 'Text to echo back.' diff --git a/app/graphql/resolvers/environments_resolver.rb b/app/graphql/resolvers/environments_resolver.rb index ee604e7b307..1823eb65d44 100644 --- a/app/graphql/resolvers/environments_resolver.rb +++ b/app/graphql/resolvers/environments_resolver.rb @@ -2,15 +2,15 @@ module Resolvers class EnvironmentsResolver < BaseResolver - argument :name, GraphQL::STRING_TYPE, + argument :name, GraphQL::Types::String, required: false, description: 'Name of the environment.' - argument :search, GraphQL::STRING_TYPE, + argument :search, GraphQL::Types::String, required: false, description: 'Search query for environment name.' - argument :states, [GraphQL::STRING_TYPE], + argument :states, [GraphQL::Types::String], required: false, description: 'States of environments that should be included in result.' diff --git a/app/graphql/resolvers/error_tracking/sentry_errors_resolver.rb b/app/graphql/resolvers/error_tracking/sentry_errors_resolver.rb index 4cd65daa655..793b73342ab 100644 --- a/app/graphql/resolvers/error_tracking/sentry_errors_resolver.rb +++ b/app/graphql/resolvers/error_tracking/sentry_errors_resolver.rb @@ -6,12 +6,12 @@ module Resolvers type Types::ErrorTracking::SentryErrorType.connection_type, null: true extension Gitlab::Graphql::Extensions::ExternallyPaginatedArrayExtension - argument :search_term, ::GraphQL::STRING_TYPE, + argument :search_term, ::GraphQL::Types::String, description: 'Search query for the Sentry error details.', required: false # TODO: convert to Enum - argument :sort, ::GraphQL::STRING_TYPE, + argument :sort, ::GraphQL::Types::String, description: 'Attribute to sort on. Options are frequency, first_seen, last_seen. last_seen is default.', required: false diff --git a/app/graphql/resolvers/full_path_resolver.rb b/app/graphql/resolvers/full_path_resolver.rb index b5e90da78b2..b8df54f49ab 100644 --- a/app/graphql/resolvers/full_path_resolver.rb +++ b/app/graphql/resolvers/full_path_resolver.rb @@ -5,9 +5,9 @@ module Resolvers extend ActiveSupport::Concern prepended do - argument :full_path, GraphQL::ID_TYPE, + argument :full_path, GraphQL::Types::ID, required: true, - description: 'The full path of the project, group or namespace, e.g., `gitlab-org/gitlab-foss`.' + description: 'Full path of the project, group, or namespace. For example, `gitlab-org/gitlab-foss`.' end def model_by_full_path(model, full_path) diff --git a/app/graphql/resolvers/group_labels_resolver.rb b/app/graphql/resolvers/group_labels_resolver.rb index 5c2f950bbc0..a22fa9761d6 100644 --- a/app/graphql/resolvers/group_labels_resolver.rb +++ b/app/graphql/resolvers/group_labels_resolver.rb @@ -4,12 +4,12 @@ module Resolvers class GroupLabelsResolver < LabelsResolver type Types::LabelType.connection_type, null: true - argument :include_descendant_groups, GraphQL::BOOLEAN_TYPE, + argument :include_descendant_groups, GraphQL::Types::Boolean, required: false, description: 'Include labels from descendant groups.', default_value: false - argument :only_group_labels, GraphQL::BOOLEAN_TYPE, + argument :only_group_labels, GraphQL::Types::Boolean, required: false, description: 'Include only group level labels.', default_value: false diff --git a/app/graphql/resolvers/group_milestones_resolver.rb b/app/graphql/resolvers/group_milestones_resolver.rb index 31280b36278..44192b6f4bf 100644 --- a/app/graphql/resolvers/group_milestones_resolver.rb +++ b/app/graphql/resolvers/group_milestones_resolver.rb @@ -2,10 +2,10 @@ module Resolvers class GroupMilestonesResolver < MilestonesResolver - argument :include_descendants, GraphQL::BOOLEAN_TYPE, + argument :include_descendants, GraphQL::Types::Boolean, required: false, description: 'Include milestones from all subgroups and subprojects.' - argument :include_ancestors, GraphQL::BOOLEAN_TYPE, + argument :include_ancestors, GraphQL::Types::Boolean, required: false, description: 'Include milestones from all parent groups.' diff --git a/app/graphql/resolvers/groups_resolver.rb b/app/graphql/resolvers/groups_resolver.rb new file mode 100644 index 00000000000..b090fdc49d4 --- /dev/null +++ b/app/graphql/resolvers/groups_resolver.rb @@ -0,0 +1,39 @@ +# frozen_string_literal: true + +module Resolvers + class GroupsResolver < BaseResolver + type Types::GroupType, null: true + + argument :include_parent_descendants, GraphQL::Types::Boolean, + required: false, + description: 'List of descendant groups of the parent group.', + default_value: true + + argument :owned, GraphQL::Types::Boolean, + required: false, + description: 'Limit result to groups owned by authenticated user.' + + argument :search, GraphQL::Types::String, + required: false, + description: 'Search query for group name or group full path.' + + alias_method :parent, :object + + def resolve(**args) + return [] unless parent.present? + + find_groups(args) + end + + private + + # rubocop: disable CodeReuse/ActiveRecord + def find_groups(args) + GroupsFinder + .new(context[:current_user], args.merge(parent: parent)) + .execute + .reorder('name ASC') + end + # rubocop: enable CodeReuse/ActiveRecord + end +end diff --git a/app/graphql/resolvers/issues_resolver.rb b/app/graphql/resolvers/issues_resolver.rb index 2017eb7decd..47e4e3c0b32 100644 --- a/app/graphql/resolvers/issues_resolver.rb +++ b/app/graphql/resolvers/issues_resolver.rb @@ -37,7 +37,8 @@ module Resolvers [ { project: [:project_feature] - } + }, + :author ] end diff --git a/app/graphql/resolvers/labels_resolver.rb b/app/graphql/resolvers/labels_resolver.rb index 1b523b8a240..505d1dff8d2 100644 --- a/app/graphql/resolvers/labels_resolver.rb +++ b/app/graphql/resolvers/labels_resolver.rb @@ -8,11 +8,11 @@ module Resolvers type Types::LabelType.connection_type, null: true - argument :search_term, GraphQL::STRING_TYPE, + argument :search_term, GraphQL::Types::String, required: false, description: 'A search term to find labels with.' - argument :include_ancestor_groups, GraphQL::BOOLEAN_TYPE, + argument :include_ancestor_groups, GraphQL::Types::Boolean, required: false, description: 'Include labels from ancestor groups.', default_value: false diff --git a/app/graphql/resolvers/members_resolver.rb b/app/graphql/resolvers/members_resolver.rb index 2b731d54cdd..827db54134a 100644 --- a/app/graphql/resolvers/members_resolver.rb +++ b/app/graphql/resolvers/members_resolver.rb @@ -7,7 +7,7 @@ module Resolvers type Types::MemberInterface.connection_type, null: true - argument :search, GraphQL::STRING_TYPE, + argument :search, GraphQL::Types::String, required: false, description: 'Search query.' diff --git a/app/graphql/resolvers/merge_request_resolver.rb b/app/graphql/resolvers/merge_request_resolver.rb index c431d079beb..0f0f3ee3772 100644 --- a/app/graphql/resolvers/merge_request_resolver.rb +++ b/app/graphql/resolvers/merge_request_resolver.rb @@ -8,7 +8,7 @@ module Resolvers type ::Types::MergeRequestType, null: true - argument :iid, GraphQL::STRING_TYPE, + argument :iid, GraphQL::Types::String, required: true, as: :iids, description: 'IID of the merge request, for example `1`.' diff --git a/app/graphql/resolvers/merge_requests_count_resolver.rb b/app/graphql/resolvers/merge_requests_count_resolver.rb new file mode 100644 index 00000000000..fc5b442db03 --- /dev/null +++ b/app/graphql/resolvers/merge_requests_count_resolver.rb @@ -0,0 +1,17 @@ +# frozen_string_literal: true + +module Resolvers + class MergeRequestsCountResolver < BaseResolver + type GraphQL::Types::Int, null: true + + def resolve + BatchLoader::GraphQL.for(object.id).batch do |ids, loader, args| + counts = MergeRequestsClosingIssues.count_for_collection(ids, context[:current_user]).to_h + + ids.each do |id| + loader.call(id, counts[id] || 0) + end + end + end + end +end diff --git a/app/graphql/resolvers/merge_requests_resolver.rb b/app/graphql/resolvers/merge_requests_resolver.rb index a9eea4ae4b8..8f2c7847a2e 100644 --- a/app/graphql/resolvers/merge_requests_resolver.rb +++ b/app/graphql/resolvers/merge_requests_resolver.rb @@ -10,28 +10,28 @@ module Resolvers alias_method :project, :object def self.accept_assignee - argument :assignee_username, GraphQL::STRING_TYPE, + argument :assignee_username, GraphQL::Types::String, required: false, description: 'Username of the assignee.' end def self.accept_author - argument :author_username, GraphQL::STRING_TYPE, + argument :author_username, GraphQL::Types::String, required: false, description: 'Username of the author.' end def self.accept_reviewer - argument :reviewer_username, GraphQL::STRING_TYPE, + argument :reviewer_username, GraphQL::Types::String, required: false, description: 'Username of the reviewer.' end - argument :iids, [GraphQL::STRING_TYPE], + argument :iids, [GraphQL::Types::String], required: false, description: 'Array of IIDs of merge requests, for example `[1, 2]`.' - argument :source_branches, [GraphQL::STRING_TYPE], + argument :source_branches, [GraphQL::Types::String], required: false, as: :source_branch, description: <<~DESC @@ -39,7 +39,7 @@ module Resolvers All resolved merge requests will have one of these branches as their source. DESC - argument :target_branches, [GraphQL::STRING_TYPE], + argument :target_branches, [GraphQL::Types::String], required: false, as: :target_branch, description: <<~DESC @@ -51,7 +51,7 @@ module Resolvers required: false, description: 'A merge request state. If provided, all resolved merge requests will have this state.' - argument :labels, [GraphQL::STRING_TYPE], + argument :labels, [GraphQL::Types::String], required: false, as: :label_name, description: 'Array of label names. All resolved merge requests will have all of these labels.' @@ -61,7 +61,7 @@ module Resolvers argument :merged_before, Types::TimeType, required: false, description: 'Merge requests merged before this date.' - argument :milestone_title, GraphQL::STRING_TYPE, + argument :milestone_title, GraphQL::Types::String, required: false, description: 'Title of the milestone.' argument :sort, Types::MergeRequestSortEnum, @@ -70,11 +70,11 @@ module Resolvers default_value: :created_desc negated do - argument :labels, [GraphQL::STRING_TYPE], + argument :labels, [GraphQL::Types::String], required: false, as: :label_name, description: 'Array of label names. All resolved merge requests will not have these labels.' - argument :milestone_title, GraphQL::STRING_TYPE, + argument :milestone_title, GraphQL::Types::String, required: false, description: 'Title of the milestone.' end diff --git a/app/graphql/resolvers/metrics/dashboard_resolver.rb b/app/graphql/resolvers/metrics/dashboard_resolver.rb index 0669fececd5..d2be9fcdd89 100644 --- a/app/graphql/resolvers/metrics/dashboard_resolver.rb +++ b/app/graphql/resolvers/metrics/dashboard_resolver.rb @@ -6,7 +6,7 @@ module Resolvers type Types::Metrics::DashboardType, null: true calls_gitaly! - argument :path, GraphQL::STRING_TYPE, + argument :path, GraphQL::Types::String, required: true, description: <<~MD Path to a file which defines a metrics dashboard eg: `"config/prometheus/common_metrics.yml"`. diff --git a/app/graphql/resolvers/milestones_resolver.rb b/app/graphql/resolvers/milestones_resolver.rb index 4fa4c939a23..84f7d66ec19 100644 --- a/app/graphql/resolvers/milestones_resolver.rb +++ b/app/graphql/resolvers/milestones_resolver.rb @@ -5,7 +5,7 @@ module Resolvers include Gitlab::Graphql::Authorize::AuthorizeResource include TimeFrameArguments - argument :ids, [GraphQL::ID_TYPE], + argument :ids, [GraphQL::Types::ID], required: false, description: 'Array of global milestone IDs, e.g., `"gid://gitlab/Milestone/1"`.' @@ -13,11 +13,11 @@ module Resolvers required: false, description: 'Filter milestones by state.' - argument :title, GraphQL::STRING_TYPE, + argument :title, GraphQL::Types::String, required: false, description: 'The title of the milestone.' - argument :search_title, GraphQL::STRING_TYPE, + argument :search_title, GraphQL::Types::String, required: false, description: 'A search string for the title.' diff --git a/app/graphql/resolvers/namespace_projects_resolver.rb b/app/graphql/resolvers/namespace_projects_resolver.rb index 86286a744bd..c3c61d31e8d 100644 --- a/app/graphql/resolvers/namespace_projects_resolver.rb +++ b/app/graphql/resolvers/namespace_projects_resolver.rb @@ -2,12 +2,12 @@ module Resolvers class NamespaceProjectsResolver < BaseResolver - argument :include_subgroups, GraphQL::BOOLEAN_TYPE, + argument :include_subgroups, GraphQL::Types::Boolean, required: false, default_value: false, description: 'Include also subgroup projects.' - argument :search, GraphQL::STRING_TYPE, + argument :search, GraphQL::Types::String, required: false, default_value: nil, description: 'Search project with most similar names or paths.' @@ -17,7 +17,7 @@ module Resolvers default_value: nil, description: 'Sort projects by this criteria.' - argument :ids, [GraphQL::ID_TYPE], + argument :ids, [GraphQL::Types::ID], required: false, default_value: nil, description: 'Filter projects by IDs.' diff --git a/app/graphql/resolvers/packages_base_resolver.rb b/app/graphql/resolvers/packages_base_resolver.rb index 3378cc32c9f..7d153d16910 100644 --- a/app/graphql/resolvers/packages_base_resolver.rb +++ b/app/graphql/resolvers/packages_base_resolver.rb @@ -9,7 +9,7 @@ module Resolvers required: false, default_value: :created_desc - argument :package_name, GraphQL::STRING_TYPE, + argument :package_name, GraphQL::Types::String, description: 'Search a package by name.', required: false, default_value: nil @@ -24,7 +24,7 @@ module Resolvers required: false, default_value: nil - argument :include_versionless, GraphQL::BOOLEAN_TYPE, + argument :include_versionless, GraphQL::Types::Boolean, description: 'Include versionless packages.', required: false, default_value: false diff --git a/app/graphql/resolvers/paginated_tree_resolver.rb b/app/graphql/resolvers/paginated_tree_resolver.rb new file mode 100644 index 00000000000..d1b4e75169c --- /dev/null +++ b/app/graphql/resolvers/paginated_tree_resolver.rb @@ -0,0 +1,47 @@ +# frozen_string_literal: true + +module Resolvers + class PaginatedTreeResolver < BaseResolver + type Types::Tree::TreeType.connection_type, null: true + extension Gitlab::Graphql::Extensions::ExternallyPaginatedArrayExtension + + calls_gitaly! + + argument :path, GraphQL::Types::String, + required: false, + default_value: '', # root of the repository + description: 'The path to get the tree for. Default value is the root of the repository.' + argument :ref, GraphQL::Types::String, + required: false, + default_value: :head, + description: 'The commit ref to get the tree for. Default value is HEAD.' + argument :recursive, GraphQL::Types::Boolean, + required: false, + default_value: false, + description: 'Used to get a recursive tree. Default is false.' + + alias_method :repository, :object + + def resolve(**args) + return unless repository.exists? + + cursor = args.delete(:after) + + pagination_params = { + limit: @field.max_page_size || 100, + page_token: cursor + } + + tree = repository.tree(args[:ref], args[:path], recursive: args[:recursive], pagination_params: pagination_params) + + next_cursor = tree.cursor&.next_cursor + Gitlab::Graphql::ExternallyPaginatedArray.new(cursor, next_cursor, *tree) + rescue Gitlab::Git::CommandError => e + raise Gitlab::Graphql::Errors::ArgumentError, e + end + + def self.field_options + super.merge(connection: false) # we manage the pagination manually, so opt out of the connection field extension + end + end +end diff --git a/app/graphql/resolvers/project_milestones_resolver.rb b/app/graphql/resolvers/project_milestones_resolver.rb index 4cd9cb53f56..567a55aa09b 100644 --- a/app/graphql/resolvers/project_milestones_resolver.rb +++ b/app/graphql/resolvers/project_milestones_resolver.rb @@ -3,7 +3,7 @@ module Resolvers class ProjectMilestonesResolver < MilestonesResolver - argument :include_ancestors, GraphQL::BOOLEAN_TYPE, + argument :include_ancestors, GraphQL::Types::Boolean, required: false, description: "Also return milestones in the project's parent group and its ancestors." diff --git a/app/graphql/resolvers/project_pipeline_resolver.rb b/app/graphql/resolvers/project_pipeline_resolver.rb index aa8808b15ac..ce4b6ac6b0c 100644 --- a/app/graphql/resolvers/project_pipeline_resolver.rb +++ b/app/graphql/resolvers/project_pipeline_resolver.rb @@ -6,11 +6,11 @@ module Resolvers alias_method :project, :object - argument :iid, GraphQL::ID_TYPE, + argument :iid, GraphQL::Types::ID, required: false, description: 'IID of the Pipeline. For example, "1".' - argument :sha, GraphQL::STRING_TYPE, + argument :sha, GraphQL::Types::String, required: false, description: 'SHA of the Pipeline. For example, "dyd0f15ay83993f5ab66k927w28673882x99100b".' diff --git a/app/graphql/resolvers/projects/jira_projects_resolver.rb b/app/graphql/resolvers/projects/jira_projects_resolver.rb index 864acb6d759..56432585015 100644 --- a/app/graphql/resolvers/projects/jira_projects_resolver.rb +++ b/app/graphql/resolvers/projects/jira_projects_resolver.rb @@ -9,7 +9,7 @@ module Resolvers authorize :admin_project argument :name, - GraphQL::STRING_TYPE, + GraphQL::Types::String, required: false, description: 'Project name or key.' diff --git a/app/graphql/resolvers/projects/services_resolver.rb b/app/graphql/resolvers/projects/services_resolver.rb index 3674aa97e1f..99de4df945c 100644 --- a/app/graphql/resolvers/projects/services_resolver.rb +++ b/app/graphql/resolvers/projects/services_resolver.rb @@ -10,7 +10,7 @@ module Resolvers authorizes_object! argument :active, - GraphQL::BOOLEAN_TYPE, + GraphQL::Types::Boolean, required: false, description: 'Indicates if the integration is active.' argument :type, diff --git a/app/graphql/resolvers/projects_resolver.rb b/app/graphql/resolvers/projects_resolver.rb index 665ec796cd3..b846248458f 100644 --- a/app/graphql/resolvers/projects_resolver.rb +++ b/app/graphql/resolvers/projects_resolver.rb @@ -4,27 +4,27 @@ module Resolvers class ProjectsResolver < BaseResolver type Types::ProjectType, null: true - argument :membership, GraphQL::BOOLEAN_TYPE, + argument :membership, GraphQL::Types::Boolean, required: false, description: 'Limit projects that the current user is a member of.' - argument :search, GraphQL::STRING_TYPE, + argument :search, GraphQL::Types::String, required: false, description: 'Search query for project name, path, or description.' - argument :ids, [GraphQL::ID_TYPE], + argument :ids, [GraphQL::Types::ID], required: false, description: 'Filter projects by IDs.' - argument :search_namespaces, GraphQL::BOOLEAN_TYPE, + argument :search_namespaces, GraphQL::Types::Boolean, required: false, description: 'Include namespace in project search.' - argument :sort, GraphQL::STRING_TYPE, + argument :sort, GraphQL::Types::String, required: false, description: 'Sort order of results.' - argument :topics, type: [GraphQL::STRING_TYPE], + argument :topics, type: [GraphQL::Types::String], required: false, description: 'Filters projects by topics.' diff --git a/app/graphql/resolvers/release_resolver.rb b/app/graphql/resolvers/release_resolver.rb index 67ff5fed0bb..0374a1103de 100644 --- a/app/graphql/resolvers/release_resolver.rb +++ b/app/graphql/resolvers/release_resolver.rb @@ -4,7 +4,7 @@ module Resolvers class ReleaseResolver < BaseResolver type Types::ReleaseType, null: true - argument :tag_name, GraphQL::STRING_TYPE, + argument :tag_name, GraphQL::Types::String, required: true, description: 'The name of the tag associated to the release.' diff --git a/app/graphql/resolvers/repository_branch_names_resolver.rb b/app/graphql/resolvers/repository_branch_names_resolver.rb index c0a5ea0366f..e9aacda2652 100644 --- a/app/graphql/resolvers/repository_branch_names_resolver.rb +++ b/app/graphql/resolvers/repository_branch_names_resolver.rb @@ -2,19 +2,19 @@ module Resolvers class RepositoryBranchNamesResolver < BaseResolver - type ::GraphQL::STRING_TYPE, null: false + type ::GraphQL::Types::String, null: false calls_gitaly! - argument :search_pattern, GraphQL::STRING_TYPE, + argument :search_pattern, GraphQL::Types::String, required: true, description: 'The pattern to search for branch names by.' - argument :offset, GraphQL::INT_TYPE, + argument :offset, GraphQL::Types::Int, required: true, description: 'The number of branch names to skip.' - argument :limit, GraphQL::INT_TYPE, + argument :limit, GraphQL::Types::Int, required: true, description: 'The number of branch names to return.' diff --git a/app/graphql/resolvers/snippets/blobs_resolver.rb b/app/graphql/resolvers/snippets/blobs_resolver.rb index 4328d38d485..00f41517422 100644 --- a/app/graphql/resolvers/snippets/blobs_resolver.rb +++ b/app/graphql/resolvers/snippets/blobs_resolver.rb @@ -12,7 +12,7 @@ module Resolvers alias_method :snippet, :object - argument :paths, [GraphQL::STRING_TYPE], + argument :paths, [GraphQL::Types::String], required: false, description: 'Paths of the blobs.' diff --git a/app/graphql/resolvers/snippets_resolver.rb b/app/graphql/resolvers/snippets_resolver.rb index 7153c919062..7d18c9c6fea 100644 --- a/app/graphql/resolvers/snippets_resolver.rb +++ b/app/graphql/resolvers/snippets_resolver.rb @@ -3,6 +3,7 @@ module Resolvers class SnippetsResolver < BaseResolver + include ResolvesIds include ResolvesSnippets ERROR_MESSAGE = 'Filtering by both an author and a project is not supported' @@ -22,7 +23,7 @@ module Resolvers description: 'The type of snippet.' argument :explore, - GraphQL::BOOLEAN_TYPE, + GraphQL::Types::Boolean, required: false, description: 'Explore personal snippets.' diff --git a/app/graphql/resolvers/terraform/states_resolver.rb b/app/graphql/resolvers/terraform/states_resolver.rb index f543eb182e8..69785cfc794 100644 --- a/app/graphql/resolvers/terraform/states_resolver.rb +++ b/app/graphql/resolvers/terraform/states_resolver.rb @@ -8,7 +8,7 @@ module Resolvers alias_method :project, :object when_single do - argument :name, GraphQL::STRING_TYPE, + argument :name, GraphQL::Types::String, required: true, description: 'Name of the Terraform state.' end diff --git a/app/graphql/resolvers/timelog_resolver.rb b/app/graphql/resolvers/timelog_resolver.rb index 8ac30c4cb5d..14831a29d90 100644 --- a/app/graphql/resolvers/timelog_resolver.rb +++ b/app/graphql/resolvers/timelog_resolver.rb @@ -3,33 +3,50 @@ module Resolvers class TimelogResolver < BaseResolver include LooksAhead + include ResolvesIds type ::Types::TimelogType.connection_type, null: false argument :start_date, Types::TimeType, required: false, - description: 'List time logs within a date range where the logged date is equal to or after startDate.' + description: 'List timelogs within a date range where the logged date is equal to or after startDate.' argument :end_date, Types::TimeType, required: false, - description: 'List time logs within a date range where the logged date is equal to or before endDate.' + description: 'List timelogs within a date range where the logged date is equal to or before endDate.' argument :start_time, Types::TimeType, required: false, - description: 'List time-logs within a time range where the logged time is equal to or after startTime.' + description: 'List timelogs within a time range where the logged time is equal to or after startTime.' argument :end_time, Types::TimeType, required: false, - description: 'List time-logs within a time range where the logged time is equal to or before endTime.' + description: 'List timelogs within a time range where the logged time is equal to or before endTime.' + + argument :project_id, ::Types::GlobalIDType[::Project], + required: false, + description: 'List timelogs for a project.' + + argument :group_id, ::Types::GlobalIDType[::Group], + required: false, + description: 'List timelogs for a group.' + + argument :username, GraphQL::Types::String, + required: false, + description: 'List timelogs for a user.' def resolve_with_lookahead(**args) - build_timelogs + validate_args!(object, args) + + timelogs = object&.timelogs || Timelog.limit(GitlabSchema.default_max_page_size) if args.any? - validate_args!(args) - build_parsed_args(args) - validate_time_difference! - apply_time_filter + args = parse_datetime_args(args) + + timelogs = apply_user_filter(timelogs, args) + timelogs = apply_project_filter(timelogs, args) + timelogs = apply_time_filter(timelogs, args) + timelogs = apply_group_filter(timelogs, args) end apply_lookahead(timelogs) @@ -37,30 +54,32 @@ module Resolvers private - attr_reader :parsed_args, :timelogs - def preloads { note: [:note] } end - def validate_args!(args) - if args[:start_time] && args[:start_date] + def validate_args!(object, args) + if args.empty? && object.nil? + raise_argument_error('Provide at least one argument') + elsif args[:start_time] && args[:start_date] raise_argument_error('Provide either a start date or time, but not both') elsif args[:end_time] && args[:end_date] raise_argument_error('Provide either an end date or time, but not both') end end - def build_parsed_args(args) + def parse_datetime_args(args) if times_provided?(args) - @parsed_args = args + args else - @parsed_args = args.except(:start_date, :end_date) + parsed_args = args.except(:start_date, :end_date) - @parsed_args[:start_time] = args[:start_date].beginning_of_day if args[:start_date] - @parsed_args[:end_time] = args[:end_date].end_of_day if args[:end_date] + parsed_args[:start_time] = args[:start_date].beginning_of_day if args[:start_date] + parsed_args[:end_time] = args[:end_date].end_of_day if args[:end_date] + + parsed_args end end @@ -68,23 +87,51 @@ module Resolvers args[:start_time] && args[:end_time] end - def validate_time_difference! - return unless end_time_before_start_time? + def validate_time_difference!(args) + return unless end_time_before_start_time?(args) raise_argument_error('Start argument must be before End argument') end - def end_time_before_start_time? - times_provided?(parsed_args) && parsed_args[:end_time] < parsed_args[:start_time] + def end_time_before_start_time?(args) + times_provided?(args) && args[:end_time] < args[:start_time] end - def build_timelogs - @timelogs = Timelog.in_group(object) + def apply_project_filter(timelogs, args) + return timelogs unless args[:project_id] + + project = resolve_ids(args[:project_id], ::Types::GlobalIDType[::Project]) + timelogs.in_project(project) end - def apply_time_filter - @timelogs = timelogs.at_or_after(parsed_args[:start_time]) if parsed_args[:start_time] - @timelogs = timelogs.at_or_before(parsed_args[:end_time]) if parsed_args[:end_time] + def apply_group_filter(timelogs, args) + return timelogs unless args[:group_id] + + group = Group.find_by_id(resolve_ids(args[:group_id], ::Types::GlobalIDType[::Group])) + timelogs.in_group(group) + end + + def apply_user_filter(timelogs, args) + return timelogs unless args[:username] + + user = UserFinder.new(args[:username]).find_by_username! + timelogs.for_user(user) + end + + def apply_time_filter(timelogs, args) + return timelogs unless args[:start_time] || args[:end_time] + + validate_time_difference!(args) + + if args[:start_time] + timelogs = timelogs.at_or_after(args[:start_time]) + end + + if args[:end_time] + timelogs = timelogs.at_or_before(args[:end_time]) + end + + timelogs end def raise_argument_error(message) diff --git a/app/graphql/resolvers/todo_resolver.rb b/app/graphql/resolvers/todo_resolver.rb index af48ceefd6f..263b190c74e 100644 --- a/app/graphql/resolvers/todo_resolver.rb +++ b/app/graphql/resolvers/todo_resolver.rb @@ -10,15 +10,15 @@ module Resolvers required: false, description: 'The action to be filtered.' - argument :author_id, [GraphQL::ID_TYPE], + argument :author_id, [GraphQL::Types::ID], required: false, description: 'The ID of an author.' - argument :project_id, [GraphQL::ID_TYPE], + argument :project_id, [GraphQL::Types::ID], required: false, description: 'The ID of a project.' - argument :group_id, [GraphQL::ID_TYPE], + argument :group_id, [GraphQL::Types::ID], required: false, description: 'The ID of a group.' diff --git a/app/graphql/resolvers/tree_resolver.rb b/app/graphql/resolvers/tree_resolver.rb index c07d9187d4d..70b4d81845c 100644 --- a/app/graphql/resolvers/tree_resolver.rb +++ b/app/graphql/resolvers/tree_resolver.rb @@ -6,15 +6,15 @@ module Resolvers calls_gitaly! - argument :path, GraphQL::STRING_TYPE, + argument :path, GraphQL::Types::String, required: false, default_value: '', description: 'The path to get the tree for. Default value is the root of the repository.' - argument :ref, GraphQL::STRING_TYPE, + argument :ref, GraphQL::Types::String, required: false, default_value: :head, description: 'The commit ref to get the tree for. Default value is HEAD.' - argument :recursive, GraphQL::BOOLEAN_TYPE, + argument :recursive, GraphQL::Types::Boolean, required: false, default_value: false, description: 'Used to get a recursive tree. Default is false.' diff --git a/app/graphql/resolvers/user_discussions_count_resolver.rb b/app/graphql/resolvers/user_discussions_count_resolver.rb index 115997ec666..0a04e8df0b8 100644 --- a/app/graphql/resolvers/user_discussions_count_resolver.rb +++ b/app/graphql/resolvers/user_discussions_count_resolver.rb @@ -4,7 +4,7 @@ module Resolvers class UserDiscussionsCountResolver < BaseResolver include Gitlab::Graphql::Authorize::AuthorizeResource - type GraphQL::INT_TYPE, null: true + type GraphQL::Types::Int, null: true def resolve authorize!(object) diff --git a/app/graphql/resolvers/user_merge_requests_resolver_base.rb b/app/graphql/resolvers/user_merge_requests_resolver_base.rb index 221a43f691d..e0201e45664 100644 --- a/app/graphql/resolvers/user_merge_requests_resolver_base.rb +++ b/app/graphql/resolvers/user_merge_requests_resolver_base.rb @@ -5,7 +5,7 @@ module Resolvers include ResolvesProject argument :project_path, - type: GraphQL::STRING_TYPE, + type: GraphQL::Types::String, required: false, description: <<~DESC The full-path of the project the authored merge requests should be in. diff --git a/app/graphql/resolvers/user_notes_count_resolver.rb b/app/graphql/resolvers/user_notes_count_resolver.rb index 2cb61104c18..b91815c72f5 100644 --- a/app/graphql/resolvers/user_notes_count_resolver.rb +++ b/app/graphql/resolvers/user_notes_count_resolver.rb @@ -4,7 +4,7 @@ module Resolvers class UserNotesCountResolver < BaseResolver include Gitlab::Graphql::Authorize::AuthorizeResource - type GraphQL::INT_TYPE, null: true + type GraphQL::Types::Int, null: true def resolve authorize!(object) diff --git a/app/graphql/resolvers/user_resolver.rb b/app/graphql/resolvers/user_resolver.rb index 84bc03091d9..99fd0d4927d 100644 --- a/app/graphql/resolvers/user_resolver.rb +++ b/app/graphql/resolvers/user_resolver.rb @@ -10,7 +10,7 @@ module Resolvers required: false, description: 'ID of the User.' - argument :username, GraphQL::STRING_TYPE, + argument :username, GraphQL::Types::String, required: false, description: 'Username of the User.' diff --git a/app/graphql/resolvers/user_starred_projects_resolver.rb b/app/graphql/resolvers/user_starred_projects_resolver.rb index a8abe759f27..07c6611e41d 100644 --- a/app/graphql/resolvers/user_starred_projects_resolver.rb +++ b/app/graphql/resolvers/user_starred_projects_resolver.rb @@ -4,7 +4,7 @@ module Resolvers class UserStarredProjectsResolver < BaseResolver type Types::ProjectType.connection_type, null: true - argument :search, GraphQL::STRING_TYPE, + argument :search, GraphQL::Types::String, required: false, description: 'Search query.' diff --git a/app/graphql/resolvers/users/group_count_resolver.rb b/app/graphql/resolvers/users/group_count_resolver.rb index ebfe594d31d..592436ac546 100644 --- a/app/graphql/resolvers/users/group_count_resolver.rb +++ b/app/graphql/resolvers/users/group_count_resolver.rb @@ -3,7 +3,7 @@ module Resolvers module Users class GroupCountResolver < BaseResolver - type GraphQL::INT_TYPE, null: true + type GraphQL::Types::Int, null: true alias_method :user, :object diff --git a/app/graphql/resolvers/users_resolver.rb b/app/graphql/resolvers/users_resolver.rb index 95ced131504..c6de3dba41a 100644 --- a/app/graphql/resolvers/users_resolver.rb +++ b/app/graphql/resolvers/users_resolver.rb @@ -7,11 +7,11 @@ module Resolvers type Types::UserType.connection_type, null: true description 'Find Users' - argument :ids, [GraphQL::ID_TYPE], + argument :ids, [GraphQL::Types::ID], required: false, description: 'List of user Global IDs.' - argument :usernames, [GraphQL::STRING_TYPE], required: false, + argument :usernames, [GraphQL::Types::String], required: false, description: 'List of usernames.' argument :sort, Types::SortEnum, @@ -19,11 +19,11 @@ module Resolvers required: false, default_value: :created_desc - argument :search, GraphQL::STRING_TYPE, + argument :search, GraphQL::Types::String, required: false, description: "Query to search users by name, username, or primary email." - argument :admins, GraphQL::BOOLEAN_TYPE, + argument :admins, GraphQL::Types::Boolean, required: false, default_value: false, description: 'Return only admin users.' diff --git a/app/graphql/types/access_level_type.rb b/app/graphql/types/access_level_type.rb index 21c3669979c..2d97f6b30e8 100644 --- a/app/graphql/types/access_level_type.rb +++ b/app/graphql/types/access_level_type.rb @@ -6,7 +6,7 @@ module Types graphql_name 'AccessLevel' description 'Represents the access level of a relationship between a User and object that it is related to' - field :integer_value, GraphQL::INT_TYPE, null: true, + field :integer_value, GraphQL::Types::Int, null: true, description: 'Integer representation of access level.', method: :to_i diff --git a/app/graphql/types/admin/analytics/usage_trends/measurement_type.rb b/app/graphql/types/admin/analytics/usage_trends/measurement_type.rb index c8ca702706f..c54c938402d 100644 --- a/app/graphql/types/admin/analytics/usage_trends/measurement_type.rb +++ b/app/graphql/types/admin/analytics/usage_trends/measurement_type.rb @@ -14,7 +14,7 @@ module Types field :recorded_at, Types::TimeType, null: true, description: 'The time the measurement was recorded.' - field :count, GraphQL::INT_TYPE, null: false, + field :count, GraphQL::Types::Int, null: false, description: 'Object count.' field :identifier, Types::Admin::Analytics::UsageTrends::MeasurementIdentifierEnum, null: false, diff --git a/app/graphql/types/admin/sidekiq_queues/delete_jobs_response_type.rb b/app/graphql/types/admin/sidekiq_queues/delete_jobs_response_type.rb index 996300edad3..cc6e3db007b 100644 --- a/app/graphql/types/admin/sidekiq_queues/delete_jobs_response_type.rb +++ b/app/graphql/types/admin/sidekiq_queues/delete_jobs_response_type.rb @@ -10,17 +10,17 @@ module Types description 'The response from the AdminSidekiqQueuesDeleteJobs mutation' field :completed, - GraphQL::BOOLEAN_TYPE, + GraphQL::Types::Boolean, null: true, description: 'Whether or not the entire queue was processed in time; if not, retrying the same request is safe.' field :deleted_jobs, - GraphQL::INT_TYPE, + GraphQL::Types::Int, null: true, description: 'The number of matching jobs deleted.' field :queue_size, - GraphQL::INT_TYPE, + GraphQL::Types::Int, null: true, description: 'The queue size after processing.' end diff --git a/app/graphql/types/alert_management/alert_status_counts_type.rb b/app/graphql/types/alert_management/alert_status_counts_type.rb index 14a81735fa5..c4aedb09997 100644 --- a/app/graphql/types/alert_management/alert_status_counts_type.rb +++ b/app/graphql/types/alert_management/alert_status_counts_type.rb @@ -11,18 +11,18 @@ module Types ::AlertManagement::Alert.status_names.each do |status| field status, - GraphQL::INT_TYPE, + GraphQL::Types::Int, null: true, description: "Number of alerts with status #{status.to_s.upcase} for the project" end field :open, - GraphQL::INT_TYPE, + GraphQL::Types::Int, null: true, description: 'Number of alerts with status TRIGGERED or ACKNOWLEDGED for the project.' field :all, - GraphQL::INT_TYPE, + GraphQL::Types::Int, null: true, description: 'Total number of alerts for the project.' end diff --git a/app/graphql/types/alert_management/alert_type.rb b/app/graphql/types/alert_management/alert_type.rb index eb0d999554f..bdfdd2c5886 100644 --- a/app/graphql/types/alert_management/alert_type.rb +++ b/app/graphql/types/alert_management/alert_type.rb @@ -13,12 +13,12 @@ module Types authorize :read_alert_management_alert field :iid, - GraphQL::ID_TYPE, + GraphQL::Types::ID, null: false, description: 'Internal ID of the alert.' field :issue_iid, - GraphQL::ID_TYPE, + GraphQL::Types::ID, null: true, deprecated: { reason: 'Use issue field', milestone: '13.10' }, description: 'Internal ID of the GitLab issue attached to the alert.' @@ -29,12 +29,12 @@ module Types description: 'Issue attached to the alert.' field :title, - GraphQL::STRING_TYPE, + GraphQL::Types::String, null: true, description: 'Title of the alert.' field :description, - GraphQL::STRING_TYPE, + GraphQL::Types::String, null: true, description: 'Description of the alert.' @@ -50,17 +50,17 @@ module Types method: :status_name field :service, - GraphQL::STRING_TYPE, + GraphQL::Types::String, null: true, description: 'Service the alert came from.' field :monitoring_tool, - GraphQL::STRING_TYPE, + GraphQL::Types::String, null: true, description: 'Monitoring tool the alert came from.' field :hosts, - [GraphQL::STRING_TYPE], + [GraphQL::Types::String], null: true, description: 'List of hosts the alert came from.' @@ -80,7 +80,7 @@ module Types description: 'Environment for the alert.' field :event_count, - GraphQL::INT_TYPE, + GraphQL::Types::Int, null: true, description: 'Number of events of this alert.', method: :events @@ -106,12 +106,12 @@ module Types description: 'Assignees of the alert.' field :metrics_dashboard_url, - GraphQL::STRING_TYPE, + GraphQL::Types::String, null: true, description: 'URL for metrics embed for the alert.' field :runbook, - GraphQL::STRING_TYPE, + GraphQL::Types::String, null: true, description: 'Runbook for the alert as defined in alert details.' @@ -120,7 +120,7 @@ module Types end field :details_url, - GraphQL::STRING_TYPE, + GraphQL::Types::String, null: false, description: 'The URL of the alert detail page.' diff --git a/app/graphql/types/alert_management/integration_type.rb b/app/graphql/types/alert_management/integration_type.rb index 6cbc17cdbfb..ca7ec99a480 100644 --- a/app/graphql/types/alert_management/integration_type.rb +++ b/app/graphql/types/alert_management/integration_type.rb @@ -7,7 +7,7 @@ module Types graphql_name 'AlertManagementIntegration' field :id, - GraphQL::ID_TYPE, + GraphQL::Types::ID, null: false, description: 'ID of the integration.' @@ -17,27 +17,27 @@ module Types description: 'Type of integration.' field :name, - GraphQL::STRING_TYPE, + GraphQL::Types::String, null: true, description: 'Name of the integration.' field :active, - GraphQL::BOOLEAN_TYPE, + GraphQL::Types::Boolean, null: true, description: 'Whether the endpoint is currently accepting alerts.' field :token, - GraphQL::STRING_TYPE, + GraphQL::Types::String, null: true, description: 'Token used to authenticate alert notification requests.' field :url, - GraphQL::STRING_TYPE, + GraphQL::Types::String, null: true, description: 'Endpoint which accepts alert notifications.' field :api_url, - GraphQL::STRING_TYPE, + GraphQL::Types::String, null: true, description: 'URL at which Prometheus metrics can be queried to populate the metrics dashboard.' diff --git a/app/graphql/types/award_emojis/award_emoji_type.rb b/app/graphql/types/award_emojis/award_emoji_type.rb index 9409304e28f..1f6f0badcac 100644 --- a/app/graphql/types/award_emojis/award_emoji_type.rb +++ b/app/graphql/types/award_emojis/award_emoji_type.rb @@ -11,27 +11,27 @@ module Types present_using AwardEmojiPresenter field :name, - GraphQL::STRING_TYPE, + GraphQL::Types::String, null: false, description: 'The emoji name.' field :description, - GraphQL::STRING_TYPE, + GraphQL::Types::String, null: false, description: 'The emoji description.' field :unicode, - GraphQL::STRING_TYPE, + GraphQL::Types::String, null: false, description: 'The emoji in Unicode.' field :emoji, - GraphQL::STRING_TYPE, + GraphQL::Types::String, null: false, description: 'The emoji as an icon.' field :unicode_version, - GraphQL::STRING_TYPE, + GraphQL::Types::String, null: false, description: 'The Unicode version for this emoji.' diff --git a/app/graphql/types/base_argument.rb b/app/graphql/types/base_argument.rb index 536a32f2bdd..2c899e9edaa 100644 --- a/app/graphql/types/base_argument.rb +++ b/app/graphql/types/base_argument.rb @@ -10,7 +10,29 @@ module Types @deprecation = gitlab_deprecation(kwargs) @doc_reference = kwargs.delete(:see) + # our custom addition `nullable` which allows us to declare + # an argument that must be provided, even if its value is null. + # When `required: true` then required arguments must not be null. + @gl_required = !!kwargs[:required] + @gl_nullable = kwargs[:required] == :nullable + + # Only valid if an argument is also required. + if @gl_nullable + # Since the framework asserts that "required" means "cannot be null" + # we have to switch off "required" but still do the check in `ready?` behind the scenes + kwargs[:required] = false + end + super(*args, **kwargs, &block) end + + def accepts?(value) + # if the argument is declared as required, it must be included + return false if @gl_required && value == :not_given + # if the argument is declared as required, the value can only be null IF it is also nullable. + return false if @gl_required && value.nil? && !@gl_nullable + + true + end end end diff --git a/app/graphql/types/blob_viewer_type.rb b/app/graphql/types/blob_viewer_type.rb index 8d863c32bc7..8c565373cfd 100644 --- a/app/graphql/types/blob_viewer_type.rb +++ b/app/graphql/types/blob_viewer_type.rb @@ -9,30 +9,30 @@ module Types description: 'Type of blob viewer.', null: false - field :load_async, GraphQL::BOOLEAN_TYPE, + field :load_async, GraphQL::Types::Boolean, description: 'Shows whether the blob content is loaded asynchronously.', null: false - field :collapsed, GraphQL::BOOLEAN_TYPE, + field :collapsed, GraphQL::Types::Boolean, description: 'Shows whether the blob should be displayed collapsed.', method: :collapsed?, null: false - field :too_large, GraphQL::BOOLEAN_TYPE, + field :too_large, GraphQL::Types::Boolean, description: 'Shows whether the blob is too large to be displayed.', method: :too_large?, null: false - field :render_error, GraphQL::STRING_TYPE, + field :render_error, GraphQL::Types::String, description: 'Error rendering the blob content.', null: true - field :file_type, GraphQL::STRING_TYPE, + field :file_type, GraphQL::Types::String, description: 'Content file type.', method: :partial_name, null: false - field :loading_partial_name, GraphQL::STRING_TYPE, + field :loading_partial_name, GraphQL::Types::String, description: 'Loading partial name.', null: false diff --git a/app/graphql/types/board_list_type.rb b/app/graphql/types/board_list_type.rb index dc10716dcb0..762e03973d9 100644 --- a/app/graphql/types/board_list_type.rb +++ b/app/graphql/types/board_list_type.rb @@ -10,19 +10,19 @@ module Types alias_method :list, :object - field :id, GraphQL::ID_TYPE, null: false, + field :id, GraphQL::Types::ID, null: false, description: 'ID (global ID) of the list.' - field :title, GraphQL::STRING_TYPE, null: false, + field :title, GraphQL::Types::String, null: false, description: 'Title of the list.' - field :list_type, GraphQL::STRING_TYPE, null: false, + field :list_type, GraphQL::Types::String, null: false, description: 'Type of the list.' - field :position, GraphQL::INT_TYPE, null: true, + field :position, GraphQL::Types::Int, null: true, description: 'Position of list within the board.' field :label, Types::LabelType, null: true, description: 'Label of the list.' - field :collapsed, GraphQL::BOOLEAN_TYPE, null: true, + field :collapsed, GraphQL::Types::Boolean, null: true, description: 'Indicates if the list is collapsed for this user.' - field :issues_count, GraphQL::INT_TYPE, null: true, + field :issues_count, GraphQL::Types::Int, null: true, description: 'Count of issues in the list.' field :issues, ::Types::IssueType.connection_type, null: true, diff --git a/app/graphql/types/board_type.rb b/app/graphql/types/board_type.rb index 292809b0d64..4ec9a8a9c63 100644 --- a/app/graphql/types/board_type.rb +++ b/app/graphql/types/board_type.rb @@ -9,15 +9,15 @@ module Types present_using BoardPresenter - field :id, type: GraphQL::ID_TYPE, null: false, + field :id, type: GraphQL::Types::ID, null: false, description: 'ID (global ID) of the board.' - field :name, type: GraphQL::STRING_TYPE, null: true, + field :name, type: GraphQL::Types::String, null: true, description: 'Name of the board.' - field :hide_backlog_list, type: GraphQL::BOOLEAN_TYPE, null: true, + field :hide_backlog_list, type: GraphQL::Types::Boolean, null: true, description: 'Whether or not backlog list is hidden.' - field :hide_closed_list, type: GraphQL::BOOLEAN_TYPE, null: true, + field :hide_closed_list, type: GraphQL::Types::Boolean, null: true, description: 'Whether or not closed list is hidden.' field :created_at, Types::TimeType, null: false, @@ -33,10 +33,10 @@ module Types resolver: Resolvers::BoardListsResolver, extras: [:lookahead] - field :web_path, GraphQL::STRING_TYPE, null: false, + field :web_path, GraphQL::Types::String, null: false, description: 'Web path of the board.' - field :web_url, GraphQL::STRING_TYPE, null: false, + field :web_url, GraphQL::Types::String, null: false, description: 'Web URL of the board.' end end diff --git a/app/graphql/types/boards/board_issuable_input_base_type.rb b/app/graphql/types/boards/board_issuable_input_base_type.rb index 2cd057347d6..326f73846d0 100644 --- a/app/graphql/types/boards/board_issuable_input_base_type.rb +++ b/app/graphql/types/boards/board_issuable_input_base_type.rb @@ -4,15 +4,15 @@ module Types module Boards # Common arguments that we can be used to filter boards epics and issues class BoardIssuableInputBaseType < BaseInputObject - argument :label_name, [GraphQL::STRING_TYPE, null: true], + argument :label_name, [GraphQL::Types::String, null: true], required: false, description: 'Filter by label name.' - argument :author_username, GraphQL::STRING_TYPE, + argument :author_username, GraphQL::Types::String, required: false, description: 'Filter by author username.' - argument :my_reaction_emoji, GraphQL::STRING_TYPE, + argument :my_reaction_emoji, GraphQL::Types::String, required: false, description: 'Filter by reaction emoji applied by the current user.' end diff --git a/app/graphql/types/boards/board_issue_input_base_type.rb b/app/graphql/types/boards/board_issue_input_base_type.rb index 30f4efcd403..82db1802b81 100644 --- a/app/graphql/types/boards/board_issue_input_base_type.rb +++ b/app/graphql/types/boards/board_issue_input_base_type.rb @@ -4,21 +4,26 @@ module Types module Boards # rubocop: disable Graphql/AuthorizeTypes class BoardIssueInputBaseType < BoardIssuableInputBaseType - argument :iids, [GraphQL::STRING_TYPE], + argument :iids, [GraphQL::Types::String], required: false, description: 'List of IIDs of issues. For example `["1", "2"]`.' - argument :milestone_title, GraphQL::STRING_TYPE, + argument :milestone_title, GraphQL::Types::String, required: false, description: 'Filter by milestone title.' - argument :assignee_username, [GraphQL::STRING_TYPE, null: true], + argument :assignee_username, [GraphQL::Types::String, null: true], required: false, description: 'Filter by assignee username.' - argument :release_tag, GraphQL::STRING_TYPE, + argument :release_tag, GraphQL::Types::String, required: false, description: 'Filter by release tag.' + + argument :types, [Types::IssueTypeEnum], + as: :issue_types, + description: 'Filter by the given issue types.', + required: false end end end diff --git a/app/graphql/types/boards/board_issue_input_type.rb b/app/graphql/types/boards/board_issue_input_type.rb index 7580b0378fe..b4dbe87e32d 100644 --- a/app/graphql/types/boards/board_issue_input_type.rb +++ b/app/graphql/types/boards/board_issue_input_type.rb @@ -10,7 +10,7 @@ module Types prepare: ->(negated_args, ctx) { negated_args.to_h }, description: 'List of negated arguments.' - argument :search, GraphQL::STRING_TYPE, + argument :search, GraphQL::Types::String, required: false, description: 'Search query for issue title or description.' diff --git a/app/graphql/types/branch_type.rb b/app/graphql/types/branch_type.rb index b788ba79769..a861bcc4bb4 100644 --- a/app/graphql/types/branch_type.rb +++ b/app/graphql/types/branch_type.rb @@ -6,7 +6,7 @@ module Types graphql_name 'Branch' field :name, - GraphQL::STRING_TYPE, + GraphQL::Types::String, null: false, description: 'Name of the branch.' diff --git a/app/graphql/types/ci/analytics_type.rb b/app/graphql/types/ci/analytics_type.rb index ba987b133bd..f52b9eae229 100644 --- a/app/graphql/types/ci/analytics_type.rb +++ b/app/graphql/types/ci/analytics_type.rb @@ -6,27 +6,27 @@ module Types class AnalyticsType < BaseObject graphql_name 'PipelineAnalytics' - field :week_pipelines_totals, [GraphQL::INT_TYPE], null: true, + field :week_pipelines_totals, [GraphQL::Types::Int], null: true, description: 'Total weekly pipeline count.' - field :week_pipelines_successful, [GraphQL::INT_TYPE], null: true, + field :week_pipelines_successful, [GraphQL::Types::Int], null: true, description: 'Total weekly successful pipeline count.' - field :week_pipelines_labels, [GraphQL::STRING_TYPE], null: true, + field :week_pipelines_labels, [GraphQL::Types::String], null: true, description: 'Labels for the weekly pipeline count.' - field :month_pipelines_totals, [GraphQL::INT_TYPE], null: true, + field :month_pipelines_totals, [GraphQL::Types::Int], null: true, description: 'Total monthly pipeline count.' - field :month_pipelines_successful, [GraphQL::INT_TYPE], null: true, + field :month_pipelines_successful, [GraphQL::Types::Int], null: true, description: 'Total monthly successful pipeline count.' - field :month_pipelines_labels, [GraphQL::STRING_TYPE], null: true, + field :month_pipelines_labels, [GraphQL::Types::String], null: true, description: 'Labels for the monthly pipeline count.' - field :year_pipelines_totals, [GraphQL::INT_TYPE], null: true, + field :year_pipelines_totals, [GraphQL::Types::Int], null: true, description: 'Total yearly pipeline count.' - field :year_pipelines_successful, [GraphQL::INT_TYPE], null: true, + field :year_pipelines_successful, [GraphQL::Types::Int], null: true, description: 'Total yearly successful pipeline count.' - field :year_pipelines_labels, [GraphQL::STRING_TYPE], null: true, + field :year_pipelines_labels, [GraphQL::Types::String], null: true, description: 'Labels for the yearly pipeline count.' - field :pipeline_times_values, [GraphQL::INT_TYPE], null: true, + field :pipeline_times_values, [GraphQL::Types::Int], null: true, description: 'Pipeline times.' - field :pipeline_times_labels, [GraphQL::STRING_TYPE], null: true, + field :pipeline_times_labels, [GraphQL::Types::String], null: true, description: 'Pipeline times labels.' end end diff --git a/app/graphql/types/ci/application_setting_type.rb b/app/graphql/types/ci/application_setting_type.rb index 8616280057c..2322778d159 100644 --- a/app/graphql/types/ci/application_setting_type.rb +++ b/app/graphql/types/ci/application_setting_type.rb @@ -7,7 +7,7 @@ module Types authorize :read_application_setting - field :keep_latest_artifact, GraphQL::BOOLEAN_TYPE, null: true, + field :keep_latest_artifact, GraphQL::Types::Boolean, null: true, description: 'Whether to keep the latest jobs artifacts.' end end diff --git a/app/graphql/types/ci/build_need_type.rb b/app/graphql/types/ci/build_need_type.rb index 19ff758ad1d..7bd12c99a08 100644 --- a/app/graphql/types/ci/build_need_type.rb +++ b/app/graphql/types/ci/build_need_type.rb @@ -7,9 +7,9 @@ module Types class BuildNeedType < BaseObject graphql_name 'CiBuildNeed' - field :id, GraphQL::ID_TYPE, null: false, + field :id, GraphQL::Types::ID, null: false, description: 'ID of the job we need to complete.' - field :name, GraphQL::STRING_TYPE, null: true, + field :name, GraphQL::Types::String, null: true, description: 'Name of the job we need to complete.' end end diff --git a/app/graphql/types/ci/ci_cd_setting_type.rb b/app/graphql/types/ci/ci_cd_setting_type.rb index f90c75454ba..790deab8f68 100644 --- a/app/graphql/types/ci/ci_cd_setting_type.rb +++ b/app/graphql/types/ci/ci_cd_setting_type.rb @@ -7,16 +7,16 @@ module Types authorize :admin_project - field :merge_pipelines_enabled, GraphQL::BOOLEAN_TYPE, null: true, + field :merge_pipelines_enabled, GraphQL::Types::Boolean, null: true, description: 'Whether merge pipelines are enabled.', method: :merge_pipelines_enabled? - field :merge_trains_enabled, GraphQL::BOOLEAN_TYPE, null: true, + field :merge_trains_enabled, GraphQL::Types::Boolean, null: true, description: 'Whether merge trains are enabled.', method: :merge_trains_enabled? - field :keep_latest_artifact, GraphQL::BOOLEAN_TYPE, null: true, + field :keep_latest_artifact, GraphQL::Types::Boolean, null: true, description: 'Whether to keep the latest builds artifacts.', method: :keep_latest_artifacts_available? - field :job_token_scope_enabled, GraphQL::BOOLEAN_TYPE, null: true, + field :job_token_scope_enabled, GraphQL::Types::Boolean, null: true, description: 'Indicates CI job tokens generated in this project have restricted access to resources.', method: :job_token_scope_enabled? field :project, Types::ProjectType, null: true, diff --git a/app/graphql/types/ci/config/config_type.rb b/app/graphql/types/ci/config/config_type.rb index 88caf21c376..6ac21968bd4 100644 --- a/app/graphql/types/ci/config/config_type.rb +++ b/app/graphql/types/ci/config/config_type.rb @@ -7,9 +7,9 @@ module Types class ConfigType < BaseObject graphql_name 'CiConfig' - field :errors, [GraphQL::STRING_TYPE], null: true, + field :errors, [GraphQL::Types::String], null: true, description: 'Linting errors.' - field :merged_yaml, GraphQL::STRING_TYPE, null: true, + field :merged_yaml, GraphQL::Types::String, null: true, description: 'Merged CI configuration YAML.' field :stages, Types::Ci::Config::StageType.connection_type, null: true, description: 'Stages of the pipeline.' diff --git a/app/graphql/types/ci/config/group_type.rb b/app/graphql/types/ci/config/group_type.rb index 11be701e73f..e5cb0d4e72f 100644 --- a/app/graphql/types/ci/config/group_type.rb +++ b/app/graphql/types/ci/config/group_type.rb @@ -7,11 +7,11 @@ module Types class GroupType < BaseObject graphql_name 'CiConfigGroup' - field :name, GraphQL::STRING_TYPE, null: true, + field :name, GraphQL::Types::String, null: true, description: 'Name of the job group.' field :jobs, Types::Ci::Config::JobType.connection_type, null: true, description: 'Jobs in group.' - field :size, GraphQL::INT_TYPE, null: true, + field :size, GraphQL::Types::Int, null: true, description: 'Size of the job group.' end end diff --git a/app/graphql/types/ci/config/job_restriction_type.rb b/app/graphql/types/ci/config/job_restriction_type.rb index 294e3c94571..891ba18dacc 100644 --- a/app/graphql/types/ci/config/job_restriction_type.rb +++ b/app/graphql/types/ci/config/job_restriction_type.rb @@ -7,7 +7,7 @@ module Types class JobRestrictionType < BaseObject graphql_name 'CiConfigJobRestriction' - field :refs, [GraphQL::STRING_TYPE], null: true, + field :refs, [GraphQL::Types::String], null: true, description: 'The Git refs the job restriction applies to.' end end diff --git a/app/graphql/types/ci/config/job_type.rb b/app/graphql/types/ci/config/job_type.rb index 65fdc4c2615..4cf6780ef60 100644 --- a/app/graphql/types/ci/config/job_type.rb +++ b/app/graphql/types/ci/config/job_type.rb @@ -7,32 +7,32 @@ module Types class JobType < BaseObject graphql_name 'CiConfigJob' - field :name, GraphQL::STRING_TYPE, null: true, + field :name, GraphQL::Types::String, null: true, description: 'Name of the job.' - field :group_name, GraphQL::STRING_TYPE, null: true, + field :group_name, GraphQL::Types::String, null: true, description: 'Name of the job group.' - field :stage, GraphQL::STRING_TYPE, null: true, + field :stage, GraphQL::Types::String, null: true, description: 'Name of the job stage.' field :needs, Types::Ci::Config::NeedType.connection_type, null: true, description: 'Builds that must complete before the jobs run.' - field :allow_failure, GraphQL::BOOLEAN_TYPE, null: true, + field :allow_failure, GraphQL::Types::Boolean, null: true, description: 'Allow job to fail.' - field :before_script, [GraphQL::STRING_TYPE], null: true, + field :before_script, [GraphQL::Types::String], null: true, description: 'Override a set of commands that are executed before the job.' - field :script, [GraphQL::STRING_TYPE], null: true, + field :script, [GraphQL::Types::String], null: true, description: 'Shell script that is executed by a runner.' - field :after_script, [GraphQL::STRING_TYPE], null: true, + field :after_script, [GraphQL::Types::String], null: true, description: 'Override a set of commands that are executed after the job.' - field :when, GraphQL::STRING_TYPE, null: true, + field :when, GraphQL::Types::String, null: true, description: 'When to run the job.', resolver_method: :restrict_when_to_run_jobs - field :environment, GraphQL::STRING_TYPE, null: true, + field :environment, GraphQL::Types::String, null: true, description: 'Name of an environment to which the job deploys.' field :except, Types::Ci::Config::JobRestrictionType, null: true, description: 'Limit when jobs are not created.' field :only, Types::Ci::Config::JobRestrictionType, null: true, description: 'Jobs are created when these conditions do not apply.' - field :tags, [GraphQL::STRING_TYPE], null: true, + field :tags, [GraphQL::Types::String], null: true, description: 'List of tags that are used to select a runner.' def restrict_when_to_run_jobs diff --git a/app/graphql/types/ci/config/need_type.rb b/app/graphql/types/ci/config/need_type.rb index 01f73100409..6e9aea8eb64 100644 --- a/app/graphql/types/ci/config/need_type.rb +++ b/app/graphql/types/ci/config/need_type.rb @@ -7,7 +7,7 @@ module Types class NeedType < BaseObject graphql_name 'CiConfigNeed' - field :name, GraphQL::STRING_TYPE, null: true, + field :name, GraphQL::Types::String, null: true, description: 'Name of the need.' end end diff --git a/app/graphql/types/ci/config/stage_type.rb b/app/graphql/types/ci/config/stage_type.rb index 060efb7d45c..7e2aa9470f2 100644 --- a/app/graphql/types/ci/config/stage_type.rb +++ b/app/graphql/types/ci/config/stage_type.rb @@ -7,7 +7,7 @@ module Types class StageType < BaseObject graphql_name 'CiConfigStage' - field :name, GraphQL::STRING_TYPE, null: true, + field :name, GraphQL::Types::String, null: true, description: 'Name of the stage.' field :groups, Types::Ci::Config::GroupType.connection_type, null: true, description: 'Groups of jobs for the stage.' diff --git a/app/graphql/types/ci/detailed_status_type.rb b/app/graphql/types/ci/detailed_status_type.rb index 6310a62a103..4433e921971 100644 --- a/app/graphql/types/ci/detailed_status_type.rb +++ b/app/graphql/types/ci/detailed_status_type.rb @@ -6,26 +6,26 @@ module Types class DetailedStatusType < BaseObject graphql_name 'DetailedStatus' - field :id, GraphQL::STRING_TYPE, null: false, + field :id, GraphQL::Types::String, null: false, description: 'ID for a detailed status.', extras: [:parent] - field :group, GraphQL::STRING_TYPE, null: true, + field :group, GraphQL::Types::String, null: true, description: 'Group of the status.' - field :icon, GraphQL::STRING_TYPE, null: true, + field :icon, GraphQL::Types::String, null: true, description: 'Icon of the status.' - field :favicon, GraphQL::STRING_TYPE, null: true, + field :favicon, GraphQL::Types::String, null: true, description: 'Favicon of the status.' - field :details_path, GraphQL::STRING_TYPE, null: true, + field :details_path, GraphQL::Types::String, null: true, description: 'Path of the details for the status.' - field :has_details, GraphQL::BOOLEAN_TYPE, null: true, + field :has_details, GraphQL::Types::Boolean, null: true, description: 'Indicates if the status has further details.', method: :has_details? - field :label, GraphQL::STRING_TYPE, null: true, + field :label, GraphQL::Types::String, null: true, calls_gitaly: true, description: 'Label of the status.' - field :text, GraphQL::STRING_TYPE, null: true, + field :text, GraphQL::Types::String, null: true, description: 'Text of the status.' - field :tooltip, GraphQL::STRING_TYPE, null: true, + field :tooltip, GraphQL::Types::String, null: true, description: 'Tooltip associated with the status.', method: :status_tooltip field :action, Types::Ci::StatusActionType, null: true, diff --git a/app/graphql/types/ci/group_type.rb b/app/graphql/types/ci/group_type.rb index 3da183cb842..3ae23ba9bd4 100644 --- a/app/graphql/types/ci/group_type.rb +++ b/app/graphql/types/ci/group_type.rb @@ -6,11 +6,11 @@ module Types class GroupType < BaseObject graphql_name 'CiGroup' - field :id, GraphQL::STRING_TYPE, null: false, + field :id, GraphQL::Types::String, null: false, description: 'ID for a group.' - field :name, GraphQL::STRING_TYPE, null: true, + field :name, GraphQL::Types::String, null: true, description: 'Name of the job group.' - field :size, GraphQL::INT_TYPE, null: true, + field :size, GraphQL::Types::Int, null: true, description: 'Size of the group.' field :jobs, Ci::JobType.connection_type, null: true, description: 'Jobs in group.' diff --git a/app/graphql/types/ci/job_artifact_type.rb b/app/graphql/types/ci/job_artifact_type.rb index 7dc93041b53..f80681bcf36 100644 --- a/app/graphql/types/ci/job_artifact_type.rb +++ b/app/graphql/types/ci/job_artifact_type.rb @@ -6,7 +6,7 @@ module Types class JobArtifactType < BaseObject graphql_name 'CiJobArtifact' - field :download_path, GraphQL::STRING_TYPE, null: true, + field :download_path, GraphQL::Types::String, null: true, description: "URL for downloading the artifact's file." field :file_type, ::Types::Ci::JobArtifactFileTypeEnum, null: true, diff --git a/app/graphql/types/ci/job_type.rb b/app/graphql/types/ci/job_type.rb index 360ea3ba7a9..4a3518e1865 100644 --- a/app/graphql/types/ci/job_type.rb +++ b/app/graphql/types/ci/job_type.rb @@ -14,7 +14,7 @@ module Types description: 'ID of the job.' field :pipeline, Types::Ci::PipelineType, null: true, description: 'Pipeline the job belongs to.' - field :name, GraphQL::STRING_TYPE, null: true, + field :name, GraphQL::Types::String, null: true, description: 'Name of the job.' field :needs, BuildNeedType.connection_type, null: true, description: 'References to builds that must complete before the jobs run.' @@ -24,11 +24,11 @@ module Types description: "Status of the job." field :stage, Types::Ci::StageType, null: true, description: 'Stage of the job.' - field :allow_failure, ::GraphQL::BOOLEAN_TYPE, null: false, + field :allow_failure, ::GraphQL::Types::Boolean, null: false, description: 'Whether the job is allowed to fail.' - field :duration, GraphQL::INT_TYPE, null: true, + field :duration, GraphQL::Types::Int, null: true, description: 'Duration of the job in seconds.' - field :tags, [GraphQL::STRING_TYPE], null: true, + field :tags, [GraphQL::Types::String], null: true, description: 'Tags for the current job.' # Life-cycle timestamps: @@ -53,33 +53,33 @@ module Types description: 'Detailed status of the job.' field :artifacts, Types::Ci::JobArtifactType.connection_type, null: true, description: 'Artifacts generated by the job.' - field :short_sha, type: GraphQL::STRING_TYPE, null: false, + field :short_sha, type: GraphQL::Types::String, null: false, description: 'Short SHA1 ID of the commit.' - field :scheduling_type, GraphQL::STRING_TYPE, null: true, + field :scheduling_type, GraphQL::Types::String, null: true, description: 'Type of job scheduling. Value is `dag` if the job uses the `needs` keyword, and `stage` otherwise.' - field :commit_path, GraphQL::STRING_TYPE, null: true, + field :commit_path, GraphQL::Types::String, null: true, description: 'Path to the commit that triggered the job.' - field :ref_name, GraphQL::STRING_TYPE, null: true, + field :ref_name, GraphQL::Types::String, null: true, description: 'Ref name of the job.' - field :ref_path, GraphQL::STRING_TYPE, null: true, + field :ref_path, GraphQL::Types::String, null: true, description: 'Path to the ref.' - field :playable, GraphQL::BOOLEAN_TYPE, null: false, method: :playable?, + field :playable, GraphQL::Types::Boolean, null: false, method: :playable?, description: 'Indicates the job can be played.' - field :retryable, GraphQL::BOOLEAN_TYPE, null: false, method: :retryable?, + field :retryable, GraphQL::Types::Boolean, null: false, method: :retryable?, description: 'Indicates the job can be retried.' - field :cancelable, GraphQL::BOOLEAN_TYPE, null: false, method: :cancelable?, + field :cancelable, GraphQL::Types::Boolean, null: false, method: :cancelable?, description: 'Indicates the job can be canceled.' - field :active, GraphQL::BOOLEAN_TYPE, null: false, method: :active?, + field :active, GraphQL::Types::Boolean, null: false, method: :active?, description: 'Indicates the job is active.' - field :stuck, GraphQL::BOOLEAN_TYPE, null: false, method: :stuck?, + field :stuck, GraphQL::Types::Boolean, null: false, method: :stuck?, description: 'Indicates the job is stuck.' field :coverage, GraphQL::FLOAT_TYPE, null: true, description: 'Coverage level of the job.' - field :created_by_tag, GraphQL::BOOLEAN_TYPE, null: false, + field :created_by_tag, GraphQL::Types::Boolean, null: false, description: 'Whether the job was created by a tag.' - field :manual_job, GraphQL::BOOLEAN_TYPE, null: true, + field :manual_job, GraphQL::Types::Boolean, null: true, description: 'Whether the job has a manual action.' - field :triggered, GraphQL::BOOLEAN_TYPE, null: true, + field :triggered, GraphQL::Types::Boolean, null: true, description: 'Whether the job was triggered.' def pipeline diff --git a/app/graphql/types/ci/pipeline_type.rb b/app/graphql/types/ci/pipeline_type.rb index f4a6c18f73e..0375257eb7b 100644 --- a/app/graphql/types/ci/pipeline_type.rb +++ b/app/graphql/types/ci/pipeline_type.rb @@ -12,25 +12,25 @@ module Types expose_permissions Types::PermissionTypes::Ci::Pipeline - field :id, GraphQL::ID_TYPE, null: false, + field :id, GraphQL::Types::ID, null: false, description: 'ID of the pipeline.' - field :iid, GraphQL::STRING_TYPE, null: false, + field :iid, GraphQL::Types::String, null: false, description: 'Internal ID of the pipeline.' - field :sha, GraphQL::STRING_TYPE, null: false, + field :sha, GraphQL::Types::String, null: false, description: "SHA of the pipeline's commit." - field :before_sha, GraphQL::STRING_TYPE, null: true, + field :before_sha, GraphQL::Types::String, null: true, description: 'Base SHA of the source branch.' - field :complete, GraphQL::BOOLEAN_TYPE, null: false, method: :complete?, + field :complete, GraphQL::Types::Boolean, null: false, method: :complete?, description: 'Indicates if a pipeline is complete.' field :status, PipelineStatusEnum, null: false, description: "Status of the pipeline (#{::Ci::Pipeline.all_state_names.compact.join(', ').upcase})" - field :warnings, GraphQL::BOOLEAN_TYPE, null: false, method: :has_warnings?, + field :warnings, GraphQL::Types::Boolean, null: false, method: :has_warnings?, description: "Indicates if a pipeline has warnings." field :detailed_status, Types::Ci::DetailedStatusType, null: false, @@ -39,7 +39,7 @@ module Types field :config_source, PipelineConfigSourceEnum, null: true, description: "Configuration source of the pipeline (#{::Enums::Ci::Pipeline.config_sources.keys.join(', ').upcase})" - field :duration, GraphQL::INT_TYPE, null: true, + field :duration, GraphQL::Types::Int, null: true, description: 'Duration of the pipeline in seconds.' field :queued_duration, Types::DurationType, null: true, @@ -76,12 +76,12 @@ module Types null: true, description: 'Pipeline user.' - field :retryable, GraphQL::BOOLEAN_TYPE, + field :retryable, GraphQL::Types::Boolean, description: 'Specifies if a pipeline can be retried.', method: :retryable?, null: false - field :cancelable, GraphQL::BOOLEAN_TYPE, + field :cancelable, GraphQL::Types::Boolean, description: 'Specifies if a pipeline can be canceled.', method: :cancelable?, null: false @@ -103,7 +103,7 @@ module Types required: false, description: 'ID of the job.' argument :name, - type: ::GraphQL::STRING_TYPE, + type: ::GraphQL::Types::String, required: false, description: 'Name of the job.' end @@ -122,19 +122,19 @@ module Types description: 'Pipeline that triggered the pipeline.', method: :triggered_by_pipeline - field :path, GraphQL::STRING_TYPE, null: true, + field :path, GraphQL::Types::String, null: true, description: "Relative path to the pipeline's page." - field :commit_path, GraphQL::STRING_TYPE, null: true, + field :commit_path, GraphQL::Types::String, null: true, description: 'Path to the commit that triggered the pipeline.' field :project, Types::ProjectType, null: true, description: 'Project the pipeline belongs to.' - field :active, GraphQL::BOOLEAN_TYPE, null: false, method: :active?, + field :active, GraphQL::Types::Boolean, null: false, method: :active?, description: 'Indicates if the pipeline is active.' - field :uses_needs, GraphQL::BOOLEAN_TYPE, null: true, + field :uses_needs, GraphQL::Types::Boolean, null: true, method: :uses_needs?, description: 'Indicates if the pipeline has jobs with `needs` dependencies.' @@ -150,7 +150,7 @@ module Types description: 'A specific test suite in a pipeline test report.', resolver: Resolvers::Ci::TestSuiteResolver - field :ref, GraphQL::STRING_TYPE, null: true, + field :ref, GraphQL::Types::String, null: true, description: 'Reference to the branch from which the pipeline was triggered.' def detailed_status diff --git a/app/graphql/types/ci/recent_failures_type.rb b/app/graphql/types/ci/recent_failures_type.rb index eeff7222762..f56b0939086 100644 --- a/app/graphql/types/ci/recent_failures_type.rb +++ b/app/graphql/types/ci/recent_failures_type.rb @@ -9,10 +9,10 @@ module Types connection_type_class(Types::CountableConnectionType) - field :count, GraphQL::INT_TYPE, null: true, + field :count, GraphQL::Types::Int, null: true, description: 'Number of times the test case has failed in the past 14 days.' - field :base_branch, GraphQL::STRING_TYPE, null: true, + field :base_branch, GraphQL::Types::String, null: true, description: 'Name of the base branch of the project.' end # rubocop: enable Graphql/AuthorizeTypes diff --git a/app/graphql/types/ci/runner_architecture_type.rb b/app/graphql/types/ci/runner_architecture_type.rb index 229974d4d13..08d3f98592b 100644 --- a/app/graphql/types/ci/runner_architecture_type.rb +++ b/app/graphql/types/ci/runner_architecture_type.rb @@ -6,9 +6,9 @@ module Types class RunnerArchitectureType < BaseObject graphql_name 'RunnerArchitecture' - field :name, GraphQL::STRING_TYPE, null: false, + field :name, GraphQL::Types::String, null: false, description: 'Name of the runner platform architecture.' - field :download_location, GraphQL::STRING_TYPE, null: false, + field :download_location, GraphQL::Types::String, null: false, description: 'Download location for the runner for the platform architecture.' end end diff --git a/app/graphql/types/ci/runner_platform_type.rb b/app/graphql/types/ci/runner_platform_type.rb index 5636f88835e..ffcf6364968 100644 --- a/app/graphql/types/ci/runner_platform_type.rb +++ b/app/graphql/types/ci/runner_platform_type.rb @@ -6,9 +6,9 @@ module Types class RunnerPlatformType < BaseObject graphql_name 'RunnerPlatform' - field :name, GraphQL::STRING_TYPE, null: false, + field :name, GraphQL::Types::String, null: false, description: 'Name slug of the runner platform.' - field :human_readable_name, GraphQL::STRING_TYPE, null: false, + field :human_readable_name, GraphQL::Types::String, null: false, description: 'Human readable name of the runner platform.' field :architectures, Types::Ci::RunnerArchitectureType.connection_type, null: true, description: 'Runner architectures supported for the platform.' diff --git a/app/graphql/types/ci/runner_setup_type.rb b/app/graphql/types/ci/runner_setup_type.rb index 61a2ea2a411..70f33cef8ad 100644 --- a/app/graphql/types/ci/runner_setup_type.rb +++ b/app/graphql/types/ci/runner_setup_type.rb @@ -6,9 +6,9 @@ module Types class RunnerSetupType < BaseObject graphql_name 'RunnerSetup' - field :install_instructions, GraphQL::STRING_TYPE, null: false, + field :install_instructions, GraphQL::Types::String, null: false, description: 'Instructions for installing the runner on the specified architecture.' - field :register_instructions, GraphQL::STRING_TYPE, null: true, + field :register_instructions, GraphQL::Types::String, null: true, description: 'Instructions for registering the runner.' end end diff --git a/app/graphql/types/ci/runner_type.rb b/app/graphql/types/ci/runner_type.rb index 9c5041b0860..e2c8070af0c 100644 --- a/app/graphql/types/ci/runner_type.rb +++ b/app/graphql/types/ci/runner_type.rb @@ -5,6 +5,7 @@ module Types class RunnerType < BaseObject graphql_name 'CiRunner' authorize :read_runner + present_using ::Ci::RunnerPresenter JOB_COUNT_LIMIT = 1000 @@ -12,38 +13,38 @@ module Types field :id, ::Types::GlobalIDType[::Ci::Runner], null: false, description: 'ID of the runner.' - field :description, GraphQL::STRING_TYPE, null: true, + field :description, GraphQL::Types::String, null: true, description: 'Description of the runner.' field :contacted_at, Types::TimeType, null: true, description: 'Last contact from the runner.', method: :contacted_at - field :maximum_timeout, GraphQL::INT_TYPE, null: true, + field :maximum_timeout, GraphQL::Types::Int, null: true, description: 'Maximum timeout (in seconds) for jobs processed by the runner.' field :access_level, ::Types::Ci::RunnerAccessLevelEnum, null: false, description: 'Access level of the runner.' - field :active, GraphQL::BOOLEAN_TYPE, null: false, + field :active, GraphQL::Types::Boolean, null: false, description: 'Indicates the runner is allowed to receive jobs.' field :status, ::Types::Ci::RunnerStatusEnum, null: false, description: 'Status of the runner.' - field :version, GraphQL::STRING_TYPE, null: true, + field :version, GraphQL::Types::String, null: true, description: 'Version of the runner.' - field :short_sha, GraphQL::STRING_TYPE, null: true, + field :short_sha, GraphQL::Types::String, null: true, description: %q(First eight characters of the runner's token used to authenticate new job requests. Used as the runner's unique ID.) - field :revision, GraphQL::STRING_TYPE, null: true, + field :revision, GraphQL::Types::String, null: true, description: 'Revision of the runner.' - field :locked, GraphQL::BOOLEAN_TYPE, null: true, + field :locked, GraphQL::Types::Boolean, null: true, description: 'Indicates the runner is locked.' - field :run_untagged, GraphQL::BOOLEAN_TYPE, null: false, + field :run_untagged, GraphQL::Types::Boolean, null: false, description: 'Indicates the runner is able to run untagged jobs.' - field :ip_address, GraphQL::STRING_TYPE, null: true, + field :ip_address, GraphQL::Types::String, null: true, description: 'IP address of the runner.' field :runner_type, ::Types::Ci::RunnerTypeEnum, null: false, description: 'Type of the runner.' - field :tag_list, [GraphQL::STRING_TYPE], null: true, + field :tag_list, [GraphQL::Types::String], null: true, description: 'Tags associated with the runner.' - field :project_count, GraphQL::INT_TYPE, null: true, + field :project_count, GraphQL::Types::Int, null: true, description: 'Number of projects that the runner is associated with.' - field :job_count, GraphQL::INT_TYPE, null: true, + field :job_count, GraphQL::Types::Int, null: true, description: "Number of jobs processed by the runner (limited to #{JOB_COUNT_LIMIT}, plus one to indicate that more items exist)." def job_count diff --git a/app/graphql/types/ci/stage_type.rb b/app/graphql/types/ci/stage_type.rb index ce3edb6c54f..63357e2345b 100644 --- a/app/graphql/types/ci/stage_type.rb +++ b/app/graphql/types/ci/stage_type.rb @@ -6,9 +6,9 @@ module Types graphql_name 'CiStage' authorize :read_commit_status - field :id, GraphQL::ID_TYPE, null: false, + field :id, GraphQL::Types::ID, null: false, description: 'ID of the stage.' - field :name, type: GraphQL::STRING_TYPE, null: true, + field :name, type: GraphQL::Types::String, null: true, description: 'Name of the stage.' field :groups, type: Ci::GroupType.connection_type, null: true, extras: [:lookahead], @@ -18,7 +18,7 @@ module Types field :jobs, Ci::JobType.connection_type, null: true, description: 'Jobs for the stage.', method: 'latest_statuses' - field :status, GraphQL::STRING_TYPE, + field :status, GraphQL::Types::String, null: true, description: 'Status of the pipeline stage.' @@ -52,9 +52,13 @@ module Types # rubocop: disable CodeReuse/ActiveRecord def jobs_for_pipeline(pipeline, stage_ids, include_needs) - results = pipeline.latest_statuses.where(stage_id: stage_ids) - results = results.preload(:project) - results = results.preload(:needs) if include_needs + builds_results = pipeline.latest_builds.where(stage_id: stage_ids).preload(:job_artifacts, :project) + bridges_results = pipeline.bridges.where(stage_id: stage_ids).preload(:project) + builds_results = builds_results.preload(:needs) if include_needs + bridges_results = bridges_results.preload(:needs) if include_needs + commit_status_results = pipeline.latest_statuses.where(stage_id: stage_ids) + + results = builds_results | bridges_results | commit_status_results results.group_by(&:stage_id) end diff --git a/app/graphql/types/ci/status_action_type.rb b/app/graphql/types/ci/status_action_type.rb index a06b09735b3..15e5344e130 100644 --- a/app/graphql/types/ci/status_action_type.rb +++ b/app/graphql/types/ci/status_action_type.rb @@ -5,19 +5,19 @@ module Types class StatusActionType < BaseObject graphql_name 'StatusAction' - field :id, GraphQL::STRING_TYPE, null: false, + field :id, GraphQL::Types::String, null: false, description: 'ID for a status action.', extras: [:parent] - field :button_title, GraphQL::STRING_TYPE, null: true, + field :button_title, GraphQL::Types::String, null: true, description: 'Title for the button, for example: Retry this job.' - field :icon, GraphQL::STRING_TYPE, null: true, + field :icon, GraphQL::Types::String, null: true, description: 'Icon used in the action button.' - field :method, GraphQL::STRING_TYPE, null: true, + field :method, GraphQL::Types::String, null: true, description: 'Method for the action, for example: :post.', resolver_method: :action_method - field :path, GraphQL::STRING_TYPE, null: true, + field :path, GraphQL::Types::String, null: true, description: 'Path for the action.' - field :title, GraphQL::STRING_TYPE, null: true, + field :title, GraphQL::Types::String, null: true, description: 'Title for the action, for example: Retry.' def id(parent:) diff --git a/app/graphql/types/ci/template_type.rb b/app/graphql/types/ci/template_type.rb index 5f07fa16928..7e7ee44025f 100644 --- a/app/graphql/types/ci/template_type.rb +++ b/app/graphql/types/ci/template_type.rb @@ -7,9 +7,9 @@ module Types graphql_name 'CiTemplate' description 'GitLab CI/CD configuration template.' - field :name, GraphQL::STRING_TYPE, null: false, + field :name, GraphQL::Types::String, null: false, description: 'Name of the CI template.' - field :content, GraphQL::STRING_TYPE, null: false, + field :content, GraphQL::Types::String, null: false, description: 'Contents of the CI template.' end end diff --git a/app/graphql/types/ci/test_case_type.rb b/app/graphql/types/ci/test_case_type.rb index 9cc3f918125..9ec5daa44ea 100644 --- a/app/graphql/types/ci/test_case_type.rb +++ b/app/graphql/types/ci/test_case_type.rb @@ -12,25 +12,25 @@ module Types field :status, Types::Ci::TestCaseStatusEnum, null: true, description: "Status of the test case (#{::Gitlab::Ci::Reports::TestCase::STATUS_TYPES.join(', ')})." - field :name, GraphQL::STRING_TYPE, null: true, + field :name, GraphQL::Types::String, null: true, description: 'Name of the test case.' - field :classname, GraphQL::STRING_TYPE, null: true, + field :classname, GraphQL::Types::String, null: true, description: 'Classname of the test case.' field :execution_time, GraphQL::FLOAT_TYPE, null: true, description: 'Test case execution time in seconds.' - field :file, GraphQL::STRING_TYPE, null: true, + field :file, GraphQL::Types::String, null: true, description: 'Path to the file of the test case.' - field :attachment_url, GraphQL::STRING_TYPE, null: true, + field :attachment_url, GraphQL::Types::String, null: true, description: 'URL of the test case attachment file.' - field :system_output, GraphQL::STRING_TYPE, null: true, + field :system_output, GraphQL::Types::String, null: true, description: 'System output of the test case.' - field :stack_trace, GraphQL::STRING_TYPE, null: true, + field :stack_trace, GraphQL::Types::String, null: true, description: 'Stack trace of the test case.' field :recent_failures, Types::Ci::RecentFailuresType, null: true, diff --git a/app/graphql/types/ci/test_report_total_type.rb b/app/graphql/types/ci/test_report_total_type.rb index 1123734adc3..aa07a391519 100644 --- a/app/graphql/types/ci/test_report_total_type.rb +++ b/app/graphql/types/ci/test_report_total_type.rb @@ -10,22 +10,22 @@ module Types field :time, GraphQL::FLOAT_TYPE, null: true, description: 'Total duration of the tests.' - field :count, GraphQL::INT_TYPE, null: true, + field :count, GraphQL::Types::Int, null: true, description: 'Total number of the test cases.' - field :success, GraphQL::INT_TYPE, null: true, + field :success, GraphQL::Types::Int, null: true, description: 'Total number of test cases that succeeded.' - field :failed, GraphQL::INT_TYPE, null: true, + field :failed, GraphQL::Types::Int, null: true, description: 'Total number of test cases that failed.' - field :skipped, GraphQL::INT_TYPE, null: true, + field :skipped, GraphQL::Types::Int, null: true, description: 'Total number of test cases that were skipped.' - field :error, GraphQL::INT_TYPE, null: true, + field :error, GraphQL::Types::Int, null: true, description: 'Total number of test cases that had an error.' - field :suite_error, GraphQL::STRING_TYPE, null: true, + field :suite_error, GraphQL::Types::String, null: true, description: 'Test suite error message.' end # rubocop: enable Graphql/AuthorizeTypes diff --git a/app/graphql/types/ci/test_suite_summary_type.rb b/app/graphql/types/ci/test_suite_summary_type.rb index a80a9179cb4..3db2d80d591 100644 --- a/app/graphql/types/ci/test_suite_summary_type.rb +++ b/app/graphql/types/ci/test_suite_summary_type.rb @@ -9,31 +9,31 @@ module Types connection_type_class(Types::CountableConnectionType) - field :name, GraphQL::STRING_TYPE, null: true, + field :name, GraphQL::Types::String, null: true, description: 'Name of the test suite.' field :total_time, GraphQL::FLOAT_TYPE, null: true, description: 'Total duration of the tests in the test suite.' - field :total_count, GraphQL::INT_TYPE, null: true, + field :total_count, GraphQL::Types::Int, null: true, description: 'Total number of the test cases in the test suite.' - field :success_count, GraphQL::INT_TYPE, null: true, + field :success_count, GraphQL::Types::Int, null: true, description: 'Total number of test cases that succeeded in the test suite.' - field :failed_count, GraphQL::INT_TYPE, null: true, + field :failed_count, GraphQL::Types::Int, null: true, description: 'Total number of test cases that failed in the test suite.' - field :skipped_count, GraphQL::INT_TYPE, null: true, + field :skipped_count, GraphQL::Types::Int, null: true, description: 'Total number of test cases that were skipped in the test suite.' - field :error_count, GraphQL::INT_TYPE, null: true, + field :error_count, GraphQL::Types::Int, null: true, description: 'Total number of test cases that had an error.' - field :suite_error, GraphQL::STRING_TYPE, null: true, + field :suite_error, GraphQL::Types::String, null: true, description: 'Test suite error message.' - field :build_ids, [GraphQL::ID_TYPE], null: true, + field :build_ids, [GraphQL::Types::ID], null: true, description: 'IDs of the builds used to run the test suite.' end # rubocop: enable Graphql/AuthorizeTypes diff --git a/app/graphql/types/ci/test_suite_type.rb b/app/graphql/types/ci/test_suite_type.rb index 7d4c01da81b..f9f37d4045e 100644 --- a/app/graphql/types/ci/test_suite_type.rb +++ b/app/graphql/types/ci/test_suite_type.rb @@ -9,28 +9,28 @@ module Types connection_type_class(Types::CountableConnectionType) - field :name, GraphQL::STRING_TYPE, null: true, + field :name, GraphQL::Types::String, null: true, description: 'Name of the test suite.' field :total_time, GraphQL::FLOAT_TYPE, null: true, description: 'Total duration of the tests in the test suite.' - field :total_count, GraphQL::INT_TYPE, null: true, + field :total_count, GraphQL::Types::Int, null: true, description: 'Total number of the test cases in the test suite.' - field :success_count, GraphQL::INT_TYPE, null: true, + field :success_count, GraphQL::Types::Int, null: true, description: 'Total number of test cases that succeeded in the test suite.' - field :failed_count, GraphQL::INT_TYPE, null: true, + field :failed_count, GraphQL::Types::Int, null: true, description: 'Total number of test cases that failed in the test suite.' - field :skipped_count, GraphQL::INT_TYPE, null: true, + field :skipped_count, GraphQL::Types::Int, null: true, description: 'Total number of test cases that were skipped in the test suite.' - field :error_count, GraphQL::INT_TYPE, null: true, + field :error_count, GraphQL::Types::Int, null: true, description: 'Total number of test cases that had an error.' - field :suite_error, GraphQL::STRING_TYPE, null: true, + field :suite_error, GraphQL::Types::String, null: true, description: 'Test suite error message.' field :test_cases, Types::Ci::TestCaseType.connection_type, null: true, diff --git a/app/graphql/types/ci_configuration/sast/analyzers_entity_input_type.rb b/app/graphql/types/ci_configuration/sast/analyzers_entity_input_type.rb index ccb72283cf6..68b9a63d8dc 100644 --- a/app/graphql/types/ci_configuration/sast/analyzers_entity_input_type.rb +++ b/app/graphql/types/ci_configuration/sast/analyzers_entity_input_type.rb @@ -7,10 +7,10 @@ module Types graphql_name 'SastCiConfigurationAnalyzersEntityInput' description 'Represents the analyzers entity in SAST CI configuration' - argument :name, GraphQL::STRING_TYPE, required: true, + argument :name, GraphQL::Types::String, required: true, description: 'Name of analyzer.' - argument :enabled, GraphQL::BOOLEAN_TYPE, required: true, + argument :enabled, GraphQL::Types::Boolean, required: true, description: 'State of the analyzer.' argument :variables, [::Types::CiConfiguration::Sast::EntityInputType], diff --git a/app/graphql/types/ci_configuration/sast/analyzers_entity_type.rb b/app/graphql/types/ci_configuration/sast/analyzers_entity_type.rb index 3c6202ca7e0..9fdc7c1b000 100644 --- a/app/graphql/types/ci_configuration/sast/analyzers_entity_type.rb +++ b/app/graphql/types/ci_configuration/sast/analyzers_entity_type.rb @@ -8,16 +8,16 @@ module Types graphql_name 'SastCiConfigurationAnalyzersEntity' description 'Represents an analyzer entity in SAST CI configuration' - field :name, GraphQL::STRING_TYPE, null: true, + field :name, GraphQL::Types::String, null: true, description: 'Name of the analyzer.' - field :label, GraphQL::STRING_TYPE, null: true, + field :label, GraphQL::Types::String, null: true, description: 'Analyzer label used in the config UI.' - field :enabled, GraphQL::BOOLEAN_TYPE, null: true, + field :enabled, GraphQL::Types::Boolean, null: true, description: 'Indicates whether an analyzer is enabled.' - field :description, GraphQL::STRING_TYPE, null: true, + field :description, GraphQL::Types::String, null: true, description: 'Analyzer description that is displayed on the form.' field :variables, ::Types::CiConfiguration::Sast::EntityType.connection_type, null: true, diff --git a/app/graphql/types/ci_configuration/sast/entity_input_type.rb b/app/graphql/types/ci_configuration/sast/entity_input_type.rb index 9fce120889b..f0e3c07d71f 100644 --- a/app/graphql/types/ci_configuration/sast/entity_input_type.rb +++ b/app/graphql/types/ci_configuration/sast/entity_input_type.rb @@ -7,13 +7,13 @@ module Types graphql_name 'SastCiConfigurationEntityInput' description 'Represents an entity in SAST CI configuration' - argument :field, GraphQL::STRING_TYPE, required: true, + argument :field, GraphQL::Types::String, required: true, description: 'CI keyword of entity.' - argument :default_value, GraphQL::STRING_TYPE, required: true, + argument :default_value, GraphQL::Types::String, required: true, description: 'Default value that is used if value is empty.' - argument :value, GraphQL::STRING_TYPE, required: true, + argument :value, GraphQL::Types::String, required: true, description: 'Current value of the entity.' end end diff --git a/app/graphql/types/ci_configuration/sast/entity_type.rb b/app/graphql/types/ci_configuration/sast/entity_type.rb index eeb9025391f..41b8575d99a 100644 --- a/app/graphql/types/ci_configuration/sast/entity_type.rb +++ b/app/graphql/types/ci_configuration/sast/entity_type.rb @@ -8,25 +8,25 @@ module Types graphql_name 'SastCiConfigurationEntity' description 'Represents an entity in SAST CI configuration' - field :field, GraphQL::STRING_TYPE, null: true, + field :field, GraphQL::Types::String, null: true, description: 'CI keyword of entity.' - field :label, GraphQL::STRING_TYPE, null: true, + field :label, GraphQL::Types::String, null: true, description: 'Label for entity used in the form.' - field :type, GraphQL::STRING_TYPE, null: true, + field :type, GraphQL::Types::String, null: true, description: 'Type of the field value.' field :options, ::Types::CiConfiguration::Sast::OptionsEntityType.connection_type, null: true, description: 'Different possible values of the field.' - field :default_value, GraphQL::STRING_TYPE, null: true, + field :default_value, GraphQL::Types::String, null: true, description: 'Default value that is used if value is empty.' - field :description, GraphQL::STRING_TYPE, null: true, + field :description, GraphQL::Types::String, null: true, description: 'Entity description that is displayed on the form.' - field :value, GraphQL::STRING_TYPE, null: true, + field :value, GraphQL::Types::String, null: true, description: 'Current value of the entity.' field :size, ::Types::CiConfiguration::Sast::UiComponentSizeEnum, null: true, diff --git a/app/graphql/types/ci_configuration/sast/options_entity_type.rb b/app/graphql/types/ci_configuration/sast/options_entity_type.rb index 86d104a7fda..5f365807cfe 100644 --- a/app/graphql/types/ci_configuration/sast/options_entity_type.rb +++ b/app/graphql/types/ci_configuration/sast/options_entity_type.rb @@ -8,10 +8,10 @@ module Types graphql_name 'SastCiConfigurationOptionsEntity' description 'Represents an entity for options in SAST CI configuration' - field :label, GraphQL::STRING_TYPE, null: true, + field :label, GraphQL::Types::String, null: true, description: 'Label of option entity.' - field :value, GraphQL::STRING_TYPE, null: true, + field :value, GraphQL::Types::String, null: true, description: 'Value of option entity.' end end diff --git a/app/graphql/types/commit_action_type.rb b/app/graphql/types/commit_action_type.rb index cc1f45478e4..b170134b388 100644 --- a/app/graphql/types/commit_action_type.rb +++ b/app/graphql/types/commit_action_type.rb @@ -4,15 +4,15 @@ module Types class CommitActionType < BaseInputObject argument :action, type: Types::CommitActionModeEnum, required: true, description: 'The action to perform, create, delete, move, update, chmod.' - argument :file_path, type: GraphQL::STRING_TYPE, required: true, + argument :file_path, type: GraphQL::Types::String, required: true, description: 'Full path to the file.' - argument :content, type: GraphQL::STRING_TYPE, required: false, + argument :content, type: GraphQL::Types::String, required: false, description: 'Content of the file.' - argument :previous_path, type: GraphQL::STRING_TYPE, required: false, + argument :previous_path, type: GraphQL::Types::String, required: false, description: 'Original full path to the file being moved.' - argument :last_commit_id, type: GraphQL::STRING_TYPE, required: false, + argument :last_commit_id, type: GraphQL::Types::String, required: false, description: 'Last known file commit ID.' - argument :execute_filemode, type: GraphQL::BOOLEAN_TYPE, required: false, + argument :execute_filemode, type: GraphQL::Types::Boolean, required: false, description: 'Enables/disables the execute flag on the file.' argument :encoding, type: Types::CommitEncodingEnum, required: false, description: 'Encoding of the file. Default is text.' diff --git a/app/graphql/types/commit_type.rb b/app/graphql/types/commit_type.rb index d137901380b..dc1bf6a3101 100644 --- a/app/graphql/types/commit_type.rb +++ b/app/graphql/types/commit_type.rb @@ -8,31 +8,31 @@ module Types present_using CommitPresenter - field :id, type: GraphQL::ID_TYPE, null: false, + field :id, type: GraphQL::Types::ID, null: false, description: 'ID (global ID) of the commit.' - field :sha, type: GraphQL::STRING_TYPE, null: false, + field :sha, type: GraphQL::Types::String, null: false, description: 'SHA1 ID of the commit.' - field :short_id, type: GraphQL::STRING_TYPE, null: false, + field :short_id, type: GraphQL::Types::String, null: false, description: 'Short SHA1 ID of the commit.' - field :title, type: GraphQL::STRING_TYPE, null: true, calls_gitaly: true, + field :title, type: GraphQL::Types::String, null: true, calls_gitaly: true, description: 'Title of the commit message.' markdown_field :title_html, null: true - field :description, type: GraphQL::STRING_TYPE, null: true, + field :description, type: GraphQL::Types::String, null: true, description: 'Description of the commit message.' markdown_field :description_html, null: true - field :message, type: GraphQL::STRING_TYPE, null: true, + field :message, type: GraphQL::Types::String, null: true, description: 'Raw commit message.' field :authored_date, type: Types::TimeType, null: true, description: 'Timestamp of when the commit was authored.' - field :web_url, type: GraphQL::STRING_TYPE, null: false, + field :web_url, type: GraphQL::Types::String, null: false, description: 'Web URL of the commit.' - field :web_path, type: GraphQL::STRING_TYPE, null: false, + field :web_path, type: GraphQL::Types::String, null: false, description: 'Web path of the commit.' - field :signature_html, type: GraphQL::STRING_TYPE, null: true, calls_gitaly: true, + field :signature_html, type: GraphQL::Types::String, null: true, calls_gitaly: true, description: 'Rendered HTML of the commit signature.' - field :author_name, type: GraphQL::STRING_TYPE, null: true, + field :author_name, type: GraphQL::Types::String, null: true, description: 'Commit authors name.' - field :author_gravatar, type: GraphQL::STRING_TYPE, null: true, + field :author_gravatar, type: GraphQL::Types::String, null: true, description: 'Commit authors gravatar.' # models/commit lazy loads the author by email diff --git a/app/graphql/types/container_expiration_policy_type.rb b/app/graphql/types/container_expiration_policy_type.rb index 2b01474617a..6d6df21fe3f 100644 --- a/app/graphql/types/container_expiration_policy_type.rb +++ b/app/graphql/types/container_expiration_policy_type.rb @@ -10,7 +10,7 @@ module Types field :created_at, Types::TimeType, null: false, description: 'Timestamp of when the container expiration policy was created.' field :updated_at, Types::TimeType, null: false, description: 'Timestamp of when the container expiration policy was updated.' - field :enabled, GraphQL::BOOLEAN_TYPE, null: false, description: 'Indicates whether this container expiration policy is enabled.' + field :enabled, GraphQL::Types::Boolean, null: false, description: 'Indicates whether this container expiration policy is enabled.' field :older_than, Types::ContainerExpirationPolicyOlderThanEnum, null: true, description: 'Tags older that this will expire.' field :cadence, Types::ContainerExpirationPolicyCadenceEnum, null: false, description: 'This container expiration policy schedule.' field :keep_n, Types::ContainerExpirationPolicyKeepEnum, null: true, description: 'Number of tags to retain.' diff --git a/app/graphql/types/container_repository_tag_type.rb b/app/graphql/types/container_repository_tag_type.rb index 6de16416395..b6b65bce421 100644 --- a/app/graphql/types/container_repository_tag_type.rb +++ b/app/graphql/types/container_repository_tag_type.rb @@ -8,15 +8,15 @@ module Types authorize :read_container_image - field :name, GraphQL::STRING_TYPE, null: false, description: 'Name of the tag.' - field :path, GraphQL::STRING_TYPE, null: false, description: 'Path of the tag.' - field :location, GraphQL::STRING_TYPE, null: false, description: 'URL of the tag.' - field :digest, GraphQL::STRING_TYPE, null: true, description: 'Digest of the tag.' - field :revision, GraphQL::STRING_TYPE, null: true, description: 'Revision of the tag.' - field :short_revision, GraphQL::STRING_TYPE, null: true, description: 'Short revision of the tag.' + field :name, GraphQL::Types::String, null: false, description: 'Name of the tag.' + field :path, GraphQL::Types::String, null: false, description: 'Path of the tag.' + field :location, GraphQL::Types::String, null: false, description: 'URL of the tag.' + field :digest, GraphQL::Types::String, null: true, description: 'Digest of the tag.' + field :revision, GraphQL::Types::String, null: true, description: 'Revision of the tag.' + field :short_revision, GraphQL::Types::String, null: true, description: 'Short revision of the tag.' field :total_size, GraphQL::Types::BigInt, null: true, description: 'The size of the tag.' field :created_at, Types::TimeType, null: true, description: 'Timestamp when the tag was created.' - field :can_delete, GraphQL::BOOLEAN_TYPE, null: false, description: 'Can the current user delete this tag.' + field :can_delete, GraphQL::Types::Boolean, null: false, description: 'Can the current user delete this tag.' def can_delete Ability.allowed?(current_user, :destroy_container_image, object) diff --git a/app/graphql/types/container_repository_type.rb b/app/graphql/types/container_repository_type.rb index 48c2b9f460f..91a65053131 100644 --- a/app/graphql/types/container_repository_type.rb +++ b/app/graphql/types/container_repository_type.rb @@ -8,17 +8,17 @@ module Types authorize :read_container_image - field :id, GraphQL::ID_TYPE, null: false, description: 'ID of the container repository.' - field :name, GraphQL::STRING_TYPE, null: false, description: 'Name of the container repository.' - field :path, GraphQL::STRING_TYPE, null: false, description: 'Path of the container repository.' - field :location, GraphQL::STRING_TYPE, null: false, description: 'URL of the container repository.' + field :id, GraphQL::Types::ID, null: false, description: 'ID of the container repository.' + field :name, GraphQL::Types::String, null: false, description: 'Name of the container repository.' + field :path, GraphQL::Types::String, null: false, description: 'Path of the container repository.' + field :location, GraphQL::Types::String, null: false, description: 'URL of the container repository.' field :created_at, Types::TimeType, null: false, description: 'Timestamp when the container repository was created.' field :updated_at, Types::TimeType, null: false, description: 'Timestamp when the container repository was updated.' field :expiration_policy_started_at, Types::TimeType, null: true, description: 'Timestamp when the cleanup done by the expiration policy was started on the container repository.' field :expiration_policy_cleanup_status, Types::ContainerRepositoryCleanupStatusEnum, null: true, description: 'The tags cleanup status for the container repository.' field :status, Types::ContainerRepositoryStatusEnum, null: true, description: 'Status of the container repository.' - field :tags_count, GraphQL::INT_TYPE, null: false, description: 'Number of tags associated with this image.' - field :can_delete, GraphQL::BOOLEAN_TYPE, null: false, description: 'Can the current user delete the container repository.' + field :tags_count, GraphQL::Types::Int, null: false, description: 'Number of tags associated with this image.' + field :can_delete, GraphQL::Types::Boolean, null: false, description: 'Can the current user delete the container repository.' field :project, Types::ProjectType, null: false, description: 'Project of the container registry.' def can_delete diff --git a/app/graphql/types/countable_connection_type.rb b/app/graphql/types/countable_connection_type.rb index 0a9699a4570..0f24964daa6 100644 --- a/app/graphql/types/countable_connection_type.rb +++ b/app/graphql/types/countable_connection_type.rb @@ -3,7 +3,7 @@ module Types # rubocop: disable Graphql/AuthorizeTypes class CountableConnectionType < GraphQL::Types::Relay::BaseConnection - field :count, GraphQL::INT_TYPE, null: false, + field :count, GraphQL::Types::Int, null: false, description: 'Total count of collection.' def count diff --git a/app/graphql/types/custom_emoji_type.rb b/app/graphql/types/custom_emoji_type.rb index 246b60ce184..64381b3ee1e 100644 --- a/app/graphql/types/custom_emoji_type.rb +++ b/app/graphql/types/custom_emoji_type.rb @@ -11,16 +11,16 @@ module Types null: false, description: 'The ID of the emoji.' - field :name, GraphQL::STRING_TYPE, + field :name, GraphQL::Types::String, null: false, description: 'The name of the emoji.' - field :url, GraphQL::STRING_TYPE, + field :url, GraphQL::Types::String, null: false, method: :file, description: 'The link to file of the emoji.' - field :external, GraphQL::BOOLEAN_TYPE, + field :external, GraphQL::Types::Boolean, null: false, description: 'Whether the emoji is an external link.' end diff --git a/app/graphql/types/design_management/design_fields.rb b/app/graphql/types/design_management/design_fields.rb index b770e30f5be..7779c3f1bcb 100644 --- a/app/graphql/types/design_management/design_fields.rb +++ b/app/graphql/types/design_management/design_fields.rb @@ -7,13 +7,13 @@ module Types field_class Types::BaseField - field :id, GraphQL::ID_TYPE, description: 'The ID of this design.', null: false + field :id, GraphQL::Types::ID, description: 'The ID of this design.', null: false field :project, Types::ProjectType, null: false, description: 'The project the design belongs to.' field :issue, Types::IssueType, null: false, description: 'The issue the design belongs to.' - field :filename, GraphQL::STRING_TYPE, null: false, description: 'The filename of the design.' - field :full_path, GraphQL::STRING_TYPE, null: false, description: 'The full path to the design file.' - field :image, GraphQL::STRING_TYPE, null: false, extras: [:parent], description: 'The URL of the full-sized image.' - field :image_v432x230, GraphQL::STRING_TYPE, null: true, extras: [:parent], + field :filename, GraphQL::Types::String, null: false, description: 'The filename of the design.' + field :full_path, GraphQL::Types::String, null: false, description: 'The full path to the design file.' + field :image, GraphQL::Types::String, null: false, extras: [:parent], description: 'The URL of the full-sized image.' + field :image_v432x230, GraphQL::Types::String, null: true, extras: [:parent], description: 'The URL of the design resized to fit within the bounds of 432x230. ' \ 'This will be `null` if the image has not been generated' field :diff_refs, Types::DiffRefsType, @@ -26,7 +26,7 @@ module Types extras: [:parent], description: 'How this design was changed in the current version.' field :notes_count, - GraphQL::INT_TYPE, + GraphQL::Types::Int, null: false, method: :user_notes_count, description: 'The total count of user-created notes for this design.' diff --git a/app/graphql/types/design_management/version_type.rb b/app/graphql/types/design_management/version_type.rb index 265d6185110..cfd2b887dc3 100644 --- a/app/graphql/types/design_management/version_type.rb +++ b/app/graphql/types/design_management/version_type.rb @@ -11,9 +11,9 @@ module Types authorize :read_design - field :id, GraphQL::ID_TYPE, null: false, + field :id, GraphQL::Types::ID, null: false, description: 'ID of the design version.' - field :sha, GraphQL::ID_TYPE, null: false, + field :sha, GraphQL::Types::ID, null: false, description: 'SHA of the design version.' field :designs, diff --git a/app/graphql/types/diff_paths_input_type.rb b/app/graphql/types/diff_paths_input_type.rb index d148b7656eb..e1d3d58411c 100644 --- a/app/graphql/types/diff_paths_input_type.rb +++ b/app/graphql/types/diff_paths_input_type.rb @@ -2,9 +2,9 @@ module Types class DiffPathsInputType < BaseInputObject - argument :old_path, GraphQL::STRING_TYPE, required: false, + argument :old_path, GraphQL::Types::String, required: false, description: 'The path of the file on the start sha.' - argument :new_path, GraphQL::STRING_TYPE, required: false, + argument :new_path, GraphQL::Types::String, required: false, description: 'The path of the file on the head sha.' end end diff --git a/app/graphql/types/diff_refs_type.rb b/app/graphql/types/diff_refs_type.rb index 3c8f934f1eb..b19d09c789c 100644 --- a/app/graphql/types/diff_refs_type.rb +++ b/app/graphql/types/diff_refs_type.rb @@ -6,11 +6,11 @@ module Types class DiffRefsType < BaseObject graphql_name 'DiffRefs' - field :head_sha, GraphQL::STRING_TYPE, null: false, + field :head_sha, GraphQL::Types::String, null: false, description: 'SHA of the HEAD at the time the comment was made.' - field :base_sha, GraphQL::STRING_TYPE, null: true, + field :base_sha, GraphQL::Types::String, null: true, description: 'Merge base of the branch the comment was made on.' - field :start_sha, GraphQL::STRING_TYPE, null: false, + field :start_sha, GraphQL::Types::String, null: false, description: 'SHA of the branch being compared against.' end # rubocop: enable Graphql/AuthorizeTypes diff --git a/app/graphql/types/diff_stats_summary_type.rb b/app/graphql/types/diff_stats_summary_type.rb index 78c0e2f2b4c..079c73d0759 100644 --- a/app/graphql/types/diff_stats_summary_type.rb +++ b/app/graphql/types/diff_stats_summary_type.rb @@ -8,13 +8,13 @@ module Types description 'Aggregated summary of changes' - field :additions, GraphQL::INT_TYPE, null: false, + field :additions, GraphQL::Types::Int, null: false, description: 'Number of lines added.' - field :deletions, GraphQL::INT_TYPE, null: false, + field :deletions, GraphQL::Types::Int, null: false, description: 'Number of lines deleted.' - field :changes, GraphQL::INT_TYPE, null: false, + field :changes, GraphQL::Types::Int, null: false, description: 'Number of lines changed.' - field :file_count, GraphQL::INT_TYPE, null: false, + field :file_count, GraphQL::Types::Int, null: false, description: 'Number of files changed.' def changes diff --git a/app/graphql/types/diff_stats_type.rb b/app/graphql/types/diff_stats_type.rb index 8a6840e5a94..60aacca8ce5 100644 --- a/app/graphql/types/diff_stats_type.rb +++ b/app/graphql/types/diff_stats_type.rb @@ -8,11 +8,11 @@ module Types description 'Changes to a single file' - field :path, GraphQL::STRING_TYPE, null: false, + field :path, GraphQL::Types::String, null: false, description: 'File path, relative to repository root.' - field :additions, GraphQL::INT_TYPE, null: false, + field :additions, GraphQL::Types::Int, null: false, description: 'Number of lines added to this file.' - field :deletions, GraphQL::INT_TYPE, null: false, + field :deletions, GraphQL::Types::Int, null: false, description: 'Number of lines deleted from this file.' end # rubocop: enable Graphql/AuthorizeTypes diff --git a/app/graphql/types/environment_type.rb b/app/graphql/types/environment_type.rb index 2e6417f08ea..267ca944198 100644 --- a/app/graphql/types/environment_type.rb +++ b/app/graphql/types/environment_type.rb @@ -9,16 +9,16 @@ module Types authorize :read_environment - field :name, GraphQL::STRING_TYPE, null: false, + field :name, GraphQL::Types::String, null: false, description: 'Human-readable name of the environment.' - field :id, GraphQL::ID_TYPE, null: false, + field :id, GraphQL::Types::ID, null: false, description: 'ID of the environment.' - field :state, GraphQL::STRING_TYPE, null: false, + field :state, GraphQL::Types::String, null: false, description: 'State of the environment, for example: available/stopped.' - field :path, GraphQL::STRING_TYPE, null: false, + field :path, GraphQL::Types::String, null: false, description: 'The path to the environment.' field :metrics_dashboard, Types::Metrics::DashboardType, null: true, diff --git a/app/graphql/types/error_tracking/sentry_detailed_error_type.rb b/app/graphql/types/error_tracking/sentry_detailed_error_type.rb index 59bd97e3448..79e789d3f8b 100644 --- a/app/graphql/types/error_tracking/sentry_detailed_error_type.rb +++ b/app/graphql/types/error_tracking/sentry_detailed_error_type.rb @@ -10,23 +10,23 @@ module Types authorize :read_sentry_issue - field :id, GraphQL::ID_TYPE, + field :id, GraphQL::Types::ID, null: false, description: 'ID (global ID) of the error.' - field :sentry_id, GraphQL::STRING_TYPE, + field :sentry_id, GraphQL::Types::String, method: :id, null: false, description: 'ID (Sentry ID) of the error.' - field :title, GraphQL::STRING_TYPE, + field :title, GraphQL::Types::String, null: false, description: 'Title of the error.' - field :type, GraphQL::STRING_TYPE, + field :type, GraphQL::Types::String, null: false, description: 'Type of the error.' - field :user_count, GraphQL::INT_TYPE, + field :user_count, GraphQL::Types::Int, null: false, description: 'Count of users affected by the error.' - field :count, GraphQL::INT_TYPE, + field :count, GraphQL::Types::Int, null: false, description: 'Count of occurrences.' field :first_seen, Types::TimeType, @@ -35,31 +35,31 @@ module Types field :last_seen, Types::TimeType, null: false, description: 'Timestamp when the error was last seen.' - field :message, GraphQL::STRING_TYPE, + field :message, GraphQL::Types::String, null: true, description: 'Sentry metadata message of the error.' - field :culprit, GraphQL::STRING_TYPE, + field :culprit, GraphQL::Types::String, null: false, description: 'Culprit of the error.' - field :external_base_url, GraphQL::STRING_TYPE, + field :external_base_url, GraphQL::Types::String, null: false, description: 'External Base URL of the Sentry Instance.' - field :external_url, GraphQL::STRING_TYPE, + field :external_url, GraphQL::Types::String, null: false, description: 'External URL of the error.' - field :sentry_project_id, GraphQL::ID_TYPE, + field :sentry_project_id, GraphQL::Types::ID, method: :project_id, null: false, description: 'ID of the project (Sentry project).' - field :sentry_project_name, GraphQL::STRING_TYPE, + field :sentry_project_name, GraphQL::Types::String, method: :project_name, null: false, description: 'Name of the project affected by the error.' - field :sentry_project_slug, GraphQL::STRING_TYPE, + field :sentry_project_slug, GraphQL::Types::String, method: :project_slug, null: false, description: 'Slug of the project affected by the error.' - field :short_id, GraphQL::STRING_TYPE, + field :short_id, GraphQL::Types::String, null: false, description: 'Short ID (Sentry ID) of the error.' field :status, Types::ErrorTracking::SentryErrorStatusEnum, @@ -68,31 +68,31 @@ module Types field :frequency, [Types::ErrorTracking::SentryErrorFrequencyType], null: false, description: 'Last 24hr stats of the error.' - field :first_release_last_commit, GraphQL::STRING_TYPE, + field :first_release_last_commit, GraphQL::Types::String, null: true, description: 'Commit the error was first seen.' - field :last_release_last_commit, GraphQL::STRING_TYPE, + field :last_release_last_commit, GraphQL::Types::String, null: true, description: 'Commit the error was last seen.' - field :first_release_short_version, GraphQL::STRING_TYPE, + field :first_release_short_version, GraphQL::Types::String, null: true, description: 'Release short version the error was first seen.' - field :last_release_short_version, GraphQL::STRING_TYPE, + field :last_release_short_version, GraphQL::Types::String, null: true, description: 'Release short version the error was last seen.' - field :first_release_version, GraphQL::STRING_TYPE, + field :first_release_version, GraphQL::Types::String, null: true, description: 'Release version the error was first seen.' - field :last_release_version, GraphQL::STRING_TYPE, + field :last_release_version, GraphQL::Types::String, null: true, description: 'Release version the error was last seen.' - field :gitlab_commit, GraphQL::STRING_TYPE, + field :gitlab_commit, GraphQL::Types::String, null: true, description: 'GitLab commit SHA attributed to the Error based on the release version.' - field :gitlab_commit_path, GraphQL::STRING_TYPE, + field :gitlab_commit_path, GraphQL::Types::String, null: true, description: 'Path to the GitLab page for the GitLab commit attributed to the error.' - field :gitlab_issue_path, GraphQL::STRING_TYPE, + field :gitlab_issue_path, GraphQL::Types::String, method: :gitlab_issue, null: true, description: 'URL of GitLab Issue.' diff --git a/app/graphql/types/error_tracking/sentry_error_collection_type.rb b/app/graphql/types/error_tracking/sentry_error_collection_type.rb index d3941b7c410..2d8c3d3d326 100644 --- a/app/graphql/types/error_tracking/sentry_error_collection_type.rb +++ b/app/graphql/types/error_tracking/sentry_error_collection_type.rb @@ -18,7 +18,7 @@ module Types description: 'Stack Trace of Sentry Error.', resolver: Resolvers::ErrorTracking::SentryErrorStackTraceResolver field :external_url, - GraphQL::STRING_TYPE, + GraphQL::Types::String, null: true, description: "External URL for Sentry." end diff --git a/app/graphql/types/error_tracking/sentry_error_frequency_type.rb b/app/graphql/types/error_tracking/sentry_error_frequency_type.rb index 05af1391af3..49a1b1e0476 100644 --- a/app/graphql/types/error_tracking/sentry_error_frequency_type.rb +++ b/app/graphql/types/error_tracking/sentry_error_frequency_type.rb @@ -9,7 +9,7 @@ module Types field :time, Types::TimeType, null: false, description: "Time the error frequency stats were recorded." - field :count, GraphQL::INT_TYPE, + field :count, GraphQL::Types::Int, null: false, description: "Count of errors received since the previously recorded time." end diff --git a/app/graphql/types/error_tracking/sentry_error_stack_trace_context_type.rb b/app/graphql/types/error_tracking/sentry_error_stack_trace_context_type.rb index 0b3c4cf55b9..ad31854b30c 100644 --- a/app/graphql/types/error_tracking/sentry_error_stack_trace_context_type.rb +++ b/app/graphql/types/error_tracking/sentry_error_stack_trace_context_type.rb @@ -8,11 +8,11 @@ module Types description 'An object context for a Sentry error stack trace' field :line, - GraphQL::INT_TYPE, + GraphQL::Types::Int, null: false, description: 'Line number of the context.' field :code, - GraphQL::STRING_TYPE, + GraphQL::Types::String, null: false, description: 'Code number of the context.' diff --git a/app/graphql/types/error_tracking/sentry_error_stack_trace_entry_type.rb b/app/graphql/types/error_tracking/sentry_error_stack_trace_entry_type.rb index c9915d052f9..e8f78004569 100644 --- a/app/graphql/types/error_tracking/sentry_error_stack_trace_entry_type.rb +++ b/app/graphql/types/error_tracking/sentry_error_stack_trace_entry_type.rb @@ -7,16 +7,16 @@ module Types graphql_name 'SentryErrorStackTraceEntry' description 'An object containing a stack trace entry for a Sentry error' - field :function, GraphQL::STRING_TYPE, + field :function, GraphQL::Types::String, null: true, description: 'Function in which the Sentry error occurred.' - field :col, GraphQL::STRING_TYPE, + field :col, GraphQL::Types::String, null: true, description: 'Function in which the Sentry error occurred.' - field :line, GraphQL::STRING_TYPE, + field :line, GraphQL::Types::String, null: true, description: 'Function in which the Sentry error occurred.' - field :file_name, GraphQL::STRING_TYPE, + field :file_name, GraphQL::Types::String, null: true, description: 'File in which the Sentry error occurred.' field :trace_context, [Types::ErrorTracking::SentryErrorStackTraceContextType], diff --git a/app/graphql/types/error_tracking/sentry_error_stack_trace_type.rb b/app/graphql/types/error_tracking/sentry_error_stack_trace_type.rb index 52959a9329b..dff52d77109 100644 --- a/app/graphql/types/error_tracking/sentry_error_stack_trace_type.rb +++ b/app/graphql/types/error_tracking/sentry_error_stack_trace_type.rb @@ -8,10 +8,10 @@ module Types authorize :read_sentry_issue - field :issue_id, GraphQL::STRING_TYPE, + field :issue_id, GraphQL::Types::String, null: false, description: 'ID of the Sentry error.' - field :date_received, GraphQL::STRING_TYPE, + field :date_received, GraphQL::Types::String, null: false, description: 'Time the stack trace was received by Sentry.' field :stack_trace_entries, [Types::ErrorTracking::SentryErrorStackTraceEntryType], diff --git a/app/graphql/types/error_tracking/sentry_error_tags_type.rb b/app/graphql/types/error_tracking/sentry_error_tags_type.rb index e2b051998c5..4d069615e3a 100644 --- a/app/graphql/types/error_tracking/sentry_error_tags_type.rb +++ b/app/graphql/types/error_tracking/sentry_error_tags_type.rb @@ -7,10 +7,10 @@ module Types graphql_name 'SentryErrorTags' description 'State of a Sentry error' - field :level, GraphQL::STRING_TYPE, + field :level, GraphQL::Types::String, null: true, description: "Severity level of the Sentry Error." - field :logger, GraphQL::STRING_TYPE, + field :logger, GraphQL::Types::String, null: true, description: "Logger of the Sentry Error." end diff --git a/app/graphql/types/error_tracking/sentry_error_type.rb b/app/graphql/types/error_tracking/sentry_error_type.rb index c0e09fb8c65..aaa6cbfb28f 100644 --- a/app/graphql/types/error_tracking/sentry_error_type.rb +++ b/app/graphql/types/error_tracking/sentry_error_type.rb @@ -9,10 +9,10 @@ module Types present_using SentryErrorPresenter - field :id, GraphQL::ID_TYPE, + field :id, GraphQL::Types::ID, null: false, description: 'ID (global ID) of the error.' - field :sentry_id, GraphQL::STRING_TYPE, + field :sentry_id, GraphQL::Types::String, method: :id, null: false, description: 'ID (Sentry ID) of the error.' @@ -22,28 +22,28 @@ module Types field :last_seen, Types::TimeType, null: false, description: 'Timestamp when the error was last seen.' - field :title, GraphQL::STRING_TYPE, + field :title, GraphQL::Types::String, null: false, description: 'Title of the error.' - field :type, GraphQL::STRING_TYPE, + field :type, GraphQL::Types::String, null: false, description: 'Type of the error.' - field :user_count, GraphQL::INT_TYPE, + field :user_count, GraphQL::Types::Int, null: false, description: 'Count of users affected by the error.' - field :count, GraphQL::INT_TYPE, + field :count, GraphQL::Types::Int, null: false, description: 'Count of occurrences.' - field :message, GraphQL::STRING_TYPE, + field :message, GraphQL::Types::String, null: true, description: 'Sentry metadata message of the error.' - field :culprit, GraphQL::STRING_TYPE, + field :culprit, GraphQL::Types::String, null: false, description: 'Culprit of the error.' - field :external_url, GraphQL::STRING_TYPE, + field :external_url, GraphQL::Types::String, null: false, description: 'External URL of the error.' - field :short_id, GraphQL::STRING_TYPE, + field :short_id, GraphQL::Types::String, null: false, description: 'Short ID (Sentry ID) of the error.' field :status, Types::ErrorTracking::SentryErrorStatusEnum, @@ -52,15 +52,15 @@ module Types field :frequency, [Types::ErrorTracking::SentryErrorFrequencyType], null: false, description: 'Last 24hr stats of the error.' - field :sentry_project_id, GraphQL::ID_TYPE, + field :sentry_project_id, GraphQL::Types::ID, method: :project_id, null: false, description: 'ID of the project (Sentry project).' - field :sentry_project_name, GraphQL::STRING_TYPE, + field :sentry_project_name, GraphQL::Types::String, method: :project_name, null: false, description: 'Name of the project affected by the error.' - field :sentry_project_slug, GraphQL::STRING_TYPE, + field :sentry_project_slug, GraphQL::Types::String, method: :project_slug, null: false, description: 'Slug of the project affected by the error.' diff --git a/app/graphql/types/event_type.rb b/app/graphql/types/event_type.rb index 2a4c2e7c60a..f4e680e93ef 100644 --- a/app/graphql/types/event_type.rb +++ b/app/graphql/types/event_type.rb @@ -9,7 +9,7 @@ module Types authorize :read_event - field :id, GraphQL::ID_TYPE, + field :id, GraphQL::Types::ID, description: 'ID of the event.', null: false diff --git a/app/graphql/types/evidence_type.rb b/app/graphql/types/evidence_type.rb index 6e56ad7d407..26fb64d25d8 100644 --- a/app/graphql/types/evidence_type.rb +++ b/app/graphql/types/evidence_type.rb @@ -9,11 +9,11 @@ module Types present_using Releases::EvidencePresenter - field :id, GraphQL::ID_TYPE, null: false, + field :id, GraphQL::Types::ID, null: false, description: 'ID of the evidence.' - field :sha, GraphQL::STRING_TYPE, null: true, + field :sha, GraphQL::Types::String, null: true, description: 'SHA1 ID of the evidence hash.' - field :filepath, GraphQL::STRING_TYPE, null: true, + field :filepath, GraphQL::Types::String, null: true, description: 'URL from where the evidence can be downloaded.' field :collected_at, Types::TimeType, null: true, description: 'Timestamp when the evidence was collected.' diff --git a/app/graphql/types/grafana_integration_type.rb b/app/graphql/types/grafana_integration_type.rb index 630d3a10e36..26fefd51e08 100644 --- a/app/graphql/types/grafana_integration_type.rb +++ b/app/graphql/types/grafana_integration_type.rb @@ -6,11 +6,11 @@ module Types authorize :admin_operations - field :id, GraphQL::ID_TYPE, null: false, + field :id, GraphQL::Types::ID, null: false, description: 'Internal ID of the Grafana integration.' - field :grafana_url, GraphQL::STRING_TYPE, null: false, + field :grafana_url, GraphQL::Types::String, null: false, description: 'URL for the Grafana host for the Grafana integration.' - field :enabled, GraphQL::BOOLEAN_TYPE, null: false, + field :enabled, GraphQL::Types::Boolean, null: false, description: 'Indicates whether Grafana integration is enabled.' field :created_at, Types::TimeType, null: false, description: 'Timestamp of the issue\'s creation.' diff --git a/app/graphql/types/group_type.rb b/app/graphql/types/group_type.rb index 27f4ae47c41..fbf0084cd0e 100644 --- a/app/graphql/types/group_type.rb +++ b/app/graphql/types/group_type.rb @@ -9,12 +9,12 @@ module Types expose_permissions Types::PermissionTypes::Group field :web_url, - type: GraphQL::STRING_TYPE, + type: GraphQL::Types::String, null: false, description: 'Web URL of the group.' field :avatar_url, - type: GraphQL::STRING_TYPE, + type: GraphQL::Types::String, null: true, description: 'Avatar URL of the group.' @@ -25,42 +25,42 @@ module Types feature_flag: :custom_emoji field :share_with_group_lock, - type: GraphQL::BOOLEAN_TYPE, + type: GraphQL::Types::Boolean, null: true, description: 'Indicates if sharing a project with another group within this group is prevented.' field :project_creation_level, - type: GraphQL::STRING_TYPE, + type: GraphQL::Types::String, null: true, method: :project_creation_level_str, description: 'The permission level required to create projects in the group.' field :subgroup_creation_level, - type: GraphQL::STRING_TYPE, + type: GraphQL::Types::String, null: true, method: :subgroup_creation_level_str, description: 'The permission level required to create subgroups within the group.' field :require_two_factor_authentication, - type: GraphQL::BOOLEAN_TYPE, + type: GraphQL::Types::Boolean, null: true, description: 'Indicates if all users in this group are required to set up two-factor authentication.' field :two_factor_grace_period, - type: GraphQL::INT_TYPE, + type: GraphQL::Types::Int, null: true, description: 'Time before two-factor authentication is enforced.' field :auto_devops_enabled, - type: GraphQL::BOOLEAN_TYPE, + type: GraphQL::Types::Boolean, null: true, description: 'Indicates whether Auto DevOps is enabled for all projects within this group.' field :emails_disabled, - type: GraphQL::BOOLEAN_TYPE, + type: GraphQL::Types::Boolean, null: true, description: 'Indicates if a group has email notifications disabled.' field :mentions_disabled, - type: GraphQL::BOOLEAN_TYPE, + type: GraphQL::Types::Boolean, null: true, description: 'Indicates if a group is disabled from getting mentioned.' @@ -103,7 +103,7 @@ module Types null: true, description: 'A label available on this group.' do argument :title, - type: GraphQL::STRING_TYPE, + type: GraphQL::Types::String, required: true, description: 'Title of the label.' end @@ -120,7 +120,7 @@ module Types authorize: :read_container_image field :container_repositories_count, - type: GraphQL::INT_TYPE, + type: GraphQL::Types::Int, null: false, description: 'Number of container repositories in the group.' @@ -149,6 +149,12 @@ module Types complexity: 5, resolver: ::Resolvers::TimelogResolver + field :descendant_groups, Types::GroupType.connection_type, + null: true, + description: 'List of descendant groups of this group.', + complexity: 5, + resolver: Resolvers::GroupsResolver + def avatar_url object.avatar_url(only_path: false) end diff --git a/app/graphql/types/invitation_interface.rb b/app/graphql/types/invitation_interface.rb index b1f69f043f2..1f0746d7726 100644 --- a/app/graphql/types/invitation_interface.rb +++ b/app/graphql/types/invitation_interface.rb @@ -4,7 +4,7 @@ module Types module InvitationInterface include BaseInterface - field :email, GraphQL::STRING_TYPE, null: false, + field :email, GraphQL::Types::String, null: false, description: 'Email of the member to invite.' field :access_level, Types::AccessLevelType, null: true, diff --git a/app/graphql/types/issue_status_counts_type.rb b/app/graphql/types/issue_status_counts_type.rb index 77429f9ea12..e4a0782e3cf 100644 --- a/app/graphql/types/issue_status_counts_type.rb +++ b/app/graphql/types/issue_status_counts_type.rb @@ -15,7 +15,7 @@ module Types next unless available_issue_states.include?(state.downcase) field state, - GraphQL::INT_TYPE, + GraphQL::Types::Int, null: true, description: "Number of issues with status #{state.upcase} for the project" end diff --git a/app/graphql/types/issue_type.rb b/app/graphql/types/issue_type.rb index 6ff38273c03..42feb8a8076 100644 --- a/app/graphql/types/issue_type.rb +++ b/app/graphql/types/issue_type.rb @@ -15,23 +15,23 @@ module Types present_using IssuePresenter - field :id, GraphQL::ID_TYPE, null: false, + field :id, GraphQL::Types::ID, null: false, description: "ID of the issue." - field :iid, GraphQL::ID_TYPE, null: false, + field :iid, GraphQL::Types::ID, null: false, description: "Internal ID of the issue." - field :title, GraphQL::STRING_TYPE, null: false, + field :title, GraphQL::Types::String, null: false, description: 'Title of the issue.' markdown_field :title_html, null: true - field :description, GraphQL::STRING_TYPE, null: true, + field :description, GraphQL::Types::String, null: true, description: 'Description of the issue.' markdown_field :description_html, null: true field :state, IssueStateEnum, null: false, description: 'State of the issue.' - field :reference, GraphQL::STRING_TYPE, null: false, + field :reference, GraphQL::Types::String, null: false, description: 'Internal reference of the issue. Returned in shortened format by default.', method: :to_reference do - argument :full, GraphQL::BOOLEAN_TYPE, required: false, default_value: false, + argument :full, GraphQL::Types::Boolean, required: false, default_value: false, description: 'Boolean option specifying whether the reference should be returned in full.' end @@ -51,42 +51,45 @@ module Types field :due_date, Types::TimeType, null: true, description: 'Due date of the issue.' - field :confidential, GraphQL::BOOLEAN_TYPE, null: false, + field :confidential, GraphQL::Types::Boolean, null: false, description: 'Indicates the issue is confidential.' - field :discussion_locked, GraphQL::BOOLEAN_TYPE, null: false, + field :discussion_locked, GraphQL::Types::Boolean, null: false, description: 'Indicates discussion is locked on the issue.' - field :upvotes, GraphQL::INT_TYPE, null: false, + field :upvotes, GraphQL::Types::Int, null: false, description: 'Number of upvotes the issue has received.' - field :downvotes, GraphQL::INT_TYPE, null: false, + field :downvotes, GraphQL::Types::Int, null: false, description: 'Number of downvotes the issue has received.' - field :user_notes_count, GraphQL::INT_TYPE, null: false, + field :merge_requests_count, GraphQL::Types::Int, null: false, + description: 'Number of merge requests that close the issue on merge.', + resolver: Resolvers::MergeRequestsCountResolver + field :user_notes_count, GraphQL::Types::Int, null: false, description: 'Number of user notes of the issue.', resolver: Resolvers::UserNotesCountResolver - field :user_discussions_count, GraphQL::INT_TYPE, null: false, + field :user_discussions_count, GraphQL::Types::Int, null: false, description: 'Number of user discussions in the issue.', resolver: Resolvers::UserDiscussionsCountResolver - field :web_path, GraphQL::STRING_TYPE, null: false, method: :issue_path, + field :web_path, GraphQL::Types::String, null: false, method: :issue_path, description: 'Web path of the issue.' - field :web_url, GraphQL::STRING_TYPE, null: false, + field :web_url, GraphQL::Types::String, null: false, description: 'Web URL of the issue.' - field :relative_position, GraphQL::INT_TYPE, null: true, + field :relative_position, GraphQL::Types::Int, null: true, description: 'Relative position of the issue (used for positioning in epic tree and issue boards).' field :participants, Types::UserType.connection_type, null: true, complexity: 5, description: 'List of participants in the issue.' - field :emails_disabled, GraphQL::BOOLEAN_TYPE, null: false, + field :emails_disabled, GraphQL::Types::Boolean, null: false, method: :project_emails_disabled?, description: 'Indicates if a project has email notifications disabled: `true` if email notifications are disabled.' - field :subscribed, GraphQL::BOOLEAN_TYPE, method: :subscribed?, null: false, complexity: 5, + field :subscribed, GraphQL::Types::Boolean, method: :subscribed?, null: false, complexity: 5, description: 'Indicates the currently logged in user is subscribed to the issue.' - field :time_estimate, GraphQL::INT_TYPE, null: false, + field :time_estimate, GraphQL::Types::Int, null: false, description: 'Time estimate of the issue.' - field :total_time_spent, GraphQL::INT_TYPE, null: false, + field :total_time_spent, GraphQL::Types::Int, null: false, description: 'Total time reported as spent on the issue.' - field :human_time_estimate, GraphQL::STRING_TYPE, null: true, + field :human_time_estimate, GraphQL::Types::String, null: true, description: 'Human-readable time estimate of the issue.' - field :human_total_time_spent, GraphQL::STRING_TYPE, null: true, + field :human_total_time_spent, GraphQL::Types::String, null: true, description: 'Human-readable total time reported as spent on the issue.' field :closed_at, Types::TimeType, null: true, @@ -115,19 +118,19 @@ module Types field :severity, Types::IssuableSeverityEnum, null: true, description: 'Severity level of the incident.' - field :moved, GraphQL::BOOLEAN_TYPE, method: :moved?, null: true, + field :moved, GraphQL::Types::Boolean, method: :moved?, null: true, description: 'Indicates if issue got moved from other project.' field :moved_to, Types::IssueType, null: true, description: 'Updated Issue after it got moved to another project.' - field :create_note_email, GraphQL::STRING_TYPE, null: true, + field :create_note_email, GraphQL::Types::String, null: true, description: 'User specific email address for the issue.' field :timelogs, Types::TimelogType.connection_type, null: false, description: 'Timelogs on the issue.' - field :project_id, GraphQL::INT_TYPE, null: false, method: :project_id, + field :project_id, GraphQL::Types::Int, null: false, method: :project_id, description: 'ID of the issue project.' def author diff --git a/app/graphql/types/issue_type_enum.rb b/app/graphql/types/issue_type_enum.rb index 7dc45f78c99..6999ea270a2 100644 --- a/app/graphql/types/issue_type_enum.rb +++ b/app/graphql/types/issue_type_enum.rb @@ -5,7 +5,7 @@ module Types graphql_name 'IssueType' description 'Issue type' - ::Issue.issue_types.keys.each do |issue_type| + ::WorkItem::Type.base_types.keys.each do |issue_type| value issue_type.upcase, value: issue_type, description: "#{issue_type.titleize} issue type" end end diff --git a/app/graphql/types/issues/negated_issue_filter_input_type.rb b/app/graphql/types/issues/negated_issue_filter_input_type.rb index 88faf7e7074..e5125c554a4 100644 --- a/app/graphql/types/issues/negated_issue_filter_input_type.rb +++ b/app/graphql/types/issues/negated_issue_filter_input_type.rb @@ -5,21 +5,24 @@ module Types class NegatedIssueFilterInputType < BaseInputObject graphql_name 'NegatedIssueFilterInput' - argument :iids, [GraphQL::STRING_TYPE], + argument :iids, [GraphQL::Types::String], required: false, description: 'List of IIDs of issues to exclude. For example, `[1, 2]`.' - argument :label_name, [GraphQL::STRING_TYPE], + argument :label_name, [GraphQL::Types::String], required: false, description: 'Labels not applied to this issue.' - argument :milestone_title, [GraphQL::STRING_TYPE], + argument :milestone_title, [GraphQL::Types::String], required: false, description: 'Milestone not applied to this issue.' - argument :assignee_usernames, [GraphQL::STRING_TYPE], + argument :assignee_usernames, [GraphQL::Types::String], required: false, description: 'Usernames of users not assigned to the issue.' - argument :assignee_id, GraphQL::STRING_TYPE, + argument :assignee_id, GraphQL::Types::String, required: false, description: 'ID of a user not assigned to the issues.' + argument :milestone_wildcard_id, ::Types::NegatedMilestoneWildcardIdEnum, + required: false, + description: 'Filter by negated milestone wildcard values.' end end end diff --git a/app/graphql/types/jira_import_type.rb b/app/graphql/types/jira_import_type.rb index 6fa115933ac..0cdfc178350 100644 --- a/app/graphql/types/jira_import_type.rb +++ b/app/graphql/types/jira_import_type.rb @@ -12,13 +12,13 @@ module Types description: 'Timestamp of when the Jira import was scheduled.' field :scheduled_by, Types::UserType, null: true, description: 'User that started the Jira import.' - field :jira_project_key, GraphQL::STRING_TYPE, null: false, + field :jira_project_key, GraphQL::Types::String, null: false, description: 'Project key for the imported Jira project.' - field :imported_issues_count, GraphQL::INT_TYPE, null: false, + field :imported_issues_count, GraphQL::Types::Int, null: false, description: 'Count of issues that were successfully imported.' - field :failed_to_import_count, GraphQL::INT_TYPE, null: false, + field :failed_to_import_count, GraphQL::Types::Int, null: false, description: 'Count of issues that failed to import.' - field :total_issue_count, GraphQL::INT_TYPE, null: false, + field :total_issue_count, GraphQL::Types::Int, null: false, description: 'Total count of issues that were attempted to import.' end # rubocop: enable Graphql/AuthorizeTypes diff --git a/app/graphql/types/jira_user_type.rb b/app/graphql/types/jira_user_type.rb index 7ccb7ad6791..6e1c349726c 100644 --- a/app/graphql/types/jira_user_type.rb +++ b/app/graphql/types/jira_user_type.rb @@ -6,17 +6,17 @@ module Types class JiraUserType < BaseObject graphql_name 'JiraUser' - field :jira_account_id, GraphQL::STRING_TYPE, null: false, + field :jira_account_id, GraphQL::Types::String, null: false, description: 'Account ID of the Jira user.' - field :jira_display_name, GraphQL::STRING_TYPE, null: false, + field :jira_display_name, GraphQL::Types::String, null: false, description: 'Display name of the Jira user.' - field :jira_email, GraphQL::STRING_TYPE, null: true, + field :jira_email, GraphQL::Types::String, null: true, description: 'Email of the Jira user, returned only for users with public emails.' - field :gitlab_id, GraphQL::INT_TYPE, null: true, + field :gitlab_id, GraphQL::Types::Int, null: true, description: 'ID of the matched GitLab user.' - field :gitlab_username, GraphQL::STRING_TYPE, null: true, + field :gitlab_username, GraphQL::Types::String, null: true, description: 'Username of the matched GitLab user.' - field :gitlab_name, GraphQL::STRING_TYPE, null: true, + field :gitlab_name, GraphQL::Types::String, null: true, description: 'Name of the matched GitLab user.' end # rubocop: enable Graphql/AuthorizeTypes diff --git a/app/graphql/types/jira_users_mapping_input_type.rb b/app/graphql/types/jira_users_mapping_input_type.rb index 32640b9cb17..37fd05370c0 100644 --- a/app/graphql/types/jira_users_mapping_input_type.rb +++ b/app/graphql/types/jira_users_mapping_input_type.rb @@ -5,11 +5,11 @@ module Types graphql_name 'JiraUsersMappingInputType' argument :jira_account_id, - GraphQL::STRING_TYPE, + GraphQL::Types::String, required: true, description: 'Jira account ID of the user.' argument :gitlab_id, - GraphQL::INT_TYPE, + GraphQL::Types::Int, required: false, description: 'ID of the GitLab user.' end diff --git a/app/graphql/types/label_type.rb b/app/graphql/types/label_type.rb index 4e8718a80da..bb2d561014e 100644 --- a/app/graphql/types/label_type.rb +++ b/app/graphql/types/label_type.rb @@ -8,16 +8,16 @@ module Types authorize :read_label - field :id, GraphQL::ID_TYPE, null: false, + field :id, GraphQL::Types::ID, null: false, description: 'Label ID.' - field :description, GraphQL::STRING_TYPE, null: true, + field :description, GraphQL::Types::String, null: true, description: 'Description of the label (Markdown rendered as HTML for caching).' markdown_field :description_html, null: true - field :title, GraphQL::STRING_TYPE, null: false, + field :title, GraphQL::Types::String, null: false, description: 'Content of the label.' - field :color, GraphQL::STRING_TYPE, null: false, + field :color, GraphQL::Types::String, null: false, description: 'Background color of the label.' - field :text_color, GraphQL::STRING_TYPE, null: false, + field :text_color, GraphQL::Types::String, null: false, description: 'Text color of the label.' field :created_at, Types::TimeType, null: false, description: 'When this label was created.' diff --git a/app/graphql/types/member_interface.rb b/app/graphql/types/member_interface.rb index 6a21e51fe28..c5623cd4710 100644 --- a/app/graphql/types/member_interface.rb +++ b/app/graphql/types/member_interface.rb @@ -4,7 +4,7 @@ module Types module MemberInterface include BaseInterface - field :id, GraphQL::ID_TYPE, null: false, + field :id, GraphQL::Types::ID, null: false, description: 'ID of the member.' field :access_level, Types::AccessLevelType, null: true, diff --git a/app/graphql/types/merge_request_sort_enum.rb b/app/graphql/types/merge_request_sort_enum.rb index 92a71998d91..d75eae6abc4 100644 --- a/app/graphql/types/merge_request_sort_enum.rb +++ b/app/graphql/types/merge_request_sort_enum.rb @@ -7,5 +7,7 @@ module Types value 'MERGED_AT_ASC', 'Merge time by ascending order.', value: :merged_at_asc value 'MERGED_AT_DESC', 'Merge time by descending order.', value: :merged_at_desc + value 'CLOSED_AT_ASC', 'Closed time by ascending order.', value: :closed_at_asc + value 'CLOSED_AT_DESC', 'Closed time by descending order.', value: :closed_at_desc end end diff --git a/app/graphql/types/merge_request_type.rb b/app/graphql/types/merge_request_type.rb index 0e9df926cdd..8e6b5421ede 100644 --- a/app/graphql/types/merge_request_type.rb +++ b/app/graphql/types/merge_request_type.rb @@ -15,14 +15,14 @@ module Types present_using MergeRequestPresenter - field :id, GraphQL::ID_TYPE, null: false, + field :id, GraphQL::Types::ID, null: false, description: 'ID of the merge request.' - field :iid, GraphQL::STRING_TYPE, null: false, + field :iid, GraphQL::Types::String, null: false, description: 'Internal ID of the merge request.' - field :title, GraphQL::STRING_TYPE, null: false, + field :title, GraphQL::Types::String, null: false, description: 'Title of the merge request.' markdown_field :title_html, null: true - field :description, GraphQL::STRING_TYPE, null: true, + field :description, GraphQL::Types::String, null: true, description: 'Description of the merge request (Markdown rendered as HTML for caching).' markdown_field :description_html, null: true field :state, MergeRequestStateEnum, null: false, @@ -41,91 +41,91 @@ module Types description: 'References of the base SHA, the head SHA, and the start SHA for this merge request.' field :project, Types::ProjectType, null: false, description: 'Alias for target_project.' - field :project_id, GraphQL::INT_TYPE, null: false, method: :target_project_id, + field :project_id, GraphQL::Types::Int, null: false, method: :target_project_id, description: 'ID of the merge request project.' - field :source_project_id, GraphQL::INT_TYPE, null: true, + field :source_project_id, GraphQL::Types::Int, null: true, description: 'ID of the merge request source project.' - field :target_project_id, GraphQL::INT_TYPE, null: false, + field :target_project_id, GraphQL::Types::Int, null: false, description: 'ID of the merge request target project.' - field :source_branch, GraphQL::STRING_TYPE, null: false, + field :source_branch, GraphQL::Types::String, null: false, description: 'Source branch of the merge request.' - field :source_branch_protected, GraphQL::BOOLEAN_TYPE, null: false, calls_gitaly: true, + field :source_branch_protected, GraphQL::Types::Boolean, null: false, calls_gitaly: true, description: 'Indicates if the source branch is protected.' - field :target_branch, GraphQL::STRING_TYPE, null: false, + field :target_branch, GraphQL::Types::String, null: false, description: 'Target branch of the merge request.' - field :work_in_progress, GraphQL::BOOLEAN_TYPE, method: :work_in_progress?, null: false, + field :work_in_progress, GraphQL::Types::Boolean, method: :work_in_progress?, null: false, deprecated: { reason: 'Use `draft`', milestone: '13.12' }, description: 'Indicates if the merge request is a draft.' - field :draft, GraphQL::BOOLEAN_TYPE, method: :draft?, null: false, + field :draft, GraphQL::Types::Boolean, method: :draft?, null: false, description: 'Indicates if the merge request is a draft.' - field :merge_when_pipeline_succeeds, GraphQL::BOOLEAN_TYPE, null: true, + field :merge_when_pipeline_succeeds, GraphQL::Types::Boolean, null: true, description: 'Indicates if the merge has been set to be merged when its pipeline succeeds (MWPS).' - field :diff_head_sha, GraphQL::STRING_TYPE, null: true, + field :diff_head_sha, GraphQL::Types::String, null: true, description: 'Diff head SHA of the merge request.' field :diff_stats, [Types::DiffStatsType], null: true, calls_gitaly: true, description: 'Details about which files were changed in this merge request.' do - argument :path, GraphQL::STRING_TYPE, required: false, description: 'A specific file-path.' + argument :path, GraphQL::Types::String, required: false, description: 'A specific file-path.' end field :diff_stats_summary, Types::DiffStatsSummaryType, null: true, calls_gitaly: true, description: 'Summary of which files were changed in this merge request.' - field :merge_commit_sha, GraphQL::STRING_TYPE, null: true, + field :merge_commit_sha, GraphQL::Types::String, null: true, description: 'SHA of the merge request commit (set once merged).' - field :user_notes_count, GraphQL::INT_TYPE, null: true, + field :user_notes_count, GraphQL::Types::Int, null: true, description: 'User notes count of the merge request.', resolver: Resolvers::UserNotesCountResolver - field :user_discussions_count, GraphQL::INT_TYPE, null: true, + field :user_discussions_count, GraphQL::Types::Int, null: true, description: 'Number of user discussions in the merge request.', resolver: Resolvers::UserDiscussionsCountResolver - field :should_remove_source_branch, GraphQL::BOOLEAN_TYPE, method: :should_remove_source_branch?, null: true, + field :should_remove_source_branch, GraphQL::Types::Boolean, method: :should_remove_source_branch?, null: true, description: 'Indicates if the source branch of the merge request will be deleted after merge.' - field :force_remove_source_branch, GraphQL::BOOLEAN_TYPE, method: :force_remove_source_branch?, null: true, + field :force_remove_source_branch, GraphQL::Types::Boolean, method: :force_remove_source_branch?, null: true, description: 'Indicates if the project settings will lead to source branch deletion after merge.' - field :merge_status, GraphQL::STRING_TYPE, method: :public_merge_status, null: true, + field :merge_status, GraphQL::Types::String, method: :public_merge_status, null: true, description: 'Status of the merge request.', deprecated: { reason: :renamed, replacement: 'MergeRequest.mergeStatusEnum', milestone: '14.0' } field :merge_status_enum, ::Types::MergeRequests::MergeStatusEnum, method: :public_merge_status, null: true, description: 'Merge status of the merge request.' - field :in_progress_merge_commit_sha, GraphQL::STRING_TYPE, null: true, + field :in_progress_merge_commit_sha, GraphQL::Types::String, null: true, description: 'Commit SHA of the merge request if merge is in progress.' - field :merge_error, GraphQL::STRING_TYPE, null: true, + field :merge_error, GraphQL::Types::String, null: true, description: 'Error message due to a merge error.' - field :allow_collaboration, GraphQL::BOOLEAN_TYPE, null: true, + field :allow_collaboration, GraphQL::Types::Boolean, null: true, description: 'Indicates if members of the target project can push to the fork.' - field :should_be_rebased, GraphQL::BOOLEAN_TYPE, method: :should_be_rebased?, null: false, calls_gitaly: true, + field :should_be_rebased, GraphQL::Types::Boolean, method: :should_be_rebased?, null: false, calls_gitaly: true, description: 'Indicates if the merge request will be rebased.' - field :rebase_commit_sha, GraphQL::STRING_TYPE, null: true, + field :rebase_commit_sha, GraphQL::Types::String, null: true, description: 'Rebase commit SHA of the merge request.' - field :rebase_in_progress, GraphQL::BOOLEAN_TYPE, method: :rebase_in_progress?, null: false, calls_gitaly: true, + field :rebase_in_progress, GraphQL::Types::Boolean, method: :rebase_in_progress?, null: false, calls_gitaly: true, description: 'Indicates if there is a rebase currently in progress for the merge request.' - field :default_merge_commit_message, GraphQL::STRING_TYPE, null: true, + field :default_merge_commit_message, GraphQL::Types::String, null: true, description: 'Default merge commit message of the merge request.' - field :default_merge_commit_message_with_description, GraphQL::STRING_TYPE, null: true, + field :default_merge_commit_message_with_description, GraphQL::Types::String, null: true, description: 'Default merge commit message of the merge request with description.' - field :default_squash_commit_message, GraphQL::STRING_TYPE, null: true, calls_gitaly: true, + field :default_squash_commit_message, GraphQL::Types::String, null: true, calls_gitaly: true, description: 'Default squash commit message of the merge request.' - field :merge_ongoing, GraphQL::BOOLEAN_TYPE, method: :merge_ongoing?, null: false, + field :merge_ongoing, GraphQL::Types::Boolean, method: :merge_ongoing?, null: false, description: 'Indicates if a merge is currently occurring.' - field :source_branch_exists, GraphQL::BOOLEAN_TYPE, + field :source_branch_exists, GraphQL::Types::Boolean, null: false, calls_gitaly: true, method: :source_branch_exists?, description: 'Indicates if the source branch of the merge request exists.' - field :target_branch_exists, GraphQL::BOOLEAN_TYPE, + field :target_branch_exists, GraphQL::Types::Boolean, null: false, calls_gitaly: true, method: :target_branch_exists?, description: 'Indicates if the target branch of the merge request exists.' - field :diverged_from_target_branch, GraphQL::BOOLEAN_TYPE, + field :diverged_from_target_branch, GraphQL::Types::Boolean, null: false, calls_gitaly: true, method: :diverged_from_target_branch?, description: 'Indicates if the source branch is behind the target branch.' - field :mergeable_discussions_state, GraphQL::BOOLEAN_TYPE, null: true, + field :mergeable_discussions_state, GraphQL::Types::Boolean, null: true, description: 'Indicates if all discussions in the merge request have been resolved, allowing the merge request to be merged.' - field :web_url, GraphQL::STRING_TYPE, null: true, + field :web_url, GraphQL::Types::String, null: true, description: 'Web URL of the merge request.' - field :upvotes, GraphQL::INT_TYPE, null: false, + field :upvotes, GraphQL::Types::Int, null: false, description: 'Number of upvotes for the merge request.' - field :downvotes, GraphQL::INT_TYPE, null: false, + field :downvotes, GraphQL::Types::Int, null: false, description: 'Number of downvotes for the merge request.' field :head_pipeline, Types::Ci::PipelineType, null: true, method: :actual_head_pipeline, @@ -151,52 +151,52 @@ module Types description: 'User who created this merge request.' field :participants, Types::UserType.connection_type, null: true, complexity: 15, description: 'Participants in the merge request. This includes the author, assignees, reviewers, and users mentioned in notes.' - field :subscribed, GraphQL::BOOLEAN_TYPE, method: :subscribed?, null: false, complexity: 5, + field :subscribed, GraphQL::Types::Boolean, method: :subscribed?, null: false, complexity: 5, description: 'Indicates if the currently logged in user is subscribed to this merge request.' field :labels, Types::LabelType.connection_type, null: true, complexity: 5, description: 'Labels of the merge request.' - field :discussion_locked, GraphQL::BOOLEAN_TYPE, + field :discussion_locked, GraphQL::Types::Boolean, description: 'Indicates if comments on the merge request are locked to members only.', null: false - field :time_estimate, GraphQL::INT_TYPE, null: false, + field :time_estimate, GraphQL::Types::Int, null: false, description: 'Time estimate of the merge request.' - field :total_time_spent, GraphQL::INT_TYPE, null: false, + field :total_time_spent, GraphQL::Types::Int, null: false, description: 'Total time reported as spent on the merge request.' - field :human_time_estimate, GraphQL::STRING_TYPE, null: true, + field :human_time_estimate, GraphQL::Types::String, null: true, description: 'Human-readable time estimate of the merge request.' - field :human_total_time_spent, GraphQL::STRING_TYPE, null: true, + field :human_total_time_spent, GraphQL::Types::String, null: true, description: 'Human-readable total time reported as spent on the merge request.' - field :reference, GraphQL::STRING_TYPE, null: false, method: :to_reference, + field :reference, GraphQL::Types::String, null: false, method: :to_reference, description: 'Internal reference of the merge request. Returned in shortened format by default.' do - argument :full, GraphQL::BOOLEAN_TYPE, required: false, default_value: false, + argument :full, GraphQL::Types::Boolean, required: false, default_value: false, description: 'Boolean option specifying whether the reference should be returned in full.' end field :task_completion_status, Types::TaskCompletionStatus, null: false, description: Types::TaskCompletionStatus.description - field :commit_count, GraphQL::INT_TYPE, null: true, method: :commits_count, + field :commit_count, GraphQL::Types::Int, null: true, method: :commits_count, description: 'Number of commits in the merge request.' - field :conflicts, GraphQL::BOOLEAN_TYPE, null: false, method: :cannot_be_merged?, + field :conflicts, GraphQL::Types::Boolean, null: false, method: :cannot_be_merged?, description: 'Indicates if the merge request has conflicts.' - field :auto_merge_enabled, GraphQL::BOOLEAN_TYPE, null: false, + field :auto_merge_enabled, GraphQL::Types::Boolean, null: false, description: 'Indicates if auto merge is enabled for the merge request.' field :approved_by, Types::UserType.connection_type, null: true, description: 'Users who approved the merge request.' - field :squash_on_merge, GraphQL::BOOLEAN_TYPE, null: false, method: :squash_on_merge?, + field :squash_on_merge, GraphQL::Types::Boolean, null: false, method: :squash_on_merge?, description: 'Indicates if squash on merge is enabled.' - field :squash, GraphQL::BOOLEAN_TYPE, null: false, + field :squash, GraphQL::Types::Boolean, null: false, description: 'Indicates if squash on merge is enabled.' - field :available_auto_merge_strategies, [GraphQL::STRING_TYPE], null: true, calls_gitaly: true, + field :available_auto_merge_strategies, [GraphQL::Types::String], null: true, calls_gitaly: true, description: 'Array of available auto merge strategies.' - field :has_ci, GraphQL::BOOLEAN_TYPE, null: false, method: :has_ci?, + field :has_ci, GraphQL::Types::Boolean, null: false, method: :has_ci?, description: 'Indicates if the merge request has CI.' - field :mergeable, GraphQL::BOOLEAN_TYPE, null: false, method: :mergeable?, calls_gitaly: true, + field :mergeable, GraphQL::Types::Boolean, null: false, method: :mergeable?, calls_gitaly: true, description: 'Indicates if the merge request is mergeable.' field :commits_without_merge_commits, Types::CommitType.connection_type, null: true, calls_gitaly: true, description: 'Merge request commits excluding merge commits.' - field :security_auto_fix, GraphQL::BOOLEAN_TYPE, null: true, + field :security_auto_fix, GraphQL::Types::Boolean, null: true, description: 'Indicates if the merge request is created by @GitLab-Security-Bot.' - field :auto_merge_strategy, GraphQL::STRING_TYPE, null: true, + field :auto_merge_strategy, GraphQL::Types::String, null: true, description: 'Selected auto merge strategy.' field :merge_user, Types::UserType, null: true, description: 'User who merged this merge request.' diff --git a/app/graphql/types/metadata/kas_type.rb b/app/graphql/types/metadata/kas_type.rb index 8af4c23270b..a947986fa60 100644 --- a/app/graphql/types/metadata/kas_type.rb +++ b/app/graphql/types/metadata/kas_type.rb @@ -7,11 +7,11 @@ module Types authorize :read_instance_metadata - field :enabled, GraphQL::BOOLEAN_TYPE, null: false, + field :enabled, GraphQL::Types::Boolean, null: false, description: 'Indicates whether the Kubernetes Agent Server is enabled.' - field :version, GraphQL::STRING_TYPE, null: true, + field :version, GraphQL::Types::String, null: true, description: 'KAS version.' - field :external_url, GraphQL::STRING_TYPE, null: true, + field :external_url, GraphQL::Types::String, null: true, description: 'The URL used by the Agents to communicate with KAS.' end end diff --git a/app/graphql/types/metadata_type.rb b/app/graphql/types/metadata_type.rb index 851c2a3f1e3..ed1e697711d 100644 --- a/app/graphql/types/metadata_type.rb +++ b/app/graphql/types/metadata_type.rb @@ -6,9 +6,9 @@ module Types authorize :read_instance_metadata - field :version, GraphQL::STRING_TYPE, null: false, + field :version, GraphQL::Types::String, null: false, description: 'Version.' - field :revision, GraphQL::STRING_TYPE, null: false, + field :revision, GraphQL::Types::String, null: false, description: 'Revision.' field :kas, ::Types::Metadata::KasType, null: false, description: 'Metadata about KAS.' diff --git a/app/graphql/types/metrics/dashboard_type.rb b/app/graphql/types/metrics/dashboard_type.rb index 40d2c2f195c..04cac55894e 100644 --- a/app/graphql/types/metrics/dashboard_type.rb +++ b/app/graphql/types/metrics/dashboard_type.rb @@ -7,10 +7,10 @@ module Types class DashboardType < ::Types::BaseObject graphql_name 'MetricsDashboard' - field :path, GraphQL::STRING_TYPE, null: true, + field :path, GraphQL::Types::String, null: true, description: 'Path to a file with the dashboard definition.' - field :schema_validation_warnings, [GraphQL::STRING_TYPE], null: true, + field :schema_validation_warnings, [GraphQL::Types::String], null: true, description: 'Dashboard schema validation warnings.' field :annotations, Types::Metrics::Dashboards::AnnotationType.connection_type, null: true, diff --git a/app/graphql/types/metrics/dashboards/annotation_type.rb b/app/graphql/types/metrics/dashboards/annotation_type.rb index b9e040dd063..fb35f2bd9a1 100644 --- a/app/graphql/types/metrics/dashboards/annotation_type.rb +++ b/app/graphql/types/metrics/dashboards/annotation_type.rb @@ -7,13 +7,13 @@ module Types authorize :read_metrics_dashboard_annotation graphql_name 'MetricsDashboardAnnotation' - field :description, GraphQL::STRING_TYPE, null: true, + field :description, GraphQL::Types::String, null: true, description: 'Description of the annotation.' - field :id, GraphQL::ID_TYPE, null: false, + field :id, GraphQL::Types::ID, null: false, description: 'ID of the annotation.' - field :panel_id, GraphQL::STRING_TYPE, null: true, + field :panel_id, GraphQL::Types::String, null: true, description: 'ID of a dashboard panel to which the annotation should be scoped.' field :starting_at, Types::TimeType, null: true, diff --git a/app/graphql/types/milestone_stats_type.rb b/app/graphql/types/milestone_stats_type.rb index e313b880e0d..6d8b7deb8e7 100644 --- a/app/graphql/types/milestone_stats_type.rb +++ b/app/graphql/types/milestone_stats_type.rb @@ -7,10 +7,10 @@ module Types authorize :read_milestone - field :total_issues_count, GraphQL::INT_TYPE, null: true, + field :total_issues_count, GraphQL::Types::Int, null: true, description: 'Total number of issues associated with the milestone.' - field :closed_issues_count, GraphQL::INT_TYPE, null: true, + field :closed_issues_count, GraphQL::Types::Int, null: true, description: 'Number of closed issues associated with the milestone.' end end diff --git a/app/graphql/types/milestone_type.rb b/app/graphql/types/milestone_type.rb index 27bc77b4da1..18e4a5d33e3 100644 --- a/app/graphql/types/milestone_type.rb +++ b/app/graphql/types/milestone_type.rb @@ -11,25 +11,25 @@ module Types alias_method :milestone, :object - field :id, GraphQL::ID_TYPE, null: false, + field :id, GraphQL::Types::ID, null: false, description: 'ID of the milestone.' - field :iid, GraphQL::ID_TYPE, null: false, + field :iid, GraphQL::Types::ID, null: false, description: "Internal ID of the milestone." - field :title, GraphQL::STRING_TYPE, null: false, + field :title, GraphQL::Types::String, null: false, description: 'Title of the milestone.' - field :description, GraphQL::STRING_TYPE, null: true, + field :description, GraphQL::Types::String, null: true, description: 'Description of the milestone.' field :state, Types::MilestoneStateEnum, null: false, description: 'State of the milestone.' - field :expired, GraphQL::BOOLEAN_TYPE, null: false, + field :expired, GraphQL::Types::Boolean, null: false, description: 'Expired state of the milestone (a milestone is expired when the due date is past the current date). Defaults to `false` when due date has not been set.' - field :web_path, GraphQL::STRING_TYPE, null: false, method: :milestone_path, + field :web_path, GraphQL::Types::String, null: false, method: :milestone_path, description: 'Web path of the milestone.' field :due_date, Types::TimeType, null: true, @@ -44,15 +44,15 @@ module Types field :updated_at, Types::TimeType, null: false, description: 'Timestamp of last milestone update.' - field :project_milestone, GraphQL::BOOLEAN_TYPE, null: false, + field :project_milestone, GraphQL::Types::Boolean, null: false, description: 'Indicates if milestone is at project level.', method: :project_milestone? - field :group_milestone, GraphQL::BOOLEAN_TYPE, null: false, + field :group_milestone, GraphQL::Types::Boolean, null: false, description: 'Indicates if milestone is at group level.', method: :group_milestone? - field :subgroup_milestone, GraphQL::BOOLEAN_TYPE, null: false, + field :subgroup_milestone, GraphQL::Types::Boolean, null: false, description: 'Indicates if milestone is at subgroup level.', method: :subgroup_milestone? diff --git a/app/graphql/types/milestone_wildcard_id_enum.rb b/app/graphql/types/milestone_wildcard_id_enum.rb new file mode 100644 index 00000000000..b5b339b1e5b --- /dev/null +++ b/app/graphql/types/milestone_wildcard_id_enum.rb @@ -0,0 +1,13 @@ +# frozen_string_literal: true + +module Types + class MilestoneWildcardIdEnum < BaseEnum + graphql_name 'MilestoneWildcardId' + description 'Milestone ID wildcard values' + + value 'NONE', 'No milestone is assigned.' + value 'ANY', 'A milestone is assigned.' + value 'STARTED', 'An open, started milestone (start date <= today).' + value 'UPCOMING', 'An open milestone due in the future (due date >= today).' + end +end diff --git a/app/graphql/types/mutation_type.rb b/app/graphql/types/mutation_type.rb index df693fafbb9..293d19d068a 100644 --- a/app/graphql/types/mutation_type.rb +++ b/app/graphql/types/mutation_type.rb @@ -99,14 +99,18 @@ module Types mount_mutation Mutations::Ci::CiCdSettingsUpdate mount_mutation Mutations::Ci::Job::Play mount_mutation Mutations::Ci::Job::Retry + mount_mutation Mutations::Ci::Job::Cancel + mount_mutation Mutations::Ci::Job::Unschedule mount_mutation Mutations::Ci::JobTokenScope::AddProject mount_mutation Mutations::Ci::JobTokenScope::RemoveProject mount_mutation Mutations::Ci::Runner::Update, feature_flag: :runner_graphql_query mount_mutation Mutations::Ci::Runner::Delete, feature_flag: :runner_graphql_query mount_mutation Mutations::Ci::RunnersRegistrationToken::Reset, feature_flag: :runner_graphql_query mount_mutation Mutations::Namespace::PackageSettings::Update + mount_mutation Mutations::Groups::Update mount_mutation Mutations::UserCallouts::Create mount_mutation Mutations::Packages::Destroy + mount_mutation Mutations::Packages::DestroyFile mount_mutation Mutations::Echo end end diff --git a/app/graphql/types/namespace/package_settings_type.rb b/app/graphql/types/namespace/package_settings_type.rb index af091515979..d573cc9ded5 100644 --- a/app/graphql/types/namespace/package_settings_type.rb +++ b/app/graphql/types/namespace/package_settings_type.rb @@ -8,9 +8,9 @@ module Types authorize :read_package_settings - field :maven_duplicates_allowed, GraphQL::BOOLEAN_TYPE, null: false, description: 'Indicates whether duplicate Maven packages are allowed for this namespace.' + field :maven_duplicates_allowed, GraphQL::Types::Boolean, null: false, description: 'Indicates whether duplicate Maven packages are allowed for this namespace.' field :maven_duplicate_exception_regex, Types::UntrustedRegexp, null: true, description: 'When maven_duplicates_allowed is false, you can publish duplicate packages with names that match this regex. Otherwise, this setting has no effect.' - field :generic_duplicates_allowed, GraphQL::BOOLEAN_TYPE, null: false, description: 'Indicates whether duplicate generic packages are allowed for this namespace.' + field :generic_duplicates_allowed, GraphQL::Types::Boolean, null: false, description: 'Indicates whether duplicate generic packages are allowed for this namespace.' field :generic_duplicate_exception_regex, Types::UntrustedRegexp, null: true, description: 'When generic_duplicates_allowed is false, you can publish duplicate packages with names that match this regex. Otherwise, this setting has no effect.' end end diff --git a/app/graphql/types/namespace/shared_runners_setting_enum.rb b/app/graphql/types/namespace/shared_runners_setting_enum.rb new file mode 100644 index 00000000000..4773e414aeb --- /dev/null +++ b/app/graphql/types/namespace/shared_runners_setting_enum.rb @@ -0,0 +1,13 @@ +# frozen_string_literal: true + +module Types + class Namespace::SharedRunnersSettingEnum < BaseEnum + graphql_name 'SharedRunnersSetting' + + ::Namespace::SHARED_RUNNERS_SETTINGS.each do |type| + value type.upcase, + description: "Sharing of runners is #{type.tr('_', ' ')}.", + value: type + end + end +end diff --git a/app/graphql/types/namespace_type.rb b/app/graphql/types/namespace_type.rb index 96eff8a46b0..4cc543f477a 100644 --- a/app/graphql/types/namespace_type.rb +++ b/app/graphql/types/namespace_type.rb @@ -6,27 +6,27 @@ module Types authorize :read_namespace - field :id, GraphQL::ID_TYPE, null: false, + field :id, GraphQL::Types::ID, null: false, description: 'ID of the namespace.' - field :name, GraphQL::STRING_TYPE, null: false, + field :name, GraphQL::Types::String, null: false, description: 'Name of the namespace.' - field :path, GraphQL::STRING_TYPE, null: false, + field :path, GraphQL::Types::String, null: false, description: 'Path of the namespace.' - field :full_name, GraphQL::STRING_TYPE, null: false, + field :full_name, GraphQL::Types::String, null: false, description: 'Full name of the namespace.' - field :full_path, GraphQL::ID_TYPE, null: false, + field :full_path, GraphQL::Types::ID, null: false, description: 'Full path of the namespace.' - field :description, GraphQL::STRING_TYPE, null: true, + field :description, GraphQL::Types::String, null: true, description: 'Description of the namespace.' markdown_field :description_html, null: true - field :visibility, GraphQL::STRING_TYPE, null: true, + field :visibility, GraphQL::Types::String, null: true, description: 'Visibility of the namespace.' - field :lfs_enabled, GraphQL::BOOLEAN_TYPE, null: true, method: :lfs_enabled?, + field :lfs_enabled, GraphQL::Types::Boolean, null: true, method: :lfs_enabled?, description: 'Indicates if Large File Storage (LFS) is enabled for namespace.' - field :request_access_enabled, GraphQL::BOOLEAN_TYPE, null: true, + field :request_access_enabled, GraphQL::Types::Boolean, null: true, description: 'Indicates if users can request access to namespace.' field :root_storage_statistics, Types::RootStorageStatisticsType, @@ -42,6 +42,11 @@ module Types null: true, description: 'The package settings for the namespace.' + field :shared_runners_setting, + Types::Namespace::SharedRunnersSettingEnum, + null: true, + description: "Shared runners availability for the namespace and its descendants." + def root_storage_statistics Gitlab::Graphql::Loaders::BatchRootStorageStatisticsLoader.new(object.id).find end diff --git a/app/graphql/types/negated_milestone_wildcard_id_enum.rb b/app/graphql/types/negated_milestone_wildcard_id_enum.rb new file mode 100644 index 00000000000..ca27a6c7b6e --- /dev/null +++ b/app/graphql/types/negated_milestone_wildcard_id_enum.rb @@ -0,0 +1,11 @@ +# frozen_string_literal: true + +module Types + class NegatedMilestoneWildcardIdEnum < BaseEnum + graphql_name 'NegatedMilestoneWildcardId' + description 'Negated Milestone ID wildcard values' + + value 'STARTED', 'An open, started milestone (start date <= today).' + value 'UPCOMING', 'An open milestone due in the future (due date >= today).' + end +end diff --git a/app/graphql/types/notes/diff_image_position_input_type.rb b/app/graphql/types/notes/diff_image_position_input_type.rb index dd5c8f20cc3..d56c67bbec8 100644 --- a/app/graphql/types/notes/diff_image_position_input_type.rb +++ b/app/graphql/types/notes/diff_image_position_input_type.rb @@ -5,13 +5,13 @@ module Types class DiffImagePositionInputType < DiffPositionBaseInputType graphql_name 'DiffImagePositionInput' - argument :x, GraphQL::INT_TYPE, required: true, + argument :x, GraphQL::Types::Int, required: true, description: copy_field_description(Types::Notes::DiffPositionType, :x) - argument :y, GraphQL::INT_TYPE, required: true, + argument :y, GraphQL::Types::Int, required: true, description: copy_field_description(Types::Notes::DiffPositionType, :y) - argument :width, GraphQL::INT_TYPE, required: true, + argument :width, GraphQL::Types::Int, required: true, description: copy_field_description(Types::Notes::DiffPositionType, :width) - argument :height, GraphQL::INT_TYPE, required: true, + argument :height, GraphQL::Types::Int, required: true, description: copy_field_description(Types::Notes::DiffPositionType, :height) end end diff --git a/app/graphql/types/notes/diff_position_base_input_type.rb b/app/graphql/types/notes/diff_position_base_input_type.rb index c8f9f9028cc..e773fbbc8a1 100644 --- a/app/graphql/types/notes/diff_position_base_input_type.rb +++ b/app/graphql/types/notes/diff_position_base_input_type.rb @@ -3,11 +3,11 @@ module Types module Notes class DiffPositionBaseInputType < BaseInputObject - argument :head_sha, GraphQL::STRING_TYPE, required: true, + argument :head_sha, GraphQL::Types::String, required: true, description: copy_field_description(Types::DiffRefsType, :head_sha) - argument :base_sha, GraphQL::STRING_TYPE, required: false, + argument :base_sha, GraphQL::Types::String, required: false, description: copy_field_description(Types::DiffRefsType, :base_sha) - argument :start_sha, GraphQL::STRING_TYPE, required: true, + argument :start_sha, GraphQL::Types::String, required: true, description: copy_field_description(Types::DiffRefsType, :start_sha) argument :paths, diff --git a/app/graphql/types/notes/diff_position_input_type.rb b/app/graphql/types/notes/diff_position_input_type.rb index 7ec5fd9e086..18ce6672d14 100644 --- a/app/graphql/types/notes/diff_position_input_type.rb +++ b/app/graphql/types/notes/diff_position_input_type.rb @@ -5,9 +5,9 @@ module Types class DiffPositionInputType < DiffPositionBaseInputType graphql_name 'DiffPositionInput' - argument :old_line, GraphQL::INT_TYPE, required: false, + argument :old_line, GraphQL::Types::Int, required: false, description: copy_field_description(Types::Notes::DiffPositionType, :old_line) - argument :new_line, GraphQL::INT_TYPE, required: false, + argument :new_line, GraphQL::Types::Int, required: false, description: copy_field_description(Types::Notes::DiffPositionType, :new_line) end end diff --git a/app/graphql/types/notes/diff_position_type.rb b/app/graphql/types/notes/diff_position_type.rb index 67747a13dcf..9c756d56b97 100644 --- a/app/graphql/types/notes/diff_position_type.rb +++ b/app/graphql/types/notes/diff_position_type.rb @@ -10,29 +10,29 @@ module Types field :diff_refs, Types::DiffRefsType, null: false, description: 'Information about the branch, HEAD, and base at the time of commenting.' - field :file_path, GraphQL::STRING_TYPE, null: false, + field :file_path, GraphQL::Types::String, null: false, description: 'Path of the file that was changed.' - field :old_path, GraphQL::STRING_TYPE, null: true, + field :old_path, GraphQL::Types::String, null: true, description: 'Path of the file on the start SHA.' - field :new_path, GraphQL::STRING_TYPE, null: true, + field :new_path, GraphQL::Types::String, null: true, description: 'Path of the file on the HEAD SHA.' field :position_type, Types::Notes::PositionTypeEnum, null: false, description: 'Type of file the position refers to.' # Fields for text positions - field :old_line, GraphQL::INT_TYPE, null: true, + field :old_line, GraphQL::Types::Int, null: true, description: 'Line on start SHA that was changed.' - field :new_line, GraphQL::INT_TYPE, null: true, + field :new_line, GraphQL::Types::Int, null: true, description: 'Line on HEAD SHA that was changed.' # Fields for image positions - field :x, GraphQL::INT_TYPE, null: true, + field :x, GraphQL::Types::Int, null: true, description: 'X position of the note.' - field :y, GraphQL::INT_TYPE, null: true, + field :y, GraphQL::Types::Int, null: true, description: 'Y position of the note.' - field :width, GraphQL::INT_TYPE, null: true, + field :width, GraphQL::Types::Int, null: true, description: 'Total width of the image.' - field :height, GraphQL::INT_TYPE, null: true, + field :height, GraphQL::Types::Int, null: true, description: 'Total height of the image.' def old_line diff --git a/app/graphql/types/notes/note_type.rb b/app/graphql/types/notes/note_type.rb index 751cf7c10f1..fa33428114c 100644 --- a/app/graphql/types/notes/note_type.rb +++ b/app/graphql/types/notes/note_type.rb @@ -22,13 +22,13 @@ module Types null: false, description: 'User who wrote this note.' - field :system, GraphQL::BOOLEAN_TYPE, + field :system, GraphQL::Types::Boolean, null: false, description: 'Indicates whether this note was created by the system or by a user.' - field :system_note_icon_name, GraphQL::STRING_TYPE, null: true, + field :system_note_icon_name, GraphQL::Types::String, null: true, description: 'Name of the icon corresponding to a system note.' - field :body, GraphQL::STRING_TYPE, + field :body, GraphQL::Types::String, null: false, method: :note, description: 'Content of the note.' @@ -43,10 +43,10 @@ module Types description: 'The discussion this note is a part of.' field :position, Types::Notes::DiffPositionType, null: true, description: 'The position of this note on a diff.' - field :confidential, GraphQL::BOOLEAN_TYPE, null: true, + field :confidential, GraphQL::Types::Boolean, null: true, description: 'Indicates if this note is confidential.', method: :confidential? - field :url, GraphQL::STRING_TYPE, + field :url, GraphQL::Types::String, null: true, description: 'URL to view this Note in the Web UI.' diff --git a/app/graphql/types/notes/update_diff_image_position_input_type.rb b/app/graphql/types/notes/update_diff_image_position_input_type.rb index ab27f6b9ad3..0c6e4a16434 100644 --- a/app/graphql/types/notes/update_diff_image_position_input_type.rb +++ b/app/graphql/types/notes/update_diff_image_position_input_type.rb @@ -6,19 +6,19 @@ module Types class UpdateDiffImagePositionInputType < BaseInputObject graphql_name 'UpdateDiffImagePositionInput' - argument :x, GraphQL::INT_TYPE, + argument :x, GraphQL::Types::Int, required: false, description: copy_field_description(Types::Notes::DiffPositionType, :x) - argument :y, GraphQL::INT_TYPE, + argument :y, GraphQL::Types::Int, required: false, description: copy_field_description(Types::Notes::DiffPositionType, :y) - argument :width, GraphQL::INT_TYPE, + argument :width, GraphQL::Types::Int, required: false, description: copy_field_description(Types::Notes::DiffPositionType, :width) - argument :height, GraphQL::INT_TYPE, + argument :height, GraphQL::Types::Int, required: false, description: copy_field_description(Types::Notes::DiffPositionType, :height) diff --git a/app/graphql/types/packages/composer/json_type.rb b/app/graphql/types/packages/composer/json_type.rb index b7aa32f0170..d2bd62ca74d 100644 --- a/app/graphql/types/packages/composer/json_type.rb +++ b/app/graphql/types/packages/composer/json_type.rb @@ -8,10 +8,10 @@ module Types graphql_name 'PackageComposerJsonType' description 'Represents a composer JSON file' - field :name, GraphQL::STRING_TYPE, null: true, description: 'The name set in the Composer JSON file.' - field :type, GraphQL::STRING_TYPE, null: true, description: 'The type set in the Composer JSON file.' - field :license, GraphQL::STRING_TYPE, null: true, description: 'The license set in the Composer JSON file.' - field :version, GraphQL::STRING_TYPE, null: true, description: 'The version set in the Composer JSON file.' + field :name, GraphQL::Types::String, null: true, description: 'The name set in the Composer JSON file.' + field :type, GraphQL::Types::String, null: true, description: 'The type set in the Composer JSON file.' + field :license, GraphQL::Types::String, null: true, description: 'The license set in the Composer JSON file.' + field :version, GraphQL::Types::String, null: true, description: 'The version set in the Composer JSON file.' end end end diff --git a/app/graphql/types/packages/composer/metadatum_type.rb b/app/graphql/types/packages/composer/metadatum_type.rb index 9d4ce3cebd4..092e729ec56 100644 --- a/app/graphql/types/packages/composer/metadatum_type.rb +++ b/app/graphql/types/packages/composer/metadatum_type.rb @@ -9,7 +9,7 @@ module Types authorize :read_package - field :target_sha, GraphQL::STRING_TYPE, null: false, description: 'Target SHA of the package.' + field :target_sha, GraphQL::Types::String, null: false, description: 'Target SHA of the package.' field :composer_json, Types::Packages::Composer::JsonType, null: false, description: 'Data of the Composer JSON file.' end end diff --git a/app/graphql/types/packages/conan/file_metadatum_type.rb b/app/graphql/types/packages/conan/file_metadatum_type.rb index 97d5abe6ba4..9a26fd5de51 100644 --- a/app/graphql/types/packages/conan/file_metadatum_type.rb +++ b/app/graphql/types/packages/conan/file_metadatum_type.rb @@ -12,9 +12,9 @@ module Types authorize :read_package field :id, ::Types::GlobalIDType[::Packages::Conan::FileMetadatum], null: false, description: 'ID of the metadatum.' - field :recipe_revision, GraphQL::STRING_TYPE, null: false, description: 'Revision of the Conan recipe.' - field :package_revision, GraphQL::STRING_TYPE, null: true, description: 'Revision of the package.' - field :conan_package_reference, GraphQL::STRING_TYPE, null: true, description: 'Reference of the Conan package.' + field :recipe_revision, GraphQL::Types::String, null: false, description: 'Revision of the Conan recipe.' + field :package_revision, GraphQL::Types::String, null: true, description: 'Revision of the package.' + field :conan_package_reference, GraphQL::Types::String, null: true, description: 'Reference of the Conan package.' field :conan_file_type, ::Types::Packages::Conan::MetadatumFileTypeEnum, null: false, description: 'Type of the Conan file.' end end diff --git a/app/graphql/types/packages/conan/metadatum_type.rb b/app/graphql/types/packages/conan/metadatum_type.rb index 00b84235d27..cdfd0aa4483 100644 --- a/app/graphql/types/packages/conan/metadatum_type.rb +++ b/app/graphql/types/packages/conan/metadatum_type.rb @@ -12,10 +12,10 @@ module Types field :id, ::Types::GlobalIDType[::Packages::Conan::Metadatum], null: false, description: 'ID of the metadatum.' field :created_at, Types::TimeType, null: false, description: 'Date of creation.' field :updated_at, Types::TimeType, null: false, description: 'Date of most recent update.' - field :package_username, GraphQL::STRING_TYPE, null: false, description: 'Username of the Conan package.' - field :package_channel, GraphQL::STRING_TYPE, null: false, description: 'Channel of the Conan package.' - field :recipe, GraphQL::STRING_TYPE, null: false, description: 'Recipe of the Conan package.' - field :recipe_path, GraphQL::STRING_TYPE, null: false, description: 'Recipe path of the Conan package.' + field :package_username, GraphQL::Types::String, null: false, description: 'Username of the Conan package.' + field :package_channel, GraphQL::Types::String, null: false, description: 'Channel of the Conan package.' + field :recipe, GraphQL::Types::String, null: false, description: 'Recipe of the Conan package.' + field :recipe_path, GraphQL::Types::String, null: false, description: 'Recipe path of the Conan package.' end end end diff --git a/app/graphql/types/packages/dependency_link_metadata_type.rb b/app/graphql/types/packages/dependency_link_metadata_type.rb new file mode 100644 index 00000000000..c13069c7889 --- /dev/null +++ b/app/graphql/types/packages/dependency_link_metadata_type.rb @@ -0,0 +1,23 @@ +# frozen_string_literal: true + +module Types + module Packages + class DependencyLinkMetadataType < BaseUnion + graphql_name 'DependencyLinkMetadata' + description 'Represents metadata associated with a dependency link' + + possible_types ::Types::Packages::Nuget::DependencyLinkMetadatumType + + def self.resolve_type(object, context) + case object + when ::Packages::Nuget::DependencyLinkMetadatum + ::Types::Packages::Nuget::DependencyLinkMetadatumType + else + # NOTE: This method must be kept in sync with `PackageDependencyLinkType#metadata`, + # which must never produce data that this discriminator cannot handle. + raise 'Unsupported metadata type' + end + end + end + end +end diff --git a/app/graphql/types/packages/maven/metadatum_type.rb b/app/graphql/types/packages/maven/metadatum_type.rb index bdb250ef96b..eb3829648d1 100644 --- a/app/graphql/types/packages/maven/metadatum_type.rb +++ b/app/graphql/types/packages/maven/metadatum_type.rb @@ -12,10 +12,10 @@ module Types field :id, ::Types::GlobalIDType[::Packages::Maven::Metadatum], null: false, description: 'ID of the metadatum.' field :created_at, Types::TimeType, null: false, description: 'Date of creation.' field :updated_at, Types::TimeType, null: false, description: 'Date of most recent update.' - field :path, GraphQL::STRING_TYPE, null: false, description: 'Path of the Maven package.' - field :app_group, GraphQL::STRING_TYPE, null: false, description: 'App group of the Maven package.' - field :app_version, GraphQL::STRING_TYPE, null: true, description: 'App version of the Maven package.' - field :app_name, GraphQL::STRING_TYPE, null: false, description: 'App name of the Maven package.' + field :path, GraphQL::Types::String, null: false, description: 'Path of the Maven package.' + field :app_group, GraphQL::Types::String, null: false, description: 'App group of the Maven package.' + field :app_version, GraphQL::Types::String, null: true, description: 'App version of the Maven package.' + field :app_name, GraphQL::Types::String, null: false, description: 'App name of the Maven package.' end end end diff --git a/app/graphql/types/packages/nuget/dependency_link_metadatum_type.rb b/app/graphql/types/packages/nuget/dependency_link_metadatum_type.rb new file mode 100644 index 00000000000..f410e62b56a --- /dev/null +++ b/app/graphql/types/packages/nuget/dependency_link_metadatum_type.rb @@ -0,0 +1,17 @@ +# frozen_string_literal: true + +module Types + module Packages + module Nuget + class DependencyLinkMetadatumType < BaseObject + graphql_name 'NugetDependencyLinkMetadata' + description 'Nuget dependency link metadata' + + authorize :read_package + + field :id, ::Types::GlobalIDType[::Packages::Nuget::DependencyLinkMetadatum], null: false, description: 'ID of the metadatum.' + field :target_framework, GraphQL::Types::String, null: false, description: 'Target framework of the dependency link package.' + end + end + end +end diff --git a/app/graphql/types/packages/nuget/metadatum_type.rb b/app/graphql/types/packages/nuget/metadatum_type.rb index 63fae2fb197..ed9d97724af 100644 --- a/app/graphql/types/packages/nuget/metadatum_type.rb +++ b/app/graphql/types/packages/nuget/metadatum_type.rb @@ -10,9 +10,9 @@ module Types authorize :read_package field :id, ::Types::GlobalIDType[::Packages::Nuget::Metadatum], null: false, description: 'ID of the metadatum.' - field :license_url, GraphQL::STRING_TYPE, null: false, description: 'License URL of the Nuget package.' - field :project_url, GraphQL::STRING_TYPE, null: false, description: 'Project URL of the Nuget package.' - field :icon_url, GraphQL::STRING_TYPE, null: false, description: 'Icon URL of the Nuget package.' + field :license_url, GraphQL::Types::String, null: false, description: 'License URL of the Nuget package.' + field :project_url, GraphQL::Types::String, null: false, description: 'Project URL of the Nuget package.' + field :icon_url, GraphQL::Types::String, null: false, description: 'Icon URL of the Nuget package.' end end end diff --git a/app/graphql/types/packages/package_dependency_link_type.rb b/app/graphql/types/packages/package_dependency_link_type.rb new file mode 100644 index 00000000000..eceb8319748 --- /dev/null +++ b/app/graphql/types/packages/package_dependency_link_type.rb @@ -0,0 +1,40 @@ +# frozen_string_literal: true + +module Types + module Packages + class PackageDependencyLinkType < BaseObject + graphql_name 'PackageDependencyLink' + description 'Represents a package dependency link' + authorize :read_package + + field :id, ::Types::GlobalIDType[::Packages::DependencyLink], null: false, description: 'ID of the dependency link.' + field :dependency_type, Types::Packages::PackageDependencyTypeEnum, null: false, description: 'Dependency type.' + field :dependency, Types::Packages::PackageDependencyType, null: true, description: 'Dependency.' + field :metadata, Types::Packages::DependencyLinkMetadataType, null: true, description: 'Dependency link metadata.' + + # NOTE: This method must be kept in sync with the union + # type: `Types::Packages::DependencyLinkMetadata`. + # + # `Types::Packages::DependencyLinkMetadata.resolve_type(metadata, ctx)` must never raise. + def metadata + model_class = case object.package.package_type + when 'nuget' + ::Packages::Nuget::DependencyLinkMetadatum + end + + return unless model_class + + # rubocop: disable CodeReuse/ActiveRecord + BatchLoader::GraphQL.for(object.id).batch do |ids, loader| + results = model_class.where(dependency_link_id: ids) + results.each { |record| loader.call(record.dependency_link_id, record) } + end + # rubocop: enable CodeReuse/ActiveRecord + end + + def dependency + ::Gitlab::Graphql::Loaders::BatchModelLoader.new(::Packages::Dependency, object.dependency_id).find + end + end + end +end diff --git a/app/graphql/types/packages/package_dependency_type.rb b/app/graphql/types/packages/package_dependency_type.rb new file mode 100644 index 00000000000..dcbc9fa3784 --- /dev/null +++ b/app/graphql/types/packages/package_dependency_type.rb @@ -0,0 +1,16 @@ +# frozen_string_literal: true +# this model does not have any kind of authorization so we disable it +# rubocop:disable Graphql/AuthorizeTypes + +module Types + module Packages + class PackageDependencyType < BaseObject + graphql_name 'PackageDependency' + description 'Represents a package dependency.' + + field :id, ::Types::GlobalIDType[::Packages::Dependency], null: false, description: 'ID of the dependency.' + field :name, GraphQL::Types::String, null: false, description: 'Name of the dependency.' + field :version_pattern, GraphQL::Types::String, null: false, description: 'Version pattern of the dependency.' + end + end +end diff --git a/app/graphql/types/packages/package_dependency_type_enum.rb b/app/graphql/types/packages/package_dependency_type_enum.rb new file mode 100644 index 00000000000..0e98d149b9a --- /dev/null +++ b/app/graphql/types/packages/package_dependency_type_enum.rb @@ -0,0 +1,13 @@ +# frozen_string_literal: true + +module Types + module Packages + class PackageDependencyTypeEnum < BaseEnum + graphql_name 'PackageDependencyType' + + ::Packages::DependencyLink.dependency_types.keys.each do |type| + value type.to_s.underscore.upcase, description: "#{type} dependency type", value: type.to_s + end + end + end +end diff --git a/app/graphql/types/packages/package_details_type.rb b/app/graphql/types/packages/package_details_type.rb index 510b7e2ba41..f52b1f02519 100644 --- a/app/graphql/types/packages/package_details_type.rb +++ b/app/graphql/types/packages/package_details_type.rb @@ -12,6 +12,8 @@ module Types field :package_files, Types::Packages::PackageFileType.connection_type, null: true, description: 'Package files.' + field :dependency_links, Types::Packages::PackageDependencyLinkType.connection_type, null: true, description: 'Dependency link.' + def versions object.versions end diff --git a/app/graphql/types/packages/package_file_type.rb b/app/graphql/types/packages/package_file_type.rb index e9e38559626..f77c40de8d8 100644 --- a/app/graphql/types/packages/package_file_type.rb +++ b/app/graphql/types/packages/package_file_type.rb @@ -10,12 +10,12 @@ module Types field :id, ::Types::GlobalIDType[::Packages::PackageFile], null: false, description: 'ID of the file.' field :created_at, Types::TimeType, null: false, description: 'The created date.' field :updated_at, Types::TimeType, null: false, description: 'The updated date.' - field :size, GraphQL::STRING_TYPE, null: false, description: 'Size of the package file.' - field :file_name, GraphQL::STRING_TYPE, null: false, description: 'Name of the package file.' - field :download_path, GraphQL::STRING_TYPE, null: false, description: 'Download path of the package file.' - field :file_md5, GraphQL::STRING_TYPE, null: true, description: 'Md5 of the package file.' - field :file_sha1, GraphQL::STRING_TYPE, null: true, description: 'Sha1 of the package file.' - field :file_sha256, GraphQL::STRING_TYPE, null: true, description: 'Sha256 of the package file.' + field :size, GraphQL::Types::String, null: false, description: 'Size of the package file.' + field :file_name, GraphQL::Types::String, null: false, description: 'Name of the package file.' + field :download_path, GraphQL::Types::String, null: false, description: 'Download path of the package file.' + field :file_md5, GraphQL::Types::String, null: true, description: 'Md5 of the package file.' + field :file_sha1, GraphQL::Types::String, null: true, description: 'Sha1 of the package file.' + field :file_sha256, GraphQL::Types::String, null: true, description: 'Sha256 of the package file.' field :file_metadata, Types::Packages::FileMetadataType, null: true, description: 'File metadata.' diff --git a/app/graphql/types/packages/package_tag_type.rb b/app/graphql/types/packages/package_tag_type.rb index a05ce03da67..450f3fc8e9c 100644 --- a/app/graphql/types/packages/package_tag_type.rb +++ b/app/graphql/types/packages/package_tag_type.rb @@ -7,8 +7,8 @@ module Types description 'Represents a package tag' authorize :read_package - field :id, GraphQL::ID_TYPE, null: false, description: 'The ID of the tag.' - field :name, GraphQL::STRING_TYPE, null: false, description: 'The name of the tag.' + field :id, GraphQL::Types::ID, null: false, description: 'The ID of the tag.' + field :name, GraphQL::Types::String, null: false, description: 'The name of the tag.' field :created_at, Types::TimeType, null: false, description: 'The created date.' field :updated_at, Types::TimeType, null: false, description: 'The updated date.' end diff --git a/app/graphql/types/packages/package_type.rb b/app/graphql/types/packages/package_type.rb index ee6785e3555..b8654ebd2c6 100644 --- a/app/graphql/types/packages/package_type.rb +++ b/app/graphql/types/packages/package_type.rb @@ -11,10 +11,10 @@ module Types field :id, ::Types::GlobalIDType[::Packages::Package], null: false, description: 'ID of the package.' - field :name, GraphQL::STRING_TYPE, null: false, description: 'Name of the package.' + field :name, GraphQL::Types::String, null: false, description: 'Name of the package.' field :created_at, Types::TimeType, null: false, description: 'Date of creation.' field :updated_at, Types::TimeType, null: false, description: 'Date of most recent update.' - field :version, GraphQL::STRING_TYPE, null: true, description: 'Version string.' + field :version, GraphQL::Types::String, null: true, description: 'Version string.' field :package_type, Types::Packages::PackageTypeEnum, null: false, description: 'Package type.' field :tags, Types::Packages::PackageTagType.connection_type, null: true, description: 'Package tags.' field :project, Types::ProjectType, null: false, description: 'Project where the package is stored.' diff --git a/app/graphql/types/packages/pypi/metadatum_type.rb b/app/graphql/types/packages/pypi/metadatum_type.rb index 031d3572197..63452d8ab6e 100644 --- a/app/graphql/types/packages/pypi/metadatum_type.rb +++ b/app/graphql/types/packages/pypi/metadatum_type.rb @@ -10,7 +10,7 @@ module Types authorize :read_package field :id, ::Types::GlobalIDType[::Packages::Pypi::Metadatum], null: false, description: 'ID of the metadatum.' - field :required_python, GraphQL::STRING_TYPE, null: true, description: 'Required Python version of the Pypi package.' + field :required_python, GraphQL::Types::String, null: true, description: 'Required Python version of the Pypi package.' end end end diff --git a/app/graphql/types/permission_types/base_permission_type.rb b/app/graphql/types/permission_types/base_permission_type.rb index deb8560bd79..a2cefb872c9 100644 --- a/app/graphql/types/permission_types/base_permission_type.rb +++ b/app/graphql/types/permission_types/base_permission_type.rb @@ -24,7 +24,7 @@ module Types def self.permission_field(name, **kword_args) kword_args = kword_args.reverse_merge( name: name, - type: GraphQL::BOOLEAN_TYPE, + type: GraphQL::Types::Boolean, description: "Indicates the user can perform `#{name}` on this resource", null: false) diff --git a/app/graphql/types/project_type.rb b/app/graphql/types/project_type.rb index 968635f9e6e..af1f1c54ec2 100644 --- a/app/graphql/types/project_type.rb +++ b/app/graphql/types/project_type.rb @@ -8,44 +8,44 @@ module Types expose_permissions Types::PermissionTypes::Project - field :id, GraphQL::ID_TYPE, null: false, + field :id, GraphQL::Types::ID, null: false, description: 'ID of the project.' - field :full_path, GraphQL::ID_TYPE, null: false, + field :full_path, GraphQL::Types::ID, null: false, description: 'Full path of the project.' - field :path, GraphQL::STRING_TYPE, null: false, + field :path, GraphQL::Types::String, null: false, description: 'Path of the project.' field :sast_ci_configuration, Types::CiConfiguration::Sast::Type, null: true, calls_gitaly: true, description: 'SAST CI configuration for the project.' - field :name_with_namespace, GraphQL::STRING_TYPE, null: false, + field :name_with_namespace, GraphQL::Types::String, null: false, description: 'Full name of the project with its namespace.' - field :name, GraphQL::STRING_TYPE, null: false, + field :name, GraphQL::Types::String, null: false, description: 'Name of the project (without namespace).' - field :description, GraphQL::STRING_TYPE, null: true, + field :description, GraphQL::Types::String, null: true, description: 'Short description of the project.' markdown_field :description_html, null: true - field :tag_list, GraphQL::STRING_TYPE, null: true, + field :tag_list, GraphQL::Types::String, null: true, deprecated: { reason: 'Use `topics`', milestone: '13.12' }, description: 'List of project topics (not Git tags).' - field :topics, [GraphQL::STRING_TYPE], null: true, + field :topics, [GraphQL::Types::String], null: true, description: 'List of project topics.' - field :ssh_url_to_repo, GraphQL::STRING_TYPE, null: true, + field :ssh_url_to_repo, GraphQL::Types::String, null: true, description: 'URL to connect to the project via SSH.' - field :http_url_to_repo, GraphQL::STRING_TYPE, null: true, + field :http_url_to_repo, GraphQL::Types::String, null: true, description: 'URL to connect to the project via HTTPS.' - field :web_url, GraphQL::STRING_TYPE, null: true, + field :web_url, GraphQL::Types::String, null: true, description: 'Web URL of the project.' - field :star_count, GraphQL::INT_TYPE, null: false, + field :star_count, GraphQL::Types::Int, null: false, description: 'Number of times the project has been starred.' - field :forks_count, GraphQL::INT_TYPE, null: false, calls_gitaly: true, # 4 times + field :forks_count, GraphQL::Types::Int, null: false, calls_gitaly: true, # 4 times description: 'Number of times the project has been forked.' field :created_at, Types::TimeType, null: true, @@ -53,26 +53,26 @@ module Types field :last_activity_at, Types::TimeType, null: true, description: 'Timestamp of the project last activity.' - field :archived, GraphQL::BOOLEAN_TYPE, null: true, + field :archived, GraphQL::Types::Boolean, null: true, description: 'Indicates the archived status of the project.' - field :visibility, GraphQL::STRING_TYPE, null: true, + field :visibility, GraphQL::Types::String, null: true, description: 'Visibility of the project.' - field :shared_runners_enabled, GraphQL::BOOLEAN_TYPE, null: true, + field :shared_runners_enabled, GraphQL::Types::Boolean, null: true, description: 'Indicates if shared runners are enabled for the project.' - field :lfs_enabled, GraphQL::BOOLEAN_TYPE, null: true, + field :lfs_enabled, GraphQL::Types::Boolean, null: true, description: 'Indicates if the project has Large File Storage (LFS) enabled.' - field :merge_requests_ff_only_enabled, GraphQL::BOOLEAN_TYPE, null: true, + field :merge_requests_ff_only_enabled, GraphQL::Types::Boolean, null: true, description: 'Indicates if no merge commits should be created and all merges should instead be fast-forwarded, which means that merging is only allowed if the branch could be fast-forwarded.' - field :service_desk_enabled, GraphQL::BOOLEAN_TYPE, null: true, + field :service_desk_enabled, GraphQL::Types::Boolean, null: true, description: 'Indicates if the project has service desk enabled.' - field :service_desk_address, GraphQL::STRING_TYPE, null: true, + field :service_desk_address, GraphQL::Types::String, null: true, description: 'E-mail address of the service desk.' - field :avatar_url, GraphQL::STRING_TYPE, null: true, calls_gitaly: true, + field :avatar_url, GraphQL::Types::String, null: true, calls_gitaly: true, description: 'URL to avatar image file of the project.' { @@ -82,7 +82,7 @@ module Types snippets: 'Snippets are', container_registry: 'Container Registry is' }.each do |feature, name_string| - field "#{feature}_enabled", GraphQL::BOOLEAN_TYPE, null: true, + field "#{feature}_enabled", GraphQL::Types::Boolean, null: true, description: "Indicates if #{name_string} enabled for the current user" define_method "#{feature}_enabled" do @@ -90,36 +90,36 @@ module Types end end - field :jobs_enabled, GraphQL::BOOLEAN_TYPE, null: true, + field :jobs_enabled, GraphQL::Types::Boolean, null: true, description: 'Indicates if CI/CD pipeline jobs are enabled for the current user.' - field :public_jobs, GraphQL::BOOLEAN_TYPE, method: :public_builds, null: true, + field :public_jobs, GraphQL::Types::Boolean, method: :public_builds, null: true, description: 'Indicates if there is public access to pipelines and job details of the project, including output logs and artifacts.' - field :open_issues_count, GraphQL::INT_TYPE, null: true, + field :open_issues_count, GraphQL::Types::Int, null: true, description: 'Number of open issues for the project.' - field :import_status, GraphQL::STRING_TYPE, null: true, + field :import_status, GraphQL::Types::String, null: true, description: 'Status of import background job of the project.' - field :jira_import_status, GraphQL::STRING_TYPE, null: true, + field :jira_import_status, GraphQL::Types::String, null: true, description: 'Status of Jira import background job of the project.' - field :only_allow_merge_if_pipeline_succeeds, GraphQL::BOOLEAN_TYPE, null: true, + field :only_allow_merge_if_pipeline_succeeds, GraphQL::Types::Boolean, null: true, description: 'Indicates if merge requests of the project can only be merged with successful jobs.' - field :allow_merge_on_skipped_pipeline, GraphQL::BOOLEAN_TYPE, null: true, + field :allow_merge_on_skipped_pipeline, GraphQL::Types::Boolean, null: true, description: 'If `only_allow_merge_if_pipeline_succeeds` is true, indicates if merge requests of the project can also be merged with skipped jobs.' - field :request_access_enabled, GraphQL::BOOLEAN_TYPE, null: true, + field :request_access_enabled, GraphQL::Types::Boolean, null: true, description: 'Indicates if users can request member access to the project.' - field :only_allow_merge_if_all_discussions_are_resolved, GraphQL::BOOLEAN_TYPE, null: true, + field :only_allow_merge_if_all_discussions_are_resolved, GraphQL::Types::Boolean, null: true, description: 'Indicates if merge requests of the project can only be merged when all the discussions are resolved.' - field :printing_merge_request_link_enabled, GraphQL::BOOLEAN_TYPE, null: true, + field :printing_merge_request_link_enabled, GraphQL::Types::Boolean, null: true, description: 'Indicates if a link to create or view a merge request should display after a push to Git repositories of the project from the command line.' - field :remove_source_branch_after_merge, GraphQL::BOOLEAN_TYPE, null: true, + field :remove_source_branch_after_merge, GraphQL::Types::Boolean, null: true, description: 'Indicates if `Delete source branch` option should be enabled by default for all new merge requests of the project.' - field :autoclose_referenced_issues, GraphQL::BOOLEAN_TYPE, null: true, + field :autoclose_referenced_issues, GraphQL::Types::Boolean, null: true, description: 'Indicates if issues referenced by merge requests and commits within the default branch are closed automatically.' - field :suggestion_commit_message, GraphQL::STRING_TYPE, null: true, + field :suggestion_commit_message, GraphQL::Types::String, null: true, description: 'The commit message used to apply merge request suggestions.' - field :squash_read_only, GraphQL::BOOLEAN_TYPE, null: false, method: :squash_readonly?, + field :squash_read_only, GraphQL::Types::Boolean, null: false, method: :squash_readonly?, description: 'Indicates if `squashReadOnly` is enabled.' field :namespace, Types::NamespaceType, null: true, @@ -318,14 +318,14 @@ module Types description: 'Container repositories of the project.', resolver: Resolvers::ContainerRepositoriesResolver - field :container_repositories_count, GraphQL::INT_TYPE, null: false, + field :container_repositories_count, GraphQL::Types::Int, null: false, description: 'Number of container repositories in the project.' field :label, Types::LabelType, null: true, description: 'A label available on this project.' do - argument :title, GraphQL::STRING_TYPE, + argument :title, GraphQL::Types::String, required: true, description: 'Title of the label.' end @@ -354,6 +354,13 @@ module Types description: 'The CI Job Tokens scope of access.', resolver: Resolvers::Ci::JobTokenScopeResolver + field :timelogs, + Types::TimelogType.connection_type, null: true, + description: 'Time logged on issues and merge requests in the project.', + extras: [:lookahead], + complexity: 5, + resolver: ::Resolvers::TimelogResolver + def label(title:) BatchLoader::GraphQL.for(title).batch(key: project) do |titles, loader, args| LabelsFinder diff --git a/app/graphql/types/projects/service_type.rb b/app/graphql/types/projects/service_type.rb index 6f0dcd44cad..4a9e5dcbfe9 100644 --- a/app/graphql/types/projects/service_type.rb +++ b/app/graphql/types/projects/service_type.rb @@ -8,9 +8,9 @@ module Types # TODO: Add all the fields that we want to expose for the project services integrations # https://gitlab.com/gitlab-org/gitlab/-/issues/213088 - field :type, GraphQL::STRING_TYPE, null: true, + field :type, GraphQL::Types::String, null: true, description: 'Class name of the service.' - field :active, GraphQL::BOOLEAN_TYPE, null: true, + field :active, GraphQL::Types::Boolean, null: true, description: 'Indicates if the service is active.' definition_methods do diff --git a/app/graphql/types/projects/services/jira_project_type.rb b/app/graphql/types/projects/services/jira_project_type.rb index 90abce2b4c3..957ac91db6b 100644 --- a/app/graphql/types/projects/services/jira_project_type.rb +++ b/app/graphql/types/projects/services/jira_project_type.rb @@ -7,12 +7,12 @@ module Types class JiraProjectType < BaseObject graphql_name 'JiraProject' - field :key, GraphQL::STRING_TYPE, null: false, + field :key, GraphQL::Types::String, null: false, description: 'Key of the Jira project.' - field :project_id, GraphQL::INT_TYPE, null: false, + field :project_id, GraphQL::Types::Int, null: false, description: 'ID of the Jira project.', method: :id - field :name, GraphQL::STRING_TYPE, null: true, + field :name, GraphQL::Types::String, null: true, description: 'Name of the Jira project.' end # rubocop:enable Graphql/AuthorizeTypes diff --git a/app/graphql/types/prometheus_alert_type.rb b/app/graphql/types/prometheus_alert_type.rb index 8e800536675..8327848032a 100644 --- a/app/graphql/types/prometheus_alert_type.rb +++ b/app/graphql/types/prometheus_alert_type.rb @@ -9,11 +9,11 @@ module Types present_using PrometheusAlertPresenter - field :id, GraphQL::ID_TYPE, null: false, + field :id, GraphQL::Types::ID, null: false, description: 'ID of the alert condition.' field :humanized_text, - GraphQL::STRING_TYPE, + GraphQL::Types::String, null: false, description: 'The human-readable text of the alert condition.' end diff --git a/app/graphql/types/query_complexity_type.rb b/app/graphql/types/query_complexity_type.rb index 82809fac22f..3f58a15aef7 100644 --- a/app/graphql/types/query_complexity_type.rb +++ b/app/graphql/types/query_complexity_type.rb @@ -9,7 +9,7 @@ module Types alias_method :query, :object - field :limit, GraphQL::INT_TYPE, + field :limit, GraphQL::Types::Int, null: true, method: :max_complexity, see: { @@ -18,7 +18,7 @@ module Types }, description: 'GraphQL query complexity limit.' - field :score, GraphQL::INT_TYPE, + field :score, GraphQL::Types::Int, null: true, description: 'GraphQL query complexity score.' diff --git a/app/graphql/types/query_type.rb b/app/graphql/types/query_type.rb index d2c67aea95c..7e9cd615719 100644 --- a/app/graphql/types/query_type.rb +++ b/app/graphql/types/query_type.rb @@ -129,7 +129,14 @@ module Types description: "Find runners visible to the current user.", feature_flag: :runner_graphql_query - field :ci_config, resolver: Resolvers::Ci::ConfigResolver, complexity: 126 # AUTHENTICATED_COMPLEXITY / 2 + 1 + field :ci_config, resolver: Resolvers::Ci::ConfigResolver, complexity: 126 # AUTHENTICATED_MAX_COMPLEXITY / 2 + 1 + + field :timelogs, Types::TimelogType.connection_type, + null: true, + description: 'Find timelogs visible to the current user.', + extras: [:lookahead], + complexity: 5, + resolver: ::Resolvers::TimelogResolver def design_management DesignManagementObject.new(nil) diff --git a/app/graphql/types/release_asset_link_shared_input_arguments.rb b/app/graphql/types/release_asset_link_shared_input_arguments.rb index 4aa247e47cc..37a6cdd55c9 100644 --- a/app/graphql/types/release_asset_link_shared_input_arguments.rb +++ b/app/graphql/types/release_asset_link_shared_input_arguments.rb @@ -5,15 +5,15 @@ module Types extend ActiveSupport::Concern included do - argument :name, GraphQL::STRING_TYPE, + argument :name, GraphQL::Types::String, required: true, description: 'Name of the asset link.' - argument :url, GraphQL::STRING_TYPE, + argument :url, GraphQL::Types::String, required: true, 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.' diff --git a/app/graphql/types/release_asset_link_type.rb b/app/graphql/types/release_asset_link_type.rb index 829e7e246db..02961f2f73f 100644 --- a/app/graphql/types/release_asset_link_type.rb +++ b/app/graphql/types/release_asset_link_type.rb @@ -7,20 +7,20 @@ module Types authorize :read_release - field :id, GraphQL::ID_TYPE, null: false, + field :id, GraphQL::Types::ID, null: false, description: 'ID of the link.' - field :name, GraphQL::STRING_TYPE, null: true, + field :name, GraphQL::Types::String, null: true, description: 'Name of the link.' - field :url, GraphQL::STRING_TYPE, null: true, + field :url, GraphQL::Types::String, null: true, description: 'URL of the link.' field :link_type, Types::ReleaseAssetLinkTypeEnum, null: true, description: 'Type of the link: `other`, `runbook`, `image`, `package`; defaults to `other`.' - field :external, GraphQL::BOOLEAN_TYPE, null: true, method: :external?, + field :external, GraphQL::Types::Boolean, null: true, method: :external?, description: 'Indicates the link points to an external resource.' - field :direct_asset_url, GraphQL::STRING_TYPE, null: true, + field :direct_asset_url, GraphQL::Types::String, null: true, description: 'Direct asset URL of the link.' - field :direct_asset_path, GraphQL::STRING_TYPE, null: true, method: :filepath, + field :direct_asset_path, GraphQL::Types::String, null: true, method: :filepath, description: 'Relative path for the direct asset link.' def direct_asset_url diff --git a/app/graphql/types/release_assets_type.rb b/app/graphql/types/release_assets_type.rb index d847d9842d5..ea6ee0b5fd9 100644 --- a/app/graphql/types/release_assets_type.rb +++ b/app/graphql/types/release_assets_type.rb @@ -11,7 +11,7 @@ module Types present_using ReleasePresenter - field :count, GraphQL::INT_TYPE, null: true, method: :assets_count, + field :count, GraphQL::Types::Int, null: true, method: :assets_count, description: 'Number of assets of the release.' field :links, Types::ReleaseAssetLinkType.connection_type, null: true, method: :sorted_links, description: 'Asset links of the release.' diff --git a/app/graphql/types/release_links_type.rb b/app/graphql/types/release_links_type.rb index a51b80e1e13..7830e29f3cd 100644 --- a/app/graphql/types/release_links_type.rb +++ b/app/graphql/types/release_links_type.rb @@ -10,20 +10,20 @@ module Types present_using ReleasePresenter - field :self_url, GraphQL::STRING_TYPE, null: true, + field :self_url, GraphQL::Types::String, null: true, description: 'HTTP URL of the release.' - field :edit_url, GraphQL::STRING_TYPE, null: true, + field :edit_url, GraphQL::Types::String, null: true, description: "HTTP URL of the release's edit page.", authorize: :update_release - field :opened_merge_requests_url, GraphQL::STRING_TYPE, null: true, + field :opened_merge_requests_url, GraphQL::Types::String, null: true, description: 'HTTP URL of the merge request page, filtered by this release and `state=open`.' - field :merged_merge_requests_url, GraphQL::STRING_TYPE, null: true, + field :merged_merge_requests_url, GraphQL::Types::String, null: true, description: 'HTTP URL of the merge request page , filtered by this release and `state=merged`.' - field :closed_merge_requests_url, GraphQL::STRING_TYPE, null: true, + field :closed_merge_requests_url, GraphQL::Types::String, null: true, description: 'HTTP URL of the merge request page , filtered by this release and `state=closed`.' - field :opened_issues_url, GraphQL::STRING_TYPE, null: true, + field :opened_issues_url, GraphQL::Types::String, null: true, description: 'HTTP URL of the issues page, filtered by this release and `state=open`.' - field :closed_issues_url, GraphQL::STRING_TYPE, null: true, + field :closed_issues_url, GraphQL::Types::String, null: true, description: 'HTTP URL of the issues page, filtered by this release and `state=closed`.' end end diff --git a/app/graphql/types/release_source_type.rb b/app/graphql/types/release_source_type.rb index 10fc202514d..fd29a69d72a 100644 --- a/app/graphql/types/release_source_type.rb +++ b/app/graphql/types/release_source_type.rb @@ -7,9 +7,9 @@ module Types authorize :download_code - field :format, GraphQL::STRING_TYPE, null: true, + field :format, GraphQL::Types::String, null: true, description: 'Format of the source.' - field :url, GraphQL::STRING_TYPE, null: true, + field :url, GraphQL::Types::String, null: true, description: 'Download URL of the source.' end end diff --git a/app/graphql/types/release_type.rb b/app/graphql/types/release_type.rb index 81813a10a3e..5e8f00b2b0a 100644 --- a/app/graphql/types/release_type.rb +++ b/app/graphql/types/release_type.rb @@ -13,22 +13,22 @@ module Types present_using ReleasePresenter - field :tag_name, GraphQL::STRING_TYPE, null: true, method: :tag, + field :tag_name, GraphQL::Types::String, null: true, method: :tag, description: 'Name of the tag associated with the release.', authorize: :download_code - field :tag_path, GraphQL::STRING_TYPE, null: true, + field :tag_path, GraphQL::Types::String, null: true, description: 'Relative web path to the tag associated with the release.', authorize: :download_code - field :description, GraphQL::STRING_TYPE, null: true, + field :description, GraphQL::Types::String, null: true, description: 'Description (also known as "release notes") of the release.' markdown_field :description_html, null: true - field :name, GraphQL::STRING_TYPE, null: true, + field :name, GraphQL::Types::String, null: true, description: 'Name of the release.' field :created_at, Types::TimeType, null: true, description: 'Timestamp of when the release was created.' field :released_at, Types::TimeType, null: true, description: 'Timestamp of when the release was released.' - field :upcoming_release, GraphQL::BOOLEAN_TYPE, null: true, method: :upcoming_release?, + field :upcoming_release, GraphQL::Types::Boolean, null: true, method: :upcoming_release?, description: 'Indicates the release is an upcoming release.' field :assets, Types::ReleaseAssetsType, null: true, method: :itself, description: 'Assets of the release.' diff --git a/app/graphql/types/repository/blob_type.rb b/app/graphql/types/repository/blob_type.rb index 8ed97d7e663..b6a1a91fd7a 100644 --- a/app/graphql/types/repository/blob_type.rb +++ b/app/graphql/types/repository/blob_type.rb @@ -8,67 +8,67 @@ module Types graphql_name 'RepositoryBlob' - field :id, GraphQL::ID_TYPE, null: false, + field :id, GraphQL::Types::ID, null: false, description: 'ID of the blob.' - field :oid, GraphQL::STRING_TYPE, null: false, method: :id, + field :oid, GraphQL::Types::String, null: false, method: :id, description: 'OID of the blob.' - field :path, GraphQL::STRING_TYPE, null: false, + field :path, GraphQL::Types::String, null: false, description: 'Path of the blob.' - field :name, GraphQL::STRING_TYPE, + field :name, GraphQL::Types::String, description: 'Blob name.', null: true - field :mode, type: GraphQL::STRING_TYPE, + field :mode, type: GraphQL::Types::String, description: 'Blob mode.', null: true - field :lfs_oid, GraphQL::STRING_TYPE, null: true, + field :lfs_oid, GraphQL::Types::String, null: true, calls_gitaly: true, description: 'LFS OID of the blob.' - field :web_path, GraphQL::STRING_TYPE, null: true, + field :web_path, GraphQL::Types::String, null: true, description: 'Web path of the blob.' - field :ide_edit_path, GraphQL::STRING_TYPE, null: true, + field :ide_edit_path, GraphQL::Types::String, null: true, description: 'Web path to edit this blob in the Web IDE.' - field :fork_and_edit_path, GraphQL::STRING_TYPE, null: true, + field :fork_and_edit_path, GraphQL::Types::String, null: true, description: 'Web path to edit this blob using a forked project.' - field :ide_fork_and_edit_path, GraphQL::STRING_TYPE, null: true, + field :ide_fork_and_edit_path, GraphQL::Types::String, null: true, description: 'Web path to edit this blob in the Web IDE using a forked project.' - field :size, GraphQL::INT_TYPE, null: true, + field :size, GraphQL::Types::Int, null: true, description: 'Size (in bytes) of the blob.' - field :raw_size, GraphQL::INT_TYPE, null: true, + field :raw_size, GraphQL::Types::Int, null: true, description: 'Size (in bytes) of the blob, or the blob target if stored externally.' - field :raw_blob, GraphQL::STRING_TYPE, null: true, method: :data, + field :raw_blob, GraphQL::Types::String, null: true, method: :data, description: 'The raw content of the blob.' - field :raw_text_blob, GraphQL::STRING_TYPE, null: true, method: :text_only_data, + field :raw_text_blob, GraphQL::Types::String, null: true, method: :text_only_data, description: 'The raw content of the blob, if the blob is text data.' - field :stored_externally, GraphQL::BOOLEAN_TYPE, null: true, method: :stored_externally?, + field :stored_externally, GraphQL::Types::Boolean, null: true, method: :stored_externally?, description: "Whether the blob's content is stored externally (for instance, in LFS)." - field :edit_blob_path, GraphQL::STRING_TYPE, null: true, + field :edit_blob_path, GraphQL::Types::String, null: true, description: 'Web path to edit the blob in the old-style editor.' - field :raw_path, GraphQL::STRING_TYPE, null: true, + field :raw_path, GraphQL::Types::String, null: true, description: 'Web path to download the raw blob.' - field :external_storage_url, GraphQL::STRING_TYPE, null: true, + field :external_storage_url, GraphQL::Types::String, null: true, description: 'Web path to download the raw blob via external storage, if enabled.' - field :replace_path, GraphQL::STRING_TYPE, null: true, + field :replace_path, GraphQL::Types::String, null: true, description: 'Web path to replace the blob content.' - field :file_type, GraphQL::STRING_TYPE, null: true, + field :file_type, GraphQL::Types::String, null: true, description: 'The expected format of the blob based on the extension.' field :simple_viewer, type: Types::BlobViewerType, @@ -79,12 +79,12 @@ module Types description: 'Blob content rich viewer.', null: true - field :plain_data, GraphQL::STRING_TYPE, + field :plain_data, GraphQL::Types::String, description: 'Blob plain highlighted data.', null: true, calls_gitaly: true - field :can_modify_blob, GraphQL::BOOLEAN_TYPE, null: true, method: :can_modify_blob?, + field :can_modify_blob, GraphQL::Types::Boolean, null: true, method: :can_modify_blob?, calls_gitaly: true, description: 'Whether the current user can modify the blob.' diff --git a/app/graphql/types/repository_type.rb b/app/graphql/types/repository_type.rb index 9d896888fa7..63d1eef5b59 100644 --- a/app/graphql/types/repository_type.rb +++ b/app/graphql/types/repository_type.rb @@ -6,20 +6,24 @@ module Types authorize :download_code - field :root_ref, GraphQL::STRING_TYPE, null: true, calls_gitaly: true, + field :root_ref, GraphQL::Types::String, null: true, calls_gitaly: true, description: 'Default branch of the repository.' - field :empty, GraphQL::BOOLEAN_TYPE, null: false, method: :empty?, calls_gitaly: true, + field :empty, GraphQL::Types::Boolean, null: false, method: :empty?, calls_gitaly: true, description: 'Indicates repository has no visible content.' - field :exists, GraphQL::BOOLEAN_TYPE, null: false, method: :exists?, calls_gitaly: true, + field :exists, GraphQL::Types::Boolean, null: false, method: :exists?, calls_gitaly: true, description: 'Indicates a corresponding Git repository exists on disk.' field :tree, Types::Tree::TreeType, null: true, resolver: Resolvers::TreeResolver, calls_gitaly: true, description: 'Tree of the repository.' + field :paginated_tree, Types::Tree::TreeType.connection_type, null: true, resolver: Resolvers::PaginatedTreeResolver, calls_gitaly: true, + max_page_size: 100, + description: 'Paginated tree of the repository.', + feature_flag: :paginated_tree_graphql_query field :blobs, Types::Repository::BlobType.connection_type, null: true, resolver: Resolvers::BlobsResolver, calls_gitaly: true, description: 'Blobs contained within the repository' - field :branch_names, [GraphQL::STRING_TYPE], null: true, calls_gitaly: true, + field :branch_names, [GraphQL::Types::String], null: true, calls_gitaly: true, complexity: 170, description: 'Names of branches available in this repository that match the search pattern.', resolver: Resolvers::RepositoryBranchNamesResolver - field :disk_path, GraphQL::STRING_TYPE, + field :disk_path, GraphQL::Types::String, description: 'Shows a disk path of the repository.', null: true, authorize: :read_storage_disk_path diff --git a/app/graphql/types/resolvable_interface.rb b/app/graphql/types/resolvable_interface.rb index a9d745c2bc1..42784aa5e00 100644 --- a/app/graphql/types/resolvable_interface.rb +++ b/app/graphql/types/resolvable_interface.rb @@ -16,10 +16,10 @@ module Types Gitlab::Graphql::Loaders::BatchModelLoader.new(User, object.resolved_by_id).find end - field :resolved, GraphQL::BOOLEAN_TYPE, null: false, + field :resolved, GraphQL::Types::Boolean, null: false, description: 'Indicates if the object is resolved.', method: :resolved? - field :resolvable, GraphQL::BOOLEAN_TYPE, null: false, + field :resolvable, GraphQL::Types::Boolean, null: false, description: 'Indicates if the object can be resolved.', method: :resolvable? field :resolved_at, Types::TimeType, null: true, diff --git a/app/graphql/types/snippet_type.rb b/app/graphql/types/snippet_type.rb index 7606bdbc46d..c345aea08bd 100644 --- a/app/graphql/types/snippet_type.rb +++ b/app/graphql/types/snippet_type.rb @@ -17,7 +17,7 @@ module Types description: 'ID of the snippet.', null: false - field :title, GraphQL::STRING_TYPE, + field :title, GraphQL::Types::String, description: 'Title of the snippet.', null: false @@ -33,11 +33,11 @@ module Types description: 'The owner of the snippet.', null: true - field :file_name, GraphQL::STRING_TYPE, + field :file_name, GraphQL::Types::String, description: 'File Name of the snippet.', null: true - field :description, GraphQL::STRING_TYPE, + field :description, GraphQL::Types::String, description: 'Description of the snippet.', null: true @@ -53,11 +53,11 @@ module Types description: 'Timestamp this snippet was updated.', null: false - field :web_url, type: GraphQL::STRING_TYPE, + field :web_url, type: GraphQL::Types::String, description: 'Web URL of the snippet.', null: false - field :raw_url, type: GraphQL::STRING_TYPE, + field :raw_url, type: GraphQL::Types::String, description: 'Raw URL of the snippet.', null: false @@ -67,12 +67,12 @@ module Types null: true, resolver: Resolvers::Snippets::BlobsResolver - field :ssh_url_to_repo, type: GraphQL::STRING_TYPE, + field :ssh_url_to_repo, type: GraphQL::Types::String, description: 'SSH URL to the snippet repository.', calls_gitaly: true, null: true - field :http_url_to_repo, type: GraphQL::STRING_TYPE, + field :http_url_to_repo, type: GraphQL::Types::String, description: 'HTTP URL to the snippet repository.', calls_gitaly: true, null: true diff --git a/app/graphql/types/snippets/blob_action_input_type.rb b/app/graphql/types/snippets/blob_action_input_type.rb index 13eade3dcc4..45dc4be8451 100644 --- a/app/graphql/types/snippets/blob_action_input_type.rb +++ b/app/graphql/types/snippets/blob_action_input_type.rb @@ -10,15 +10,15 @@ module Types description: 'Type of input action.', required: true - argument :previous_path, GraphQL::STRING_TYPE, + argument :previous_path, GraphQL::Types::String, description: 'Previous path of the snippet file.', required: false - argument :file_path, GraphQL::STRING_TYPE, + argument :file_path, GraphQL::Types::String, description: 'Path of the snippet file.', required: true - argument :content, GraphQL::STRING_TYPE, + argument :content, GraphQL::Types::String, description: 'Snippet file content.', required: false end diff --git a/app/graphql/types/snippets/blob_type.rb b/app/graphql/types/snippets/blob_type.rb index 1335838935e..d5da271d936 100644 --- a/app/graphql/types/snippets/blob_type.rb +++ b/app/graphql/types/snippets/blob_type.rb @@ -8,36 +8,36 @@ module Types description 'Represents the snippet blob' present_using SnippetBlobPresenter - field :rich_data, GraphQL::STRING_TYPE, + field :rich_data, GraphQL::Types::String, description: 'Blob highlighted data.', null: true - field :plain_data, GraphQL::STRING_TYPE, + field :plain_data, GraphQL::Types::String, description: 'Blob plain highlighted data.', null: true - field :raw_plain_data, GraphQL::STRING_TYPE, + field :raw_plain_data, GraphQL::Types::String, description: 'The raw content of the blob, if the blob is text data.', null: true - field :raw_path, GraphQL::STRING_TYPE, + field :raw_path, GraphQL::Types::String, description: 'Blob raw content endpoint path.', null: false - field :size, GraphQL::INT_TYPE, + field :size, GraphQL::Types::Int, description: 'Blob size.', null: false - field :binary, GraphQL::BOOLEAN_TYPE, + field :binary, GraphQL::Types::Boolean, description: 'Shows whether the blob is binary.', method: :binary?, null: false - field :name, GraphQL::STRING_TYPE, + field :name, GraphQL::Types::String, description: 'Blob name.', null: true - field :path, GraphQL::STRING_TYPE, + field :path, GraphQL::Types::String, description: 'Blob path.', null: true @@ -49,15 +49,15 @@ module Types description: 'Blob content rich viewer.', null: true - field :mode, type: GraphQL::STRING_TYPE, + field :mode, type: GraphQL::Types::String, description: 'Blob mode.', null: true - field :external_storage, type: GraphQL::STRING_TYPE, + field :external_storage, type: GraphQL::Types::String, description: 'Blob external storage.', null: true - field :rendered_as_text, type: GraphQL::BOOLEAN_TYPE, + field :rendered_as_text, type: GraphQL::Types::Boolean, description: 'Shows whether the blob is rendered as text.', method: :rendered_as_text?, null: false diff --git a/app/graphql/types/task_completion_status.rb b/app/graphql/types/task_completion_status.rb index 6837256f202..3aa19ff9413 100644 --- a/app/graphql/types/task_completion_status.rb +++ b/app/graphql/types/task_completion_status.rb @@ -8,9 +8,9 @@ module Types graphql_name 'TaskCompletionStatus' description 'Completion status of tasks' - field :count, GraphQL::INT_TYPE, null: false, + field :count, GraphQL::Types::Int, null: false, description: 'Number of total tasks.' - field :completed_count, GraphQL::INT_TYPE, null: false, + field :completed_count, GraphQL::Types::Int, null: false, description: 'Number of completed tasks.' end # rubocop: enable Graphql/AuthorizeTypes diff --git a/app/graphql/types/terraform/state_type.rb b/app/graphql/types/terraform/state_type.rb index 9e2c47a9ece..cbd5aeaeef9 100644 --- a/app/graphql/types/terraform/state_type.rb +++ b/app/graphql/types/terraform/state_type.rb @@ -9,11 +9,11 @@ module Types connection_type_class(Types::CountableConnectionType) - field :id, GraphQL::ID_TYPE, + field :id, GraphQL::Types::ID, null: false, description: 'ID of the Terraform state.' - field :name, GraphQL::STRING_TYPE, + field :name, GraphQL::Types::String, null: false, description: 'Name of the Terraform state.' diff --git a/app/graphql/types/terraform/state_version_type.rb b/app/graphql/types/terraform/state_version_type.rb index 2cd2ec8dcda..545b3c0044d 100644 --- a/app/graphql/types/terraform/state_version_type.rb +++ b/app/graphql/types/terraform/state_version_type.rb @@ -9,7 +9,7 @@ module Types authorize :read_terraform_state - field :id, GraphQL::ID_TYPE, + field :id, GraphQL::Types::ID, null: false, description: 'ID of the Terraform state version.' @@ -17,7 +17,7 @@ module Types null: true, description: 'The user that created this version.' - field :download_path, GraphQL::STRING_TYPE, + field :download_path, GraphQL::Types::String, null: true, description: "URL for downloading the version's JSON file." @@ -25,7 +25,7 @@ module Types null: true, description: 'The job that created this version.' - field :serial, GraphQL::INT_TYPE, + field :serial, GraphQL::Types::Int, null: true, description: 'Serial number of the version.', method: :version diff --git a/app/graphql/types/timelog_type.rb b/app/graphql/types/timelog_type.rb index 925a522629e..206aabbada3 100644 --- a/app/graphql/types/timelog_type.rb +++ b/app/graphql/types/timelog_type.rb @@ -12,7 +12,7 @@ module Types description: 'Timestamp of when the time tracked was spent at.' field :time_spent, - GraphQL::INT_TYPE, + GraphQL::Types::Int, null: false, description: 'The time spent displayed in seconds.' @@ -36,6 +36,10 @@ module Types null: true, description: 'The note where the quick action to add the logged time was executed.' + field :summary, GraphQL::Types::String, + null: true, + description: 'The summary of how the time was spent.' + def user Gitlab::Graphql::Loaders::BatchModelLoader.new(User, object.user_id).find end diff --git a/app/graphql/types/todo_type.rb b/app/graphql/types/todo_type.rb index 3b983060de2..24c110ce09b 100644 --- a/app/graphql/types/todo_type.rb +++ b/app/graphql/types/todo_type.rb @@ -9,7 +9,7 @@ module Types authorize :read_todo - field :id, GraphQL::ID_TYPE, + field :id, GraphQL::Types::ID, description: 'ID of the to-do item.', null: false @@ -35,7 +35,7 @@ module Types description: 'Target type of the to-do item.', null: false - field :body, GraphQL::STRING_TYPE, + field :body, GraphQL::Types::String, description: 'Body of the to-do item.', null: false, calls_gitaly: true # TODO This is only true when `target_type` is `Commit`. See https://gitlab.com/gitlab-org/gitlab/issues/34757#note_234752665 diff --git a/app/graphql/types/tree/blob_type.rb b/app/graphql/types/tree/blob_type.rb index d192c8d3c57..bb15d91a62f 100644 --- a/app/graphql/types/tree/blob_type.rb +++ b/app/graphql/types/tree/blob_type.rb @@ -10,14 +10,14 @@ module Types graphql_name 'Blob' - field :web_url, GraphQL::STRING_TYPE, null: true, + field :web_url, GraphQL::Types::String, null: true, description: 'Web URL of the blob.' - field :web_path, GraphQL::STRING_TYPE, null: true, + field :web_path, GraphQL::Types::String, null: true, description: 'Web path of the blob.' - field :lfs_oid, GraphQL::STRING_TYPE, null: true, + field :lfs_oid, GraphQL::Types::String, null: true, calls_gitaly: true, description: 'LFS ID of the blob.' - field :mode, GraphQL::STRING_TYPE, null: true, + field :mode, GraphQL::Types::String, null: true, description: 'Blob mode in numeric format.' def lfs_oid diff --git a/app/graphql/types/tree/entry_type.rb b/app/graphql/types/tree/entry_type.rb index c0150b77c55..1c612f91a5b 100644 --- a/app/graphql/types/tree/entry_type.rb +++ b/app/graphql/types/tree/entry_type.rb @@ -4,17 +4,17 @@ module Types module EntryType include Types::BaseInterface - field :id, GraphQL::ID_TYPE, null: false, + field :id, GraphQL::Types::ID, null: false, description: 'ID of the entry.' - field :sha, GraphQL::STRING_TYPE, null: false, + field :sha, GraphQL::Types::String, null: false, description: 'Last commit SHA for the entry.', method: :id - field :name, GraphQL::STRING_TYPE, null: false, + field :name, GraphQL::Types::String, null: false, description: 'Name of the entry.' field :type, Tree::TypeEnum, null: false, description: 'Type of tree entry.' - field :path, GraphQL::STRING_TYPE, null: false, + field :path, GraphQL::Types::String, null: false, description: 'Path of the entry.' - field :flat_path, GraphQL::STRING_TYPE, null: false, + field :flat_path, GraphQL::Types::String, null: false, description: 'Flat path of the entry.' end end diff --git a/app/graphql/types/tree/submodule_type.rb b/app/graphql/types/tree/submodule_type.rb index 519e866ebb0..05d8c1a951a 100644 --- a/app/graphql/types/tree/submodule_type.rb +++ b/app/graphql/types/tree/submodule_type.rb @@ -8,9 +8,9 @@ module Types graphql_name 'Submodule' - field :web_url, type: GraphQL::STRING_TYPE, null: true, + field :web_url, type: GraphQL::Types::String, null: true, description: 'Web URL for the sub-module.' - field :tree_url, type: GraphQL::STRING_TYPE, null: true, + field :tree_url, type: GraphQL::Types::String, null: true, description: 'Tree URL for the sub-module.' end # rubocop: enable Graphql/AuthorizeTypes diff --git a/app/graphql/types/tree/tree_entry_type.rb b/app/graphql/types/tree/tree_entry_type.rb index daf4b5421fb..998b3617574 100644 --- a/app/graphql/types/tree/tree_entry_type.rb +++ b/app/graphql/types/tree/tree_entry_type.rb @@ -11,9 +11,9 @@ module Types graphql_name 'TreeEntry' description 'Represents a directory' - field :web_url, GraphQL::STRING_TYPE, null: true, + field :web_url, GraphQL::Types::String, null: true, description: 'Web URL for the tree entry (directory).' - field :web_path, GraphQL::STRING_TYPE, null: true, + field :web_path, GraphQL::Types::String, null: true, description: 'Web path for the tree entry (directory).' end # rubocop: enable Graphql/AuthorizeTypes diff --git a/app/graphql/types/user_interface.rb b/app/graphql/types/user_interface.rb index 7d61b296eae..71c6b7f3019 100644 --- a/app/graphql/types/user_interface.rb +++ b/app/graphql/types/user_interface.rb @@ -14,20 +14,20 @@ module Types method: :itself field :id, - type: GraphQL::ID_TYPE, + type: GraphQL::Types::ID, null: false, description: 'ID of the user.' field :bot, - type: GraphQL::BOOLEAN_TYPE, + type: GraphQL::Types::Boolean, null: false, description: 'Indicates if the user is a bot.', method: :bot? field :username, - type: GraphQL::STRING_TYPE, + type: GraphQL::Types::String, null: false, description: 'Username of the user. Unique within this instance of GitLab.' field :name, - type: GraphQL::STRING_TYPE, + type: GraphQL::Types::String, null: false, description: 'Human-readable name of the user.' field :state, @@ -35,24 +35,24 @@ module Types null: false, description: 'State of the user.' field :email, - type: GraphQL::STRING_TYPE, + type: GraphQL::Types::String, null: true, description: 'User email.', method: :public_email, deprecated: { reason: :renamed, replacement: 'User.publicEmail', milestone: '13.7' } field :public_email, - type: GraphQL::STRING_TYPE, + type: GraphQL::Types::String, null: true, description: "User's public email." field :avatar_url, - type: GraphQL::STRING_TYPE, + type: GraphQL::Types::String, null: true, description: "URL of the user's avatar." field :web_url, - type: GraphQL::STRING_TYPE, + type: GraphQL::Types::String, null: false, description: 'Web URL of the user.' field :web_path, - type: GraphQL::STRING_TYPE, + type: GraphQL::Types::String, null: false, description: 'Web path of the user.' field :group_memberships, @@ -67,7 +67,7 @@ module Types null: true, description: 'User status.' field :location, - type: ::GraphQL::STRING_TYPE, + type: ::GraphQL::Types::String, null: true, description: 'The location of the user.' field :project_memberships, @@ -77,6 +77,10 @@ module Types field :starred_projects, description: 'Projects starred by the user.', resolver: Resolvers::UserStarredProjectsResolver + field :namespace, + type: Types::NamespaceType, + null: true, + description: 'Personal namespace of the user.' field :todos, resolver: Resolvers::TodoResolver, description: 'To-do items of the user.' do extension(::Gitlab::Graphql::TodosProjectPermissionPreloader::FieldExtension) @@ -100,6 +104,13 @@ module Types Types::UserCalloutType.connection_type, null: true, description: 'User callouts that belong to the user.' + field :timelogs, + Types::TimelogType.connection_type, + null: true, + description: 'Time logged by the user.', + extras: [:lookahead], + complexity: 5, + resolver: ::Resolvers::TimelogResolver definition_methods do def resolve_type(object, context) diff --git a/app/graphql/types/user_merge_request_interaction_type.rb b/app/graphql/types/user_merge_request_interaction_type.rb index b9ff489e0d6..ff6e83efbb2 100644 --- a/app/graphql/types/user_merge_request_interaction_type.rb +++ b/app/graphql/types/user_merge_request_interaction_type.rb @@ -13,14 +13,14 @@ module Types authorize :read_merge_request field :can_merge, - type: ::GraphQL::BOOLEAN_TYPE, + type: ::GraphQL::Types::Boolean, null: false, calls_gitaly: true, method: :can_merge?, description: 'Whether this user can merge this merge request.' field :can_update, - type: ::GraphQL::BOOLEAN_TYPE, + type: ::GraphQL::Types::Boolean, null: false, method: :can_update?, description: 'Whether this user can update this merge request.' @@ -31,13 +31,13 @@ module Types description: 'The state of the review by this user.' field :reviewed, - type: ::GraphQL::BOOLEAN_TYPE, + type: ::GraphQL::Types::Boolean, null: false, method: :reviewed?, description: 'Whether this user has provided a review for this merge request.' field :approved, - type: ::GraphQL::BOOLEAN_TYPE, + type: ::GraphQL::Types::Boolean, null: false, method: :approved?, description: 'Whether this user has approved this merge request.' diff --git a/app/graphql/types/user_status_type.rb b/app/graphql/types/user_status_type.rb index c1a736a3722..61abec0ba96 100644 --- a/app/graphql/types/user_status_type.rb +++ b/app/graphql/types/user_status_type.rb @@ -7,9 +7,9 @@ module Types markdown_field :message_html, null: true, description: 'HTML of the user status message' - field :message, GraphQL::STRING_TYPE, null: true, + field :message, GraphQL::Types::String, null: true, description: 'User status message.' - field :emoji, GraphQL::STRING_TYPE, null: true, + field :emoji, GraphQL::Types::String, null: true, description: 'String representation of emoji.' field :availability, Types::AvailabilityEnum, null: false, description: 'User availability status.' |