Search in sources :

Example 1 with InsertOrdersWithAtomicMutation

use of com.example.graphql.client.betterbotz.atomic.InsertOrdersWithAtomicMutation in project stargate by stargate.

the class AtomicDirectiveTest method shouldSupportSingleMutationWithAtomicDirective.

@Test
@DisplayName("Should execute single mutation with atomic directive")
public void shouldSupportSingleMutationWithAtomicDirective() {
    UUID id = UUID.randomUUID();
    String productName = "prod " + id;
    String description = "desc " + id;
    String customer = "cust 1";
    ApolloClient client = getApolloClient("/graphql/" + keyspace);
    InsertOrdersWithAtomicMutation mutation = InsertOrdersWithAtomicMutation.builder().value(OrdersInput.builder().prodName(productName).customerName(customer).price("456").description(description).build()).build();
    getObservable(client.mutate(mutation));
    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);
}
Also used : ApolloClient(com.apollographql.apollo.ApolloClient) Assertions.catchThrowableOfType(org.assertj.core.api.Assertions.catchThrowableOfType) MutationConsistency(com.example.graphql.client.betterbotz.type.MutationConsistency) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) Error(com.apollographql.apollo.api.Error) ProductsInput(com.example.graphql.client.betterbotz.type.ProductsInput) InsertOrdersWithAtomicMutation(com.example.graphql.client.betterbotz.atomic.InsertOrdersWithAtomicMutation) UUID(java.util.UUID) SimpleStatement(com.datastax.oss.driver.api.core.cql.SimpleStatement) ApolloClient(com.apollographql.apollo.ApolloClient) OrdersInput(com.example.graphql.client.betterbotz.type.OrdersInput) DisplayName(org.junit.jupiter.api.DisplayName) Test(org.junit.jupiter.api.Test) MutationOptions(com.example.graphql.client.betterbotz.type.MutationOptions) Uuids(com.datastax.oss.driver.api.core.uuid.Uuids) ProductsAndOrdersMutation(com.example.graphql.client.betterbotz.atomic.ProductsAndOrdersMutation) InsertOrdersWithAtomicMutation(com.example.graphql.client.betterbotz.atomic.InsertOrdersWithAtomicMutation) UUID(java.util.UUID) Test(org.junit.jupiter.api.Test) DisplayName(org.junit.jupiter.api.DisplayName)

Aggregations

ApolloClient (com.apollographql.apollo.ApolloClient)1 Error (com.apollographql.apollo.api.Error)1 SimpleStatement (com.datastax.oss.driver.api.core.cql.SimpleStatement)1 Uuids (com.datastax.oss.driver.api.core.uuid.Uuids)1 InsertOrdersWithAtomicMutation (com.example.graphql.client.betterbotz.atomic.InsertOrdersWithAtomicMutation)1 ProductsAndOrdersMutation (com.example.graphql.client.betterbotz.atomic.ProductsAndOrdersMutation)1 MutationConsistency (com.example.graphql.client.betterbotz.type.MutationConsistency)1 MutationOptions (com.example.graphql.client.betterbotz.type.MutationOptions)1 OrdersInput (com.example.graphql.client.betterbotz.type.OrdersInput)1 ProductsInput (com.example.graphql.client.betterbotz.type.ProductsInput)1 UUID (java.util.UUID)1 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)1 Assertions.catchThrowableOfType (org.assertj.core.api.Assertions.catchThrowableOfType)1 DisplayName (org.junit.jupiter.api.DisplayName)1 Test (org.junit.jupiter.api.Test)1