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