Search in sources :

Example 21 with Document

use of io.smallrye.graphql.client.core.Document in project smallrye-graphql by smallrye.

the class EnumsTest method invalidValueTrue.

@Test
public void invalidValueTrue() {
    try {
        Document document = document(operation(QUERY, field("exams", args(arg("result", gqlEnum("true"))), field("score"))));
        fail("Invalid enum value should not be accepted");
    } catch (BuildException be) {
    // OK
    }
}
Also used : BuildException(io.smallrye.graphql.client.core.exceptions.BuildException) Document(io.smallrye.graphql.client.core.Document) Test(org.junit.jupiter.api.Test)

Example 22 with Document

use of io.smallrye.graphql.client.core.Document in project smallrye-graphql by smallrye.

the class FragmentsTest method fragmentTest.

@Test
public void fragmentTest() {
    String expectedRequest = Utils.getResourceFileContent("core/fragments.graphql");
    Document document = document(operation(QUERY, field("people", fragmentRef("sensitiveFields"))), fragment("sensitiveFields").on("Person", field("age"), field("religion")));
    String generatedRequest = document.build();
    AssertGraphQL.assertEquivalentGraphQLRequest(expectedRequest, generatedRequest);
}
Also used : Document(io.smallrye.graphql.client.core.Document) Test(org.junit.jupiter.api.Test)

Example 23 with Document

use of io.smallrye.graphql.client.core.Document in project smallrye-graphql by smallrye.

the class InlineFragmentsTest method inlineFragmentTest.

@Test
public void inlineFragmentTest() {
    String expectedRequest = Utils.getResourceFileContent("core/inlinefragments.graphql");
    Document document = document(operation(QUERY, field("regularField"), on("Type1", field("type1Field1"), field("type1Field2")), on("Type2", field("type2Field"))));
    String generatedRequest = document.build();
    AssertGraphQL.assertEquivalentGraphQLRequest(expectedRequest, generatedRequest);
}
Also used : Document(io.smallrye.graphql.client.core.Document) Test(org.junit.jupiter.api.Test)

Example 24 with Document

use of io.smallrye.graphql.client.core.Document in project smallrye-graphql by smallrye.

the class NestedObjectsTest method nestedObjectsTest.

@Test
public void nestedObjectsTest() throws IOException, URISyntaxException {
    String expectedRequest = Utils.getResourceFileContent("core/nestedObjects.graphql");
    InputObject baseObject0 = inputObject(prop("level", 0), prop("name", "level 0"), prop("levelLineage", new byte[] {}), prop("nestedObjectLineage", new InputObject[] {}));
    InputObject baseObject1 = inputObject(prop("level", 1), prop("name", "level 1"), prop("levelLineage", new byte[] { 0 }), prop("nestedObjectLineage", new InputObject[] { baseObject0 }));
    InputObject baseObject2 = inputObject(prop("level", 2), prop("name", "level 2"), prop("levelLineage", new byte[] { 0, 1 }), prop("nestedObjectLineage", new InputObject[] { baseObject0, baseObject1 }));
    InputObject baseObject3 = inputObject(prop("level", 3), prop("name", "level 3"), prop("levelLineage", new byte[] { 0, 1, 2 }), prop("nestedObjectLineage", new InputObject[] { baseObject0, baseObject1, baseObject2 }));
    /*
         * We use cloning hereafter to avoid circular references.
         */
    InputObject object3 = inputObject();
    object3.setInputObjectFields(new ArrayList<>(baseObject3.getInputObjectFields()));
    object3.getInputObjectFields().add(prop("nestedObject", null));
    InputObject object2 = inputObject();
    object2.setInputObjectFields(new ArrayList<>(baseObject2.getInputObjectFields()));
    object2.getInputObjectFields().add(prop("nestedObject", object3));
    InputObject object1 = inputObject();
    object1.setInputObjectFields(new ArrayList<>(baseObject1.getInputObjectFields()));
    object1.getInputObjectFields().add(prop("nestedObject", object2));
    InputObject object0 = inputObject();
    object0.setInputObjectFields(new ArrayList<>(baseObject0.getInputObjectFields()));
    object0.getInputObjectFields().add(prop("nestedObject", object1));
    Document document = document(operation(MUTATION, "nestedObjects", field("nestedObjectHolder", args(arg("nestedObjectHolder", object0)), field("level"), field("name"), field("levelLineage"), field("nestedObjectLineage", field("level"), field("name"), field("levelLineage"), field("nestedObjectLineage", field("level"), field("name"), field("levelLineage"), field("nestedObjectLineage", field("level"), field("name"), field("levelLineage"), field("nestedObjectLineage", field("level"), field("name"), field("levelLineage"))))), field("nestedObject", field("level"), field("name"), field("levelLineage"), field("nestedObjectLineage", field("level"), field("name"), field("levelLineage"), field("nestedObjectLineage", field("level"), field("name"), field("levelLineage"), field("nestedObjectLineage", field("level"), field("name"), field("levelLineage"), field("nestedObjectLineage", field("level"), field("name"), field("levelLineage"))))), field("nestedObject", field("level"), field("name"), field("levelLineage"), field("nestedObjectLineage", field("level"), field("name"), field("levelLineage"), field("nestedObjectLineage", field("level"), field("name"), field("levelLineage"), field("nestedObjectLineage", field("level"), field("name"), field("levelLineage"), field("nestedObjectLineage", field("level"), field("name"), field("levelLineage"))))), field("nestedObject", field("level"), field("name"), field("levelLineage"), field("nestedObjectLineage", field("level"), field("name"), field("levelLineage"), field("nestedObjectLineage", field("level"), field("name"), field("levelLineage"), field("nestedObjectLineage", field("level"), field("name"), field("levelLineage"), field("nestedObjectLineage", field("level"), field("name"), field("levelLineage"))))), field("nestedObject", field("level"), field("name"), field("levelLineage"), field("nestedObjectLineage", field("level"), field("name"), field("levelLineage"), field("nestedObjectLineage", field("level"), field("name"), field("levelLineage"), field("nestedObjectLineage", field("level"), field("name"), field("levelLineage"), field("nestedObjectLineage", field("level"), field("name"), field("levelLineage"))))), field("nestedObject", field("level"), field("name"), field("levelLineage"), field("nestedObjectLineage", field("level"), field("name"), field("levelLineage"), field("nestedObjectLineage", field("level"), field("name"), field("levelLineage"), field("nestedObjectLineage", field("level"), field("name"), field("levelLineage"), field("nestedObjectLineage", field("level"), field("name"), field("levelLineage")))))))))))));
    String generatedRequest = document.build();
    // System.out.println(generatedRequest);
    AssertGraphQL.assertEquivalentGraphQLRequest(expectedRequest, generatedRequest);
}
Also used : InputObject(io.smallrye.graphql.client.core.InputObject) Document(io.smallrye.graphql.client.core.Document) Test(org.junit.jupiter.api.Test)

Example 25 with Document

use of io.smallrye.graphql.client.core.Document in project smallrye-graphql by smallrye.

the class ScalarsTest method scalarsTest.

@Test
public void scalarsTest() throws IOException, URISyntaxException {
    String expectedRequest = Utils.getResourceFileContent("core/scalars.graphql");
    Document document = document(operation(MUTATION, "scalarHolderMutation", field("scalarHolder", args(arg("scalarHolder", inputObject(prop("booleanPrimitive", false), prop("booleanObject", Boolean.valueOf(true)), prop("bytePrimitive", Byte.MIN_VALUE), prop("byteObject", Byte.valueOf(Byte.MAX_VALUE)), prop("shortPrimitive", Short.MIN_VALUE), prop("shortObject", Short.valueOf(Short.MAX_VALUE)), prop("intPrimitive", Integer.MIN_VALUE + 1), prop("intObject", Integer.valueOf(Integer.MAX_VALUE)), prop("longPrimitive", Long.MIN_VALUE), prop("longObject", Long.valueOf(Long.MAX_VALUE)), prop("floatPrimitive", Float.MIN_VALUE), prop("floatObject", Float.valueOf(Float.MAX_VALUE)), prop("doublePrimitive", Double.MIN_VALUE), prop("doubleObject", Double.valueOf(Double.MAX_VALUE)), prop("bigInteger", BigInteger.TEN), prop("bigDecimal", BigDecimal.TEN), prop("charPrimitive", 'a'), prop("charObject", Character.valueOf('Z')), prop("stringObject", "Hello World !")))), field("booleanPrimitive"), field("booleanObject"), field("bytePrimitive"), field("byteObject"), field("shortPrimitive"), field("shortObject"), field("intPrimitive"), field("intObject"), field("longPrimitive"), field("longObject"), field("floatPrimitive"), field("floatObject"), field("doublePrimitive"), field("doubleObject"), field("bigInteger"), field("bigDecimal"), field("charPrimitive"), field("charObject"), field("stringObject"))));
    String generatedRequest = document.build();
    AssertGraphQL.assertEquivalentGraphQLRequest(expectedRequest, generatedRequest);
}
Also used : Document(io.smallrye.graphql.client.core.Document) Test(org.junit.jupiter.api.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