Commit c9a4c9af authored by Douglas Barbosa Alexandre's avatar Douglas Barbosa Alexandre

Merge branch 'graphql-complexity-flag' into 'master'

Remove graphql_resolver_complexity flag

Closes #35736 and #208120

See merge request gitlab-org/gitlab!27652
parents 0393142f 497b5569
...@@ -90,8 +90,6 @@ module Types ...@@ -90,8 +90,6 @@ module Types
# proc because we set complexity depending on arguments and number of # proc because we set complexity depending on arguments and number of
# items which can be loaded. # items which can be loaded.
proc do |ctx, args, child_complexity| proc do |ctx, args, child_complexity|
next base_complexity unless resolver_complexity_enabled?(ctx)
# 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
complexity += 1 if calls_gitaly? complexity += 1 if calls_gitaly?
...@@ -101,10 +99,6 @@ module Types ...@@ -101,10 +99,6 @@ module Types
end end
end end
def resolver_complexity_enabled?(ctx)
ctx.fetch(:graphql_resolver_complexity_flag) { |key| ctx[key] = Feature.enabled?(:graphql_resolver_complexity) }
end
def connection_complexity_multiplier(ctx, args) def connection_complexity_multiplier(ctx, args)
# Resolvers may add extra complexity depending on number of items being loaded. # Resolvers may add extra complexity depending on number of items being loaded.
field_defn = to_graphql field_defn = to_graphql
......
---
title: Fix processing of GrapqhQL query complexity based on used resolvers.
merge_request: 27652
author:
type: fixed
...@@ -67,17 +67,6 @@ describe Types::BaseField do ...@@ -67,17 +67,6 @@ describe Types::BaseField do
expect(field.to_graphql.complexity.call({}, { first: 1 }, 2)).to eq 2 expect(field.to_graphql.complexity.call({}, { first: 1 }, 2)).to eq 2
expect(field.to_graphql.complexity.call({}, { first: 1, foo: true }, 2)).to eq 4 expect(field.to_graphql.complexity.call({}, { first: 1, foo: true }, 2)).to eq 4
end end
context 'when graphql_resolver_complexity is disabled' do
before do
stub_feature_flags(graphql_resolver_complexity: false)
end
it 'sets default field complexity' do
expect(field.to_graphql.complexity.call({}, {}, 2)).to eq 1
expect(field.to_graphql.complexity.call({}, { first: 50 }, 2)).to eq 1
end
end
end end
context 'and is not a connection' do context 'and is not a connection' do
......
...@@ -165,7 +165,6 @@ describe 'GraphQL' do ...@@ -165,7 +165,6 @@ describe 'GraphQL' do
before do before do
stub_const('GitlabSchema::DEFAULT_MAX_COMPLEXITY', 6) stub_const('GitlabSchema::DEFAULT_MAX_COMPLEXITY', 6)
stub_feature_flags(graphql_resolver_complexity: true)
end end
context 'when fetching single resource' do context 'when fetching single resource' do
...@@ -186,18 +185,6 @@ describe 'GraphQL' do ...@@ -186,18 +185,6 @@ describe 'GraphQL' do
expect_graphql_errors_to_include(/which exceeds max complexity/) expect_graphql_errors_to_include(/which exceeds max complexity/)
end end
context 'when graphql_resolver_complexity is disabled' do
before do
stub_feature_flags(graphql_resolver_complexity: false)
end
it 'processes the query' do
post_graphql(query)
expect(graphql_errors).to be_nil
end
end
end end
end end
end end
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