diff options
author | charlieablett <cablett@gitlab.com> | 2019-06-28 13:24:47 +1200 |
---|---|---|
committer | charlieablett <cablett@gitlab.com> | 2019-07-03 22:53:13 +1200 |
commit | cf1b0d10bcdde69f05695a2e9a0d380c6badb6d1 (patch) | |
tree | 9bcc0d99dc22a2f4fa2601f1b904c7a418766616 /app/graphql | |
parent | a11fe5de4408595cc8b2b091cbbb76e423c98f34 (diff) | |
download | gitlab-ce-cf1b0d10bcdde69f05695a2e9a0d380c6badb6d1.tar.gz |
Address reviewer comments
- Add 1 for all fields that call Gitaly (with resolvers or without)
- Clarify comment regarding Gitaly call alert
- Expose predicate `calls_gitaly?` instead of ivar
Diffstat (limited to 'app/graphql')
-rw-r--r-- | app/graphql/types/base_field.rb | 16 |
1 files changed, 4 insertions, 12 deletions
diff --git a/app/graphql/types/base_field.rb b/app/graphql/types/base_field.rb index 42c7eb6b485..6b377e88e16 100644 --- a/app/graphql/types/base_field.rb +++ b/app/graphql/types/base_field.rb @@ -4,8 +4,6 @@ module Types class BaseField < GraphQL::Schema::Field prepend Gitlab::Graphql::Authorize - attr_reader :calls_gitaly - DEFAULT_COMPLEXITY = 1 def initialize(*args, **kwargs, &block) @@ -17,19 +15,12 @@ module Types def base_complexity complexity = DEFAULT_COMPLEXITY - complexity += 1 if @calls_gitaly + complexity += 1 if calls_gitaly? complexity end - def calls_gitaly_check(calls) - return if @calls_gitaly - return if calls < 1 - - # Will inform you if :calls_gitaly should be true or false based on the number of Gitaly calls - # involved with the request. - raise "Gitaly is called for field '#{name}' #{"on type #{owner.name} " if owner}- please add `calls_gitaly: true` to the field declaration" - rescue => e - Gitlab::Sentry.track_exception(e) + def calls_gitaly? + @calls_gitaly end private @@ -51,6 +42,7 @@ module Types proc do |ctx, args, child_complexity| # 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 += 1 if calls_gitaly? field_defn = to_graphql |