Allow tests to ignore recursion
This commit is contained in:
parent
32cdfb9535
commit
d08a78f4b0
2 changed files with 10 additions and 1 deletions
|
@ -45,13 +45,17 @@ module Gitlab
|
||||||
def recursion_too_deep?(node_name, times_encountered)
|
def recursion_too_deep?(node_name, times_encountered)
|
||||||
return if IGNORED_FIELDS.include?(node_name)
|
return if IGNORED_FIELDS.include?(node_name)
|
||||||
|
|
||||||
times_encountered > RECURSION_THRESHOLD
|
times_encountered > recursion_threshold
|
||||||
end
|
end
|
||||||
|
|
||||||
def skip_node?(irep_node)
|
def skip_node?(irep_node)
|
||||||
ast_node = irep_node.ast_node
|
ast_node = irep_node.ast_node
|
||||||
!ast_node.is_a?(GraphQL::Language::Nodes::Field) || ast_node.selections.empty?
|
!ast_node.is_a?(GraphQL::Language::Nodes::Field) || ast_node.selections.empty?
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def recursion_threshold
|
||||||
|
RECURSION_THRESHOLD
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -129,6 +129,7 @@ module GraphqlHelpers
|
||||||
|
|
||||||
allow_unlimited_graphql_complexity
|
allow_unlimited_graphql_complexity
|
||||||
allow_unlimited_graphql_depth
|
allow_unlimited_graphql_depth
|
||||||
|
allow_high_graphql_recursion
|
||||||
|
|
||||||
type = GitlabSchema.types[class_name.to_s]
|
type = GitlabSchema.types[class_name.to_s]
|
||||||
return "" unless type
|
return "" unless type
|
||||||
|
@ -277,6 +278,10 @@ module GraphqlHelpers
|
||||||
allow_any_instance_of(GitlabSchema).to receive(:max_depth).and_return nil
|
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
|
allow(GitlabSchema).to receive(:max_query_depth).with(any_args).and_return nil
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def allow_high_graphql_recursion
|
||||||
|
allow_any_instance_of(Gitlab::Graphql::QueryAnalyzers::RecursionAnalyzer).to receive(:recursion_threshold).and_return 1000
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# This warms our schema, doing this as part of loading the helpers to avoid
|
# This warms our schema, doing this as part of loading the helpers to avoid
|
||||||
|
|
Loading…
Reference in a new issue