Sha256: 9acd189cd94806531b175cee5107ea8952eea08fcdc715f26f0a9135d7884326
Contents?: true
Size: 1.34 KB
Versions: 1
Compression:
Stored size: 1.34 KB
Contents
require 'spec_helper' describe GraphQL::StaticValidation::ArgumentLiteralsAreCompatible do let(:document) { GraphQL.parse(%| query getCheese { cheese(id: "aasdlkfj") { source } cheese(id: 1) { source @skip(if: {id: 1})} yakSource: searchDairy(product: {source: YAK, fatContent: 1.1}) { source } badSource: searchDairy(product: {source: 1.1}) { source } } fragment cheeseFields on Cheese { similarCheeses(source: 4.5) } |)} let(:validator) { GraphQL::StaticValidation::Validator.new(schema: DummySchema, validators: [GraphQL::StaticValidation::ArgumentLiteralsAreCompatible]) } let(:errors) { validator.validate(document) } it 'finds undefined arguments to fields and directives' do assert_equal(3, errors.length) query_root_error = { "message"=>"id on Field 'cheese' has an invalid value", "locations"=>[{"line"=>3, "column"=>7}] } assert_includes(errors, query_root_error) input_object_error = { "message"=>"product on Field 'searchDairy' has an invalid value", "locations"=>[{"line"=>6, "column"=>7}] } assert_includes(errors, input_object_error) fragment_error = { "message"=>"source on Field 'similarCheeses' has an invalid value", "locations"=>[{"line"=>10, "column"=>7}] } assert_includes(errors, fragment_error) end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
graphql-0.2.0 | spec/graph_ql/static_validation/argument_literals_are_compatible_spec.rb |