use of com.example.graphql.client.betterbotz.atomic.ProductsAndOrdersMutation in project stargate by stargate.
the class AtomicDirectiveTest method multipleOptionsWithAtomicDirectiveShouldReturnErrorResponse.
@Test
@DisplayName("Multiple options with atomic directive should return error response")
public void multipleOptionsWithAtomicDirectiveShouldReturnErrorResponse() {
ApolloClient client = getApolloClient("/graphql/" + keyspace);
ProductsAndOrdersMutation mutation = ProductsAndOrdersMutation.builder().productValue(ProductsInput.builder().id(Uuids.random().toString()).prodName("prod 1").price("1").name("prod1").created(now()).build()).productOptions(MutationOptions.builder().consistency(MutationConsistency.ALL).build()).orderValue(OrdersInput.builder().prodName("prod 1").customerName("cust 1").description("my description").build()).orderOptions(MutationOptions.builder().consistency(MutationConsistency.LOCAL_QUORUM).build()).build();
GraphQLTestException ex = catchThrowableOfType(() -> getObservable(client.mutate(mutation)), GraphQLTestException.class);
assertThat(ex).isNotNull();
assertThat(ex.errors).hasSize(2).first().extracting(Error::getMessage).asString().contains("options can only de defined once in an @atomic mutation selection");
}
use of com.example.graphql.client.betterbotz.atomic.ProductsAndOrdersMutation in project stargate by stargate.
the class AtomicDirectiveTest method multipleMutationsWithAtomicDirectiveShouldReturnErrorResponse.
@Test
@DisplayName("When invalid, multiple mutations with atomic directive should return error response")
public void multipleMutationsWithAtomicDirectiveShouldReturnErrorResponse() {
ApolloClient client = getApolloClient("/graphql/" + keyspace);
ProductsAndOrdersMutation mutation = ProductsAndOrdersMutation.builder().productValue(// The mutation is invalid as parts of the primary key are missing
ProductsInput.builder().id(UUID.randomUUID().toString()).prodName("prodName sample").customerName("customer name").build()).orderValue(OrdersInput.builder().prodName("a").customerName("b").description("c").build()).build();
GraphQLTestException ex = catchThrowableOfType(() -> getObservable(client.mutate(mutation)), GraphQLTestException.class);
assertThat(ex).isNotNull();
assertThat(ex.errors).hasSize(2).first().extracting(Error::getMessage).asString().contains("Some clustering keys are missing");
}
use of com.example.graphql.client.betterbotz.atomic.ProductsAndOrdersMutation in project stargate by stargate.
the class ApolloTest method shouldSupportMultipleMutationsWithAtomicDirective.
@Test
@DisplayName("Should execute multiple mutations with atomic directive")
public void shouldSupportMultipleMutationsWithAtomicDirective() {
UUID id = UUID.randomUUID();
String productName = "prod " + id;
String customer = "cust " + id;
String price = "123";
String description = "desc " + id;
ApolloClient client = getApolloClient("/graphql/" + keyspace);
ProductsAndOrdersMutation mutation = ProductsAndOrdersMutation.builder().productValue(ProductsInput.builder().id(id.toString()).prodName(productName).price(price).name(productName).customerName(customer).created(now()).description(description).build()).orderValue(OrdersInput.builder().prodName(productName).customerName(customer).price(price).description(description).build()).build();
getObservable(client.mutate(mutation));
assertThat(session.execute(SimpleStatement.newInstance("SELECT * FROM \"Products\" WHERE id = ?", id)).one()).isNotNull().extracting(r -> r.getString("\"prodName\""), r -> r.getString("description")).containsExactly(productName, description);
assertThat(session.execute(SimpleStatement.newInstance("SELECT * FROM \"Orders\" WHERE \"prodName\" = ?", productName)).one()).isNotNull().extracting(r -> r.getString("\"customerName\""), r -> r.getString("description")).containsExactly(customer, description);
}
Aggregations