summaryrefslogtreecommitdiff
path: root/app/graphql
diff options
context:
space:
mode:
authorBrett Walker <bwalker@gitlab.com>2019-09-04 17:42:48 +0000
committerMayra Cabrera <mcabrera@gitlab.com>2019-09-04 17:42:48 +0000
commitaa7b1cfc5b3319373a4b56c755b1fc1d4cbaff02 (patch)
treeba078b30d36bf8ed8d5ec8fece71871e40d85a2c /app/graphql
parent29e3a08b8f8f9511dd6e25566bc9abb135a597c4 (diff)
downloadgitlab-ce-aa7b1cfc5b3319373a4b56c755b1fc1d4cbaff02.tar.gz
Upgrade GraphQL gem to 1.8.17
- Due to https://github.com/exAspArk/batch-loader/pull/32, we changed BatchLoader.for into BatchLoader::GraphQL.for - since our results are wrapped in a BatchLoader::GraphQL, calling `sync` during authorization is required to get real object - `graphql` now has it's own authorization system. Our `authorized?` method conflicted and required renaming
Diffstat (limited to 'app/graphql')
-rw-r--r--app/graphql/mutations/notes/create/base.rb4
-rw-r--r--app/graphql/resolvers/full_path_resolver.rb2
-rw-r--r--app/graphql/resolvers/issues_resolver.rb4
-rw-r--r--app/graphql/resolvers/merge_requests_resolver.rb6
-rw-r--r--app/graphql/resolvers/namespace_projects_resolver.rb4
5 files changed, 9 insertions, 11 deletions
diff --git a/app/graphql/mutations/notes/create/base.rb b/app/graphql/mutations/notes/create/base.rb
index d3a5dae2188..cf9f74a63d8 100644
--- a/app/graphql/mutations/notes/create/base.rb
+++ b/app/graphql/mutations/notes/create/base.rb
@@ -18,8 +18,6 @@ module Mutations
required: true,
description: copy_field_description(Types::Notes::NoteType, :body)
- private
-
def resolve(args)
noteable = authorized_find!(id: args[:noteable_id])
@@ -37,6 +35,8 @@ module Mutations
}
end
+ private
+
def create_note_params(noteable, args)
{
noteable: noteable,
diff --git a/app/graphql/resolvers/full_path_resolver.rb b/app/graphql/resolvers/full_path_resolver.rb
index 972f318c806..2afd0411ea6 100644
--- a/app/graphql/resolvers/full_path_resolver.rb
+++ b/app/graphql/resolvers/full_path_resolver.rb
@@ -11,7 +11,7 @@ module Resolvers
end
def model_by_full_path(model, full_path)
- BatchLoader.for(full_path).batch(key: model) do |full_paths, loader, args|
+ BatchLoader::GraphQL.for(full_path).batch(key: model) do |full_paths, loader, args|
# `with_route` avoids an N+1 calculating full_path
args[:key].where_full_path_in(full_paths).with_route.each do |model_instance|
loader.call(model_instance.full_path, model_instance)
diff --git a/app/graphql/resolvers/issues_resolver.rb b/app/graphql/resolvers/issues_resolver.rb
index 6988b451ec3..dd104e83f43 100644
--- a/app/graphql/resolvers/issues_resolver.rb
+++ b/app/graphql/resolvers/issues_resolver.rb
@@ -41,13 +41,11 @@ module Resolvers
type Types::IssueType, null: true
- alias_method :project, :object
-
def resolve(**args)
# The project could have been loaded in batch by `BatchLoader`.
# At this point we need the `id` of the project to query for issues, so
# make sure it's loaded and not `nil` before continuing.
- project.sync if project.respond_to?(:sync)
+ project = object.respond_to?(:sync) ? object.sync : object
return Issue.none if project.nil?
# Will need to be be made group & namespace aware with
diff --git a/app/graphql/resolvers/merge_requests_resolver.rb b/app/graphql/resolvers/merge_requests_resolver.rb
index b84e60066e1..1740d614b69 100644
--- a/app/graphql/resolvers/merge_requests_resolver.rb
+++ b/app/graphql/resolvers/merge_requests_resolver.rb
@@ -25,8 +25,10 @@ module Resolvers
# rubocop: disable CodeReuse/ActiveRecord
def batch_load(iid)
- BatchLoader.for(iid.to_s).batch(key: project) do |iids, loader, args|
- args[:key].merge_requests.where(iid: iids).each do |mr|
+ BatchLoader::GraphQL.for(iid.to_s).batch(key: project) do |iids, loader, args|
+ arg_key = args[:key].respond_to?(:sync) ? args[:key].sync : args[:key]
+
+ arg_key.merge_requests.where(iid: iids).each do |mr|
loader.call(mr.iid.to_s, mr)
end
end
diff --git a/app/graphql/resolvers/namespace_projects_resolver.rb b/app/graphql/resolvers/namespace_projects_resolver.rb
index 677ea808aeb..f5b60f91be6 100644
--- a/app/graphql/resolvers/namespace_projects_resolver.rb
+++ b/app/graphql/resolvers/namespace_projects_resolver.rb
@@ -9,13 +9,11 @@ module Resolvers
type Types::ProjectType, null: true
- alias_method :namespace, :object
-
def resolve(include_subgroups:)
# The namespace could have been loaded in batch by `BatchLoader`.
# At this point we need the `id` or the `full_path` of the namespace
# to query for projects, so make sure it's loaded and not `nil` before continuing.
- namespace.sync if namespace.respond_to?(:sync)
+ namespace = object.respond_to?(:sync) ? object.sync : object
return Project.none if namespace.nil?
if include_subgroups