Skip to content

Commit

Permalink
test(VariableUsagesAreAllowed) add failing test for list dimension
Browse files Browse the repository at this point in the history
  • Loading branch information
rmosolgo committed Jul 5, 2017
1 parent 12b7b71 commit 03b4861
Showing 1 changed file with 49 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -80,4 +80,53 @@
assert_equal "Argument 'id' on Field 'cheese' has an invalid value. Expected type 'Int!'.", errors[0]["message"]
end
end

describe "list-type variables" do
let(:schema) {
GraphQL::Schema.from_definition <<-GRAPHQL
input ImageSize {
height: Int
width: Int
scale: Int
}
type Query {
imageUrl(height: Int, width: Int, size: ImageSize, sizes: [ImageSize!]): String!
}
GRAPHQL
}

describe "nullability mismatch" do
let(:query_string) {
<<-GRAPHQL
# This variable _should_ be [ImageSize!]
query ($sizes: [ImageSize]) {
imageUrl(sizes: $sizes)
}
GRAPHQL
}

it "finds invalid inner definitions" do
assert_equal 1, errors.size
expected_message = "Nullability mismatch on variable $sizes and argument sizes ([ImageSize] / [ImageSize!])"
assert_equal [expected_message], errors.map { |e| e["message"] }
end
end

describe "list dimension mismatch" do
let(:query_string) {
<<-GRAPHQL
query ($sizes: [ImageSize]) {
imageUrl(sizes: [$sizes])
}
GRAPHQL
}

it "finds invalid inner definitions" do
assert_equal 1, errors.size
expected_message = "List dimension mismatch on variable $sizes and argument sizes ([[ImageSize]] / [ImageSize!])"
assert_equal [expected_message], errors.map { |e| e["message"] }
end
end
end
end

0 comments on commit 03b4861

Please sign in to comment.