Welcome to mirror list, hosted at ThFree Co, Russian Federation.

nested_environment_type.rb « types « graphql « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: b835af2bf45899a200a3e79ac2b22c54cc42fe78 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# frozen_string_literal: true

module Types
  # rubocop: disable Graphql/AuthorizeTypes
  class NestedEnvironmentType < BaseObject
    graphql_name 'NestedEnvironment'
    description 'Describes where code is deployed for a project organized by folder.'

    field :name, GraphQL::Types::String,
          null: false, description: 'Human-readable name of the environment.'

    field :size, GraphQL::Types::Int,
          null: false, description: 'Number of environments nested in the folder.'

    field :environment,
          Types::EnvironmentType,
          null: true, description: 'Latest environment in the folder.'

    def environment
      BatchLoader::GraphQL.for(object.last_id).batch do |environment_ids, loader|
        Environment.id_in(environment_ids).each do |environment|
          loader.call(environment.id, environment)
        end
      end
    end
  end
  # rubocop: enable Graphql/AuthorizeTypes
end