debian-mirror-gitlab/app/graphql/types/group_type.rb

134 lines
4.7 KiB
Ruby
Raw Normal View History

2019-07-31 22:56:46 +05:30
# frozen_string_literal: true
module Types
class GroupType < NamespaceType
graphql_name 'Group'
authorize :read_group
expose_permissions Types::PermissionTypes::Group
2019-12-26 22:10:19 +05:30
field :web_url, GraphQL::STRING_TYPE, null: false,
2021-03-11 19:13:27 +05:30
description: 'Web URL of the group.'
2019-07-31 22:56:46 +05:30
2019-12-26 22:10:19 +05:30
field :avatar_url, GraphQL::STRING_TYPE, null: true,
2021-03-11 19:13:27 +05:30
description: 'Avatar URL of the group.'
2019-07-31 22:56:46 +05:30
2021-01-29 00:20:46 +05:30
field :custom_emoji, Types::CustomEmojiType.connection_type, null: true,
2021-03-11 19:13:27 +05:30
description: 'Custom emoji within this namespace.',
2021-01-29 00:20:46 +05:30
feature_flag: :custom_emoji
2020-03-13 15:44:24 +05:30
field :share_with_group_lock, GraphQL::BOOLEAN_TYPE, null: true,
2021-03-11 19:13:27 +05:30
description: 'Indicates if sharing a project with another group within this group is prevented.'
2020-03-13 15:44:24 +05:30
field :project_creation_level, GraphQL::STRING_TYPE, null: true, method: :project_creation_level_str,
2021-03-11 19:13:27 +05:30
description: 'The permission level required to create projects in the group.'
2020-03-13 15:44:24 +05:30
field :subgroup_creation_level, GraphQL::STRING_TYPE, null: true, method: :subgroup_creation_level_str,
2021-03-11 19:13:27 +05:30
description: 'The permission level required to create subgroups within the group.'
2020-03-13 15:44:24 +05:30
field :require_two_factor_authentication, GraphQL::BOOLEAN_TYPE, null: true,
2021-03-11 19:13:27 +05:30
description: 'Indicates if all users in this group are required to set up two-factor authentication.'
2020-03-13 15:44:24 +05:30
field :two_factor_grace_period, GraphQL::INT_TYPE, null: true,
2021-03-11 19:13:27 +05:30
description: 'Time before two-factor authentication is enforced.'
2020-03-13 15:44:24 +05:30
field :auto_devops_enabled, GraphQL::BOOLEAN_TYPE, null: true,
2021-03-11 19:13:27 +05:30
description: 'Indicates whether Auto DevOps is enabled for all projects within this group.'
2020-03-13 15:44:24 +05:30
field :emails_disabled, GraphQL::BOOLEAN_TYPE, null: true,
2021-03-11 19:13:27 +05:30
description: 'Indicates if a group has email notifications disabled.'
2020-03-13 15:44:24 +05:30
field :mentions_disabled, GraphQL::BOOLEAN_TYPE, null: true,
2021-03-11 19:13:27 +05:30
description: 'Indicates if a group is disabled from getting mentioned.'
2020-03-13 15:44:24 +05:30
2019-12-26 22:10:19 +05:30
field :parent, GroupType, null: true,
2021-03-11 19:13:27 +05:30
description: 'Parent group.'
2020-03-13 15:44:24 +05:30
2020-04-22 19:07:51 +05:30
field :issues,
Types::IssueType.connection_type,
null: true,
2021-03-11 19:13:27 +05:30
description: 'Issues for projects in this group.',
2020-10-24 23:57:45 +05:30
resolver: Resolvers::GroupIssuesResolver
2020-04-22 19:07:51 +05:30
2021-01-03 14:25:43 +05:30
field :merge_requests,
Types::MergeRequestType.connection_type,
null: true,
2021-03-11 19:13:27 +05:30
description: 'Merge requests for projects in this group.',
2021-01-03 14:25:43 +05:30
resolver: Resolvers::GroupMergeRequestsResolver
2020-03-13 15:44:24 +05:30
field :milestones, Types::MilestoneType.connection_type, null: true,
2021-03-11 19:13:27 +05:30
description: 'Milestones of the group.',
2020-10-24 23:57:45 +05:30
resolver: Resolvers::GroupMilestonesResolver
2020-04-08 14:13:33 +05:30
field :boards,
Types::BoardType.connection_type,
null: true,
2021-03-11 19:13:27 +05:30
description: 'Boards of the group.',
2020-04-08 14:13:33 +05:30
max_page_size: 2000,
resolver: Resolvers::BoardsResolver
field :board,
Types::BoardType,
null: true,
2021-03-11 19:13:27 +05:30
description: 'A single board of the group.',
2021-01-03 14:25:43 +05:30
resolver: Resolvers::BoardResolver
2020-06-23 00:09:42 +05:30
field :label,
Types::LabelType,
null: true,
2021-03-11 19:13:27 +05:30
description: 'A label available on this group.' do
2020-06-23 00:09:42 +05:30
argument :title, GraphQL::STRING_TYPE,
required: true,
2021-03-11 19:13:27 +05:30
description: 'Title of the label.'
2020-06-23 00:09:42 +05:30
end
2020-11-24 15:15:51 +05:30
field :group_members,
2021-03-11 19:13:27 +05:30
description: 'A membership of a user within this group.',
2020-11-24 15:15:51 +05:30
resolver: Resolvers::GroupMembersResolver
2021-01-29 00:20:46 +05:30
field :container_repositories,
Types::ContainerRepositoryType.connection_type,
null: true,
2021-03-11 19:13:27 +05:30
description: 'Container repositories of the group.',
2021-01-29 00:20:46 +05:30
resolver: Resolvers::ContainerRepositoriesResolver,
authorize: :read_container_image
2021-02-22 17:27:13 +05:30
field :container_repositories_count, GraphQL::INT_TYPE, null: false,
2021-03-11 19:13:27 +05:30
description: 'Number of container repositories in the group.'
2021-02-22 17:27:13 +05:30
2020-06-23 00:09:42 +05:30
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,
2021-03-11 19:13:27 +05:30
description: 'Labels available on this group.',
resolver: Resolvers::GroupLabelsResolver
2020-06-23 00:09:42 +05:30
2021-02-22 17:27:13 +05:30
def avatar_url
object.avatar_url(only_path: false)
end
def parent
Gitlab::Graphql::Loaders::BatchModelLoader.new(Group, object.parent_id).find
end
def container_repositories_count
group.container_repositories.size
end
2020-06-23 00:09:42 +05:30
private
def group
object.respond_to?(:sync) ? object.sync : object
end
2019-07-31 22:56:46 +05:30
end
end
2019-12-04 20:38:33 +05:30
Types::GroupType.prepend_if_ee('EE::Types::GroupType')