Sha256: a74a427dc735934583bcdca369e56419248823466aea26a2ccc0719077eec44f
Contents?: true
Size: 1.16 KB
Versions: 13
Compression:
Stored size: 1.16 KB
Contents
require "spec_helper" describe GraphQL::StaticValidation::FragmentsAreFinite do let(:query_string) {%| query getCheese { cheese(id: 1) { ... idField ... sourceField ... flavorField } } fragment sourceField on Cheese { source, ... flavorField ... idField } fragment flavorField on Cheese { flavor, ... sourceField } fragment idField on Cheese { id } |} let(:validator) { GraphQL::StaticValidation::Validator.new(schema: DummySchema, rules: [GraphQL::StaticValidation::FragmentsAreFinite]) } let(:query) { GraphQL::Query.new(DummySchema, query_string) } let(:errors) { validator.validate(query)[:errors] } it "doesnt allow infinite loops" do expected = [ { "message"=>"Fragment sourceField contains an infinite loop", "locations"=>[{"line"=>10, "column"=>5}], "path"=>["fragment sourceField"], }, { "message"=>"Fragment flavorField contains an infinite loop", "locations"=>[{"line"=>15, "column"=>5}], "path"=>["fragment flavorField"], } ] assert_equal(expected, errors) end end
Version data entries
13 entries across 13 versions & 1 rubygems