Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/graphql/analysis/query_complexity.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def result
complexity_cost_calculation_mode(:future) # or `:legacy`, `:compare`

GRAPHQL
max_possible_complexity
max_possible_complexity(mode: :legacy)
else
raise ArgumentError, "Expected `:future`, `:legacy`, `:compare`, or `nil` from `#{query.schema}.complexity_cost_calculation_mode_for` but got: #{query.schema.complexity_cost_calculation_mode.inspect}"
end
Expand Down
24 changes: 24 additions & 0 deletions spec/graphql/analysis/query_complexity_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -958,6 +958,30 @@ def self.legacy_complexity_cost_calculation_mismatch(query, future_cpx, legacy_c

assert_includes stdout, "GraphQL-Ruby's complexity cost system is getting some \"breaking fixes\" in a future version. See the migration notes at https://graphql-ruby.org/api-doc/#{GraphQL::VERSION}/GraphQL/Schema.html#complexity_cost_calculation_mode_for-class_method

To opt into the future behavior, configure your schema (MaxOfPossibleScopes) with:

complexity_cost_calculation_mode(:future) # or `:legacy`, `:compare`"
end

it "uses legacy mode" do
cost = nil
assert_nil MaxOfPossibleScopes.complexity_cost_calculation_mode
stdout, _stderr = capture_io do
cost = MaxOfPossibleScopes.cost(%|
{
entity {
...on Farm { name }
...on Producer { name }
}
}
|)
end
puts stdout

assert_equal 6, cost

assert_includes stdout, "GraphQL-Ruby's complexity cost system is getting some \"breaking fixes\" in a future version. See the migration notes at https://graphql-ruby.org/api-doc/#{GraphQL::VERSION}/GraphQL/Schema.html#complexity_cost_calculation_mode_for-class_method

To opt into the future behavior, configure your schema (MaxOfPossibleScopes) with:

complexity_cost_calculation_mode(:future) # or `:legacy`, `:compare`"
Expand Down