Skip to content

Commit 8c171aa

Browse files
Brett WalkerMayra Cabrera
authored andcommitted
Upgrade GraphQL gem to 1.8.17
- Due to exAspArk/batch-loader#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
1 parent 7452537 commit 8c171aa

33 files changed

+88
-67
lines changed

Gemfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ gem 'grape-entity', '~> 0.7.1'
8686
gem 'rack-cors', '~> 1.0.0', require: 'rack/cors'
8787

8888
# GraphQL API
89-
gem 'graphql', '= 1.8.4'
89+
gem 'graphql', '= 1.8.17'
9090
gem 'graphiql-rails', '~> 1.4.10'
9191
gem 'apollo_upload_server', '~> 2.0.0.beta3'
9292
gem 'graphql-docs', '~> 1.6.0', group: [:development, :test]

Gemfile.lock

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,7 @@ GEM
402402
graphiql-rails (1.4.10)
403403
railties
404404
sprockets-rails
405-
graphql (1.8.4)
405+
graphql (1.8.17)
406406
graphql-docs (1.6.0)
407407
commonmarker (~> 0.16)
408408
escape_utils (~> 1.2)
@@ -1146,7 +1146,7 @@ DEPENDENCIES
11461146
grape-path-helpers (~> 1.1)
11471147
grape_logging (~> 1.7)
11481148
graphiql-rails (~> 1.4.10)
1149-
graphql (= 1.8.4)
1149+
graphql (= 1.8.17)
11501150
graphql-docs (~> 1.6.0)
11511151
grpc (~> 1.19.0)
11521152
gssapi

app/graphql/mutations/notes/create/base.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@ class Base < Mutations::Notes::Base
1818
required: true,
1919
description: copy_field_description(Types::Notes::NoteType, :body)
2020

21-
private
22-
2321
def resolve(args)
2422
noteable = authorized_find!(id: args[:noteable_id])
2523

@@ -37,6 +35,8 @@ def resolve(args)
3735
}
3836
end
3937

38+
private
39+
4040
def create_note_params(noteable, args)
4141
{
4242
noteable: noteable,

app/graphql/resolvers/full_path_resolver.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ module FullPathResolver
1111
end
1212

1313
def model_by_full_path(model, full_path)
14-
BatchLoader.for(full_path).batch(key: model) do |full_paths, loader, args|
14+
BatchLoader::GraphQL.for(full_path).batch(key: model) do |full_paths, loader, args|
1515
# `with_route` avoids an N+1 calculating full_path
1616
args[:key].where_full_path_in(full_paths).with_route.each do |model_instance|
1717
loader.call(model_instance.full_path, model_instance)

app/graphql/resolvers/issues_resolver.rb

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,11 @@ class IssuesResolver < BaseResolver
4141

4242
type Types::IssueType, null: true
4343

44-
alias_method :project, :object
45-
4644
def resolve(**args)
4745
# The project could have been loaded in batch by `BatchLoader`.
4846
# At this point we need the `id` of the project to query for issues, so
4947
# make sure it's loaded and not `nil` before continuing.
50-
project.sync if project.respond_to?(:sync)
48+
project = object.respond_to?(:sync) ? object.sync : object
5149
return Issue.none if project.nil?
5250

5351
# Will need to be be made group & namespace aware with

app/graphql/resolvers/merge_requests_resolver.rb

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,10 @@ def resolve(**args)
2525

2626
# rubocop: disable CodeReuse/ActiveRecord
2727
def batch_load(iid)
28-
BatchLoader.for(iid.to_s).batch(key: project) do |iids, loader, args|
29-
args[:key].merge_requests.where(iid: iids).each do |mr|
28+
BatchLoader::GraphQL.for(iid.to_s).batch(key: project) do |iids, loader, args|
29+
arg_key = args[:key].respond_to?(:sync) ? args[:key].sync : args[:key]
30+
31+
arg_key.merge_requests.where(iid: iids).each do |mr|
3032
loader.call(mr.iid.to_s, mr)
3133
end
3234
end

app/graphql/resolvers/namespace_projects_resolver.rb

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,11 @@ class NamespaceProjectsResolver < BaseResolver
99

1010
type Types::ProjectType, null: true
1111

12-
alias_method :namespace, :object
13-
1412
def resolve(include_subgroups:)
1513
# The namespace could have been loaded in batch by `BatchLoader`.
1614
# At this point we need the `id` or the `full_path` of the namespace
1715
# to query for projects, so make sure it's loaded and not `nil` before continuing.
18-
namespace.sync if namespace.respond_to?(:sync)
16+
namespace = object.respond_to?(:sync) ? object.sync : object
1917
return Project.none if namespace.nil?
2018

2119
if include_subgroups

ee/app/graphql/resolvers/design_management/design_resolver.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ class DesignResolver < BaseResolver
1010
'If argument is omitted or nil then all designs will reflect the latest version.'
1111

1212
def resolve(at_version: nil)
13-
version = at_version ? GitlabSchema.object_from_id(at_version) : nil
13+
version = at_version ? GitlabSchema.object_from_id(at_version)&.sync : nil
1414

1515
::DesignManagement::DesignsFinder.new(
1616
object.issue,

ee/app/graphql/resolvers/design_management/version_resolver.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ def resolve(parent: nil)
1515
# for consistency we should only present versions up to the given
1616
# version here.
1717
at_version = Gitlab::Graphql::FindArgumentInParent.find(parent, :at_version, limit_depth: 4)
18-
version = at_version ? GitlabSchema.object_from_id(at_version) : nil
18+
version = at_version ? GitlabSchema.object_from_id(at_version).sync : nil
1919

2020
::DesignManagement::VersionsFinder.new(
2121
design_or_collection,

ee/app/graphql/resolvers/epic_resolver.rb

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,9 @@ class EpicResolver < BaseResolver
2525
type Types::EpicType, null: true
2626

2727
def resolve(**args)
28-
return [] unless object.present?
28+
@resolver_object = object.respond_to?(:sync) ? object.sync : object
29+
30+
return [] unless resolver_object.present?
2931
return [] unless epic_feature_enabled?
3032

3133
validate_date_params!(args)
@@ -35,6 +37,8 @@ def resolve(**args)
3537

3638
private
3739

40+
attr_reader :resolver_object
41+
3842
def find_epics(args)
3943
EpicsFinder.new(context[:current_user], args).execute
4044
end
@@ -62,17 +66,17 @@ def transform_args(args)
6266
transformed
6367
end
6468

65-
# `object` refers to the object we're currently querying on, and is usually a `Group`
69+
# `resolver_object` refers to the object we're currently querying on, and is usually a `Group`
6670
# when querying an Epic. In the case of field that uses this resolver, for example
67-
# an Epic's `children` field, then `object` is an `EpicPresenter` (rather than an Epic).
71+
# an Epic's `children` field, then `resolver_object` is an `EpicPresenter` (rather than an Epic).
6872
# But that's the epic we need in order to scope the find to only children of this epic,
6973
# using the `parent_id`
7074
def parent
71-
object if object.is_a?(EpicPresenter)
75+
resolver_object if resolver_object.is_a?(EpicPresenter)
7276
end
7377

7478
def group
75-
return object if object.is_a?(Group)
79+
return resolver_object if resolver_object.is_a?(Group)
7680

7781
parent.group
7882
end

0 commit comments

Comments
 (0)