summaryrefslogtreecommitdiff
path: root/app/graphql/types
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-07-20 12:26:25 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2020-07-20 12:26:25 +0000
commita09983ae35713f5a2bbb100981116d31ce99826e (patch)
tree2ee2af7bd104d57086db360a7e6d8c9d5d43667a /app/graphql/types
parent18c5ab32b738c0b6ecb4d0df3994000482f34bd8 (diff)
downloadgitlab-ce-a09983ae35713f5a2bbb100981116d31ce99826e.tar.gz
Add latest changes from gitlab-org/gitlab@13-2-stable-ee
Diffstat (limited to 'app/graphql/types')
-rw-r--r--app/graphql/types/alert_management/alert_sort_enum.rb8
-rw-r--r--app/graphql/types/alert_management/alert_type.rb6
-rw-r--r--app/graphql/types/ci_configuration/sast/analyzers_entity_type.rb25
-rw-r--r--app/graphql/types/ci_configuration/sast/entity_type.rb34
-rw-r--r--app/graphql/types/ci_configuration/sast/options_entity_type.rb19
-rw-r--r--app/graphql/types/ci_configuration/sast/type.rb22
-rw-r--r--app/graphql/types/container_expiration_policy_type.rb4
-rw-r--r--app/graphql/types/deprecated_mutations.rb19
-rw-r--r--app/graphql/types/diff_stats_summary_type.rb25
-rw-r--r--app/graphql/types/diff_stats_type.rb19
-rw-r--r--app/graphql/types/error_tracking/sentry_detailed_error_type.rb8
-rw-r--r--app/graphql/types/error_tracking/sentry_error_collection_type.rb2
-rw-r--r--app/graphql/types/global_id_type.rb64
-rw-r--r--app/graphql/types/issue_connection_type.rb13
-rw-r--r--app/graphql/types/issue_type.rb4
-rw-r--r--app/graphql/types/jira_user_type.rb6
-rw-r--r--app/graphql/types/jira_users_mapping_input_type.rb18
-rw-r--r--app/graphql/types/merge_request_type.rb26
-rw-r--r--app/graphql/types/milestone_stats_type.rb16
-rw-r--r--app/graphql/types/milestone_type.rb11
-rw-r--r--app/graphql/types/mutation_type.rb4
-rw-r--r--app/graphql/types/namespace_type.rb2
-rw-r--r--app/graphql/types/notes/note_type.rb6
-rw-r--r--app/graphql/types/package_type.rb16
-rw-r--r--app/graphql/types/package_type_enum.rb9
-rw-r--r--app/graphql/types/project_statistics_type.rb2
-rw-r--r--app/graphql/types/project_type.rb19
-rw-r--r--app/graphql/types/projects/services/jira_service_type.rb2
-rw-r--r--app/graphql/types/query_type.rb4
-rw-r--r--app/graphql/types/release_asset_link_type.rb (renamed from app/graphql/types/release_link_type.rb)7
-rw-r--r--app/graphql/types/release_asset_link_type_enum.rb (renamed from app/graphql/types/release_link_type_enum.rb)4
-rw-r--r--app/graphql/types/release_assets_type.rb5
-rw-r--r--app/graphql/types/release_links_type.rb23
-rw-r--r--app/graphql/types/release_source_type.rb3
-rw-r--r--app/graphql/types/release_type.rb14
-rw-r--r--app/graphql/types/root_storage_statistics_type.rb1
-rw-r--r--app/graphql/types/todo_target_enum.rb1
-rw-r--r--app/graphql/types/tree/blob_type.rb2
-rw-r--r--app/graphql/types/untrusted_regexp.rb22
39 files changed, 465 insertions, 30 deletions
diff --git a/app/graphql/types/alert_management/alert_sort_enum.rb b/app/graphql/types/alert_management/alert_sort_enum.rb
index 3faac9ce53c..51e7bef0a7f 100644
--- a/app/graphql/types/alert_management/alert_sort_enum.rb
+++ b/app/graphql/types/alert_management/alert_sort_enum.rb
@@ -16,10 +16,10 @@ module Types
value 'UPDATED_TIME_DESC', 'Created time by descending order', value: :updated_at_desc
value 'EVENT_COUNT_ASC', 'Events count by ascending order', value: :event_count_asc
value 'EVENT_COUNT_DESC', 'Events count by descending order', value: :event_count_desc
- value 'SEVERITY_ASC', 'Severity by ascending order', value: :severity_asc
- value 'SEVERITY_DESC', 'Severity by descending order', value: :severity_desc
- value 'STATUS_ASC', 'Status by ascending order', value: :status_asc
- value 'STATUS_DESC', 'Status by descending order', value: :status_desc
+ value 'SEVERITY_ASC', 'Severity from less critical to more critical', value: :severity_asc
+ value 'SEVERITY_DESC', 'Severity from more critical to less critical', value: :severity_desc
+ value 'STATUS_ASC', 'Status by order: Ignored > Resolved > Acknowledged > Triggered', value: :status_asc
+ value 'STATUS_DESC', 'Status by order: Triggered > Acknowledged > Resolved > Ignored', value: :status_desc
end
end
end
diff --git a/app/graphql/types/alert_management/alert_type.rb b/app/graphql/types/alert_management/alert_type.rb
index 8215ccb152c..089d2426158 100644
--- a/app/graphql/types/alert_management/alert_type.rb
+++ b/app/graphql/types/alert_management/alert_type.rb
@@ -91,6 +91,12 @@ module Types
null: true,
description: 'Assignees of the alert'
+ field :metrics_dashboard_url,
+ GraphQL::STRING_TYPE,
+ null: true,
+ description: 'URL for metrics embed for the alert',
+ resolve: -> (alert, _args, _context) { alert.present.metrics_dashboard_url }
+
def notes
object.ordered_notes
end
diff --git a/app/graphql/types/ci_configuration/sast/analyzers_entity_type.rb b/app/graphql/types/ci_configuration/sast/analyzers_entity_type.rb
new file mode 100644
index 00000000000..ccd1c7dd0eb
--- /dev/null
+++ b/app/graphql/types/ci_configuration/sast/analyzers_entity_type.rb
@@ -0,0 +1,25 @@
+# frozen_string_literal: true
+
+module Types
+ module CiConfiguration
+ module Sast
+ # rubocop: disable Graphql/AuthorizeTypes
+ class AnalyzersEntityType < BaseObject
+ graphql_name 'SastCiConfigurationAnalyzersEntity'
+ description 'Represents an analyzer entity in SAST CI configuration'
+
+ field :name, GraphQL::STRING_TYPE, null: true,
+ description: 'Name of the analyzer.'
+
+ field :label, GraphQL::STRING_TYPE, null: true,
+ description: 'Analyzer label used in the config UI.'
+
+ field :enabled, GraphQL::BOOLEAN_TYPE, null: true,
+ description: 'Indicates whether an analyzer is enabled.'
+
+ field :description, GraphQL::STRING_TYPE, null: true,
+ description: 'Analyzer description that is displayed on the form.'
+ end
+ end
+ end
+end
diff --git a/app/graphql/types/ci_configuration/sast/entity_type.rb b/app/graphql/types/ci_configuration/sast/entity_type.rb
new file mode 100644
index 00000000000..b61b582ad20
--- /dev/null
+++ b/app/graphql/types/ci_configuration/sast/entity_type.rb
@@ -0,0 +1,34 @@
+# frozen_string_literal: true
+
+module Types
+ module CiConfiguration
+ module Sast
+ # rubocop: disable Graphql/AuthorizeTypes
+ class EntityType < BaseObject
+ graphql_name 'SastCiConfigurationEntity'
+ description 'Represents an entity in SAST CI configuration'
+
+ field :field, GraphQL::STRING_TYPE, null: true,
+ description: 'CI keyword of entity.'
+
+ field :label, GraphQL::STRING_TYPE, null: true,
+ description: 'Label for entity used in the form.'
+
+ field :type, GraphQL::STRING_TYPE, 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,
+ description: 'Default value that is used if value is empty.'
+
+ field :description, GraphQL::STRING_TYPE, null: true,
+ description: 'Entity description that is displayed on the form.'
+
+ field :value, GraphQL::STRING_TYPE, null: true,
+ description: 'Current value of the entity.'
+ end
+ end
+ end
+end
diff --git a/app/graphql/types/ci_configuration/sast/options_entity_type.rb b/app/graphql/types/ci_configuration/sast/options_entity_type.rb
new file mode 100644
index 00000000000..86d104a7fda
--- /dev/null
+++ b/app/graphql/types/ci_configuration/sast/options_entity_type.rb
@@ -0,0 +1,19 @@
+# frozen_string_literal: true
+
+module Types
+ module CiConfiguration
+ module Sast
+ # rubocop: disable Graphql/AuthorizeTypes
+ class OptionsEntityType < BaseObject
+ graphql_name 'SastCiConfigurationOptionsEntity'
+ description 'Represents an entity for options in SAST CI configuration'
+
+ field :label, GraphQL::STRING_TYPE, null: true,
+ description: 'Label of option entity.'
+
+ field :value, GraphQL::STRING_TYPE, null: true,
+ description: 'Value of option entity.'
+ end
+ end
+ end
+end
diff --git a/app/graphql/types/ci_configuration/sast/type.rb b/app/graphql/types/ci_configuration/sast/type.rb
new file mode 100644
index 00000000000..35d11584ac7
--- /dev/null
+++ b/app/graphql/types/ci_configuration/sast/type.rb
@@ -0,0 +1,22 @@
+# frozen_string_literal: true
+
+module Types
+ module CiConfiguration
+ module Sast
+ # rubocop: disable Graphql/AuthorizeTypes
+ class Type < BaseObject
+ graphql_name 'SastCiConfiguration'
+ description 'Represents a CI configuration of SAST'
+
+ field :global, ::Types::CiConfiguration::Sast::EntityType.connection_type, null: true,
+ description: 'List of global entities related to SAST configuration.'
+
+ field :pipeline, ::Types::CiConfiguration::Sast::EntityType.connection_type, null: true,
+ description: 'List of pipeline entities related to SAST configuration.'
+
+ field :analyzers, ::Types::CiConfiguration::Sast::AnalyzersEntityType.connection_type, null: true,
+ description: 'List of analyzers entities attached to SAST configuration.'
+ end
+ end
+ end
+end
diff --git a/app/graphql/types/container_expiration_policy_type.rb b/app/graphql/types/container_expiration_policy_type.rb
index da53dbcbd39..f19aa964377 100644
--- a/app/graphql/types/container_expiration_policy_type.rb
+++ b/app/graphql/types/container_expiration_policy_type.rb
@@ -14,8 +14,8 @@ module Types
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'
- field :name_regex, GraphQL::STRING_TYPE, null: true, description: 'Tags with names matching this regex pattern will expire'
- field :name_regex_keep, GraphQL::STRING_TYPE, null: true, description: 'Tags with names matching this regex pattern will be preserved'
+ field :name_regex, Types::UntrustedRegexp, null: true, description: 'Tags with names matching this regex pattern will expire'
+ field :name_regex_keep, Types::UntrustedRegexp, null: true, description: 'Tags with names matching this regex pattern will be preserved'
field :next_run_at, Types::TimeType, null: true, description: 'Next time that this container expiration policy will get executed'
end
end
diff --git a/app/graphql/types/deprecated_mutations.rb b/app/graphql/types/deprecated_mutations.rb
new file mode 100644
index 00000000000..a4336fa3ef3
--- /dev/null
+++ b/app/graphql/types/deprecated_mutations.rb
@@ -0,0 +1,19 @@
+# frozen_string_literal: true
+
+module Types
+ module DeprecatedMutations
+ extend ActiveSupport::Concern
+
+ prepended do
+ mount_aliased_mutation 'AddAwardEmoji',
+ Mutations::AwardEmojis::Add,
+ deprecated: { reason: 'Use awardEmojiAdd', milestone: '13.2' }
+ mount_aliased_mutation 'RemoveAwardEmoji',
+ Mutations::AwardEmojis::Remove,
+ deprecated: { reason: 'Use awardEmojiRemove', milestone: '13.2' }
+ mount_aliased_mutation 'ToggleAwardEmoji',
+ Mutations::AwardEmojis::Toggle,
+ deprecated: { reason: 'Use awardEmojiToggle', milestone: '13.2' }
+ end
+ end
+end
diff --git a/app/graphql/types/diff_stats_summary_type.rb b/app/graphql/types/diff_stats_summary_type.rb
new file mode 100644
index 00000000000..956400fd21b
--- /dev/null
+++ b/app/graphql/types/diff_stats_summary_type.rb
@@ -0,0 +1,25 @@
+# frozen_string_literal: true
+
+module Types
+ # rubocop: disable Graphql/AuthorizeTypes
+ # Types that use DiffStatsType should have their own authorization
+ class DiffStatsSummaryType < BaseObject
+ graphql_name 'DiffStatsSummary'
+
+ description 'Aggregated summary of changes'
+
+ field :additions, GraphQL::INT_TYPE, null: false,
+ description: 'Number of lines added'
+ field :deletions, GraphQL::INT_TYPE, null: false,
+ description: 'Number of lines deleted'
+ field :changes, GraphQL::INT_TYPE, null: false,
+ description: 'Number of lines changed'
+ field :file_count, GraphQL::INT_TYPE, null: false,
+ description: 'Number of files changed'
+
+ def changes
+ object[:additions] + object[:deletions]
+ end
+ end
+ # rubocop: enable Graphql/AuthorizeTypes
+end
diff --git a/app/graphql/types/diff_stats_type.rb b/app/graphql/types/diff_stats_type.rb
new file mode 100644
index 00000000000..6c79a4c389d
--- /dev/null
+++ b/app/graphql/types/diff_stats_type.rb
@@ -0,0 +1,19 @@
+# frozen_string_literal: true
+
+module Types
+ # rubocop: disable Graphql/AuthorizeTypes
+ # Types that use DiffStatsType should have their own authorization
+ class DiffStatsType < BaseObject
+ graphql_name 'DiffStats'
+
+ description 'Changes to a single file'
+
+ field :path, GraphQL::STRING_TYPE, null: false,
+ description: 'File path, relative to repository root'
+ field :additions, GraphQL::INT_TYPE, null: false,
+ description: 'Number of lines added to this file'
+ field :deletions, GraphQL::INT_TYPE, null: false,
+ description: 'Number of lines deleted from this file'
+ end
+ # rubocop: enable Graphql/AuthorizeTypes
+end
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 124398f28e7..8bdd8afcbff 100644
--- a/app/graphql/types/error_tracking/sentry_detailed_error_type.rb
+++ b/app/graphql/types/error_tracking/sentry_detailed_error_type.rb
@@ -76,9 +76,15 @@ module Types
description: 'Commit the error was last seen'
field :first_release_short_version, GraphQL::STRING_TYPE,
null: true,
- description: 'Release version the error was first seen'
+ description: 'Release short version the error was first seen'
field :last_release_short_version, GraphQL::STRING_TYPE,
null: true,
+ description: 'Release short version the error was last seen'
+ field :first_release_version, GraphQL::STRING_TYPE,
+ null: true,
+ description: 'Release version the error was first seen'
+ field :last_release_version, GraphQL::STRING_TYPE,
+ null: true,
description: 'Release version the error was last seen'
field :gitlab_commit, GraphQL::STRING_TYPE,
null: true,
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 121146133cb..f423fcb1b9f 100644
--- a/app/graphql/types/error_tracking/sentry_error_collection_type.rb
+++ b/app/graphql/types/error_tracking/sentry_error_collection_type.rb
@@ -17,7 +17,7 @@ module Types
resolver: Resolvers::ErrorTracking::SentryErrorsResolver do
argument :search_term,
String,
- description: 'Search term for the Sentry error.',
+ description: 'Search query for the Sentry error details',
required: false
argument :sort,
String,
diff --git a/app/graphql/types/global_id_type.rb b/app/graphql/types/global_id_type.rb
new file mode 100644
index 00000000000..a3964ba83e1
--- /dev/null
+++ b/app/graphql/types/global_id_type.rb
@@ -0,0 +1,64 @@
+# frozen_string_literal: true
+
+module Types
+ class GlobalIDType < BaseScalar
+ graphql_name 'GlobalID'
+ description 'A global identifier'
+
+ # @param value [GID]
+ # @return [String]
+ def self.coerce_result(value, _ctx)
+ ::Gitlab::GlobalId.as_global_id(value).to_s
+ end
+
+ # @param value [String]
+ # @return [GID]
+ def self.coerce_input(value, _ctx)
+ gid = GlobalID.parse(value)
+ raise GraphQL::CoercionError, "#{value.inspect} is not a valid Global ID" if gid.nil?
+ raise GraphQL::CoercionError, "#{value.inspect} is not a Gitlab Global ID" unless gid.app == GlobalID.app
+
+ gid
+ end
+
+ # Construct a restricted type, that can only be inhabited by an ID of
+ # a given model class.
+ def self.[](model_class)
+ @id_types ||= {}
+
+ @id_types[model_class] ||= Class.new(self) do
+ graphql_name "#{model_class.name.gsub(/::/, '')}ID"
+ description "Identifier of #{model_class.name}"
+
+ self.define_singleton_method(:to_s) do
+ graphql_name
+ end
+
+ self.define_singleton_method(:inspect) do
+ graphql_name
+ end
+
+ self.define_singleton_method(:coerce_result) do |gid, ctx|
+ global_id = ::Gitlab::GlobalId.as_global_id(gid, model_name: model_class.name)
+
+ if suitable?(global_id)
+ global_id.to_s
+ else
+ raise GraphQL::CoercionError, "Expected a #{model_class.name} ID, got #{global_id}"
+ end
+ end
+
+ self.define_singleton_method(:suitable?) do |gid|
+ gid&.model_class&.ancestors&.include?(model_class)
+ end
+
+ self.define_singleton_method(:coerce_input) do |string, ctx|
+ gid = super(string, ctx)
+ raise GraphQL::CoercionError, "#{string.inspect} does not represent an instance of #{model_class.name}" unless suitable?(gid)
+
+ gid
+ end
+ end
+ end
+ end
+end
diff --git a/app/graphql/types/issue_connection_type.rb b/app/graphql/types/issue_connection_type.rb
new file mode 100644
index 00000000000..beed392f01a
--- /dev/null
+++ b/app/graphql/types/issue_connection_type.rb
@@ -0,0 +1,13 @@
+# frozen_string_literal: true
+
+module Types
+ # rubocop: disable Graphql/AuthorizeTypes
+ class IssueConnectionType < GraphQL::Types::Relay::BaseConnection
+ field :count, Integer, null: false,
+ description: 'Total count of collection'
+
+ def count
+ object.items.size
+ end
+ end
+end
diff --git a/app/graphql/types/issue_type.rb b/app/graphql/types/issue_type.rb
index 73219ca9e1e..9baa0018999 100644
--- a/app/graphql/types/issue_type.rb
+++ b/app/graphql/types/issue_type.rb
@@ -4,6 +4,8 @@ module Types
class IssueType < BaseObject
graphql_name 'Issue'
+ connection_type_class(Types::IssueConnectionType)
+
implements(Types::Notes::NoteableType)
authorize :read_issue
@@ -12,6 +14,8 @@ module Types
present_using IssuePresenter
+ field :id, GraphQL::ID_TYPE, null: false,
+ description: "ID of the issue"
field :iid, GraphQL::ID_TYPE, null: false,
description: "Internal ID of the issue"
field :title, GraphQL::STRING_TYPE, null: false,
diff --git a/app/graphql/types/jira_user_type.rb b/app/graphql/types/jira_user_type.rb
index 8aa21ce669b..999526a920e 100644
--- a/app/graphql/types/jira_user_type.rb
+++ b/app/graphql/types/jira_user_type.rb
@@ -13,7 +13,11 @@ module Types
field :jira_email, GraphQL::STRING_TYPE, null: true,
description: 'Email of the Jira user, returned only for users with public emails'
field :gitlab_id, GraphQL::INT_TYPE, null: true,
- description: 'Id of the matched GitLab user'
+ description: 'ID of the matched GitLab user'
+ field :gitlab_username, GraphQL::STRING_TYPE, null: true,
+ description: 'Username of the matched GitLab user'
+ field :gitlab_name, GraphQL::STRING_TYPE, null: true,
+ description: 'Name of the matched GitLab user'
end
# rubocop: enable Graphql/AuthorizeTypes
end
diff --git a/app/graphql/types/jira_users_mapping_input_type.rb b/app/graphql/types/jira_users_mapping_input_type.rb
new file mode 100644
index 00000000000..61cf1474493
--- /dev/null
+++ b/app/graphql/types/jira_users_mapping_input_type.rb
@@ -0,0 +1,18 @@
+# frozen_string_literal: true
+
+module Types
+ # rubocop: disable Graphql/AuthorizeTypes
+ class JiraUsersMappingInputType < BaseInputObject
+ graphql_name 'JiraUsersMappingInputType'
+
+ argument :jira_account_id,
+ GraphQL::STRING_TYPE,
+ required: true,
+ description: 'Jira account id of the user'
+ argument :gitlab_id,
+ GraphQL::INT_TYPE,
+ required: false,
+ description: 'Id of the GitLab user'
+ end
+ # rubocop: enable Graphql/AuthorizeTypes
+end
diff --git a/app/graphql/types/merge_request_type.rb b/app/graphql/types/merge_request_type.rb
index cb4ff7ea0c5..c194b467363 100644
--- a/app/graphql/types/merge_request_type.rb
+++ b/app/graphql/types/merge_request_type.rb
@@ -54,6 +54,13 @@ module Types
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,
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'
+ 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,
description: 'SHA of the merge request commit (set once merged)'
field :user_notes_count, GraphQL::INT_TYPE, null: true,
@@ -134,5 +141,24 @@ module Types
end
field :task_completion_status, Types::TaskCompletionStatus, null: false,
description: Types::TaskCompletionStatus.description
+
+ def diff_stats(path: nil)
+ stats = Array.wrap(object.diff_stats&.to_a)
+
+ if path.present?
+ stats.select { |s| s.path == path }
+ else
+ stats
+ end
+ end
+
+ def diff_stats_summary
+ nil_stats = { additions: 0, deletions: 0, file_count: 0 }
+ return nil_stats unless object.diff_stats.present?
+
+ object.diff_stats.each_with_object(nil_stats) do |status, hash|
+ hash.merge!(additions: status.additions, deletions: status.deletions, file_count: 1) { |_, x, y| x + y }
+ end
+ end
end
end
diff --git a/app/graphql/types/milestone_stats_type.rb b/app/graphql/types/milestone_stats_type.rb
new file mode 100644
index 00000000000..ef533af59e7
--- /dev/null
+++ b/app/graphql/types/milestone_stats_type.rb
@@ -0,0 +1,16 @@
+# frozen_string_literal: true
+
+module Types
+ class MilestoneStatsType < BaseObject
+ graphql_name 'MilestoneStats'
+ description 'Contains statistics about a milestone'
+
+ authorize :read_milestone
+
+ field :total_issues_count, GraphQL::INT_TYPE, null: true,
+ description: 'Total number of issues associated with the milestone'
+
+ field :closed_issues_count, GraphQL::INT_TYPE, 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 99bd6e819d6..ca606c9da44 100644
--- a/app/graphql/types/milestone_type.rb
+++ b/app/graphql/types/milestone_type.rb
@@ -9,6 +9,8 @@ module Types
authorize :read_milestone
+ alias_method :milestone, :object
+
field :id, GraphQL::ID_TYPE, null: false,
description: 'ID of the milestone'
@@ -47,5 +49,14 @@ module Types
field :subgroup_milestone, GraphQL::BOOLEAN_TYPE, null: false,
description: 'Indicates if milestone is at subgroup level',
method: :subgroup_milestone?
+
+ field :stats, Types::MilestoneStatsType, null: true,
+ description: 'Milestone statistics'
+
+ def stats
+ return unless Feature.enabled?(:graphql_milestone_stats, milestone.project || milestone.group, default_enabled: true)
+
+ milestone
+ end
end
end
diff --git a/app/graphql/types/mutation_type.rb b/app/graphql/types/mutation_type.rb
index 8874c56dfdb..49d51b626b2 100644
--- a/app/graphql/types/mutation_type.rb
+++ b/app/graphql/types/mutation_type.rb
@@ -10,6 +10,7 @@ module Types
mount_mutation Mutations::AlertManagement::CreateAlertIssue
mount_mutation Mutations::AlertManagement::UpdateAlertStatus
mount_mutation Mutations::AlertManagement::Alerts::SetAssignees
+ mount_mutation Mutations::AlertManagement::Alerts::Todo::Create
mount_mutation Mutations::AwardEmojis::Add
mount_mutation Mutations::AwardEmojis::Remove
mount_mutation Mutations::AwardEmojis::Toggle
@@ -17,9 +18,11 @@ module Types
mount_mutation Mutations::Commits::Create, calls_gitaly: true
mount_mutation Mutations::Discussions::ToggleResolve
mount_mutation Mutations::Issues::SetConfidential
+ mount_mutation Mutations::Issues::SetLocked
mount_mutation Mutations::Issues::SetDueDate
mount_mutation Mutations::Issues::Update
mount_mutation Mutations::MergeRequests::Create
+ mount_mutation Mutations::MergeRequests::Update
mount_mutation Mutations::MergeRequests::SetLabels
mount_mutation Mutations::MergeRequests::SetLocked
mount_mutation Mutations::MergeRequests::SetMilestone
@@ -56,4 +59,5 @@ module Types
end
end
+::Types::MutationType.prepend(::Types::DeprecatedMutations)
::Types::MutationType.prepend_if_ee('::EE::Types::MutationType')
diff --git a/app/graphql/types/namespace_type.rb b/app/graphql/types/namespace_type.rb
index 1714284a5cf..fbdf049b755 100644
--- a/app/graphql/types/namespace_type.rb
+++ b/app/graphql/types/namespace_type.rb
@@ -38,3 +38,5 @@ module Types
resolver: ::Resolvers::NamespaceProjectsResolver
end
end
+
+Types::NamespaceType.prepend_if_ee('EE::Types::NamespaceType')
diff --git a/app/graphql/types/notes/note_type.rb b/app/graphql/types/notes/note_type.rb
index 8755b4ccad5..5d41f0032bd 100644
--- a/app/graphql/types/notes/note_type.rb
+++ b/app/graphql/types/notes/note_type.rb
@@ -27,6 +27,8 @@ module Types
field :system, GraphQL::BOOLEAN_TYPE,
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,
+ description: 'Name of the icon corresponding to a system note'
field :body, GraphQL::STRING_TYPE,
null: false,
@@ -46,6 +48,10 @@ module Types
field :confidential, GraphQL::BOOLEAN_TYPE, null: true,
description: 'Indicates if this note is confidential',
method: :confidential?
+
+ def system_note_icon_name
+ SystemNoteHelper.system_note_icon_name(object) if object.system?
+ end
end
end
end
diff --git a/app/graphql/types/package_type.rb b/app/graphql/types/package_type.rb
new file mode 100644
index 00000000000..0604bf827a5
--- /dev/null
+++ b/app/graphql/types/package_type.rb
@@ -0,0 +1,16 @@
+# frozen_string_literal: true
+
+module Types
+ class PackageType < BaseObject
+ graphql_name 'Package'
+ description 'Represents a package'
+ authorize :read_package
+
+ field :id, GraphQL::ID_TYPE, null: false, description: 'The ID of the package'
+ field :name, GraphQL::STRING_TYPE, null: false, description: 'The name of the package'
+ field :created_at, Types::TimeType, null: false, description: 'The created date'
+ field :updated_at, Types::TimeType, null: false, description: 'The update date'
+ field :version, GraphQL::STRING_TYPE, null: true, description: 'The version of the package'
+ field :package_type, Types::PackageTypeEnum, null: false, description: 'The type of the package'
+ end
+end
diff --git a/app/graphql/types/package_type_enum.rb b/app/graphql/types/package_type_enum.rb
new file mode 100644
index 00000000000..bc03b8f5f8b
--- /dev/null
+++ b/app/graphql/types/package_type_enum.rb
@@ -0,0 +1,9 @@
+# frozen_string_literal: true
+
+module Types
+ class PackageTypeEnum < BaseEnum
+ ::Packages::Package.package_types.keys.each do |package_type|
+ value package_type.to_s.upcase, "Packages from the #{package_type} package manager", value: package_type.to_s
+ end
+ end
+end
diff --git a/app/graphql/types/project_statistics_type.rb b/app/graphql/types/project_statistics_type.rb
index e1546d31e89..b3916e42e92 100644
--- a/app/graphql/types/project_statistics_type.rb
+++ b/app/graphql/types/project_statistics_type.rb
@@ -21,5 +21,7 @@ module Types
description: 'Packages size of the project'
field :wiki_size, GraphQL::FLOAT_TYPE, null: true,
description: 'Wiki size of the project'
+ field :snippets_size, GraphQL::FLOAT_TYPE, null: true,
+ description: 'Snippets size of the project'
end
end
diff --git a/app/graphql/types/project_type.rb b/app/graphql/types/project_type.rb
index bbfb7fc4f20..2251a0f4e0c 100644
--- a/app/graphql/types/project_type.rb
+++ b/app/graphql/types/project_type.rb
@@ -60,6 +60,12 @@ module Types
field :merge_requests_ff_only_enabled, GraphQL::BOOLEAN_TYPE, 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,
+ description: 'Indicates if the project has service desk enabled.'
+
+ field :service_desk_address, GraphQL::STRING_TYPE, null: true,
+ description: 'E-mail address of the service desk.'
+
field :avatar_url, GraphQL::STRING_TYPE, null: true, calls_gitaly: true,
description: 'URL to avatar image file of the project',
resolve: -> (project, args, ctx) do
@@ -153,12 +159,20 @@ module Types
description: 'Environments of the project',
resolver: Resolvers::EnvironmentsResolver
+ field :sast_ci_configuration, ::Types::CiConfiguration::Sast::Type, null: true,
+ description: 'SAST CI configuration for the project',
+ resolver: ::Resolvers::CiConfiguration::SastResolver
+
field :issue,
Types::IssueType,
null: true,
description: 'A single issue of the project',
resolver: Resolvers::IssuesResolver.single
+ field :packages, Types::PackageType.connection_type, null: true,
+ description: 'Packages of the project',
+ resolver: Resolvers::PackagesResolver
+
field :pipelines,
Types::Ci::PipelineType.connection_type,
null: true,
@@ -243,15 +257,14 @@ module Types
Types::ReleaseType.connection_type,
null: true,
description: 'Releases of the project',
- resolver: Resolvers::ReleasesResolver,
- feature_flag: :graphql_release_data
+ resolver: Resolvers::ReleasesResolver
field :release,
Types::ReleaseType,
null: true,
description: 'A single release of the project',
resolver: Resolvers::ReleasesResolver.single,
- feature_flag: :graphql_release_data
+ authorize: :download_code
field :container_expiration_policy,
Types::ContainerExpirationPolicyType,
diff --git a/app/graphql/types/projects/services/jira_service_type.rb b/app/graphql/types/projects/services/jira_service_type.rb
index e81963f752d..8bf85a14cbf 100644
--- a/app/graphql/types/projects/services/jira_service_type.rb
+++ b/app/graphql/types/projects/services/jira_service_type.rb
@@ -15,7 +15,7 @@ module Types
null: true,
connection: false,
extensions: [Gitlab::Graphql::Extensions::ExternallyPaginatedArrayExtension],
- description: 'List of Jira projects fetched through Jira REST API',
+ description: 'List of all Jira projects fetched through Jira REST API',
resolver: Resolvers::Projects::JiraProjectsResolver
end
end
diff --git a/app/graphql/types/query_type.rb b/app/graphql/types/query_type.rb
index 362e4004b73..b4cbd96bfdb 100644
--- a/app/graphql/types/query_type.rb
+++ b/app/graphql/types/query_type.rb
@@ -61,10 +61,6 @@ module Types
description: 'Text to echo back',
resolver: Resolvers::EchoResolver
- field :user, Types::UserType, null: true,
- description: 'Find a user on this instance',
- resolver: Resolvers::UserResolver
-
def design_management
DesignManagementObject.new(nil)
end
diff --git a/app/graphql/types/release_link_type.rb b/app/graphql/types/release_asset_link_type.rb
index 070f14a90df..21f1bd50cff 100644
--- a/app/graphql/types/release_link_type.rb
+++ b/app/graphql/types/release_asset_link_type.rb
@@ -1,8 +1,9 @@
# frozen_string_literal: true
module Types
- class ReleaseLinkType < BaseObject
- graphql_name 'ReleaseLink'
+ class ReleaseAssetLinkType < BaseObject
+ graphql_name 'ReleaseAssetLink'
+ description 'Represents an asset link associated with a release'
authorize :read_release
@@ -12,7 +13,7 @@ module Types
description: 'Name of the link'
field :url, GraphQL::STRING_TYPE, null: true,
description: 'URL of the link'
- field :link_type, Types::ReleaseLinkTypeEnum, null: true,
+ 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?,
description: 'Indicates the link points to an external resource'
diff --git a/app/graphql/types/release_link_type_enum.rb b/app/graphql/types/release_asset_link_type_enum.rb
index b364855833f..01862ada56d 100644
--- a/app/graphql/types/release_link_type_enum.rb
+++ b/app/graphql/types/release_asset_link_type_enum.rb
@@ -1,8 +1,8 @@
# frozen_string_literal: true
module Types
- class ReleaseLinkTypeEnum < BaseEnum
- graphql_name 'ReleaseLinkType'
+ class ReleaseAssetLinkTypeEnum < BaseEnum
+ graphql_name 'ReleaseAssetLinkType'
description 'Type of the link: `other`, `runbook`, `image`, `package`; defaults to `other`'
::Releases::Link.link_types.keys.each do |link_type|
diff --git a/app/graphql/types/release_assets_type.rb b/app/graphql/types/release_assets_type.rb
index 58ad05b5365..d6042bdbc0b 100644
--- a/app/graphql/types/release_assets_type.rb
+++ b/app/graphql/types/release_assets_type.rb
@@ -3,6 +3,7 @@
module Types
class ReleaseAssetsType < BaseObject
graphql_name 'ReleaseAssets'
+ description 'A container for all assets associated with a release'
authorize :read_release
@@ -10,9 +11,9 @@ module Types
present_using ReleasePresenter
- field :assets_count, GraphQL::INT_TYPE, null: true,
+ field :count, GraphQL::INT_TYPE, null: true, method: :assets_count,
description: 'Number of assets of the release'
- field :links, Types::ReleaseLinkType.connection_type, null: true,
+ field :links, Types::ReleaseAssetLinkType.connection_type, null: true,
description: 'Asset links of the release'
field :sources, Types::ReleaseSourceType.connection_type, null: true,
description: 'Sources of the release'
diff --git a/app/graphql/types/release_links_type.rb b/app/graphql/types/release_links_type.rb
new file mode 100644
index 00000000000..f61a16f5b67
--- /dev/null
+++ b/app/graphql/types/release_links_type.rb
@@ -0,0 +1,23 @@
+# frozen_string_literal: true
+
+module Types
+ class ReleaseLinksType < BaseObject
+ graphql_name 'ReleaseLinks'
+
+ authorize :download_code
+
+ alias_method :release, :object
+
+ present_using ReleasePresenter
+
+ field :self_url, GraphQL::STRING_TYPE, null: true,
+ description: 'HTTP URL of the release'
+ field :merge_requests_url, GraphQL::STRING_TYPE, null: true,
+ description: 'HTTP URL of the merge request page filtered by this release'
+ field :issues_url, GraphQL::STRING_TYPE, null: true,
+ description: 'HTTP URL of the issues page filtered by this release'
+ field :edit_url, GraphQL::STRING_TYPE, null: true,
+ description: "HTTP URL of the release's edit page",
+ authorize: :update_release
+ end
+end
diff --git a/app/graphql/types/release_source_type.rb b/app/graphql/types/release_source_type.rb
index 0ec1ad85a39..891da472116 100644
--- a/app/graphql/types/release_source_type.rb
+++ b/app/graphql/types/release_source_type.rb
@@ -3,8 +3,9 @@
module Types
class ReleaseSourceType < BaseObject
graphql_name 'ReleaseSource'
+ description 'Represents the source code attached to a release in a particular format'
- authorize :read_release_sources
+ authorize :download_code
field :format, GraphQL::STRING_TYPE, null: true,
description: 'Format of the source'
diff --git a/app/graphql/types/release_type.rb b/app/graphql/types/release_type.rb
index 3d8e5a93c68..a0703b96a36 100644
--- a/app/graphql/types/release_type.rb
+++ b/app/graphql/types/release_type.rb
@@ -3,6 +3,7 @@
module Types
class ReleaseType < BaseObject
graphql_name 'Release'
+ description 'Represents a release'
authorize :read_release
@@ -10,10 +11,12 @@ module Types
present_using ReleasePresenter
- field :tag_name, GraphQL::STRING_TYPE, null: false, method: :tag,
- description: 'Name of the tag associated with the release'
+ field :tag_name, GraphQL::STRING_TYPE, null: true, method: :tag,
+ description: 'Name of the tag associated with the release',
+ authorize: :download_code
field :tag_path, GraphQL::STRING_TYPE, null: true,
- description: 'Relative web path to the tag associated with the release'
+ description: 'Relative web path to the tag associated with the release',
+ authorize: :download_code
field :description, GraphQL::STRING_TYPE, null: true,
description: 'Description (also known as "release notes") of the release'
markdown_field :description_html, null: true
@@ -25,6 +28,8 @@ module Types
description: 'Timestamp of when the release was released'
field :assets, Types::ReleaseAssetsType, null: true, method: :itself,
description: 'Assets of the release'
+ field :links, Types::ReleaseLinksType, null: true, method: :itself,
+ description: 'Links of the release'
field :milestones, Types::MilestoneType.connection_type, null: true,
description: 'Milestones associated to the release'
field :evidences, Types::EvidenceType.connection_type, null: true,
@@ -39,8 +44,7 @@ module Types
field :commit, Types::CommitType, null: true,
complexity: 10, calls_gitaly: true,
- description: 'The commit associated with the release',
- authorize: :reporter_access
+ description: 'The commit associated with the release'
def commit
return if release.sha.nil?
diff --git a/app/graphql/types/root_storage_statistics_type.rb b/app/graphql/types/root_storage_statistics_type.rb
index e2d85aebc48..3acc1d9ca44 100644
--- a/app/graphql/types/root_storage_statistics_type.rb
+++ b/app/graphql/types/root_storage_statistics_type.rb
@@ -12,5 +12,6 @@ module Types
field :build_artifacts_size, GraphQL::FLOAT_TYPE, null: false, description: 'The CI artifacts size in bytes'
field :packages_size, GraphQL::FLOAT_TYPE, null: false, description: 'The packages size in bytes'
field :wiki_size, GraphQL::FLOAT_TYPE, null: false, description: 'The wiki size in bytes'
+ field :snippets_size, GraphQL::FLOAT_TYPE, null: false, description: 'The snippets size in bytes'
end
end
diff --git a/app/graphql/types/todo_target_enum.rb b/app/graphql/types/todo_target_enum.rb
index a377c3aafdc..b797722fef8 100644
--- a/app/graphql/types/todo_target_enum.rb
+++ b/app/graphql/types/todo_target_enum.rb
@@ -6,6 +6,7 @@ module Types
value 'ISSUE', value: 'Issue', description: 'An Issue'
value 'MERGEREQUEST', value: 'MergeRequest', description: 'A MergeRequest'
value 'DESIGN', value: 'DesignManagement::Design', description: 'A Design'
+ value 'ALERT', value: 'AlertManagement::Alert', description: 'An Alert'
end
end
diff --git a/app/graphql/types/tree/blob_type.rb b/app/graphql/types/tree/blob_type.rb
index 22349203519..36cae756a0d 100644
--- a/app/graphql/types/tree/blob_type.rb
+++ b/app/graphql/types/tree/blob_type.rb
@@ -17,6 +17,8 @@ module Types
resolve: -> (blob, args, ctx) do
Gitlab::Graphql::Loaders::BatchLfsOidLoader.new(blob.repository, blob.id).find
end
+ field :mode, GraphQL::STRING_TYPE, null: true,
+ description: 'Blob mode in numeric format'
# rubocop: enable Graphql/AuthorizeTypes
end
end
diff --git a/app/graphql/types/untrusted_regexp.rb b/app/graphql/types/untrusted_regexp.rb
new file mode 100644
index 00000000000..2c715ab4967
--- /dev/null
+++ b/app/graphql/types/untrusted_regexp.rb
@@ -0,0 +1,22 @@
+# frozen_string_literal: true
+
+module Types
+ class UntrustedRegexp < Types::BaseScalar
+ description 'A regexp containing patterns sourced from user input'
+
+ def self.coerce_input(input_value, _)
+ return unless input_value
+
+ Gitlab::UntrustedRegexp.new(input_value)
+
+ input_value
+ rescue RegexpError => e
+ message = "#{input_value} is an invalid regexp: #{e.message}"
+ raise GraphQL::CoercionError, message
+ end
+
+ def self.coerce_result(ruby_value, _)
+ ruby_value.to_s
+ end
+ end
+end