Sha256: b6b95660ad76d8e72db6fa3359e480e71baca453566bdb044d5eedb14b27141f
Contents?: true
Size: 1.33 KB
Versions: 26
Compression:
Stored size: 1.33 KB
Contents
require 'spec_helper' describe GraphQL::StaticValidation::FragmentSpreadsArePossible do let(:document) { GraphQL.parse(%| query getCheese { cheese(id: 1) { ... milkFields ... cheeseFields ... on Milk { fatContent } ... on AnimalProduct { source } ... on DairyProduct { fatContent ... on Edible { fatContent } } } } fragment milkFields on Milk { fatContent } fragment cheeseFields on Cheese { fatContent ... milkFields } |)} let(:validator) { GraphQL::StaticValidation::Validator.new(schema: DummySchema, rules: [GraphQL::StaticValidation::FragmentSpreadsArePossible]) } let(:errors) { validator.validate(document) } it "doesnt allow spreads where they'll never apply" do # TODO: more negative, abstract examples here, add stuff to the schema expected = [ { "message"=>"Fragment on Milk can't be spread inside Cheese", "locations"=>[{"line"=>6, "column"=>9}] }, { "message"=>"Fragment milkFields on Milk can't be spread inside Cheese", "locations"=>[{"line"=>4, "column"=>9}] }, { "message"=>"Fragment milkFields on Milk can't be spread inside Cheese", "locations"=>[{"line"=>18, "column"=>7}] } ] assert_equal(expected, errors) end end
Version data entries
26 entries across 26 versions & 1 rubygems