Skip to content

Commit 94f1d70

Browse files
author
Thomas Draier
committed
Added unit test with list of list as input
1 parent 875f59d commit 94f1d70

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

src/test/java/graphql/annotations/GraphQLInputTest.java

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,13 @@ public String value(InputObject input) {
7979
}
8080
}
8181

82+
static class TestObjectList {
83+
@GraphQLField
84+
public String value(List<List<List<InputObject>>> input) {
85+
return input.get(0).get(0).get(0).key + "a";
86+
}
87+
}
88+
8289
static class TestObjectRec {
8390
@GraphQLField
8491
public String value(RecursiveInputObject input) {
@@ -124,6 +131,13 @@ public TestObjectRec object() {
124131
};
125132
}
126133

134+
static class QueryList {
135+
@GraphQLField
136+
public TestObjectList object() {
137+
return new TestObjectList();
138+
};
139+
}
140+
127141
static class QueryIface {
128142
@GraphQLField
129143
public TestObject iface() {
@@ -167,6 +181,15 @@ public void queryWithRecursion() {
167181
assertEquals(((Map<String, Map<String, String>>) result.getData()).get("object").get("value"), "rectesta");
168182
}
169183

184+
@Test
185+
public void queryWithList() {
186+
GraphQLSchema schema = newSchema().query(GraphQLAnnotations.object(QueryList.class)).build();
187+
188+
GraphQL graphQL = GraphQL.newGraphQL(schema).build();
189+
ExecutionResult result = graphQL.execute("{ object { value(input:[[[{key:\"test\"}]]]) } }", new QueryList());
190+
assertEquals(((Map<String, Map<String, String>>) result.getData()).get("object").get("value"), "testa");
191+
}
192+
170193
@Test
171194
public void queryWithInterface() {
172195
GraphQLSchema schema = newSchema().query(GraphQLAnnotations.object(QueryIface.class)).build(Collections.singleton(GraphQLAnnotations.object(TestObject.class)));

0 commit comments

Comments
 (0)