Thanks to visit codestin.com
Credit goes to github.com

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
4 changes: 3 additions & 1 deletion src/main/java/graphql/execution/ResultPath.java
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,10 @@ public static ResultPath fromList(List<?> objects) {
for (Object object : objects) {
if (object instanceof String) {
path = path.segment(((String) object));
} else {
} else if (object instanceof Integer) {
path = path.segment((int) object);
} else if (object != null) {
path = path.segment(object.toString());
}
}
return path;
Expand Down
7 changes: 7 additions & 0 deletions src/test/groovy/graphql/execution/ResultPathTest.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,13 @@ class ResultPathTest extends Specification {
path.toList() == ["a", "b"]
}

def "pass any other object than string or int"(){
when:
ResultPath.fromList(["a", "b", true])
Copy link
Member

Choose a reason for hiding this comment

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

the graphql-java code itself would never use anything but a String or Integer - but I am happy to have this be more robust


then:
notThrown(ClassCastException)
}

def "can append paths"() {
when:
Expand Down
Loading