Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-03-02 21:07:42 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2020-03-02 21:07:42 +0300
commit7b52c7cb634ef7047d30b0337fe477bcdcedf41d (patch)
tree374ca9e908204488422046f10e340d1500780362 /app/graphql/mutations
parentb375c6c05fbd03aea33a9ee9f82e678bdaa8c3cc (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/graphql/mutations')
-rw-r--r--app/graphql/mutations/concerns/mutations/resolves_group.rb4
-rw-r--r--app/graphql/mutations/concerns/mutations/resolves_issuable.rb24
-rw-r--r--app/graphql/mutations/concerns/mutations/resolves_project.rb4
-rw-r--r--app/graphql/mutations/issues/base.rb8
-rw-r--r--app/graphql/mutations/merge_requests/base.rb8
5 files changed, 32 insertions, 16 deletions
diff --git a/app/graphql/mutations/concerns/mutations/resolves_group.rb b/app/graphql/mutations/concerns/mutations/resolves_group.rb
index 4306ce512f1..d5a040c84e9 100644
--- a/app/graphql/mutations/concerns/mutations/resolves_group.rb
+++ b/app/graphql/mutations/concerns/mutations/resolves_group.rb
@@ -5,10 +5,10 @@ module Mutations
extend ActiveSupport::Concern
def resolve_group(full_path:)
- resolver.resolve(full_path: full_path)
+ group_resolver.resolve(full_path: full_path)
end
- def resolver
+ def group_resolver
Resolvers::GroupResolver.new(object: nil, context: context)
end
end
diff --git a/app/graphql/mutations/concerns/mutations/resolves_issuable.rb b/app/graphql/mutations/concerns/mutations/resolves_issuable.rb
new file mode 100644
index 00000000000..4146bf8fdc8
--- /dev/null
+++ b/app/graphql/mutations/concerns/mutations/resolves_issuable.rb
@@ -0,0 +1,24 @@
+# frozen_string_literal: true
+
+module Mutations
+ module ResolvesIssuable
+ extend ActiveSupport::Concern
+ include Mutations::ResolvesProject
+
+ def resolve_issuable(type:, parent_path:, iid:)
+ parent = resolve_issuable_parent(parent_path)
+
+ issuable_resolver(type, parent, context).resolve(iid: iid.to_s)
+ end
+
+ def issuable_resolver(type, parent, context)
+ resolver_class = "Resolvers::#{type.to_s.classify.pluralize}Resolver".constantize
+
+ resolver_class.single.new(object: parent, context: context)
+ end
+
+ def resolve_issuable_parent(parent_path)
+ resolve_project(full_path: parent_path)
+ end
+ end
+end
diff --git a/app/graphql/mutations/concerns/mutations/resolves_project.rb b/app/graphql/mutations/concerns/mutations/resolves_project.rb
index da9814e88b0..0e91a25b803 100644
--- a/app/graphql/mutations/concerns/mutations/resolves_project.rb
+++ b/app/graphql/mutations/concerns/mutations/resolves_project.rb
@@ -5,10 +5,10 @@ module Mutations
extend ActiveSupport::Concern
def resolve_project(full_path:)
- resolver.resolve(full_path: full_path)
+ project_resolver.resolve(full_path: full_path)
end
- def resolver
+ def project_resolver
Resolvers::ProjectResolver.new(object: nil, context: context)
end
end
diff --git a/app/graphql/mutations/issues/base.rb b/app/graphql/mutations/issues/base.rb
index b7fa234a50b..7c545c3eb00 100644
--- a/app/graphql/mutations/issues/base.rb
+++ b/app/graphql/mutations/issues/base.rb
@@ -3,7 +3,7 @@
module Mutations
module Issues
class Base < BaseMutation
- include Mutations::ResolvesProject
+ include Mutations::ResolvesIssuable
argument :project_path, GraphQL::ID_TYPE,
required: true,
@@ -23,11 +23,7 @@ module Mutations
private
def find_object(project_path:, iid:)
- project = resolve_project(full_path: project_path)
- resolver = Resolvers::IssuesResolver
- .single.new(object: project, context: context)
-
- resolver.resolve(iid: iid)
+ resolve_issuable(type: :issue, parent_path: project_path, iid: iid)
end
end
end
diff --git a/app/graphql/mutations/merge_requests/base.rb b/app/graphql/mutations/merge_requests/base.rb
index 28e0cdc8cc7..96228855ace 100644
--- a/app/graphql/mutations/merge_requests/base.rb
+++ b/app/graphql/mutations/merge_requests/base.rb
@@ -3,7 +3,7 @@
module Mutations
module MergeRequests
class Base < BaseMutation
- include Mutations::ResolvesProject
+ include Mutations::ResolvesIssuable
argument :project_path, GraphQL::ID_TYPE,
required: true,
@@ -23,11 +23,7 @@ module Mutations
private
def find_object(project_path:, iid:)
- project = resolve_project(full_path: project_path)
- resolver = Resolvers::MergeRequestsResolver
- .single.new(object: project, context: context)
-
- resolver.resolve(iid: iid)
+ resolve_issuable(type: :merge_request, parent_path: project_path, iid: iid)
end
end
end