Sha256: ce38581f607fa818e86f0f74ecfedeb41c72a9bfe58a9bfbc087b57dfc43b5e5

Contents?: true

Size: 675 Bytes

Versions: 8

Compression:

Stored size: 675 Bytes

Contents

# frozen_string_literal: true
require_relative "./query_complexity"
module GraphQL
  module Analysis
    module AST
      # Used under the hood to implement complexity validation,
      # see {Schema#max_complexity} and {Query#max_complexity}
      class MaxQueryComplexity < QueryComplexity
        def result
          return if query.max_complexity.nil?

          total_complexity = super

          if total_complexity > query.max_complexity
            GraphQL::AnalysisError.new("Query has complexity of #{total_complexity}, which exceeds max complexity of #{query.max_complexity}")
          else
            nil
          end
        end
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
graphql-1.9.3 lib/graphql/analysis/ast/max_query_complexity.rb
graphql-1.9.2 lib/graphql/analysis/ast/max_query_complexity.rb
graphql-1.9.1 lib/graphql/analysis/ast/max_query_complexity.rb
graphql-1.9.0 lib/graphql/analysis/ast/max_query_complexity.rb
graphql-1.9.0.pre4 lib/graphql/analysis/ast/max_query_complexity.rb
graphql-1.9.0.pre3 lib/graphql/analysis/ast/max_query_complexity.rb
graphql-1.9.0.pre2 lib/graphql/analysis/ast/max_query_complexity.rb
graphql-1.9.0.pre1 lib/graphql/analysis/ast/max_query_complexity.rb