Skip to content

Commit

Permalink
Merge pull request rmosolgo#3690 from mattpage/1.11.x
Browse files Browse the repository at this point in the history
use validation_max_errors in validation pipeline
  • Loading branch information
Robert Mosolgo committed Nov 4, 2021
2 parents 816e14d + b0a25a0 commit 720eab9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/graphql/query/validation_pipeline.rb
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def ensure_has_validated
elsif @operation_name_error
@validation_errors << @operation_name_error
else
validation_result = @schema.static_validator.validate(@query, validate: @validate, timeout: @schema.validate_timeout)
validation_result = @schema.static_validator.validate(@query, validate: @validate, timeout: @schema.validate_timeout, max_errors: @schema.validate_max_errors)
@validation_errors.concat(validation_result[:errors])
@internal_representation = validation_result[:irep]

Expand Down
7 changes: 7 additions & 0 deletions spec/graphql/query_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,13 @@
)}
let(:result) { query.result }

it "applies the max validation errors config" do
limited_schema = Class.new(schema) { validate_max_errors(2) }
res = limited_schema.execute("{ a b c d }")
assert_equal 2, res["errors"].size
refute res.key?("data")
end

describe "when passed both a query string and a document" do
it "returns an error to the client when query kwarg is used" do
assert_raises ArgumentError do
Expand Down

0 comments on commit 720eab9

Please sign in to comment.