Skip to content

Commit 42c646c

Browse files
author
Thomas Draier
committed
Added unit test with more complex input type
1 parent 94f1d70 commit 42c646c

File tree

1 file changed

+19
-5
lines changed

1 file changed

+19
-5
lines changed

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

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,26 @@ public GraphQLObjectType getType(TypeResolutionEnvironment env) {
4141
}
4242
}
4343

44+
static class SubInputObject {
45+
public SubInputObject(String subKey) {
46+
this.subKey = subKey;
47+
}
48+
49+
@GraphQLField
50+
private String subKey;
51+
}
52+
4453
static class InputObject {
45-
public InputObject(HashMap map) {
46-
key = (String) map.get("key");
54+
public InputObject(String key, List<SubInputObject> complex) {
55+
this.key = key;
56+
this.complex = complex;
4757
}
4858

4959
@GraphQLField
5060
private String key;
61+
62+
@GraphQLField
63+
private List<SubInputObject> complex;
5164
}
5265

5366
static class RecursiveInputObject {
@@ -82,7 +95,8 @@ public String value(InputObject input) {
8295
static class TestObjectList {
8396
@GraphQLField
8497
public String value(List<List<List<InputObject>>> input) {
85-
return input.get(0).get(0).get(0).key + "a";
98+
InputObject inputObject = input.get(0).get(0).get(0);
99+
return inputObject.key + "-" + inputObject.complex.get(0).subKey;
86100
}
87101
}
88102

@@ -186,8 +200,8 @@ public void queryWithList() {
186200
GraphQLSchema schema = newSchema().query(GraphQLAnnotations.object(QueryList.class)).build();
187201

188202
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");
203+
ExecutionResult result = graphQL.execute("{ object { value(input:[[[{key:\"test\", complex:[{subKey:\"subtest\"},{subKey:\"subtest2\"}]}]]]) } }", new QueryList());
204+
assertEquals(((Map<String, Map<String, String>>) result.getData()).get("object").get("value"), "test-subtest");
191205
}
192206

193207
@Test

0 commit comments

Comments
 (0)