Sha256: dcbc8be29ea18c4d4879238685da1b53ac16f362e61b5820bef14bc61ba5154d
Contents?: true
Size: 1.33 KB
Versions: 5
Compression:
Stored size: 1.33 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}] }, { "message"=>"Invalid fragment on type DairyProductInput (must be Union, Interface or Object)", "locations"=>[{"line"=>14, "column"=>9}], }, { "message"=>"Invalid fragment on type Int (must be Union, Interface or Object)", "locations"=>[{"line"=>20, "column"=>5}] }, ] assert_equal(expected, errors) end end
Version data entries
5 entries across 5 versions & 1 rubygems