Skip to content

Commit

Permalink
Add test coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
igdianov committed Nov 29, 2024
1 parent 7770e99 commit b8f7121
Showing 1 changed file with 40 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1574,6 +1574,46 @@ public void testGraphqlAggregateTasksQuery() {
assertThat(result.getData().toString()).isEqualTo(expected);
}

@Test
public void testGraphqlPagedQueryWithAliasedResults() {
GraphQLQueryRequest query = new GraphQLQueryRequest(
"""
query {
page1: Tasks(page: {start: 1, limit: 2}) {
select {
id
name
}
}
page2: Tasks(page: {start: 3, limit: 2}) {
select {
id
name
}
}
}
"""
);

ResponseEntity<GraphQLQueryResult> entity = rest.postForEntity(
GRAPHQL_URL,
new HttpEntity<>(query, authHeaders),
GraphQLQueryResult.class
);

assertThat(entity.getStatusCode()).describedAs(entity.toString()).isEqualTo(HttpStatus.OK);

GraphQLQueryResult result = entity.getBody();

assertThat(result).isNotNull();
assertThat(result.getErrors()).isNull();

var expected =
"{page1={select=[{id=1, name=task1}, {id=2, name=task2}]}, page2={select=[{id=5, name=task5}, {id=6, name=task6}]}}";

assertThat(result.getData().toString()).isEqualTo(expected);
}

public static StringObjectMapBuilder mapBuilder() {
return new StringObjectMapBuilder();
}
Expand Down

0 comments on commit b8f7121

Please sign in to comment.