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
}
}
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);
}
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);
}
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);
}
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);
}
Aggregations