debian-mirror-gitlab/app/graphql/resolvers/concerns/resolves_merge_requests.rb

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

60 lines
1.5 KiB
Ruby
Raw Normal View History

2020-06-23 00:09:42 +05:30
# frozen_string_literal: true
# Mixin for resolving merge requests. All arguments must be in forms
# that `MergeRequestsFinder` can handle, so you may need to use aliasing.
module ResolvesMergeRequests
extend ActiveSupport::Concern
include LooksAhead
included do
type Types::MergeRequestType, null: true
end
def resolve_with_lookahead(**args)
2020-07-28 23:09:34 +05:30
mr_finder = MergeRequestsFinder.new(current_user, args.compact)
2021-01-03 14:25:43 +05:30
finder = Gitlab::Graphql::Loaders::IssuableLoader.new(mr_parent, mr_finder)
2020-06-23 00:09:42 +05:30
2020-07-28 23:09:34 +05:30
select_result(finder.batching_find_all { |query| apply_lookahead(query) })
2020-06-23 00:09:42 +05:30
end
def ready?(**args)
return early_return if no_results_possible?(args)
super
end
def early_return
[false, single? ? nil : MergeRequest.none]
end
private
2021-01-03 14:25:43 +05:30
def mr_parent
project
end
2020-06-23 00:09:42 +05:30
def unconditional_includes
[:target_project]
end
def preloads
{
assignees: [:assignees],
2021-03-08 18:12:59 +05:30
reviewers: [:reviewers],
participants: MergeRequest.participant_includes,
2020-06-23 00:09:42 +05:30
labels: [:labels],
author: [:author],
2020-10-24 23:57:45 +05:30
merged_at: [:metrics],
commit_count: [:metrics],
2021-01-03 14:25:43 +05:30
diff_stats_summary: [:metrics],
approved_by: [:approved_by_users],
2020-06-23 00:09:42 +05:30
milestone: [:milestone],
2021-03-08 18:12:59 +05:30
security_auto_fix: [:author],
2021-04-29 21:17:54 +05:30
head_pipeline: [:merge_request_diff, { head_pipeline: [:merge_request] }],
2022-05-07 20:08:51 +05:30
timelogs: [:timelogs],
2022-07-23 23:45:48 +05:30
pipelines: [:merge_request_diffs], # used by `recent_diff_head_shas` to load pipelines
2022-05-07 20:08:51 +05:30
committers: [merge_request_diff: [:merge_request_diff_commits]]
2020-06-23 00:09:42 +05:30
}
end
end