Skip to content
Snippets Groups Projects

[graphql] Convert to using the new query interpreter runtime

Merged Brett Walker requested to merge bw-graphql-interpreter into master
2 files
+ 3
4
Compare changes
  • Side-by-side
  • Inline
Files
2
@@ -53,6 +53,30 @@ def authorized?(object, args, ctx)
@@ -53,6 +53,30 @@ def authorized?(object, args, ctx)
field_authorized?(object, ctx) && resolver_authorized?(object, ctx)
field_authorized?(object, ctx) && resolver_authorized?(object, ctx)
end
end
 
# This gets called from the gem's `calculate_complexity` method, allowing us
 
# to ensure our complexity calculation is used even for connections.
 
# This code is actually a copy of the default case in `calculate_complexity`
 
# in `lib/graphql/schema/field.rb`
 
# (https://github.com/rmosolgo/graphql-ruby/blob/master/lib/graphql/schema/field.rb)
 
def complexity_for(child_complexity:, query:, lookahead:)
 
defined_complexity = complexity
 
 
case defined_complexity
 
when Proc
 
arguments = query.arguments_for(lookahead.ast_nodes.first, self)
 
 
if arguments.respond_to?(:keyword_arguments)
 
defined_complexity.call(query.context, arguments.keyword_arguments, child_complexity)
 
else
 
child_complexity
 
end
 
when Numeric
 
defined_complexity + child_complexity
 
else
 
raise("Invalid complexity: #{defined_complexity.inspect} on #{path} (#{inspect})")
 
end
 
end
 
def base_complexity
def base_complexity
complexity = DEFAULT_COMPLEXITY
complexity = DEFAULT_COMPLEXITY
complexity += 1 if calls_gitaly?
complexity += 1 if calls_gitaly?
Loading