Skip to content
Snippets Groups Projects
Commit 0e711381 authored by Mayra Cabrera's avatar Mayra Cabrera
Browse files

Merge branch '62535-upgrade-graphql-gem-to-version-1-8-17' into 'master'

Upgrade GraphQL gem to 1.8.17

See merge request gitlab-org/gitlab-ce!32299
parents 29e3a08b aa7b1cfc
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -12,7 +12,7 @@ describe Resolvers::ProjectResolver do
it 'batch-resolves projects by full path' do
paths = [project1.full_path, project2.full_path]
 
result = batch(max_queries: 1) do
result = batch_sync(max_queries: 1) do
paths.map { |path| resolve_project(path) }
end
 
Loading
Loading
@@ -20,7 +20,7 @@ describe Resolvers::ProjectResolver do
end
 
it 'resolves an unknown full_path to nil' do
result = batch { resolve_project('unknown/project') }
result = batch_sync { resolve_project('unknown/project') }
 
expect(result).to be_nil
end
Loading
Loading
Loading
Loading
@@ -46,9 +46,9 @@ describe Gitlab::Graphql::Authorize::AuthorizeResource do
end
end
 
describe '#authorized?' do
describe '#authorized_resource?' do
it 'is true' do
expect(loading_resource.authorized?(project)).to be(true)
expect(loading_resource.authorized_resource?(project)).to be(true)
end
end
end
Loading
Loading
@@ -72,9 +72,9 @@ describe Gitlab::Graphql::Authorize::AuthorizeResource do
end
end
 
describe '#authorized?' do
describe '#authorized_resource?' do
it 'is false' do
expect(loading_resource.authorized?(project)).to be(false)
expect(loading_resource.authorized_resource?(project)).to be(false)
end
end
end
Loading
Loading
@@ -121,9 +121,9 @@ describe Gitlab::Graphql::Authorize::AuthorizeResource do
end
end
 
describe '#authorized?' do
describe '#authorized_resource?' do
it 'raises a comprehensive error message' do
expect { loading_resource.authorized?(project) }.to raise_error(error)
expect { loading_resource.authorized_resource?(project) }.to raise_error(error)
end
end
end
Loading
Loading
Loading
Loading
@@ -12,7 +12,7 @@ describe Gitlab::Graphql::Loaders::BatchLfsOidLoader do
it 'batch-resolves LFS blob IDs' do
expect(Gitlab::Git::Blob).to receive(:batch_lfs_pointers).once.and_call_original
 
result = batch do
result = batch_sync do
[blob, otherblob].map { |b| described_class.new(repository, b.id).find }
end
 
Loading
Loading
Loading
Loading
@@ -9,8 +9,8 @@ describe Gitlab::Graphql::Loaders::BatchModelLoader do
issue_result = described_class.new(Issue, issue.id).find
user_result = described_class.new(User, user.id).find
 
expect(issue_result.__sync).to eq(issue)
expect(user_result.__sync).to eq(user)
expect(issue_result.sync).to eq(issue)
expect(user_result.sync).to eq(user)
end
 
it 'only queries once per model' do
Loading
Loading
@@ -21,7 +21,7 @@ describe Gitlab::Graphql::Loaders::BatchModelLoader do
expect do
[described_class.new(User, other_user.id).find,
described_class.new(User, user.id).find,
described_class.new(Issue, issue.id).find].map(&:__sync)
described_class.new(Issue, issue.id).find].map(&:sync)
end.not_to exceed_query_limit(2)
end
end
Loading
Loading
Loading
Loading
@@ -10,7 +10,7 @@ describe Gitlab::Graphql::Loaders::PipelineForShaLoader do
pipeline2 = create(:ci_pipeline, project: project, ref: project.default_branch, sha: project.commit.sha)
pipeline3 = create(:ci_pipeline, project: project, ref: 'improve/awesome', sha: project.commit('improve/awesome').sha)
 
result = batch(max_queries: 1) do
result = batch_sync(max_queries: 1) do
[pipeline1.sha, pipeline3.sha].map { |sha| described_class.new(project, sha).find_last }
end
 
Loading
Loading
Loading
Loading
@@ -13,7 +13,7 @@ describe 'Setting WIP status of a merge request' do
project_path: project.full_path,
iid: merge_request.iid.to_s
}
graphql_mutation(:merge_request_set_wip, variables.merge(input))
graphql_mutation(:merge_request_set_wip, variables.merge(input), "clientMutationId\nerrors\nmergeRequest { id\ntitle }")
end
 
def mutation_response
Loading
Loading
Loading
Loading
@@ -34,6 +34,14 @@ module GraphqlHelpers
end
end
 
# BatchLoader::GraphQL returns a wrapper, so we need to :sync in order
# to get the actual values
def batch_sync(max_queries: nil, &blk)
result = batch(max_queries: nil, &blk)
result.is_a?(Array) ? result.map(&:sync) : result&.sync
end
def graphql_query_for(name, attributes = {}, fields = nil)
<<~QUERY
{
Loading
Loading
@@ -114,7 +122,11 @@ module GraphqlHelpers
FIELDS
end
 
def all_graphql_fields_for(class_name, parent_types = Set.new)
def all_graphql_fields_for(class_name, parent_types = Set.new, max_depth: 3)
# pulling _all_ fields can generate a _huge_ query (like complexity 180,000),
# and significantly increase spec runtime. so limit the depth by default
return if max_depth <= 0
allow_unlimited_graphql_complexity
allow_unlimited_graphql_depth
 
Loading
Loading
@@ -133,9 +145,9 @@ module GraphqlHelpers
 
if nested_fields?(field)
fields =
all_graphql_fields_for(singular_field_type, parent_types | [type])
all_graphql_fields_for(singular_field_type, parent_types | [type], max_depth: max_depth - 1)
 
"#{name} { #{fields} }"
"#{name} { #{fields} }" unless fields.blank?
else
name
end
Loading
Loading
Loading
Loading
@@ -46,7 +46,7 @@ shared_context 'exposing regular notes on a noteable in GraphQL' do
discussions {
edges {
node {
#{all_graphql_fields_for('Discussion')}
#{all_graphql_fields_for('Discussion', max_depth: 4)}
}
}
}
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment