2022-10-11 01:57:18 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module Resolvers
|
|
|
|
module Projects
|
|
|
|
class BranchRulesResolver < BaseResolver
|
2022-11-25 23:54:43 +05:30
|
|
|
include LooksAhead
|
|
|
|
|
2022-10-11 01:57:18 +05:30
|
|
|
type Types::Projects::BranchRuleType.connection_type, null: false
|
|
|
|
|
|
|
|
alias_method :project, :object
|
|
|
|
|
2022-11-25 23:54:43 +05:30
|
|
|
def resolve_with_lookahead(**args)
|
2023-03-17 16:20:25 +05:30
|
|
|
protected_branches.map do |protected_branch|
|
|
|
|
::Projects::BranchRule.new(project, protected_branch)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def protected_branches
|
|
|
|
apply_lookahead(project.protected_branches.sorted_by_name)
|
2022-10-11 01:57:18 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2022-11-25 23:54:43 +05:30
|
|
|
|
|
|
|
Resolvers::Projects::BranchRulesResolver.prepend_mod_with('Resolvers::Projects::BranchRulesResolver')
|