Sha256: e8d94f6fc9d32d9ab70e707b19758eab21da32b1702e175de92cb9df43765bfb
Contents?: true
Size: 1.2 KB
Versions: 15
Compression:
Stored size: 1.2 KB
Contents
require "spec_helper" describe GraphQL::StaticValidation::VariablesAreInputTypes do let(:query_string) {' query getCheese( $id: Int = 1, $str: [String!], $interface: AnimalProduct!, $object: Milk = 1, $objects: [Cheese]!, ) { cheese(id: $id) { source } } '} let(:validator) { GraphQL::StaticValidation::Validator.new(schema: DummySchema, rules: [GraphQL::StaticValidation::VariablesAreInputTypes]) } let(:query) { GraphQL::Query.new(DummySchema, query_string) } let(:errors) { validator.validate(query)[:errors] } it "finds variables whose types are invalid" do expected = [ { "message"=>"AnimalProduct isn't a valid input type (on $interface)", "locations"=>[{"line"=>5, "column"=>7}], "path"=>["query getCheese"], }, { "message"=>"Milk isn't a valid input type (on $object)", "locations"=>[{"line"=>6, "column"=>7}], "path"=>["query getCheese"], }, { "message"=>"Cheese isn't a valid input type (on $objects)", "locations"=>[{"line"=>7, "column"=>7}], "path"=>["query getCheese"], } ] assert_equal(expected, errors) end end
Version data entries
15 entries across 15 versions & 1 rubygems