Search in sources :

Example 1 with QueryOptions

use of com.example.graphql.client.betterbotz.type.QueryOptions in project stargate by stargate.

the class ApolloTestBase method getProducts.

protected static Optional<GetProductsWithFilterQuery.Products> getProducts(ApolloClient client, int pageSize, Optional<String> pageState) {
    ProductsFilterInput filterInput = ProductsFilterInput.builder().build();
    QueryOptions.Builder optionsBuilder = QueryOptions.builder().pageSize(pageSize).consistency(QueryConsistency.LOCAL_QUORUM);
    pageState.ifPresent(optionsBuilder::pageState);
    QueryOptions options = optionsBuilder.build();
    GetProductsWithFilterQuery query = GetProductsWithFilterQuery.builder().filter(filterInput).options(options).build();
    GetProductsWithFilterQuery.Data result = getObservable(client.query(query));
    assertThat(result.getProducts()).hasValueSatisfying(products -> {
        assertThat(products.getValues()).hasValueSatisfying(values -> {
            assertThat(values).hasSizeLessThanOrEqualTo(pageSize);
        });
    });
    return result.getProducts();
}
Also used : GetProductsWithFilterQuery(com.example.graphql.client.betterbotz.products.GetProductsWithFilterQuery) ProductsFilterInput(com.example.graphql.client.betterbotz.type.ProductsFilterInput) QueryOptions(com.example.graphql.client.betterbotz.type.QueryOptions)

Example 2 with QueryOptions

use of com.example.graphql.client.betterbotz.type.QueryOptions in project stargate by stargate.

the class ApolloTestBase method getProductValues.

protected List<GetProductsWithFilterQuery.Value> getProductValues(ApolloClient client, String productId) {
    ProductsFilterInput filterInput = ProductsFilterInput.builder().id(UuidFilterInput.builder().eq(productId).build()).build();
    QueryOptions options = QueryOptions.builder().consistency(QueryConsistency.LOCAL_QUORUM).build();
    GetProductsWithFilterQuery query = GetProductsWithFilterQuery.builder().filter(filterInput).options(options).build();
    GetProductsWithFilterQuery.Data result = getObservable(client.query(query));
    assertThat(result.getProducts()).isPresent();
    GetProductsWithFilterQuery.Products products = result.getProducts().get();
    assertThat(products.getValues()).isPresent();
    return products.getValues().get();
}
Also used : GetProductsWithFilterQuery(com.example.graphql.client.betterbotz.products.GetProductsWithFilterQuery) ProductsFilterInput(com.example.graphql.client.betterbotz.type.ProductsFilterInput) QueryOptions(com.example.graphql.client.betterbotz.type.QueryOptions)

Aggregations

GetProductsWithFilterQuery (com.example.graphql.client.betterbotz.products.GetProductsWithFilterQuery)2 ProductsFilterInput (com.example.graphql.client.betterbotz.type.ProductsFilterInput)2 QueryOptions (com.example.graphql.client.betterbotz.type.QueryOptions)2