Skip to content

Commit

Permalink
feat(all): provide cacheable operations with function (#3282)
Browse files Browse the repository at this point in the history
  • Loading branch information
griest024 authored Oct 16, 2024
1 parent 19f05b0 commit e9fc8dc
Show file tree
Hide file tree
Showing 10 changed files with 30 additions and 89 deletions.
22 changes: 6 additions & 16 deletions libs/category/driver/magento/src/category-driver.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
} from '@angular/core';

import { provideDaffCategoryDriver } from '@daffodil/category/driver';
import { DAFF_MAGENTO_CACHEABLE_OPERATIONS } from '@daffodil/driver/magento';
import { provideManyDaffMagentoCacheableOperations } from '@daffodil/driver/magento';
import { DAFF_MAGENTO_GET_FILTER_TYPES_QUERY_NAME } from '@daffodil/product/driver/magento';

import { DaffMagentoCategoryService } from './category.service';
Expand Down Expand Up @@ -42,21 +42,11 @@ export class DaffCategoryMagentoDriverModule {
DaffMagentoCategoryResponseTransformService,
DaffMagentoCategoryTransformerService,
DaffMagentoAppliedFiltersTransformService,
{
provide: DAFF_MAGENTO_CACHEABLE_OPERATIONS,
useValue: DAFF_MAGENTO_GET_FILTER_TYPES_QUERY_NAME,
multi: true,
},
{
provide: DAFF_MAGENTO_CACHEABLE_OPERATIONS,
useValue: DAFF_MAGENTO_GET_CATEGORY_AND_PRODUCTS_QUERY_NAME,
multi: true,
},
{
provide: DAFF_MAGENTO_CACHEABLE_OPERATIONS,
useValue: DAFF_MAGENTO_RESOLVE_CATEGORY_URL_QUERY_NAME,
multi: true,
},
provideManyDaffMagentoCacheableOperations(
DAFF_MAGENTO_GET_FILTER_TYPES_QUERY_NAME,
DAFF_MAGENTO_GET_CATEGORY_AND_PRODUCTS_QUERY_NAME,
DAFF_MAGENTO_RESOLVE_CATEGORY_URL_QUERY_NAME,
),
provideMagentoCategoryConfig(config),
],
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
ModuleWithProviders,
} from '@angular/core';

import { DAFF_MAGENTO_CACHEABLE_OPERATIONS } from '@daffodil/driver/magento';
import { provideDaffMagentoCacheableOperation } from '@daffodil/driver/magento';
import { provideDaffExternalRouterDriver } from '@daffodil/external-router/driver';

import { DAFF_MAGENTO_RESOLVE_URL_QUERY_NAME } from './graphql/queries/resolve-url-v2.4.1';
Expand Down Expand Up @@ -39,11 +39,7 @@ export class DaffExternalRouterDriverMagentoModule {
ngModule: DaffExternalRouterDriverMagentoModule,
providers: [
provideDaffExternalRouterDriver(DaffExternalRouterMagentoDriver),
{
provide: DAFF_MAGENTO_CACHEABLE_OPERATIONS,
useValue: DAFF_MAGENTO_RESOLVE_URL_QUERY_NAME,
multi: true,
},
provideDaffMagentoCacheableOperation(DAFF_MAGENTO_RESOLVE_URL_QUERY_NAME),
],
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
ModuleWithProviders,
} from '@angular/core';

import { DAFF_MAGENTO_CACHEABLE_OPERATIONS } from '@daffodil/driver/magento';
import { provideDaffMagentoCacheableOperation } from '@daffodil/driver/magento';
import { provideDaffExternalRouterDriver } from '@daffodil/external-router/driver';

import { DAFF_MAGENTO_RESOLVE_URL_QUERY_NAME } from './graphql/queries/resolve-url-v2.4.2';
Expand Down Expand Up @@ -40,11 +40,7 @@ export class DaffExternalRouterDriverMagentoModule {
ngModule: DaffExternalRouterDriverMagentoModule,
providers: [
provideDaffExternalRouterDriver(DaffExternalRouterMagentoDriver),
{
provide: DAFF_MAGENTO_CACHEABLE_OPERATIONS,
useValue: DAFF_MAGENTO_RESOLVE_URL_QUERY_NAME,
multi: true,
},
provideDaffMagentoCacheableOperation(DAFF_MAGENTO_RESOLVE_URL_QUERY_NAME),
],
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
ModuleWithProviders,
} from '@angular/core';

import { DAFF_MAGENTO_CACHEABLE_OPERATIONS } from '@daffodil/driver/magento';
import { provideDaffMagentoCacheableOperation } from '@daffodil/driver/magento';
import { provideDaffExternalRouterDriver } from '@daffodil/external-router/driver';

import { DAFF_MAGENTO_RESOLVE_URL_QUERY_NAME } from './graphql/queries/resolve';
Expand Down Expand Up @@ -40,11 +40,7 @@ export class DaffExternalRouterDriverMagentoModule {
ngModule: DaffExternalRouterDriverMagentoModule,
providers: [
provideDaffExternalRouterDriver(DaffExternalRouterMagentoDriver),
{
provide: DAFF_MAGENTO_CACHEABLE_OPERATIONS,
useValue: DAFF_MAGENTO_RESOLVE_URL_QUERY_NAME,
multi: true,
},
provideDaffMagentoCacheableOperation(DAFF_MAGENTO_RESOLVE_URL_QUERY_NAME),
],
};
}
Expand Down
14 changes: 3 additions & 11 deletions libs/geography/driver/magento/src/geography-driver.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
ModuleWithProviders,
} from '@angular/core';

import { DAFF_MAGENTO_CACHEABLE_OPERATIONS } from '@daffodil/driver/magento';
import { provideDaffMagentoCacheableOperation } from '@daffodil/driver/magento';
import { provideDaffGeographyDriver } from '@daffodil/geography/driver';

import { DaffGeographyMagentoService } from './geography.service';
Expand All @@ -24,16 +24,8 @@ export class DaffGeographyMagentoDriverModule {
ngModule: DaffGeographyMagentoDriverModule,
providers: [
provideDaffGeographyDriver(DaffGeographyMagentoService),
{
provide: DAFF_MAGENTO_CACHEABLE_OPERATIONS,
useValue: MAGENTO_GET_COUNTRY_QUERY_NAME,
multi: true,
},
{
provide: DAFF_MAGENTO_CACHEABLE_OPERATIONS,
useValue: MAGENTO_GET_COUNTRIES_QUERY_NAME,
multi: true,
},
provideDaffMagentoCacheableOperation(MAGENTO_GET_COUNTRY_QUERY_NAME),
provideDaffMagentoCacheableOperation(MAGENTO_GET_COUNTRIES_QUERY_NAME),
],
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
ModuleWithProviders,
} from '@angular/core';

import { DAFF_MAGENTO_CACHEABLE_OPERATIONS } from '@daffodil/driver/magento';
import { provideDaffMagentoCacheableOperation } from '@daffodil/driver/magento';
import {
provideDaffNavigationDriver,
DaffNavigationTransformer,
Expand Down Expand Up @@ -35,11 +35,7 @@ export class DaffNavigationMagentoDriverModule {
useExisting: DaffMagentoNavigationTransformerService,
},
provideMagentoNavigationDriverConfig(config),
{
provide: DAFF_MAGENTO_CACHEABLE_OPERATIONS,
useValue: DAFF_MAGENTO_GET_CATEGORY_TREE_QUERY_NAME,
multi: true,
},
provideDaffMagentoCacheableOperation(DAFF_MAGENTO_GET_CATEGORY_TREE_QUERY_NAME),
],
};
}
Expand Down
22 changes: 6 additions & 16 deletions libs/product/driver/magento/src/product-driver.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
ModuleWithProviders,
} from '@angular/core';

import { DAFF_MAGENTO_CACHEABLE_OPERATIONS } from '@daffodil/driver/magento';
import { provideManyDaffMagentoCacheableOperations } from '@daffodil/driver/magento';
import { provideDaffProductDriver } from '@daffodil/product/driver';

import { MAGENTO_PRODUCT_CONFIG_DEFAULT } from './config/public_api';
Expand Down Expand Up @@ -32,21 +32,11 @@ export class DaffProductMagentoDriverModule {
ngModule: DaffProductMagentoDriverModule,
providers: [
provideDaffProductDriver(DaffMagentoProductService),
{
provide: DAFF_MAGENTO_CACHEABLE_OPERATIONS,
useValue: DAFF_MAGENTO_GET_ALL_PRODUCTS_QUERY_NAME,
multi: true,
},
{
provide: DAFF_MAGENTO_CACHEABLE_OPERATIONS,
useValue: DAFF_MAGENTO_GET_A_PRODUCT_QUERY_NAME,
multi: true,
},
{
provide: DAFF_MAGENTO_CACHEABLE_OPERATIONS,
useValue: DAFF_MAGENTO_GET_A_PRODUCT_BY_URL_QUERY_NAME,
multi: true,
},
provideManyDaffMagentoCacheableOperations(
DAFF_MAGENTO_GET_ALL_PRODUCTS_QUERY_NAME,
DAFF_MAGENTO_GET_A_PRODUCT_QUERY_NAME,
DAFF_MAGENTO_GET_A_PRODUCT_BY_URL_QUERY_NAME,
),
provideMagentoProductConfig(config),
],
};
Expand Down
8 changes: 2 additions & 6 deletions libs/reviews/driver/magento/src/reviews-driver.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
ModuleWithProviders,
} from '@angular/core';

import { DAFF_MAGENTO_CACHEABLE_OPERATIONS } from '@daffodil/driver/magento';
import { provideDaffMagentoCacheableOperation } from '@daffodil/driver/magento';
import {
provideDaffProductMagentoExtraProductPreviewFragments,
provideDaffProductMagentoExtraProductPreviewTransforms,
Expand Down Expand Up @@ -35,11 +35,7 @@ export class DaffReviewsMagentoDriverModule {
...provideDaffProductMagentoExtraProductPreviewTransforms(
magentoReviewedProductTransform,
),
{
provide: DAFF_MAGENTO_CACHEABLE_OPERATIONS,
useValue: MAGENTO_REVIEWS_LIST_QUERY_NAME,
multi: true,
},
provideDaffMagentoCacheableOperation(MAGENTO_REVIEWS_LIST_QUERY_NAME),
],
};
}
Expand Down
8 changes: 2 additions & 6 deletions libs/search-category/driver/magento/src/driver.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
ModuleWithProviders,
} from '@angular/core';

import { DAFF_MAGENTO_CACHEABLE_OPERATIONS } from '@daffodil/driver/magento';
import { provideDaffMagentoCacheableOperation } from '@daffodil/driver/magento';
import { DAFF_SEARCH_FEDERATED_DRIVERS } from '@daffodil/search/driver/federated';

import { DaffSearchCategoryMagentoDriver } from './category-search.service';
Expand All @@ -18,11 +18,7 @@ import { DAFF_MAGENTO_SEARCH_FOR_CATEGORIES_QUERY_NAME } from './queries/categor
CommonModule,
],
providers: [
{
provide: DAFF_MAGENTO_CACHEABLE_OPERATIONS,
useValue: DAFF_MAGENTO_SEARCH_FOR_CATEGORIES_QUERY_NAME,
multi: true,
},
provideDaffMagentoCacheableOperation(DAFF_MAGENTO_SEARCH_FOR_CATEGORIES_QUERY_NAME),
],
})
export class DaffSearchCategoryMagentoDriverModule {
Expand Down
13 changes: 3 additions & 10 deletions libs/search-product/driver/magento/src/core.module.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
import { CommonModule } from '@angular/common';
import {
NgModule,
ModuleWithProviders,
} from '@angular/core';
import { NgModule } from '@angular/core';

import { DAFF_MAGENTO_CACHEABLE_OPERATIONS } from '@daffodil/driver/magento';
import { provideDaffMagentoCacheableOperation } from '@daffodil/driver/magento';

import { DAFF_MAGENTO_SEARCH_FOR_PRODUCTS_QUERY_NAME } from './queries/product-search';

Expand All @@ -16,11 +13,7 @@ import { DAFF_MAGENTO_SEARCH_FOR_PRODUCTS_QUERY_NAME } from './queries/product-s
CommonModule,
],
providers: [
{
provide: DAFF_MAGENTO_CACHEABLE_OPERATIONS,
useValue: DAFF_MAGENTO_SEARCH_FOR_PRODUCTS_QUERY_NAME,
multi: true,
},
provideDaffMagentoCacheableOperation(DAFF_MAGENTO_SEARCH_FOR_PRODUCTS_QUERY_NAME),
],
})
export class DaffSearchProductMagentoCoreModule {}

0 comments on commit e9fc8dc

Please sign in to comment.