Search in sources :

Example 26 with Document

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);
}
Also used : Variable(io.smallrye.graphql.client.core.Variable) Document(io.smallrye.graphql.client.core.Document) Test(org.junit.jupiter.api.Test)

Example 27 with Document

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"));
}
Also used : Response(io.smallrye.graphql.client.Response) JsonObject(javax.json.JsonObject) Document(io.smallrye.graphql.client.core.Document) Test(org.junit.Test)

Example 28 with Document

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"));
}
Also used : JsonObject(javax.json.JsonObject) Document(io.smallrye.graphql.client.core.Document) Test(org.junit.Test)

Example 29 with Document

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"));
}
Also used : JsonObject(javax.json.JsonObject) Document(io.smallrye.graphql.client.core.Document) Test(org.junit.Test)

Example 30 with Document

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));
}
Also used : Document(io.smallrye.graphql.client.core.Document) Test(org.junit.Test)

Aggregations

Document (io.smallrye.graphql.client.core.Document)31 Test (org.junit.Test)16 Test (org.junit.jupiter.api.Test)13 Response (io.smallrye.graphql.client.Response)11 JsonObject (javax.json.JsonObject)6 Variable (io.smallrye.graphql.client.core.Variable)5 BuildException (io.smallrye.graphql.client.core.exceptions.BuildException)2 Calendar (java.util.Calendar)2 Date (java.util.Date)2 SuperHero (examples.typesafeclient.SuperHero)1 Blocking (io.smallrye.common.annotation.Blocking)1 InputObject (io.smallrye.graphql.client.core.InputObject)1 CountDownLatch (java.util.concurrent.CountDownLatch)1 AtomicReference (java.util.concurrent.atomic.AtomicReference)1 JsonArray (javax.json.JsonArray)1 GET (javax.ws.rs.GET)1 Path (javax.ws.rs.Path)1 Produces (javax.ws.rs.Produces)1 FilmConnection (org.acme.microprofile.graphql.client.model.FilmConnection)1