blob: 82809fac22fb6b3641eb052a2f9b9708263351db (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
# frozen_string_literal: true
module Types
# rubocop: disable Graphql/AuthorizeTypes
class QueryComplexityType < ::Types::BaseObject
ANALYZER = GraphQL::Analysis::QueryComplexity.new { |_query, complexity| complexity }
graphql_name 'QueryComplexity'
alias_method :query, :object
field :limit, GraphQL::INT_TYPE,
null: true,
method: :max_complexity,
see: {
'GitLab documentation on this limit' =>
'https://docs.gitlab.com/ee/api/graphql/index.html#max-query-complexity'
},
description: 'GraphQL query complexity limit.'
field :score, GraphQL::INT_TYPE,
null: true,
description: 'GraphQL query complexity score.'
def score
::GraphQL::Analysis.analyze_query(query, [ANALYZER]).first
end
end
# rubocop: enable Graphql/AuthorizeTypes
end
|