Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion src/main/java/graphql/scalar/GraphqlBooleanCoercing.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,14 @@ private Boolean convertImpl(Object input) {
if (input instanceof Boolean) {
return (Boolean) input;
} else if (input instanceof String) {
return Boolean.parseBoolean((String) input);
String lStr = ((String) input).toLowerCase();
if (lStr.equals("true")) {
return true;
}
if (lStr.equals("false")) {
return false;
}
return null;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

null causes a coercing exception ins code you cant see in the diff

} else if (isNumberIsh(input)) {
BigDecimal value;
try {
Expand Down
12 changes: 8 additions & 4 deletions src/test/groovy/graphql/ScalarsBooleanTest.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,6 @@ class ScalarsBooleanTest extends Specification {
"false" | false
"true" | true
"True" | true
"some value not true" | false
"" | false
0 | false
1 | true
-1 | true
Expand All @@ -70,8 +68,14 @@ class ScalarsBooleanTest extends Specification {
thrown(CoercingSerializeException)

where:
value | _
new Object() | _
value | _
new Object() | _
"some value not true" | _
"" | _
"T" | _
"t" | _
"F" | _
"f" | _
}

@Unroll
Expand Down