Commit 0cedd43e authored by Brett Walker's avatar Brett Walker

Grab field_defn to access certain values

parent 95b3fe28
...@@ -32,9 +32,11 @@ module Types ...@@ -32,9 +32,11 @@ module Types
# Resolvers may add extra complexity depending on used arguments # Resolvers may add extra complexity depending on used arguments
complexity = child_complexity + self.resolver&.try(:resolver_complexity, args, child_complexity: child_complexity).to_i complexity = child_complexity + self.resolver&.try(:resolver_complexity, args, child_complexity: child_complexity).to_i
if @connection field_defn = to_graphql
if field_defn.connection?
# Resolvers may add extra complexity depending on number of items being loaded. # Resolvers may add extra complexity depending on number of items being loaded.
page_size = @max_page_size || ctx.schema.default_max_page_size page_size = field_defn.connection_max_page_size || ctx.schema.default_max_page_size
limit_value = [args[:first], args[:last], page_size].compact.min limit_value = [args[:first], args[:last], page_size].compact.min
multiplier = self.resolver&.try(:complexity_multiplier, args).to_f multiplier = self.resolver&.try(:complexity_multiplier, args).to_f
complexity += complexity * limit_value * multiplier complexity += complexity * limit_value * multiplier
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment