9403b1d951
This allows the user to get a single MR nested in a GraphQL project query. Since we need the full path and the iid anyway, this makes more sense than having a root query that needs the full path as well.
20 lines
556 B
Ruby
20 lines
556 B
Ruby
module Resolvers
|
|
class MergeRequestResolver < BaseResolver
|
|
argument :iid, GraphQL::ID_TYPE,
|
|
required: true,
|
|
description: 'The IID of the merge request, e.g., "1"'
|
|
|
|
type Types::MergeRequestType, null: true
|
|
|
|
alias_method :project, :object
|
|
|
|
def resolve(iid:)
|
|
return unless project.present?
|
|
|
|
BatchLoader.for(iid.to_s).batch(key: project.id) do |iids, loader|
|
|
results = project.merge_requests.where(iid: iids)
|
|
results.each { |mr| loader.call(mr.iid.to_s, mr) }
|
|
end
|
|
end
|
|
end
|
|
end
|