Sha256: 7bdf146ac35d817bf4c15b2b77b1ef6043194da596ca6aec3f9e9ebd22188451
Contents?: true
Size: 1.87 KB
Versions: 1
Compression:
Stored size: 1.87 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 } missingSource: searchDairy(product: [{fatContent: 1.1}]) { source } } fragment cheeseFields on Cheese { similarCheese(source: 4.5) } |)} let(:validator) { GraphQL::StaticValidation::Validator.new(schema: DummySchema, rules: [GraphQL::StaticValidation::ArgumentLiteralsAreCompatible]) } let(:errors) { validator.validate(document) } it 'finds undefined or missing-required arguments to fields and directives' do assert_equal(5, errors.length) query_root_error = { "message"=>"Argument id on Field 'cheese' has an invalid value", "locations"=>[{"line"=>3, "column"=>7}] } assert_includes(errors, query_root_error) directive_error = { "message"=>"Argument if on Directive 'skip' has an invalid value", "locations"=>[{"line"=>4, "column"=>31}] } assert_includes(errors, directive_error) input_object_error = { "message"=>"Argument product on Field 'badSource' has an invalid value", "locations"=>[{"line"=>6, "column"=>7}] } assert_includes(errors, input_object_error) missing_required_field_error = { "message"=>"Argument product on Field 'missingSource' has an invalid value", "locations"=>[{"line"=>7, "column"=>7}] } assert_includes(errors, missing_required_field_error) fragment_error = { "message"=>"Argument source on Field 'similarCheese' has an invalid value", "locations"=>[{"line"=>11, "column"=>7}] } assert_includes(errors, fragment_error) end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
graphql-0.10.4 | spec/graphql/static_validation/rules/argument_literals_are_compatible_spec.rb |