Sha256: 1a1cebb935f18c274792680f23be0b4c12b740a4ff5e2b8e5cc87a413ca584c5
Contents?: true
Size: 1.63 KB
Versions: 1
Compression:
Stored size: 1.63 KB
Contents
# frozen_string_literal: true require "spec_helper" describe GraphQL::StaticValidation::VariablesAreInputTypes do include StaticValidationHelpers let(:query_string) {' query getCheese( $id: Int = 1, $str: [String!], $interface: AnimalProduct!, $object: Milk = 1, $objects: [Cheese]!, $unknownType: Nonsense, ) { cheese(id: $id) { source } __type(name: $str) { name } } '} it "finds variables whose types are invalid" do assert_includes(errors, { "message"=>"AnimalProduct isn't a valid input type (on $interface)", "locations"=>[{"line"=>5, "column"=>7}], "fields"=>["query getCheese"], }) assert_includes(errors, { "message"=>"Milk isn't a valid input type (on $object)", "locations"=>[{"line"=>6, "column"=>7}], "fields"=>["query getCheese"], }) assert_includes(errors, { "message"=>"Cheese isn't a valid input type (on $objects)", "locations"=>[{"line"=>7, "column"=>7}], "fields"=>["query getCheese"], }) assert_includes(errors, { "message"=>"Nonsense isn't a defined input type (on $unknownType)", "locations"=>[{"line"=>8, "column"=>7}], "fields"=>["query getCheese"], }) end describe "typos" do it "returns a client error" do res = schema.execute <<-GRAPHQL query GetCheese($id: IDX) { cheese(id: $id) { flavor } } GRAPHQL assert_equal false, res.key?("data") assert_equal 1, res["errors"].length assert_equal "IDX isn't a defined input type (on $id)", res["errors"][0]["message"] end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
graphql-1.5.3 | spec/graphql/static_validation/rules/variables_are_input_types_spec.rb |