debian-mirror-gitlab/app/graphql/resolvers/projects_resolver.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

47 lines
1.4 KiB
Ruby
Raw Normal View History

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
2023-04-23 21:23:45 +05:30
argument :with_issues_enabled, GraphQL::Types::Boolean,
required: false,
description: "Return only projects with issues enabled."
argument :with_merge_requests_enabled, GraphQL::Types::Boolean,
required: false,
description: "Return only projects with merge requests enabled."
2020-05-24 23:13:21 +05:30
def resolve(**args)
ProjectsFinder
2023-04-23 21:23:45 +05:30
.new(current_user: current_user, params: finder_params(args), project_ids_relation: parse_gids(args[:ids]))
2020-05-24 23:13:21 +05:30
.execute
end
private
2023-04-23 21:23:45 +05:30
def finder_params(args)
{
**project_finder_params(args),
with_issues_enabled: args[:with_issues_enabled],
with_merge_requests_enabled: args[:with_merge_requests_enabled]
}
end
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