Sha256: 2fa00cb72db3096238e271bab151c56faf907ffe73febcb31e1145b4aecbdfcc
Contents?: true
Size: 1.53 KB
Versions: 15
Compression:
Stored size: 1.53 KB
Contents
require "spec_helper" describe GraphQL::StaticValidation::FragmentsAreOnCompositeTypes do let(:query_string) {%| query getCheese { cheese(id: 1) { ... on Cheese { source ... on Boolean { something } } ... intFields ... on DairyProduct { name } ... on DairyProductInput { something } } } fragment intFields on Int { something } |} let(:validator) { GraphQL::StaticValidation::Validator.new(schema: DummySchema, rules: [GraphQL::StaticValidation::FragmentsAreOnCompositeTypes]) } let(:query) { GraphQL::Query.new(DummySchema, query_string) } let(:errors) { validator.validate(query)[:errors] } it "requires Object/Union/Interface fragment types" do expected = [ { "message"=>"Invalid fragment on type Boolean (must be Union, Interface or Object)", "locations"=>[{"line"=>6, "column"=>11}], "path"=>["query getCheese", "cheese", "... on Cheese", "... on Boolean"], }, { "message"=>"Invalid fragment on type DairyProductInput (must be Union, Interface or Object)", "locations"=>[{"line"=>14, "column"=>9}], "path"=>["query getCheese", "cheese", "... on DairyProductInput"], }, { "message"=>"Invalid fragment on type Int (must be Union, Interface or Object)", "locations"=>[{"line"=>20, "column"=>5}], "path"=>["fragment intFields"], }, ] assert_equal(expected, errors) end end
Version data entries
15 entries across 15 versions & 1 rubygems