use of io.smallrye.graphql.client.core.Document in project smallrye-graphql by smallrye.
the class VariablesTest method variablesFlatTest.
@Test
public void variablesFlatTest() throws IOException, URISyntaxException {
String expectedRequest = Utils.getResourceFileContent("core/variablesFlat.graphql");
Variable varBool = var("varBool", nonNull(GQL_BOOL));
Variable varDouble = var("varDouble", nonNull(GQL_FLOAT));
Variable varString = var("varString", nonNull(GQL_STRING));
Document document = document(operation(QUERY, vars(varBool, varDouble, varString), field("withArgWithSubField", args(arg("aString", varString), arg("aDouble", varDouble), arg("aBool", varBool)), field("bool"), field("double"), field("string"))));
String generatedRequest = document.build();
AssertGraphQL.assertEquivalentGraphQLRequest(expectedRequest, generatedRequest);
}
use of io.smallrye.graphql.client.core.Document in project smallrye-graphql by smallrye.
the class DynamicClientSingleOperationsTestBase method testSimpleQueryWithArgument.
@Test
public void testSimpleQueryWithArgument() throws ExecutionException, InterruptedException {
Document document = document(operation(field("queryWithArgument", args(arg("number", 12)), field("integer"))));
Response response = client.executeSync(document);
JsonObject data = response.getData();
assertEquals(12, data.getJsonObject("queryWithArgument").getInt("integer"));
}
use of io.smallrye.graphql.client.core.Document in project smallrye-graphql by smallrye.
the class DynamicClientSingleOperationsTestBase method testTwoQueriesInOneOperationSync.
@Test
public void testTwoQueriesInOneOperationSync() throws ExecutionException, InterruptedException {
Document document = document(operation(field("simple", field("string"), field("integer")), field("simple2", field("string"), field("integer"))));
JsonObject data = client.executeSync(document).getData();
assertEquals("asdf", data.getJsonObject("simple").getString("string"));
assertEquals(30, data.getJsonObject("simple").getInt("integer"));
assertEquals("asdfgh", data.getJsonObject("simple2").getString("string"));
assertEquals(31, data.getJsonObject("simple2").getInt("integer"));
}
use of io.smallrye.graphql.client.core.Document in project smallrye-graphql by smallrye.
the class DynamicClientSingleOperationsTestBase method testSimpleQueryAsync.
@Test
public void testSimpleQueryAsync() {
Document document = document(operation(field("simple", field("string"), field("integer"))));
JsonObject data = client.executeAsync(document).await().atMost(Duration.ofSeconds(30)).getData();
assertEquals("asdf", data.getJsonObject("simple").getString("string"));
assertEquals(30, data.getJsonObject("simple").getInt("integer"));
}
use of io.smallrye.graphql.client.core.Document in project smallrye-graphql by smallrye.
the class DynamicClientFragmentTest method testInlineFragment.
@Test
public void testInlineFragment() throws ExecutionException, InterruptedException {
Document document = document(operation(field("vehicles", field("wheelsCount"), on("Car", field("engineCylinders")), on("Bicycle", field("frameSize")))));
validateResponse(client.executeSync(document));
}
Aggregations