group_type.rb 735 Bytes
Newer Older
Brett Walker's avatar
Brett Walker committed
1
2
3
4
5
6
7
8
9
10
# frozen_string_literal: true

module Types
  class GroupType < NamespaceType
    graphql_name 'Group'

    authorize :read_group

    expose_permissions Types::PermissionTypes::Group

11
    field :web_url, GraphQL::STRING_TYPE, null: false # rubocop:disable Graphql/Descriptions
Brett Walker's avatar
Brett Walker committed
12

13
    field :avatar_url, GraphQL::STRING_TYPE, null: true, resolve: -> (group, args, ctx) do # rubocop:disable Graphql/Descriptions
Brett Walker's avatar
Brett Walker committed
14
15
16
      group.avatar_url(only_path: false)
    end

17
    field :parent, GroupType, # rubocop:disable Graphql/Descriptions
18
19
          null: true,
          resolve: -> (obj, _args, _ctx) { Gitlab::Graphql::Loaders::BatchModelLoader.new(Group, obj.parent_id).find }
Brett Walker's avatar
Brett Walker committed
20
21
  end
end
22
23

Types::GroupType.prepend_if_ee('EE::Types::GroupType')