Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorBrett Walker <bwalker@gitlab.com>2019-03-27 23:02:25 +0300
committerBrett Walker <bwalker@gitlab.com>2019-04-04 16:39:30 +0300
commitf458c561070d754cd546b07caf60dfa7ffb06293 (patch)
treeef4c65fb5b6767030c0c8b88223f415eabfe88be /lib
parent815901e322b60d28983f52a7ce5e98555285bef8 (diff)
Initial field and query complexity limits
It makes all Types::BaseField default to a complexity of 1. Queries themselves now have limited complexity, scaled to the type of user: no user, authenticated user, or an admin user.
Diffstat (limited to 'lib')
-rw-r--r--lib/gitlab/graphql/query_analyzers/log_query_complexity.rb18
1 files changed, 18 insertions, 0 deletions
diff --git a/lib/gitlab/graphql/query_analyzers/log_query_complexity.rb b/lib/gitlab/graphql/query_analyzers/log_query_complexity.rb
new file mode 100644
index 00000000000..95db130dbfc
--- /dev/null
+++ b/lib/gitlab/graphql/query_analyzers/log_query_complexity.rb
@@ -0,0 +1,18 @@
+# frozen_string_literal: true
+
+module Gitlab
+ module Graphql
+ module QueryAnalyzers
+ class LogQueryComplexity
+ class << self
+ def analyzer
+ GraphQL::Analysis::QueryComplexity.new do |query, complexity|
+ # temporary until https://gitlab.com/gitlab-org/gitlab-ce/issues/59587
+ Rails.logger.info("[GraphQL Query Complexity] #{complexity} | admin? #{query.context[:current_user]&.admin?}")
+ end
+ end
+ end
+ end
+ end
+ end
+end