diff options
Diffstat (limited to 'app/graphql/mutations/concerns/mutations/resolves_issuable.rb')
-rw-r--r-- | app/graphql/mutations/concerns/mutations/resolves_issuable.rb | 29 |
1 files changed, 15 insertions, 14 deletions
diff --git a/app/graphql/mutations/concerns/mutations/resolves_issuable.rb b/app/graphql/mutations/concerns/mutations/resolves_issuable.rb index 13a56f2e709..0fe2d09de6d 100644 --- a/app/graphql/mutations/concerns/mutations/resolves_issuable.rb +++ b/app/graphql/mutations/concerns/mutations/resolves_issuable.rb @@ -9,30 +9,31 @@ module Mutations end def resolve_issuable(type:, parent_path:, iid:) - parent = resolve_issuable_parent(type, parent_path) - key = type == :merge_request ? :iids : :iid - args = { key => iid.to_s } + parent = ::Gitlab::Graphql::Lazy.force(resolve_issuable_parent(type, parent_path)) + return unless parent.present? - resolver = issuable_resolver(type, parent, context) - ready, early_return = resolver.ready?(**args) - - return early_return unless ready - - resolver.resolve(**args) + finder = issuable_finder(type, iids: [iid]) + Gitlab::Graphql::Loaders::IssuableLoader.new(parent, finder).find_all.first end private - def issuable_resolver(type, parent, context) - resolver_class = "Resolvers::#{type.to_s.classify.pluralize}Resolver".constantize - - resolver_class.single.new(object: parent, context: context, field: nil) + def issuable_finder(type, args) + case type + when :merge_request + MergeRequestsFinder.new(current_user, args) + when :issue + IssuesFinder.new(current_user, args) + else + raise "Unsupported type: #{type}" + end end def resolve_issuable_parent(type, parent_path) + return unless parent_path.present? return unless type == :issue || type == :merge_request - resolve_project(full_path: parent_path) if parent_path.present? + resolve_project(full_path: parent_path) end end end |