summaryrefslogtreecommitdiff
path: root/app/graphql/types
diff options
context:
space:
mode:
Diffstat (limited to 'app/graphql/types')
-rw-r--r--app/graphql/types/admin/analytics/usage_trends/measurement_type.rb3
-rw-r--r--app/graphql/types/alert_management/prometheus_integration_type.rb4
-rw-r--r--app/graphql/types/board_list_type.rb4
-rw-r--r--app/graphql/types/ci/pipeline_counts_type.rb24
-rw-r--r--app/graphql/types/ci/runner_sort_enum.rb2
-rw-r--r--app/graphql/types/ci/runner_status_enum.rb12
-rw-r--r--app/graphql/types/ci/runner_type.rb50
-rw-r--r--app/graphql/types/clusters/agent_activity_event_type.rb2
-rw-r--r--app/graphql/types/clusters/agent_token_type.rb2
-rw-r--r--app/graphql/types/clusters/agent_type.rb2
-rw-r--r--app/graphql/types/commit_type.rb14
-rw-r--r--app/graphql/types/group_invitation_type.rb6
-rw-r--r--app/graphql/types/group_member_type.rb6
-rw-r--r--app/graphql/types/group_type.rb24
-rw-r--r--app/graphql/types/issuable_type.rb4
-rw-r--r--app/graphql/types/issue_type.rb11
-rw-r--r--app/graphql/types/label_type.rb3
-rw-r--r--app/graphql/types/member_interface.rb12
-rw-r--r--app/graphql/types/merge_request_sort_enum.rb2
-rw-r--r--app/graphql/types/merge_requests/assignee_type.rb5
-rw-r--r--app/graphql/types/merge_requests/interacts_with_merge_request.rb5
-rw-r--r--app/graphql/types/merge_requests/reviewer_type.rb5
-rw-r--r--app/graphql/types/metrics/dashboards/annotation_type.rb2
-rw-r--r--app/graphql/types/mutation_type.rb9
-rw-r--r--app/graphql/types/notes/discussion_type.rb4
-rw-r--r--app/graphql/types/packages/package_details_type.rb15
-rw-r--r--app/graphql/types/permission_types/issue.rb2
-rw-r--r--app/graphql/types/permission_types/merge_request.rb9
-rw-r--r--app/graphql/types/project_type.rb14
-rw-r--r--app/graphql/types/query_complexity_type.rb4
-rw-r--r--app/graphql/types/repository/blob_type.rb18
-rw-r--r--app/graphql/types/root_storage_statistics_type.rb1
-rw-r--r--app/graphql/types/subscription_type.rb3
-rw-r--r--app/graphql/types/terraform/state_version_type.rb4
-rw-r--r--app/graphql/types/tree/blob_type.rb5
-rw-r--r--app/graphql/types/tree/submodule_type.rb4
-rw-r--r--app/graphql/types/tree/tree_entry_type.rb7
-rw-r--r--app/graphql/types/user_interface.rb4
-rw-r--r--app/graphql/types/user_preferences_type.rb17
-rw-r--r--app/graphql/types/work_item_state_enum.rb11
-rw-r--r--app/graphql/types/work_item_type.rb2
-rw-r--r--app/graphql/types/work_items/state_event_enum.rb13
42 files changed, 267 insertions, 83 deletions
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 8276549ddcc..1fc47303d67 100644
--- a/app/graphql/types/admin/analytics/usage_trends/measurement_type.rb
+++ b/app/graphql/types/admin/analytics/usage_trends/measurement_type.rb
@@ -5,10 +5,11 @@ module Types
module Analytics
module UsageTrends
class MeasurementType < BaseObject
- include Gitlab::Graphql::Authorize::AuthorizeResource
graphql_name 'UsageTrendsMeasurement'
description 'Represents a recorded measurement (object count) for the Admins'
+ include Gitlab::Graphql::Authorize::AuthorizeResource
+
authorize :read_usage_trends_measurement
field :recorded_at, Types::TimeType, null: true,
diff --git a/app/graphql/types/alert_management/prometheus_integration_type.rb b/app/graphql/types/alert_management/prometheus_integration_type.rb
index 27e4832d8f6..9a2ef78eca7 100644
--- a/app/graphql/types/alert_management/prometheus_integration_type.rb
+++ b/app/graphql/types/alert_management/prometheus_integration_type.rb
@@ -3,11 +3,11 @@
module Types
module AlertManagement
class PrometheusIntegrationType < ::Types::BaseObject
- include ::Gitlab::Routing
-
graphql_name 'AlertManagementPrometheusIntegration'
description 'An endpoint and credentials used to accept Prometheus alerts for a project'
+ include ::Gitlab::Routing
+
implements(Types::AlertManagement::IntegrationType)
authorize :admin_project
diff --git a/app/graphql/types/board_list_type.rb b/app/graphql/types/board_list_type.rb
index 8c67803e39e..733006369ea 100644
--- a/app/graphql/types/board_list_type.rb
+++ b/app/graphql/types/board_list_type.rb
@@ -3,11 +3,11 @@
module Types
# rubocop: disable Graphql/AuthorizeTypes
class BoardListType < BaseObject
- include Gitlab::Utils::StrongMemoize
-
graphql_name 'BoardList'
description 'Represents a list for an issue board'
+ include Gitlab::Utils::StrongMemoize
+
alias_method :list, :object
field :id, GraphQL::Types::ID,
diff --git a/app/graphql/types/ci/pipeline_counts_type.rb b/app/graphql/types/ci/pipeline_counts_type.rb
new file mode 100644
index 00000000000..9c2b822091e
--- /dev/null
+++ b/app/graphql/types/ci/pipeline_counts_type.rb
@@ -0,0 +1,24 @@
+# frozen_string_literal: true
+
+module Types
+ module Ci
+ class PipelineCountsType < BaseObject
+ graphql_name 'PipelineCounts'
+ description "Represents pipeline counts for the project"
+
+ authorize :read_pipeline
+
+ (::Types::Ci::PipelineScopeEnum.values.keys - %w[BRANCHES TAGS]).each do |scope|
+ field scope.downcase,
+ GraphQL::Types::Int,
+ null: true,
+ description: "Number of pipelines with scope #{scope} for the project"
+ end
+
+ field :all,
+ GraphQL::Types::Int,
+ null: true,
+ description: 'Total number of pipelines for the project.'
+ end
+ end
+end
diff --git a/app/graphql/types/ci/runner_sort_enum.rb b/app/graphql/types/ci/runner_sort_enum.rb
index 95ec1867fea..8f2a13bd699 100644
--- a/app/graphql/types/ci/runner_sort_enum.rb
+++ b/app/graphql/types/ci/runner_sort_enum.rb
@@ -10,6 +10,8 @@ module Types
value 'CONTACTED_DESC', 'Ordered by contacted_at in descending order.', value: :contacted_desc
value 'CREATED_ASC', 'Ordered by created_at in ascending order.', value: :created_at_asc
value 'CREATED_DESC', 'Ordered by created_at in descending order.', value: :created_at_desc
+ value 'TOKEN_EXPIRES_AT_ASC', 'Ordered by token_expires_at in ascending order.', value: :token_expires_at_asc
+ value 'TOKEN_EXPIRES_AT_DESC', 'Ordered by token_expires_at in descending order.', value: :token_expires_at_desc
end
end
end
diff --git a/app/graphql/types/ci/runner_status_enum.rb b/app/graphql/types/ci/runner_status_enum.rb
index dd056191ceb..2e65e2d4e1e 100644
--- a/app/graphql/types/ci/runner_status_enum.rb
+++ b/app/graphql/types/ci/runner_status_enum.rb
@@ -7,12 +7,20 @@ module Types
value 'ACTIVE',
description: 'Runner that is not paused.',
- deprecated: { reason: 'Use CiRunnerType.active instead', milestone: '14.6' },
+ deprecated: {
+ reason: :renamed,
+ replacement: 'CiRunner.paused',
+ milestone: '14.6'
+ },
value: :active
value 'PAUSED',
description: 'Runner that is paused.',
- deprecated: { reason: 'Use CiRunnerType.active instead', milestone: '14.6' },
+ deprecated: {
+ reason: :renamed,
+ replacement: 'CiRunner.paused',
+ milestone: '14.6'
+ },
value: :paused
value 'ONLINE',
diff --git a/app/graphql/types/ci/runner_type.rb b/app/graphql/types/ci/runner_type.rb
index 4fe65734911..9094c6b96e4 100644
--- a/app/graphql/types/ci/runner_type.rb
+++ b/app/graphql/types/ci/runner_type.rb
@@ -3,12 +3,13 @@
module Types
module Ci
class RunnerType < BaseObject
+ graphql_name 'CiRunner'
+
edge_type_class(RunnerWebUrlEdge)
connection_type_class(Types::CountableConnectionType)
- graphql_name 'CiRunner'
+
authorize :read_runner
present_using ::Ci::RunnerPresenter
-
expose_permissions Types::PermissionTypes::Ci::Runner
JOB_COUNT_LIMIT = 1000
@@ -24,12 +25,18 @@ module Types
field :contacted_at, Types::TimeType, null: true,
description: 'Timestamp of last contact from this runner.',
method: :contacted_at
+ field :token_expires_at, Types::TimeType, null: true,
+ description: 'Runner token expiration time.',
+ method: :token_expires_at
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::Types::Boolean, null: false,
- description: 'Indicates the runner is allowed to receive jobs.'
+ description: 'Indicates the runner is allowed to receive jobs.',
+ deprecated: { reason: 'Use paused', milestone: '14.8' }
+ field :paused, GraphQL::Types::Boolean, null: false,
+ description: 'Indicates the runner is paused and not available to run jobs.'
field :status,
Types::Ci::RunnerStatusEnum,
null: false,
@@ -63,6 +70,14 @@ module Types
description: 'Executor last advertised by the runner.',
method: :executor_name,
feature_flag: :graphql_ci_runner_executor
+ field :groups, ::Types::GroupType.connection_type, null: true,
+ description: 'Groups the runner is associated with. For group runners only.'
+ field :projects, ::Types::ProjectType.connection_type, null: true,
+ description: 'Projects the runner is associated with. For project runners only.'
+ field :jobs, ::Types::Ci::JobType.connection_type, null: true,
+ description: 'Jobs assigned to the runner.',
+ authorize: :read_builds,
+ resolver: ::Resolvers::Ci::RunnerJobsResolver
def job_count
# We limit to 1 above the JOB_COUNT_LIMIT to indicate that more items exist after JOB_COUNT_LIMIT
@@ -94,11 +109,40 @@ module Types
end
# rubocop: enable CodeReuse/ActiveRecord
+ def groups
+ return unless runner.group_type?
+
+ batched_owners(::Ci::RunnerNamespace, Group, :runner_groups, :namespace_id)
+ end
+
+ def projects
+ return unless runner.project_type?
+
+ batched_owners(::Ci::RunnerProject, Project, :runner_projects, :project_id)
+ end
+
private
def can_admin_runners?
context[:current_user]&.can_admin_all_resources?
end
+
+ # rubocop: disable CodeReuse/ActiveRecord
+ def batched_owners(runner_assoc_type, assoc_type, key, column_name)
+ BatchLoader::GraphQL.for(runner.id).batch(key: key) do |runner_ids, loader, args|
+ runner_and_owner_ids = runner_assoc_type.where(runner_id: runner_ids).pluck(:runner_id, column_name)
+
+ owner_ids_by_runner_id = runner_and_owner_ids.group_by(&:first).transform_values { |v| v.pluck(1) }
+ owner_ids = runner_and_owner_ids.pluck(1).uniq
+
+ owners = assoc_type.where(id: owner_ids).index_by(&:id)
+
+ runner_ids.each do |runner_id|
+ loader.call(runner_id, owner_ids_by_runner_id[runner_id]&.map { |owner_id| owners[owner_id] } || [])
+ end
+ end
+ end
+ # rubocop: enable CodeReuse/ActiveRecord
end
end
end
diff --git a/app/graphql/types/clusters/agent_activity_event_type.rb b/app/graphql/types/clusters/agent_activity_event_type.rb
index 79a9fd70505..3484acfe25e 100644
--- a/app/graphql/types/clusters/agent_activity_event_type.rb
+++ b/app/graphql/types/clusters/agent_activity_event_type.rb
@@ -5,7 +5,7 @@ module Types
class AgentActivityEventType < BaseObject
graphql_name 'ClusterAgentActivityEvent'
- authorize :admin_cluster
+ authorize :read_cluster
connection_type_class(Types::CountableConnectionType)
diff --git a/app/graphql/types/clusters/agent_token_type.rb b/app/graphql/types/clusters/agent_token_type.rb
index 96fdb5f05c8..24489707698 100644
--- a/app/graphql/types/clusters/agent_token_type.rb
+++ b/app/graphql/types/clusters/agent_token_type.rb
@@ -5,7 +5,7 @@ module Types
class AgentTokenType < BaseObject
graphql_name 'ClusterAgentToken'
- authorize :admin_cluster
+ authorize :read_cluster
connection_type_class(Types::CountableConnectionType)
diff --git a/app/graphql/types/clusters/agent_type.rb b/app/graphql/types/clusters/agent_type.rb
index 89316ed4728..546252b2285 100644
--- a/app/graphql/types/clusters/agent_type.rb
+++ b/app/graphql/types/clusters/agent_type.rb
@@ -5,7 +5,7 @@ module Types
class AgentType < BaseObject
graphql_name 'ClusterAgent'
- authorize :admin_cluster
+ authorize :read_cluster
connection_type_class(Types::CountableConnectionType)
diff --git a/app/graphql/types/commit_type.rb b/app/graphql/types/commit_type.rb
index 2584e15ff0b..8bc00359ccb 100644
--- a/app/graphql/types/commit_type.rb
+++ b/app/graphql/types/commit_type.rb
@@ -10,33 +10,37 @@ module Types
field :id, type: GraphQL::Types::ID, null: false,
description: 'ID (global ID) of the commit.'
+
field :sha, type: GraphQL::Types::String, null: false,
description: 'SHA1 ID of the commit.'
+
field :short_id, type: GraphQL::Types::String, null: false,
description: 'Short SHA1 ID of the commit.'
field :title, type: GraphQL::Types::String, null: true, calls_gitaly: true,
description: 'Title of the commit message.'
- markdown_field :title_html, null: true
field :full_title, type: GraphQL::Types::String, null: true, calls_gitaly: true,
description: 'Full title of the commit message.'
- markdown_field :full_title_html, 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::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::Types::String, null: false,
description: 'Web URL of the commit.'
+
field :web_path, type: GraphQL::Types::String, null: false,
description: 'Web path of the commit.'
+
field :signature_html, type: GraphQL::Types::String, null: true, calls_gitaly: true,
description: 'Rendered HTML of the commit signature.'
+
field :author_name, type: GraphQL::Types::String, null: true,
description: 'Commit authors name.'
field :author_email, type: GraphQL::Types::String, null: true,
@@ -53,6 +57,10 @@ module Types
description: 'Pipelines of the commit ordered latest first.',
resolver: Resolvers::CommitPipelinesResolver
+ markdown_field :title_html, null: true
+ markdown_field :full_title_html, null: true
+ markdown_field :description_html, null: true
+
def author_gravatar
GravatarService.new.execute(object.author_email, 40)
end
diff --git a/app/graphql/types/group_invitation_type.rb b/app/graphql/types/group_invitation_type.rb
index 9410253553c..48281dcfd9f 100644
--- a/app/graphql/types/group_invitation_type.rb
+++ b/app/graphql/types/group_invitation_type.rb
@@ -2,14 +2,14 @@
module Types
class GroupInvitationType < BaseObject
+ graphql_name 'GroupInvitation'
+ description 'Represents a Group Invitation'
+
expose_permissions Types::PermissionTypes::Group
authorize :admin_group
implements InvitationInterface
- graphql_name 'GroupInvitation'
- description 'Represents a Group Invitation'
-
field :group, Types::GroupType, null: true,
description: 'Group that a User is invited to.'
diff --git a/app/graphql/types/group_member_type.rb b/app/graphql/types/group_member_type.rb
index 8b8e69d795d..d68abc11bba 100644
--- a/app/graphql/types/group_member_type.rb
+++ b/app/graphql/types/group_member_type.rb
@@ -2,14 +2,14 @@
module Types
class GroupMemberType < BaseObject
+ graphql_name 'GroupMember'
+ description 'Represents a Group Membership'
+
expose_permissions Types::PermissionTypes::Group
authorize :read_group
implements MemberInterface
- graphql_name 'GroupMember'
- description 'Represents a Group Membership'
-
field :group, Types::GroupType, null: true,
description: 'Group that a User is a member of.'
diff --git a/app/graphql/types/group_type.rb b/app/graphql/types/group_type.rb
index e02650fd285..5f63aa20953 100644
--- a/app/graphql/types/group_type.rb
+++ b/app/graphql/types/group_type.rb
@@ -94,6 +94,12 @@ module Types
max_page_size: 2000,
resolver: Resolvers::BoardsResolver
+ field :recent_issue_boards,
+ Types::BoardType.connection_type,
+ null: true,
+ description: 'List of recently visited boards of the group. Maximum size is 4.',
+ resolver: Resolvers::RecentBoardsResolver
+
field :board,
Types::BoardType,
null: true,
@@ -170,15 +176,6 @@ module Types
null: true,
description: 'Dependency proxy TTL policy for the group.'
- def label(title:)
- BatchLoader::GraphQL.for(title).batch(key: group) do |titles, loader, args|
- LabelsFinder
- .new(current_user, group: args[:key], title: titles)
- .execute
- .each { |label| loader.call(label.title, label) }
- end
- end
-
field :labels,
Types::LabelType.connection_type,
null: true,
@@ -215,6 +212,15 @@ module Types
description: 'Work item types available to the group.',
feature_flag: :work_items
+ def label(title:)
+ BatchLoader::GraphQL.for(title).batch(key: group) do |titles, loader, args|
+ LabelsFinder
+ .new(current_user, group: args[:key], title: titles)
+ .execute
+ .each { |label| loader.call(label.title, label) }
+ end
+ end
+
def avatar_url
object.avatar_url(only_path: false)
end
diff --git a/app/graphql/types/issuable_type.rb b/app/graphql/types/issuable_type.rb
index 6ca74087f8a..4a39b5ed6ec 100644
--- a/app/graphql/types/issuable_type.rb
+++ b/app/graphql/types/issuable_type.rb
@@ -5,10 +5,12 @@ module Types
graphql_name 'Issuable'
description 'Represents an issuable.'
- possible_types Types::IssueType, Types::MergeRequestType
+ possible_types Types::IssueType, Types::MergeRequestType, Types::WorkItemType
def self.resolve_type(object, context)
case object
+ when WorkItem
+ Types::WorkItemType
when Issue
Types::IssueType
when MergeRequest
diff --git a/app/graphql/types/issue_type.rb b/app/graphql/types/issue_type.rb
index 46fe91feae4..ee57961ee4a 100644
--- a/app/graphql/types/issue_type.rb
+++ b/app/graphql/types/issue_type.rb
@@ -21,10 +21,8 @@ module Types
description: "Internal ID of the issue."
field :title, GraphQL::Types::String, null: false,
description: 'Title of the issue.'
- markdown_field :title_html, 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.'
@@ -143,6 +141,9 @@ module Types
field :escalation_status, Types::IncidentManagement::EscalationStatusEnum, null: true,
description: 'Escalation status of the issue.'
+ markdown_field :title_html, null: true
+ markdown_field :description_html, null: true
+
def author
Gitlab::Graphql::Loaders::BatchModelLoader.new(User, object.author_id).find
end
@@ -168,13 +169,11 @@ module Types
end
def hidden?
- object.hidden? if Feature.enabled?(:ban_user_feature_flag)
+ object.hidden? if Feature.enabled?(:ban_user_feature_flag, default_enabled: :yaml)
end
def escalation_status
- return unless Feature.enabled?(:incident_escalations, object.project) && object.supports_escalation?
-
- object.escalation_status&.status_name
+ object.supports_escalation? ? object.escalation_status&.status_name : nil
end
end
end
diff --git a/app/graphql/types/label_type.rb b/app/graphql/types/label_type.rb
index bb2d561014e..5a10bcfee74 100644
--- a/app/graphql/types/label_type.rb
+++ b/app/graphql/types/label_type.rb
@@ -12,7 +12,6 @@ module Types
description: 'Label ID.'
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::Types::String, null: false,
description: 'Content of the label.'
field :color, GraphQL::Types::String, null: false,
@@ -23,5 +22,7 @@ module Types
description: 'When this label was created.'
field :updated_at, Types::TimeType, null: false,
description: 'When this label was last updated.'
+
+ markdown_field :description_html, null: true
end
end
diff --git a/app/graphql/types/member_interface.rb b/app/graphql/types/member_interface.rb
index c5623cd4710..67d0e18b522 100644
--- a/app/graphql/types/member_interface.rb
+++ b/app/graphql/types/member_interface.rb
@@ -25,6 +25,12 @@ module Types
field :user, Types::UserType, null: true,
description: 'User that is associated with the member object.'
+ field :merge_request_interaction, Types::UserMergeRequestInteractionType,
+ null: true,
+ description: 'Find a merge request.' do
+ argument :id, ::Types::GlobalIDType[::MergeRequest], required: true, description: 'Global ID of the merge request.'
+ end
+
definition_methods do
def resolve_type(object, context)
case object
@@ -37,5 +43,11 @@ module Types
end
end
end
+
+ def merge_request_interaction(id: nil)
+ Gitlab::Graphql::Lazy.with_value(GitlabSchema.object_from_id(id, expected_class: ::MergeRequest)) do |merge_request|
+ Users::MergeRequestInteraction.new(user: object.user, merge_request: merge_request) if merge_request
+ end
+ end
end
end
diff --git a/app/graphql/types/merge_request_sort_enum.rb b/app/graphql/types/merge_request_sort_enum.rb
index d75eae6abc4..a74c5a01769 100644
--- a/app/graphql/types/merge_request_sort_enum.rb
+++ b/app/graphql/types/merge_request_sort_enum.rb
@@ -9,5 +9,7 @@ module Types
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
+ value 'TITLE_ASC', 'Title by ascending order.', value: :title_asc
+ value 'TITLE_DESC', 'Title by descending order.', value: :title_desc
end
end
diff --git a/app/graphql/types/merge_requests/assignee_type.rb b/app/graphql/types/merge_requests/assignee_type.rb
index 8448477370e..24321d057a3 100644
--- a/app/graphql/types/merge_requests/assignee_type.rb
+++ b/app/graphql/types/merge_requests/assignee_type.rb
@@ -3,11 +3,12 @@
module Types
module MergeRequests
class AssigneeType < ::Types::UserType
+ graphql_name 'MergeRequestAssignee'
+ description 'A user assigned to a merge request.'
+
include FindClosest
include ::Types::MergeRequests::InteractsWithMergeRequest
- graphql_name 'MergeRequestAssignee'
- description 'A user assigned to a merge request.'
authorize :read_user
end
end
diff --git a/app/graphql/types/merge_requests/interacts_with_merge_request.rb b/app/graphql/types/merge_requests/interacts_with_merge_request.rb
index d4a1f2faa8d..15621ef1472 100644
--- a/app/graphql/types/merge_requests/interacts_with_merge_request.rb
+++ b/app/graphql/types/merge_requests/interacts_with_merge_request.rb
@@ -5,6 +5,8 @@ module Types
module InteractsWithMergeRequest
extend ActiveSupport::Concern
+ include FindClosest
+
included do
field :merge_request_interaction,
type: ::Types::UserMergeRequestInteractionType,
@@ -13,8 +15,9 @@ module Types
description: "Details of this user's interactions with the merge request."
end
- def merge_request_interaction(parent:)
+ def merge_request_interaction(parent:, id: nil)
merge_request = closest_parent([::Types::MergeRequestType], parent)
+
return unless merge_request
Users::MergeRequestInteraction.new(user: object, merge_request: merge_request)
diff --git a/app/graphql/types/merge_requests/reviewer_type.rb b/app/graphql/types/merge_requests/reviewer_type.rb
index 1ced821c839..11f7ceaf461 100644
--- a/app/graphql/types/merge_requests/reviewer_type.rb
+++ b/app/graphql/types/merge_requests/reviewer_type.rb
@@ -3,11 +3,12 @@
module Types
module MergeRequests
class ReviewerType < ::Types::UserType
+ graphql_name 'MergeRequestReviewer'
+ description 'A user assigned to a merge request as a reviewer.'
+
include FindClosest
include ::Types::MergeRequests::InteractsWithMergeRequest
- graphql_name 'MergeRequestReviewer'
- description 'A user assigned to a merge request as a reviewer.'
authorize :read_user
end
end
diff --git a/app/graphql/types/metrics/dashboards/annotation_type.rb b/app/graphql/types/metrics/dashboards/annotation_type.rb
index fb35f2bd9a1..0c787476f54 100644
--- a/app/graphql/types/metrics/dashboards/annotation_type.rb
+++ b/app/graphql/types/metrics/dashboards/annotation_type.rb
@@ -4,8 +4,8 @@ module Types
module Metrics
module Dashboards
class AnnotationType < ::Types::BaseObject
- authorize :read_metrics_dashboard_annotation
graphql_name 'MetricsDashboardAnnotation'
+ authorize :read_metrics_dashboard_annotation
field :description, GraphQL::Types::String, null: true,
description: 'Description of the annotation.'
diff --git a/app/graphql/types/mutation_type.rb b/app/graphql/types/mutation_type.rb
index c350f4dd922..3c735231595 100644
--- a/app/graphql/types/mutation_type.rb
+++ b/app/graphql/types/mutation_type.rb
@@ -2,10 +2,10 @@
module Types
class MutationType < BaseObject
- include Gitlab::Graphql::MountMutation
-
graphql_name 'Mutation'
+ include Gitlab::Graphql::MountMutation
+
mount_mutation Mutations::Admin::SidekiqQueues::DeleteJobs
mount_mutation Mutations::AlertManagement::CreateAlertIssue
mount_mutation Mutations::AlertManagement::UpdateAlertStatus
@@ -121,10 +121,13 @@ module Types
mount_mutation Mutations::Namespace::PackageSettings::Update
mount_mutation Mutations::Groups::Update
mount_mutation Mutations::UserCallouts::Create
+ mount_mutation Mutations::UserPreferences::Update
mount_mutation Mutations::Packages::Destroy
mount_mutation Mutations::Packages::DestroyFile
mount_mutation Mutations::Echo
- mount_mutation Mutations::WorkItems::Create, feature_flag: :work_items
+ mount_mutation Mutations::WorkItems::Create
+ mount_mutation Mutations::WorkItems::Delete
+ mount_mutation Mutations::WorkItems::Update
end
end
diff --git a/app/graphql/types/notes/discussion_type.rb b/app/graphql/types/notes/discussion_type.rb
index 56579c357a7..ffe61c9ff88 100644
--- a/app/graphql/types/notes/discussion_type.rb
+++ b/app/graphql/types/notes/discussion_type.rb
@@ -3,10 +3,10 @@
module Types
module Notes
class DiscussionType < BaseObject
- DiscussionID = ::Types::GlobalIDType[::Discussion]
-
graphql_name 'Discussion'
+ DiscussionID = ::Types::GlobalIDType[::Discussion]
+
authorize :read_note
implements(Types::ResolvableInterface)
diff --git a/app/graphql/types/packages/package_details_type.rb b/app/graphql/types/packages/package_details_type.rb
index 1d2cf9649d8..444ecb5e792 100644
--- a/app/graphql/types/packages/package_details_type.rb
+++ b/app/graphql/types/packages/package_details_type.rb
@@ -3,16 +3,17 @@
module Types
module Packages
class PackageDetailsType < PackageType
- include ::PackagesHelper
-
graphql_name 'PackageDetailsType'
description 'Represents a package details in the Package Registry. Note that this type is in beta and susceptible to changes'
+
+ include ::PackagesHelper
+
authorize :read_package
field :versions, ::Types::Packages::PackageType.connection_type, null: true,
description: 'Other versions of the package.'
- field :package_files, Types::Packages::PackageFileType.connection_type, null: true, description: 'Package files.'
+ field :package_files, Types::Packages::PackageFileType.connection_type, null: true, method: :installable_package_files, description: 'Package files.'
field :dependency_links, Types::Packages::PackageDependencyLinkType.connection_type, null: true, description: 'Dependency link.'
@@ -36,14 +37,6 @@ module Types
object.versions
end
- def package_files
- if Feature.enabled?(:packages_installable_package_files, default_enabled: :yaml)
- object.installable_package_files
- else
- object.package_files
- end
- end
-
def composer_config_repository_url
composer_config_repository_name(object.project.group&.id)
end
diff --git a/app/graphql/types/permission_types/issue.rb b/app/graphql/types/permission_types/issue.rb
index 94e1bffd685..b38971b64cd 100644
--- a/app/graphql/types/permission_types/issue.rb
+++ b/app/graphql/types/permission_types/issue.rb
@@ -3,8 +3,8 @@
module Types
module PermissionTypes
class Issue < BasePermissionType
- description 'Check permissions for the current user on a issue'
graphql_name 'IssuePermissions'
+ description 'Check permissions for the current user on a issue'
abilities :read_issue, :admin_issue, :update_issue, :reopen_issue,
:read_design, :create_design, :destroy_design,
diff --git a/app/graphql/types/permission_types/merge_request.rb b/app/graphql/types/permission_types/merge_request.rb
index 52c11fe5588..73a2f820f79 100644
--- a/app/graphql/types/permission_types/merge_request.rb
+++ b/app/graphql/types/permission_types/merge_request.rb
@@ -3,15 +3,16 @@
module Types
module PermissionTypes
class MergeRequest < BasePermissionType
+ graphql_name 'MergeRequestPermissions'
+ description 'Check permissions for the current user on a merge request'
+
+ present_using MergeRequestPresenter
+
PERMISSION_FIELDS = %i[push_to_source_branch
remove_source_branch
cherry_pick_on_current_merge_request
revert_on_current_merge_request].freeze
- present_using MergeRequestPresenter
- description 'Check permissions for the current user on a merge request'
- graphql_name 'MergeRequestPermissions'
-
abilities :read_merge_request, :admin_merge_request,
:update_merge_request, :create_note
diff --git a/app/graphql/types/project_type.rb b/app/graphql/types/project_type.rb
index d49244f6b65..dc428e7bdce 100644
--- a/app/graphql/types/project_type.rb
+++ b/app/graphql/types/project_type.rb
@@ -15,6 +15,8 @@ module Types
description: 'Full path of the project.'
field :path, GraphQL::Types::String, null: false,
description: 'Path of the project.'
+ field :ci_config_path_or_default, GraphQL::Types::String, null: false,
+ description: 'Path of the CI configuration file.'
field :sast_ci_configuration, Types::CiConfiguration::Sast::Type, null: true,
calls_gitaly: true,
@@ -195,6 +197,12 @@ module Types
extras: [:lookahead],
resolver: Resolvers::ProjectPipelineResolver
+ field :pipeline_counts,
+ Types::Ci::PipelineCountsType,
+ null: true,
+ description: 'Build pipeline counts of the project.',
+ resolver: Resolvers::Ci::ProjectPipelineCountsResolver
+
field :ci_cd_settings,
Types::Ci::CiCdSettingType,
null: true,
@@ -231,6 +239,12 @@ module Types
max_page_size: 2000,
resolver: Resolvers::BoardsResolver
+ field :recent_issue_boards,
+ Types::BoardType.connection_type,
+ null: true,
+ description: 'List of recently visited boards of the project. Maximum size is 4.',
+ resolver: Resolvers::RecentBoardsResolver
+
field :board,
Types::BoardType,
null: true,
diff --git a/app/graphql/types/query_complexity_type.rb b/app/graphql/types/query_complexity_type.rb
index 3f58a15aef7..13b618cf5ce 100644
--- a/app/graphql/types/query_complexity_type.rb
+++ b/app/graphql/types/query_complexity_type.rb
@@ -3,10 +3,10 @@
module Types
# rubocop: disable Graphql/AuthorizeTypes
class QueryComplexityType < ::Types::BaseObject
- ANALYZER = GraphQL::Analysis::QueryComplexity.new { |_query, complexity| complexity }
-
graphql_name 'QueryComplexity'
+ ANALYZER = GraphQL::Analysis::QueryComplexity.new { |_query, complexity| complexity }
+
alias_method :query, :object
field :limit, GraphQL::Types::Int,
diff --git a/app/graphql/types/repository/blob_type.rb b/app/graphql/types/repository/blob_type.rb
index 28339093172..bfd59763a07 100644
--- a/app/graphql/types/repository/blob_type.rb
+++ b/app/graphql/types/repository/blob_type.rb
@@ -4,10 +4,10 @@ module Types
# rubocop: disable Graphql/AuthorizeTypes
# This is presented through `Repository` that has its own authorization
class BlobType < BaseObject
- present_using BlobPresenter
-
graphql_name 'RepositoryBlob'
+ present_using BlobPresenter
+
field :id, GraphQL::Types::ID, null: false,
description: 'ID of the blob.'
@@ -87,6 +87,14 @@ module Types
description: 'Web path to blob permalink.',
calls_gitaly: true
+ field :environment_formatted_external_url, GraphQL::Types::String, null: true,
+ description: 'Environment on which the blob is available.',
+ calls_gitaly: true
+
+ field :environment_external_url_for_route_map, GraphQL::Types::String, null: true,
+ description: 'Web path to blob on an environment.',
+ calls_gitaly: true
+
field :code_owners, [Types::UserType], null: true,
description: 'List of code owners for the blob.',
calls_gitaly: true
@@ -117,6 +125,12 @@ module Types
field :archived, GraphQL::Types::Boolean, null: true, method: :archived?,
description: 'Whether the current project is archived.'
+ field :language, GraphQL::Types::String,
+ description: 'Blob language.',
+ method: :blob_language,
+ null: true,
+ calls_gitaly: true
+
def raw_text_blob
object.data unless object.binary?
end
diff --git a/app/graphql/types/root_storage_statistics_type.rb b/app/graphql/types/root_storage_statistics_type.rb
index 88dc6036bfd..4dcadf1274f 100644
--- a/app/graphql/types/root_storage_statistics_type.rb
+++ b/app/graphql/types/root_storage_statistics_type.rb
@@ -15,5 +15,6 @@ module Types
field :snippets_size, GraphQL::Types::Float, null: false, description: 'Snippets size in bytes.'
field :pipeline_artifacts_size, GraphQL::Types::Float, null: false, description: 'CI pipeline artifacts size in bytes.'
field :uploads_size, GraphQL::Types::Float, null: false, description: 'Uploads size in bytes.'
+ field :dependency_proxy_size, GraphQL::Types::Float, null: false, description: 'Dependency Proxy sizes in bytes.'
end
end
diff --git a/app/graphql/types/subscription_type.rb b/app/graphql/types/subscription_type.rb
index 3629edb5b33..db6a247179d 100644
--- a/app/graphql/types/subscription_type.rb
+++ b/app/graphql/types/subscription_type.rb
@@ -9,5 +9,8 @@ module Types
field :issue_crm_contacts_updated, subscription: Subscriptions::IssuableUpdated, null: true,
description: 'Triggered when the crm contacts of an issuable are updated.'
+
+ field :issuable_title_updated, subscription: Subscriptions::IssuableUpdated, null: true,
+ description: 'Triggered when the title of an issuable is updated.'
end
end
diff --git a/app/graphql/types/terraform/state_version_type.rb b/app/graphql/types/terraform/state_version_type.rb
index bf1af4565bc..59da550aa1b 100644
--- a/app/graphql/types/terraform/state_version_type.rb
+++ b/app/graphql/types/terraform/state_version_type.rb
@@ -3,10 +3,10 @@
module Types
module Terraform
class StateVersionType < BaseObject
- include ::API::Helpers::RelatedResourcesHelpers
-
graphql_name 'TerraformStateVersion'
+ include ::API::Helpers::RelatedResourcesHelpers
+
authorize :read_terraform_state
field :id, GraphQL::Types::ID,
diff --git a/app/graphql/types/tree/blob_type.rb b/app/graphql/types/tree/blob_type.rb
index bb15d91a62f..bcff65be652 100644
--- a/app/graphql/types/tree/blob_type.rb
+++ b/app/graphql/types/tree/blob_type.rb
@@ -4,12 +4,11 @@ module Types
# rubocop: disable Graphql/AuthorizeTypes
# This is presented through `Repository` that has its own authorization
class BlobType < BaseObject
- implements Types::Tree::EntryType
+ graphql_name 'Blob'
+ implements Types::Tree::EntryType
present_using BlobPresenter
- graphql_name 'Blob'
-
field :web_url, GraphQL::Types::String, null: true,
description: 'Web URL of the blob.'
field :web_path, GraphQL::Types::String, null: true,
diff --git a/app/graphql/types/tree/submodule_type.rb b/app/graphql/types/tree/submodule_type.rb
index 05d8c1a951a..bc7828dbffa 100644
--- a/app/graphql/types/tree/submodule_type.rb
+++ b/app/graphql/types/tree/submodule_type.rb
@@ -4,10 +4,10 @@ module Types
# rubocop: disable Graphql/AuthorizeTypes
# This is presented through `Repository` that has its own authorization
class SubmoduleType < BaseObject
- implements Types::Tree::EntryType
-
graphql_name 'Submodule'
+ implements Types::Tree::EntryType
+
field :web_url, type: GraphQL::Types::String, null: true,
description: 'Web URL for the sub-module.'
field :tree_url, type: GraphQL::Types::String, null: true,
diff --git a/app/graphql/types/tree/tree_entry_type.rb b/app/graphql/types/tree/tree_entry_type.rb
index 998b3617574..cdc84c8e318 100644
--- a/app/graphql/types/tree/tree_entry_type.rb
+++ b/app/graphql/types/tree/tree_entry_type.rb
@@ -4,13 +4,12 @@ module Types
# rubocop: disable Graphql/AuthorizeTypes
# This is presented through `Repository` that has its own authorization
class TreeEntryType < BaseObject
- implements Types::Tree::EntryType
-
- present_using TreeEntryPresenter
-
graphql_name 'TreeEntry'
description 'Represents a directory'
+ implements Types::Tree::EntryType
+ present_using TreeEntryPresenter
+
field :web_url, GraphQL::Types::String, null: true,
description: 'Web URL for the tree entry (directory).'
field :web_path, GraphQL::Types::String, null: true,
diff --git a/app/graphql/types/user_interface.rb b/app/graphql/types/user_interface.rb
index 6bb4cb29cdd..24fca80d5a9 100644
--- a/app/graphql/types/user_interface.rb
+++ b/app/graphql/types/user_interface.rb
@@ -31,7 +31,7 @@ module Types
null: false,
resolver_method: :redacted_name,
description: 'Human-readable name of the user. ' \
- 'Will return `****` if the user is a project bot and the requester does not have permission to read resource access tokens.'
+ 'Returns `****` if the user is a project bot and the requester does not have permission to view the project.'
field :state,
type: Types::UserStateEnum,
@@ -127,7 +127,7 @@ module Types
def redacted_name
return object.name unless object.project_bot?
- return object.name if context[:current_user]&.can?(:read_resource_access_tokens, object.projects.first)
+ return object.name if context[:current_user]&.can?(:read_project, object.projects.first)
# If the requester does not have permission to read the project bot name,
# the API returns an arbitrary string. UI changes will be addressed in a follow up issue:
diff --git a/app/graphql/types/user_preferences_type.rb b/app/graphql/types/user_preferences_type.rb
new file mode 100644
index 00000000000..9a1ea4a2e4f
--- /dev/null
+++ b/app/graphql/types/user_preferences_type.rb
@@ -0,0 +1,17 @@
+# frozen_string_literal: true
+
+module Types
+ # rubocop: disable Graphql/AuthorizeTypes
+ # Only used to render the current user's own preferences
+ class UserPreferencesType < BaseObject
+ graphql_name 'UserPreferences'
+
+ field :issues_sort, Types::IssueSortEnum,
+ description: 'Sort order for issue lists.',
+ null: true
+
+ def issues_sort
+ object.issues_sort.to_sym
+ end
+ end
+end
diff --git a/app/graphql/types/work_item_state_enum.rb b/app/graphql/types/work_item_state_enum.rb
new file mode 100644
index 00000000000..8fe58f76d9a
--- /dev/null
+++ b/app/graphql/types/work_item_state_enum.rb
@@ -0,0 +1,11 @@
+# frozen_string_literal: true
+
+module Types
+ class WorkItemStateEnum < BaseEnum
+ graphql_name 'WorkItemState'
+ description 'State of a GitLab work item'
+
+ value 'OPEN', 'In open state.', value: 'opened'
+ value 'CLOSED', 'In closed state.', value: 'closed'
+ end
+end
diff --git a/app/graphql/types/work_item_type.rb b/app/graphql/types/work_item_type.rb
index 486c1e52987..15a5557b489 100644
--- a/app/graphql/types/work_item_type.rb
+++ b/app/graphql/types/work_item_type.rb
@@ -12,6 +12,8 @@ module Types
description: 'Global ID of the work item.'
field :iid, GraphQL::Types::ID, null: false,
description: 'Internal ID of the work item.'
+ field :state, WorkItemStateEnum, null: false,
+ description: 'State of the work item.'
field :title, GraphQL::Types::String, null: false,
description: 'Title of the work item.'
field :work_item_type, Types::WorkItems::TypeType, null: false,
diff --git a/app/graphql/types/work_items/state_event_enum.rb b/app/graphql/types/work_items/state_event_enum.rb
new file mode 100644
index 00000000000..db54d494c12
--- /dev/null
+++ b/app/graphql/types/work_items/state_event_enum.rb
@@ -0,0 +1,13 @@
+# frozen_string_literal: true
+
+module Types
+ module WorkItems
+ class StateEventEnum < BaseEnum
+ graphql_name 'WorkItemStateEvent'
+ description 'Values for work item state events'
+
+ value 'REOPEN', 'Reopens the work item.', value: 'reopen'
+ value 'CLOSE', 'Closes the work item.', value: 'close'
+ end
+ end
+end