summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcharlieablett <cablett@gitlab.com>2019-08-28 15:47:29 +1200
committercharlieablett <cablett@gitlab.com>2019-10-23 15:35:33 +1300
commitd08a78f4b0874f7750242d1a009e1f5342e56172 (patch)
tree6e1c03be424a627e74dbb296548ce29c5c4e7dfa
parent32cdfb95352b4269df288ae77d9ce85fd04e723f (diff)
downloadgitlab-ce-d08a78f4b0874f7750242d1a009e1f5342e56172.tar.gz
Allow tests to ignore recursion
-rw-r--r--lib/gitlab/graphql/query_analyzers/recursion_analyzer.rb6
-rw-r--r--spec/support/helpers/graphql_helpers.rb5
2 files changed, 10 insertions, 1 deletions
diff --git a/lib/gitlab/graphql/query_analyzers/recursion_analyzer.rb b/lib/gitlab/graphql/query_analyzers/recursion_analyzer.rb
index 70d4672d079..ccf9e597307 100644
--- a/lib/gitlab/graphql/query_analyzers/recursion_analyzer.rb
+++ b/lib/gitlab/graphql/query_analyzers/recursion_analyzer.rb
@@ -45,13 +45,17 @@ module Gitlab
def recursion_too_deep?(node_name, times_encountered)
return if IGNORED_FIELDS.include?(node_name)
- times_encountered > RECURSION_THRESHOLD
+ times_encountered > recursion_threshold
end
def skip_node?(irep_node)
ast_node = irep_node.ast_node
!ast_node.is_a?(GraphQL::Language::Nodes::Field) || ast_node.selections.empty?
end
+
+ def recursion_threshold
+ RECURSION_THRESHOLD
+ end
end
end
end
diff --git a/spec/support/helpers/graphql_helpers.rb b/spec/support/helpers/graphql_helpers.rb
index 69bf1f0f3fa..6fb1d279456 100644
--- a/spec/support/helpers/graphql_helpers.rb
+++ b/spec/support/helpers/graphql_helpers.rb
@@ -129,6 +129,7 @@ module GraphqlHelpers
allow_unlimited_graphql_complexity
allow_unlimited_graphql_depth
+ allow_high_graphql_recursion
type = GitlabSchema.types[class_name.to_s]
return "" unless type
@@ -277,6 +278,10 @@ module GraphqlHelpers
allow_any_instance_of(GitlabSchema).to receive(:max_depth).and_return nil
allow(GitlabSchema).to receive(:max_query_depth).with(any_args).and_return nil
end
+
+ def allow_high_graphql_recursion
+ allow_any_instance_of(Gitlab::Graphql::QueryAnalyzers::RecursionAnalyzer).to receive(:recursion_threshold).and_return 1000
+ end
end
# This warms our schema, doing this as part of loading the helpers to avoid