@Test public void testMagentoError() throws Exception { Utils.setupHttpResponse("magento-graphql-error.json", httpClient, HttpStatus.SC_OK); GraphqlResponse<Query, Error> response = dataService.execute("{dummy}", null); assertEquals(1, response.getErrors().size()); Error error = response.getErrors().get(0); assertEquals("Cannot query field \"categoriess\" on type \"ProductInterface\".", error.getMessage()); assertEquals("graphql", error.getCategory()); assertEquals(1, error.getLocations().size()); Location location = error.getLocations().get(0); assertEquals(23, location.getLine().intValue()); assertEquals(9, location.getColumn().intValue()); }
protected GraphqlResponse<Query, Error> execute(String query, String storeView) { RequestOptions options = requestOptions; if (storeView != null) { Header storeHeader = new BasicHeader(Constants.STORE_HEADER, storeView); options = new RequestOptions() .withGson(requestOptions.getGson()) .withHeaders(Collections.singletonList(storeHeader)); } return baseClient.execute(new GraphqlRequest(query), Query.class, Error.class, options); }
GraphqlDataServiceImpl implements GraphqlDataService { protected GraphqlResponse<Query, Error> execute(String query, String storeView) { RequestOptions options = requestOptions; if (storeView != null) { Header storeHeader = new BasicHeader(Constants.STORE_HEADER, storeView); options = new RequestOptions() .withGson(requestOptions.getGson()) .withHeaders(Collections.singletonList(storeHeader)); } return baseClient.execute(new GraphqlRequest(query), Query.class, Error.class, options); } }
GraphqlDataServiceImpl implements GraphqlDataService { protected GraphqlResponse<Query, Error> execute(String query, String storeView) { RequestOptions options = requestOptions; if (storeView != null) { Header storeHeader = new BasicHeader(Constants.STORE_HEADER, storeView); options = new RequestOptions() .withGson(requestOptions.getGson()) .withHeaders(Collections.singletonList(storeHeader)); } return baseClient.execute(new GraphqlRequest(query), Query.class, Error.class, options); }  }
GraphqlDataServiceImpl implements GraphqlDataService { protected GraphqlResponse<Query, Error> execute(String query, String storeView) { RequestOptions options = requestOptions; if (storeView != null) { Header storeHeader = new BasicHeader(Constants.STORE_HEADER, storeView); options = new RequestOptions() .withGson(requestOptions.getGson()) .withHeaders(Collections.singletonList(storeHeader)); } return baseClient.execute(new GraphqlRequest(query), Query.class, Error.class, options); }  @Activate void activate(GraphqlDataServiceConfiguration conf); @Override ProductInterface getProductBySku(String sku, String storeView); @Override CategoryTree getCategoryById(Integer id, String storeView); @Override CategoryTree getCategoryByPath(String urlPath, String storeView); @Override List<ProductInterface> searchProducts(String text, Integer categoryId, Integer currentPage, Integer pageSize, String storeView); @Override List<CategoryTree> searchCategories(String text, Integer categoryId, Integer currentPage, Integer pageSize, String storeView); @Override CategoryProducts getCategoryProducts(Integer categoryId, Integer currentPage, Integer pageSize, String storeView); @Override String getIdentifier(); }
GraphqlDataServiceImpl implements GraphqlDataService { protected GraphqlResponse<Query, Error> execute(String query, String storeView) { RequestOptions options = requestOptions; if (storeView != null) { Header storeHeader = new BasicHeader(Constants.STORE_HEADER, storeView); options = new RequestOptions() .withGson(requestOptions.getGson()) .withHeaders(Collections.singletonList(storeHeader)); } return baseClient.execute(new GraphqlRequest(query), Query.class, Error.class, options); }  @Activate void activate(GraphqlDataServiceConfiguration conf); @Override ProductInterface getProductBySku(String sku, String storeView); @Override CategoryTree getCategoryById(Integer id, String storeView); @Override CategoryTree getCategoryByPath(String urlPath, String storeView); @Override List<ProductInterface> searchProducts(String text, Integer categoryId, Integer currentPage, Integer pageSize, String storeView); @Override List<CategoryTree> searchCategories(String text, Integer categoryId, Integer currentPage, Integer pageSize, String storeView); @Override CategoryProducts getCategoryProducts(Integer categoryId, Integer currentPage, Integer pageSize, String storeView); @Override String getIdentifier();  }