Sha256: 2e1b20ade6f421b3bcc89060f6d17a8dc23147e857ae953329144ccad62b4ad0

Contents?: true

Size: 819 Bytes

Versions: 25

Compression:

Stored size: 819 Bytes

Contents

require_relative "./query_depth"
module GraphQL
  module Analysis
    # Used under the hood to implement depth validation,
    # see {Schema#max_depth} and {Query#max_depth}
    #
    # @example Assert max depth of 10
    #   # DON'T actually do this, graphql-ruby
    #   # Does this for you based on your `max_depth` setting
    #   MySchema.query_analyzers << GraphQL::Analysis::MaxQueryDepth.new(10)
    #
    class MaxQueryDepth < GraphQL::Analysis::QueryDepth
      def initialize(max_depth)
        disallow_excessive_depth = -> (query, depth) {
          if depth > max_depth
            GraphQL::AnalysisError.new("Query has depth of #{depth}, which exceeds max depth of #{max_depth}")
          else
            nil
          end
        }
        super(&disallow_excessive_depth)
      end
    end
  end
end

Version data entries

25 entries across 25 versions & 1 rubygems

Version Path
graphql-0.19.3 lib/graphql/analysis/max_query_depth.rb
graphql-0.19.2 lib/graphql/analysis/max_query_depth.rb
graphql-0.19.1 lib/graphql/analysis/max_query_depth.rb
graphql-0.19.0 lib/graphql/analysis/max_query_depth.rb
graphql-0.18.15 lib/graphql/analysis/max_query_depth.rb
graphql-0.18.14 lib/graphql/analysis/max_query_depth.rb
graphql-0.18.13 lib/graphql/analysis/max_query_depth.rb
graphql-0.18.12 lib/graphql/analysis/max_query_depth.rb
graphql-0.18.11 lib/graphql/analysis/max_query_depth.rb
graphql-0.18.10 lib/graphql/analysis/max_query_depth.rb
graphql-0.18.9 lib/graphql/analysis/max_query_depth.rb
graphql-0.18.8 lib/graphql/analysis/max_query_depth.rb
graphql-0.18.7 lib/graphql/analysis/max_query_depth.rb
graphql-0.18.6 lib/graphql/analysis/max_query_depth.rb
graphql-0.18.5 lib/graphql/analysis/max_query_depth.rb
graphql-0.18.4 lib/graphql/analysis/max_query_depth.rb
graphql-0.18.3 lib/graphql/analysis/max_query_depth.rb
graphql-0.18.2 lib/graphql/analysis/max_query_depth.rb
graphql-0.18.1 lib/graphql/analysis/max_query_depth.rb
graphql-0.18.0 lib/graphql/analysis/max_query_depth.rb