Skip to content

Commit 200e88c

Browse files
committed
Added additional test to ensure Async option works
1 parent b7013e8 commit 200e88c

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

src/test/java/graphql/annotations/connection/GraphQLEnhancedConnectionTest.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,11 @@ public static class TestListField {
8181
@GraphQLDataFetcher(GoodConnectionDataFetcher.class)
8282
public PaginatedData<Obj> objs;
8383

84+
@GraphQLField
85+
@GraphQLConnection(connection = PaginatedDataConnectionFetcher.class, async = true)
86+
@GraphQLDataFetcher(GoodConnectionDataFetcher.class)
87+
public PaginatedData<Obj> objsAsync;
88+
8489
public TestListField(PaginatedData<Obj> objs) {
8590
this.objs = objs;
8691
}
@@ -148,6 +153,21 @@ public void validDatafetcher_queryForCursors_getValidCursors() throws Exception
148153
assertEquals(edges.get(1).get("cursor"), "2");
149154
}
150155

156+
@Test
157+
public void fetchConnectionAsync() throws Exception {
158+
//Arrange
159+
ExecutionInput executionInput = new ExecutionInput("{ objsAsync(first:2) { edges { cursor } } }",
160+
null, "CONTEXT", null, null);
161+
//Act
162+
ExecutionResult result = graphQL.execute(executionInput);
163+
Map<String, Map<String, List<Map<String, Map<String, Object>>>>> data = result.getData();
164+
List<Map<String, Map<String, Object>>> edges = data.get("objsAsync").get("edges");
165+
166+
//Assert
167+
assertEquals(edges.get(0).get("cursor"), "1");
168+
assertEquals(edges.get(1).get("cursor"), "2");
169+
}
170+
151171
@Test
152172
public void validDatafetcher_queryForValues_returnsValidValues() throws Exception {
153173
//Arrange

0 commit comments

Comments
 (0)