Class: Resolvers::DesignManagement::Version::DesignAtVersionResolver

Inherits:
BaseResolver
  • Object
show all
Includes:
Gitlab::Graphql::Authorize::AuthorizeResource
Defined in:
app/graphql/resolvers/design_management/version/design_at_version_resolver.rb

Overview

Resolver for a DesignAtVersion object given an implicit version context

Constant Summary collapse

DesignAtVersionID =
::Types::GlobalIDType[::DesignManagement::DesignAtVersion]
DesignID =
::Types::GlobalIDType[::DesignManagement::Design]

Constants included from Gitlab::Graphql::Authorize::AuthorizeResource

Gitlab::Graphql::Authorize::AuthorizeResource::RESOURCE_ACCESS_ERROR

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Gitlab::Graphql::Authorize::AuthorizeResource

#authorize!, #authorized_find!, #authorized_resource?, #find_object, #raise_resource_not_available_error!

Methods inherited from BaseResolver

as_single, complexity, complexity_multiplier, #current_user, field_options, last, #object, #offset_pagination, requires_argument!, resolver_complexity, #select_result, #single?, single_definition_blocks, singular_type, #synchronized_object, when_single

Methods included from Gitlab::Utils::Override

#extended, extensions, #included, #method_added, #override, #prepended, #queue_verification, verify!

Methods included from Gitlab::Graphql::GlobalIDCompatibility

#coerce_global_id_arguments!

Methods included from Gitlab::Utils::StrongMemoize

#clear_memoization, #strong_memoize, #strong_memoized?

Class Method Details

.singleObject


30
31
32
# File 'app/graphql/resolvers/design_management/version/design_at_version_resolver.rb', line 30

def self.single
  self
end

Instance Method Details

#resolve(design_id: nil, filename: nil, design_at_version_id: nil) ⇒ Object


34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'app/graphql/resolvers/design_management/version/design_at_version_resolver.rb', line 34

def resolve(design_id: nil, filename: nil, design_at_version_id: nil)
  validate_arguments(design_id, filename, design_at_version_id)

  # TODO: remove this when the compatibility layer is removed
  # See: https://gitlab.com/gitlab-org/gitlab/-/issues/257883
  design_id &&= DesignID.coerce_isolated_input(design_id)
  design_at_version_id &&= DesignAtVersionID.coerce_isolated_input(design_at_version_id)

  return unless Ability.allowed?(current_user, :read_design, issue)
  return specific_design_at_version(design_at_version_id) if design_at_version_id

  find(design_id, filename).map { |d| make(d) }.first
end