use of io.smallrye.graphql.client.Response in project smallrye-graphql by smallrye.
the class RecordAsInputToDynamicClientTest method testSimpleRecord.
@Test
public void testSimpleRecord() throws Exception {
try (DynamicGraphQLClient client = new VertxDynamicGraphQLClientBuilder().url(testingURL.toString() + "graphql").build()) {
Response response = client.executeSync("query { simple {a b} }");
SimpleRecord result = response.getObject(SimpleRecord.class, "simple");
assertEquals("a", result.a());
assertEquals("b", result.b());
}
}
use of io.smallrye.graphql.client.Response in project smallrye-graphql by smallrye.
the class MyClientUsageString method execute.
public void execute() throws ExecutionException, InterruptedException {
// <1>
String queryWithInlineVariables = "query {" + " allHeroesIn(location: \"Outer Space\") {" + " name" + " superPowers" + " }" + "}";
Response response = client.executeSync(queryWithInlineVariables);
// <2>
String queryWithExtractedVariables = "query($loc: String) {" + " allHeroesIn(location: $loc) {" + " name" + " superPowers" + " }" + "}";
// <3>
Map<String, Object> variables = new HashMap<>();
variables.put("loc", "Outer Space");
Response response2 = client.executeSync(queryWithExtractedVariables, variables);
}
use of io.smallrye.graphql.client.Response in project smallrye-graphql by smallrye.
the class DynamicClientSingleOperationsTestBase method testRenamedField.
/**
* Parsing the response into a model class that contains a renamed field (using @Name)
*/
@Test
public void testRenamedField() throws ExecutionException, InterruptedException {
Document document = document(operation(field("withRenamedField", field("renamedField:specialName"), field("string"))));
Response response = client.executeSync(document);
Dummy ret = response.getObject(Dummy.class, "withRenamedField");
assertEquals("foo", ret.getRenamedField());
}
use of io.smallrye.graphql.client.Response in project smallrye-graphql by smallrye.
the class DynamicClientSingleOperationsTestBase method testListWithRenamedField.
@Test
public void testListWithRenamedField() throws ExecutionException, InterruptedException {
Document document = document(operation(field("listWithRenamedField", field("renamedField:specialName"), field("string"))));
Response response = client.executeSync(document);
List<Dummy> ret = response.getList(Dummy.class, "listWithRenamedField");
assertEquals("foo", ret.get(0).getRenamedField());
assertEquals("foo2", ret.get(1).getRenamedField());
}
use of io.smallrye.graphql.client.Response in project smallrye-graphql by smallrye.
the class AbstractDynamicClientSubscriptionTest method testCounting.
@Test
public void testCounting() {
Document document = document(operation(OperationType.SUBSCRIPTION, field("countToFive")));
List<Response> responses = client.subscription(document).subscribe().asStream().collect(Collectors.toList());
for (int i = 0; i < 5; i++) {
Response response = responses.get(i);
assertEquals(i, response.getData().getInt("countToFive"));
assertNoErrors(response.getErrors());
}
}
Aggregations