Files
grecia/spec/graphql/consul_schema_spec.rb
Javi Martín 90bb7484a5 Add max_depth limit to GraphQL queries once again
We accidentally removed this code in commit c984e666f. As mentioned in
our GraphQL documentation, limiting the depth of the queries helps
against DoS attacks.
2024-09-30 11:52:39 +02:00

38 lines
847 B
Ruby

require "rails_helper"
describe ConsulSchema do
let(:user) { create(:user) }
it "returns an error for queries exceeding max depth" do
query = <<~GRAPHQL
{
user(id: #{user.id}) {
public_proposals {
edges {
node {
public_author {
username
public_proposals {
edges {
node {
public_author {
username
}
}
}
}
}
}
}
}
}
}
GRAPHQL
response = execute(query)
expect(response["errors"]).not_to be nil
expect(response["errors"].first["message"]).to match(/exceeds max depth/)
end
end