2020-05-24 23:13:21 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module Resolvers
|
|
|
|
module DesignManagement
|
|
|
|
class DesignsResolver < BaseResolver
|
2021-01-29 00:20:46 +05:30
|
|
|
DesignID = ::Types::GlobalIDType[::DesignManagement::Design]
|
|
|
|
VersionID = ::Types::GlobalIDType[::DesignManagement::Version]
|
|
|
|
|
|
|
|
type ::Types::DesignManagement::DesignType.connection_type, null: true
|
|
|
|
|
|
|
|
argument :ids, [DesignID],
|
2020-05-24 23:13:21 +05:30
|
|
|
required: false,
|
2021-03-08 18:12:59 +05:30
|
|
|
description: 'Filters designs by their ID.'
|
2021-01-29 00:20:46 +05:30
|
|
|
argument :filenames, [GraphQL::STRING_TYPE],
|
2020-05-24 23:13:21 +05:30
|
|
|
required: false,
|
2021-03-08 18:12:59 +05:30
|
|
|
description: 'Filters designs by their filename.'
|
2021-01-29 00:20:46 +05:30
|
|
|
argument :at_version, VersionID,
|
2020-05-24 23:13:21 +05:30
|
|
|
required: false,
|
|
|
|
description: 'Filters designs to only those that existed at the version. ' \
|
|
|
|
'If argument is omitted or nil then all designs will reflect the latest version'
|
|
|
|
|
|
|
|
def self.single
|
|
|
|
::Resolvers::DesignManagement::DesignResolver
|
|
|
|
end
|
|
|
|
|
|
|
|
def resolve(ids: nil, filenames: nil, at_version: nil)
|
|
|
|
::DesignManagement::DesignsFinder.new(
|
|
|
|
issue,
|
|
|
|
current_user,
|
|
|
|
ids: design_ids(ids),
|
|
|
|
filenames: filenames,
|
2020-10-24 23:57:45 +05:30
|
|
|
visible_at_version: version(at_version)
|
2020-05-24 23:13:21 +05:30
|
|
|
).execute
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def version(at_version)
|
2020-10-24 23:57:45 +05:30
|
|
|
return unless at_version
|
|
|
|
|
2021-01-29 00:20:46 +05:30
|
|
|
# TODO: remove this line when the compatibility layer is removed
|
|
|
|
# See: https://gitlab.com/gitlab-org/gitlab/-/issues/257883
|
|
|
|
at_version = VersionID.coerce_isolated_input(at_version)
|
|
|
|
# TODO: when we get promises use this to make resolve lazy
|
|
|
|
Gitlab::Graphql::Lazy.force(GitlabSchema.find_by_gid(at_version))
|
2020-05-24 23:13:21 +05:30
|
|
|
end
|
|
|
|
|
2021-01-29 00:20:46 +05:30
|
|
|
def design_ids(gids)
|
|
|
|
return if gids.nil?
|
|
|
|
|
|
|
|
# TODO: remove this line when the compatibility layer is removed
|
|
|
|
# See: https://gitlab.com/gitlab-org/gitlab/-/issues/257883
|
|
|
|
gids = gids.map { |id| DesignID.coerce_isolated_input(id) }
|
|
|
|
gids.map(&:model_id)
|
2020-05-24 23:13:21 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
def issue
|
|
|
|
object.issue
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|