2020-01-16 13:08:46 -05:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module Resolvers
|
|
|
|
class EnvironmentsResolver < BaseResolver
|
|
|
|
argument :name, GraphQL::STRING_TYPE,
|
|
|
|
required: false,
|
2021-01-11 19:10:42 -05:00
|
|
|
description: 'Name of the environment.'
|
2020-01-16 13:08:46 -05:00
|
|
|
|
|
|
|
argument :search, GraphQL::STRING_TYPE,
|
|
|
|
required: false,
|
2021-01-11 19:10:42 -05:00
|
|
|
description: 'Search query for environment name.'
|
2020-01-16 13:08:46 -05:00
|
|
|
|
2020-04-07 20:09:30 -04:00
|
|
|
argument :states, [GraphQL::STRING_TYPE],
|
|
|
|
required: false,
|
2021-01-11 19:10:42 -05:00
|
|
|
description: 'States of environments that should be included in result.'
|
2020-04-07 20:09:30 -04:00
|
|
|
|
2020-01-16 13:08:46 -05:00
|
|
|
type Types::EnvironmentType, null: true
|
|
|
|
|
|
|
|
alias_method :project, :object
|
|
|
|
|
|
|
|
def resolve(**args)
|
|
|
|
return unless project.present?
|
|
|
|
|
2021-04-22 05:09:45 -04:00
|
|
|
Environments::EnvironmentsFinder.new(project, context[:current_user], args).execute
|
|
|
|
rescue Environments::EnvironmentsFinder::InvalidStatesError => exception
|
2020-04-07 20:09:30 -04:00
|
|
|
raise Gitlab::Graphql::Errors::ArgumentError, exception.message
|
2020-01-16 13:08:46 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|