|
|
@@ -1,5 +1,5 @@
|
|
|
-import { Observable } from 'rxjs';
|
|
|
-import { map } from 'rxjs/operators';
|
|
|
+import { QueryRef } from 'apollo-angular';
|
|
|
+
|
|
|
import { ID } from '../../../../../../shared/shared-types';
|
|
|
import { getProductById } from '../../../common/queries/get-product-by-id';
|
|
|
import { getProductList } from '../../../common/queries/get-product-list';
|
|
|
@@ -8,24 +8,23 @@ import {
|
|
|
GetProductByIdQueryVariables,
|
|
|
GetProductListQuery,
|
|
|
GetProductListQueryVariables,
|
|
|
+ LanguageCode,
|
|
|
} from '../../../common/types/gql-generated-types';
|
|
|
+
|
|
|
import { BaseDataService } from './base-data.service';
|
|
|
|
|
|
export class ProductDataService {
|
|
|
|
|
|
constructor(private baseDataService: BaseDataService) {}
|
|
|
|
|
|
- getProducts(take: number = 10, skip: number = 0): Observable<GetProductListQuery['products']> {
|
|
|
- return this.baseDataService.query<GetProductListQuery, GetProductListQueryVariables>(getProductList, { take, skip }).pipe(
|
|
|
- map(data => data.products),
|
|
|
- );
|
|
|
+ getProducts(take: number = 10, skip: number = 0): QueryRef<GetProductListQuery, GetProductListQueryVariables> {
|
|
|
+ return this.baseDataService
|
|
|
+ .query<GetProductListQuery, GetProductListQueryVariables>(getProductList, { take, skip, languageCode: LanguageCode.en });
|
|
|
}
|
|
|
|
|
|
- getProduct(id: ID): Observable<GetProductByIdQuery['product']> {
|
|
|
+ getProduct(id: ID): any {
|
|
|
const stringId = id.toString();
|
|
|
- return this.baseDataService.query<GetProductByIdQuery, GetProductByIdQueryVariables>(getProductById, { id: stringId }).pipe(
|
|
|
- map(data => data.product),
|
|
|
- );
|
|
|
+ return this.baseDataService.query<GetProductByIdQuery, GetProductByIdQueryVariables>(getProductById, { id: stringId });
|
|
|
}
|
|
|
|
|
|
}
|