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:
authorBrett Walker <bwalker@gitlab.com>2019-09-04 20:42:48 +0300
committerMayra Cabrera <mcabrera@gitlab.com>2019-09-04 20:42:48 +0300
commitaa7b1cfc5b3319373a4b56c755b1fc1d4cbaff02 (patch)
treeba078b30d36bf8ed8d5ec8fece71871e40d85a2c /spec/support
parent29e3a08b8f8f9511dd6e25566bc9abb135a597c4 (diff)
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 'spec/support')
-rw-r--r--spec/support/helpers/graphql_helpers.rb18
-rw-r--r--spec/support/shared_examples/graphql/notes_on_noteables_shared_examples.rb2
2 files changed, 16 insertions, 4 deletions
diff --git a/spec/support/helpers/graphql_helpers.rb b/spec/support/helpers/graphql_helpers.rb
index d86371d70b9..beb346b2855 100644
--- a/spec/support/helpers/graphql_helpers.rb
+++ b/spec/support/helpers/graphql_helpers.rb
@@ -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
{
@@ -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
@@ -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
diff --git a/spec/support/shared_examples/graphql/notes_on_noteables_shared_examples.rb b/spec/support/shared_examples/graphql/notes_on_noteables_shared_examples.rb
index 323d1c51ffd..9a60825855f 100644
--- a/spec/support/shared_examples/graphql/notes_on_noteables_shared_examples.rb
+++ b/spec/support/shared_examples/graphql/notes_on_noteables_shared_examples.rb
@@ -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)}
}
}
}