Skip to content
Snippets Groups Projects
Commit a142c969 authored by Brett Walker's avatar Brett Walker
Browse files

Override new complexity calculation to use our own

parent a92098dd
No related branches found
No related tags found
No related merge requests found
This commit is part of merge request !27536. Comments created here will be created in the context of that merge request.
......@@ -53,6 +53,22 @@ def authorized?(object, args, ctx)
field_authorized?(object, ctx) && resolver_authorized?(object, ctx)
end
# This gets called from the gem's `calculate_complexity` method, allowing us
# to ensure our complexity calculation is used even for connections
def complexity_for(child_complexity:, query:, lookahead:)
defined_complexity = complexity
case defined_complexity
when Proc
arguments = query.arguments_for(lookahead.ast_nodes.first, self)
defined_complexity.call(query.context, arguments.keyword_arguments, child_complexity)
when Numeric
defined_complexity + child_complexity
else
raise("Invalid complexity: #{defined_complexity.inspect} on #{path} (#{inspect})")
end
end
def base_complexity
complexity = DEFAULT_COMPLEXITY
complexity += 1 if calls_gitaly?
......
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