2020-05-24 23:13:21 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module Resolvers
|
|
|
|
class ProjectsResolver < BaseResolver
|
2022-10-11 01:57:18 +05:30
|
|
|
include ProjectSearchArguments
|
2020-05-24 23:13:21 +05:30
|
|
|
|
2022-10-11 01:57:18 +05:30
|
|
|
type Types::ProjectType, null: true
|
2020-05-24 23:13:21 +05:30
|
|
|
|
2021-10-27 15:23:28 +05:30
|
|
|
argument :ids, [GraphQL::Types::ID],
|
2021-01-03 14:25:43 +05:30
|
|
|
required: false,
|
2021-03-08 18:12:59 +05:30
|
|
|
description: 'Filter projects by IDs.'
|
2021-01-03 14:25:43 +05:30
|
|
|
|
2021-10-27 15:23:28 +05:30
|
|
|
argument :sort, GraphQL::Types::String,
|
2021-01-03 14:25:43 +05:30
|
|
|
required: false,
|
2022-11-25 23:54:43 +05:30
|
|
|
description: "Sort order of results. Format: `<field_name>_<sort_direction>`, " \
|
|
|
|
"for example: `id_desc` or `name_asc`"
|
2021-09-04 01:27:46 +05:30
|
|
|
|
2020-05-24 23:13:21 +05:30
|
|
|
def resolve(**args)
|
|
|
|
ProjectsFinder
|
2020-11-24 15:15:51 +05:30
|
|
|
.new(current_user: current_user, params: project_finder_params(args), project_ids_relation: parse_gids(args[:ids]))
|
2020-05-24 23:13:21 +05:30
|
|
|
.execute
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
2020-11-24 15:15:51 +05:30
|
|
|
def parse_gids(gids)
|
|
|
|
gids&.map { |gid| GitlabSchema.parse_gid(gid, expected_type: ::Project).model_id }
|
|
|
|
end
|
2020-05-24 23:13:21 +05:30
|
|
|
end
|
|
|
|
end
|