Sha256: 51ad59703406b42e3e440bf2e11d802cdcba0828a1fba9bbf50a8ff0d4cf93c9
Contents?: true
Size: 1.62 KB
Versions: 15
Compression:
Stored size: 1.62 KB
Contents
require "spec_helper" describe GraphQL::StaticValidation::VariableDefaultValuesAreCorrectlyTyped do let(:query_string) {%| query getCheese( $id: Int = 1, $int: Int = 3.4e24, # can be coerced $str: String!, $badFloat: Float = true, $badInt: Int = "abc", $input: DairyProductInput = {source: YAK, fatContent: 1}, $badInput: DairyProductInput = {source: YAK, fatContent: true}, $nonNull: Int! = 1, ) { cheese(id: $id) { source } } |} let(:validator) { GraphQL::StaticValidation::Validator.new(schema: DummySchema, rules: [GraphQL::StaticValidation::VariableDefaultValuesAreCorrectlyTyped]) } let(:query) { GraphQL::Query.new(DummySchema, query_string) } let(:errors) { validator.validate(query)[:errors] } it "finds default values that don't match their types" do expected = [ { "message"=>"Default value for $badFloat doesn't match type Float", "locations"=>[{"line"=>6, "column"=>7}], "path"=>["query getCheese"], }, { "message"=>"Default value for $badInt doesn't match type Int", "locations"=>[{"line"=>7, "column"=>7}], "path"=>["query getCheese"], }, { "message"=>"Default value for $badInput doesn't match type DairyProductInput", "locations"=>[{"line"=>9, "column"=>7}], "path"=>["query getCheese"], }, { "message"=>"Non-null variable $nonNull can't have a default value", "locations"=>[{"line"=>10, "column"=>7}], "path"=>["query getCheese"], } ] assert_equal(expected, errors) end end
Version data entries
15 entries across 15 versions & 1 rubygems