use of io.smallrye.graphql.client.core.Document in project smallrye-graphql by smallrye.
the class VariablesTest method variablesDefaultValueTest.
@Test
public void variablesDefaultValueTest() throws IOException, URISyntaxException {
String expectedRequest = Utils.getResourceFileContent("core/variablesDefaultValue.graphql");
Variable varName = var("name", GQL_STRING, "Lee Byron");
Document document = document(operation(QUERY, vars(varName), field("helloYou", arg("name", varName))));
String generatedRequest = document.build();
AssertGraphQL.assertEquivalentGraphQLRequest(expectedRequest, generatedRequest);
}
use of io.smallrye.graphql.client.core.Document in project smallrye-graphql by smallrye.
the class VariablesTest method variablesInInputObjectTest.
@Test
public void variablesInInputObjectTest() throws IOException, URISyntaxException {
String expectedRequest = Utils.getResourceFileContent("core/variablesInInputObject.graphql");
Variable varBool = var("varBool", nonNull(GQL_BOOL));
Variable varInt = var("varInt", nonNull(GQL_INT));
Variable varFloat = var("varFloat", nonNull(GQL_FLOAT));
Variable varString = var("varString", nonNull(GQL_STRING));
Variable varID = var("varID", GQL_ID);
Document document = document(operation(QUERY, vars(varBool, varInt, varFloat, varString, varID), field("basicScalarHolder", args(arg("basicScalarHolder", inputObject(prop("bool", varBool), prop("int", varInt), prop("float", varFloat), prop("string", varString), prop("iD", varID)))), field("bool"), field("int"), field("float"), field("string"), field("iD"))));
String generatedRequest = document.build();
AssertGraphQL.assertEquivalentGraphQLRequest(expectedRequest, generatedRequest);
}
use of io.smallrye.graphql.client.core.Document in project quarkus-quickstarts by quarkusio.
the class StarWarsResource method getAllFilmsUsingDynamicClient.
@GET
@Path("/dynamic")
@Produces(MediaType.APPLICATION_JSON)
@Blocking
public List<Film> getAllFilmsUsingDynamicClient() throws Exception {
Document query = document(operation(field("allFilms", field("films", field("title"), field("planetConnection", field("planets", field("name")))))));
Response response = dynamicClient.executeSync(query);
// translate it into an instance of the corresponding model class
return response.getObject(FilmConnection.class, "allFilms").getFilms();
}
use of io.smallrye.graphql.client.core.Document in project smallrye-graphql by smallrye.
the class MyClientUsage method execute.
public void execute() throws ExecutionException, InterruptedException {
Document document = document(operation(field("allHeroesIn", args(arg("location", "Outer Space")), field("name"), field("superPowers"))));
// <2>
Response response = client.executeSync(document);
// <3>
JsonArray heroesArray = response.getData().getJsonArray("allHeroesIn");
// <4>
List<SuperHero> heroes = response.getList(SuperHero.class, "allHeroesIn");
}
use of io.smallrye.graphql.client.core.Document in project smallrye-graphql by smallrye.
the class EnumsTest method enumsTest.
@Test
public void enumsTest() {
String expectedRequest = Utils.getResourceFileContent("core/enums.graphql");
Document document = document(operation(QUERY, field("exams", args(arg("result", gqlEnum("PASSED"))), field("score"))));
String generatedRequest = document.build();
AssertGraphQL.assertEquivalentGraphQLRequest(expectedRequest, generatedRequest);
}
Aggregations