2021-04-17 20:07:23 +05:30
|
|
|
# frozen_string_literal: true
|
2021-06-08 01:23:25 +05:30
|
|
|
# rubocop: disable Graphql/ResolverType
|
2021-04-17 20:07:23 +05:30
|
|
|
|
|
|
|
module Resolvers
|
2021-06-08 01:23:25 +05:30
|
|
|
class GroupPackagesResolver < PackagesBaseResolver
|
|
|
|
# The GraphQL type is defined in the extended class
|
|
|
|
|
2022-10-11 01:57:18 +05:30
|
|
|
extension ::Gitlab::Graphql::Limit::FieldCallCount, limit: 1
|
|
|
|
|
2021-06-08 01:23:25 +05:30
|
|
|
argument :sort, Types::Packages::PackageGroupSortEnum,
|
|
|
|
description: 'Sort packages by this criteria.',
|
|
|
|
required: false,
|
|
|
|
default_value: :created_desc
|
|
|
|
|
|
|
|
GROUP_SORT_TO_PARAMS_MAP = SORT_TO_PARAMS_MAP.merge({
|
2023-03-04 22:38:38 +05:30
|
|
|
project_path_desc: { order_by: 'project_path', sort: 'desc' },
|
|
|
|
project_path_asc: { order_by: 'project_path', sort: 'asc' }
|
|
|
|
}).freeze
|
2021-04-17 20:07:23 +05:30
|
|
|
|
2021-06-08 01:23:25 +05:30
|
|
|
def resolve(sort:, **filters)
|
2021-04-17 20:07:23 +05:30
|
|
|
return unless packages_available?
|
|
|
|
|
2022-07-16 23:28:13 +05:30
|
|
|
params = filters.merge(GROUP_SORT_TO_PARAMS_MAP.fetch(sort))
|
|
|
|
params[:preload_pipelines] = false
|
|
|
|
|
|
|
|
::Packages::GroupPackagesFinder.new(current_user, object, params).execute
|
2021-04-17 20:07:23 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2021-06-08 01:23:25 +05:30
|
|
|
# rubocop: enable Graphql/ResolverType
|